/* Fixed Income Portfolio Analytics — design system.
 * Layout language blended from the two Artem-approved templates (NOT 1:1):
 *  - Subly: light dashboard, white rounded cards, black vertical icon rail,
 *    top pill nav, big KPI numbers with green/red deltas, gradient charts.
 *  - Finor: dark navy page background, light cards, top ticker strip,
 *    portfolio line chart, profits donut, distribution bars, asset lists.
 * Re-skinned in the Erthiox palette: navy #0B1F3A / #111622, gold #C5A880 /
 * #B89047, cream #FCFBF9, slate #5A606C, teal #0E7C6B, blue #1a73e8.
 */
:root {
  --navy: #0B1F3A;
  --ink: #111622;
  --gold: #C5A880;
  --gold-dark: #B89047;
  --cream: #FCFBF9;
  --slate: #5A606C;
  --teal: #0E7C6B;
  --blue: #1a73e8;
  --pos: #1E7A46;
  --neg: #B3261E;
  --amber: #8A6D3B;
  --surface: #F2F6F8;
  --border: #C9D2DC;
  --divider: #E8E5DF;
  --card: #FFFFFF;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(11, 31, 58, .06), 0 8px 24px rgba(11, 31, 58, .08);
  --font-body: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-head: 'Outfit', 'Inter', -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font-body); font-size: 14.5px; line-height: 1.5;
  color: var(--ink); background: linear-gradient(180deg, #0B1F3A 0%, #101a30 420px, #16213a 100%);
  background-attachment: fixed; min-height: 100vh;
}
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--navy); margin: 0 0 8px; letter-spacing: -.01em; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 19px; }
h3 { font-size: 15.5px; }
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: 14.5px; }
.num, td.num, .kpi-value { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.muted { color: var(--slate); }
.small { font-size: 12.5px; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .warn { color: var(--amber); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

/* ---- custom scrollbars (never the browser default) ---- */
* { scrollbar-width: thin; scrollbar-color: #b9a06a #eef1f4; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: #eef1f4; border-radius: 8px; }
*::-webkit-scrollbar-thumb { background: linear-gradient(180deg, var(--gold), var(--gold-dark)); border-radius: 8px; border: 2px solid #eef1f4; }
*::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }

/* ---- app shell: left icon rail + content ---- */
#app { display: flex; min-height: 100vh; }
.rail {
  width: 68px; flex: 0 0 68px; 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;
}
.rail-logo { width: 40px; height: 40px; margin-bottom: 10px; }
.rail-btn {
  width: 46px; height: 46px; border: 0; border-radius: 12px; background: transparent;
  color: #9aa7bd; display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.rail-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.rail-btn.active { background: var(--gold-dark); color: #fff; }
.rail-spacer { flex: 1; }
.main { flex: 1; min-width: 0; padding: 0 28px 40px; }
/* Page-level headings sit on the dark navy page background (Finor), so they
   are white / light — card headings keep the navy colour from the h1 rule. */
.main > h1 { color: #fff; }
.main > p.muted { color: #b9c6d8; }
.main > p.muted b { color: #fff; }

/* ---- header ---- */
.topbar { display: flex; align-items: center; gap: 16px; padding: 18px 0 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; }
.brand img { width: 44px; height: 44px; }
.brand-name { font-family: var(--font-head); font-weight: 700; font-size: 18px; line-height: 1.15; color: #fff; }
.brand-sub { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
.pillnav {
  display: flex; gap: 4px; background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px; padding: 4px; margin-left: auto; overflow-x: auto; max-width: 100%;
}
.pillnav a {
  padding: 7px 15px; border-radius: 999px; color: #d7dee9; font-weight: 600; font-size: 13.5px;
  white-space: nowrap; text-decoration: none;
}
.pillnav a:hover { color: #fff; }
.pillnav a.active { background: #fff; color: var(--navy); }
.asof {
  display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14); color: #e8edf4; border-radius: 999px; padding: 7px 13px;
  font-size: 12.5px; font-weight: 600;
}
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
}
.badge-ok { background: #e3f2e8; color: var(--pos); }
.badge-warn { background: #f7ecd4; color: var(--amber); }
.badge-err { background: #fbe4e1; color: var(--neg); }
.badge-navy { background: var(--navy); color: #fff; }
.badge-gold { background: #f3e9d7; color: #7a5c22; }
.badge-demo { background: var(--gold-dark); color: #fff; }

/* ---- ticker strip (Finor) ---- */
.ticker {
  display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 14px; scrollbar-width: none;
}
.ticker::-webkit-scrollbar { display: none; }
.tick {
  flex: 0 0 auto; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px; padding: 9px 14px; color: #fff; min-width: 150px;
}
.tick .t-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #9fb0c8; }
.tick .t-val { font-size: 15.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tick .t-delta { font-size: 12px; font-weight: 600; margin-left: 6px; }

/* ---- cards & grids ---- */
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-main { grid-template-columns: 1.9fr 1fr; }
.g-main-r { grid-template-columns: 1fr 1.9fr; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px; min-width: 0;
}
.card h2 { display: flex; align-items: center; gap: 8px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-head .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.kpi-label { font-size: 12px; letter-spacing: .07em; text-transform: uppercase; color: var(--slate); font-weight: 700; }
.kpi-value { font-size: 34px; font-weight: 700; color: var(--navy); line-height: 1.1; font-family: var(--font-head); }
.kpi-value.sm { font-size: 26px; }
.kpi-delta { font-size: 13px; font-weight: 700; }
.kpi-sub { font-size: 12.5px; color: var(--slate); margin-top: 4px; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; border: 0; border-radius: 10px;
  padding: 9px 16px; font-size: 13.5px; font-weight: 700; background: var(--navy); color: #fff;
  text-decoration: none;
}
.btn:hover { background: #16294d; text-decoration: none; }
.btn.gold { background: var(--gold-dark); color: #fff; }
.btn.gold:hover { background: #a37c33; }
.btn.teal { background: var(--teal); }
.btn.ghost { background: #eef1f4; color: var(--navy); }
.btn.ghost:hover { background: #e2e8ee; }
.btn.outline { background: #fff; color: var(--navy); border: 1.5px solid var(--border); }
.btn.outline:hover { border-color: var(--navy); }
.btn.danger { background: var(--neg); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--divider); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th {
  position: sticky; top: 0; background: var(--navy); color: #fff; font-size: 11.5px;
  letter-spacing: .06em; text-transform: uppercase; z-index: 2;
}
thead th:first-child { border-radius: 8px 0 0 0; }
thead th:last-child { border-radius: 0 8px 0 0; }
tbody tr:nth-child(even) { background: var(--surface); }
tbody tr:hover { background: #eef3f6; }
tfoot td { font-weight: 700; background: #f7f3ea; border-top: 2px solid var(--gold-dark); }
td.neg, th.neg { color: var(--neg); }
td.pos { color: var(--pos); }
.flag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #f7ecd4; color: var(--amber); margin-left: 6px; }
.flag.red { background: #fbe4e1; color: var(--neg); }
.flag.grey { background: #eef1f4; color: var(--slate); }
.flag.teal { background: #dff0ec; color: var(--teal); }

/* ---- charts ---- */
.chart { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--slate); margin-top: 8px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.dist-row { display: grid; grid-template-columns: 130px 1fr 74px; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--divider); font-size: 13px; }
.dist-row:last-child { border-bottom: 0; }
.dist-bar { height: 10px; background: #edf0f3; border-radius: 99px; overflow: hidden; position: relative; }
.dist-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--teal), #2aa58f); }
.dist-fill.bench { background: linear-gradient(90deg, var(--gold), var(--gold-dark)); }

/* ---- forms ---- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--slate); margin-bottom: 5px; }
.input, input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"] {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 10px; background: #fff; color: var(--ink);
}
.input:focus, input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(26,115,232,.15); }
.input.err { border-color: var(--neg); }
.field-err { color: var(--neg); font-size: 12.5px; margin-top: 4px; display: none; }
.field-err.show { display: block; }
.hint { font-size: 12.5px; color: var(--slate); margin-top: 4px; }

/* ---- custom dropdown (never a native <select>) ---- */
.dd { position: relative; }
.dd-btn {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 10px; background: #fff;
  font-size: 14px; font-weight: 600; color: var(--ink); text-align: left;
}
.dd-btn::after { content: "▾"; color: var(--slate); font-size: 12px; }
.dd-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 5px); background: #fff; border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); z-index: 60; max-height: 260px; overflow-y: auto; display: none;
}
.dd.open .dd-menu { display: block; }
.dd-item { display: block; width: 100%; text-align: left; padding: 10px 13px; border: 0; background: #fff; font-size: 13.5px; }
.dd-item:hover, .dd-item.sel { background: var(--surface); }
.dd-item .sub { display: block; font-size: 12px; color: var(--slate); }
.dd.sm .dd-btn { padding: 7px 11px; font-size: 13px; }

/* ---- modal / toast (custom, never alert/confirm) ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(11, 22, 34, .55); display: none;
  align-items: center; justify-content: center; z-index: 100; padding: 18px;
}
.modal-backdrop.show { display: flex; }
.modal { background: #fff; border-radius: 18px; box-shadow: var(--shadow); max-width: 560px; width: 100%; max-height: 88vh; overflow-y: auto; padding: 24px; }
.modal h2 { margin-bottom: 6px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 36px)); }
.toast {
  background: var(--ink); color: #fff; border-radius: 12px; padding: 13px 16px; font-size: 13.5px;
  box-shadow: var(--shadow); border-left: 4px solid var(--gold-dark);
}
.toast.err { border-left-color: var(--neg); }
.toast.ok { border-left-color: var(--pos); }

/* ---- tabs (auth + wizard) ---- */
.tabs { display: flex; gap: 4px; background: var(--surface); border-radius: 999px; padding: 4px; margin-bottom: 18px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px 10px; border-radius: 999px; font-weight: 700; font-size: 13.5px; color: var(--slate); }
.tabs button.active { background: var(--navy); color: #fff; }
.steps { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.step { flex: 1; min-width: 110px; font-size: 12.5px; font-weight: 700; color: var(--slate); padding-top: 8px; border-top: 3px solid var(--border); }
.step.active { color: var(--navy); border-top-color: var(--gold-dark); }
.step.done { color: var(--pos); border-top-color: var(--pos); }

/* ---- misc components ---- */
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--divider); }
.list-row:last-child { border-bottom: 0; }
.avatar { width: 38px; height: 38px; border-radius: 10px; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex: 0 0 38px; }
.avatar.teal { background: var(--teal); } .avatar.gold { background: var(--gold-dark); } .avatar.blue { background: var(--blue); }
.empty { text-align: center; padding: 38px 18px; color: var(--slate); }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.notice { border-radius: 12px; padding: 13px 16px; font-size: 13.5px; margin-bottom: 16px; }
.notice.warn { background: #fbf3df; border: 1px solid #e8d5a4; color: #6b5316; }
.notice.err { background: #fdecea; border: 1px solid #f3c1bc; color: #7c1d17; }
.notice.info { background: #e8f0fe; border: 1px solid #bcd2f7; color: #17406e; }
.notice.ok { background: #e6f4ea; border: 1px solid #b9dcc4; color: #14532d; }
.kofi { display: inline-flex; align-items: center; gap: 8px; background: var(--gold-dark); color: #090d16; font-weight: 700; border-radius: 10px; padding: 9px 16px; text-decoration: none; font-size: 13.5px; }
.kofi:hover { background: #a37c33; color: #fff; text-decoration: none; }
.footer { color: #8fa0b8; font-size: 12.5px; padding: 26px 4px 0; line-height: 1.7; }
.footer a { color: #c8d3e2; }
.progress { height: 8px; background: #edf0f3; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--teal), #2aa58f); border-radius: 99px; }
.waterfall-label { font-size: 11px; fill: var(--slate); }
.stat-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--divider); font-size: 13.5px; }
.stat-row:last-child { border-bottom: 0; }
.stat-row b { font-variant-numeric: tabular-nums; }
.glossary-term { border-bottom: 1px dotted var(--gold-dark); cursor: help; }
.search { position: relative; }
.search input { padding-left: 36px; }
.search::before { content: "⌕"; position: absolute; left: 12px; top: 9px; font-size: 16px; color: var(--slate); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 13px; color: var(--slate); }
.dropzone {
  border: 2px dashed var(--border); border-radius: 14px; padding: 30px 18px; text-align: center;
  color: var(--slate); background: var(--surface); cursor: pointer;
}
.dropzone.over { border-color: var(--gold-dark); background: #fbf6ea; }
.chip { display: inline-block; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; margin: 0 4px 4px 0; }
pre.code { background: var(--ink); color: #d7e3f4; padding: 14px 16px; border-radius: 12px; overflow-x: auto; font-size: 12.5px; line-height: 1.6; }

/* ---- auth screen ---- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { background: #fff; border-radius: 20px; box-shadow: var(--shadow); max-width: 460px; width: 100%; padding: 30px 30px 26px; }
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.auth-logo img { width: 46px; height: 46px; }
.divider-or { display: flex; align-items: center; gap: 12px; color: var(--slate); font-size: 12px; margin: 16px 0; }
.divider-or::before, .divider-or::after { content: ""; flex: 1; height: 1px; background: var(--divider); }

/* ---- print (daily / monthly pack) ---- */
@media print {
  body { background: #fff; }
  .rail, .pillnav, .topbar .actions, .ticker, #toasts, .no-print { display: none !important; }
  .main { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  thead th { background: #eee !important; color: #000 !important; }
}

/* ---- responsive ---- */
@media (max-width: 1180px) {
  .g-4 { grid-template-columns: repeat(2, 1fr); }
  .g-main, .g-main-r { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .g-3, .g-2 { grid-template-columns: 1fr; }
  .main { padding: 0 14px 30px; }
  .kpi-value { font-size: 28px; }
}
@media (max-width: 720px) {
  .rail { display: none; }
  .brand-name { font-size: 15px; }
  .topbar { gap: 10px; }
  .pillnav { order: 3; width: 100%; }
  .g-4 { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 16px; }
  .dist-row { grid-template-columns: 96px 1fr 62px; }
}
