/* SNC Invoicing app chrome. Colours and type come from the invoice design. */
:root {
  --navy: #0F2A45;
  --teal: #08889E;
  --teal-dark: #06707F;
  --gold: #B08D3A;
  --ink: #0F2A45;
  --muted: #5B6E80;
  --faint: #A3B1BE;
  --line: #DCE3EA;
  --line-strong: #C5D0DA;
  --soft: #F1F5F8;
  --focus: #E6F3F5;
  --bg: #F4F6F8;
  --card: #FFFFFF;
  --ok: #2E7D4F;
  --ok-bg: #E5F2EA;
  --bad: #A8452F;
  --bad-bg: #F8E9E5;
  --warn-bg: #FBF5E6;
  --warn-line: #EADBB5;
  --warn-ink: #6B5320;
  --r: 8px;
  --shadow: 0 1px 2px rgba(15, 42, 69, .05), 0 6px 20px rgba(15, 42, 69, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Lexend', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--navy); }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 24px; letter-spacing: -.01em; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
button, input, select, textarea { font-family: inherit; }

/* ---------- top bar ---------- */
.chrome { position: sticky; top: 0; z-index: 20; }
.topbar { display: flex; align-items: center; gap: 28px; height: 60px; padding: 0 28px; background: #fff; }
.brand { display: flex; align-items: center; gap: 12px; flex: none; }
.brand img { display: block; height: 26px; width: auto; }
.brand span { padding-left: 12px; border-left: 1px solid var(--line); font-size: 13px; font-weight: 500; color: var(--muted); }
.topbar nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.topbar nav a { padding: 7px 12px; border-radius: 6px; color: var(--muted); font-weight: 500; font-size: 13.5px; white-space: nowrap; }
.topbar nav a:hover, .topbar nav a.on { color: var(--navy); background: var(--soft); }
.stripe { display: flex; height: 3px; }
.stripe span:nth-child(1) { flex: 1; background: var(--navy); }
.stripe span:nth-child(2) { width: 64px; background: var(--teal); }
.stripe span:nth-child(3) { width: 28px; background: var(--gold); }

/* ---------- layout ---------- */
.main { max-width: 1180px; margin: 0 auto; padding: 28px 28px 64px; }
.main.wide { max-width: none; padding: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.crumbs { margin-bottom: 6px; font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.grid-2.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.lg { gap: 20px; }
.muted { color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--navy);
  font-size: 13px; font-weight: 500; white-space: nowrap; text-decoration: none;
  cursor: pointer; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--soft); color: var(--navy); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--soft); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.lg { height: 42px; padding: 0 22px; font-size: 14px; }
.btn:disabled { opacity: .6; cursor: default; }
.btn:focus-visible, .link:focus-visible, .chip:focus-visible, .seg button:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.link { padding: 0; border: none; background: none; color: var(--teal); font-size: 13px; cursor: pointer; }
.link:hover { color: var(--navy); }
.link.danger { color: var(--bad); }

/* ---------- forms ---------- */
.in {
  width: 100%; height: 36px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--ink);
  font-size: 13.5px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
textarea.in { height: auto; padding: 8px 10px; line-height: 1.5; resize: vertical; }
select.in {
  padding-right: 30px; appearance: none; cursor: pointer;
  background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%235B6E80' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat right 11px center;
}
.in:hover { border-color: var(--line-strong); }
.in:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--focus); }
.in::placeholder { color: var(--faint); }
.in[list]::-webkit-calendar-picker-indicator { display: none !important; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lbl { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.hint.warn { color: var(--bad); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span2 { grid-column: 1 / -1; }
.form-section + .form-section { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.form-section > h3 { margin-bottom: 14px; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 22px; }
.form-actions .spacer { flex: 1; }
.form-actions.start { justify-content: flex-start; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); cursor: pointer; }
.check-end { align-self: end; min-height: 36px; }
.check input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--teal); }

/* ---------- cards, tiles, tables ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head a { font-size: 13px; }
.card > .sub:first-of-type { margin-bottom: 18px; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.tiles.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tiles.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack > .tiles { margin-bottom: 0; }
.tile { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; min-width: 0; color: var(--ink); }
a.tile { transition: border-color .12s, box-shadow .12s; }
a.tile:hover { color: var(--ink); border-color: var(--line-strong); box-shadow: var(--shadow); }
.tile-lbl { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.tile.warn .tile-lbl::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }
.tile.accent { border-color: #B5DCE3; background: linear-gradient(180deg, #F3FAFB, #fff 60%); }
.tile.accent .tile-lbl::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); }
.tile-val { margin-top: 6px; font-size: 24px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile-val .alt { display: block; margin-top: 3px; font-size: 14px; font-weight: 500; color: var(--muted); }
.tile-cap { margin-top: 6px; font-size: 12px; color: var(--muted); }

.table-wrap { overflow-x: auto; }
.card:not(.flush) > .table-wrap { margin: 0 -22px -20px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: #FAFBFC;
  font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  text-align: left; white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 22px; }
.table th:last-child, .table td:last-child { padding-right: 22px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr[data-href] { cursor: pointer; }
.table tbody tr[data-href]:hover td { background: var(--soft); }
.table .r { text-align: right; }
.table .muted { color: var(--muted); }
.table a.strong { color: var(--ink); font-weight: 500; white-space: nowrap; }
.table td.num { white-space: nowrap; }
.table-note { margin: 0; padding: 10px 22px 14px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.table .cell-sub { margin-top: 2px; font-size: 12px; color: var(--muted); }
.table .cell-sub.clip { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }
.table .strong { color: var(--ink); font-weight: 500; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td, .table tbody tr.clickable:focus-visible td { background: var(--soft); }
.table tbody tr.clickable:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; }
.table tbody tr.dim td { color: var(--faint); }
.table tbody tr.dim td .muted { color: var(--faint); }
.bleed { margin: 0 -22px -20px; }
.rec-mark { display: inline-flex; vertical-align: -2px; margin-left: 7px; color: var(--teal); }
.row-acts { display: flex; justify-content: flex-end; gap: 14px; white-space: nowrap; }
.occ-inv { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
.occ-inv a { font-weight: 500; }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 4px; background: #EEF2F5; color: var(--muted); font-size: 11.5px; font-weight: 500; white-space: nowrap; vertical-align: 1px; }
.tag.teal { background: var(--focus); color: var(--teal-dark); }
.clip-ico { display: inline-flex; align-items: center; gap: 2px; color: var(--teal); font-size: 12px; font-weight: 500; }
.no-receipt { font-size: 12px; color: var(--faint); }

.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-draft { background: #EEF2F5; color: var(--muted); }
.pill-sent { background: var(--focus); color: var(--teal-dark); }
.pill-overdue { background: var(--bad-bg); color: var(--bad); }
.pill-paid { background: var(--ok-bg); color: var(--ok); }
.pill-void { background: #F1F1F1; color: #8A96A3; }

/* Revenue by client: one series, so bars carry the accent and text stays in ink. */
.bars { display: flex; flex-direction: column; gap: 16px; margin: 0; padding: 0; list-style: none; }
.bars a { display: flex; justify-content: space-between; gap: 12px; color: var(--ink); font-size: 13.5px; }
.bars a:hover .bar-name { color: var(--teal); }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.bar-val { flex: none; font-weight: 500; font-variant-numeric: tabular-nums; }
.bar-track { display: flex; gap: 2px; height: 8px; margin-top: 6px; }
.bar { flex: none; height: 8px; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--teal); }
.bar.proj { background: #9CCFD8; }
.bar:not(:last-child) { border-radius: 0; }
.bar-sub { margin-top: 4px; font-size: 12px; color: var(--muted); }
.bars-note { margin: 16px 0 0; font-size: 12px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 18px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend .sw { width: 12px; height: 8px; border-radius: 2px; background: var(--teal); }
.legend .sw.proj { background: #9CCFD8; }

/* Coming up: the next recurring invoices. */
.upcoming { display: flex; flex-direction: column; margin: 0 -10px; padding: 0; list-style: none; }
.upcoming.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
.upcoming a { display: flex; align-items: center; gap: 14px; padding: 9px 10px; border-radius: 7px; color: var(--ink); }
.upcoming a:hover { background: var(--soft); color: var(--ink); }
.up-date { display: flex; flex: none; flex-direction: column; align-items: center; justify-content: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 7px; background: #fff; line-height: 1.1; }
.up-date b { font-size: 16px; font-weight: 600; }
.up-date span { font-size: 10.5px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--teal); }
.up-main, .up-amt { display: flex; flex-direction: column; min-width: 0; }
.up-main { flex: 1; }
.up-amt { flex: none; align-items: flex-end; font-weight: 500; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.up-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 400; color: var(--muted); }

.empty { padding: 32px 20px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 14px; }
.empty p:last-child { margin: 0; }

.notice { display: block; margin-bottom: 12px; padding: 11px 14px; border: 1px solid var(--warn-line); border-radius: 7px; background: var(--warn-bg); color: var(--warn-ink); font-size: 13px; }
.notice a { color: var(--warn-ink); font-weight: 500; text-decoration: underline; }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.filters select.in { width: auto; min-width: 180px; }
.filters input[type=search] { flex: 1; width: auto; min-width: 220px; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.seg button { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer; }
.seg button:hover { color: var(--navy); }
.seg button.on { background: var(--navy); color: #fff; }
.seg .count { font-size: 11px; opacity: .75; font-variant-numeric: tabular-nums; }

/* ---------- invoice editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; max-width: 1240px; margin: 0 auto; padding: 28px 28px 80px; }
.editor-doc { display: flex; justify-content: center; min-width: 0; }
.paper { box-shadow: 0 1px 3px rgba(15, 42, 69, .08), 0 12px 32px rgba(15, 42, 69, .10); }
.editor-side { position: sticky; top: 87px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 103px); overflow-y: auto; padding: 0 2px 4px; }
.side-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; }
.side-card.flash { animation: flash 1s ease; }
@keyframes flash { 30% { border-color: var(--teal); box-shadow: 0 0 0 3px var(--focus); } }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.save-state { font-size: 12px; color: var(--muted); }
.save-state.bad { color: var(--bad); }
.side-note { margin: 0; font-size: 12.5px; color: var(--muted); }
.side-actions { gap: 8px; }
.side-links { display: flex; justify-content: center; gap: 18px; padding-top: 4px; }
.side-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.activity { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; font-size: 12.5px; }
.activity li { display: flex; justify-content: space-between; gap: 10px; }
.activity time { color: var(--muted); white-space: nowrap; }

.terms, .terms-fields { display: flex; flex-direction: column; gap: 10px; }
.t-row { display: flex; align-items: flex-end; gap: 10px; }
.t-row > .field { flex: none; width: 84px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; padding-bottom: 4px; }
.chip { min-width: 34px; height: 28px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--navy); font-size: 12.5px; cursor: pointer; }
.chip:hover { border-color: var(--teal); color: var(--teal); }
.chip.on { border-color: var(--navy); background: var(--navy); color: #fff; }
.terms-preview { padding: 9px 11px; border-radius: 6px; background: var(--soft); font-size: 12.5px; color: var(--muted); }
.terms-preview b { color: var(--ink); font-weight: 500; }
.rec-note { display: flex; gap: 8px; align-items: flex-start; }
.rec-note svg { flex: none; margin-top: 3px; color: var(--teal); }

/* ---------- recurring schedules ---------- */
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.li { display: flex; flex-direction: column; gap: 6px; }
.li-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px 110px 110px 28px; gap: 8px; align-items: center; }
.li-head { font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.li-head .r, .li-row .r { text-align: right; }
.li-amt { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.li-del { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: #EEF2F5; color: var(--muted); font-size: 15px; line-height: 26px; cursor: pointer; }
.li-del:hover { background: var(--line); color: var(--navy); }
.li-add { align-self: flex-start; margin-top: 4px; padding: 6px 12px; border: 1px dashed #9CCFD8; border-radius: 6px; background: transparent; color: var(--teal); font-size: 12.5px; font-weight: 500; cursor: pointer; }
.li-add:hover { background: var(--focus); }
.li-hint { margin: 10px 0 16px; }
.per-invoice { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-top: 14px; padding: 10px 12px; border-radius: 7px; background: var(--soft); font-size: 13px; }
.per-invoice b { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.every { display: flex; align-items: center; gap: 8px; }
.every input { width: 76px; }
.every select { width: auto; min-width: 120px; }
.field .chips { margin-top: 4px; padding: 0; }
.ends { display: flex; flex-direction: column; gap: 8px; }
.end-opt { display: flex; align-items: center; gap: 10px; min-height: 36px; font-size: 13px; }
.end-opt .check { min-width: 64px; }
.end-opt input:disabled { background: var(--soft); color: var(--faint); }
.num-in { width: 80px; }
.date-in { width: auto; }
.choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice-opt { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.choice-opt:hover { border-color: var(--line-strong); }
.choice-opt:has(input:checked) { border-color: var(--teal); background: #F3FAFB; box-shadow: 0 0 0 1px var(--teal); }
.choice-opt input { flex: none; width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--teal); }
.choice-opt > span { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.choice-opt b { font-weight: 500; }
.gap-top { margin-top: 18px; }
.narrow { max-width: 220px; }
.sched-preview { display: flex; flex-direction: column; gap: 12px; }
.preview-head { margin: 0; font-size: 13.5px; }
.preview-head b { font-weight: 600; }
.preview-note { margin: 0; padding: 9px 12px; border-radius: 6px; background: var(--warn-bg); color: var(--warn-ink); font-size: 12.5px; }
.date-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.date-list li { padding: 4px 9px; border: 1px solid var(--line); border-radius: 5px; background: #fff; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.date-list li.edited { border-color: #9CCFD8; background: var(--focus); }
.date-list li.more { border-style: dashed; color: var(--muted); }

/* ---------- expenses ---------- */
.page-hint { margin: 12px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.main.dropping { outline: 2px dashed var(--teal); outline-offset: -8px; border-radius: 12px; background: var(--focus); }
.drop { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1.5px dashed var(--line-strong); border-radius: 8px; background: #FAFBFC; transition: border-color .12s, background .12s; }
.drop.over { border-color: var(--teal); background: var(--focus); }
.drop-msg { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.drop-msg svg { flex: none; }
.drop-msg > div { display: flex; flex-direction: column; gap: 1px; }
.drop-msg b { font-weight: 500; }
.drop-msg span { color: var(--muted); font-size: 12.5px; }
.drop.has-files .drop-msg { padding-top: 10px; border-top: 1px solid var(--line); }
.files { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.files:empty { display: none; }
.file { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.file-thumb { display: flex; flex: none; align-items: center; justify-content: center; width: 40px; height: 40px; overflow: hidden; border-radius: 5px; background: var(--soft); }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-name { flex: 1; min-width: 0; padding: 0; border: 0; background: none; color: var(--ink); font-size: 13px; font-weight: 500; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.file-name:hover { color: var(--teal); text-decoration: underline; }
.file-size { flex: none; font-size: 12px; color: var(--muted); }
.in-with { display: flex; gap: 6px; }
.in-with .btn { flex: none; padding: 0 10px; }
.opt { font-weight: 400; color: var(--faint); }
.indent { margin: 6px 0 14px 24px; }

/* ---------- clients ---------- */
.tabs { display: flex; gap: 4px; margin: -4px 0 20px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.tabs a:hover { color: var(--navy); }
.tabs a.on { color: var(--navy); border-bottom-color: var(--teal); }
.tabs .count { min-width: 18px; padding: 0 5px; border-radius: 9px; background: #EEF2F5; color: var(--muted); font-size: 11px; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.info-card { max-width: 880px; }
.re { display: flex; flex-direction: column; gap: 8px; }
.re-rows { display: flex; flex-direction: column; gap: 8px; }
.re-rows:empty { display: none; }
.re-row { display: grid; grid-template-columns: var(--re-cols) 28px; gap: 8px; align-items: center; }
.re .li-add { margin-top: 0; }
.re-hint { margin: -6px 0 12px; }
.kv { display: flex; flex-direction: column; gap: 10px; margin: 0; font-size: 13px; }
.kv-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; }
.kv dt { color: var(--muted); overflow-wrap: anywhere; }
.kv dd { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.kv b { font-weight: 500; }

/* ---------- documents ---------- */
.doc-list { display: flex; flex-direction: column; margin: 0 -10px; padding: 0; list-style: none; }
.doc-list a { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 7px; color: var(--ink); }
.doc-list a:hover { background: var(--soft); color: var(--ink); }
.doc-list svg { flex: none; }
.dl-main { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.dl-title, .dl-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-title { font-weight: 500; }
.dl-sub { font-size: 12px; color: var(--muted); }
.doc-types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.doc-types .choice-opt { padding: 10px 12px; }
.seg-full { display: flex; }
.seg-full button { flex: 1; justify-content: center; }
.tok-group { display: flex; flex-direction: column; gap: 6px; }
.tok-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.toks { display: flex; flex-wrap: wrap; gap: 5px; }
.tok { height: 26px; padding: 0 9px; border: 1px solid #B5DCE3; border-radius: 13px; background: #F3FAFB; color: var(--teal-dark); font-size: 12px; cursor: pointer; }
.tok:hover { border-color: var(--teal); background: var(--focus); }
.tok.empty { border-style: dashed; border-color: var(--line-strong); background: #fff; color: var(--muted); }
.tok-warn code { font-family: inherit; font-weight: 500; }
.add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.add-grid .btn { height: 32px; font-size: 12.5px; }

/* ---------- modal & toast ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 7vh 16px 16px; overflow-y: auto; background: rgba(15, 42, 69, .38); animation: fade .12s ease; }
.modal { width: 100%; max-width: 480px; border-radius: 10px; background: #fff; box-shadow: 0 20px 60px rgba(15, 42, 69, .25); }
.modal.wide { max-width: 660px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 0; }
.modal-head .x { width: 32px; height: 32px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.modal-head .x:hover { background: var(--soft); }
.modal-body { padding: 16px 22px 4px; }
.modal-body p { margin: 0 0 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 22px 20px; }
.attach { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--soft); font-size: 13px; font-weight: 500; }
.attach svg { flex: none; }
.attach span { margin-left: auto; color: var(--muted); font-weight: 400; }
@keyframes fade { from { opacity: 0; } }

.toasts { position: fixed; bottom: 20px; left: 50%; z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.toast { max-width: 520px; padding: 10px 16px; border-radius: 8px; background: var(--navy); color: #fff; font-size: 13px; box-shadow: 0 8px 24px rgba(15, 42, 69, .25); transition: opacity .3s, transform .3s; }
.toast.error { background: var(--bad); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- setup & settings ---------- */
.setup { display: flex; justify-content: center; min-height: 100vh; padding: 48px 16px; }
.setup-card { align-self: flex-start; width: 100%; max-width: 780px; padding: 36px 40px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.setup-card .brand-logo { display: block; height: 34px; width: auto; }
.setup-card .stripe { margin: 20px 0 26px; }
.setup-card h1 + .sub { margin-bottom: 16px; }
.sources { margin: 0 0 24px; font-size: 13px; color: var(--muted); }
.sources summary { color: var(--teal); cursor: pointer; }
.sources ul { margin: 8px 0 0; padding-left: 18px; }
.seed { margin-top: 22px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--soft); }

.settings { display: flex; flex-direction: column; gap: 20px; max-width: 880px; }
.paths { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.paths code { padding: 2px 6px; border-radius: 4px; background: var(--soft); font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
.key-state { display: flex; align-items: center; gap: 10px; font-size: 13px; }

.fatal { max-width: 560px; margin: 15vh auto; padding: 0 16px; text-align: center; }
.fatal img { display: block; height: 40px; width: auto; margin: 0 auto 24px; }
.fatal p { color: var(--muted); }
.signin { position: fixed; inset: 0; z-index: 150; display: flex; justify-content: center; align-items: flex-start; padding: 14vh 16px 48px; overflow-y: auto; background: var(--bg); }
.signin-card { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 400px; padding: 32px 32px 30px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.signin-card .brand-logo { display: block; align-self: flex-start; height: 30px; width: auto; }
.signin-card .stripe { margin: 2px 0 4px; }
.signin-card h1 { margin: 0; font-size: 20px; }
.signin-card .btn { margin-top: 4px; }
.boot { display: flex; align-items: center; justify-content: center; min-height: 80vh; }
.boot img { height: 36px; width: auto; opacity: .9; animation: fade .6s ease; }

/* ---------- small screens ---------- */
@media (max-width: 1180px) {
  .editor { grid-template-columns: 1fr; }
  .editor-side { position: static; order: -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); max-height: none; overflow: visible; }
  .tiles.five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .tiles, .tiles.five, .tiles.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles.five .tile:last-child, .tiles.three .tile:last-child { grid-column: 1 / -1; }
  .grid-2, .grid-2.even { grid-template-columns: 1fr; }
  .topbar { gap: 14px; padding: 0 16px; }
  .brand span { display: none; }
  .brand img { height: 22px; }
  .main { padding: 20px 16px 48px; }
  .editor { padding: 16px 16px 64px; }
  .choice, .upcoming.cols { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .form-grid, .form-grid.three, .tiles, .tiles.five, .tiles.three { grid-template-columns: 1fr; }
  .topbar .btn { display: none; }
  .setup-card, .signin-card { padding: 24px 20px; }
  .li-row { grid-template-columns: minmax(0, 1fr) 56px 84px 26px; }
  .li-amt { display: none; }
  .re-row { grid-template-columns: minmax(0, 1fr) 28px; }
  .re-row .li-del { grid-column: 2; grid-row: 1; }
  .doc-types { grid-template-columns: 1fr; }
}
