:root {
  --ink: #1e2430;
  --ink-soft: #5a6475;
  --paper: #f6f7f9;
  --card: #ffffff;
  --line: #e4e7ec;
  --brand: #175e54;      /* deep evergreen */
  --brand-soft: #e3efec;
  --accent: #c9a24b;     /* brass */
  --pos: #177a4c;
  --neg: #b3382c;
  --radius: 12px;
  --display-font: inherit;
  --sidebar-bg: var(--brand);
  --sidebar-text: #ffffff;
  font-size: 15px;
}

/* ---- Theme: Ink & Ivory — editorial, serif, gallery-quiet ---- */
[data-theme="ivory"] {
  --ink: #211d18;
  --ink-soft: #77705f;
  --paper: #faf7f1;
  --card: #fffdf8;
  --line: #e9e2d3;
  --brand: #26221b;
  --brand-soft: #f0ebe0;
  --accent: #9a6a3f;
  --pos: #4a6b53;
  --neg: #9c3f2e;
  --radius: 6px;
  --display-font: "Fraunces", Georgia, serif;
  --sidebar-bg: #26221b;
  --sidebar-text: #f5f0e6;
}
[data-theme="ivory"] h1, [data-theme="ivory"] h3, [data-theme="ivory"] .logo,
[data-theme="ivory"] .card.stat .big { font-family: var(--display-font); font-weight: 600; }
[data-theme="ivory"] .bar-fill { background: #9a6a3f; }
[data-theme="ivory"] .bar-track { background: #f0ebe0; }

/* ---- Theme: Navy Ledger — classic banker's navy & brass ---- */
[data-theme="navy"] {
  --ink: #17202e;
  --ink-soft: #5b6778;
  --paper: #f3f5f8;
  --card: #ffffff;
  --line: #dfe4ec;
  --brand: #1d3557;
  --brand-soft: #e5ebf4;
  --accent: #c9a24b;
  --pos: #1e6e4e;
  --neg: #a63a3a;
  --radius: 10px;
  --sidebar-bg: #1d3557;
  --sidebar-text: #ffffff;
}

/* ---- Theme: Gallery — white, minimal, single ochre accent ---- */
[data-theme="gallery"] {
  --ink: #191919;
  --ink-soft: #6f6f6f;
  --paper: #ffffff;
  --card: #ffffff;
  --line: #e6e6e6;
  --brand: #b4532a;
  --brand-soft: #f7ece6;
  --accent: #b4532a;
  --pos: #2f7a4d;
  --neg: #b4532a;
  --radius: 4px;
  --display-font: "Fraunces", Georgia, serif;
  --sidebar-bg: #ffffff;
  --sidebar-text: #191919;
}
[data-theme="gallery"] .sidebar { border-right: 1px solid var(--line); }
[data-theme="gallery"] #nav a:hover { background: #f3f3f3; }
[data-theme="gallery"] #nav a.active { background: #191919; color: #fff; }
[data-theme="gallery"] h1, [data-theme="gallery"] .logo { font-family: var(--display-font); font-weight: 600; }
[data-theme="gallery"] .card { border-radius: 4px; }
[data-theme="gallery"] .sync.ok { color: #2f7a4d; } [data-theme="gallery"] .sync.off { color: #b4532a; }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--paper); color: var(--ink);
  font-family: "Albert Sans", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

#app { display: none; min-height: 100vh; }
.sidebar { width: 210px; flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-text); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.logo { font-weight: 800; font-size: 1.15rem; letter-spacing: .3px; padding: 6px 10px 16px; }
.logo small { display: block; font-weight: 400; opacity: .75; font-size: .72rem; }
#nav a { display: flex; gap: 10px; align-items: center; color: var(--sidebar-text); padding: 9px 12px; border-radius: 8px; opacity: .85; }
#nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; opacity: 1; }
#nav a.active { background: rgba(255,255,255,.18); opacity: 1; font-weight: 600; }
.sidebar .foot { margin-top: auto; font-size: .75rem; opacity: .8; padding: 10px; }
.sidebar .foot select { width: 100%; font-size: .78rem; padding: 4px 6px; background: transparent; color: var(--sidebar-text); border: 1px solid rgba(128,128,128,.45); border-radius: 6px; }
.sidebar .foot select option { color: #1e2430; background: #fff; }
.sync.ok { color: #a9e5c8; } .sync.off { color: #ffd28a; }

.main { flex: 1; padding: 26px 32px 60px; max-width: 1200px; }
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
h1 { margin: 0; font-size: 1.5rem; }
h3 { margin: 4px 0 12px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--ink-soft); font-size: .85rem; }

.cards { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; flex: 1; min-width: 240px; margin-bottom: 14px; }
.cards .card { margin-bottom: 0; }
.card.stat .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.card.stat .big { font-size: 1.7rem; font-weight: 800; margin: 4px 0; }
.card.stat .sub { color: var(--ink-soft); font-size: .85rem; }
.cardlink { display: inline-block; margin-top: 8px; font-size: .85rem; }
.kidrow { display: flex; justify-content: space-between; padding: 3px 0; }

.btn { display: inline-block; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font: inherit; color: var(--ink); }
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.block { display: block; margin-bottom: 8px; text-align: left; }
.mini { font-size: .75rem; padding: 2px 8px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; }
.mini.danger { color: var(--neg); }
.mini.danger:hover { border-color: var(--neg); }

.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
select, input { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
input.num { text-align: right; width: 120px; }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); padding: 8px 8px; border-bottom: 2px solid var(--line); }
.table td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
.table .r, th.r, td.r { text-align: right; }
.table.half { max-width: 640px; }
.nowrap { white-space: nowrap; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.total-row td { border-top: 2px solid var(--ink); }
tr.settled { opacity: .55; }
.scroll-x { overflow-x: auto; }
.cat-select { font-size: .82rem; padding: 3px 6px; max-width: 170px; }

.bar-row { display: grid; grid-template-columns: 160px 1fr 150px; gap: 10px; align-items: center; margin: 7px 0; }
.bar-label { font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--brand-soft); border-radius: 6px; height: 18px; }
.bar-fill { background: var(--brand); height: 100%; border-radius: 6px; min-width: 2px; }
.bar-val { font-size: .85rem; text-align: right; white-space: nowrap; }

.empty { text-align: center; padding: 30px 20px; }
.empty h3 { margin-bottom: 6px; }
.insights li { margin-bottom: 6px; }

/* statement document */
.statement-doc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 34px 40px; }
.pfs-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px double var(--ink); padding-bottom: 12px; margin-bottom: 18px; }
.pfs-title { font-size: 1.45rem; font-weight: 800; font-family: Georgia, "Times New Roman", serif; }
.pfs-sub, .pfs-date { color: var(--ink-soft); margin-top: 6px; }
.pfs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.pfs-h { font-family: Georgia, serif; border-bottom: 1px solid var(--ink); padding-bottom: 4px; margin-top: 20px; }
.pfs-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.pfs-table th { text-align: left; font-size: .72rem; text-transform: uppercase; color: var(--ink-soft); padding: 4px 6px; }
.pfs-table td { padding: 2px 6px; }
.pfs-table tfoot td { border-top: 2px solid var(--ink); padding-top: 6px; font-size: .95rem; }
.pfs-table.half { max-width: 560px; }
.cat-row td { font-weight: 700; padding-top: 12px; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--brand); }
.cell { border: none; border-bottom: 1px dashed transparent; border-radius: 0; padding: 3px 4px; width: 100%; background: transparent; }
.cell:hover, .cell:focus { border-bottom-color: var(--accent); outline: none; background: #fdfaf2; }
.cell.num { text-align: right; }
.cell.inline { width: auto; display: inline-block; }
.networth-box { margin-top: 16px; background: var(--brand-soft); border-radius: 8px; padding: 12px 16px; display: flex; justify-content: space-between; font-size: 1.05rem; }
.networth-box b { font-size: 1.2rem; }
.pfs-sign { display: flex; gap: 40px; flex-wrap: wrap; margin-top: 34px; font-size: .9rem; color: var(--ink-soft); }
.pfs-foot { margin-top: 14px; font-size: .75rem; }

/* sign-in */
#signin-overlay { display: none; position: fixed; inset: 0; background: var(--brand); align-items: center; justify-content: center; flex-direction: column; gap: 18px; color: #fff; text-align: center; padding: 20px; }
#signin-overlay h1 { font-size: 1.6rem; }
#signin-error { color: #ffd2c9; min-height: 20px; }

/* toast */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; opacity: 0; transform: translateY(8px); transition: all .3s; z-index: 99; max-width: 380px; }
.toast.show { opacity: 1; transform: none; }
.toast.bad { background: var(--neg); }

@media (max-width: 780px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; align-items: center; padding: 8px; }
  .logo { padding: 0 10px; font-size: .95rem; } .logo small { display: none; }
  #nav { display: flex; } #nav a span:not(.icon) { display: none; }
  .sidebar .foot { display: none; }
  .main { padding: 16px; }
  .pfs-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 110px; }
}

@media print {
  .sidebar, .no-print, .head-actions, .filters, .toast { display: none !important; }
  body, .main { background: #fff; padding: 0; max-width: none; }
  .card, .statement-doc { border: none; padding: 0; }
  .page-head h1 { font-size: 1.2rem; }
  .cell { border: none !important; background: transparent !important; }
  .cat-select { appearance: none; border: none; background: transparent; }
}
