:root {
  --bg: #f3f2ec;
  --paper: #fffefa;
  --ink: #172019;
  --muted: #687068;
  --line: #dedfd7;
  --nav: #111a16;
  --accent: #c7f36b;
  --accent-dark: #4d7014;
  --danger: #c64532;
  --positive: #277a4b;
  --shadow: 0 18px 48px rgba(18, 28, 22, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 242px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 18px; background: var(--nav); color: #f8fbf4; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 32px; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { width: 54px; height: 54px; border-radius: 17px; display: grid; place-items: center; background: var(--accent); color: #15200f; font-weight: 900; letter-spacing: -.08em; }
.brand-mark.small { width: 34px; height: 34px; border-radius: 10px; font-size: 13px; }
nav { display: grid; gap: 6px; }
nav button { border: 0; color: #abb5ad; background: transparent; border-radius: 12px; padding: 12px 14px; text-align: left; display: flex; gap: 12px; align-items: center; }
nav button span { width: 22px; text-align: center; font-size: 19px; }
nav button:hover, nav button.active { color: white; background: #263129; }
nav button.active { box-shadow: inset 3px 0 var(--accent); }
.sidebar-foot { margin-top: auto; padding: 14px 10px; color: #8e9a91; font-size: 12px; }
.status-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--accent); margin-right: 7px; box-shadow: 0 0 0 5px rgba(199,243,107,.09); }
main { min-width: 0; padding: 0 36px 60px; }
.topbar { min-height: 112px; display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.topbar h1 { margin: 3px 0 0; font-size: clamp(25px, 3vw, 38px); letter-spacing: -.045em; }
.eyebrow { margin: 0; font-size: 10px; letter-spacing: .16em; font-weight: 800; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.icon-button { border: 1px solid var(--line); width: 39px; height: 39px; border-radius: 50%; background: var(--paper); }
#menu-button { display: none; }
.view { display: none; animation: lift .22s ease-out; }
.view.active { display: block; }
@keyframes lift { from { opacity: 0; transform: translateY(5px); } }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.metric, .panel, .capture-card { background: var(--paper); border: 1px solid rgba(30,45,35,.08); border-radius: 20px; box-shadow: var(--shadow); }
.metric { min-height: 154px; padding: 22px; display: flex; flex-direction: column; }
.metric.hero { background: var(--nav); color: white; }
.metric span { font-size: 12px; color: var(--muted); }
.metric.hero span, .metric.hero small { color: #aeb8b0; }
.metric strong { margin: auto 0 5px; font-size: clamp(25px, 2.6vw, 38px); letter-spacing: -.055em; white-space: nowrap; }
.metric small { color: var(--muted); }
.two-column { display: grid; grid-template-columns: 1.45fr 1fr; gap: 14px; margin-bottom: 14px; }
.panel { padding: 22px; margin-bottom: 14px; }
.panel h2, .capture-card h2 { margin: 4px 0 0; font-size: 20px; letter-spacing: -.025em; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.pill { padding: 7px 10px; border-radius: 999px; font-weight: 750; font-size: 12px; background: #e6f6df; color: var(--positive); }
.cashflow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.cashflow div { padding: 14px; border: 1px solid var(--line); border-radius: 14px; }
.cashflow span { display: block; color: var(--muted); font-size: 12px; }
.cashflow strong { display: block; margin-top: 5px; font-size: 22px; }
.bar-chart { min-height: 130px; display: flex; align-items: flex-end; gap: 10px; overflow-x: auto; padding-top: 10px; }
.bar-item { min-width: 48px; flex: 1; text-align: center; }
.bar { min-height: 4px; border-radius: 8px 8px 3px 3px; background: var(--accent); border: 1px solid #abd54d; }
.bar-item span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 10px; margin-top: 7px; }
.breakdown { display: grid; gap: 9px; }
.breakdown-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding-bottom: 9px; border-bottom: 1px solid var(--line); font-size: 13px; }
.breakdown-row span { color: var(--muted); }
.breakdown-row.total { font-weight: 800; border: 0; font-size: 15px; padding-top: 6px; }
.transaction-list { display: grid; }
.transaction-item { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.transaction-item:last-child { border-bottom: 0; }
.transaction-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: #eef0e9; font-weight: 800; }
.transaction-item p { margin: 0; font-weight: 650; }
.transaction-item small { color: var(--muted); }
.amount.expense { color: var(--danger); }
.amount.income { color: var(--positive); }
.text-button { border: 0; background: transparent; color: var(--accent-dark); }
.capture-card { padding: 24px; display: grid; grid-template-columns: 1fr minmax(360px, 1.2fr); gap: 24px; align-items: end; margin-bottom: 14px; }
.capture-card p:not(.eyebrow), .import-panel p, .muted { color: var(--muted); font-size: 13px; }
#capture-form { display: grid; grid-template-columns: 1fr 180px auto; gap: 8px; }
input, select { min-width: 0; width: 100%; border: 1px solid var(--line); background: #fafaf6; border-radius: 11px; padding: 11px 12px; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: #91b94a; box-shadow: 0 0 0 3px rgba(199,243,107,.25); }
.primary, .secondary { border-radius: 11px; padding: 11px 15px; font-weight: 750; border: 1px solid transparent; }
.primary { background: var(--nav); color: white; }
.primary:hover { background: #273229; }
.secondary { background: transparent; border-color: var(--line); color: var(--ink); }
.bulk-row { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 12px; }
.bulk-row select { max-width: 260px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-size: 10px; letter-spacing: .09em; text-transform: uppercase; }
th, td { padding: 12px 9px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td:nth-child(3) { white-space: normal; min-width: 180px; }
.import-panel { display: grid; grid-template-columns: 1fr 1.5fr; gap: 24px; }
#import-form { align-self: center; display: grid; grid-template-columns: 1fr 170px auto; gap: 8px; }
#import-result { grid-column: 1 / -1; }
.import-errors { margin: 12px 0; color: var(--danger); font-size: 13px; }
.import-errors summary { cursor: pointer; font-weight: 700; }
.import-errors li { margin: 5px 0; }
.import-blocked { color: var(--danger) !important; font-weight: 700; }
.card-list { display: grid; gap: 9px; margin: 18px 0; }
.card-list.horizontal { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.list-card { border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list-card strong, .list-card span { display: block; }
.list-card small { color: var(--muted); }
.stack-form { display: grid; gap: 9px; padding-top: 16px; border-top: 1px solid var(--line); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.inline-form { display: grid; grid-template-columns: repeat(5, minmax(110px, 1fr)) auto; gap: 8px; padding-top: 17px; border-top: 1px solid var(--line); }
.bank-controls { display: flex; align-items: center; gap: 9px; }
.bank-controls select { max-width: 420px; }
.bank-mapping { display: grid; gap: 10px; width: 100%; }
.bank-map-row { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto; gap: 10px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 14px; }
.bank-map-row small, .bank-error { display: block; color: var(--muted); margin-top: 4px; }
.bank-error { color: var(--danger); }
.bank-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.legal-links { display: flex; gap: 12px; margin-top: 9px; }
.legal-links a { color: var(--muted); font-size: 12px; }
.big-number { font-size: 50px; font-weight: 850; letter-spacing: -.06em; margin: 25px 0; }
.limit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.limit-card { border: 1px solid var(--line); padding: 14px; border-radius: 14px; }
.limit-card span { display: block; color: var(--muted); font-size: 12px; }
.limit-card strong { display: block; margin-top: 7px; font-size: 20px; }
.flash { position: sticky; top: 10px; z-index: 5; margin-bottom: 12px; padding: 13px 16px; border-radius: 12px; background: var(--nav); color: white; box-shadow: var(--shadow); }
.flash.error { background: #6c251c; }
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); text-align: center; padding: 44px; background: var(--paper); border-radius: 24px; box-shadow: var(--shadow); }
.auth-card .brand-mark { margin: 0 auto 20px; }
.auth-card p { color: var(--muted); }
code { padding: 2px 6px; border-radius: 5px; background: #e8e9e1; }
@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .capture-card, .import-panel { grid-template-columns: 1fr; }
  #capture-form, #import-form { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 10; left: -260px; width: 242px; transition: left .2s; }
  .sidebar.open { left: 0; box-shadow: 20px 0 60px rgba(0,0,0,.25); }
  main { padding: 0 14px 40px; }
  #menu-button { display: inline-grid; place-items: center; }
  .topbar { min-height: 90px; }
  .top-actions span { display: none; }
  .metric-grid, .two-column { grid-template-columns: 1fr; }
  .metric { min-height: 130px; }
  .inline-form, .form-row { grid-template-columns: 1fr; }
  .bank-map-row { grid-template-columns: 1fr; }
  .panel, .capture-card { border-radius: 16px; padding: 17px; }
}
