/* Our Money Hub · Emerald ledger (dark). No brown, no orbs. */
:root {
  --bg: #04130d;
  --side: #061a12;
  --card: #0b261a;
  --card-2: #0f3022;
  --border: #1c4634;
  --text: #ecf7f1;
  --muted: #a9cbbb;
  --accent: #34d399;
  --accent-2: #10b981;
  --accent-ink: #022417;
  --link: #6ee7b7;
  --pos: #4ade80;
  --neg: #fca5a5;
  --warn: #fde047;
  --radius: 14px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: #a7f3d0; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: .85rem; margin-top: .9rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
small { display: block; color: var(--muted); font-size: .8rem; }
code { font: .8rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }
.ico { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico circle[r="1.6"] { fill: currentColor; stroke: none; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; width: 248px; flex: none;
  background: var(--side); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.05rem; min-height: 44px; padding: 0 6px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 550; }
.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active { background: var(--card-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav-item.active .ico { color: var(--accent); }
.side-note { margin-top: auto; font-size: .8rem; color: var(--muted); padding: 0 6px; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 28px; background: rgba(4, 19, 13, .9); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.topbar h1 { font-size: 1.35rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; gap: 10px; align-items: center; flex: none; }
.demo-banner { margin: 16px 28px 0; padding: 10px 14px; border: 1px solid #3d6b58; background: #0d2a1e; border-radius: 10px; font-size: .9rem; color: var(--text); }
main { padding: 20px 28px 32px; display: flex; flex-direction: column; gap: 18px; outline: none; }
.foot { margin-top: auto; padding: 16px 28px 24px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: .8rem; color: var(--muted); border-top: 1px solid var(--border); }
.lede { margin: 0; color: var(--muted); }
.loading, .empty { color: var(--muted); margin: 0; }

/* controls */
select, input {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid #3a6a56;
  border-radius: 10px; min-height: 44px; padding: 8px 12px; width: 100%; min-width: 0;
}
select { padding-right: 32px; }
input::placeholder { color: #86a99a; }
.cur-pick select { width: auto; font-weight: 650; }
label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--muted); min-width: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid #3a6a56;
  background: var(--card-2); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--text); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #6ee7b7; color: var(--accent-ink); }
.btn-ghost { background: transparent; }
.btn-danger { border-color: #7f3b3b; color: #fecaca; background: #2a1414; }
.btn-small { min-height: 44px; padding: 0 12px; font-size: .9rem; align-self: flex-start; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.add-btn span[aria-hidden] { font-size: 1.3rem; line-height: 1; }
.icon-btn { flex: none; width: 44px; height: 44px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 1.4rem; cursor: pointer; }
.icon-btn:hover { border-color: #7f3b3b; color: #fecaca; }

/* cards, KPIs, board */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpis.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; border-top: 3px solid var(--border); }
.kpi.pos { border-top-color: var(--pos); }
.kpi.neg { border-top-color: var(--neg); }
.kpi.acc { border-top-color: var(--accent); }
.kpi-label { margin: 0; font-size: .85rem; color: var(--muted); }
.kpi-value { margin: 4px 0 2px; font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-sub { margin: 0; font-size: .8rem; color: var(--muted); }
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; align-items: start; }
.list { background: var(--side); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.list-wide { grid-column: 1 / -1; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.list-link { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px; font-size: .9rem; }
.big { margin: 0; font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.big small { display: inline; font-size: .9rem; font-weight: 500; }
.muted { color: var(--muted); margin: 0; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.acc { color: var(--accent); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.mini { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.mini li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--border); min-height: 44px; }
.mini li:last-child { border-bottom: 0; }
.mini li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.gh-mini { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); column-gap: 18px; }
.gh-mini li:last-child { border-bottom: 1px solid var(--border); }
.cats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.cat-row { display: flex; justify-content: space-between; gap: 10px; font-size: .95rem; margin-bottom: 6px; }
.bar { height: 8px; border-radius: 99px; background: #163b2b; overflow: hidden; }
.bar span { display: block; height: 100%; width: var(--w, 0%); border-radius: inherit; background: var(--accent); }
.bar.ok span { background: var(--pos); }
.bar.warn span { background: var(--warn); }
.bar.bad span { background: #f87171; }
.pill { display: inline-flex; align-items: center; min-height: 28px; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 650; border: 1px solid currentColor; white-space: nowrap; text-decoration: none; }
a.pill { min-height: 44px; }
.pill.ok { color: var(--pos); }
.pill.warn { color: var(--warn); }
.pill.bad { color: var(--neg); }
.pill.acc { color: var(--accent); }
.pill.muted { color: var(--muted); }

/* transactions */
.txs { list-style: none; margin: 0; padding: 0; }
.tx { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); min-height: 56px; }
.tx:last-child { border-bottom: 0; }
.tx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tx-label { font-weight: 600; overflow-wrap: anywhere; }
.tx-meta { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.tx-amt { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; display: flex; flex-direction: column; }
.tx-amt .orig { font-size: .75rem; color: var(--muted); font-weight: 500; }
.compact .tx { min-height: 48px; }
.count { margin: 0; font-size: .85rem; color: var(--muted); }
.filters { display: grid; grid-template-columns: 200px 170px 1fr; gap: 10px; }
.add-card summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 650; color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid h2, .span2 { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hint { font-size: .85rem; color: var(--muted); }
.inline-form { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: end; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; align-items: start; }

/* P/L chart and tables */
.chart { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; height: 200px; align-items: end; }
.chart-col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.bars span { width: min(22px, 40%); height: var(--h, 2%); border-radius: 6px 6px 2px 2px; }
.b-in, .k-in { background: var(--accent); }
.b-out, .k-out { background: #f87171; }
.chart-x { font-size: .8rem; color: var(--muted); }
.legend { margin: 0; font-size: .85rem; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-left: 8px; }
.key:first-child { margin-left: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .95rem; }
th, td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child { text-align: left; }
thead th { font-size: .8rem; color: var(--muted); font-weight: 600; }
th small { display: inline; margin-left: 6px; }

/* settings */
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg-btn { min-height: 44px; min-width: 64px; border-radius: 10px; border: 1px solid #3a6a56; background: var(--bg); color: var(--text); font: inherit; font-weight: 650; cursor: pointer; }
.seg-btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* GitHub projects */
.gh-bar { gap: 10px; }
.gh-status { margin: 0; color: var(--muted); font-size: .9rem; }
.gh-tools { display: flex; gap: 10px; }
.grow { flex: 1; }
.repo-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.repo-head h2 { overflow-wrap: anywhere; min-width: 0; }
.repo-head h2 a { display: inline-flex; min-height: 44px; min-width: 44px; align-items: center; }
.gh-mini a { display: inline-flex; min-height: 44px; align-items: center; }
.repo-tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.repo-meta { margin: 0; font-size: .85rem; color: var(--muted); }
.commits { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.commits li { font-size: .9rem; overflow-wrap: anywhere; }
.commits a { display: block; padding: 8px 0 0; min-height: 36px; }
.repo details summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--link); font-size: .9rem; }

.more-list { padding: 6px; gap: 0; }
.more-item { display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 0 12px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border); font-weight: 600; }
.more-item:last-child { border-bottom: 0; }
.more-item .chev { margin-left: auto; color: var(--muted); font-size: 1.4rem; }
.noscript { padding: 20px; }

/* phone bottom tab bar (glass) */
.tabbar { display: none; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar { display: none; }
  .topbar { padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
  .topbar h1 { font-size: 1.15rem; }
  .demo-banner { margin: 12px 14px 0; font-size: .85rem; }
  main { padding: 14px 14px 20px; gap: 14px; }
  .foot { padding: 14px 14px calc(var(--tab-h) + var(--safe-b) + 20px); }
  .kpis, .kpis.three { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: 1.15rem; }
  .board, .grid-cards { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 14px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .grow { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .inline-form { grid-template-columns: 1fr 1fr; }
  .inline-form label { grid-column: 1 / -1; }
  .chart { height: 160px; gap: 6px; }
  .add-label { display: none; }
  .add-btn { width: 44px; padding: 0; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 8px; right: 8px; bottom: calc(8px + var(--safe-b)); z-index: 20;
    height: var(--tab-h); border-radius: 20px;
    background: rgba(8, 36, 25, .72); border: 1px solid rgba(110, 231, 183, .22);
    backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .45);
  }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; color: #c2ddd0; text-decoration: none; font-size: .72rem; font-weight: 600; border-radius: 16px; margin: 4px 2px; }
  .tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab.active { color: var(--accent-ink); background: var(--accent); }
}
@media (max-width: 380px) {
  .kpi-value { font-size: 1.05rem; }
  .big { font-size: 1.3rem; }
  .tab { font-size: .68rem; }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .tabbar { background: #0b2a1d; }
}
@media (prefers-reduced-motion: no-preference) {
  .bar span { transition: width .4s ease; }
  .nav-item, .btn, .tab { transition: background-color .15s, color .15s, border-color .15s; }
}
.lede-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.month-pick { flex-direction: row; align-items: center; gap: 8px; }
.month-pick select { width: auto; }
main:focus, main:focus-visible { outline: none; }
@media (max-width: 560px) {
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack, table.stack tbody { display: block; }
  table.stack tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  table.stack th[scope="row"] { grid-column: 1 / -1; border: 0; padding: 0 0 4px; text-align: left; }
  table.stack td { border: 0; padding: 3px 0; text-align: left; display: flex; flex-direction: column; white-space: normal; }
  table.stack td::before { content: attr(data-label); font-size: .75rem; color: var(--muted); }
}
