/* RiskLens styles — Subly + Finor layout language, Erthiox skin.
 * Dark navy page frame (#0B1F3A), white rounded cards, black icon rail,
 * pill nav, big KPIs, ticker strip, gradient bars, donut. Erthiox palette:
 * #111622 / #C5A880 / #B89047 / #FCFBF9 / #5A606C, blue #1a73e8.
 * Fonts: Inter (base), Outfit (headings/KPIs). Light only in v1 (plan §4.3).
 */
:root {
  --navy: #0B1F3A; --navy-2: #111622; --steel: #143A6B; --blue: #1a73e8; --blue-dark: #0d47a1;
  --gold: #C5A880; --gold-dark: #B89047; --cream: #FCFBF9; --ink: #1A2332; --muted: #5A606C;
  --border: #E8E5DF; --surface: #F2F4F7; --green: #1E7A46; --amber: #C98A1B; --red: #B3261E;
  --radius: 18px; --shadow: 0 8px 30px rgba(11, 31, 58, .10);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: Inter, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(160deg, #0B1F3A 0%, #12294d 55%, #0d1b30 100%);
  background-attachment: fixed; color: var(--ink); font-size: 15px; line-height: 1.5;
}
h1, h2, h3, h4 { font-family: Outfit, Inter, sans-serif; color: var(--navy); margin: 0 0 8px; }
h2 { font-size: 22px; } h3 { font-size: 17px; } h4 { font-size: 15px; }
p { margin: 0 0 10px; }
a { color: var(--blue); text-decoration: none; } a:hover { text-decoration: underline; }
.muted { color: var(--muted); } .pos { color: var(--green); } .neg { color: var(--red); }
.warn-txt { color: var(--amber); } .danger-txt { color: var(--red); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #eef1f5; border-radius: 8px; }
::-webkit-scrollbar-thumb { background: linear-gradient(#C5A880, #B89047); border-radius: 8px; border: 2px solid #eef1f5; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }
* { scrollbar-width: thin; scrollbar-color: var(--gold-dark) #eef1f5; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; max-width: 1560px; margin: 0 auto; padding: 18px; gap: 18px; }
.rail {
  width: 92px; flex: 0 0 92px; background: var(--navy-2); border-radius: 22px;
  display: flex; flex-direction: column; align-items: center; padding: 18px 0; gap: 6px;
  position: sticky; top: 18px; height: calc(100vh - 36px); box-shadow: var(--shadow);
}
.rail-logo { display: flex; flex-direction: column; align-items: center; gap: 4px; color: #fff; font-family: Outfit; font-weight: 700; font-size: 12px; margin-bottom: 12px; }
.rail-logo img { width: 44px; height: 44px; }
.rail-btn {
  width: 72px; padding: 10px 0 8px; border: 0; border-radius: 14px; background: transparent;
  color: #c8ccd6; cursor: pointer; font-family: Inter; font-size: 11px; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.rail-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.rail-btn.active { background: linear-gradient(135deg, #1a73e8, #0d47a1); color: #fff; }
.rail-ico { font-size: 20px; line-height: 1; }
.rail-signout { margin-top: auto; }
.nav-dot { position: absolute; top: 8px; right: 14px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); border: 2px solid var(--navy-2); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }.topbar {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 18px; padding: 12px 20px; flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-logo { width: 40px; height: 40px; }
.topbar-left h1 { font-size: 22px; margin: 0; }
.topbar-left p { margin: 0; font-size: 12px; color: var(--muted); }
.pillnav { display: flex; background: var(--surface); border-radius: 999px; padding: 4px; gap: 2px; flex-wrap: wrap; min-width: 0; }
.pill { border: 0; background: transparent; border-radius: 999px; padding: 8px 16px; font: 600 13px Inter; color: var(--muted); cursor: pointer; }
.pill:hover { color: var(--ink); }
.pill.active { background: var(--navy); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.snap-chip { font-size: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; color: var(--muted); }
.user-chip { font-size: 13px; font-weight: 600; background: linear-gradient(135deg, #C5A880, #B89047); color: #111622; border-radius: 999px; padding: 7px 14px; }
.badge { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 5px 10px; }
.badge.amber { background: #fdf3dd; color: #7a5200; border: 1px solid #f0d48a; }

/* ticker (Finor top-gainers strip) */
.ticker {
  background: rgba(255,255,255,.96); border-radius: 14px; box-shadow: var(--shadow);
  display: flex; gap: 0; overflow-x: auto; padding: 8px 6px; white-space: nowrap; min-width: 0; width: 100%;
}
.ticker-item { display: inline-flex; gap: 8px; align-items: center; padding: 2px 16px; border-right: 1px solid var(--border); font-size: 13px; }
.ticker-item:last-child { border-right: 0; }
.ticker-item b { color: var(--muted); font-weight: 600; }
.ticker-item .up { color: var(--green); font-weight: 700; } .ticker-item .down { color: var(--red); font-weight: 700; }

/* banners */
.banner { border-radius: 12px; padding: 12px 16px; font-size: 14px; }
.banner.info { background: #e8f0fe; color: #174ea6; border: 1px solid #aecbfa; }
.banner.warn { background: #fdf3dd; color: #7a5200; border: 1px solid #f0d48a; }
.banner.danger { background: #fce8e6; color: #8c1d18; border: 1px solid #f5a9a2; }

/* ---------- cards / grids ---------- */
.view { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; min-width: 0; }
.grid-2 > *, .kpi-grid > * { min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.kpi-num { font-family: Outfit; font-size: 34px; font-weight: 700; color: var(--navy); margin: 2px 0 4px; font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0; }
.kpi-sub { font-size: 13px; color: var(--muted); margin: 0; }
.kpi-red .kpi-num { color: var(--red); }
.run-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.run-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* buttons */
.btn {
  border: 1px solid var(--border); background: #fff; color: var(--ink); border-radius: 999px;
  padding: 10px 20px; font: 600 14px Inter; cursor: pointer; display: inline-block; text-align: center;
}
.btn:hover { border-color: var(--gold-dark); }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: var(--steel); }
.btn.gold { background: linear-gradient(135deg, #C5A880, #B89047); color: #111622; border-color: #B89047; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn.block { display: block; width: 100%; margin: 8px 0; }
.btn.sm { padding: 6px 12px; font-size: 12px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.icon-btn { border: 0; background: transparent; font-size: 16px; cursor: pointer; color: var(--muted); padding: 4px 8px; }
.danger-txt { color: var(--red); }

/* tables */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--border); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--surface); white-space: nowrap; }
.tbl tbody tr:nth-child(even) { background: var(--cream); }
.tbl tbody tr:hover { background: #f4ede1; }
.tbl.corr td, .tbl.corr th { text-align: center; }
.tbl.corr th:first-child, .tbl.corr td:first-child { text-align: left; }
.corr-hi { background: #e8f0fe; font-weight: 700; } .corr-mid { background: #f6f8fb; }

/* limits / distribution bars */
.limit-row { margin-bottom: 12px; }
.limit-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; margin-bottom: 5px; flex-wrap: wrap; }
.limit-track { height: 10px; background: var(--surface); border-radius: 999px; overflow: hidden; }
.limit-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #1E7A46, #2ea36b); }
.limit-fill.near { background: linear-gradient(90deg, #C98A1B, #e8b64c); }
.limit-fill.breach { background: linear-gradient(90deg, #B3261E, #e05244); }
.dist-row { display: grid; grid-template-columns: 130px 1fr 52px 110px; gap: 10px; align-items: center; margin-bottom: 10px; font-size: 13.5px; }
.dist-track { height: 12px; background: var(--surface); border-radius: 999px; overflow: hidden; }
.dist-fill { height: 100%; background: linear-gradient(90deg, #0B1F3A, #1a73e8, #C5A880); border-radius: 999px; }
.pill-status { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 4px 10px; text-transform: capitalize; }
.pill-status.ok, .pill-status.green { background: #e6f4ea; color: var(--green); }
.pill-status.near, .pill-status.amber { background: #fdf3dd; color: #7a5200; }
.pill-status.breach, .pill-status.red { background: #fce8e6; color: var(--red); }
.breach-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; background: #fce8e6; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: 13.5px; flex-wrap: wrap; }
.chart { width: 100%; display: block; }
.chart.tall { height: 260px; }
.rev-result { background: var(--surface); border-radius: 10px; padding: 12px 14px; margin-top: 10px; }
.empty { background: var(--surface); border-radius: 12px; padding: 18px; text-align: center; margin-top: 12px; }

/* forms */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field input[type="text"], .field input[type="email"], .field input[type="password"],
.field input[type="number"], .field input[type="file"] {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: 12px;
  font: 15px Inter; color: var(--ink); background: #fff;
}
.field input:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
.field input:disabled { background: var(--surface); color: var(--muted); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.field-err { color: var(--red); font-size: 13.5px; min-height: 18px; margin: 4px 0; }
.field-note { font-size: 12px; color: var(--muted); font-weight: 400; }

/* custom dropdown */
.dropdown { position: relative; width: 100%; }
.dropdown-btn {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: 12px; background: #fff; font: 15px Inter; cursor: pointer; text-align: left;
}
.dropdown-btn:hover { border-color: var(--gold-dark); }
.dd-label { color: var(--muted); font-size: 13px; }
.dd-value { font-weight: 600; flex: 1; }
.dd-caret { color: var(--muted); }
.dropdown-menu {
  position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; right: 0; background: #fff;
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(11,31,58,.18);
  padding: 6px; display: none; max-height: 260px; overflow-y: auto;
}
.dropdown-menu.open { display: block; }
.dropdown-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 12px; border-radius: 8px; font: 15px Inter; cursor: pointer; }
.dropdown-item:hover { background: var(--surface); }
.dropdown-item.active { background: #f4ede1; font-weight: 700; }

/* modal + toast */
.modal-overlay { position: fixed; inset: 0; background: rgba(11, 22, 34, .55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 20px; max-width: 640px; width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: 0 24px 64px rgba(0,0,0,.35); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 0; }
.modal-body { padding: 14px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 22px 20px; flex-wrap: wrap; }
#toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, 90vw); }
.toast { background: var(--navy-2); color: #fff; border-radius: 12px; padding: 12px 16px; font-size: 14px; box-shadow: 0 12px 32px rgba(0,0,0,.3); opacity: 0; transform: translateY(8px); transition: .3s; border-left: 4px solid var(--gold); }
.toast.show { opacity: 1; transform: none; }
.toast.warn { border-left-color: var(--amber); } .toast.danger { border-left-color: var(--red); }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: #fff; border-radius: 24px; box-shadow: 0 24px 64px rgba(0,0,0,.35); max-width: 480px; width: 100%; padding: 34px 32px; text-align: center; }
.login-logo { width: 84px; height: 84px; }
.login-card h1 { font-size: 30px; margin: 6px 0 2px; }
.login-tag { font-size: 16px; font-weight: 600; color: var(--navy); }
.login-sub { color: var(--muted); font-size: 13.5px; }
.login-tabs { display: flex; background: var(--surface); border-radius: 999px; padding: 4px; margin: 16px 0; }
.login-tab { flex: 1; border: 0; background: transparent; border-radius: 999px; padding: 9px; font: 600 14px Inter; color: var(--muted); cursor: pointer; }
.login-tab.active { background: var(--navy); color: #fff; }
.login-card .field { text-align: left; }
.login-note { font-size: 12.5px; color: var(--muted); text-align: left; }

/* footer */
.foot { background: rgba(255,255,255,.96); border-radius: 14px; padding: 14px 18px; font-size: 12.5px; color: var(--muted); box-shadow: var(--shadow); }

/* methodology page */
.page-wrap { max-width: 920px; margin: 0 auto; padding: 24px 18px 60px; }
.page-wrap .card { margin-bottom: 16px; }
.page-wrap table { width: 100%; border-collapse: collapse; font-size: 14px; }
.page-wrap th, .page-wrap td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--surface); vertical-align: top; }
.page-wrap code { background: var(--surface); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.page-wrap pre { background: var(--navy-2); color: #e8ecf3; padding: 16px; border-radius: 12px; overflow-x: auto; font-size: 13px; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .shell { padding: 10px; gap: 10px; }
  .rail { display: none; }
  .topbar { padding: 10px 14px; }
  .kpi-num { font-size: 28px; }
  .dist-row { grid-template-columns: 96px 1fr 48px 90px; }
}
@media (max-width: 480px) {
  body { font-size: 14px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .pillnav { overflow-x: auto; flex-wrap: nowrap; max-width: 100%; }
  .snap-chip { display: none; }
  .topbar-right { margin-left: 0; }
  .dist-row { grid-template-columns: 84px 1fr 44px; }
  .dist-row span.muted { display: none; }
  .modal-foot .btn { flex: 1; }
}
@media print {
  body { background: #fff; }
  .rail, .pillnav, .topbar-right, .ticker, .btn, .banner, .foot { display: none !important; }
  .shell { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}
