/* Erthiox Repo Desk — main stylesheet.
 * Language: Erthiox prestige (navy #0B1F3A, gold #C5A880 / #B89047, cream
 * #FCFBF9, slate #5A606C) blended with the two UI templates Artem supplied:
 * Subly light dashboard (white cards, dark left icon rail, pill top nav, big
 * KPIs) and Finor dark-navy fintech dashboard (ticker strip, big value +
 * line chart, donut, distribution bars). NOT a 1:1 copy of either.
 * Light mode only in v1 (plan 1.5). No native select, no native scrollbar.
 */
:root {
  --navy-900: #0B1F3A; --navy-800: #12294a; --steel-700: #143A6B;
  --gold-500: #C5A880; --gold-dark: #B89047;
  --cream: #FCFBF9; --surface: #F2F4F7; --ink: #1A2332; --muted: #44536A;
  --border: #B9C2CF; --divider: #E8E5DF;
  --green: #0E7A5F; --amber: #8A6D3B; --red: #B3261E;
  --blue: #1a73e8;
  --radius: 14px; --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(11,31,58,.06), 0 8px 24px rgba(11,31,58,.07);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'Outfit', 'Inter', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--cream); color: var(--ink); font-size: 15px; line-height: 1.5; }
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--navy-900); margin: 0 0 8px; letter-spacing: -.01em; }
a { color: var(--steel-700); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; font-size: 15px; }
img { max-width: 100%; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* custom scrollbars everywhere (rule 2) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--gold-500); border-radius: 6px; border: 2px solid var(--surface); }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }
* { scrollbar-width: thin; scrollbar-color: var(--gold-500) var(--surface); }

/* ---------- app shell: dark rail + content ---------- */
.shell { display: flex; min-height: 100vh; }
.rail { width: 232px; flex: 0 0 232px; background: var(--navy-900); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 40; }
.rail-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.12); }
.rail-brand img { width: 38px; height: 38px; border-radius: 9px; background: #fff; padding: 2px; }
.rail-brand .name { font-family: var(--font-head); font-weight: 700; font-size: 16px; line-height: 1.15; }
.rail-brand .sub { font-size: 11px; color: var(--gold-500); letter-spacing: .04em; }
.rail nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.rail nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px; color: #cfd8e6; font-size: 14px; text-decoration: none; }
.rail nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.rail nav a.active { background: var(--gold-dark); color: #fff; font-weight: 600; }
.rail nav a .ic { width: 20px; text-align: center; font-size: 16px; }
.rail-foot { margin-top: auto; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.12); font-size: 12px; color: #9fb0c6; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(252,251,249,.96); backdrop-filter: blur(6px); border-bottom: 1px solid var(--divider); padding: 10px 22px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar .ws { font-weight: 700; color: var(--navy-900); }
.topbar .asof { font-size: 13px; color: var(--muted); }
.topbar .spacer { flex: 1; }
.content { padding: 22px; max-width: 1440px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 26px; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ticker strip (Finor-style) */
.ticker { display: flex; gap: 8px; overflow-x: auto; padding: 10px 22px 0; }
.ticker .tick { flex: 0 0 auto; background: #fff; border: 1px solid var(--divider); border-radius: 999px; padding: 6px 14px; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.ticker .tick b { color: var(--navy-900); }
.ticker .up { color: var(--green); } .ticker .down { color: var(--red); }

/* demo banner */
.demo-banner { background: #fff7e6; border: 1px solid #e8c87a; color: #6b4e12; padding: 9px 22px; font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.demo-banner b { color: #6b4e12; }

/* ---------- buttons, pills, cards ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--navy-900); background: var(--navy-900); color: #fff; border-radius: 9px; padding: 10px 16px; font-size: 14px; font-weight: 600; text-decoration: none; }
.btn:hover { background: var(--navy-800); text-decoration: none; }
.btn.gold { background: var(--gold-dark); border-color: var(--gold-dark); color: #fff; }
.btn.gold:hover { background: #a67c3a; }
.btn.ghost { background: #fff; color: var(--navy-900); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface); }
.btn.danger { background: #fff; color: var(--red); border-color: var(--red); }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.pill.green { background: #e2f3ee; color: #0a5c48; }
.pill.amber { background: #f7ecd4; color: #6b4e12; }
.pill.red { background: #fbe3e1; color: #8f1d16; }
.pill.navy { background: #e3e9f2; color: var(--navy-900); }
.pill.grey { background: var(--surface); color: var(--muted); }
.card { background: #fff; border: 1px solid var(--divider); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h2 { font-size: 17px; }
.card h3 { font-size: 15px; }
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(4, 1fr); }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.kpi .label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.kpi .value { font-family: var(--font-head); font-size: 30px; font-weight: 700; color: var(--navy-900); margin: 6px 0 2px; }
.kpi .delta { font-size: 13px; }
.kpi .delta.good { color: var(--green); } .kpi .delta.bad { color: var(--red); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--divider); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 720px; }
.tbl th { position: sticky; top: 0; background: var(--navy-900); color: #fff; text-align: left; padding: 11px 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.tbl td { padding: 11px 12px; border-top: 1px solid var(--divider); white-space: nowrap; }
.tbl tbody tr:nth-child(even) td { background: var(--surface); }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover td { background: #f6ecd9; }
.tbl .r { text-align: right; }
.tbl .c { text-align: center; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--navy-900); margin-bottom: 5px; }
.field input[type=text], .field input[type=number], .field input[type=date], .field input[type=email], .field input[type=password], .field textarea { width: 100%; border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; background: #fff; color: var(--ink); }
.field input:focus, .field textarea:focus { outline: 2px solid var(--gold-500); border-color: var(--gold-dark); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .err { font-size: 13px; color: var(--red); margin-top: 4px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.callout { border-left: 4px solid var(--gold-dark); background: #fbf6ec; padding: 12px 14px; border-radius: 0 9px 9px 0; font-size: 14px; margin: 12px 0; }
.callout.red { border-color: var(--red); background: #fdf1f0; }
.callout.green { border-color: var(--green); background: #eef7f4; }
.callout.amber { border-color: var(--amber); background: #fbf5e6; }

/* custom dropdown (no native select) */
.dd { position: relative; }
.dd-btn { width: 100%; display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; background: #fff; font-size: 14px; text-align: left; }
.dd-btn:after { content: "▾"; color: var(--muted); }
.dd-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; z-index: 60; display: none; }
.dd.open .dd-list { display: block; }
.dd-list button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px; font-size: 14px; }
.dd-list button:hover, .dd-list button.sel { background: var(--surface); font-weight: 600; }
.dd-list .dd-search { width: 100%; border: 0; border-bottom: 1px solid var(--divider); padding: 10px 12px; }

/* modal + toast (no native alert/confirm) */
.modal-backdrop { position: fixed; inset: 0; background: rgba(11,31,58,.55); display: none; align-items: center; justify-content: center; z-index: 100; padding: 18px; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: 16px; box-shadow: 0 24px 64px rgba(0,0,0,.3); max-width: 640px; width: 100%; max-height: 88vh; overflow-y: auto; padding: 22px; }
.modal h2 { font-size: 20px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; 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, calc(100vw - 40px)); }
.toast { background: var(--navy-900); color: #fff; border-radius: 10px; padding: 12px 16px; font-size: 14px; box-shadow: var(--shadow); border-left: 4px solid var(--gold-500); }
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }

/* misc components */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 8px 15px; font-size: 13px; font-weight: 600; color: var(--muted); }
.tabs button.active { background: var(--navy-900); color: #fff; border-color: var(--navy-900); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; }
.calc-line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--divider); font-size: 14px; }
.calc-line.total { font-weight: 700; border-bottom: 0; font-size: 16px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; margin: 8px 0; }
.bar-row .blabel { width: 170px; flex: 0 0 170px; }
.bar-track { flex: 1; height: 12px; background: var(--surface); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--steel-700); border-radius: 6px; }
.bar-fill.gold { background: var(--gold-dark); }
.bar-fill.green { background: var(--green); }
.bar-fill.red { background: var(--red); }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty h3 { color: var(--navy-900); }
.footer { padding: 22px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--divider); margin-top: auto; display: flex; gap: 18px; flex-wrap: wrap; justify-content: space-between; }
.landing-hero { background: var(--navy-900); color: #fff; border-radius: 20px; padding: 44px 36px; margin-bottom: 20px; }
.landing-hero h1 { color: #fff; font-size: 40px; line-height: 1.1; }
.landing-hero p { color: #cfd8e6; font-size: 17px; max-width: 640px; }
.landing-hero .btn.gold { margin-top: 8px; }
.feature-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.feature-list .card h3 { margin-bottom: 4px; }
.support { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--divider); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); }
.kofi { display: inline-flex; align-items: center; gap: 8px; background: var(--gold-dark); color: #090d16; font-weight: 700; border-radius: 9px; padding: 10px 16px; text-decoration: none; }
.kofi:hover { text-decoration: none; background: #a67c3a; color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .donut-wrap { flex-direction: column; align-items: flex-start !important; }
  .donut-wrap > div { width: 100%; }
  .kpi .value { font-size: 26px; }
}
@media (max-width: 1100px) {
  .grid.kpis { grid-template-columns: repeat(2, 1fr); }
  .grid.three, .feature-list { grid-template-columns: 1fr 1fr; }
  .grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .rail { width: 64px; flex-basis: 64px; }
  .rail-brand .name, .rail-brand .sub, .rail nav a span.lbl, .rail-foot { display: none; }
  .rail-brand { justify-content: center; padding: 14px 8px 10px; }
  .rail nav a { justify-content: center; padding: 12px; }
  .content { padding: 16px; }
}
@media (max-width: 640px) {
  .grid.kpis, .grid.three, .feature-list, .form-grid { grid-template-columns: 1fr; }
  .landing-hero { padding: 28px 20px; }
  .landing-hero h1 { font-size: 29px; }
  .topbar { padding: 10px 14px; }
  .kpi .value { font-size: 25px; }
  .bar-row .blabel { width: 110px; flex-basis: 110px; }
  .modal { padding: 16px; }
}
@media print {
  .rail, .topbar, .footer, .demo-banner { display: none; }
  .content { padding: 0; }
}
