/* ============================================================
   Tacoma Vocal Standard — Treasurer
   Single stylesheet. Every rule lives here so there is one place
   to look and nothing can drift between modules.
   ============================================================ */

:root {
  --bg:        #f5f3ee;
  --surface:   #ffffff;
  --surface-2: #f0ede6;
  --border:    #ddd9d0;
  --border-2:  #c8c3b8;

  --text:      #1a1916;
  --text-2:    #6b6760;
  --text-3:    #9e9a93;

  --accent:    #1d4e3a;
  --accent-lt: #e8f0ec;
  --accent-br: #b8d4c4;

  --gold:      #b5822a;
  --gold-lt:   #f8f1e4;
  --gold-br:   #e0c870;

  --red:       #a33030;
  --red-lt:    #faeaea;
  --red-br:    #d4a0a0;

  --green:     #1d6b45;
  --green-lt:  #e6f4ec;
  --green-br:  #8bc4a0;

  --r:   6px;
  --r-l: 10px;

  --sans: 'DM Sans', system-ui, -apple-system, sans-serif;
  --mono: 'DM Mono', ui-monospace, monospace;
  --disp: 'Playfair Display', Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Top bar ─────────────────────────────────────────────── */

.topbar {
  background: var(--accent);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: env(safe-area-inset-top);
}
.topbar-in { max-width: 1240px; margin: 0 auto; padding: 0 20px; }

.brand { display: flex; align-items: baseline; gap: 10px; padding: 13px 0 9px; }
.brand-name { font-family: var(--disp); font-size: 19px; font-weight: 600; letter-spacing: .01em; }
.brand-sub  { font-family: var(--mono); font-size: 10px; letter-spacing: .12em;
              text-transform: uppercase; color: rgba(255,255,255,.55); }

.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }

.tab {
  appearance: none; border: 0; background: none; cursor: pointer;
  font-family: var(--sans); font-size: 13px; color: rgba(255,255,255,.68);
  padding: 8px 13px 10px; white-space: nowrap;
  border-bottom: 2px solid transparent; transition: color .12s;
  display: flex; align-items: center; gap: 6px;
}
.tab:hover { color: rgba(255,255,255,.92); }
.tab.is-active { color: #fff; border-bottom-color: #fff; font-weight: 500; }

.pip {
  background: var(--gold); color: #fff; font-family: var(--mono);
  font-size: 10px; line-height: 1; padding: 3px 6px; border-radius: 9px;
}

/* ── Layout ──────────────────────────────────────────────── */

#main { max-width: 1240px; margin: 0 auto; padding: 22px 20px 80px; }

.page-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 16px;
}
.page-head h1 { font-family: var(--disp); font-size: 22px; font-weight: 600; }
.page-sub { font-size: 13px; color: var(--text-2); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.boot { text-align: center; padding: 80px 20px; color: var(--text-2); }
.spinner {
  width: 22px; height: 22px; margin: 0 auto 12px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Cards ───────────────────────────────────────────────── */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-l); overflow: hidden; margin-bottom: 16px;
}
.card-head {
  padding: 11px 15px; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title { font-family: var(--disp); font-size: 15px; font-weight: 600; }
.card-body { padding: 15px; }
.card-body.flush { padding: 0; }

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
  appearance: none; font-family: var(--sans); font-size: 13px; font-weight: 500;
  padding: 7px 14px; border-radius: var(--r); cursor: pointer;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  transition: background .12s, border-color .12s;
  text-decoration: none; line-height: 1.4;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: #163d2c; }
.btn-danger { background: var(--red-lt); color: var(--red); border-color: var(--red-br); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-sm { font-size: 12px; padding: 4px 9px; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────── */

.field { display: block; margin-bottom: 12px; }
.field-label {
  display: block; font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: .09em; color: var(--text-3);
  margin-bottom: 4px;
}
.input, .select, textarea.input {
  width: 100%; font-family: var(--sans); font-size: 14px;
  padding: 8px 10px; border: 1px solid var(--border-2); border-radius: var(--r);
  background: var(--surface); color: var(--text); line-height: 1.4;
}
.input:focus, .select:focus {
  outline: 2px solid var(--accent-br); outline-offset: 0; border-color: var(--accent);
}
.input-mono { font-family: var(--mono); }
.input-amt  { font-family: var(--mono); text-align: right; }

/* Native selects render as OS widgets on mobile and clash badly, so
   they get an explicit chevron and app-native surface instead. */
.select {
  appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239e9a93' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }

.filters {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px;
}
.filters .select, .filters .input { width: auto; flex: 0 1 auto; font-size: 13px; padding: 6px 10px; }
.filters .select { padding-right: 28px; }
.filters .grow { flex: 1 1 160px; }

/* ── Tables ──────────────────────────────────────────────── */

.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-3); text-align: left;
  padding: 8px 11px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap; font-weight: 400;
}
.tbl td { padding: 9px 11px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #faf9f6; }
.tbl .num { font-family: var(--mono); text-align: right; white-space: nowrap; }
.tbl .date { font-family: var(--mono); font-size: 12px; color: var(--text-2); white-space: nowrap; }
.tbl tr.is-flagged td { background: var(--gold-lt); }
.tbl tr.is-flagged:hover td { background: #fbeed3; }

.amt-in  { color: var(--green); }
.amt-out { color: var(--red); }

/* ── Chips ───────────────────────────────────────────────── */

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--mono); font-size: 10px; padding: 2px 7px;
  border-radius: 9px; white-space: nowrap;
}
.chip-rev  { background: var(--green-lt); color: var(--green); }
.chip-exp  { background: var(--red-lt);   color: var(--red); }
.chip-none { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border-2); }
.chip-warn { background: var(--gold-lt);  color: var(--gold); }
.chip-split{ background: var(--gold-lt);  color: var(--gold); border: 1px solid var(--gold-br); }

.doc-yes { color: var(--green); border-color: var(--green-br); }
.doc-no  { color: var(--red);   border-color: var(--red-br); background: var(--red-lt); }

/* Split transactions read as a parent row with its category lines
   beneath, at the same size as everything else. The only difference is
   a lighter background and a tick mark, so the grouping is obvious
   without the lines looking like footnotes. */
.tbl tr.has-split td { border-bottom: 0; }
.tbl tr.split-row td { background: var(--surface-2); border-bottom: 0; padding-top: 5px; padding-bottom: 5px; }
.tbl tr.split-row:hover td { background: var(--surface-2); }
.tbl tr.split-last td { border-bottom: 1px solid var(--border); padding-bottom: 9px; }
.split-tick { color: var(--text-2); position: relative; padding-left: 22px !important; }
.split-tick::before {
  content: ''; position: absolute; left: 6px; top: -2px; bottom: 50%;
  width: 8px; border-left: 1px solid var(--border-2);
  border-bottom: 1px solid var(--border-2); border-bottom-left-radius: 3px;
}
.tbl tr.split-last .split-tick::before { bottom: 50%; }

/* Still used by the import previews, where space is tighter */
.split-lines {
  font-family: var(--mono); font-size: 10px; color: var(--text-3);
  line-height: 1.55; margin-top: 3px;
}

/* ── Stat strip ──────────────────────────────────────────── */

.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.stat {
  flex: 1 1 140px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 10px 13px;
}
.stat-label {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-3); margin-bottom: 2px;
}
.stat-value { font-family: var(--mono); font-size: 19px; font-weight: 500; }

/* ── Notices ─────────────────────────────────────────────── */

.notice { border-radius: var(--r); padding: 11px 14px; margin-bottom: 14px; font-size: 13px; }
.notice-warn { background: var(--gold-lt);  border: 1px solid var(--gold-br); }
.notice-ok   { background: var(--green-lt); border: 1px solid var(--green-br); }
.notice-bad  { background: var(--red-lt);   border: 1px solid var(--red-br); color: var(--red); }
.notice-title { font-weight: 500; margin-bottom: 4px; }
.notice ul { margin: 6px 0 0 18px; line-height: 1.7; }

.empty { text-align: center; padding: 44px 20px; color: var(--text-3); }
.empty-title { font-family: var(--disp); font-size: 16px; color: var(--text-2); margin-bottom: 5px; }

/* ── Drop zone ───────────────────────────────────────────── */

.drop {
  border: 2px dashed var(--border-2); border-radius: var(--r-l);
  padding: 30px 22px; text-align: center; cursor: pointer;
  background: var(--surface); transition: border-color .15s, background .15s;
  display: block;
}
.drop:hover, .drop.is-over { border-color: var(--accent); background: var(--accent-lt); }
.drop-title { font-family: var(--disp); font-size: 16px; margin: 8px 0 4px; }
.drop-hint  { font-size: 12px; color: var(--text-2); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ── Progress ────────────────────────────────────────────── */

.bar { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin: 10px 0; }
.bar-fill { height: 100%; background: var(--accent); transition: width .25s; }

/* ── Match screen ────────────────────────────────────────── */

.match-grid { display: grid; grid-template-columns: minmax(0,.85fr) minmax(0,1.15fr); gap: 16px; }
@media (max-width: 760px) { .match-grid { grid-template-columns: 1fr; } }

.viewer {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 9px;
}
.viewer-frame {
  background: var(--surface); border-radius: 4px; min-height: 240px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.viewer-frame img { max-width: 100%; max-height: 460px; display: block; }
.viewer-frame iframe { width: 100%; height: 460px; border: 0; }
.viewer-name {
  font-family: var(--mono); font-size: 11px; color: var(--text-2);
  margin-top: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.cand {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 9px 12px; margin-bottom: 7px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.cand:hover { background: var(--surface-2); }
.cand.is-sel { border-color: var(--accent); border-width: 2px; padding: 8px 11px; }
.cand-top { display: flex; justify-content: space-between; align-items: baseline; gap: 9px; }
.cand-desc { font-size: 14px; font-weight: 500; }
.cand-meta { font-size: 12px; color: var(--text-2); margin-top: 1px; }

kbd {
  font-family: var(--mono); font-size: 11px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px;
}
.keyhints { font-size: 12px; color: var(--text-3); line-height: 2; margin-top: 12px;
            border-top: 1px solid var(--border); padding-top: 10px; }

/* ── Documents grid ──────────────────────────────────────── */

.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 11px; }
.doc {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden; cursor: pointer;
  transition: border-color .12s;
}
.doc:hover { border-color: var(--border-2); }
.doc-thumb {
  height: 108px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-glyph { font-family: var(--disp); font-size: 21px; color: var(--text-3); }
.doc-info { padding: 7px 9px; }
.doc-name {
  font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-meta { font-size: 11px; color: var(--text-3); margin-top: 2px;
            display: flex; justify-content: space-between; gap: 6px; }

/* ── Sheet ───────────────────────────────────────────────── */

.sheet-bg {
  position: fixed; inset: 0; background: rgba(20,18,15,.42);
  z-index: 60; display: flex; align-items: flex-start; justify-content: center;
  padding: 26px 16px; overflow-y: auto;
}
.sheet-bg[hidden] { display: none; }
.sheet {
  background: var(--surface); border-radius: var(--r-l);
  width: 100%; max-width: 620px; margin: auto;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.sheet-head h2 { font-family: var(--disp); font-size: 17px; font-weight: 600; }
.sheet-body { padding: 18px; }
.sheet-foot {
  display: flex; gap: 8px; justify-content: flex-end; align-items: center;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border);
}

/* ── Split editor ────────────────────────────────────────── */

.alloc {
  display: flex; gap: 9px; align-items: flex-start; padding: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); margin-bottom: 8px;
}
.alloc-main { flex: 1; min-width: 0; }
.alloc-amt  { width: 108px; flex: 0 0 108px; }
.balance {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 13px; border-radius: var(--r); font-size: 13px; margin-top: 9px;
}
.balance-ok  { background: var(--green-lt); border: 1px solid var(--green-br); }
.balance-bad { background: var(--red-lt);   border: 1px solid var(--red-br); }

/* ── Toast ───────────────────────────────────────────────── */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(14px);
  bottom: calc(20px + env(safe-area-inset-bottom));
  background: var(--text); color: #fff; font-size: 13px;
  padding: 9px 17px; border-radius: 20px; z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 40px);
}
.toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-bad { background: var(--red); }

/* ── Mobile ──────────────────────────────────────────────── */

@media (max-width: 700px) {
  #main { padding: 16px 13px 70px; }
  .topbar-in { padding: 0 13px; }
  .brand-name { font-size: 16px; }
  .page-head h1 { font-size: 18px; }
  .stat { flex-basis: calc(50% - 5px); }
  .stat-value { font-size: 16px; }
  .filters .select, .filters .input { flex: 1 1 calc(50% - 4px); }
  .filters .grow { flex-basis: 100%; }
  .sheet-bg { padding: 0; align-items: flex-end; }
  .sheet { max-width: none; border-radius: var(--r-l) var(--r-l) 0 0;
           margin: 0; max-height: 92vh; overflow-y: auto; }
  .alloc { flex-wrap: wrap; }
  .alloc-amt { flex-basis: 100%; width: 100%; }
  .docs { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  .hide-sm { display: none !important; }
}

@media print {
  .topbar, .filters, .head-actions, .btn, .toast { display: none !important; }
  #main { padding: 0; max-width: none; }
  body { background: #fff; font-size: 11px; }
  .card { border-color: #ccc; break-inside: avoid; }
}
