/* Editor shell — dark glass chrome around the paper. All of it disappears in print. */

* { box-sizing: border-box; }

[hidden] { display: none !important; }

:root {
  --ui-bg-1: #0b1220;
  --ui-bg-2: #14203a;
  --ui-glass: rgba(15, 23, 42, .72);
  --ui-border: rgba(148, 163, 184, .18);
  --ui-ink: #e2e8f0;
  --ui-ink-dim: #94a3b8;
  --ui-blue: #4d8fe0;
  --ui-yellow: #ffcc00;
  --ui-danger: #f87171;
  --ui-radius: 12px;
}

html { background: var(--ui-bg-1); }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ui-ink);
  background:
    radial-gradient(1100px 500px at 15% -10%, rgba(37, 99, 235, .22), transparent 60%),
    radial-gradient(900px 500px at 95% 0%, rgba(255, 204, 0, .10), transparent 55%),
    linear-gradient(170deg, var(--ui-bg-1), var(--ui-bg-2));
  background-attachment: fixed;
  min-height: 100vh;
}

/* ---- toolbar ---------------------------------------------------------- */

#toolbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  z-index: 60;
  background: var(--ui-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--ui-border);
}
#toolbar .brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .01em;
  padding-right: 12px;
  border-right: 1px solid var(--ui-border);
  white-space: nowrap;
}
#toolbar .brand em { color: var(--ui-yellow); font-style: normal; }
#toolbar .brand { display: inline-flex; align-items: center; gap: 8px; }
.brand-icon { width: 22px; height: 22px; }
#toolbar button svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  display: block;
}
#month-label { font-variant-numeric: tabular-nums; }
#toolbar .spacer { flex: 1; }
#toolbar .edit-hint {
  font-size: 12px;
  color: var(--ui-ink-dim);
  animation: hintPulse 3s ease-in-out infinite;
}
@keyframes hintPulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

#toolbar button, .btn {
  border: none;
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
#toolbar #export-pdf {
  background: linear-gradient(180deg, #ffd633, #f5c400);
  color: #1a2b4a;
  box-shadow: 0 0 0 1px rgba(255, 204, 0, .4), 0 4px 18px rgba(255, 204, 0, .25);
}
#toolbar #export-pdf:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px rgba(255, 204, 0, .6), 0 6px 24px rgba(255, 204, 0, .4);
}
#toolbar #export-pdf[disabled] { opacity: .7; cursor: wait; transform: none; }
#toolbar button.secondary {
  background: rgba(255, 255, 255, .08);
  color: var(--ui-ink);
  border: 1px solid var(--ui-border);
}
#toolbar button.secondary:hover { background: rgba(255, 255, 255, .15); }
#savestate { font-size: 11.5px; color: var(--ui-ink-dim); min-width: 52px; }

/* ---- preview ----------------------------------------------------------- */

#preview {
  padding: 80px 16px 70px 16px;
}
#pages-wrap { transform-origin: top center; margin: 0 auto; width: 210mm; }

@media screen {
  .page {
    border-radius: 3px;
    box-shadow:
      0 0 0 1px rgba(148, 163, 184, .14),
      0 12px 40px rgba(2, 6, 23, .55),
      0 2px 10px rgba(2, 6, 23, .4);
  }
}

/* ---- hover affordances on the paper ------------------------------------ */

@media screen {
  [data-blk], h2[data-sec], .text-block, [data-edit], [data-asset] {
    transition: box-shadow .12s ease, background-color .12s ease;
  }
  .page [data-blk]:hover, .page h2[data-sec]:hover {
    box-shadow: 0 0 0 2px rgba(77, 143, 224, .55), 0 0 14px rgba(77, 143, 224, .25);
    border-radius: 3px;
    cursor: pointer;
  }
  .page [data-edit]:hover, .page [data-asset]:hover, .page [data-covel]:hover {
    box-shadow: 0 0 0 2px rgba(255, 204, 0, .65), 0 0 14px rgba(255, 204, 0, .3);
    border-radius: 3px;
    cursor: pointer;
  }
  .page [data-covel]:hover { cursor: move; }
  [contenteditable] {
    outline: none;
    box-shadow: 0 0 0 2px var(--ui-blue), 0 0 18px rgba(77, 143, 224, .45) !important;
    border-radius: 3px;
    cursor: text;
  }

  /* spacer blocks are invisible on paper — show a whisper of them while editing */
  .page .spacer-block:hover::after {
    content: 'spacer';
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 8pt;
    color: rgba(77, 143, 224, .55);
    border: 1px dashed rgba(77, 143, 224, .35);
    border-radius: 3px;
  }

  /* dashed placeholders for missing images */
  .asset-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px dashed rgba(0, 61, 134, .45);
    border-radius: 4px;
    color: rgba(0, 61, 134, .6);
    font-size: 8pt;
    font-weight: 600;
    padding: 0 3mm;
    min-width: 16mm;
    background: rgba(0, 61, 134, .04);
  }
}

/* ---- floating chip (block toolbar) ------------------------------------- */

#chip {
  position: fixed;
  z-index: 70;
  display: flex;
  gap: 3px;
  padding: 4px;
  border-radius: 10px;
  background: var(--ui-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--ui-border);
  box-shadow: 0 8px 24px rgba(2, 6, 23, .5);
  animation: chipIn .12s ease;
}
@keyframes chipIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; } }
#chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  background: rgba(255, 255, 255, .07);
  color: var(--ui-ink);
  border: none;
  border-radius: 7px;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background .1s ease;
}
#chip button svg,
#fmtbar button svg,
#tabletools button svg,
.mp-head button svg,
#popover-close svg,
#drawer-close svg {
  width: 14px;
  height: 14px;
  display: block;
}
#fmtbar button,
#tabletools button,
.mp-head button,
#popover-close,
#drawer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#chip button:hover { background: rgba(77, 143, 224, .45); }
#chip button.danger:hover { background: rgba(248, 113, 113, .45); }
#chip .chip-label {
  font-size: 11px;
  color: var(--ui-ink-dim);
  align-self: center;
  padding: 0 6px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- floating text-format bar (while inline editing) ------------------- */

#fmtbar {
  position: fixed;
  z-index: 74;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border-radius: 10px;
  background: var(--ui-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--ui-border);
  box-shadow: 0 8px 24px rgba(2, 6, 23, .5);
  animation: chipIn .12s ease;
}
#fmtbar button {
  background: rgba(255, 255, 255, .07);
  color: var(--ui-ink);
  border: none;
  border-radius: 7px;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background .1s ease;
}
#fmtbar button:hover { background: rgba(77, 143, 224, .45); }
#fmtbar button.active { background: rgba(77, 143, 224, .5); }
#fmtbar .fb-sep { width: 1px; background: var(--ui-border); height: 18px; margin: 0 3px; }
#fmtbar input[type="color"].fb-color {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

/* ---- popover ------------------------------------------------------------ */

#popover {
  position: fixed;
  z-index: 80;
  width: 380px;
  max-width: calc(100vw - 24px);
  max-height: min(calc(100vh - 84px), 640px);
  display: flex;
  flex-direction: column;
  border-radius: var(--ui-radius);
  background: var(--ui-glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--ui-border);
  box-shadow: 0 0 0 1px rgba(2, 6, 23, .4), 0 18px 50px rgba(2, 6, 23, .65);
  animation: popIn .16s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.94) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
#popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--ui-border);
  cursor: grab;
  user-select: none;
  touch-action: none;
}
#popover-head:active { cursor: grabbing; }
#popover-title { font-size: 13px; font-weight: 700; }
#popover-close, #drawer-close {
  background: none;
  border: none;
  color: var(--ui-ink-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
#popover-close:hover, #drawer-close:hover { background: rgba(255, 255, 255, .1); color: var(--ui-ink); }
#popover-body { padding: 12px 14px; overflow-y: auto; }

/* ---- drawer ------------------------------------------------------------- */

#drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 430px;
  max-width: 92vw;
  z-index: 90;
  display: flex;
  flex-direction: column;
  background: rgba(11, 18, 32, .92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid var(--ui-border);
  box-shadow: -18px 0 50px rgba(2, 6, 23, .6);
  animation: drawerIn .2s ease;
}
@keyframes drawerIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
#drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ui-border);
}
#drawer-title { font-size: 14px; font-weight: 700; }
#drawer-body { padding: 14px 16px 40px 16px; overflow-y: auto; overflow-x: hidden; }

.drawer-group { margin-bottom: 18px; }
.drawer-group > .cap {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ui-ink-dim);
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--ui-border);
}
.menu-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--ui-border);
  border-radius: 11px;
  background: rgba(255, 255, 255, .04);
  margin-bottom: 8px;
}
.menu-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(77, 143, 224, .16);
  color: #a8c8ef;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.menu-icon svg { width: 18px; height: 18px; }
.menu-icon.danger { background: rgba(248, 113, 113, .14); color: var(--ui-danger); }
.menu-text { flex: 1; min-width: 0; }
.menu-title { font-size: 13px; font-weight: 600; }
.menu-desc { font-size: 11px; color: var(--ui-ink-dim); margin-top: 2px; line-height: 1.4; }
.menu-card button { flex-shrink: 0; white-space: nowrap; }

.month-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.month-chip {
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--ui-border);
  border-radius: 999px;
  color: var(--ui-ink);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
}
.month-chip:hover { background: rgba(77, 143, 224, .3); }
.month-chip.current {
  border-color: var(--ui-yellow);
  box-shadow: 0 0 0 1px var(--ui-yellow);
  font-weight: 700;
}
.hint.warn { color: #fbbf24; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.field-grid .field.span2 { grid-column: 1 / -1; }
.field-grid .field label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.color-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.color-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border: 1px solid var(--ui-border);
  border-radius: 9px;
  background: rgba(255, 255, 255, .04);
  cursor: pointer;
}
.color-cell input[type="color"] {
  width: 34px;
  height: 26px;
  padding: 1px;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}
.color-cell span {
  font-size: 10px;
  color: var(--ui-ink-dim);
  text-align: center;
  line-height: 1.2;
}
#scrim {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(2, 6, 23, .45);
}

/* ---- form bits (popover + drawer share these) --------------------------- */

.field { margin-bottom: 10px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--ui-ink-dim);
  margin-bottom: 4px;
  letter-spacing: .02em;
}
.field input[type="text"], .field input[type="number"], .field input[type="date"],
.field select, .field textarea,
.rowlist .row input, .rowlist .row textarea, .rowlist .row select {
  width: 100%;
  background: rgba(255, 255, 255, .07);
  color: var(--ui-ink);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 13px;
  font-family: inherit;
  color-scheme: dark;
}
.field input:focus, .field select:focus, .field textarea:focus,
.rowlist input:focus, .rowlist textarea:focus {
  outline: none;
  border-color: var(--ui-blue);
  box-shadow: 0 0 0 2px rgba(77, 143, 224, .3);
}
.field input[type="color"] {
  width: 46px;
  height: 30px;
  padding: 2px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
}
.field textarea { min-height: 110px; resize: vertical; }
.field input[type="range"] {
  width: 100%;
  accent-color: var(--ui-blue);
  background: transparent;
  border: none;
  padding: 4px 0;
}
.hint { font-size: 11px; color: var(--ui-ink-dim); margin-top: 4px; line-height: 1.45; }

.rowlist .row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  align-items: flex-start;
}
.rowlist .row input, .rowlist .row textarea { padding: 6px 7px; font-size: 12px; min-width: 0; }
.rowlist .row textarea { min-height: 46px; resize: vertical; }
.rowlist .row.stacked-row {
  flex-wrap: wrap;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  padding: 7px;
}
.rowlist .row.stacked-row textarea { flex-basis: 100%; }
.rowlist .row .del {
  background: none;
  border: none;
  color: var(--ui-danger);
  font-size: 15px;
  cursor: pointer;
  padding: 5px;
  line-height: 1;
}
.rowlist .add, .block-form .add, .btn-soft {
  background: rgba(77, 143, 224, .18);
  color: #a8c8ef;
  border: 1px dashed rgba(77, 143, 224, .5);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background .1s ease;
}
.rowlist .add:hover, .btn-soft:hover { background: rgba(77, 143, 224, .3); }
.btn-danger {
  background: rgba(248, 113, 113, .12);
  color: var(--ui-danger);
  border: 1px dashed rgba(248, 113, 113, .5);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.btn-danger:hover { background: rgba(248, 113, 113, .25); }

.csv-drop {
  border: 1.5px dashed rgba(77, 143, 224, .5);
  border-radius: 10px;
  background: rgba(77, 143, 224, .08);
  padding: 12px;
  font-size: 12px;
  color: var(--ui-ink-dim);
  text-align: center;
  cursor: pointer;
  margin: 8px 0;
  transition: background .12s ease;
}
.csv-drop:hover, .csv-drop.drag { background: rgba(77, 143, 224, .2); color: var(--ui-ink); }
.csv-drop input { display: none; }
.csv-status { font-size: 11px; color: #4ade80; margin-bottom: 8px; }

.popover-section {
  border-top: 1px solid var(--ui-border);
  margin-top: 12px;
  padding-top: 10px;
}
.popover-section > .cap {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ui-ink-dim);
  margin-bottom: 8px;
}

/* month picker */
.mp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.mp-head .mp-year { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mp-head button {
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--ui-border);
  color: var(--ui-ink);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  font-size: 14px;
  cursor: pointer;
}
.mp-head button:hover { background: rgba(77, 143, 224, .35); }
.mp-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.mp-grid button {
  position: relative;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  padding: 9px 0;
  color: var(--ui-ink);
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
}
.mp-grid button:hover { background: rgba(77, 143, 224, .3); }
.mp-grid button.current {
  border-color: var(--ui-yellow);
  box-shadow: 0 0 0 1px var(--ui-yellow);
  font-weight: 700;
}
.mp-grid button .dot {
  position: absolute;
  top: 4px; right: 5px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #4ade80;
}

/* TLP option list */
.tlp-options { display: flex; flex-direction: column; gap: 6px; }
.tlp-options button {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--ui-border);
  border-radius: 9px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--ui-ink);
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
}
.tlp-options button:hover { background: rgba(255, 255, 255, .12); }
.tlp-options button.active { border-color: var(--ui-yellow); box-shadow: 0 0 0 1px var(--ui-yellow); }
.tlp-swatch {
  background: #000;
  font-weight: 700;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
}

.asset-thumb { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.asset-thumb img {
  height: 36px; max-width: 90px; object-fit: contain;
  background: repeating-conic-gradient(#334 0% 25%, #223 0% 50%) 0 0/12px 12px;
  border: 1px solid var(--ui-border); border-radius: 5px;
}

.block-form {
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, .04);
  padding: 10px;
  margin: 6px 0 10px 0;
}

/* type picker for new blocks */
.type-list { display: flex; flex-direction: column; gap: 5px; }
.type-list button {
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--ui-ink);
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}
.type-list button:hover { background: rgba(77, 143, 224, .25); }

/* ---- bottom bar --------------------------------------------------------- */

#bottombar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  z-index: 55;
  background: var(--ui-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--ui-border);
  font-size: 12px;
  color: var(--ui-ink-dim);
}
.bb-group { display: flex; align-items: center; gap: 6px; }
#bottombar button {
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--ui-border);
  border-radius: 7px;
  color: var(--ui-ink);
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#bottombar button:hover { background: rgba(77, 143, 224, .35); }
#bottombar button svg { width: 14px; height: 14px; }
#bb-page {
  min-width: 52px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--ui-ink);
}
#zoom-input {
  width: 56px;
  height: 26px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--ui-border);
  border-radius: 7px;
  color: var(--ui-ink);
  text-align: center;
  font-family: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
#zoom-input::-webkit-inner-spin-button,
#zoom-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
/* ---- image resize handles ----------------------------------------------- */

#handles { position: fixed; inset: 0; z-index: 72; pointer-events: none; }
.rh {
  position: fixed;
  width: 11px;
  height: 11px;
  margin: -5.5px 0 0 -5.5px;
  background: #fff;
  border: 1.5px solid var(--ui-blue);
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(2, 6, 23, .5);
  pointer-events: auto;
  touch-action: none;
}
.rh-nw, .rh-se { cursor: nwse-resize; }
.rh-ne, .rh-sw { cursor: nesw-resize; }
.rh-n, .rh-s { cursor: ns-resize; }
.rh-e, .rh-w { cursor: ew-resize; }

/* ---- table row / column controls ---------------------------------------- */

#tabletools { position: fixed; inset: 0; z-index: 72; pointer-events: none; }
.tt-group {
  position: fixed;
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 8px;
  background: var(--ui-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--ui-border);
  box-shadow: 0 6px 18px rgba(2, 6, 23, .5);
  pointer-events: auto;
  animation: chipIn .12s ease;
}
.tt-group button {
  background: rgba(255, 255, 255, .07);
  color: var(--ui-ink);
  border: none;
  border-radius: 6px;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  transition: background .1s ease;
}
.tt-group button:hover { background: rgba(77, 143, 224, .45); }
.tt-group button.tt-danger:hover { background: rgba(248, 113, 113, .45); }

/* ---- custom tooltip ----------------------------------------------------- */

#tooltip {
  position: fixed;
  z-index: 120;
  max-width: 300px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(8, 13, 24, .94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(148, 163, 184, .28);
  box-shadow: 0 6px 22px rgba(2, 6, 23, .55);
  color: var(--ui-ink);
  font-size: 11.5px;
  line-height: 1.45;
  pointer-events: none;
  animation: tipIn .14s ease;
}
@keyframes tipIn { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; } }
#tooltip::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -4.5px;
  transform: translateX(-50%) rotate(45deg);
  width: 8px; height: 8px;
  background: rgba(8, 13, 24, .94);
  border-right: 1px solid rgba(148, 163, 184, .28);
  border-bottom: 1px solid rgba(148, 163, 184, .28);
}
#tooltip.below::after {
  bottom: auto;
  top: -4.5px;
  border: none;
  border-left: 1px solid rgba(148, 163, 184, .28);
  border-top: 1px solid rgba(148, 163, 184, .28);
}

/* ---- add-section strips ------------------------------------------------- */

.add-strip {
  display: block;
  width: 210mm;
  margin: -4mm auto 10mm auto;
  padding: 10px;
  background: rgba(77, 143, 224, .1);
  border: 1.5px dashed rgba(77, 143, 224, .45);
  border-radius: 10px;
  color: #a8c8ef;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s ease;
}
.add-strip:hover { background: rgba(77, 143, 224, .22); color: #d5e5f8; }

/* ---- CSV import wizard (modal) ----------------------------------------- */

#importer {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
}
#importer .imp-scrim {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, .55);
}
#importer .imp-card {
  position: relative;
  width: 760px;
  max-width: calc(100vw - 32px);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  background: rgba(11, 18, 32, .95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--ui-border);
  box-shadow: 0 0 0 1px rgba(2, 6, 23, .4), 0 24px 64px rgba(2, 6, 23, .7);
  animation: popIn .16s cubic-bezier(.2, .9, .3, 1.2);
}
.imp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--ui-border);
}
.imp-head .imp-title { font-size: 15px; font-weight: 700; }
.imp-head button {
  background: none;
  border: none;
  color: var(--ui-ink-dim);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.imp-head button:hover { background: rgba(255, 255, 255, .1); color: var(--ui-ink); }
.imp-head button svg { width: 16px; height: 16px; display: block; }
.imp-body { padding: 16px 18px; overflow-y: auto; }
.imp-section { margin-bottom: 20px; }
.imp-section > .cap {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ui-ink-dim);
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--ui-border);
}
.imp-detect { font-size: 12px; color: #4ade80; margin: 8px 0; }
.imp-detect:empty { display: none; }

.imp-mini { overflow-x: auto; border: 1px solid var(--ui-border); border-radius: 8px; }
.imp-mini table {
  border-collapse: collapse;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  white-space: nowrap;
}
.imp-mini th, .imp-mini td {
  border: 1px solid var(--ui-border);
  padding: 3px 8px;
  text-align: left;
  color: var(--ui-ink);
}
.imp-mini th { background: rgba(255, 255, 255, .06); color: var(--ui-ink-dim); font-weight: 700; }

.imp-maprow { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.imp-maprow input[type="text"], .imp-maprow select {
  background: rgba(255, 255, 255, .07);
  color: var(--ui-ink);
  border: 1px solid var(--ui-border);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  color-scheme: dark;
  min-width: 0;
}
.imp-maprow input[type="text"] { flex: 1 1 100px; }
.imp-maprow select { flex: 0 1 auto; }
.imp-maprow input:focus, .imp-maprow select:focus {
  outline: none;
  border-color: var(--ui-blue);
  box-shadow: 0 0 0 2px rgba(77, 143, 224, .3);
}
.imp-mbtn {
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--ui-border);
  color: var(--ui-ink);
  border-radius: 6px;
  width: 24px;
  height: 24px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.imp-mbtn:hover { background: rgba(77, 143, 224, .35); }
.imp-mbtn svg { width: 13px; height: 13px; display: block; }
.imp-mbtn.danger { color: var(--ui-danger); }
.imp-mbtn.danger:hover { background: rgba(248, 113, 113, .45); color: #fff; }

.imp-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-top: 1px solid var(--ui-border);
}
.imp-foot .hint { flex: 1; margin: 0; }
.imp-apply {
  background: linear-gradient(180deg, #ffd633, #f5c400);
  color: #1a2b4a;
  border: none;
  border-radius: 9px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  box-shadow: 0 0 0 1px rgba(255, 204, 0, .4), 0 4px 18px rgba(255, 204, 0, .25);
  transition: transform .12s ease, box-shadow .12s ease;
}
.imp-apply:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(255, 204, 0, .6), 0 6px 24px rgba(255, 204, 0, .4); }
.imp-apply[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---- print: only the report ------------------------------------------- */

@media print {
  #toolbar, #bottombar, #chip, #fmtbar, #popover, #drawer, #scrim, #tooltip, #tabletools, #importer, .add-strip { display: none !important; }
  #preview { overflow: visible; padding: 0; }
  #pages-wrap { transform: none !important; height: auto !important; width: auto; }
  html, body { background: #fff; }
  .asset-slot { display: none !important; }
}
