/* style.css — WeatherEdge Design Tokens + Component Styles */

/* ====== TYPE SCALE ====== */
:root {
  --text-xs:   clamp(0.6875rem, 0.65rem + 0.2vw, 0.75rem);
  --text-sm:   clamp(0.75rem,   0.7rem  + 0.25vw, 0.875rem);
  --text-base: clamp(0.875rem,  0.8rem  + 0.35vw, 1rem);
  --text-lg:   clamp(1rem,      0.9rem  + 0.5vw,  1.25rem);
  --text-xl:   clamp(1.25rem,   1rem    + 1vw,    1.75rem);
  --text-2xl:  clamp(1.5rem,    1rem    + 1.5vw,  2.25rem);

  /* Spacing — 4px grid */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Fonts */
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;

  /* Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ====== DARK MODE (Primary) ====== */
:root, [data-theme="dark"] {
  --color-bg:               #0d0f11;
  --color-surface:          #141719;
  --color-surface-2:        #1a1d21;
  --color-surface-offset:   #1e2126;
  --color-surface-offset-2: #24282d;
  --color-surface-dynamic:  #2c3138;
  --color-divider:          #2a2e34;
  --color-border:           #353a42;

  --color-text:             #e1e3e6;
  --color-text-muted:       #8b9099;
  --color-text-faint:       #555b65;
  --color-text-inverse:     #0d0f11;

  --color-primary:          #5fa8d3;
  --color-primary-hover:    #4a91bc;
  --color-primary-active:   #377aa5;
  --color-primary-highlight: #1e2d38;

  --color-success:          #2ecc71;
  --color-success-hover:    #27ae60;
  --color-success-active:   #1e8449;
  --color-success-highlight: #162e1f;
  --color-success-dim:      rgba(46, 204, 113, 0.12);

  --color-error:            #e74c3c;
  --color-error-hover:      #c0392b;
  --color-error-active:     #96281b;
  --color-error-highlight:  #331a1a;
  --color-error-dim:        rgba(231, 76, 60, 0.12);

  --color-warning:          #f0a500;
  --color-warning-hover:    #d49200;
  --color-warning-active:   #b37d00;
  --color-warning-highlight: #2e2710;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
}

/* ====== LIGHT MODE ====== */
[data-theme="light"] {
  --color-bg:               #f2f3f6;
  --color-surface:          #ffffff;
  --color-surface-2:        #f8f9fb;
  --color-surface-offset:   #ebedf1;
  --color-surface-offset-2: #e1e4e9;
  --color-surface-dynamic:  #d5d9e0;
  --color-divider:          #cdd1d8;
  --color-border:           #bfc4ce;

  --color-text:             #1a1d23;
  --color-text-muted:       #5f6673;
  --color-text-faint:       #a0a5ae;
  --color-text-inverse:     #f2f3f6;

  --color-primary:          #2b7daa;
  --color-primary-hover:    #1f6692;
  --color-primary-active:   #185478;
  --color-primary-highlight: #daeaf4;

  --color-success:          #1a9a52;
  --color-success-hover:    #14804a;
  --color-success-active:   #0f6a3c;
  --color-success-highlight: #dcf0e4;
  --color-success-dim:      rgba(26, 154, 82, 0.10);

  --color-error:            #d63031;
  --color-error-hover:      #b52728;
  --color-error-active:     #911f20;
  --color-error-highlight:  #fce4e4;
  --color-error-dim:        rgba(214, 48, 49, 0.10);

  --color-warning:          #c98400;
  --color-warning-hover:    #a86f00;
  --color-warning-active:   #8a5c00;
  --color-warning-highlight: #fef3d9;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.10);
}

/* ====== DASHBOARD LAYOUT ====== */
html, body {
  height: 100%;
  overflow: hidden;
  margin: 0;
  max-width: 100vw;
}

.dashboard {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
}

.header {
  flex-shrink: 0;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  z-index: 20;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--color-text);
  white-space: nowrap;
}
.logo svg {
  display: inline-block;
  flex-shrink: 0;
}

.paper-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--color-warning-highlight);
  color: var(--color-warning);
  white-space: nowrap;
}

.stat-group {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.stat-label {
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-faint);
  line-height: 1;
}
.stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.4;
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-interactive);
  flex-shrink: 0;
}
.theme-toggle:hover {
  color: var(--color-text);
  background: var(--color-surface-dynamic);
}

/* Main content area */
.main {
  flex: 1 1 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: var(--space-5);
  min-height: 0;
  min-width: 0;
}

/* ====== TOP TOOLBAR (tabs + refresh) ====== */
.top-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.top-toolbar-tabs {
  flex: 1;
  min-width: 0;
}
.top-toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ====== CITY TABS ====== */
.city-tabs {
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  flex-wrap: nowrap;
  padding-bottom: var(--space-1);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--color-surface-dynamic) transparent;
}
.city-tabs::-webkit-scrollbar {
  height: 4px;
}
.city-tabs::-webkit-scrollbar-track {
  background: transparent;
}
.city-tabs::-webkit-scrollbar-thumb {
  background: var(--color-surface-dynamic);
  border-radius: var(--radius-full);
}
.city-tab {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-interactive);
  white-space: nowrap;
  flex-shrink: 0;
}
.city-tab:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}
.city-tab.active {
  color: var(--color-text);
  background: var(--color-surface);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}
.city-tab:active {
  transform: scale(0.97);
}

/* Best Bets tab highlight */
.city-tab-best {
  font-weight: 600;
  background: var(--color-success-dim);
  border-color: rgba(46, 204, 113, 0.2);
  color: var(--color-success);
}
.city-tab-best:hover {
  background: rgba(46, 204, 113, 0.18);
  color: var(--color-success);
}
.city-tab-best.active {
  background: var(--color-success-dim);
  border-color: var(--color-success);
  color: var(--color-success);
  box-shadow: 0 0 8px rgba(46, 204, 113, 0.2);
}

/* Best Bets scrollable area — show ~6 rows, scroll for the rest */
#best-bets-body {
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#best-bets-body .bracket-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-surface-offset);
}

/* P&L History scrollable — show ~10 rows, scroll for the rest */
#pnl-table-wrapper {
  max-height: 440px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#pnl-table-wrapper .log-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-surface-offset);
}

/* Tab divider between Best Bets and cities */
.tab-divider {
  display: inline-block;
  width: 1px;
  height: 24px;
  background: var(--color-border);
  margin: 0 var(--space-1);
  flex-shrink: 0;
  align-self: center;
}

/* ====== PANELS ====== */
.panels {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
  min-width: 0;
}
.panels > * {
  min-width: 0;
}

@media (max-width: 900px) {
  .panels {
    grid-template-columns: 1fr;
  }
}

/* ====== CARDS ====== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}
.card-body {
  padding: var(--space-4);
}

/* ====== FORECAST CARD ====== */
.forecast-temp {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
  margin-bottom: var(--space-2);
}
.forecast-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}
.forecast-meta {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.forecast-meta span {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* ====== INFO PANEL ====== */
.info-card {
  margin-top: var(--space-4);
}

/* Collapsible details/summary */
details.info-card > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
details.info-card > summary::-webkit-details-marker {
  display: none;
}
details.info-card > summary::marker {
  display: none;
  content: '';
}
.collapsible-header .chevron-icon {
  transition: transform var(--transition-interactive);
  color: var(--color-text-muted);
  flex-shrink: 0;
}
details[open] .collapsible-header .chevron-icon {
  transform: rotate(180deg);
}
.info-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.info-list li {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding-left: var(--space-4);
  position: relative;
  max-width: none;
}
.info-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
}

/* ====== BRACKET TABLE ====== */
.bracket-table {
  width: 100%;
  font-size: var(--text-sm);
}
.bracket-table th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-offset);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
.bracket-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  vertical-align: middle;
  white-space: nowrap;
}
.bracket-table tbody tr {
  transition: background var(--transition-interactive);
}
.bracket-table tbody tr:hover {
  background: var(--color-surface-offset);
}
.bracket-table .mono-cell {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 500;
}

/* Probability bar */
.prob-cell {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.prob-bar {
  width: 48px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--color-surface-dynamic);
  overflow: hidden;
  flex-shrink: 0;
}
.prob-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  transition: width var(--transition-slow);
}

/* Edge highlight */
.edge-positive {
  color: var(--color-success);
  font-weight: 600;
}
.edge-negative {
  color: var(--color-error);
}
.edge-neutral {
  color: var(--color-text-muted);
}

/* Signal badges */
.signal-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.signal-buy {
  background: var(--color-success-dim);
  color: var(--color-success);
}
.signal-avoid {
  background: var(--color-error-dim);
  color: var(--color-error);
}
.signal-neutral {
  background: var(--color-surface-dynamic);
  color: var(--color-text-faint);
}

/* Trade button in table */
.btn-trade {
  padding: 2px var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--color-success);
  color: var(--color-text-inverse);
  border: none;
  cursor: pointer;
  transition: all var(--transition-interactive);
  white-space: nowrap;
}
.btn-trade:hover {
  background: var(--color-success-hover);
}
.btn-trade:active {
  transform: scale(0.95);
}
.btn-trade:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ====== TRADE MODAL ====== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform var(--transition-slow);
}
.modal-overlay.active .modal {
  transform: scale(1);
}
.modal-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-size: var(--text-lg);
  font-weight: 600;
}
.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-interactive);
}
.modal-close:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
}
.modal-body {
  padding: var(--space-5);
}
.modal-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-divider);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* Modal data rows */
.modal-data {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
}
.modal-data-item {
  display: flex;
  flex-direction: column;
}
.modal-data-label {
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-faint);
  margin-bottom: 2px;
}
.modal-data-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: var(--text-sm);
  font-weight: 600;
}

/* Modal input */
.modal-input-group {
  margin-bottom: var(--space-4);
}
.modal-input-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
  display: block;
}
.modal-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text);
  outline: none;
  transition: border-color var(--transition-interactive);
}
.modal-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-highlight);
}
.modal-hint {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: var(--space-1);
}

/* Modal summary */
.modal-summary {
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.modal-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
}
.modal-summary-label { color: var(--color-text-muted); }
.modal-summary-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 500;
}

/* ====== BUTTONS ====== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-interactive);
  border: none;
  font-family: var(--font-body);
  white-space: nowrap;
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--color-success);
  color: var(--color-text-inverse);
}
.btn-primary:hover { background: var(--color-success-hover); }
.btn-secondary {
  background: var(--color-surface-dynamic);
  color: var(--color-text);
}
.btn-secondary:hover { background: var(--color-border); }
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover { color: var(--color-text); background: var(--color-surface-offset); }
.btn-danger {
  background: var(--color-error);
  color: #fff;
}
.btn-danger:hover { background: var(--color-error-hover); }

/* ====== TRADE LOG ====== */
.log-section {
  margin-top: var(--space-5);
  min-width: 0;
}
.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Log tabs */
.log-tabs {
  display: flex;
  gap: var(--space-1);
}
.log-tab {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-interactive);
  white-space: nowrap;
  font-family: var(--font-body);
}
.log-tab:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}
.log-tab.active {
  color: var(--color-text);
  background: var(--color-surface);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

/* Tab panels */
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}
.log-title {
  font-size: var(--text-lg);
  font-weight: 600;
}
.log-actions {
  display: flex;
  gap: var(--space-2);
}

.log-table {
  width: 100%;
  font-size: var(--text-sm);
}
.log-table th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-offset);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
.log-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap;
}
.log-table tbody tr {
  transition: background var(--transition-interactive);
}
.log-table tbody tr:hover {
  background: var(--color-surface-offset);
}

/* Trade status badges */
.status-open { color: var(--color-warning); }
.status-won { color: var(--color-success); }
.status-lost { color: var(--color-error); }

/* Log totals */
.log-totals {
  display: flex;
  gap: var(--space-6);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-offset);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.log-total-item {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.log-total-label {
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-faint);
}
.log-total-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: var(--text-sm);
  font-weight: 600;
}

/* ====== SKELETON LOADERS ====== */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-offset) 25%,
    var(--color-surface-dynamic) 50%,
    var(--color-surface-offset) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton-line {
  height: 1em;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-sm);
}
.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }
.skeleton-block {
  height: 3em;
  margin-bottom: var(--space-3);
  border-radius: var(--radius-sm);
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-10) var(--space-6);
  color: var(--color-text-muted);
}
.empty-state svg {
  margin-bottom: var(--space-4);
  color: var(--color-text-faint);
}
.empty-state h3 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}
.empty-state p {
  font-size: var(--text-sm);
  max-width: 36ch;
}

/* ====== UTILITY ====== */
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.text-muted { color: var(--color-text-muted); }
.text-faint { color: var(--color-text-faint); }
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
}
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
  .header {
    padding: var(--space-2) var(--space-3);
    gap: var(--space-2);
  }
  .stat-group {
    gap: var(--space-3);
  }
  .main {
    padding: var(--space-3);
  }
  .panels {
    grid-template-columns: 1fr;
  }
  .city-tabs {
    padding-bottom: var(--space-2);
  }
  .bracket-table,
  .log-table {
    font-size: var(--text-xs);
  }
  .bracket-table td,
  .bracket-table th,
  .log-table td,
  .log-table th {
    padding: var(--space-1) var(--space-2);
  }
}

@media (max-width: 480px) {
  .stat:nth-child(n+3) {
    display: none;
  }
  .logo {
    font-size: var(--text-base);
  }
}

/* ====== LOADING / FETCH INDICATOR ====== */
.loading-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}
.loading-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Table wrapper for horizontal scroll on mobile */
.table-wrapper {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border-radius: var(--radius-lg);
}

/* ====== LIVE DATA STATUS ====== */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.125rem 0.5rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-full);
}

.data-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
}
.data-status.live {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.05);
}
.data-status.simulated {
  border-color: rgba(251, 191, 36, 0.3);
  background: rgba(251, 191, 36, 0.05);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.status-live {
  background: #34d399;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
  animation: pulse-dot 2s ease-in-out infinite;
}
.status-dot.status-sim {
  background: #fbbf24;
}
.status-dot.status-loading {
  background: var(--color-primary);
  animation: pulse-dot 1s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
.status-detail {
  color: var(--color-text-faint);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  margin-left: var(--space-1);
}

/* Modal live/sim badge */
.modal-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.4rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-radius: var(--radius-sm);
  vertical-align: middle;
  margin-left: var(--space-2);
}
.modal-badge.live {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}
.modal-badge.sim {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

/* Trade log live tag */
.trade-live-tag {
  display: inline-block;
  padding: 0 0.3rem;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  border-radius: var(--radius-sm);
  vertical-align: middle;
  margin-left: 0.25rem;
}

/* Trade type tag (auto/manual) */
.trade-type-tag {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.trade-type-tag.type-auto {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.12);
}
.trade-type-tag.type-manual {
  color: var(--color-text-muted);
  background: rgba(148, 163, 184, 0.1);
}

/* Auto-refresh button */
.btn-auto-refresh {
  gap: var(--space-1);
  transition: var(--transition-interactive);
}
.btn-auto-refresh.active {
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.08);
}
.btn-auto-refresh:not(.active) {
  opacity: 0.5;
}
#refresh-countdown {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  min-width: 7ch;
}

/* Toolbar divider */
.toolbar-divider {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: var(--color-border);
  margin: 0 var(--space-1);
  flex-shrink: 0;
}

/* Auto-trade controls */
.threshold-input {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.threshold-label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  white-space: nowrap;
}
.threshold-field {
  width: 44px;
  padding: 2px 4px;
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text);
  text-align: center;
  outline: none;
  transition: border-color var(--transition-interactive);
}
.threshold-field:focus {
  border-color: var(--color-primary);
}
.exit-field-wide {
  width: 52px;
}

/* Auto-exit bar */
.auto-exit-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1) var(--space-3);
  background: rgba(96, 165, 250, 0.06);
  border: 1px solid rgba(96, 165, 250, 0.15);
  border-radius: var(--radius-md);
  margin-top: calc(-1 * var(--space-2));
  margin-bottom: var(--space-2);
}
.auto-exit-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: #60a5fa;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.auto-trade-indicator {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.4rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: rgba(46, 204, 113, 0.15);
  color: var(--color-success);
  border: 1px solid rgba(46, 204, 113, 0.3);
  border-radius: var(--radius-full);
  animation: pulse-dot 2s ease-in-out infinite;
}

.auto-trade-flash {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-success);
  opacity: 0;
  transition: opacity 0.3s ease;
  white-space: nowrap;
}

/* Per-trade resolve button */
.btn-resolve-single {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-interactive);
  white-space: nowrap;
}
.btn-resolve-single:hover {
  color: var(--color-warning, #fbbf24);
  border-color: var(--color-warning, #fbbf24);
  background: rgba(251, 191, 36, 0.08);
}

/* Toggle switch */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
}
.toggle-switch input {
  display: none;
}
.toggle-slider {
  position: relative;
  width: 32px;
  height: 18px;
  background: var(--color-surface-dynamic);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  transition: all var(--transition-interactive);
  flex-shrink: 0;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: var(--color-text-muted);
  border-radius: 50%;
  transition: all var(--transition-interactive);
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--color-primary-highlight);
  border-color: var(--color-primary);
}
.toggle-switch input:checked + .toggle-slider::after {
  left: 16px;
  background: var(--color-primary);
}
.toggle-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
}
