/* ============================================================
   WEATHEREDGE TERMINAL — style.css
   Part 1: Variables, Reset, Base, Typography, Layout
   ============================================================ */

/* --- CSS Custom Properties (Color Scheme) --- */
:root {
  /* Backgrounds */
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --border: #30363d;

  /* Text */
  --text-primary: #c9d1d9;
  --text-secondary: #8b949e;

  /* Status Colors */
  --green: #3fb950;
  --red: #f85149;
  --amber: #d29922;
  --cyan: #39d2c0;
  --blue: #58a6ff;
  --purple: #bc8cff;

  /* Direction Badges */
  --sell: #f85149;
  --buy: #3fb950;

  /* Charts */
  --chart-primary: #58a6ff;
  --chart-secondary: #8b949e;
  --chart-green: #3fb950;
  --chart-red: #f85149;

  /* Accent */
  --accent: #bc8cff;
  --live-pulse: #39d2c0;
}

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

/* --- Base --- */
body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* --- Typography --- */
.mono {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

.text-secondary { color: var(--text-secondary); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }
.text-cyan { color: var(--cyan); }

h2.zone-header {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* --- Header --- */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
  flex-wrap: wrap;
}

.header-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}

.status-led {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}
.status-led.stale { background: var(--amber); }
.status-led.error { background: var(--red); }

#last-scan-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 400;
}

.quick-stats {
  display: flex;
  gap: 20px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

.quick-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 14px;
  font-weight: 600;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Main Layout --- */
.app-main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.zone {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

/* --- Zone 1: P&L Command Strip --- */
.zone-1 {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 12px;
  height: 220px;
  min-height: 220px;
  max-height: 220px;
  overflow: hidden;
}
.pnl-chart-container {
  position: relative;
  height: 220px;
  overflow: hidden;
  min-height: 0;
}
.pnl-chart-container canvas {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
}
.metric-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  height: 100%;
  overflow: hidden;
}

/* --- Zone 2+3 --- */
.zone-2-3-container {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 12px;
  min-height: 0;
}
.zone-2 {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 500px;
  min-height: 0;
}
.zone-3 {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 500px;
  min-height: 0;
}
#positions-table-container {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}
.exposure-charts-row {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.exposure-chart-container {
  position: relative;
  height: 140px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.exposure-chart-container canvas {
  flex: 1;
  min-height: 0;
  width: 100% !important;
}
#city-cards-container {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}
#price-ticker {
  flex: 0 0 auto;
  max-height: 160px;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-top: 8px;
  font-size: 12px;
}
#arb-scanner {
  flex: 0 0 auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-top: 8px;
  font-size: 12px;
}

/* --- Zone 4: Analytics --- */
.zone-4 {
  display: flex;
  flex-direction: column;
  height: 550px;
  overflow: hidden;
}
.tab-bar {
  flex: 0 0 auto;
  display: flex;
  gap: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tab-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 12px 4px;
  min-height: 0;
}
.tab-panel.active {
  display: flex;
  flex-direction: column;
}

/* --- Zone 5: Detail Drawer --- */
#zone-5-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
}
#zone-5-overlay.visible { display: block; }
.trade-detail-panel {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 70vh;
  background: var(--surface);
  border-top: 2px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 20px;
  z-index: 201;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 300ms ease;
}
.trade-detail-panel.visible { transform: translateY(0); }
.detail-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

/* ============================================================
   Part 2: Components
   ============================================================ */

/* --- Buttons --- */
button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-family: inherit;
  transition: background 150ms ease;
}
button:hover { background: var(--border); }

/* --- Kill Switch --- */
.kill-switch {
  background: rgba(248, 81, 73, 0.15);
  border-color: var(--red);
  color: var(--red);
  font-weight: 600;
}
.kill-switch:hover { background: rgba(248, 81, 73, 0.25); }
.kill-switch.active {
  background: var(--red);
  color: white;
}

/* --- Direction Badges --- */
.badge-sell, .badge-buy {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}
.badge-sell {
  background: rgba(248, 81, 73, 0.15);
  border: 1px solid var(--sell);
  color: var(--sell);
}
.badge-buy {
  background: rgba(63, 185, 80, 0.15);
  border: 1px solid var(--buy);
  color: var(--buy);
}

/* --- Traffic Lights --- */
.traffic-light { transition: color 500ms ease, background-color 500ms ease; }
.traffic-light.green  { color: var(--green); }
.traffic-light.yellow { color: var(--amber); }
.traffic-light.red    { color: var(--red); }

/* --- Metric Cards --- */
.metric-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}
.card-sub {
  font-size: 11px;
  color: var(--text-secondary);
}
.trend-arrow { font-size: 12px; }
.sparkline { height: 32px; width: 100%; margin-top: 4px; }

/* --- Positions Table --- */
.positions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.positions-table thead th {
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 10px;
  text-align: left;
  position: sticky;
  top: 0;
  white-space: nowrap;
}
.positions-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.positions-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

/* --- Exposure Charts Row --- */
.exposure-charts-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}
.exposure-chart-container {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  height: 160px;
  position: relative;
}
.exposure-chart-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

/* --- City Cards (Zone 3) --- */
.city-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}
.city-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.city-name {
  font-weight: 600;
  font-size: 14px;
}
.city-time {
  font-size: 12px;
  color: var(--text-secondary);
}
.city-temp-chart {
  width: 100%;
  height: 100px;
  min-height: 100px;
  max-height: 100px;
  margin-bottom: 10px;
  position: relative;
  display: block;
}
.city-temp-chart canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}
.city-stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.city-forecast, .city-peak {
  font-size: 11px;
  color: var(--text-secondary);
}

/* --- Price Ticker --- */
#price-ticker {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  max-height: 200px;
  overflow-y: auto;
}
.ticker-item {
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.ticker-item:last-child { border-bottom: none; }

/* --- Arbitrage Scanner --- */
#arb-scanner {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.arb-detected {
  border-color: var(--cyan);
  background: rgba(57, 210, 192, 0.05);
}

/* --- Tab Bar --- */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
  gap: 0;
}
.tab {
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  border-radius: 0;
  font-size: 13px;
  white-space: nowrap;
  transition: color 150ms ease, border-color 150ms ease;
}
.tab:hover {
  color: var(--text-primary);
  background: transparent;
}
.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--chart-primary);
}

/* --- Trade Detail Drawer --- */
#zone-5-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 499;
}
#zone-5-overlay.visible { display: block; }

.trade-detail-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 70vh;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  z-index: 500;
  overflow-y: auto;
  padding: 20px;
  transform: translateY(100%);
  transition: transform 300ms ease-out;
}
.trade-detail-panel.open { transform: translateY(0); }

.detail-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

/* --- Order Book --- */
.order-book {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}
.order-book-asks { color: var(--red); }
.order-book-bids { color: var(--green); }
.order-book-spread {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-secondary);
  font-size: 11px;
  padding: 4px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* --- Alert Toasts --- */
#alert-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.alert-toast {
  background: var(--surface);
  border-radius: 8px;
  padding: 12px 16px;
  max-width: 320px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: all;
  border-left: 4px solid var(--text-secondary);
  font-size: 13px;
}
.alert-toast.critical { border-left-color: var(--red); }
.alert-toast.high     { border-left-color: var(--amber); }
.alert-toast.medium   { border-left-color: var(--green); }
.alert-toast.info     { border-left-color: var(--text-secondary); }

/* --- Alert Panel --- */
.alert-panel {
  position: fixed;
  top: 56px;
  right: 16px;
  width: 360px;
  max-height: 500px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 300;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.alert-panel.hidden { display: none; }
.alert-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
#alert-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
}
.alert-list-item {
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 12px;
  border-left: 3px solid var(--border);
}
.alert-list-item.unread { background: var(--surface-2); }

/* --- Settings Panel --- */
.settings-panel {
  position: fixed;
  top: 56px;
  right: 16px;
  width: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 300;
  padding: 16px;
}
.settings-panel.hidden { display: none; }
.settings-panel h3 { margin-bottom: 16px; font-size: 14px; }
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
}
.setting-row label { color: var(--text-secondary); }
.setting-row input {
  width: 100px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  padding: 4px 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* --- Analytics Tables --- */
.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.analytics-table th {
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  user-select: none;
}
.analytics-table th:hover { color: var(--text-primary); }
.analytics-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.analytics-table tfoot td {
  background: var(--surface-2);
  font-weight: 600;
  border-top: 1px solid var(--border);
}

/* --- City Score Cards (Tab 2) --- */
.city-score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.city-score-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}
.city-score-card .wr-bar-container {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin: 8px 0;
  overflow: hidden;
}
.city-score-card .wr-bar {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 500ms ease;
}

/* --- WR Badge --- */
.wr-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

/* --- Table Filters --- */
.table-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  align-items: center;
}
.table-filter {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 5px 10px;
  font-size: 12px;
  font-family: inherit;
}

/* --- Export Buttons --- */
.export-btn {
  background: var(--surface-2);
  border-color: var(--border);
  font-size: 11px;
  padding: 4px 10px;
}

/* --- Trip Wire Table --- */
.tripwire-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}
.tripwire-table th, .tripwire-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.tripwire-table th { color: var(--text-secondary); font-size: 10px; text-transform: uppercase; }

/* --- Chart Containers --- */
.chart-container {
  position: relative;
  height: 200px;
  margin-bottom: 16px;
}
.chart-container.tall { height: 300px; }
.chart-container.small { height: 150px; }

/* ============================================================
   Part 3: States, Animations, Responsive
   ============================================================ */

/* --- Skeleton Loading States --- */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.skeleton {
  background: #21262d;
  border-radius: 4px;
  animation: pulse 1.5s ease-in-out infinite;
}

.skeleton-row {
  height: 36px;
  margin-bottom: 8px;
  width: 100%;
}

.skeleton-card {
  height: 80px;
  width: 100%;
}

.skeleton-chart {
  height: 200px;
  width: 100%;
}

/* --- Error Banner --- */
.error-banner {
  background: rgba(248, 81, 73, 0.15);
  border: 1px solid #f85149;
  border-radius: 6px;
  color: #f85149;
  padding: 8px 12px;
  font-size: 12px;
  margin-bottom: 8px;
}

/* --- Empty States --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  color: #8b949e;
  text-align: center;
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 600; color: #c9d1d9; margin-bottom: 4px; }
.empty-sub { font-size: 13px; }

/* --- Stale Data Indicator --- */
.stale { color: #d29922; }

.stale-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  background: rgba(210, 153, 34, 0.15);
  border: 1px solid #d29922;
  border-radius: 3px;
  padding: 1px 4px;
  vertical-align: middle;
  margin-left: 4px;
}

.zone-header.stale::before {
  content: '●';
  color: #d29922;
  margin-right: 6px;
  font-size: 8px;
}

/* --- Live Value Update Pulse --- */
@keyframes valuePulse {
  0%   { background-color: rgba(57, 210, 192, 0.3); }
  100% { background-color: transparent; }
}

.value-updated {
  animation: valuePulse 200ms ease-out;
  border-radius: 3px;
}

/* --- Tab Panel Transitions --- */
.tab-panel {
  opacity: 0;
  transition: opacity 150ms ease;
  pointer-events: none;
  display: none;
}

.tab-panel.active {
  opacity: 1;
  pointer-events: auto;
  display: block;
}

/* --- Alert Toast Animation --- */
@keyframes slideInRight {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}

.alert-toast {
  animation: slideInRight 250ms ease-out;
  transition: opacity 300ms ease;
}

.alert-toast.dismissing { opacity: 0; }

/* --- Chart Load Animation (defined here for reference; applied in app.js) ---
   const CHART_ANIMATION = { duration: 1000, easing: 'easeInQuad' };
   Apply to all Chart.js instances as: options.animation = CHART_ANIMATION
   ------------------------------------------------------------------ */

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   MISSING CLASSES — Added by Agent 9
   ============================================================ */

/* 1. P&L positive/negative (trade tables) */
.pnl-positive { color: var(--green); }
.pnl-negative { color: var(--red); }

/* 2. Stats strip (header quick stats) */
.stats-strip { display: flex; gap: 20px; flex: 1; justify-content: center; flex-wrap: wrap; }
.stat-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-label { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 13px; font-weight: 600; }
.header-left, .header-center, .header-right { display: flex; align-items: center; }
.header-center { flex: 1; justify-content: center; }
.header-right { gap: 8px; }
.header-btn { background: var(--surface-2); border-color: var(--border); }

/* 3. Zone 3 specific classes (price ticker, arb scanner) */
.price-ticker { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.price-ticker h4 { font-size: 11px; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 8px; }
.ticker-list { max-height: 180px; overflow-y: auto; }
.ticker-item { font-size: 11px; font-family: 'JetBrains Mono', monospace; padding: 4px 0; border-bottom: 1px solid var(--border); display: flex; gap: 6px; flex-wrap: wrap; }
.ticker-item:last-child { border-bottom: none; }
.arbitrage-scanner { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.arbitrage-scanner h4 { font-size: 11px; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 8px; }
.arbitrage-alert { background: rgba(57,210,192,0.05); border: 1px solid var(--cyan); border-radius: 6px; padding: 10px; margin-bottom: 8px; font-size: 12px; }
.arb-buckets { font-family: 'JetBrains Mono', monospace; font-size: 11px; margin-top: 4px; }

/* 4. AI Justification + Trade Detail classes */
.ai-justification { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 14px; font-size: 12px; line-height: 1.7; }
.detail-header { padding: 16px; border-bottom: 1px solid var(--border); }
.detail-stats { margin-top: 6px; font-size: 12px; color: var(--text-secondary); }
.detail-countdown { margin-top: 4px; font-size: 12px; color: var(--text-secondary); }
#detail-close-btn { float: right; background: transparent; border: none; font-size: 16px; cursor: pointer; color: var(--text-secondary); }
#detail-close-btn:hover { color: var(--text-primary); }

/* 5. Alert system classes */
.alert { display: flex; align-items: flex-start; gap: 8px; background: var(--surface); border-radius: 8px; padding: 10px 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.4); font-size: 12px; border-left: 4px solid var(--text-secondary); max-width: 340px; }
.alert.alert-critical { border-left-color: var(--red); }
.alert.alert-high { border-left-color: var(--amber); }
.alert.alert-medium { border-left-color: var(--green); }
.alert.alert-info { border-left-color: var(--text-secondary); }
.alert-icon { font-size: 14px; flex-shrink: 0; }
.alert-msg { flex: 1; }
.alert-time { font-size: 10px; color: var(--text-secondary); font-family: 'JetBrains Mono', monospace; flex-shrink: 0; }
.alert-dismiss { background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 14px; padding: 0; line-height: 1; }
.alert-panel-list { padding: 8px; }
.alert-panel-item { padding: 8px; border-radius: 6px; margin-bottom: 4px; font-size: 12px; border-left: 3px solid var(--border); }
.alert-panel-item.unread { background: var(--surface-2); border-left-color: var(--chart-primary); }

/* 6. Heating status classes */
.status-predawn { color: #8b949e; }
.status-heating { color: #f0883e; }
.status-peak { color: #f85149; }
.status-cooling { color: #58a6ff; }
.status-night { color: #8b949e; }

/* 7. Card generic class */
.card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 14px; }

/* 8. City cards grid */
.city-cards-grid { display: flex; flex-direction: column; gap: 12px; }

/* 9. Skeleton pulse */
.skeleton-pulse { background: #21262d; border-radius: 4px; height: 16px; width: 80%; animation: pulse 1.5s ease-in-out infinite; }

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */

/* --- Tablet: 768px – 1200px --- */
@media (min-width: 768px) and (max-width: 1200px) {
  .zone-2-3-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .zone-3 { order: 2; }
  .zone-2 { order: 1; }

  .metric-cards-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* --- Mobile: < 768px --- */
@media (max-width: 767px) {
  /* Mobile tab-panel display fix */
  .tab-panel { display: none; opacity: 0; }
  .tab-panel.active { display: block; opacity: 1; }
  /* Layout */
  .zone-2-3-container {
    grid-template-columns: 1fr;
  }

  /* Header */
  #app-header {
    flex-direction: column;
    gap: 8px;
    padding: 8px 12px;
  }

  .quick-stats {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }

  .quick-stat {
    min-width: calc(50% - 4px);
  }

  /* Zone 1 */
  .zone-1 {
    flex-direction: column;
  }

  .pnl-chart-container {
    width: 100%;
    flex: none;
  }

  .metric-cards-grid {
    width: 100%;
    flex: none;
    grid-template-columns: repeat(2, 1fr);
  }

  /* Zone 2: Table → Card Layout on Mobile */
  .positions-table thead {
    display: none;
  }

  .positions-table tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--surface-2);
  }

  .positions-table tbody tr td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border: none;
    font-size: 13px;
    white-space: normal;
  }

  .positions-table tbody tr td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    margin-right: 8px;
  }

  /* Zone 3 */
  .city-card { width: 100%; }
  .city-temp-chart { height: 120px; }

  /* Zone 4 Tabs */
  .tab-bar {
    overflow-x: auto;
    white-space: nowrap;
  }
  .tab { padding: 8px 12px; font-size: 12px; }

  /* Zone 5: Full-Screen on Mobile */
  .trade-detail-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    border-radius: 0;
    z-index: 1000;
    overflow-y: auto;
  }

  .detail-panels {
    grid-template-columns: 1fr;
  }

  /* Exposure Charts: Stack on Mobile */
  .exposure-charts-row {
    grid-template-columns: 1fr;
  }
}


/* Polymarket view button in positions table */
a.view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 20px;
  background: rgba(88, 166, 255, 0.12);
  border: 1px solid rgba(88, 166, 255, 0.3);
  border-radius: 4px;
  color: #58a6ff;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
}
a.view-btn:hover {
  background: rgba(88, 166, 255, 0.25);
  border-color: rgba(88, 166, 255, 0.6);
  color: #79b8ff;
}

/* ── STAT STRIP ── */
.stat-strip{display:flex;gap:0;height:100%;align-items:stretch}
.stat-item{flex:1;display:flex;flex-direction:column;justify-content:center;align-items:center;padding:8px 12px;border-right:1px solid var(--border);min-width:0}
.stat-item:last-child{border-right:none}
.stat-val{font-size:17px;font-weight:700;font-family:'JetBrains Mono',monospace;color:var(--text-primary);white-space:nowrap}
.stat-lbl{font-size:9px;font-weight:600;text-transform:uppercase;letter-spacing:.8px;color:var(--text-secondary);margin-top:2px}
.stat-green .stat-val{color:#3fb950}
.stat-red .stat-val{color:#f85149}
/* ── Zone 1 compact ── */
.zone-1{display:flex!important;flex-direction:row!important;padding:0!important;height:72px!important;min-height:72px!important;max-height:72px!important;overflow:hidden}
.pnl-chart-container{width:160px!important;min-width:160px!important;height:72px!important;border-right:1px solid var(--border);padding:6px;position:relative}
.pnl-chart-container canvas{width:100%!important;height:100%!important}
.metric-cards-grid{flex:1!important;display:flex!important;height:72px!important}
/* ── TRADE DAY CARDS ── */
.trade-day-list{display:flex;flex-direction:column;gap:8px;padding:4px 0}
.trade-day-card{background:#161b22;border:1px solid #30363d;border-radius:6px;overflow:hidden}
.trade-day-header{display:flex;justify-content:space-between;align-items:center;padding:8px 12px;background:rgba(255,255,255,.03);border-bottom:1px solid #30363d}
.trade-day-left{display:flex;align-items:center;gap:10px}
.trade-day-date{font-size:12px;font-weight:700;color:#c9d1d9}
.trade-day-count{font-size:10px;color:#8b949e}
.trade-day-stats{display:flex;gap:14px;align-items:center}
.trade-day-stat{font-size:11px;font-family:'JetBrains Mono',monospace;font-weight:600;color:#c9d1d9}
.trade-day-rows{overflow-x:auto}
.trade-day-table{width:100%;border-collapse:collapse;font-size:11px}
.trade-day-table th{font-size:9px;font-weight:600;text-transform:uppercase;letter-spacing:.5px;color:#8b949e;padding:4px 10px;text-align:left;border-bottom:1px solid #30363d;background:rgba(0,0,0,.2)}
.trade-day-table td{padding:5px 10px;border-bottom:1px solid rgba(48,54,61,.5)}
.trade-day-table tbody tr:last-child td{border-bottom:none}
.trade-day-table tbody tr:hover{background:rgba(255,255,255,.03)}
