:root {
  --bg: #f8f7f4;
  --surface: #ffffff;
  --surface-2: #f3f2ee;
  --ink: #17171c;
  --ink-2: #3d3d46;
  --muted: #74737d;
  --line: #e8e6e0;
  --line-2: #d9d6ce;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --green: #047857;
  --green-soft: #e3f6ee;
  --amber: #8a5a00;
  --amber-soft: #fff4d6;
  --red: #b42318;
  --red-soft: #fdeceb;
  --violet-soft: #f1edff;
  --shadow: 0 1px 2px rgba(20, 20, 30, .04), 0 8px 24px rgba(20, 20, 30, .06);
  --shadow-lg: 0 20px 60px rgba(20, 20, 30, .18);
  --radius: 14px;
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Instrument Serif', ui-serif, Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f12; --surface: #17171c; --surface-2: #1e1e24; --ink: #f2f1ee; --ink-2: #d1d0cc; --muted: #9a99a3;
    --line: #2a2a31; --line-2: #383841; --accent: #8b85ff; --accent-ink: #0f0f12; --accent-soft: #23224a;
    --green: #4ade9f; --green-soft: #0f2e22; --amber: #fbbf47; --amber-soft: #33270b; --red: #ff8a80; --red-soft: #3a1714;
    --violet-soft: #2a2347; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f12; --surface: #17171c; --surface-2: #1e1e24; --ink: #f2f1ee; --ink-2: #d1d0cc; --muted: #9a99a3;
  --line: #2a2a31; --line-2: #383841; --accent: #8b85ff; --accent-ink: #0f0f12; --accent-soft: #23224a;
  --green: #4ade9f; --green-soft: #0f2e22; --amber: #fbbf47; --amber-soft: #33270b; --red: #ff8a80; --red-soft: #3a1714;
  --violet-soft: #2a2347; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; font-feature-settings: 'cv11', 'ss01'; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; margin-top: 22px; }
p { margin: 0; }
code { font: 12px ui-monospace, 'SF Mono', Menlo, monospace; background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------- controls */
button, .file-btn { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid transparent; padding: 8px 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; }
button:active, .file-btn:active { transform: translateY(1px); }
.primary { background: var(--ink); color: var(--bg); }
.primary:hover { background: var(--ink-2); }
.primary.big { width: 100%; justify-content: center; padding: 12px 16px; font-size: 15px; }
.ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.ghost:hover { background: var(--surface-2); }
.small { font-size: 12.5px; }
button.small { padding: 6px 10px; border-radius: 8px; }
.link { background: none; border: none; color: var(--muted); padding: 6px 0; text-decoration: underline; text-underline-offset: 3px; }
.danger { background: var(--red-soft); color: var(--red); border-color: transparent; }
.danger:hover { filter: brightness(.97); }
.file-btn input { display: none; }
input[type=text], input[type=email], input[type=search], input:not([type]), input[inputmode], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 12px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { font: 13px/1.6 ui-monospace, 'SF Mono', Menlo, monospace; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2374737d' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
label { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-2); margin: 14px 0 6px; }
label.check { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; cursor: pointer; }
.error { color: var(--red); font-size: 13px; min-height: 20px; margin: 8px 0 4px; }

/* ---------------------------------------------------------- header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 650; font-size: 16px; letter-spacing: -0.02em; }
.book-picker { display: flex; align-items: center; gap: 8px; padding-left: 16px; border-left: 1px solid var(--line); }
.book-picker select { width: auto; min-width: 180px; max-width: 260px; padding: 7px 28px 7px 10px; font-weight: 500; }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who .email { color: var(--muted); font-size: 13px; }
.save-state { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.save-state::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.save-state.saving::before { background: var(--amber); }
.save-state.failed { color: var(--red); }
.save-state.failed::before { background: var(--red); }
.save-state:empty { display: none; }

/* ---------------------------------------------------------- sign in */
.signin { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); min-height: calc(100vh - 57px); }
.signin-left { display: flex; align-items: center; justify-content: center; padding: 48px 32px; }
.signin-inner { width: 100%; max-width: 440px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }
.display { font-family: var(--serif); font-weight: 400; font-size: clamp(44px, 5.4vw, 64px); line-height: 1; letter-spacing: -0.02em; }
.display em { color: var(--accent); }
.lede { color: var(--ink-2); font-size: 16px; line-height: 1.6; margin: 20px 0 28px; }
.auth { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 20px 20px; box-shadow: var(--shadow); }
.code-input { font-size: 22px !important; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; }
.fine { font-size: 12.5px; color: var(--muted); margin-top: 16px; }
.signin-right { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 28px; padding: 48px 40px; background: radial-gradient(120% 90% at 80% 0%, #3b2f9e 0%, #191637 45%, #0d0c16 100%); color: #ecebf5; }
.signin-right::after { content: ''; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.07) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(to bottom, #000, transparent 85%); pointer-events: none; }
.preview { position: relative; z-index: 1; width: 100%; max-width: 520px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 18px; padding: 14px; backdrop-filter: blur(10px); box-shadow: 0 30px 80px rgba(0,0,0,.45); transform: perspective(1400px) rotateY(-6deg) rotateX(3deg); }
.preview-head { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; font-weight: 600; padding: 4px 6px 12px; }
.pill-soft { font-size: 11px; font-weight: 500; background: rgba(255,255,255,.1); padding: 2px 8px; border-radius: 99px; }
.preview-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.preview-stats div { background: rgba(255,255,255,.06); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.preview-stats b { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.preview-stats span { font-size: 11px; color: #a9a7c2; }
.preview-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto 78px; gap: 10px; align-items: center; font-size: 12px; padding: 9px 6px; border-top: 1px solid rgba(255,255,255,.07); }
.preview-row .d { color: #8f8daa; font-variant-numeric: tabular-nums; }
.preview-row .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-row .acct { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.08); padding: 3px 8px; border-radius: 7px; font-size: 11.5px; white-space: nowrap; }
.preview-row .acct i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }
.preview-row .acct.q { background: rgba(251,191,71,.16); color: #fcd581; }
.preview-row .amt { text-align: right; font-variant-numeric: tabular-nums; }
.preview-row .amt.in { color: #6ee7b7; }
.preview-q { margin-top: 10px; background: rgba(139,133,255,.14); border: 1px solid rgba(139,133,255,.35); border-radius: 12px; padding: 11px 12px; display: grid; gap: 6px; font-size: 12.5px; }
.preview-q span { color: #b6b3d6; font-size: 11.5px; }
.preview-q .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.preview-q em { font-style: normal; font-size: 11.5px; padding: 3px 9px; border-radius: 99px; background: rgba(255,255,255,.08); color: #ecebf5; }
.preview-q em.on { background: #8b85ff; color: #0d0c16; font-weight: 600; }
.quote { position: relative; z-index: 1; font-family: var(--serif); font-size: 22px; line-height: 1.3; max-width: 440px; text-align: center; color: #d7d5ee; }

/* ---------------------------------------------------------- app shell */
#app { max-width: 1320px; margin: 0 auto; padding: 18px 24px 120px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: none; border-radius: 0; padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.count { font-size: 11px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); border-radius: 99px; padding: 0 7px; margin-left: 4px; font-variant-numeric: tabular-nums; }
.count:empty { display: none; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head > div:first-child { max-width: 720px; }
.panel-head h2 { font-size: 22px; font-weight: 600; margin-bottom: 4px; }

/* ---------------------------------------------------------- drop zone */
.drop { border: 1.5px dashed var(--line-2); border-radius: 20px; background: var(--surface); padding: 64px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); transition: border-color .15s, background .15s; }
.drop svg { color: var(--accent); background: var(--accent-soft); border-radius: 14px; padding: 9px; width: 58px; height: 58px; margin-bottom: 8px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-title { font-size: 20px; font-weight: 600; color: var(--ink); letter-spacing: -0.015em; }
.drop-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }
.private-note { font-size: 12.5px; margin-top: 14px; }

/* ---------------------------------------------------------- review */
.filebar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.filename { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; word-break: break-word; }
.filebar-actions { display: flex; gap: 8px; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.progress { grid-column: span 1; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 99px; transition: width .3s; }

.questions { margin-bottom: 16px; border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); }
.q-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; margin-bottom: 12px; }
.q-head p { color: var(--ink-2); font-size: 13px; }
.q-list { display: grid; gap: 10px; }
.q { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 14px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.q-num { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.q-meta { font-size: 12px; color: var(--muted); }
.q-body { display: grid; gap: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); border-radius: 99px; padding: 5px 11px; font-size: 12.5px; font-weight: 500; }
.chip:hover { border-color: var(--line-2); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.q-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.q-fields input { padding: 7px 10px; font-size: 13px; }
.q-fields.owner { grid-template-columns: minmax(0, 1fr) auto; }

.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin: 6px 0 12px; }
.toolbar-right { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.toolbar-right input[type=search] { width: 220px; padding: 7px 12px; }
.filters { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.filters button { background: none; border: none; padding: 5px 11px; font-size: 13px; color: var(--muted); border-radius: 8px; }
.filters button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--line); }
.filters button .n { font-size: 11px; margin-left: 4px; color: var(--muted); font-variant-numeric: tabular-nums; }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
.tx th { position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tx td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tx tr:last-child td { border-bottom: none; }
.tx tbody tr { transition: background .12s; }
.tx tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.tx tbody tr.sel { background: var(--accent-soft); }
.tx tbody tr.done { opacity: .62; }
.tx tbody tr.done:hover { opacity: 1; }
.c-sel, .c-ok { width: 40px; text-align: center; }
.tx td.c-sel { padding-top: 13px; }
.c-date { width: 92px; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.c-amt { width: 120px; text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 500; }
.amt-in { color: var(--green); }
.c-type { width: 142px; }
.c-acct { width: 260px; }
.c-conf { width: 104px; }
.desc { font-weight: 500; word-break: break-word; }
.note { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.45; }
.note.ask { color: var(--amber); }
.note .edited { color: var(--accent); font-weight: 500; }
.tx select, .tx input.acct { padding: 6px 9px; font-size: 13px; border-radius: 8px; border-color: var(--line); background-color: var(--surface); }
.tx select { padding-right: 24px; background-position: right 8px center; }
.tx input.acct:hover, .tx select:hover { border-color: var(--line-2); }
.tx input.acct.blank { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.tx input.acct.blank::placeholder { color: var(--amber); opacity: .9; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.High { background: var(--green-soft); color: var(--green); }
.pill.Medium { background: var(--violet-soft); color: var(--accent); }
.pill.Low { background: var(--amber-soft); color: var(--amber); }
.pill.Reviewed { background: var(--surface-2); color: var(--ink-2); }
.okbtn { width: 28px; height: 28px; padding: 0; justify-content: center; border-radius: 50%; border: 1.5px solid var(--line-2); background: var(--surface); color: transparent; }
.okbtn:hover { border-color: var(--green); color: var(--green); }
.okbtn[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.empty { padding: 40px; text-align: center; }

/* bulk bar (floating) */
.bulkbar { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 30; display: flex; align-items: center; gap: 8px; background: #16151c; color: #f2f1ee; border-radius: 16px; padding: 8px 8px 8px 16px; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); animation: rise .2s ease-out; }
.bulkbar span { font-size: 13px; color: #b9b8c2; margin-right: 4px; white-space: nowrap; }
.bulkbar input { width: 220px; background: #26252e; border-color: #34333d; color: #f2f1ee; padding: 7px 10px; font-size: 13px; }
.bulkbar button { background: #26252e; color: #f2f1ee; border: 1px solid #34333d; padding: 7px 13px; font-size: 13px; }
.bulkbar button:hover { background: #312f3a; }
.bulkbar .x { padding: 7px 10px; }
@keyframes rise { from { transform: translate(-50%, 12px); opacity: 0; } }

/* toast */
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 40; max-width: 420px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 14px 16px; display: grid; gap: 10px; animation: slide .2s ease-out; }
.toast .t-title { font-weight: 600; font-size: 13.5px; display: flex; gap: 8px; align-items: center; }
.toast .t-title::before { content: '✦'; color: var(--accent); }
.toast .t-body { font-size: 13px; color: var(--ink-2); }
.toast .t-actions { display: flex; gap: 8px; justify-content: flex-end; }
.toast.err .t-title::before { content: '!'; color: var(--red); font-weight: 700; }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } }
body.bulk-on .toast { bottom: 84px; }

/* ---------------------------------------------------------- settings tables */
.grid th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid tr:last-child td { border-bottom: none; }
.grid input, .grid select { padding: 7px 10px; font-size: 13px; border-color: var(--line); }
.grid .num { font-variant-numeric: tabular-nums; font-weight: 600; width: 90px; }
.grid .del { background: none; border: none; color: var(--muted); padding: 6px 8px; }
.grid .del:hover { color: var(--red); }
.grid .empty-row td { padding: 36px; text-align: center; color: var(--muted); }

.rules { display: grid; gap: 10px; }
.rule { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; grid-template-columns: 28px minmax(0, 2.2fr) 100px 110px minmax(0, 1.3fr) 104px auto; gap: 10px; align-items: start; }
.rule .idx { font-size: 12px; color: var(--muted); padding-top: 8px; font-variant-numeric: tabular-nums; }
.rule input, .rule select { padding: 7px 10px; font-size: 13px; border-color: var(--line); }
.rule .full { grid-column: 2 / -1; }
.rule .tools { display: flex; gap: 2px; }
.rule .tools button { background: none; border: none; color: var(--muted); padding: 6px 7px; }
.rule .tools button:hover { color: var(--ink); }
.rule .tools .del:hover { color: var(--red); }
.rule-label { font-size: 11px; color: var(--muted); margin: 0 0 3px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }

.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.settings-grid .card p.muted { margin: 4px 0 12px; font-size: 13px; }
.danger-h { color: var(--red); margin-top: 28px; }

/* ---------------------------------------------------------- small screens */
@media (max-width: 1000px) {
  .signin { grid-template-columns: 1fr; }
  .signin-right { display: none; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rule { grid-template-columns: 24px minmax(0, 1fr) minmax(0, 1fr); }
  .rule > :nth-child(n+3) { grid-column: auto; }
  .rule .full { grid-column: 2 / -1; }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .top { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .who .email { display: none; }
  .book-picker { order: 3; width: 100%; border-left: none; padding-left: 0; }
  .book-picker select { flex: 1; max-width: none; min-width: 0; }
  #app { padding: 14px 16px 120px; }
  .signin-left { padding: 32px 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .q { grid-template-columns: 1fr; gap: 8px; }
  .q-fields, .q-fields.owner { grid-template-columns: 1fr; }
  .toolbar-right input[type=search] { width: 100%; }
  .toolbar-right { width: 100%; }
  /* table rows become cards */
  .tx thead { display: none; }
  .tx, .tx tbody, .tx tr, .tx td { display: block; width: 100%; }
  .tx tr { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 4px 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .tx td { border: none; padding: 0; width: auto; }
  .tx td.c-sel { grid-row: 1; grid-column: 1; padding-top: 2px; }
  .tx td.c-main { grid-row: 1; grid-column: 2; }
  .tx td.c-amt { grid-row: 1; grid-column: 3; }
  .tx td.c-date { grid-row: 2; grid-column: 2 / -1; font-size: 12px; color: var(--muted); }
  .tx td.c-type { grid-column: 2; }
  .tx td.c-acct { grid-column: 2 / -1; }
  .tx td.c-conf { grid-column: 2; }
  .tx td.c-ok { grid-column: 3; grid-row: auto; text-align: right; }
  .grid, .grid tbody, .grid tr, .grid td { display: block; width: 100%; }
  .grid thead { display: none; }
  .grid tr { padding: 10px 12px; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
  .grid td { border: none; padding: 0; }
  .grid .num { width: auto; }
  .bulkbar { flex-wrap: wrap; left: 16px; right: 16px; transform: none; bottom: 16px; animation: none; }
  .bulkbar input { flex: 1; width: auto; min-width: 0; }
  .toast { left: 16px; right: 16px; bottom: 16px; max-width: none; }
}

/* dialog */
.dialog { border: 1px solid var(--line); border-radius: 18px; padding: 22px; width: min(420px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
.dialog::backdrop { background: rgba(15, 15, 20, .4); backdrop-filter: blur(3px); }
.dialog-actions { justify-content: flex-end; margin-top: 18px; }
