/* Folio — mobile-first; desktop gets the left sidebar */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #1a2330;
  --ink-2: #55637a;
  --ink-3: #8b97ab;
  --line: #e3e7ee;
  --accent: #1f6f5c;
  --accent-deep: #14493d;
  --accent-ink: #ffffff;
  --good-bg: #e7f3ec; --good-ink: #1e6b43;
  --warn-bg: #fdf3e0; --warn-ink: #8a5a10;
  --neg: #a33a3a;
  --chosen-bg: #f4faf8;
  --tip-bg: #1a2330; --tip-ink: #ffffff;
  --shadow: rgba(26, 35, 48, .14);
  --radius: 12px;
}
html[data-theme="dark"] {
  --bg: #101314;
  --surface: #1a1e20;
  --ink: #e8eaed;
  --ink-2: #a9b1bb;
  --ink-3: #79828e;
  --line: #2c3236;
  --accent: #2f9a80;
  --accent-deep: #7fd0bc;
  --accent-ink: #ffffff;
  --good-bg: #12352a; --good-ink: #5cc79b;
  --warn-bg: #3a2f14; --warn-ink: #e2b355;
  --neg: #e07a7a;
  --chosen-bg: #14332b;
  --tip-bg: #e8eaed; --tip-ink: #101314;
  --shadow: rgba(0, 0, 0, .5);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  padding-bottom: 70px; /* room for bottom tabs on mobile */
}
[hidden] { display: none !important; } /* class display rules must not defeat the hidden attribute */

/* ---- shell: sidebar (desktop) / top strip + bottom tabs (mobile) ---- */
.side {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; text-decoration: none; }
.mock-badge {
  font-size: 11px; font-weight: 700; letter-spacing: .6px;
  background: var(--warn-bg); color: var(--warn-ink);
  padding: 3px 8px; border-radius: 20px;
}
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a {
  flex: 1; text-align: center; padding: 13px 4px max(13px, env(safe-area-inset-bottom));
  text-decoration: none; color: var(--ink-2); font-size: 13px; font-weight: 600;
}
.tabs a.active { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.pill {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 2px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 10px; font-size: 11px; line-height: 18px;
}
#theme-toggle {
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  background: none; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  white-space: nowrap;
}
#theme-toggle:hover { color: var(--ink); border-color: var(--ink-3); }

main { max-width: 860px; margin: 0 auto; padding: 16px; }
/* wide views: reports, registers, chart of accounts stretch to the browser */
body[data-view="reports"] main, body[data-view="register"] main, body[data-view="accounts"] main {
  max-width: min(1550px, 97vw);
}
body[data-view="reports"] .report { font-size: 12px; }
body[data-view="reports"] .report td { padding: 4px 6px; }
h2 { font-size: 16px; margin: 22px 0 10px; }
h2:first-child { margin-top: 4px; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px;
}
.tile .label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.tile .value { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .value.neg { color: var(--neg); }
.tile .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px;
}

.txrow { display: flex; gap: 10px; align-items: baseline; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.txrow:last-child { border-bottom: none; }
.txmain { flex: 1; min-width: 0; }
.txdesc { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txmeta { font-size: 12px; color: var(--ink-2); }
.txamt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.txamt.neg { color: var(--neg); }

.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 10px; }
.badge.auto, .badge.approved, .badge.matched { background: var(--good-bg); color: var(--good-ink); }
.badge.pending { background: var(--warn-bg); color: var(--warn-ink); }

select, button, input, textarea {
  font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
}
input[type="checkbox"] { padding: 0; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button { cursor: pointer; }
.review-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.bulk-bar { display: flex; gap: 12px; align-items: center; position: sticky; top: 8px; z-index: 20; flex-wrap: wrap; }
.bulk-all { display: flex; gap: 7px; align-items: center; font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; cursor: pointer; }
.bulk-pick { display: flex; align-items: center; padding-right: 4px; cursor: pointer; }
.bulk-check, #bulk-all { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.attach-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 12px; border-radius: 8px; border: 1px solid #4682B4;
  background: #4682B4; color: #fff; font-weight: 600; font-size: 14px; cursor: pointer;
  white-space: nowrap;
}
.attach-btn:hover { background: #3d739e; }
.attach-btn input { display: none; }
.attach-btn.attach-sm { padding: 5px 10px; font-size: 12px; margin-top: 4px; }

.combo { position: relative; flex: 1; min-width: 200px; }
.combo input { width: 100%; }
.combo input.combo-chosen { border-color: var(--accent); background: var(--chosen-bg); }
.combo-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  max-height: 260px; overflow-y: auto; box-shadow: 0 8px 24px var(--shadow);
}
.combo-item { padding: 8px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.combo-item:hover { background: var(--bg); }
.combo-type { font-size: 11px; color: var(--ink-3); }
.combo-empty { padding: 10px; color: var(--ink-3); }

/* dashboard charts */
.chart-card svg { display: block; width: 100%; height: auto; }
.chart-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
#viz-tip {
  position: fixed; z-index: 99; pointer-events: none; background: var(--tip-bg); color: var(--tip-ink);
  font-size: 12px; padding: 6px 9px; border-radius: 6px; display: none; white-space: nowrap;
}

.confidence { font-size: 12px; color: var(--ink-3); }

table.report { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.report td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.report td.num { text-align: right; white-space: nowrap; }
table.report tr.section td { font-weight: 700; border-bottom: 2px solid var(--ink-2); padding-top: 14px; }
table.report tr.total td { font-weight: 700; border-top: 2px solid var(--ink-2); border-bottom: none; }
.report-controls { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
/* segmented toggle (Activity: All | Bank | Card) */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: none; border-radius: 0; padding: 7px 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.act-empty { padding: 14px 0; }

.receipt-link { font-size: 12px; }
.attach-label {
  display: inline-block; font-size: 12px; font-weight: 600; color: var(--accent);
  cursor: pointer; margin-top: 4px;
}
.attach-label input { display: none; }

/* receipt thumbnails + lightbox */
.rthumb {
  height: 46px; width: 46px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line); cursor: zoom-in; display: block; background: var(--bg);
}
.rthumb:hover { border-color: var(--accent); }
.rpdf {
  height: 46px; width: 46px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 6px; cursor: zoom-in;
  font-size: 10px; font-weight: 700; color: var(--neg); background: var(--bg);
}
.rwrap { display: inline-block; margin-top: 4px; }
#lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, .72);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
#lightbox-panel {
  background: var(--surface); border-radius: 12px; max-width: 94vw; max-height: 92vh;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
#lightbox-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
#lightbox-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-btn {
  display: inline-block; font-size: 13px; font-weight: 600; text-decoration: none;
  color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 11px; cursor: pointer;
}
.lb-btn:hover { border-color: var(--accent); color: var(--accent); }
#lightbox-body { overflow: auto; display: flex; align-items: center; justify-content: center; }
#lightbox-body img { max-width: 92vw; max-height: calc(92vh - 58px); object-fit: contain; display: block; }
#lightbox-body iframe { width: 86vw; height: calc(92vh - 58px); border: none; }

/* refund pairing popup */
#pair-modal {
  position: fixed; inset: 0; z-index: 210; background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.pair-panel {
  background: var(--surface); border-radius: 12px; width: 520px; max-width: 100%; max-height: 92vh; overflow: auto;
  padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.pair-panel h3 { margin: 0 0 14px; font-size: 17px; }
.pair-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.pair-refund { background: var(--bg); }
.pair-cand { margin-top: 8px; cursor: pointer; }
.pair-cand:has(input:checked) { border-color: var(--accent); }
.pair-q { font-size: 13px; color: var(--ink-2); margin: 12px 0 0; }
.pair-leaf { margin-top: 12px; }
.pair-leaf .combo { margin-top: 6px; }
.pair-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 10px; }

.empty { color: var(--ink-3); text-align: center; padding: 30px 0; }

.table-scroll { overflow-x: auto; }
a.drill { color: var(--ink); text-decoration: underline dotted var(--ink-3); text-underline-offset: 3px; }
a.drill:hover { color: var(--accent); }

/* chart of accounts tree */
.coa-hint { font-size: 12px; color: var(--ink-3); margin-bottom: 10px; }
.coa-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.coa-addroot { font-size: 12px; }
.coa-node .coa-kids { margin-left: 22px; }
.coa-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px; border-radius: 6px;
  cursor: grab; user-select: none;
}
.coa-row:hover { background: var(--bg); }
.coa-row.drop-hint, .coa-header.drop-hint { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--good-bg); }
.coa-caret { width: 16px; text-align: center; color: var(--ink-2); cursor: pointer; }
.coa-leafdot { color: var(--ink-3); cursor: default; }
.coa-name { font-weight: 600; }
.coa-code { font-size: 11px; color: var(--ink-3); }
.coa-tag { font-size: 10px; font-weight: 700; background: var(--warn-bg); color: var(--warn-ink); padding: 1px 6px; border-radius: 8px; }
.coa-tools { margin-left: auto; visibility: hidden; display: flex; gap: 4px; }
.coa-row:hover .coa-tools { visibility: visible; }
.coa-tools button { padding: 2px 7px; font-size: 12px; }

.coa-root .coa-name, .coa-group2 .coa-name { font-weight: 700; }
.coa-group .coa-name { font-weight: 700; color: var(--ink-2); }
.coa-menu {
  position: fixed; z-index: 100; min-width: 190px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px var(--shadow); padding: 6px; display: flex; flex-direction: column;
}
.coa-menu-title { font-size: 11px; font-weight: 700; color: var(--ink-3); padding: 4px 8px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.coa-menu button { border: none; background: none; text-align: left; padding: 7px 8px; border-radius: 6px; font-size: 13px; }
.coa-menu button:hover { background: var(--bg); }
.coa-menu .coa-danger { color: var(--neg); }

/* journal entry form */
.je-line { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; flex-wrap: wrap; }
.je-line input[type="number"] { width: 110px; }
.je-remove { padding: 6px 10px; }

.rep-dl { display: inline-flex; gap: 8px; font-weight: 400; }

/* 1099 recipient copies */
.f1099-form { border: 2px solid #333; border-radius: 6px; padding: 16px; margin: 0 0 18px; page-break-inside: avoid; page-break-after: always; background: #fff; color: #111; }
.f1099-head { border-bottom: 2px solid #333; padding-bottom: 8px; margin-bottom: 12px; }
.f1099-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 12px; }
.f1099-label { font-size: 10px; font-weight: 700; letter-spacing: .8px; color: #555; }
.f1099-box { border: 2px solid #333; border-radius: 4px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; font-size: 18px; margin-bottom: 8px; }

/* ---- print / save-as-PDF: one statement, landscape, on white ---- */
@page { size: landscape; margin: 12mm; }
@media print {
  body.print-is #card-bs { display: none !important; }
  body.print-bs #card-is { display: none !important; }
  body.print-1099 main > *:not(#f1099) { display: none !important; }
  body.print-1099 #f1099 { display: block !important; }
  html, html[data-theme="dark"] {
    --bg: #fff; --surface: #fff; --ink: #111; --ink-2: #444; --ink-3: #777; --line: #ccc;
  }
  body { background: #fff; padding: 0; }
  .side, .no-print, #theme-toggle, button, .tabs { display: none !important; }
  .shell { display: block; }
  main { max-width: none; padding: 0; }
  .card { border: none; padding: 0; margin-bottom: 18px; }
  .table-scroll { overflow: visible; }
  table.report { font-size: 10px; }
  a.drill { text-decoration: none; color: #111; }
  h2 { page-break-after: avoid; }
}

/* ---- desktop: real left sidebar ---- */
@media (min-width: 700px) {
  body { padding-bottom: 0; }
  .shell { display: flex; min-height: 100vh; align-items: stretch; }
  .side {
    flex: 0 0 188px; position: sticky; top: 0; align-self: flex-start; height: 100vh;
    display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start;
    gap: 14px; padding: 18px 14px; border-bottom: none; border-right: 1px solid var(--line);
  }
  .brand { padding: 2px 6px; }
  .mock-badge { align-self: flex-start; margin-left: 6px; }
  .tabs {
    position: static; display: flex; flex-direction: column; gap: 2px;
    background: none; border: none;
  }
  .tabs a {
    flex: none; text-align: left; padding: 10px 12px; border-radius: 8px; font-size: 14px;
  }
  .tabs a.active { box-shadow: none; background: var(--good-bg); color: var(--accent); }
  .tabs a:hover:not(.active) { background: var(--bg); }
  #theme-toggle { margin-top: auto; }  /* pinned to the lower left */
  .content { flex: 1 1 auto; min-width: 0; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
}

/* live filter search + per-transaction notes (2026-10-04) */
.live-search { flex: 1; min-width: 180px; }
.txnote { font-size: 12px; margin-top: 2px; }
.note-text { color: var(--ink-2); font-style: italic; }
.note-btn { color: var(--accent); text-decoration: none; font-size: 11px; font-weight: 600; }
.note-btn:hover { text-decoration: underline; }
.note-edit { width: 100%; max-width: 420px; font-size: 12px; padding: 5px 8px; }
