:root {
  --bg: #0b0e11;
  --panel: #12161b;
  --panel-border: #1f262e;
  --text: #e6e9ec;
  --muted: #7c8793;
  --accent-up: #3ddc84;
  --accent-down: #ff5c5c;
  --accent-amber: #f5a623;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--panel-border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.topbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { color: var(--accent-up); font-size: 18px; }
.brand-name {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 15px;
}

.meta { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.user-pill {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 5px 9px;
  color: var(--text);
}
.meta-label { text-transform: uppercase; letter-spacing: 0.05em; margin-right: 6px; }
.meta-value { color: var(--text); }
.scan-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); }

@media (min-width: 720px) {
  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
  }
  .topbar-row { flex: 0 0 auto; }
  .search-box { order: 2; max-width: 320px; }
  .scan-meta { order: 1; margin-left: 16px; }
  .meta { order: 3; }
}

main { padding: 20px 16px 60px; max-width: 1280px; margin: 0 auto; }

@media (min-width: 720px) {
  main { padding: 28px 32px 60px; }
}

.empty {
  text-align: center;
  padding: 100px 20px;
  color: var(--muted);
}
.empty-glyph { font-size: 40px; color: var(--panel-border); margin-bottom: 14px; }
.empty-sub { font-size: 13px; margin-top: 6px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

@media (min-width: 720px) {
  .grid { gap: 16px; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-left: 3px solid var(--accent-up);
  border-radius: 6px;
  padding: 18px;
}
.card.down { border-left-color: var(--accent-down); }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}
.ticker {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.02em;
}
.gap { font-family: var(--mono); font-size: 14px; font-weight: 600; }
.gap.up { color: var(--accent-up); }
.gap.down { color: var(--accent-down); }

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-top: 1px solid var(--panel-border);
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 14px;
}
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.stat-value { font-family: var(--mono); font-size: 14px; }

.gamma-block { margin-bottom: 10px; }
.gamma-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.gamma-value { font-family: var(--mono); font-size: 14px; font-weight: 600; }
.gamma-value.pos { color: var(--accent-up); }
.gamma-value.neg { color: var(--accent-down); }

.gauge {
  position: relative;
  height: 6px;
  background: #1a2128;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.gauge-fill { height: 100%; border-radius: 3px; }
.gauge-fill.pos { background: var(--accent-up); }
.gauge-fill.neg { background: var(--accent-down); }
.gauge-mid {
  position: absolute;
  left: 0; top: -3px;
  width: 1px; height: 12px;
  background: var(--panel-border);
}

.gamma-foot { display: flex; justify-content: space-between; font-size: 11px; }
.gamma-foot .stat-value { font-size: 12px; }

.flag {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent-amber);
  background: rgba(245, 166, 35, 0.1);
  border: 1px solid rgba(245, 166, 35, 0.3);
  border-radius: 4px;
  padding: 6px 8px;
}

.history { margin-top: 48px; }
.history h3 {
  font-family: var(--mono);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 14px;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-border);
}
td { padding: 10px; border-bottom: 1px solid var(--panel-border); font-family: var(--mono); }
.tickers { color: var(--muted); }

footer {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 11px;
  font-family: var(--mono);
}

.logout-link {
  color: var(--muted);
  font-family: var(--mono);
  text-decoration: none;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
}
.logout-link:hover { color: var(--text); border-color: var(--muted); }

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 32px 24px;
  width: 100%;
  max-width: 340px;
}
.login-brand { justify-content: center; margin-bottom: 28px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; }
.login-form input {
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 12px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 16px;       /* 16px prevents iOS Safari auto-zoom on focus */
  min-height: 44px;
}
.login-form input:focus {
  outline: none;
  border-color: var(--accent-up);
}
.login-form button {
  margin-top: 6px;
  background: var(--accent-up);
  color: #06140d;
  border: none;
  border-radius: 4px;
  padding: 13px;
  min-height: 44px;
  font-weight: 600;
  font-size: 15px;
  font-family: var(--sans);
  cursor: pointer;
}
.login-form button:hover { filter: brightness(1.08); }
.login-error {
  background: rgba(255, 92, 92, 0.1);
  border: 1px solid rgba(255, 92, 92, 0.3);
  color: var(--accent-down);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 4px;
}

/* search box */
.search-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: none;
  margin: 0;
}
.search-actions {
  display: flex;
  gap: 8px;
}
.search-actions button { flex: 1; }

@media (min-width: 720px) {
  .search-box { flex-direction: row; align-items: center; }
  .search-actions { flex: 0 0 auto; }
}
.search-box input {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 16px;       /* prevents iOS auto-zoom */
  min-height: 44px;
}
.search-box input:focus { outline: none; border-color: var(--accent-up); }
.search-box button {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 4px;
  padding: 8px 16px;
  font-family: var(--sans);
  font-size: 13px;
  min-height: 44px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.search-box button:hover { border-color: var(--accent-up); color: var(--accent-up); }

.brand-link { display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; }

/* GEX heatmap */
.heatmap-head { margin-bottom: 18px; }
.heatmap-head h2 {
  font-family: var(--mono);
  font-size: clamp(18px, 5vw, 22px);
  margin: 0 0 4px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}
.spot-price { color: var(--accent-up); font-size: 15px; }
.heatmap-sub { font-size: 12px; color: var(--muted); }

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.legend-gradient {
  width: 160px;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(to right, rgb(68,1,84), rgb(59,82,139), rgb(33,144,141), rgb(93,201,99), rgb(253,231,37));
}

@media (min-width: 720px) {
  .legend-gradient { width: 200px; }
}

.caveat-banner {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-left: 3px solid var(--accent-amber);
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 20px;
}

table.flow-table td.up { color: var(--accent-up); font-weight: 600; }
table.flow-table td.down { color: var(--accent-down); font-weight: 600; }

.empty-sub code {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
}

/* net premium page */
.premium-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.premium-stat {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.premium-value {
  font-family: var(--mono);
  font-size: clamp(16px, 4vw, 20px);
  font-weight: 700;
}
.premium-value.up { color: var(--accent-up); }
.premium-value.down { color: var(--accent-down); }

.lean-bar {
  width: 80px;
  height: 8px;
  background: #1a2128;
  border-radius: 4px;
  overflow: hidden;
}
.lean-fill { height: 100%; }
.lean-fill.up { background: var(--accent-up); }
.lean-fill.down { background: var(--accent-down); }

/* sector rotation */
.rotation-badge {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.rotation-badge.inflow {
  color: var(--accent-up);
  background: rgba(61, 220, 132, 0.12);
  border: 1px solid rgba(61, 220, 132, 0.3);
}
.rotation-badge.outflow {
  color: var(--accent-down);
  background: rgba(255, 92, 92, 0.12);
  border: 1px solid rgba(255, 92, 92, 0.3);
}
.rotation-badge.neutral {
  color: var(--muted);
  background: rgba(124, 135, 147, 0.1);
  border: 1px solid var(--panel-border);
}

.heatmap-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  max-height: 70vh;
  overflow-y: auto;
}

.scroll-hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin: 8px 0 14px;
}

@media (min-width: 720px) {
  .scroll-hint { display: none; }
}

table.heatmap {
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 11px;
  width: 100%;
}

@media (min-width: 720px) {
  table.heatmap { font-size: 12px; }
}
table.heatmap th {
  background: var(--panel);
  color: var(--muted);
  padding: 10px 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  white-space: nowrap;
  z-index: 3;
}
table.heatmap .strike-col {
  position: sticky;
  left: 0;
  background: var(--panel);
  z-index: 4;
  font-weight: 600;
  text-align: right;
  padding-right: 14px;
}
td.gex-cell {
  padding: 9px 12px;
  text-align: center;
  font-weight: 600;
  white-space: nowrap;
}

@media (min-width: 720px) {
  table.heatmap th { padding: 10px 14px; font-size: 11px; }
  table.heatmap .strike-col { padding-right: 16px; }
  td.gex-cell { padding: 8px 14px; }
}
tr.spot-row .strike-col { color: var(--accent-up); }
.spot-marker { color: var(--accent-up); margin-left: 4px; font-size: 10px; }
