/* Erthiox ALM Desk — design system.
   Layout language blended from the Subly + Finor templates (NOT 1:1),
   re-skinned in Erthiox colours. Tokens: prestige dark #111622,
   gold #C5A880 / #B89047, cream #FCFBF9, slate #5A606C, navy #0B1F3A,
   asset teal #0E7A6B, liability amber #B45309, pass #1E7A46, breach #B3261E. */
:root {
  --navy: #0B1F3A;
  --ink: #111622;
  --gold: #C5A880;
  --gold-dark: #B89047;
  --cream: #FCFBF9;
  --slate: #5A606C;
  --mist: #F2F4F7;
  --border: #E8E5DF;
  --divider: #F1EFEA;
  --blue: #1a73e8;
  --teal: #0E7A6B;
  --teal-soft: #E3F2EF;
  --amber: #B45309;
  --amber-soft: #FBEEE2;
  --green: #1E7A46;
  --green-soft: #E4F3E9;
  --red: #B3261E;
  --red-soft: #FBE9E7;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(17, 22, 34, .06), 0 8px 24px rgba(17, 22, 34, .07);
  --font-body: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Outfit", "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Liberation Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--navy); color: var(--ink);
  font-family: var(--font-body); font-size: 14px; line-height: 1.5;
}
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; color: var(--navy); font-weight: 700; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
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: 14px; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }

/* custom scrollbars — no browser defaults anywhere */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #C9CDD6; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); border: 2px solid transparent; background-clip: content-box; }
* { scrollbar-width: thin; scrollbar-color: #C9CDD6 transparent; }

:focus-visible { outline: 2px solid var(--gold-dark); outline-offset: 2px; border-radius: 4px; }

/* ---------- app shell ---------- */
#app { display: flex; min-height: 100vh; }
.sidebar {
  width: 76px; flex: 0 0 76px; background: var(--ink);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0; gap: 6px; position: sticky; top: 0; height: 100vh; z-index: 40;
}
.sidebar .side-logo { width: 44px; height: 44px; margin-bottom: 10px; border-radius: 12px; background: var(--navy); display: flex; align-items: center; justify-content: center; }
.sidebar .side-logo img { width: 34px; height: 34px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; align-items: center; width: 100%; }
.side-link {
  width: 56px; height: 52px; border: 0; border-radius: 14px; background: transparent;
  color: #9AA3B2; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 9.5px; font-weight: 600; letter-spacing: .02em;
}
.side-link svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-link:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.side-link.active { background: var(--gold-dark); color: #fff; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; align-items: center; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 22px; height: 64px;
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 38px; height: 38px; }
.brand .brand-name { font-family: var(--font-head); font-weight: 700; font-size: 17px; color: var(--navy); white-space: nowrap; }
.brand .brand-sub { font-size: 11px; color: var(--gold-dark); font-weight: 600; white-space: nowrap; }
.pillnav { display: flex; gap: 2px; background: var(--mist); border-radius: 999px; padding: 3px; margin-left: 8px; overflow-x: auto; }
.pillnav a {
  padding: 6px 13px; border-radius: 999px; color: var(--slate); font-weight: 600;
  font-size: 13px; white-space: nowrap; text-decoration: none;
}
.pillnav a:hover { color: var(--navy); }
.pillnav a.active { background: var(--ink); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.market-stamp {
  display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--slate);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; white-space: nowrap;
  background: var(--cream);
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.live { background: var(--green); }
.dot.stale { background: #D97706; }
.dot.demo { background: var(--gold-dark); }
.kofi-btn {
  background: var(--gold-dark); color: #090d16; border: 0; border-radius: 999px;
  font-weight: 700; font-size: 13px; padding: 9px 16px; text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px;
}
.kofi-btn:hover { background: var(--gold); text-decoration: none; }
.user-chip {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--border);
  background: #fff; border-radius: 999px; padding: 5px 12px 5px 5px; font-size: 13px; font-weight: 600; color: var(--navy);
}
.user-chip .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: var(--gold); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.icon-btn { background: #fff; border: 1px solid var(--border); border-radius: 10px; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; color: var(--slate); }
.icon-btn:hover { color: var(--navy); border-color: var(--gold-dark); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }

.content { padding: 20px 22px 40px; max-width: 1460px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .sub { color: #C7CDD8; font-size: 13px; margin-top: 3px; }
.page-head .head-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.demo-badge {
  display: inline-flex; align-items: center; gap: 6px; background: var(--gold-dark); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .06em; border-radius: 6px; padding: 4px 9px;
  text-transform: uppercase;
}
.stamp-line { font-size: 12px; color: #8A93A5; }
.stamp-line b { color: #C7CDD8; font-weight: 600; }

/* ---------- ticker strip (Finor) ---------- */
.ticker {
  display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 12px;
}
.ticker-item {
  flex: 0 0 auto; background: #fff; border-radius: 12px; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow);
}
.ticker-item .t-label { font-size: 11px; color: var(--slate); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.ticker-item .t-value { font-size: 15px; font-weight: 700; color: var(--navy); }
.ticker-item .t-sub { font-size: 11px; color: var(--slate); }

/* ---------- cards & grids ---------- */
.grid { display: grid; gap: 16px; }
.grid.kpi { grid-template-columns: repeat(4, 1fr); }
.grid.two { grid-template-columns: 1.6fr 1fr; }
.grid.two-eq { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card h2 { margin-bottom: 4px; }
.card .card-sub { font-size: 12.5px; color: var(--slate); margin-bottom: 12px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.kpi-value { font-family: var(--font-head); font-size: 30px; font-weight: 700; color: var(--navy); line-height: 1.1; }
.kpi-value small { font-size: 15px; color: var(--slate); font-weight: 600; }
.kpi-delta { font-size: 12.5px; font-weight: 700; margin-top: 4px; }
.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--red); }
.kpi-delta.flat { color: var(--slate); }
.kpi-note { font-size: 12px; color: var(--slate); margin-top: 6px; }
.kpi-label { font-size: 12px; font-weight: 700; color: var(--slate); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }

.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 10px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.chip.pass { background: var(--green-soft); color: var(--green); }
.chip.warn { background: #FDF3E3; color: #92400E; }
.chip.breach { background: var(--red-soft); color: var(--red); }
.chip.info { background: #E8F0FE; color: var(--blue); }
.chip.neutral { background: var(--mist); color: var(--slate); }
.chip.gold { background: #F6EEDF; color: #8A6A2F; }

/* ---------- buttons / inputs ---------- */
.btn {
  border: 1px solid var(--border); background: #fff; color: var(--navy); border-radius: 10px;
  padding: 9px 15px; font-size: 13.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { border-color: var(--gold-dark); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--ink); }
.btn.gold { background: var(--gold-dark); border-color: var(--gold-dark); color: #fff; }
.btn.gold:hover { background: #A67C3E; }
.btn.danger { color: var(--red); border-color: #EFC5C2; }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--navy); margin-bottom: 5px; }
.field input[type="text"], .field input[type="email"], .field input[type="password"],
.field input[type="number"], .field input[type="date"], .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  background: #fff; color: var(--ink);
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--gold-dark); outline-offset: 0; border-color: var(--gold-dark); }
.field .hint { font-size: 12px; color: var(--slate); margin-top: 4px; }
.field .err { font-size: 12px; color: var(--red); margin-top: 4px; font-weight: 600; }
input.invalid { border-color: var(--red) !important; }

/* custom dropdown (no native <select>) */
.dropdown { position: relative; display: inline-block; }
.dropdown-btn {
  border: 1px solid var(--border); background: #fff; border-radius: 10px; padding: 9px 12px;
  font-size: 13.5px; font-weight: 600; color: var(--navy); display: inline-flex; align-items: center; gap: 8px;
  min-width: 150px; justify-content: space-between;
}
.dropdown-btn .caret { font-size: 10px; color: var(--slate); }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 100%; background: #fff;
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); z-index: 60;
  padding: 5px; display: none; max-height: 280px; overflow-y: auto;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 9px 11px; border-radius: 8px; font-size: 13.5px; color: var(--ink);
}
.dropdown-item:hover { background: var(--mist); }
.dropdown-item.selected { background: #F6EEDF; color: #8A6A2F; font-weight: 700; }
.dropdown-item .item-sub { display: block; font-size: 11.5px; color: var(--slate); font-weight: 400; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
table.data th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--slate); font-weight: 700; padding: 9px 10px; border-bottom: 2px solid var(--divider);
  white-space: nowrap;
}
table.data td { padding: 10px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #FBFAF8; }
table.data td.r, table.data th.r { text-align: right; }
table.data td.c, table.data th.c { text-align: center; }
.pos { color: var(--teal); font-weight: 600; }
.neg { color: var(--amber); font-weight: 600; }
.gain { color: var(--green); font-weight: 600; }
.loss { color: var(--red); font-weight: 600; }
.bar-cell { min-width: 120px; }
.mini-bar { height: 8px; border-radius: 4px; background: var(--mist); overflow: hidden; display: flex; }
.mini-bar > span { display: block; height: 100%; }
.mini-bar .fill-teal { background: var(--teal); }
.mini-bar .fill-amber { background: var(--amber); }
.mini-bar .fill-navy { background: var(--navy); }
.mini-bar .fill-gold { background: var(--gold-dark); }

/* ---------- banners / alerts / empty states ---------- */
.banner { border-radius: 12px; padding: 13px 16px; margin-bottom: 16px; display: flex; gap: 12px; align-items: flex-start; font-size: 13.5px; }
.banner.red { background: var(--red-soft); color: #7A1F19; border: 1px solid #F0C4C0; }
.banner.amber { background: #FDF3E3; color: #6B3A08; border: 1px solid #F3D9A8; }
.banner.blue { background: #E8F0FE; color: #174EA6; border: 1px solid #C2D7F8; }
.banner b { font-weight: 700; }
.banner .banner-actions { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }
.empty { text-align: center; padding: 38px 20px; color: var(--slate); }
.empty h3 { color: var(--navy); margin-bottom: 6px; }
.empty .empty-actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.alert-row { display: flex; gap: 10px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--divider); font-size: 13.5px; }
.alert-row:last-child { border-bottom: 0; }
.alert-row .alert-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }

/* ---------- modal / toast ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(11, 22, 34, .55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal { background: #fff; border-radius: 18px; box-shadow: 0 24px 64px rgba(0, 0, 0, .3); width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; padding: 22px 24px; }
.modal.wide { max-width: 760px; }
.modal h2 { margin-bottom: 4px; }
.modal .modal-sub { color: var(--slate); font-size: 13.5px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
#toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 16px; font-size: 13.5px; box-shadow: var(--shadow); max-width: 380px; display: flex; gap: 10px; align-items: flex-start; }
.toast.error { background: var(--red); }
.toast.ok { background: var(--green); }

/* ---------- 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; box-shadow: 0 24px 64px rgba(0, 0, 0, .35); width: 100%; max-width: 460px; padding: 30px 32px; }
.auth-card .auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.auth-card .auth-logo img { width: 48px; height: 48px; }
.auth-tabs { display: flex; background: var(--mist); border-radius: 999px; padding: 3px; margin: 18px 0; }
.auth-tabs button { flex: 1; border: 0; background: transparent; border-radius: 999px; padding: 9px; font-weight: 700; font-size: 13.5px; color: var(--slate); }
.auth-tabs button.active { background: var(--ink); color: #fff; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--slate); font-size: 12px; margin: 16px 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.google-btn { width: 100%; border: 1px solid var(--border); background: #fff; border-radius: 10px; padding: 11px; font-weight: 600; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.google-btn:hover { border-color: var(--gold-dark); }

/* ---------- misc ---------- */
.footer { border-top: 1px solid rgba(255, 255, 255, .14); padding: 22px; color: #8A93A5; font-size: 12.5px; display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.footer a { color: #C7CDD8; }
.footer .foot-right { margin-left: auto; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.assumption-rail { display: grid; gap: 8px; font-size: 13px; }
.assumption-rail .ar-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--divider); }
.assumption-rail .ar-row:last-child { border-bottom: 0; }
.assumption-rail .ar-label { color: var(--slate); flex-shrink: 0; white-space: nowrap; }
.assumption-rail .ar-value { font-weight: 600; color: var(--navy); text-align: right; }
.toggle-row { display: flex; gap: 6px; }
.seg { display: inline-flex; background: var(--mist); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 7px 14px; font-weight: 700; font-size: 13px; color: var(--slate); }
.seg button.active { background: var(--ink); color: #fff; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--slate); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.check-line { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--divider); font-size: 13.5px; }
.check-line:last-child { border-bottom: 0; }
.check-line input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--gold-dark); margin-top: 2px; flex-shrink: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13.5px; }
.kv dt { color: var(--slate); }
.kv dd { margin: 0; font-weight: 600; color: var(--navy); }
.formula { font-family: var(--font-mono); background: var(--mist); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; overflow-x: auto; white-space: nowrap; margin: 8px 0; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 94vw; background: #fff; z-index: 90; box-shadow: -12px 0 40px rgba(0, 0, 0, .2); overflow-y: auto; padding: 22px; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(11, 22, 34, .4); z-index: 80; }
.progress-track { height: 10px; background: var(--mist); border-radius: 5px; overflow: hidden; }
.progress-track > span { display: block; height: 100%; border-radius: 5px; }
.tag { display: inline-block; background: var(--mist); border-radius: 6px; padding: 2px 8px; font-size: 11.5px; font-weight: 700; color: var(--slate); }
@media print {
  .sidebar, .topbar, .footer, .no-print { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid.kpi { grid-template-columns: repeat(2, 1fr); }
  .grid.two, .grid.two-eq, .grid.three { grid-template-columns: 1fr; }
  .pillnav { display: none; }
}
@media (max-width: 760px) {
  #app { flex-direction: column; }
  .sidebar {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; width: 100%; height: 62px;
    flex: 0 0 62px; flex-direction: row; padding: 0 4px; justify-content: space-around; z-index: 50;
  }
  .sidebar .side-logo, .side-foot { display: none; }
  .side-nav { flex-direction: row; justify-content: space-around; width: 100%; }
  .side-link { width: 52px; height: 52px; font-size: 8.5px; }
  .main { padding-bottom: 62px; }
  .topbar { padding: 0 12px; gap: 8px; height: 58px; }
  .brand .brand-sub { display: none; }
  .brand .brand-name { font-size: 15px; }
  .market-stamp { display: none; }
  .user-chip .user-name { display: none; }
  .content { padding: 14px 12px 30px; }
  .kpi-value { font-size: 25px; }
  .kofi-btn { padding: 8px 12px; font-size: 12.5px; }
  .modal { padding: 18px; }
  .drawer { width: 100vw; }
}

/* ---------- scenario cards / presets (views part 2) ---------- */
.scen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.scen-card { display: flex; flex-direction: column; gap: 4px; text-align: left; background: var(--mist); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; cursor: pointer; font: inherit; color: var(--ink); }
.scen-card:hover { border-color: var(--gold); background: #FBF7EF; }
.scen-card b { font-size: 14px; }
.scen-card span { font-size: 12.5px; color: var(--slate); }
.preset-list { display: flex; flex-direction: column; gap: 8px; }
.preset-row { display: block; font-size: 13.5px; line-height: 1.45; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.preset-row:hover { border-color: var(--gold); }
.preset-row input { margin-right: 8px; accent-color: var(--gold-dark); }
