/* Erthiox Trade Planner — design system
   Blend of the two attached templates (Subly light dashboard + Finor dark-navy
   fintech dashboard), rebuilt in the Erthiox palette. NOT a 1:1 copy. */
:root {
  --navy: #0B1F3A;
  --ink: #111622;
  --gold: #C5A880;
  --gold-dark: #B89047;
  --cream: #FCFBF9;
  --slate: #5A606C;
  --border: #E8E5DF;
  --divider: #F1EFEA;
  --teal: #0E7C7B;
  --blue: #1a73e8;
  --buy: #1E7A46;
  --sell: #B3261E;
  --amber: #B7791F;
  --amber-bg: #FDF3E0;
  --muted: #F2F4F7;
  --text: #1A2332;
  --text2: #44536A;
  --border2: #B9C2CF;
  --focus: #143A6B;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(17, 22, 34, .06), 0 8px 24px rgba(17, 22, 34, .06);
  --font: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-head: 'Outfit', 'Inter', -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--cream); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--ink); margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 30px; letter-spacing: -.01em; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p { margin: 0 0 12px; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; font-size: 15px; color: var(--text); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--gold); color: var(--ink); }

/* Custom scrollbars — never the browser default */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--divider); }
::-webkit-scrollbar-thumb { background: var(--gold-dark); border-radius: 6px; border: 2px solid var(--divider); }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }
* { scrollbar-width: thin; scrollbar-color: var(--gold-dark) var(--divider); }

.num, td.num, .kpi-value { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.small { font-size: 12.5px; color: var(--slate); }
.muted { color: var(--slate); }
.gold-text { color: var(--gold-dark); }
.buy-text { color: var(--buy); font-weight: 700; }
.sell-text { color: var(--sell); font-weight: 700; }

/* ---------- App shell: navy icon rail + content ---------- */
.shell { display: flex; min-height: 100vh; }
.rail {
  width: 76px; flex: 0 0 76px; background: var(--navy); color: #fff;
  display: flex; flex-direction: column; align-items: center;
  padding: 18px 0 14px; gap: 6px; position: sticky; top: 0; height: 100vh; z-index: 40;
}
.rail-logo { width: 44px; height: 44px; margin-bottom: 14px; }
.rail-logo img { width: 100%; height: 100%; display: block; }
.rail a {
  width: 52px; height: 52px; border-radius: 12px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; color: #B9C2CF;
  font-size: 9.5px; font-weight: 600; letter-spacing: .02em; text-decoration: none;
}
.rail a svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.rail a:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.rail a.active { color: #fff; background: var(--gold-dark); }
.rail .spacer { flex: 1; }
.rail .rail-user {
  width: 40px; height: 40px; border-radius: 50%; background: var(--gold-dark);
  color: var(--ink); font-weight: 700; font-size: 14px; border: 0;
  display: flex; align-items: center; justify-content: center;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 28px;
  position: sticky; top: 0; z-index: 30;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 700; font-size: 17px; color: var(--ink); }
.topbar .brand img { width: 32px; height: 32px; }
.topbar .brand small { display: block; font-size: 11px; color: var(--slate); font-weight: 500; font-family: var(--font); }
.pillnav { display: flex; gap: 4px; background: var(--muted); border-radius: 999px; padding: 4px; margin-left: 12px; }
.pillnav a { padding: 7px 16px; border-radius: 999px; color: var(--text2); font-weight: 600; font-size: 13.5px; text-decoration: none; white-space: nowrap; }
.pillnav a:hover { color: var(--ink); text-decoration: none; }
.pillnav a.active { background: var(--navy); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.market-pill {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; background: #EAF5EC; color: var(--buy); border: 1px solid #CBE6D4;
}
.market-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--buy); }
.market-pill.closed { background: var(--muted); color: var(--slate); border-color: var(--border2); }
.market-pill.closed .dot { background: var(--slate); }
.content { padding: 28px; max-width: 1280px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .promise { font-size: 15px; color: var(--slate); margin: 4px 0 0; }
.footer {
  margin-top: auto; border-top: 1px solid var(--border); background: #fff;
  padding: 22px 28px; font-size: 13px; color: var(--slate);
  display: flex; gap: 24px; flex-wrap: wrap; align-items: center; justify-content: space-between;
}
.footer a { color: var(--slate); }

/* Compact table for wide blotters */
.table-compact table { font-size: 12.5px; }
.table-compact th, .table-compact td { padding: 8px 8px; }
.table-compact td.num, .table-compact th.num { white-space: nowrap; }

/* Filter rows: stack on small screens (inline styles must not win) */
.filters-3 { grid-template-columns: 1fr 1fr 1fr; }
.filters-2-1-1 { grid-template-columns: 2fr 1fr 1fr; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 10px; padding: 10px 18px;
  font-size: 14.5px; font-weight: 650; text-decoration: none; transition: .15s;
  background: var(--navy); color: #fff; min-height: 42px;
}
.btn:hover { background: #16305a; text-decoration: none; }
.btn.gold { background: var(--gold-dark); color: var(--ink); }
.btn.gold:hover { background: var(--gold); }
.btn.ghost { background: #fff; border-color: var(--border2); color: var(--text); }
.btn.ghost:hover { border-color: var(--gold-dark); }
.btn.danger { background: #FDECEA; color: var(--sell); border-color: #F5C6C2; }
.btn.sm { padding: 7px 13px; min-height: 34px; font-size: 13px; border-radius: 8px; }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn-block { width: 100%; }

/* ---------- Cards, KPIs, grids ---------- */
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card h3 { margin-bottom: 4px; }
.card .card-sub { font-size: 13px; color: var(--slate); margin-bottom: 14px; }
.grid { display: grid; gap: 18px; }
.grid > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 2fr; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.kpi-label { font-size: 12.5px; font-weight: 650; color: var(--slate); text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-family: var(--font-head); font-size: 30px; font-weight: 700; color: var(--ink); margin-top: 4px; overflow-wrap: anywhere; }
.kpi-sub { font-size: 13px; color: var(--slate); margin-top: 2px; }
.kpi .delta-up { color: var(--buy); font-weight: 700; }
.kpi .delta-down { color: var(--sell); font-weight: 700; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--slate); padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--cream); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #FBF8F2; }
td.num, th.num { text-align: right; }
tr.clickable { cursor: pointer; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .03em; white-space: nowrap;
}
.badge.buy { background: #EAF5EC; color: var(--buy); }
.badge.sell { background: #FDECEA; color: var(--sell); }
.badge.pass { background: #EAF5EC; color: var(--buy); }
.badge.warn { background: var(--amber-bg); color: var(--amber); }
.badge.block { background: #FDECEA; color: var(--sell); }
.badge.info { background: #E8F0FE; color: #0d47a1; }
.badge.neutral { background: var(--muted); color: var(--slate); }
.badge.gold { background: #F7EEDD; color: var(--gold-dark); }
.badge.stale { background: var(--amber-bg); color: var(--amber); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 650; color: var(--text); margin-bottom: 6px; }
.field .hint { font-size: 12.5px; color: var(--slate); margin-top: 5px; }
.field .error-text { font-size: 12.5px; color: var(--sell); margin-top: 5px; font-weight: 600; display: none; }
.field.invalid input, .field.invalid .dd-btn { border-color: var(--sell); }
.field.invalid .error-text { display: block; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=email], input[type=password], textarea {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--border2); border-radius: 10px;
  background: #fff; font-size: 15px;
}
input:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(20, 58, 107, .15); }
input:disabled { background: var(--muted); color: var(--slate); }
textarea { min-height: 84px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.seg { display: inline-flex; background: var(--muted); border-radius: 10px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; padding: 8px 18px; border-radius: 8px; font-size: 14px; font-weight: 650; color: var(--text2); }
.seg button.active-buy { background: var(--buy); color: #fff; }
.seg button.active-sell { background: var(--sell); color: #fff; }
.seg button.active { background: var(--navy); color: #fff; }

/* Custom dropdown (never a native <select>) */
.dd { position: relative; }
.dd-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 13px; border: 1.5px solid var(--border2); border-radius: 10px; background: #fff;
  font-size: 15px; color: var(--text); text-align: left;
}
.dd-btn .chev { color: var(--slate); font-size: 12px; }
.dd-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60;
  background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(17,22,34,.16);
  max-height: 280px; overflow-y: auto; display: none; padding: 6px;
}
.dd.open .dd-list { display: block; }
.dd-list button {
  display: flex; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 10px 12px; border-radius: 8px; font-size: 14px; color: var(--text); gap: 8px; align-items: center;
}
.dd-list button:hover, .dd-list button.focused { background: var(--divider); }
.dd-list button .dd-note { margin-left: auto; font-size: 12px; color: var(--slate); }
.dd-list .dd-search { width: 100%; margin-bottom: 6px; }

/* ---------- Wizard ---------- */
.wizard { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }
.steps { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; position: sticky; top: 84px; }
.step-item { display: flex; gap: 12px; padding: 12px 10px; border-radius: 10px; cursor: pointer; border: 0; background: transparent; width: 100%; text-align: left; }
.step-item:hover { background: var(--divider); }
.step-item.active { background: #F7EEDD; }
.step-item .step-n {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; background: var(--muted);
  color: var(--slate); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center;
}
.step-item.active .step-n { background: var(--gold-dark); color: var(--ink); }
.step-item.done .step-n { background: var(--buy); color: #fff; }
.step-item .step-t { font-weight: 650; font-size: 14px; color: var(--ink); }
.step-item .step-d { font-size: 12px; color: var(--slate); }
.wizard-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; }

/* ---------- Checks panel ---------- */
.check-row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--divider); align-items: flex-start; }
.check-row:last-child { border-bottom: 0; }
.check-row .check-msg { flex: 1; font-size: 14px; }
.check-row .check-msg b { display: block; font-size: 13.5px; }

/* ---------- Schedule chart (CSS bars + text table) ---------- */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 8px 4px 0; border-bottom: 2px solid var(--border2); }
.chart .bar { flex: 1; background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dark) 100%); border-radius: 4px 4px 0 0; min-height: 4px; position: relative; }
.chart .bar:hover { background: linear-gradient(180deg, var(--navy) 0%, #16305a 100%); }
.chart-labels { display: flex; gap: 6px; font-size: 11px; color: var(--slate); margin-top: 6px; min-width: 0; }
.chart-labels span { flex: 1; text-align: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Ticker (Finor-style top movers) ---------- */
.ticker { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 10px; }
.ticker-item {
  flex: 0 0 auto; display: flex; align-items: center; gap: 9px; background: #fff;
  border: 1px solid var(--border); border-radius: 12px; padding: 9px 14px; cursor: pointer;
}
.ticker-item:hover { border-color: var(--gold-dark); }
.ticker-item .tk-sym { font-weight: 700; font-size: 13.5px; }
.ticker-item .tk-px { font-size: 13px; color: var(--slate); }
.ticker-item .tk-chg { font-size: 12.5px; font-weight: 700; }
.ticker-item .tk-chg.up { color: var(--buy); }
.ticker-item .tk-chg.down { color: var(--sell); }

/* ---------- Landing ---------- */
.hero { background: var(--navy); color: #fff; border-radius: 20px; padding: 40px 36px; margin-bottom: 20px; position: relative; overflow: hidden; }
.hero h1 { color: #fff; font-size: 38px; max-width: 640px; }
.hero p { color: #C9D2DE; font-size: 16.5px; max-width: 620px; }
.hero .hero-cta { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.hero .hero-badge { display: inline-block; background: rgba(197,168,128,.18); color: var(--gold); border: 1px solid rgba(197,168,128,.5); padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; letter-spacing: .04em; margin-bottom: 14px; }
.hero-art { position: absolute; right: 36px; top: 50%; transform: translateY(-50%); width: 220px; opacity: .95; background: var(--cream); border-radius: 18px; padding: 16px; }
.job-card h3 { font-size: 16px; }
.job-card p { font-size: 13.5px; color: var(--slate); margin-bottom: 0; }
.job-card .job-n { font-family: var(--font-head); font-size: 26px; color: var(--gold); font-weight: 700; }
.kofi-wrap { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.kofi-btn {
  display: inline-flex; align-items: center; gap: 9px; background: var(--gold-dark); color: #090d16;
  font-weight: 700; font-size: 15px; padding: 12px 22px; border-radius: 10px; text-decoration: none;
}
.kofi-btn:hover { background: var(--gold); text-decoration: none; }

/* ---------- Modal / toast / auth ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(11, 31, 58, .55); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: 16px; max-width: 520px; width: 100%; padding: 26px; box-shadow: 0 24px 64px rgba(0,0,0,.3); max-height: 90vh; overflow-y: auto; }
.modal h2 { margin-bottom: 4px; }
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast { background: var(--navy); color: #fff; border-radius: 12px; padding: 13px 16px; font-size: 14px; box-shadow: 0 12px 32px rgba(0,0,0,.3); display: flex; gap: 10px; align-items: flex-start; }
.toast.err { background: #7A1F1A; }
.toast .toast-x { margin-left: auto; background: none; border: 0; color: #fff; font-size: 16px; line-height: 1; }
.auth-screen { max-width: 480px; margin: 60px auto; }
.auth-tabs { display: flex; background: var(--muted); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.auth-tabs button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 8px; font-weight: 650; font-size: 14px; color: var(--text2); }
.auth-tabs button.active { background: var(--navy); color: #fff; }
.demo-banner {
  background: #F7EEDD; border: 1px solid var(--gold); color: #6B4E16; border-radius: 10px;
  padding: 10px 14px; font-size: 13.5px; margin-bottom: 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.stale-banner { background: var(--amber-bg); border: 1px solid #E8C88A; color: #6B4E16; border-radius: 10px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 18px; }
.empty-state { text-align: center; padding: 44px 20px; color: var(--slate); }
.empty-state .empty-ico { font-size: 34px; margin-bottom: 8px; }
.skeleton { background: linear-gradient(90deg, var(--divider) 25%, var(--muted) 50%, var(--divider) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; min-height: 18px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Cost build-up rows */
.cost-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--divider); font-size: 14px; }
.cost-row > * { min-width: 0; }
.cost-row strong { overflow-wrap: anywhere; text-align: right; }
.cost-row.total { border-top: 2px solid var(--ink); border-bottom: 0; font-weight: 700; font-size: 16px; padding-top: 12px; }
.cost-row .cost-note { font-size: 12px; color: var(--slate); display: block; }

/* Mobile nav */
.mobile-nav { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g-2-1, .g-1-2 { grid-template-columns: 1fr; }
  .hero-art { display: none; }
}
@media (max-width: 900px) {
  .rail { display: none; }
  .mobile-nav {
    display: flex; gap: 2px; overflow-x: auto; background: var(--navy); padding: 8px 10px;
    position: sticky; top: 64px; z-index: 30;
  }
  .mobile-nav a { color: #B9C2CF; font-size: 12.5px; font-weight: 650; padding: 8px 12px; border-radius: 8px; white-space: nowrap; text-decoration: none; }
  .mobile-nav a.active { background: var(--gold-dark); color: var(--ink); }
  .pillnav { display: none; }
  .wizard { grid-template-columns: 1fr; }
  .filters-3, .filters-2-1-1 { grid-template-columns: 1fr; }
  .steps { position: static; display: flex; overflow-x: auto; gap: 6px; padding: 10px; }
  .step-item { flex: 0 0 auto; }
  .step-item .step-d { display: none; }
  .topbar { padding: 0 16px; }
  .content { padding: 18px 16px; }
  .g3, .g2 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  h1 { font-size: 25px; }
  .hero { padding: 28px 22px; }
  .hero h1 { font-size: 27px; }
  .topbar .brand small { display: none; }
  .market-pill { display: none; }
}
@media (max-width: 420px) {
  .g4 { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 24px; }
  .btn { padding: 10px 14px; }
}
@media print {
  .rail, .topbar, .mobile-nav, .footer, .wizard-nav { display: none !important; }
  .content { padding: 0; }
}
