/* ============================================================
   THAI DIVIDEND STOCK ALERT — MINIMAL PROFESSIONAL DASHBOARD
   ธีม: Light · Hairline · Refined Blue + Restrained Gold
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  /* Surface — cool whites & paper grays */
  --surface-app:     #f7f8fa;
  --surface-panel:   #ffffff;
  --surface-sunken:  #f1f3f6;
  --surface-hover:   #f5f7fa;
  --surface-active:  #eef2f7;

  /* Hairlines */
  --line:            #e6e8ec;
  --line-strong:     #d4d8df;
  --line-soft:       #eef0f4;

  /* Ink — slate-warm */
  --ink-900: #0b1220;
  --ink-800: #1a2236;
  --ink-700: #2c3650;
  --ink-600: #475069;
  --ink-500: #6b7488;
  --ink-400: #969cad;
  --ink-300: #b9bdc9;
  --ink-200: #d6d9e0;

  /* Brand — refined navy blue (single, controlled accent) */
  --blue-900: #0a2454;
  --blue-800: #0f3275;
  --blue-700: #1843a0;
  --blue-600: #2056c6;
  --blue-500: #2f6fe5;
  --blue-100: #e0eaff;
  --blue-50:  #f0f5ff;

  /* Gold — restrained, used only for highlights/marks */
  --gold-700: #8a6a14;
  --gold-600: #b08220;
  --gold-500: #c8962b;
  --gold-400: #d6a946;
  --gold-100: #f7ecc7;
  --gold-50:  #fdf7e3;

  /* Status — muted, professional (not neon) */
  --success-700: #0a6e3f;
  --success-500: #15a25d;
  --success-100: #d8f3e3;
  --warn-700:    #8a4a04;
  --warn-500:    #c5710a;
  --warn-100:    #fbe7c7;
  --danger-700:  #93180c;
  --danger-500:  #d62f1f;
  --danger-100:  #fbe1dd;

  /* Type — IBM Plex Sans Thai (display) · Sarabun (body) · JetBrains Mono (numerics) */
  --font-display: 'IBM Plex Sans Thai', 'Sarabun', system-ui, sans-serif;
  --font-body:    'Sarabun', 'IBM Plex Sans Thai', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  /* Layout */
  --sidebar-w: 232px;
  --radius-lg: 10px;
  --radius:    8px;
  --radius-sm: 6px;

  /* Shadow — barely there */
  --shadow-xs: 0 1px 2px rgba(11, 18, 32, 0.04);
  --shadow-sm: 0 2px 6px rgba(11, 18, 32, 0.05);
  --shadow-md: 0 4px 14px rgba(11, 18, 32, 0.06);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--surface-app);
  color: var(--ink-800);
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'tnum' 1;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { color: var(--blue-700); }

/* ---------- Risk Banner — subdued, professional ---------- */
.risk-banner {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 24px;
  background: var(--ink-900);
  color: #cdd2dc;
  font-size: 11.5px;
  font-weight: 400;
  letter-spacing: 0.005em;
  border-bottom: 1px solid var(--ink-800);
}
.risk-banner strong { color: #fff; font-weight: 600; }
.risk-icon { font-size: 12px; opacity: 0.85; }
.risk-text { letter-spacing: 0.005em; }

/* ---------- App Shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100vh - 28px);
}

/* ---------- Sidebar — paper white ---------- */
.sidebar {
  background: var(--surface-panel);
  border-right: 1px solid var(--line);
  padding: 20px 14px 18px;
  position: sticky;
  top: 28px;
  height: calc(100vh - 28px);
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--surface-panel);
  padding: 2px;
  flex-shrink: 0;
  display: block;
}
.brand-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--ink-900);
}
.brand-title span { color: var(--blue-600); }
.brand-sub {
  font-size: 10px;
  color: var(--ink-500);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
  margin-top: 2px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink-600);
  font-family: var(--font-display);
  font-weight: 500;
  transition: background .12s, color .12s;
  text-align: left;
  position: relative;
  letter-spacing: 0.005em;
}
.nav-item:hover { background: var(--surface-hover); color: var(--ink-900); }
.nav-item.active {
  background: var(--blue-50);
  color: var(--blue-700);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 16px;
  background: var(--blue-600);
  border-radius: 0 2px 2px 0;
}
.nav-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
  filter: grayscale(0.15);
  opacity: 0.85;
}
.nav-item.active .nav-icon { filter: none; opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--ink-600);
  font-family: var(--font-mono);
}
.status-pill .dot {
  width: 6px; height: 6px;
  background: var(--success-500);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(21, 162, 93, 0.18);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.95); }
}
.btn-refresh {
  padding: 8px 12px;
  background: var(--ink-900);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-family: var(--font-display);
  font-size: 12.5px;
  display: flex; align-items: center; gap: 8px; justify-content: center;
  transition: background .12s, transform .12s;
  border: 1px solid var(--ink-900);
}
.btn-refresh:hover { background: var(--ink-800); }
.btn-refresh span:first-child { font-size: 14px; opacity: 0.9; }

/* ---------- Main content ---------- */
.main-content {
  padding: 24px 32px 80px;
  overflow-x: hidden;
  max-width: 100%;
}

.page { display: none; animation: fadeUp .25s cubic-bezier(.4,0,.2,1); }
.page.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Page header ---------- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.page-eyebrow {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--blue-600);
  margin-bottom: 6px;
  font-family: var(--font-display);
}
.page-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink-900);
  line-height: 1.2;
}
.page-sub {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-500);
}
.page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ---------- Buttons ---------- */
.btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-display);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s, color .12s;
  letter-spacing: 0.005em;
  white-space: nowrap;
}
.btn-primary {
  background: var(--ink-900);
  color: #fff;
  border-color: var(--ink-900);
}
.btn-primary:hover { background: var(--ink-800); border-color: var(--ink-800); }
.btn-ghost {
  background: var(--surface-panel);
  color: var(--ink-700);
  border-color: var(--line-strong);
}
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--ink-300); color: var(--ink-900); }
.btn-danger {
  background: #fff;
  color: var(--danger-700);
  border-color: var(--danger-100);
}
.btn-danger:hover { background: var(--danger-100); }

/* ---------- Stat tiles — clean numeric cards ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 22px;
  overflow: hidden;
}
.stat {
  background: var(--surface-panel);
  padding: 16px 18px 18px;
  position: relative;
  transition: background .15s;
}
.stat:hover { background: var(--surface-hover); }
.stat-label {
  font-size: 11.5px;
  color: var(--ink-500);
  font-weight: 500;
  letter-spacing: 0.01em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat-label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-300);
  flex-shrink: 0;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--ink-900);
  letter-spacing: -0.025em;
  line-height: 1;
  font-feature-settings: 'tnum' 1;
}
.stat-value sup {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-400);
  margin-left: 4px;
  letter-spacing: 0;
  vertical-align: middle;
}

/* Accent dots — give each metric a subtle category color */
.stat.accent-gold   .stat-label::before { background: var(--gold-500); }
.stat.accent-green  .stat-label::before { background: var(--success-500); }
.stat.accent-red    .stat-label::before { background: var(--danger-500); }
.stat.accent-amber  .stat-label::before { background: var(--warn-500); }

/* ---------- Card ---------- */
.card {
  background: var(--surface-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
  overflow: hidden;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.card-header h3 {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-900);
  letter-spacing: -0.005em;
}
.card-sub {
  font-size: 11.5px;
  color: var(--ink-500);
  font-weight: 400;
}
.card-header-row {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---------- Charts grid ---------- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.charts-grid .card { margin-bottom: 0; }
.chart-wrap {
  padding: 14px 18px 18px;
  height: 240px;
}

/* ---------- Filters & inputs ---------- */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar input,
.filter-bar select,
.settings-grid input,
.settings-grid select,
.watchlist-form input,
.select-large {
  background: var(--surface-panel);
  border: 1px solid var(--line-strong);
  color: var(--ink-900);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  font-family: var(--font-body);
}
.filter-bar input:focus,
.filter-bar select:focus,
.settings-grid input:focus,
.settings-grid select:focus,
.watchlist-form input:focus,
.select-large:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-100);
}
.filter-bar input { min-width: 220px; }
.filter-bar input::placeholder { color: var(--ink-400); }
.select-large { min-width: 280px; padding: 8px 12px; font-size: 13px; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.stock-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  font-feature-settings: 'tnum' 1;
}
.stock-table thead th {
  text-align: left;
  padding: 10px 12px;
  background: var(--surface-sunken);
  font-weight: 500;
  font-family: var(--font-display);
  color: var(--ink-500);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
.stock-table tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-800);
  vertical-align: middle;
  white-space: nowrap;
}
.stock-table tbody tr {
  cursor: pointer;
  transition: background .1s;
}
.stock-table tbody tr:hover { background: var(--surface-hover); }
.stock-table tbody tr:last-child td { border-bottom: none; }

.cell-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}
.cell-symbol {
  font-weight: 600;
  color: var(--ink-900);
  font-family: var(--font-display);
  letter-spacing: 0.005em;
}
.cell-name {
  color: var(--ink-700);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cell-sector {
  color: var(--ink-500);
  font-size: 11.5px;
}

.text-up   { color: var(--success-700); font-weight: 500; }
.text-down { color: var(--danger-700);  font-weight: 500; }
.text-warn { color: var(--warn-700);    font-weight: 500; }
.text-mute { color: var(--ink-400); }

/* ---------- Score pill ---------- */
.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 11.5px;
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
}
.score-pill.s-high {
  background: var(--success-100);
  color: var(--success-700);
}
.score-pill.s-med {
  background: var(--blue-100);
  color: var(--blue-700);
}
.score-pill.s-low {
  background: var(--danger-100);
  color: var(--danger-700);
}
.score-pill.s-neut {
  background: var(--surface-sunken);
  color: var(--ink-600);
}

.bonus-tag {
  display: inline-block;
  padding: 2px 6px;
  background: var(--gold-50);
  color: var(--gold-700);
  border: 1px solid var(--gold-100);
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
  font-family: var(--font-display);
  margin-right: 4px;
  margin-bottom: 2px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-attractive {
  background: var(--success-100);
  color: var(--success-700);
  border-color: rgba(21, 162, 93, 0.2);
}
.badge-watch {
  background: var(--blue-100);
  color: var(--blue-700);
  border-color: rgba(47, 111, 229, 0.18);
}
.badge-wait {
  background: var(--surface-sunken);
  color: var(--ink-600);
  border-color: var(--line);
}
.badge-fail {
  background: var(--danger-100);
  color: var(--danger-700);
  border-color: rgba(214, 47, 31, 0.16);
}
.badge-low52 {
  background: var(--warn-100);
  color: var(--warn-700);
  border-color: rgba(197, 113, 10, 0.18);
}
.badge-xd {
  background: var(--gold-50);
  color: var(--gold-700);
  border-color: var(--gold-100);
}
.badge-postxd {
  background: #f3eaff;
  color: #5a2da1;
  border-color: #e2d3f5;
}

/* ---------- Detail page button ---------- */
.btn-detail {
  padding: 4px 10px;
  background: transparent;
  color: var(--blue-600);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 500;
  font-family: var(--font-display);
  transition: all .12s;
}
.btn-detail:hover {
  background: var(--blue-50);
  border-color: var(--blue-500);
  color: var(--blue-700);
}

/* ---------- Detail / Analysis ---------- */
.detail-hero {
  background: var(--surface-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  align-items: center;
  position: relative;
}
.detail-symbol {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 32px;
  color: var(--ink-900);
  letter-spacing: -0.025em;
  line-height: 1;
}
.detail-name {
  font-size: 14px;
  color: var(--ink-500);
  margin-top: 4px;
  margin-bottom: 16px;
}
.detail-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 24px;
  margin-bottom: 4px;
}
.detail-meta > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
}
.detail-meta > div span:first-child {
  color: var(--ink-500);
  font-size: 11.5px;
  letter-spacing: 0.005em;
}
.detail-meta > div span:last-child {
  color: var(--ink-900);
  font-weight: 500;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.detail-hero-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.score-circle {
  --p: 0;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  position: relative;
  display: grid;
  place-items: center;
  background:
    conic-gradient(var(--blue-600) calc(var(--p) * 1%), var(--surface-sunken) 0);
}
.score-circle::after {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--surface-panel);
  border: 1px solid var(--line);
}
.score-circle-inner {
  position: relative;
  z-index: 1;
  text-align: center;
}
.score-circle-num {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 600;
  color: var(--ink-900);
  letter-spacing: -0.03em;
  line-height: 1;
}
.score-circle-label {
  font-size: 10px;
  color: var(--ink-500);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  margin-top: 4px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.detail-cell {
  background: var(--surface-panel);
  padding: 12px 14px;
}
.detail-cell-label {
  font-size: 11px;
  color: var(--ink-500);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}
.detail-cell-value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-900);
}
.detail-cell-value small { color: var(--ink-400); font-size: 11px; }

.dividend-history {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--line);
  margin: 0;
}
.dividend-history > div {
  background: var(--surface-panel);
  padding: 14px 12px;
  text-align: center;
}
.dividend-history > div small {
  display: block;
  font-size: 10.5px;
  color: var(--ink-500);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.dividend-history > div b {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-900);
}

.summary-box {
  padding: 14px 18px;
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--blue-500);
  font-size: 13px;
  color: var(--ink-700);
  line-height: 1.6;
  margin: 14px 18px 18px;
}

.pros-cons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 0 18px 14px;
}
.pros, .cons {
  padding: 14px 0;
}
.pros { border-right: 1px solid var(--line); padding-right: 18px; }
.cons { padding-left: 18px; }
.pros h4, .cons h4 {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.pros h4 { color: var(--success-700); }
.cons h4 { color: var(--danger-700); }
.pros ul, .cons ul { list-style: none; }
.pros li, .cons li {
  padding: 5px 0 5px 16px;
  position: relative;
  font-size: 12.5px;
  color: var(--ink-700);
  line-height: 1.5;
}
.pros li::before {
  content: '+';
  position: absolute;
  left: 0;
  color: var(--success-500);
  font-weight: 600;
  font-family: var(--font-mono);
}
.cons li::before {
  content: '−';
  position: absolute;
  left: 0;
  color: var(--danger-500);
  font-weight: 600;
  font-family: var(--font-mono);
}

/* ---------- Watchlist form ---------- */
.watchlist-form {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr auto auto;
  gap: 8px;
  padding: 14px 18px;
}
.watchlist-form .switch {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-600);
  white-space: nowrap;
  padding: 0 4px;
}
.watchlist-form .switch input { width: 14px; height: 14px; accent-color: var(--blue-600); }

/* ---------- Settings ---------- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  padding: 16px 18px 18px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field span {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-600);
  letter-spacing: 0.005em;
}
.field-full { grid-column: 1 / -1; }
.settings-actions {
  display: flex;
  gap: 8px;
  padding: 14px 18px 18px;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  background: var(--surface-sunken);
}

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface-panel);
  border-top: 1px solid var(--line);
  padding: 8px 6px env(safe-area-inset-bottom, 8px);
  z-index: 60;
  justify-content: space-around;
}
.bn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 8px;
  font-size: 10.5px;
  color: var(--ink-500);
  font-weight: 500;
  font-family: var(--font-display);
  border-radius: var(--radius-sm);
  flex: 1;
}
.bn-item span:first-child { font-size: 18px; opacity: 0.85; }
.bn-item.active { color: var(--blue-700); }
.bn-item.active span:first-child { opacity: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--ink-900);
  color: #fff;
  padding: 11px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-display);
  box-shadow: var(--shadow-md);
  z-index: 100;
  opacity: 0;
  transition: transform .25s cubic-bezier(.4,0,.2,1), opacity .2s;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: var(--danger-700); }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface-app); }
::-webkit-scrollbar-thumb {
  background: var(--ink-200);
  border: 2px solid var(--surface-app);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-300); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main-content { padding: 18px 16px 100px; }
  .bottom-nav { display: flex; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-title { font-size: 22px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .watchlist-form { grid-template-columns: 1fr; }
  .pros-cons { grid-template-columns: 1fr; padding: 0 14px 14px; }
  .pros { border-right: none; border-bottom: 1px solid var(--line); padding-right: 0; padding-bottom: 14px; }
  .cons { padding-left: 0; padding-top: 14px; }
  .detail-hero { grid-template-columns: 1fr; text-align: left; }
  .detail-hero-right { align-items: flex-start; }
  .stat-value { font-size: 22px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat { padding: 12px 14px 14px; }
  .stat-value { font-size: 20px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; justify-content: center; }
}

/* ============================================================
   🚀 FUTURE STOCKS PAGE
   ============================================================ */

/* ---------- Step 1: Stock input ---------- */
.future-input-row {
  display: flex;
  gap: 8px;
  padding: 14px 18px 8px;
  flex-wrap: wrap;
}
.future-input-row input {
  flex: 1;
  min-width: 240px;
  background: var(--surface-panel);
  border: 1px solid var(--line-strong);
  color: var(--ink-900);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.future-input-row input:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-100);
}
.future-input-row input::placeholder {
  color: var(--ink-400);
  text-transform: none;
  font-family: var(--font-body);
  letter-spacing: 0;
}

/* ---------- Stock chips ---------- */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 18px 16px;
  min-height: 28px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 4px 10px;
  background: var(--blue-50);
  color: var(--blue-700);
  border: 1px solid rgba(47, 111, 229, 0.18);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: 0.01em;
}
.chip-warn {
  background: var(--warn-100);
  color: var(--warn-700);
  border-color: rgba(197, 113, 10, 0.2);
}
.chip small {
  font-size: 10px;
  background: var(--warn-700);
  color: #fff;
  width: 14px;
  height: 14px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 700;
}
.chip-x {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  font-size: 16px;
  line-height: 1;
  color: var(--ink-500);
  background: transparent;
  display: grid;
  place-items: center;
  transition: background .12s, color .12s;
}
.chip-x:hover { background: rgba(0,0,0,0.06); color: var(--danger-700); }
.chips-empty {
  color: var(--ink-400);
  font-size: 12.5px;
  font-style: italic;
}

/* ---------- Step 2: Trend selector ---------- */
.trend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  padding: 14px 18px 18px;
}
.trend-chip {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px 14px 14px;
  background: var(--surface-panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  transition: all .15s;
  position: relative;
  overflow: hidden;
}
.trend-chip:hover {
  border-color: var(--ink-300);
  background: var(--surface-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.trend-chip.active {
  background: var(--blue-50);
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-100);
}
.trend-chip.active::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 3px;
  background: var(--blue-600);
}
.trend-icon {
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
}
.trend-text { flex: 1; min-width: 0; }
.trend-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-900);
  letter-spacing: -0.005em;
  margin-bottom: 4px;
}
.trend-desc {
  font-size: 11.5px;
  color: var(--ink-500);
  line-height: 1.45;
}
.trend-chip.active .trend-name { color: var(--blue-800); }
.trend-check {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--surface-sunken);
  color: transparent;
  border: 1px solid var(--line-strong);
  transition: all .12s;
}
.trend-chip.active .trend-check {
  background: var(--blue-600);
  color: #fff;
  border-color: var(--blue-600);
}

/* ---------- Step 3: Recommendations ---------- */
.future-summary {
  display: flex;
  gap: 14px;
}
.future-summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 10px;
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  font-size: 11px;
}
.future-summary-item span {
  color: var(--ink-500);
  font-size: 10.5px;
  letter-spacing: 0.02em;
}
.future-summary-item b {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--ink-900);
  font-weight: 600;
}

.future-recs {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.empty-state {
  padding: 40px 18px;
  text-align: center;
  color: var(--ink-400);
  font-size: 13px;
}

.rec-card {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.rec-card:last-child { border-bottom: none; }

.rec-notfound {
  background: var(--warn-100);
  opacity: 0.85;
}
.rec-notfound-msg {
  font-size: 12px;
  color: var(--warn-700);
}

.rec-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.rec-left { flex: 1; min-width: 0; }
.rec-symbol-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.rec-symbol {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--ink-900);
  letter-spacing: -0.01em;
}
.rec-name {
  font-size: 13px;
  color: var(--ink-600);
}
.rec-tag {
  display: inline-flex;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  font-family: var(--font-display);
}
.rec-tag-user {
  background: var(--gold-50);
  color: var(--gold-700);
  border: 1px solid var(--gold-100);
}
.rec-tag-sector {
  background: var(--surface-sunken);
  color: var(--ink-600);
  border: 1px solid var(--line);
}
.rec-trends {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.rec-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 500;
  background: var(--surface-sunken);
  color: var(--ink-500);
  border: 1px solid var(--line);
}
.rec-trend-match {
  background: var(--blue-100);
  color: var(--blue-700);
  border-color: rgba(47, 111, 229, 0.18);
  font-weight: 600;
}

/* ---------- Score block ---------- */
.rec-scores {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.rec-score-big {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--surface-sunken);
  text-align: center;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.rec-score-big.s-high { background: var(--success-100); border-color: rgba(21,162,93,0.2); }
.rec-score-big.s-med  { background: var(--blue-100); border-color: rgba(47,111,229,0.18); }
.rec-score-big.s-neut { background: var(--surface-sunken); }
.rec-score-big.s-low  { background: var(--danger-100); border-color: rgba(214,47,31,0.16); }
.rec-score-num {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1;
}
.rec-score-big.s-high .rec-score-num { color: var(--success-700); }
.rec-score-big.s-med .rec-score-num  { color: var(--blue-700); }
.rec-score-big.s-neut .rec-score-num { color: var(--ink-700); }
.rec-score-big.s-low .rec-score-num  { color: var(--danger-700); }
.rec-score-label {
  font-size: 9.5px;
  color: inherit;
  opacity: 0.75;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
  font-weight: 600;
}
.rec-score-mini {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  min-width: 80px;
}
.rec-score-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.rec-score-row span { color: var(--ink-500); }
.rec-score-row b {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--ink-900);
}

/* ---------- Metrics row ---------- */
.rec-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.rec-metrics > div {
  background: var(--surface-panel);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rec-metrics > div span {
  font-size: 10.5px;
  color: var(--ink-500);
  letter-spacing: 0.02em;
}
.rec-metrics > div b {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-900);
}

/* ---------- Reasoning ---------- */
.rec-reasoning {
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-700);
}
.rec-reasoning strong { color: var(--ink-900); font-weight: 600; }
.rec-reason { }
.rec-risk { color: var(--ink-600); }
.rec-risk strong { color: var(--danger-700); }

/* ---------- Action buttons ---------- */
.rec-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-sm {
  padding: 5px 10px;
  font-size: 11.5px;
}

/* ---------- Disclaimer ---------- */
.future-disclaimer {
  background: var(--warn-100);
  border: 1px solid rgba(197, 113, 10, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 12px;
  color: var(--warn-700);
  line-height: 1.55;
}
.future-disclaimer strong { color: var(--warn-700); font-weight: 600; }

/* ---------- Future page mobile ---------- */
@media (max-width: 768px) {
  .future-input-row { flex-direction: column; }
  .future-input-row input { min-width: auto; width: 100%; }
  .trend-grid { grid-template-columns: 1fr; }
  .rec-header { flex-direction: column; }
  .rec-scores { width: 100%; justify-content: space-between; }
  .rec-metrics { grid-template-columns: repeat(2, 1fr); }
  .rec-actions { flex-direction: column; }
  .rec-actions .btn { width: 100%; justify-content: center; }
}
