/* Liquidity and Treasury Forecaster — main stylesheet
 * Design language: Finor dark-navy frame + market ticker strip, Subly light
 * cards + dark icon rail + pill nav + big KPIs. NOT a 1:1 copy of either.
 * Palette: Erthiox prestige dark #111622, gold #C5A880 / #B89047, cream
 * #FCFBF9, slate #5A606C; tool navy #0B1F3A, teal #0E7C7B, green #1E7A46,
 * red #B3261E, amber #B7791F. Fonts: Inter (base), Outfit (headings). */
:root {
  --navy: #0B1F3A;
  --navy-2: #12294a;
  --prestige: #111622;
  --gold: #C5A880;
  --gold-dark: #B89047;
  --cream: #FCFBF9;
  --canvas: #F7F8FA;
  --surface: #FFFFFF;
  --ink: #1A2332;
  --ink-2: #44536A;
  --slate: #5A606C;
  --border: #B9C2CF;
  --border-soft: #E8E5DF;
  --divider: #F1EFEA;
  --teal: #0E7C7B;
  --teal-soft: #D6EFEA;
  --blue: #1B6CA8;
  --band: #D6E4EE;
  --green: #1E7A46;
  --green-soft: #DFF0E4;
  --red: #B3261E;
  --red-soft: #F9E3E1;
  --red-muted: #C25B54;
  --amber: #B7791F;
  --amber-soft: #F7ECD4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(11,31,58,.06), 0 8px 24px rgba(11,31,58,.07);
  --font-body: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-head: 'Outfit', 'Inter', -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font-body); background: var(--navy);
  color: var(--ink); font-size: 15px; line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; margin: 0; color: var(--ink); }
p { margin: 0 0 10px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; font-size: 15px; }
img, svg { display: block; }
:focus-visible { outline: 3px solid var(--gold-dark); outline-offset: 2px; border-radius: 4px; }

/* ---- custom scrollbars (rule: no default browser scrollbar) ---- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c9cdd6; border-radius: 8px; border: 2px solid var(--canvas); }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }
* { scrollbar-width: thin; scrollbar-color: #c9cdd6 transparent; }

/* ================= App shell ================= */
.app-shell { display: flex; min-height: 100vh; background: var(--canvas); }
.rail {
  width: 76px; flex: 0 0 76px; background: var(--prestige); color: #fff;
  display: flex; flex-direction: column; align-items: center; padding: 14px 0; gap: 6px;
  position: sticky; top: 0; height: 100vh; z-index: 40;
}
.rail-logo { width: 40px; height: 54px; margin-bottom: 10px; flex: 0 0 auto; }
.rail-logo img { width: 100%; height: 100%; }
.rail-btn {
  width: 52px; height: 52px; border: 0; border-radius: 14px; background: transparent;
  color: #aeb6c4; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 10px; line-height: 1.1; position: relative;
}
.rail-btn svg { width: 22px; height: 22px; }
.rail-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.rail-btn.active { background: var(--gold-dark); color: #fff; }
.rail-btn .dot { position: absolute; top: 8px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.rail-spacer { flex: 1; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* top bar: pill nav + workspace + freshness badge */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 12px 22px;
  background: var(--surface); border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 30; flex-wrap: wrap;
}
.topbar h1 { font-size: 19px; }
.pillnav { display: flex; gap: 4px; background: var(--canvas); border: 1px solid var(--border-soft); border-radius: 999px; padding: 4px; }
.pillnav button {
  border: 0; background: transparent; padding: 7px 14px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.pillnav button:hover { color: var(--ink); }
.pillnav button.active { background: var(--navy); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ws-chip {
  display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600;
  background: var(--cream); border: 1px solid var(--border-soft); border-radius: 999px; padding: 6px 12px;
}
.fresh-badge { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 5px 10px; display: inline-flex; align-items: center; gap: 6px; }
.fresh-badge .fb-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.fresh-badge.green { background: var(--green-soft); color: var(--green); }
.fresh-badge.amber { background: var(--amber-soft); color: var(--amber); }
.fresh-badge.red { background: var(--red-soft); color: var(--red); }

/* market ticker strip (Finor) */
.ticker {
  display: flex; gap: 0; overflow-x: auto; background: var(--navy); color: #dbe2ee;
  font-size: 12.5px; padding: 7px 22px; scrollbar-width: none;
}
.ticker::-webkit-scrollbar { display: none; }
.ticker span { white-space: nowrap; padding: 0 18px; border-right: 1px solid rgba(255,255,255,.14); }
.ticker span:first-child { padding-left: 0; }
.ticker b { color: #fff; font-weight: 600; }
.ticker .up { color: #7fd1cf; } .ticker .down { color: #f2a19b; }

.content { padding: 22px; max-width: 1560px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h2 { font-size: 26px; }
.page-head .sub { color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.kicker { font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-dark); font-weight: 700; }

/* ---- cards / KPI (Subly big numbers) ---- */
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; } /* grid items must be allowed to shrink below their min-content (tables/charts) or they force page overflow on phones */
.grid.kpis { grid-template-columns: repeat(4, 1fr); }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.wide-narrow { grid-template-columns: 1.9fr 1fr; }
.card {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); min-width: 0;
}
.card h3 { font-size: 16px; margin-bottom: 4px; }
.card .card-sub { color: var(--ink-2); font-size: 13px; margin-bottom: 10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-head h3 { margin: 0; }
.kpi-label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.kpi-value { font-size: 34px; font-weight: 700; font-family: var(--font-head); line-height: 1.15; letter-spacing: -.01em; }
.kpi-value small { font-size: 16px; font-weight: 600; color: var(--ink-2); }
.kpi-delta { font-size: 13px; font-weight: 600; margin-top: 2px; }
.kpi-delta.pos { color: var(--green); } .kpi-delta.neg { color: var(--red); } .kpi-delta.warn { color: var(--amber); }
.kpi-note { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.kpi-big { border-top: 4px solid var(--gold); }
.kpi-big.alert { border-top-color: var(--red); }
.kpi-big.ok { border-top-color: var(--green); }
.kpi-big.teal { border-top-color: var(--teal); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; padding: 9px 15px;
}
.btn:hover { border-color: var(--navy); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.gold { background: var(--gold-dark); border-color: var(--gold-dark); color: #fff; }
.btn.gold:hover { background: #a37c3c; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: 12px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
table.data th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2);
  padding: 10px 12px; background: var(--canvas); border-bottom: 1px solid var(--border-soft); white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--divider); }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #faf9f6; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.neg, .neg { color: var(--red); font-weight: 600; }
.pos { color: var(--green); font-weight: 600; }
table.data tr.row-negative td { background: #fdf3f2; }
table.data tr.row-alert td:first-child { border-left: 4px solid var(--red); }
.sticky-first th:first-child, .sticky-first td:first-child { position: sticky; left: 0; background: var(--surface); }
.sticky-first thead th:first-child { background: var(--canvas); }

/* ---- badges / chips / tags ---- */
.tag { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 9px; }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.teal { background: var(--teal-soft); color: var(--teal); }
.tag.navy { background: #e3e9f2; color: var(--navy); }
.tag.grey { background: #eef0f3; color: var(--ink-2); }
.tag.gold { background: #f3ead9; color: #8a6d2f; }

/* ---- forms ---- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 5px; }
.field .hint { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.field .error { font-size: 12.5px; color: var(--red); font-weight: 600; margin-top: 4px; display: none; }
.field.invalid .error { display: block; }
.field.invalid input, .field.invalid textarea { border-color: var(--red); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus { outline: 2px solid var(--gold-dark); outline-offset: 0; border-color: var(--gold-dark); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.segmented { display: inline-flex; flex-wrap: wrap; background: var(--canvas); border: 1px solid var(--border-soft); border-radius: 999px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 6px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.segmented button.active { background: var(--navy); color: #fff; }

/* ---- custom dropdown (no native <select>) ---- */
.dropdown { position: relative; }
.dropdown-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: #fff; font-size: 15px; color: var(--ink); text-align: left;
}
.dropdown-btn .chev { color: var(--ink-2); font-size: 12px; }
.dropdown-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 60; background: #fff;
  border: 1px solid var(--border-soft); border-radius: 12px; box-shadow: 0 12px 32px rgba(11,31,58,.18);
  max-height: 260px; overflow-y: auto; padding: 6px; display: none;
}
.dropdown.open .dropdown-list { display: block; }
.dropdown-list button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 10px;
  border-radius: 8px; font-size: 14px; color: var(--ink);
}
.dropdown-list button:hover, .dropdown-list button:focus-visible { background: var(--cream); }
.dropdown-list button[aria-selected="true"] { background: var(--teal-soft); font-weight: 700; }

/* ---- modal / toast (no native alert/confirm) ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(17,22,34,.55); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 18px;
}
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; padding: 24px; box-shadow: 0 24px 64px rgba(0,0,0,.3); }
.modal.wide { max-width: 760px; }
.modal h3 { font-size: 20px; margin-bottom: 4px; }
.modal .modal-sub { color: var(--ink-2); font-size: 14px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.modal-close { float: right; border: 0; background: transparent; font-size: 22px; line-height: 1; color: var(--ink-2); padding: 4px 8px; }
.toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 40px)); }
.toast {
  background: var(--prestige); color: #fff; border-radius: 12px; padding: 12px 16px; font-size: 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,.3); border-left: 4px solid var(--gold);
}
.toast.error { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }

/* ---- banners ---- */
.banner {
  border-radius: 12px; padding: 12px 16px; font-size: 14px; margin-bottom: 16px;
  display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap;
}
.banner.sample { background: var(--amber-soft); color: #6b4c10; border: 1px solid #e8d9b0; }
.banner.offline { background: #eef0f3; color: var(--ink-2); border: 1px solid var(--border); }
.banner.error { background: var(--red-soft); color: var(--red); border: 1px solid #f0c6c2; }
.banner.info { background: #e3eef7; color: var(--navy); border: 1px solid #c4d8ea; }
.banner b { font-weight: 700; }

/* ---- charts ---- */
.chart-wrap { width: 100%; overflow-x: auto; }
.chart-wrap svg { min-width: 520px; width: 100%; height: auto; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 22px; height: 0; border-top: 3px solid; display: inline-block; }
.legend .sw.dashed { border-top-style: dashed; }
.legend .sw.dotted { border-top-style: dotted; }
.legend .sw.band { height: 10px; border: 0; background: var(--band); border-radius: 2px; }
.donut-center { font-family: var(--font-head); font-weight: 700; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 110px; gap: 10px; align-items: center; margin: 7px 0; font-size: 13.5px; }
.bar-track { height: 12px; background: var(--divider); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }

/* ---- alerts list ---- */
.alert-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--divider); align-items: flex-start; }
.alert-item:last-child { border-bottom: 0; }
.alert-item .alert-ico { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex: 0 0 34px; }
.alert-item .alert-ico.red { background: var(--red-soft); color: var(--red); }
.alert-item .alert-ico.amber { background: var(--amber-soft); color: var(--amber); }
.alert-item .alert-ico.teal { background: var(--teal-soft); color: var(--teal); }
.alert-item .alert-body { flex: 1; min-width: 0; }
.alert-item .alert-title { font-weight: 700; font-size: 14px; }
.alert-item .alert-desc { font-size: 13px; color: var(--ink-2); }

/* ---- auth screen ---- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--navy); }
.auth-card { background: #fff; border-radius: 20px; width: 100%; max-width: 460px; padding: 32px 30px; box-shadow: 0 24px 64px rgba(0,0,0,.35); }
.auth-card .logo-row { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.auth-card .logo-row img { width: 40px; height: 54px; }
.auth-card h1 { font-size: 24px; }
.auth-tabs { display: flex; gap: 4px; background: var(--canvas); border-radius: 999px; padding: 4px; margin: 18px 0; }
.auth-tabs button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 999px; font-weight: 700; font-size: 14px; color: var(--ink-2); }
.auth-tabs button.active { background: var(--navy); color: #fff; }
.auth-divider { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 12.5px; margin: 16px 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border-soft); }
.kofi-note { font-size: 12.5px; color: var(--ink-2); text-align: center; margin-top: 16px; }

/* ---- onboarding steps ---- */
.steps { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.step-pill { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 5px 11px; background: #eef0f3; color: var(--ink-2); }
.step-pill.done { background: var(--teal-soft); color: var(--teal); }
.step-pill.now { background: var(--navy); color: #fff; }

/* ---- misc ---- */
.empty-state { text-align: center; padding: 34px 18px; color: var(--ink-2); }
.empty-state .big { font-size: 34px; margin-bottom: 8px; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.formula { background: var(--canvas); border: 1px solid var(--border-soft); border-radius: 10px; padding: 10px 12px; font-family: var(--font-mono); font-size: 13px; overflow-x: auto; margin: 8px 0; }
.planning-note { font-size: 12.5px; color: var(--ink-2); background: var(--cream); border: 1px solid var(--border-soft); border-radius: 10px; padding: 10px 12px; margin-top: 12px; }
.footer { padding: 18px 22px 28px; color: var(--ink-2); font-size: 13px; display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.footer .kofi { margin-left: auto; }
.kofi-btn {
  display: inline-flex; align-items: center; gap: 8px; background: var(--gold-dark); color: #090d16;
  font-weight: 700; font-size: 14px; border-radius: 999px; padding: 9px 16px; border: 0; text-decoration: none;
}
.kofi-btn:hover { background: var(--gold); text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.hidden { display: none !important; }
.text-right { text-align: right; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb16 { margin-bottom: 16px; }

/* ---- print (daily pack) ---- */
@media print {
  .rail, .topbar, .ticker, .footer, .page-head .actions, .toast-stack { display: none !important; }
  body { background: #fff; }
  .app-shell { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ================= Responsive ================= */
@media (max-width: 1180px) {
  .grid.kpis { grid-template-columns: repeat(2, 1fr); }
  .grid.three { grid-template-columns: 1fr 1fr; }
  .grid.wide-narrow { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .rail { width: 60px; flex-basis: 60px; }
  .rail-btn { width: 46px; height: 46px; font-size: 9px; }
  .rail-btn svg { width: 20px; height: 20px; }
  .topbar { padding: 10px 14px; }
  .topbar h1 { display: none; }
  .pillnav { order: 3; width: 100%; overflow-x: auto; }
  .content { padding: 14px; }
  .kpi-value { font-size: 28px; }
  .form-row { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 96px 1fr 84px; }
}
@media (max-width: 430px) {
  .grid.kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; }
  .kpi-value { font-size: 24px; }
  .page-head h2 { font-size: 21px; }
  .ticker { padding: 6px 14px; }
  .modal { padding: 18px; }
}
