/* ==========================================================================
   protrader — styles.css
   Dark "trading terminal" theme. Big, high-contrast, dyslexia-friendly:
   large readable type, generous spacing, strong color states, clear hierarchy.
   Vanilla CSS, no build step, no external fonts (system stack only).
   ========================================================================== */

:root {
  /* --- Palette --- */
  --bg:        #0c1018;   /* page background, deep but not pure black */
  --bg-2:      #121826;   /* panels */
  --bg-3:      #1a2334;   /* cards / inputs */
  --bg-4:      #232f45;   /* hover / borders-light */
  --line:      #2c3a55;   /* hairlines */
  --line-soft: #1f2a3d;

  --text:      #f2f6ff;   /* primary text — very high contrast */
  --text-2:    #b9c5db;   /* secondary */
  --text-3:    #8294b3;   /* muted */

  /* States */
  --buy:       #1ed982;   /* green — BUY / positive */
  --buy-deep:  #0f3b2b;
  --buy-glow:  rgba(30, 217, 130, 0.18);
  --wait:      #94a3bd;   /* grey — WAIT / neutral */
  --loss:      #ff5d6c;   /* red — negative */
  --loss-deep: #3a1620;
  --warn:      #ffce4d;   /* amber */

  /* Brand: AI vs Human */
  --ai:        #4db5ff;   /* blue = the machine */
  --ai-soft:   rgba(77, 181, 255, 0.16);
  --human:     #ffb04d;   /* amber = the person */
  --human-soft:rgba(255, 176, 77, 0.16);

  --primary:   #4db5ff;

  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 8px 28px rgba(0, 0, 0, 0.45);

  /* Type — min ~17px body */
  --fz-body:   17px;
  --lh:        1.65;
  --font: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system,
          "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", "Consolas", "Roboto Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fz-body);
  line-height: var(--lh);
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* leave room for the fixed footer */
  padding-bottom: 64px;
}

h1, h2, h3 { line-height: 1.25; margin: 0; }

strong { font-weight: 800; }
em { font-style: normal; color: var(--text); text-decoration: underline; text-underline-offset: 2px; }

.muted { color: var(--text-3); font-weight: 600; font-size: 0.85em; }

/* ============================ TOP BAR ============================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: linear-gradient(180deg, #0e1422 0%, #0c1018 100%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  color: var(--buy);
  font-size: 26px;
  letter-spacing: -3px;
  font-family: var(--mono);
  text-shadow: 0 0 18px var(--buy-glow);
}
.brand-name {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.brand-tag { margin: 2px 0 0; color: var(--text-3); font-size: 14px; }
.brand-tag strong { color: var(--text-2); }
.topbar-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ============================ TABS ============================ */
.tabs {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 12px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--text-3);
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  padding: 14px 18px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
  border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--text-2); background: rgba(255,255,255,0.03); }
.tab.is-active { color: var(--text); border-bottom-color: var(--primary); }
.tab-emoji { font-size: 18px; }

/* ============================ LAYOUT ============================ */
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}
.panel { display: none; animation: fade .2s ease; }
.panel.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.panel-title { font-size: 30px; font-weight: 900; letter-spacing: -0.02em; }
.panel-sub { margin: 8px 0 0; color: var(--text-2); max-width: 64ch; font-size: 17px; }
.panel-sub strong { color: var(--text); }

.section-h {
  font-size: 21px;
  font-weight: 800;
  margin: 30px 0 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

/* ============================ BUTTONS ============================ */
.btn {
  appearance: none;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s, box-shadow .15s;
  line-height: 1.2;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #06121f; }
.btn-primary:hover { background: #6ec3ff; box-shadow: 0 0 0 4px rgba(77,181,255,0.16); }

.btn-ghost { background: var(--bg-3); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg-4); }

.btn-buy { background: var(--buy); color: #06231a; }
.btn-buy:hover { background: #45e89c; box-shadow: 0 0 0 4px var(--buy-glow); }

.btn-skip { background: var(--bg-4); color: var(--text); border-color: var(--line); }
.btn-skip:hover { background: #2c3a55; }

.btn-override { background: transparent; color: var(--human); border-color: var(--human); }
.btn-override:hover { background: var(--human-soft); }

.btn-cancel { color: var(--text-3); }

/* small remove (x) on chips */
.btn-x {
  appearance: none; background: transparent; border: 0; cursor: pointer;
  color: var(--text-3); font-size: 20px; line-height: 1; padding: 0 2px;
  font-weight: 900; transition: color .12s;
}
.btn-x:hover { color: var(--loss); }

/* ============================ STATUS / LOADING ============================ */
.status { margin: 6px 0 18px; min-height: 0; }
.status:empty { margin: 0; }
.status .loading,
.status .error,
.status .info {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border-radius: var(--radius);
  font-weight: 700; font-size: 17px;
}
.status .loading { background: var(--bg-3); color: var(--text-2); border: 1px solid var(--line-soft); }
.status .error   { background: var(--loss-deep); color: #ffd2d7; border: 1px solid #5a2330; }
.status .info    { background: var(--ai-soft); color: var(--text); border: 1px solid #2c4a66; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--primary);
  animation: spin .7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Friendly empty state */
.empty {
  text-align: center;
  background: var(--bg-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 48px 24px;
}
.empty-emoji { font-size: 54px; display: block; margin-bottom: 8px; }
.empty h3 { font-size: 24px; margin-bottom: 8px; }
.empty p { color: var(--text-2); max-width: 48ch; margin: 0 auto 22px; }

/* ============================ TODAY: SUMMARY STRIP ============================ */
.summary-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 24px;
}
.mini-score {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  border-left: 6px solid var(--line);
}
.mini-score.is-ai { border-left-color: var(--ai); }
.mini-score.is-human { border-left-color: var(--human); }
.mini-score .who { font-size: 14px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.mini-score.is-ai .who { color: var(--ai); }
.mini-score.is-human .who { color: var(--human); }
.mini-score .big { font-size: 28px; font-weight: 900; margin-top: 2px; }
.mini-score .sub { font-size: 14px; color: var(--text-3); }

/* ============================ CARDS (TODAY) ============================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 18px;
}
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.card.is-buy {
  border-color: rgba(30,217,130,0.45);
  background: linear-gradient(180deg, rgba(30,217,130,0.08), var(--bg-2) 60%);
  box-shadow: 0 0 0 1px rgba(30,217,130,0.15), var(--shadow);
}
.card.is-wait { opacity: 0.96; }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-sym { font-size: 30px; font-weight: 900; letter-spacing: -0.01em; font-family: var(--mono); }
.card-price { font-size: 18px; color: var(--text-2); margin-top: 2px; font-family: var(--mono); }

.badge {
  font-size: 14px; font-weight: 900; letter-spacing: .06em;
  padding: 6px 12px; border-radius: 999px; text-transform: uppercase;
}
.badge-buy  { background: var(--buy); color: #06231a; }
.badge-wait { background: var(--bg-4); color: var(--text-2); }

.card-stats { display: flex; gap: 22px; margin: 16px 0 4px; }
.card-stat .k { font-size: 13px; color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.card-stat .v { font-size: 22px; font-weight: 900; font-family: var(--mono); }

.card-reason {
  margin: 14px 0 0;
  font-size: 16px;
  color: var(--text-2);
  background: var(--bg-3);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
}

/* Confidence meter */
.meter { margin: 16px 0 4px; }
.meter-label { display: flex; justify-content: space-between; font-size: 14px; color: var(--text-3); font-weight: 700; margin-bottom: 6px; }
.meter-label .pct { color: var(--text); font-weight: 900; font-family: var(--mono); }
.meter-track { height: 12px; background: var(--bg-3); border-radius: 999px; overflow: hidden; border: 1px solid var(--line-soft); }
.meter-fill { height: 100%; border-radius: 999px; transition: width .4s ease; }
.meter-fill.lvl-hi  { background: linear-gradient(90deg, #14b873, var(--buy)); }
.meter-fill.lvl-mid { background: linear-gradient(90deg, #b58a1f, var(--warn)); }
.meter-fill.lvl-lo  { background: linear-gradient(90deg, #4a5871, var(--wait)); }

.card-actions { display: flex; gap: 10px; margin-top: 18px; }
.card-actions .btn { flex: 1; padding: 12px 8px; font-size: 16px; }

.card-decided {
  margin-top: 18px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bg-3); border: 1px solid var(--line-soft);
  font-weight: 800; text-align: center; font-size: 16px;
}

/* ============================ TRACK: SCOREBOARD ============================ */
.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: stretch;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
}
.score-col {
  padding: 22px 20px;
  border-radius: var(--radius-sm);
}
.score-col.is-ai { background: var(--ai-soft); border: 1px solid #2c4a66; }
.score-col.is-human { background: var(--human-soft); border: 1px solid #5e4a26; }
.score-col .who { font-size: 18px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
.score-col.is-ai .who { color: var(--ai); }
.score-col.is-human .who { color: var(--human); }
.score-rows { margin-top: 14px; display: grid; gap: 12px; }
.score-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.score-row .k { font-size: 15px; color: var(--text-2); font-weight: 700; }
.score-row .v { font-size: 24px; font-weight: 900; font-family: var(--mono); }
.score-row .v.lead { text-shadow: 0 0 12px currentColor; }

.vs {
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 900; color: var(--text-3);
  padding: 0 4px;
}
.vs-pill {
  background: var(--bg-4); color: var(--text);
  border-radius: 999px; padding: 8px 14px; border: 1px solid var(--line);
  font-size: 18px;
}

/* ============================ CHART ============================ */
.chart-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px 22px;
  margin-top: 26px;
}
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.chart-head .section-h { margin: 0 0 8px; }
.legend { display: flex; gap: 18px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--text-2); }
.swatch { width: 16px; height: 4px; border-radius: 2px; display: inline-block; }
.swatch-ai { background: var(--ai); }
.swatch-human { background: var(--human); }
.chart-body { width: 100%; }
.chart-body svg { width: 100%; height: auto; display: block; }
.chart-empty { padding: 40px; text-align: center; color: var(--text-3); font-weight: 700; }

/* ============================ TABLES ============================ */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
thead th {
  text-align: left; font-size: 13px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); font-weight: 800; padding: 14px 16px;
  border-bottom: 2px solid var(--line); white-space: nowrap;
}
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); font-size: 16px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
td.sym, th.sym { font-family: var(--mono); font-weight: 800; }
td.num { font-family: var(--mono); text-align: right; }

.tag {
  font-size: 12px; font-weight: 900; padding: 3px 9px; border-radius: 6px;
  letter-spacing: .04em; text-transform: uppercase;
}
.tag-ai { background: var(--ai-soft); color: var(--ai); }
.tag-human { background: var(--human-soft); color: var(--human); }
.tag-open { background: var(--ai-soft); color: var(--ai); }

.pos { color: var(--buy); font-weight: 900; }
.neg { color: var(--loss); font-weight: 900; }

/* ============================ STAT GRID (BACKTEST) ============================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.stat {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
}
.stat .k { font-size: 14px; color: var(--text-3); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 32px; font-weight: 900; font-family: var(--mono); margin-top: 4px; }
.stat .hint { font-size: 13px; color: var(--text-3); margin-top: 4px; }

/* ============================ WATCHLIST CHIPS ============================ */
.add-row {
  display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 8px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; font-weight: 800; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.input {
  background: var(--bg-3); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 17px; font-family: inherit;
  min-width: 160px; transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(77,181,255,0.18); }
.input-lg { font-size: 22px; padding: 14px 16px; width: 100%; letter-spacing: .1em; text-align: center; }
select.input { cursor: pointer; }

.wl-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 8px; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 9px 9px 16px;
  font-family: var(--mono); font-weight: 800; font-size: 17px;
}
.chip.is-inactive { opacity: .5; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--buy); }
.chip.is-inactive .dot { background: var(--text-3); }

/* ============================ DISCLAIMER ============================ */
.disclaimer-inline {
  margin-top: 24px; background: rgba(255,206,77,0.08);
  border: 1px solid #5a4a1e; border-radius: var(--radius);
  padding: 16px 18px; color: var(--text-2); font-size: 16px; line-height: 1.6;
}
.disclaimer-inline strong { color: var(--warn); }

/* ============================ FOOTER ============================ */
.footer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(10,14,22,0.95);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  text-align: center;
}
.footer p { margin: 0; padding: 14px 16px; font-size: 14px; font-weight: 700; color: var(--text-3); letter-spacing: .02em; }

/* ============================ MODAL ============================ */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4,7,12,0.78);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fade .15s ease;
}
/* A class selector beats the browser's default [hidden] rule, so state it explicitly. */
.modal[hidden] { display: none; }
.modal-card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px; max-width: 440px; width: 100%;
  box-shadow: var(--shadow);
}
.modal-title { font-size: 24px; font-weight: 900; margin-bottom: 8px; }
.modal-text { color: var(--text-2); margin: 0 0 18px; font-size: 16px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 16px; }
.modal-actions-stack { flex-direction: column; }
.modal-actions-stack .btn { width: 100%; padding: 14px; }
.pin-error { color: #ffd2d7; background: var(--loss-deep); border: 1px solid #5a2330; border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 10px; font-weight: 700; font-size: 15px; }

/* ============================ TOAST ============================ */
.toast {
  position: fixed; left: 50%; bottom: 78px; transform: translateX(-50%);
  z-index: 120; background: var(--bg-4); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 12px 22px; font-weight: 800; font-size: 16px;
  box-shadow: var(--shadow); animation: toastIn .2s ease;
  max-width: 90vw; text-align: center;
}
.toast.is-good { border-color: var(--buy); }
.toast.is-bad  { border-color: var(--loss); color: #ffd2d7; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============================ RESPONSIVE ============================ */
@media (max-width: 720px) {
  :root { --fz-body: 17px; }
  .panel-title { font-size: 25px; }
  .topbar-inner { padding: 12px 14px; }
  .wrap { padding: 20px 14px 32px; }
  .summary-strip { grid-template-columns: 1fr; }
  .wl-groups { grid-template-columns: 1fr; }
  .scoreboard { grid-template-columns: 1fr; }
  .vs { padding: 6px 0; }
  .vs-pill { transform: none; }
  .card-grid { grid-template-columns: 1fr; }
  .panel-head { align-items: flex-start; }
  .btn { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
