/* FIRE Tracker — clean fintech theme, mobile-first, system fonts */

:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #1a2332;
  --muted: #5d6b82;
  --faint: #8a96ab;
  --line: #e3e8f0;
  --accent: #1663d9;
  --accent-dark: #0f4aa8;
  --green: #178a4c;
  --red: #c93a3a;
  --amber: #b97a0c;
  --header-bg: #101c30;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 28, 48, 0.08), 0 4px 14px rgba(16, 28, 48, 0.06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 15px;
}

/* ---------- Header ---------- */
.app-header {
  background: var(--header-bg);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2f7de1, #0f4aa8);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; letter-spacing: 0.5px;
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: 0.2px; }

.header-stats { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.header-stat { display: flex; flex-direction: column; line-height: 1.25; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: #9fb0cc; }
.stat-value { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.stat-value.pos { color: #7ddba0; }
.stat-value.neg { color: #ff9d9d; }

.price-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #cdd8ec;
  white-space: nowrap;
}
.price-badge.ok { background: rgba(23, 138, 76, 0.35); color: #bdf0d2; }
.price-badge.stale { background: rgba(185, 122, 12, 0.35); color: #ffe1a8; }
.price-badge.off { background: rgba(201, 58, 58, 0.35); color: #ffc9c9; }

/* ---------- Tabs ---------- */
.tab-nav {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 16px 0;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  background: transparent;
  border: none;
  color: #9fb0cc;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tab-btn:hover { color: #dbe4f5; }
.tab-btn.active { color: #fff; border-bottom-color: #2f7de1; }

/* ---------- Layout ---------- */
.main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadein 0.18s ease-in; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 16px; }
.card h3 { margin: 14px 0 8px; font-size: 14px; color: var(--muted); }
.explainer p { margin: 8px 0; color: var(--muted); }
.explainer strong { color: var(--ink); }

.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid-2 { grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.grid > .card { margin-bottom: 0; }

.cards-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .cards-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .cards-grid { grid-template-columns: 1fr 1fr 1fr; } }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.inline-h { margin: 0; font-size: 16px; }
.lede { color: var(--muted); margin: 0; max-width: 640px; }
.hint { color: var(--faint); font-size: 13px; margin: 10px 0 0; }
.big-number { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
.sub { color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.pos { color: var(--green); } .neg { color: var(--red); }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.kv:last-child { border-bottom: none; }
.kv span { color: var(--muted); }
.kv.big { font-size: 17px; }
.kv strong { text-align: right; }

/* ---------- Progress ---------- */
.progress-wrap { margin: 6px 0 10px; }
.progress-track { height: 14px; background: #e8edf5; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #2f7de1, #18b26b); border-radius: 999px; transition: width 0.4s ease; }
.progress-meta { display: flex; justify-content: space-between; margin-top: 6px; font-size: 13px; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.table th { text-align: left; color: var(--faint); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; white-space: nowrap; }
.row-shortfall td { background: #fdf0f0; }

/* ---------- Forms & buttons ---------- */
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
label.full { grid-column: 1 / -1; }
label .val { color: var(--ink); font-weight: 700; }
input[type="text"], input[type="number"], input[type="date"], input[type="month"], select {
  font: inherit; color: var(--ink);
  border: 1px solid #c9d2e0; border-radius: 8px;
  padding: 9px 11px; background: #fff; width: 100%;
}
input:focus, select:focus { outline: 2px solid rgba(47, 125, 225, 0.45); border-color: var(--accent); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.inline-label { flex-direction: row; align-items: center; gap: 8px; }
.inline-label select { width: auto; }

.btn-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.btn-row.wrap { flex-wrap: wrap; }
.btn {
  font: inherit; font-weight: 600; font-size: 14px;
  border: 1px solid #c9d2e0; background: #fff; color: var(--ink);
  border-radius: 9px; padding: 9px 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none;
}
.btn:hover { background: #f0f4fa; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; }
.btn-danger-ghost { background: transparent; color: var(--red); border-color: #eec9c9; }
.btn-danger-ghost:hover { background: #fdf0f0; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.hidden { display: none !important; }

/* ---------- Donut / legend ---------- */
.donut-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
#donutChart { width: 150px; height: 150px; flex: none; }
.legend { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.legend.inline { flex-direction: row; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.legend-item { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }

/* ---------- Account cards ---------- */
.acct { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.acct-head { padding: 14px 18px; background: #f8fafd; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.acct-head h3 { margin: 0; font-size: 15px; }
.acct-type { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.6px; }
.acct-value { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.acct-body { padding: 6px 18px 14px; }
.acct-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rules { background: #f2f6fc; border-left: 3px solid var(--accent); padding: 10px 14px; margin: 12px 0; font-size: 13px; color: var(--muted); border-radius: 0 8px 8px 0; }
.rules a { color: var(--accent); }
.rules strong { color: var(--ink); }

.sched { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; background: #fff; }
.sched.ended { opacity: 0.62; }
.sched-info strong { display: block; }
.sched-info .meta { font-size: 13px; color: var(--muted); }
.sched-amt { font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; text-align: right; }
.match-tag { font-size: 11px; font-weight: 700; color: var(--green); border: 1px solid #bfe6cf; border-radius: 999px; padding: 1px 8px; margin-left: 8px; }
.ended-tag { font-size: 11px; font-weight: 700; color: var(--amber); border: 1px solid #f0dcae; border-radius: 999px; padding: 1px 8px; margin-left: 8px; }

/* ---------- Verdict / notice ---------- */
.verdict { margin-top: 14px; padding: 14px 16px; border-radius: 10px; font-size: 15px; display: none; }
.verdict.show { display: block; }
.verdict.good { background: #e9f7ef; border: 1px solid #bfe6cf; color: #14532d; }
.verdict.warn { background: #fdf3e3; border: 1px solid #f0dcae; color: #7a4d08; }
.verdict.bad { background: #fdecec; border: 1px solid #f3c2c2; color: #8f1f1f; }
.notice { background: #fff8e8; border: 1px solid #f0dcae; border-radius: 10px; padding: 12px 14px; margin: 14px 0; font-size: 14px; color: #5c4a1f; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: #e8edf5; stroke-width: 1; }
.chart .axis-label { fill: var(--faint); font-size: 11px; }
.chart .tick-label { fill: var(--faint); font-size: 10px; }

/* ---------- Modal / toast ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(16, 28, 48, 0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 14px; z-index: 100; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  width: 100%; max-width: 520px; padding: 22px; margin-top: 4vh;
}
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal .form-grid { margin-bottom: 6px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  max-width: 90vw; text-align: center;
}

/* ---------- Footer ---------- */
.footer {
  max-width: 1100px; margin: 0 auto; padding: 0 16px 30px;
  color: var(--faint); font-size: 13px; text-align: center;
}

.mini { font-size: 12px; color: var(--faint); }
.linklike { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; font-size: 13px; padding: 0; }
.linklike:hover { text-decoration: underline; }

/* Ticker autocomplete dropdown */
.ticker-suggest-wrap { position: relative; display: inline-block; max-width: 100%; }
.ticker-suggest {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; min-width: 260px;
  z-index: 120; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(16, 28, 48, 0.14);
  max-height: 248px; overflow-y: auto; padding: 4px;
}
.ts-item {
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 13px;
}
.ts-item strong { color: var(--ink); white-space: nowrap; }
.ts-item.active, .ts-item:hover { background: #eaf1fd; }
.ts-name { flex: 1; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-exch { color: var(--faint); font-size: 11px; white-space: nowrap; }
