/* Tabulate — the app accent (mirrors style.css; keep the two in step), page bits, and the "try it right here" model:
   green-ruled ledger paper, mono figures, a rubber-stamp Balance Seal. */
[data-app="tabulate"] { --a1: #1F5C46; --a2: #C9A227; --b1: #1F5C46; --b2: #2E7A5C; --ink-l: #1F5C46; --ink-d: #6CC197; }

/* ───────── Page bits ───────── */
.tb-checks { display: grid; gap: 8px; }
.tb-checks > div { display: grid; grid-template-columns: 112px 1fr auto; gap: 4px 14px; align-items: start; padding: 13px 16px; border-radius: 14px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); font-size: 14.5px; }
.tb-checks b { font-weight: 650; }
.tb-checks span { color: var(--muted); }
.tb-checks i { font-style: normal; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; padding: 3px 8px; border-radius: 999px; color: var(--muted); background: color-mix(in srgb, var(--text) 7%, transparent); }
.tb-checks i.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.tb-checks i.bad { color: #b2452d; background: color-mix(in srgb, #b2452d 11%, transparent); }
.tb-checks i.warn { color: var(--thread-ink); background: color-mix(in srgb, var(--thread) 14%, transparent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tb-checks i.bad { color: #e8816a; } }
:root[data-theme="dark"] .tb-checks i.bad { color: #e8816a; }
@media (max-width: 600px) { .tb-checks > div { grid-template-columns: 1fr auto; } .tb-checks span { grid-column: 1 / -1; grid-row: 2; } }
#seal .split > *, #exports .split > * { min-width: 0; }
.tb-list { margin: 18px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; color: var(--muted); font-size: 15.5px; }
.tb-list li { padding-left: 16px; position: relative; }
.tb-list li::before { content: ""; position: absolute; left: 0; top: .62em; width: 6px; height: 6px; border-radius: 2px; background: var(--accent-ink); opacity: .7; }
.tb-list b { color: var(--text); font-weight: 650; }
.tb-export-shot img { width: 100%; max-width: 520px; margin: 0 auto; border-radius: 14px; box-shadow: 0 0 0 1px var(--line), var(--shadow-lg); }

/* The desk: sample PDFs to drag into the window */
.tb-desk { display: flex; align-items: flex-end; justify-content: flex-end; gap: 14px; margin: 0 6px 14px; flex-wrap: wrap; }
.tb-desk-label { align-self: center; margin-right: auto; font-size: 13.5px; font-weight: 650; color: var(--muted); }
@media (max-width: 760px) { .tb-desk-label { display: none; } }
.tb-desk-label small { display: block; font-weight: 500; font-size: 12px; color: var(--faint); }
.tb-file { display: grid; grid-template-columns: 62px 150px; grid-template-rows: auto auto 1fr; gap: 2px 10px; align-items: start; text-align: left; padding: 8px 10px 8px 8px;
  border: 0; border-radius: 12px; background: color-mix(in srgb, var(--card) 70%, transparent); box-shadow: inset 0 0 0 1px var(--line); color: var(--text); font: inherit;
  cursor: grab; touch-action: none; -webkit-user-select: none; user-select: none; transition: transform .2s var(--ease), opacity .2s, box-shadow .2s; }
.tb-file:hover { box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow-sm); transform: translateY(-1px); }
.tb-file:active { cursor: grabbing; }
.tb-file.lifted { opacity: .4; }
.tb-file.used { opacity: .62; }
.tb-file .tb-pdf { grid-row: 1 / 4; }
.tb-fname { font-size: 12.5px; font-weight: 600; line-height: 1.3; word-break: break-word; }
.tb-ftag { justify-self: start; font-size: 11px; font-weight: 700; letter-spacing: .02em; padding: 2px 7px; border-radius: 999px; color: #8a6a1c; background: rgba(201, 162, 39, .16); }
.tb-file.used .tb-ftag { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.tb-desk.nudge .tb-file:not(.used) { animation: tbNudge .7s var(--ease) 2; }
@keyframes tbNudge { 30% { transform: translateY(-6px) rotate(-2deg); } 60% { transform: translateY(0) rotate(1deg); } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tb-ftag { color: #e0bf5c; } }
:root[data-theme="dark"] .tb-ftag { color: #e0bf5c; }
@media (min-width: 761px) { .tb-desk { margin-top: -12px; } }
@media (max-width: 760px) { .tb-desk { justify-content: center; gap: 8px; } .tb-file { grid-template-columns: 50px minmax(0, 1fr); flex: 1 1 150px; max-width: 220px; } }

/* A rendered PDF page from a made-up bank */
.tb-pdf { position: relative; display: block; width: 62px; height: 80px; padding: 5px 5px 0; overflow: hidden; border-radius: 3px; background: #fffefb; color: #333;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08), 0 3px 8px rgba(0,0,0,.14); font-family: var(--font); font-size: 3.6px; line-height: 1.25; text-align: left; }
.tb-pdf-hd { display: flex; align-items: center; gap: 2px; padding-bottom: 2px; border-bottom: .6px solid #8a3b2b; color: #8a3b2b; }
.tb-pdf-hd i { width: 6px; height: 6px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #d9a441, #8a3b2b 70%); }
.tb-pdf-hd b { font-size: 4.4px; letter-spacing: .04em; }
.tb-pdf-meta { display: block; margin: 2px 0; color: #555; }
.tb-pdf-meta b { display: block; color: #222; }
.tb-pdf-tbl { display: block; height: 40px; background:
  linear-gradient(#8a3b2b, #8a3b2b) 0 0 / 100% 2.6px no-repeat,
  repeating-linear-gradient(transparent 0 2.4px, rgba(0,0,0,.09) 2.4px 3px),
  linear-gradient(90deg, rgba(0,0,0,.18) 0 18%, transparent 18% 22%, rgba(0,0,0,.12) 22% 62%, transparent 62% 70%, rgba(0,0,0,.18) 70% 84%, transparent 84% 86%, rgba(0,0,0,.18) 86%) 0 3.4px / 100% 1.1px repeat-y; background-size: 100% 2.6px, auto, 100% 3px; }
.tb-pdf.scan { background: #f1efe6; transform: rotate(1.4deg); filter: contrast(.92) saturate(.6); }
.tb-pdf.scan::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 80% 90%, rgba(0,0,0,.08), transparent 55%), repeating-linear-gradient(90deg, rgba(0,0,0,.02) 0 1px, transparent 1px 3px); }
.tb-pdf-lock { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,254,251,.55); -webkit-backdrop-filter: blur(1.2px); backdrop-filter: blur(1.2px); }
.tb-pdf-lock svg { width: 22px; height: 22px; color: #9a7420; fill: none; stroke: currentColor; stroke-width: 1.6; filter: drop-shadow(0 1px 1px rgba(0,0,0,.15)); }
.tb-pdf-lock svg .f { fill: #c9a227; stroke: #9a7420; }
.tb-ghost { position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none; box-shadow: 0 12px 30px rgba(0,0,0,.28); opacity: .95; }
@media (max-width: 760px) { .tb-file .tb-pdf { width: 50px; height: 64px; font-size: 2.9px; } .tb-file .tb-pdf-tbl { height: 30px; } }

/* ───────── The model ───────── */
.tb {
  --tb-desk: #f3f1e8; --tb-sheet: #fbfaf4; --tb-panel: #fdfcf8; --tb-side: #ebeae3; --tb-bar: #e9e8e2;
  --tb-ink: #1c2420; --tb-ink2: rgba(28,36,32,.66); --tb-ink3: rgba(28,36,32,.45); --tb-hair: rgba(28,36,32,.10); --tb-hair2: rgba(28,36,32,.18);
  --tb-rule: rgba(47,111,85,.17); --tb-rule2: rgba(47,111,85,.42); --tb-wash: rgba(31,92,70,.075); --tb-selc: rgba(31,92,70,.14);
  --tb-green: #1f5c46; --tb-greenS: rgba(31,92,70,.12); --tb-rust: #b2452d; --tb-rustS: rgba(178,69,45,.10); --tb-brass: #9a7420; --tb-brassS: rgba(154,116,32,.12);
  --tb-on: #fbfaf4; --tb-stampblend: multiply;
  position: relative; height: 660px; display: grid; grid-template-columns: 210px minmax(0, 1fr); background: var(--tb-desk); color: var(--tb-ink);
  font-family: var(--font); font-size: 13px; line-height: 1.35; overflow: hidden; -webkit-user-select: none; user-select: none;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tb {
  --tb-desk: #0f1411; --tb-sheet: #151b17; --tb-panel: #1a211c; --tb-side: #161b18; --tb-bar: #1b201d;
  --tb-ink: #e6ebe5; --tb-ink2: rgba(230,235,229,.66); --tb-ink3: rgba(230,235,229,.44); --tb-hair: rgba(230,235,229,.10); --tb-hair2: rgba(230,235,229,.18);
  --tb-rule: rgba(124,196,160,.13); --tb-rule2: rgba(124,196,160,.34); --tb-wash: rgba(93,179,138,.11); --tb-selc: rgba(93,179,138,.20);
  --tb-green: #6cc197; --tb-greenS: rgba(108,193,151,.16); --tb-rust: #e8816a; --tb-rustS: rgba(232,129,106,.16); --tb-brass: #d8ae55; --tb-brassS: rgba(216,174,85,.16);
  --tb-on: #0f1411; --tb-stampblend: screen; } }
:root[data-theme="dark"] .tb {
  --tb-desk: #0f1411; --tb-sheet: #151b17; --tb-panel: #1a211c; --tb-side: #161b18; --tb-bar: #1b201d;
  --tb-ink: #e6ebe5; --tb-ink2: rgba(230,235,229,.66); --tb-ink3: rgba(230,235,229,.44); --tb-hair: rgba(230,235,229,.10); --tb-hair2: rgba(230,235,229,.18);
  --tb-rule: rgba(124,196,160,.13); --tb-rule2: rgba(124,196,160,.34); --tb-wash: rgba(93,179,138,.11); --tb-selc: rgba(93,179,138,.20);
  --tb-green: #6cc197; --tb-greenS: rgba(108,193,151,.16); --tb-rust: #e8816a; --tb-rustS: rgba(232,129,106,.16); --tb-brass: #d8ae55; --tb-brassS: rgba(216,174,85,.16);
  --tb-on: #0f1411; --tb-stampblend: screen; }
.tb button, .tb input, .tb select { font: inherit; color: inherit; }
.tb button { cursor: pointer; }
.tb :focus-visible { outline: 2px solid var(--tb-green); outline-offset: 1px; border-radius: 6px; }
.tb svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.tb svg .f { fill: currentColor; stroke: none; }
.tb svg .k { stroke: var(--tb-on); stroke-width: 1.7; }
.tb-i-ok { color: var(--tb-green); } .tb-i-bad, .tb-i-bang { color: var(--tb-rust); }
.tb-i-spin { color: var(--tb-ink3); animation: tbSpin .9s linear infinite; }
@keyframes tbSpin { to { transform: rotate(360deg); } }
.tb-kick { margin: 0 0 4px; font-family: var(--font-mono); font-size: 9.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--tb-ink2); }
.tb-big { margin: 0; font-family: var(--font-serif); font-size: 25px; font-weight: 600; letter-spacing: -.01em; line-height: 1.15; }
.tb-big span { color: var(--tb-ink3); font-size: 20px; margin-left: 4px; }
.tb-sub { margin: 4px 0 0; color: var(--tb-ink2); }
.tb-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.tb .g { color: var(--tb-green); }
.tb-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 5px 12px; border: 0; border-radius: 7px; background: var(--tb-panel); box-shadow: inset 0 0 0 1px var(--tb-hair2), 0 1px 1px rgba(0,0,0,.04); font-weight: 600; white-space: nowrap; }
.tb-btn:hover { background: var(--tb-sheet); }
.tb-btn.pri { background: var(--tb-green); color: var(--tb-on); box-shadow: none; }
.tb-btn.pri:hover { filter: brightness(1.08); }
.tb-btn:disabled { opacity: .45; cursor: default; filter: none; }
.tb-link { border: 0; background: none; padding: 0; color: var(--tb-green); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.tb-in { padding: 6px 9px; border: 0; border-radius: 7px; background: var(--tb-panel); box-shadow: inset 0 0 0 1px var(--tb-hair2); outline: none; -webkit-user-select: text; user-select: text; }
.tb-in:focus { box-shadow: inset 0 0 0 2px var(--tb-green); }
.tb-sel { padding: 4px 8px; border: 0; border-radius: 7px; background: var(--tb-panel); box-shadow: inset 0 0 0 1px var(--tb-hair2); }
.tb-chk { display: flex; align-items: center; gap: 7px; }
.tb-chk input { accent-color: var(--tb-green); margin: 0; }
.tb code { font-family: var(--font-mono); font-size: 11.5px; }

/* Sidebar */
.tb-side { position: relative; display: flex; flex-direction: column; min-height: 0; padding: 14px 10px 12px; background: var(--tb-side); border-right: 1px solid var(--tb-hair); overflow: hidden; }
.tb-side .lights { padding: 0 6px 18px; }
.tb-side .tb-kick { padding: 0 6px; margin-top: 4px; color: var(--tb-ink3); }
.tb-nav { display: flex; flex-direction: column; gap: 1px; margin-bottom: 14px; }
.tb-nav button { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border: 0; border-radius: 7px; background: none; text-align: left; color: var(--tb-ink2); }
.tb-nav button svg { opacity: .8; }
.tb-nav button:hover { background: var(--tb-wash); color: var(--tb-ink); }
.tb-nav button[aria-current="true"] { background: var(--tb-selc); color: var(--tb-ink); }
.tb-nav em { margin-left: auto; font-style: normal; font-family: var(--font-mono); font-size: 11px; color: var(--tb-ink3); }
.tb-sts button { align-items: flex-start; }
.tb-sti { display: grid; place-items: center; width: 16px; height: 16px; margin-top: 1px; }
.tb-stl { display: grid; min-width: 0; }
.tb-stl small { font-size: 11px; color: var(--tb-ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-sfoot { margin-top: auto; display: grid; gap: 8px; }
.tb-sfoot p { display: flex; gap: 5px; margin: 0; padding: 0 2px; font-size: 11px; color: var(--tb-ink3); }
.tb-sfoot p svg { width: 12px; height: 12px; margin-top: 1px; }

/* Main column */
.tb-col { position: relative; display: grid; grid-template-rows: 44px auto minmax(0, 1fr); min-width: 0; min-height: 0; }
.tb-bar { display: flex; align-items: center; gap: 10px; padding: 0 12px 0 16px; background: var(--tb-bar); border-bottom: 1px solid var(--tb-hair); }
.tb-title { font-weight: 650; font-size: 14px; color: var(--tb-ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-tools { margin-left: auto; display: flex; gap: 2px; }
.tb-tools button { display: grid; place-items: center; width: 30px; height: 28px; border: 0; border-radius: 7px; background: none; color: var(--tb-ink2); }
.tb-tools button svg { width: 17px; height: 17px; }
.tb-tools button:hover:not(:disabled) { background: var(--tb-wash); color: var(--tb-ink); }
.tb-tools button[aria-pressed="true"] { background: var(--tb-selc); color: var(--tb-green); }
.tb-tools button:disabled { opacity: .35; cursor: default; }
.tb-mnav { display: none; }
.tb-bar { grid-row: 1; } .tb-mnav { grid-row: 2; }
.tb-main { grid-row: 3; position: relative; min-height: 0; padding: 20px 22px 16px; }
.tb-main.is-sheet { display: flex; flex-direction: column; gap: 12px; }
.tb-main.is-scroll { overflow: auto; overscroll-behavior: contain; }
.tb-main.is-scroll > * + * { margin-top: 12px; }
.tb-main.is-scroll > .tb-big { margin-top: 0; }

/* Empty state */
.tb-main.is-empty { display: grid; place-items: center; overflow: auto; }
.tb-empty { max-width: 470px; text-align: center; }
.tb-ill { position: relative; width: 190px; height: 136px; margin: 0 auto 20px; border-radius: 9px; border: 1.5px dashed var(--tb-rule2);
  background: linear-gradient(90deg, transparent 18px, var(--tb-rule2) 18px 19px, transparent 19px 21px, var(--tb-rule2) 21px 22px, transparent 22px),
    repeating-linear-gradient(transparent 0 14px, var(--tb-rule) 14px 15px), var(--tb-sheet); }
.tb-ill-seal { position: absolute; right: -14px; bottom: -14px; width: 76px; transform: rotate(-10deg); }
.tb-ill-seal .tb-seal { width: 76px !important; height: 76px !important; }
.tb-eh { margin: 0 0 6px; font-family: var(--font-serif); font-size: 24px; font-weight: 600; }
.tb-ep { margin: 0 0 16px; color: var(--tb-ink2); }
.tb-eb { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.tb-eb .tb-btn { padding: 7px 14px; }
.tb-el { display: flex; justify-content: center; align-items: center; gap: 5px; margin: 16px 0 0; font-size: 11.5px; color: var(--tb-ink3); }
.tb-el svg { width: 12px; height: 12px; }

/* Statement head + the seal */
.tb-head { position: relative; display: flex; align-items: flex-start; gap: 16px; }
.tb-hl { min-width: 0; flex: 1; }
.tb-figs { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 8px 0 6px; }
.tb-figs div { display: grid; }
.tb-figs dt, .tb-stats dt { font-family: var(--font-mono); font-size: 9px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--tb-ink3); }
.tb-figs dd { margin: 0; font-family: var(--font-mono); font-size: 13.5px; font-weight: 600; }
.tb-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; font-size: 11.5px; color: var(--tb-ink3); }
.tb-tags span { padding: 1px 6px; border-radius: 4px; background: var(--tb-hair); font-family: var(--font-mono); font-size: 10.5px; color: var(--tb-ink2); }
.tb-badge { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border: 0; border-radius: 10px; background: var(--tb-panel); box-shadow: inset 0 0 0 1px var(--tb-hair); font-weight: 600; white-space: nowrap; }
.tb-badge.bad { color: var(--tb-rust); box-shadow: inset 0 0 0 1px var(--tb-rust); }
.tb-badge:disabled { cursor: default; }
.tb-sealw { position: relative; flex: none; }
.tb-sealb { display: block; padding: 0; border: 0; background: none; border-radius: 50% !important; }
.tb-seal { display: block; width: 92px !important; height: 92px !important; transform: rotate(-9deg); mix-blend-mode: var(--tb-stampblend); color: var(--tb-green); stroke: none !important; }
.tb-seal.s-bad { color: var(--tb-rust); }
.tb-seal.s-wait { color: var(--tb-brass); }
.tb-seal circle { fill: none; stroke: currentColor; }
.tb-seal .o { stroke-width: 2.6; opacity: .9; }
.tb-seal .o2 { stroke-width: .8; }
.tb-seal .i { stroke-width: 1.1; fill: color-mix(in srgb, currentColor 7%, transparent); }
.tb-seal.s-wait .o { stroke-dasharray: 4 3; animation: tbSpin 6s linear infinite; transform-origin: 50px 50px; }
.tb-seal text { fill: currentColor; stroke: none; font-family: var(--font-mono); font-weight: 700; text-anchor: middle; }
.tb-seal .rg { font-size: 7.6px; letter-spacing: .4px; text-anchor: start; }
.tb-seal .lb { font-size: 7.4px; letter-spacing: .3px; }
.tb-seal .bg { font-family: var(--font-serif); font-size: 24px; }
.tb-seal .mk { fill: none; stroke: currentColor; stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; }
.tb-sealb.stamp .tb-seal { animation: tbStamp .55s cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes tbStamp { 0% { transform: scale(2.1) rotate(-26deg); opacity: 0; } 55% { transform: scale(.92) rotate(-8deg); opacity: 1; } 75% { transform: scale(1.03) rotate(-9.5deg); } 100% { transform: scale(1) rotate(-9deg); } }
.tb-sealb.stamp::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid currentColor; color: var(--tb-green); opacity: 0; animation: tbRing .7s .3s ease-out; }
@keyframes tbRing { 0% { opacity: .5; transform: scale(.9); } 100% { opacity: 0; transform: scale(1.35); } }
.tb-sealpop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 12; width: 290px; padding: 12px 14px; border-radius: 11px; background: var(--tb-panel); box-shadow: 0 0 0 1px var(--tb-hair2), 0 12px 32px rgba(0,0,0,.18); font-size: 12.5px; -webkit-user-select: text; user-select: text; }
.tb-sealpop > b { display: block; font-family: var(--font-serif); font-size: 15px; margin-bottom: 4px; }
.tb-sealpop.ok > b { color: var(--tb-green); }
.tb-sealpop.bad > b { color: var(--tb-rust); }
.tb-sealpop p { margin: 0 0 7px; color: var(--tb-ink2); }
.tb-sealpop p b { color: var(--tb-ink); font-family: var(--font-mono); font-weight: 600; }
.tb-eq { font-family: var(--font-mono); font-size: 11.5px; line-height: 1.6; }
.tb-pill { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--tb-rustS); color: var(--tb-rust); font-weight: 600; }
.tb-pb { display: flex; gap: 6px; flex-wrap: wrap; }

/* Filters */
.tb-filt { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tb-search { display: flex; align-items: center; gap: 6px; flex: 0 1 300px; min-width: 150px; padding: 0 9px; border-radius: 8px; background: var(--tb-panel); box-shadow: inset 0 0 0 1px var(--tb-hair2); color: var(--tb-ink3); }
.tb-search:focus-within { box-shadow: inset 0 0 0 2px var(--tb-green); }
.tb-search input { flex: 1; min-width: 0; padding: 6px 0; border: 0; background: none; outline: none; color: var(--tb-ink); -webkit-user-select: text; user-select: text; }
.tb-search input::-webkit-search-cancel-button { opacity: .5; }
.tb-seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--tb-hair); }
.tb-seg button { padding: 3px 10px; border: 0; border-radius: 6px; background: none; white-space: nowrap; }
.tb-seg button[aria-pressed="true"] { background: var(--tb-panel); box-shadow: 0 1px 2px rgba(0,0,0,.12); font-weight: 600; }
.tb-count { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--tb-ink3); }

/* The ledger sheet: green ruling, a double margin rule, mono figures */
.tb-grid { flex: 1; min-height: 0; display: flex; flex-direction: column; border-radius: 10px; background: var(--tb-sheet); box-shadow: inset 0 0 0 1px var(--tb-hair); overflow: hidden; }
.tb-tr { display: grid; grid-template-columns: 20px 96px minmax(0, 1fr) 128px 92px 92px 104px; grid-template-areas: "mk dt pt ca de cr ba"; align-items: center; column-gap: 10px; min-height: 30px; padding: 0 12px 0 0; border-bottom: 1px solid var(--tb-rule); position: relative; }
.is-led .tb-tr { grid-template-columns: 20px 96px minmax(0, 1fr) 128px 96px 96px; grid-template-areas: "mk dt pt ca de cr"; }
.tb-mk { grid-area: mk; } .tb-dt { grid-area: dt; } .tb-pt { grid-area: pt; } .tb-ca { grid-area: ca; } .tb-de { grid-area: de; } .tb-cr { grid-area: cr; } .tb-am { grid-area: am; } .tb-ba { grid-area: ba; }
.tb-tr::before { content: ""; position: absolute; left: 22px; top: 0; bottom: -1px; width: 4px; border-left: 1px solid var(--tb-rule2); border-right: 1px solid var(--tb-rule2); }
.tb-th { min-height: 28px; font-family: var(--font-mono); font-size: 9.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--tb-ink3); border-bottom-color: var(--tb-rule2); background: var(--tb-sheet); }
.tb-th .tb-dt, .tb-tot .tb-dt { padding-left: 12px; }
.tb-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; background: repeating-linear-gradient(transparent 0 30px, var(--tb-rule) 30px 31px); background-attachment: local; scroll-behavior: auto; }
.tb-body .tb-tr:hover { background: var(--tb-wash); }
.tb-tot { min-height: 36px; border-top: 1px solid var(--tb-rule2); border-bottom: 0; color: var(--tb-ink2); font-size: 12px; }
.tb-tot .tb-dt { font-family: var(--font-mono); font-size: 11.5px; }
.tb-tot u { text-decoration: none; padding-bottom: 2px; border-bottom: 3px double currentColor; color: var(--tb-ink); font-weight: 650; }
.tb-tot .g u { color: var(--tb-green); }
.tb-mk { display: grid; place-items: center; }
.tb-mk svg { width: 13px; height: 13px; }
.tb-dt { padding-left: 12px; font-family: var(--font-mono); font-size: 12px; color: var(--tb-ink2); white-space: nowrap; }
.tb-dt .s { display: none; }
.tb-pt { display: flex; flex-direction: column; min-width: 0; }
.tb-p1 { display: flex; align-items: baseline; gap: 6px; min-width: 0; white-space: nowrap; }
.tb-p1 b { font-weight: 600; flex: none; }
.tb-p1 small { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; color: var(--tb-ink3); }
.tb-ch { flex: none; align-self: center; font-style: normal; font-family: var(--font-mono); font-size: 8.5px; font-weight: 600; letter-spacing: .04em; padding: 0 4px; border-radius: 3px; box-shadow: inset 0 0 0 1px var(--tb-hair2); color: var(--tb-ink3); }
.tb-catb { justify-self: start; max-width: 100%; padding: 2px 6px; margin-left: -6px; border: 0; border-radius: 5px; background: none; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-catb:hover { background: var(--tb-wash); box-shadow: inset 0 0 0 1px var(--tb-hair2); }
.tb-catb.un { color: var(--tb-brass); font-style: italic; }
.tb-catb.m { display: none; }
.tb-fig { padding: 1px 4px; margin-right: -4px; border: 0; border-radius: 4px; background: none; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12.5px; color: inherit; }
.tb-fig:hover { background: var(--tb-wash); box-shadow: inset 0 0 0 1px var(--tb-hair2); }
.tb-cr .tb-fig, .tb-am.g .tb-fig { color: var(--tb-green); }
.tb-num { font-size: 12.5px; white-space: nowrap; }
.tb-am { display: none; }
.tb-ba { display: grid; justify-items: end; line-height: 1.15; }
.tb-ba small { font-size: 9.5px; color: var(--tb-rust); }
.tb-edit { width: 100%; max-width: 100px; justify-self: end; padding: 2px 5px; border: 0; border-radius: 5px; background: var(--tb-panel); box-shadow: inset 0 0 0 2px var(--tb-green); font-family: var(--font-mono); font-size: 12.5px; text-align: right; outline: none; -webkit-user-select: text; user-select: text; }
.tb-tr.brk { background: var(--tb-rustS) !important; box-shadow: inset 0 1px 0 var(--tb-rust), inset 0 -1px 0 var(--tb-rust); }
.tb-tr.brk .tb-ba > span { color: var(--tb-rust); font-weight: 650; }
.tb-tr.fresh { animation: tbIn .35s var(--ease) both; }
@keyframes tbIn { from { opacity: 0; transform: translateX(-8px); background: var(--tb-greenS); } }
.tb-tr.flash { animation: tbFlash 1.2s ease-out; }
@keyframes tbFlash { 0%, 30% { box-shadow: inset 0 0 0 2px var(--tb-rust); } }
.tb-none { margin: 0; padding: 18px; color: var(--tb-ink3); text-align: center; }

/* Reading panel */
#tabulate-demo .demo-toast { bottom: auto; top: 52px; }
.tb-imp { position: absolute; left: 50%; bottom: 16px; z-index: 14; width: min(440px, calc(100% - 24px)); transform: translateX(-50%); padding: 10px 12px; border-radius: 12px; background: var(--tb-panel); box-shadow: 0 0 0 1px var(--tb-hair2), 0 14px 36px rgba(0,0,0,.18); animation: tbUp .3s var(--ease); }
.tb-imp[hidden] { display: none; }
@keyframes tbUp { from { opacity: 0; transform: translate(-50%, 12px); } }
.tb-ir { display: flex; align-items: center; gap: 9px; }
.tb-ir > span:nth-child(2) { display: grid; min-width: 0; flex: 1; }
.tb-ir b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-ir small { font-size: 11.5px; color: var(--tb-ink3); }
.tb-ir.s-locked small { color: var(--tb-brass); font-weight: 600; }
.tb-ir.s-locked .tb-sti { color: var(--tb-brass); }

/* Category popover */
.tb-pop { position: absolute; z-index: 16; width: 300px; padding: 10px; border-radius: 11px; background: var(--tb-panel); box-shadow: 0 0 0 1px var(--tb-hair2), 0 14px 36px rgba(0,0,0,.2); }
.tb-pop[hidden] { display: none; }
.tb-catg { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 4px 0 8px; }
.tb-catg button { padding: 3px 7px; border: 0; border-radius: 5px; background: none; text-align: left; font-size: 12px; }
.tb-catg button:hover { background: var(--tb-wash); }
.tb-catg button[aria-pressed="true"] { background: var(--tb-green); color: var(--tb-on); }
.tb-pop .tb-chk { padding-top: 8px; border-top: 1px solid var(--tb-hair); font-size: 12px; }

/* Sheets */
.tb-veil { position: absolute; inset: 0; z-index: 20; display: grid; place-items: start center; padding: 54px 14px 14px; background: rgba(10,14,12,.28); animation: tbFade .2s; overflow: auto; }
.tb-veil[hidden] { display: none; }
@keyframes tbFade { from { opacity: 0; } }
.tb-dlg { width: 100%; max-width: 440px; padding: 18px 20px; border-radius: 13px; background: var(--tb-desk); box-shadow: 0 0 0 1px var(--tb-hair2), 0 24px 60px rgba(0,0,0,.35); animation: tbDrop .3s var(--ease); }
@keyframes tbDrop { from { opacity: 0; transform: translateY(-14px); } }
.tb-dlg.shake { animation: tbShake .4s; }
@keyframes tbShake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.tb-dt2 { margin: 0; font-family: var(--font-serif); font-size: 21px; font-weight: 600; }
.tb-fn { margin: 0 0 12px; font-size: 12px; color: var(--tb-ink3); }
.tb-pwh { display: flex; gap: 12px; align-items: center; }
.tb-pwh .tb-i-doc { width: 34px; height: 34px; color: var(--tb-brass); stroke-width: 1.1; }
.tb-pwh .tb-i-doc .f { fill: var(--tb-brass); }
.tb-pwin { width: 100%; margin-top: 2px; -webkit-text-security: disc; letter-spacing: .08em; }
.tb-err { min-height: 4px; margin: 4px 0; font-size: 12px; font-weight: 600; color: var(--tb-rust); }
.tb-hint { margin: 0 0 10px; font-size: 12px; color: var(--tb-ink2); }
.tb-samp { margin: 0 0 12px; padding: 7px 10px; border-radius: 8px; background: var(--tb-brassS); font-size: 12.5px; }
.tb-samp code { font-weight: 700; color: var(--tb-ink); }
.tb-dlgb { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 14px; }
.tb-ex .tb-dlgb { justify-content: flex-end; }
.tb-exn { margin-right: auto; font-size: 11.5px; color: var(--tb-ink3); }
.tb-ex { max-width: 600px; }
.tb-fmts { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.tb-fmts button { position: relative; display: grid; gap: 2px; padding: 9px 11px; border: 0; border-radius: 9px; background: var(--tb-panel); box-shadow: inset 0 0 0 1px var(--tb-hair); text-align: left; }
.tb-fmts button[aria-checked="true"] { background: var(--tb-selc); box-shadow: inset 0 0 0 1.5px var(--tb-green); }
.tb-fmts b { font-weight: 650; }
.tb-fmts b code { font-weight: 400; color: var(--tb-ink3); font-size: 10.5px; }
.tb-fmts small { font-size: 11.5px; color: var(--tb-ink2); }
.tb-fmts em { position: absolute; right: 8px; top: 8px; font-style: normal; font-size: 9.5px; font-weight: 700; letter-spacing: .02em; padding: 1px 6px; border-radius: 999px; color: var(--tb-brass); background: var(--tb-brassS); }
.tb-note { margin: 9px 0 0; font-size: 11.5px; color: var(--tb-ink3); transition: color .2s; }
.tb-note.hl { color: var(--tb-brass); font-weight: 600; }
.tb-exo { display: grid; grid-template-columns: auto 1fr; gap: 9px 14px; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--tb-hair2); }
.tb-exo > span { font-weight: 600; }
.tb-exo .tb-sel, .tb-exo .tb-seg { justify-self: start; }

/* Recurring, insights, rules */
.tb-card { padding: 10px 14px; border-radius: 10px; background: var(--tb-panel); box-shadow: inset 0 0 0 1px var(--tb-hair); }
.tb-card > .tb-kick { margin-bottom: 6px; }
.tb-rec { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--tb-hair); }
.tb-card > .tb-kick + .tb-rec { border-top: 0; }
.tb-rec small { display: block; font-size: 11.5px; color: var(--tb-ink3); }
.tb-rec .tb-num { flex: none; display: grid; }
.tb-rec .tb-num small { font-size: 10.5px; }
.tb-tag { display: inline-flex; align-items: center; gap: 3px; font-style: normal; font-family: var(--font-mono); font-size: 8.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 1px 5px; border-radius: 3px; background: var(--tb-hair); color: var(--tb-ink2); vertical-align: 1px; }
.tb-tag.up { background: var(--tb-brassS); color: var(--tb-brass); }
.tb-tag svg { width: 9px; height: 9px; stroke-width: 2; }
.tb-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; }
.tb-stats div { padding: 9px 12px; border-radius: 10px; background: var(--tb-panel); box-shadow: inset 0 0 0 1px var(--tb-hair); }
.tb-stats dd { margin: 2px 0 0; font-family: var(--font-mono); font-size: 15px; font-weight: 600; white-space: nowrap; }
.tb-bars { display: flex; gap: 10px; height: 128px; padding-bottom: 18px; border-bottom: 1px solid var(--tb-hair); }
.tb-bm { flex: 1; display: grid; grid-template-rows: 1fr auto; gap: 4px; }
.tb-bp { display: flex; align-items: flex-end; justify-content: center; gap: 4px; border-bottom: 1px solid var(--tb-rule2); }
.tb-bp i { width: min(34px, 30%); background: var(--tb-ink3); border-radius: 2px 2px 0 0; min-height: 1px; }
.tb-bp i.in { background: var(--tb-green); }
.tb-bm span { text-align: center; font-size: 11px; color: var(--tb-ink2); }
.tb-legend { display: flex; align-items: center; gap: 5px; margin: 6px 0 0; font-size: 11px; color: var(--tb-ink2); }
.tb-legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--tb-ink3); }
.tb-legend i.in { background: var(--tb-green); }
.tb-legend i + * , .tb-legend i:nth-of-type(2) { margin-left: 8px; }
.tb-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tb-cb { display: grid; grid-template-columns: 1fr auto auto; gap: 0 10px; align-items: baseline; padding: 3px 0; }
.tb-cb small { font-family: var(--font-mono); font-size: 9.5px; color: var(--tb-ink3); }
.tb-cb i { grid-column: 1 / -1; height: 5px; margin-top: 3px; border-radius: 3px; background: var(--tb-green); opacity: .8; }
.tb-cp { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--tb-rule); }
.tb-cp small { font-size: 10px; color: var(--tb-ink3); }
.tb-nr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.tb-nr label { display: flex; align-items: center; gap: 7px; }
.tb-nr .tb-in { width: 190px; }
.tb-rule { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--tb-hair); }
.tb-rule code { font-weight: 600; }
.tb-ib { margin-left: auto; display: grid; place-items: center; width: 26px; height: 24px; border: 0; border-radius: 6px; background: none; color: var(--tb-ink3); }
.tb-ib:hover { background: var(--tb-rustS); color: var(--tb-rust); }
.tb details.tb-bi { border-bottom: 0; padding: 10px 14px; }
.tb .tb-bi summary { display: flex; align-items: baseline; gap: 6px; padding: 2px 0; font-size: 13px; font-weight: 600; line-height: 1.35; cursor: pointer; list-style: none; }
.tb .tb-bi summary::after { content: "›"; position: static; margin-left: auto; width: auto; height: auto; border: 0; background: none; font-size: 16px; line-height: 1; color: var(--tb-ink3); transform: none; transition: transform .2s; }
.tb .tb-bi[open] summary::after { transform: rotate(90deg); }
.tb .tb-bi > div { margin: 0; max-width: none; color: var(--tb-ink); }
.tb-bi summary small { font-weight: 400; color: var(--tb-ink3); margin-left: 6px; }

/* Drag-over */
.tb-dropmsg { position: absolute; inset: 8px; z-index: 30; display: grid; place-items: center; border-radius: 12px; border: 2.5px dashed var(--tb-green); background: color-mix(in srgb, var(--tb-desk) 70%, transparent); opacity: 0; pointer-events: none; transition: opacity .15s; }
.tb-dropmsg span { padding: 10px 18px; border-radius: 999px; background: var(--tb-green); color: var(--tb-on); font-weight: 650; font-size: 14px; }
.tb-over .tb-dropmsg { opacity: 1; }

/* ───────── Phones and narrow windows ───────── */
@media (max-width: 760px) {
  .tb { height: 600px; grid-template-columns: minmax(0, 1fr); }
  .tb-side { display: none; }
  .tb-col { grid-template-rows: 40px auto minmax(0, 1fr); }
  .tb-bar { padding-left: 12px; }
  .tb-mnav { display: flex; gap: 4px; padding: 6px 10px; overflow-x: auto; background: var(--tb-side); border-bottom: 1px solid var(--tb-hair); scrollbar-width: none; }
  .tb-mnav button { flex: none; padding: 4px 10px; border: 0; border-radius: 999px; background: none; color: var(--tb-ink2); font-size: 12px; white-space: nowrap; }
  .tb-mnav button[aria-current="true"] { background: var(--tb-selc); color: var(--tb-ink); font-weight: 600; }
  .tb-mnav button.st::before { content: "✓ "; color: var(--tb-green); }
  .tb-mnav button.st.s-bad::before { content: "! "; color: var(--tb-rust); font-weight: 700; }
  .tb-mnav button.st.s-wait::before { content: "… "; }
  .tb-main { padding: 12px 10px 10px; }
  .tb-main.is-sheet { gap: 8px; }
  .tb-big { font-size: 19px; }
  .tb-big span { font-size: 15px; }
  .tb-figs { gap: 2px 14px; margin: 4px 0; }
  .tb-figs dd { font-size: 11.5px; }
  .tb-tags { display: none; }
  .tb-seal { width: 70px !important; height: 70px !important; }
  .tb-sealpop { width: min(290px, calc(100vw - 60px)); }
  .tb-head { gap: 8px; }
  .tb-badge { padding: 6px 9px; font-size: 12px; }
  .tb-search { flex: 1 1 100%; }
  .tb-sel, .tb-count { display: none; }
  .tb-seg button { padding: 3px 8px; font-size: 12px; }
  .tb-tr { grid-template-columns: 44px minmax(0, 1fr) 82px 76px; grid-template-areas: "dt pt am ba"; column-gap: 6px; min-height: 40px; padding-right: 6px; }
  .is-led .tb-tr { grid-template-columns: 44px minmax(0, 1fr) 88px; grid-template-areas: "dt pt am"; }
  .tb-ch { display: none; }
  .tb-file .tb-fname { font-size: 11.5px; }
  .tb-tr::before { left: 0; width: 3px; border-left: 0; }
  .tb-mk { position: absolute; left: 3px; top: 4px; }
  .tb-th .tb-dt, .tb-tot .tb-dt, .tb-dt { padding-left: 8px; }
  .tb-dt .l { display: none; } .tb-dt .s { display: inline; font-size: 10px; }
  .tb-dt { padding-left: 6px !important; }
  .tb-ca, .tb-de, .tb-cr { display: none; }
  .tb-am { display: block; }
  .tb-p1 small { display: none; }
  .tb-p1 b { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
  .tb-catb.m { display: block; padding: 0 6px; font-size: 11px; color: var(--tb-ink3); }
  .tb-catb.m.un { color: var(--tb-brass); }
  .tb-body { background: none; }
  .tb-fig { font-size: 11px; padding: 1px 2px; margin-right: -2px; }
  .tb-num { font-size: 11px; }
  .tb-ba small { font-size: 8.5px; white-space: normal; text-align: right; line-height: 1.1; }
  .tb-tot .tb-pt { display: none; }
  .tb-tot .tb-dt { grid-column: 1 / 3; }
  .tb-stats { grid-template-columns: 1fr 1fr; }
  .tb-stats dd { font-size: 13px; }
  .tb-two { grid-template-columns: 1fr; }
  .tb-fmts { grid-template-columns: 1fr; }
  .tb-fmts small { display: none; }
  .tb-exo { grid-template-columns: 1fr; gap: 6px; }
  .tb-veil { padding-top: 20px; }
  .tb-dlg { padding: 14px; }
  .tb-pop { width: min(300px, calc(100% - 16px)); }
  .tb-nr .tb-in { width: 100%; }
  .tb-nr label { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .tb *, .tb-file, .tb-desk * { animation: none !important; transition: none !important; }
}
