/* ================================================================
   FinceptTerminal Design System - "Obsidian" Theme
   Extracted from: https://github.com/Fincept-Corporation/FinceptTerminal
   Source: fincept-qt/src/ui/theme/ThemeManager.cpp (THEME_OBSIDIAN)
   ================================================================

   A professional dark-mode financial terminal design system.
   Built for dense data display, long-screen-time readability,
   and institutional-grade trading UI aesthetics.

   Design principles:
   1. Near-black backgrounds with subtle layering for depth
   2. Monospace typography for data alignment
   3. Amber accent for interactive highlights (not blue/purple)
   4. Green/red semantic colors for financial data
   5. Thin, low-contrast borders - never compete with data
   6. Information density over whitespace
   ================================================================ */

/* ── CSS Variables (Design Tokens) ── */
:root {
  /* Backgrounds (darkest -> lightest) */
  --bg-base:      #080808;  /* deepest background */
  --bg-surface:   #0a0a0a;  /* card / panel surface */
  --bg-raised:    #111111;  /* elevated surfaces (headers, toolbars) */
  --bg-hover:     #161616;  /* hover state background */

  /* Borders */
  --border-dim:    #1a1a1a;  /* hairline, barely visible */
  --border-med:    #222222;  /* standard separator */
  --border-bright: #333333;  /* active / focused border */

  /* Text hierarchy */
  --text-primary:   #e5e5e5;  /* body / data text */
  --text-secondary: #808080;  /* labels, captions */
  --text-tertiary:  #525252;  /* disabled, placeholder */
  --text-dim:       #404040;  /* near-invisible muted text */

  /* Accent (theme-defining color) */
  --accent:         #d97706;  /* primary highlight - amber */
  --accent-dim:     #78350f;  /* dimmed accent for backgrounds */
  --text-on-accent: #ffffff;  /* text color when accent is background */

  /* Interactive chrome */
  --icon-dim:    #808080;  /* muted icon/button color */
  --icon-hover:  #e5e5e5;  /* icon color on hover */

  /* Functional / semantic colors */
  --positive:     #16a34a;  /* gain / success / buy */
  --positive-dim: #14532d;  /* dimmed positive */
  --negative:     #dc2626;  /* loss / error / sell */
  --negative-dim: #7f1d1d;  /* dimmed negative */
  --warning:      #ca8a04;  /* caution */
  --info:         #2563eb;  /* informational */
  --cyan:         #0891b2;  /* secondary highlight / links */

  /* Tinted backgrounds (subtle fills) */
  --accent-bg:   #1a1000;  /* translucent accent background */
  --positive-bg: #0a1a0f;  /* translucent positive background */
  --negative-bg: #1a0a0a;  /* translucent negative background */

  /* Table */
  --row-alt: #121212;  /* alternating row background */
  --row-base: #0a0a0a; /* base row background */

  /* Typography */
  --font-family: 'SF Mono', 'Cascadia Mono', 'Cascadia Code', 'Consolas',
                 'DejaVu Sans Mono', 'Liberation Mono', 'Source Code Pro',
                 'Courier New', monospace;
  --font-size-base: 14px;

  /* Chart palette (6 series colors) */
  --chart-1: #d97706;
  --chart-2: #0891b2;
  --chart-3: #16a34a;
  --chart-4: #dc2626;
  --chart-5: #2563eb;
  --chart-6: #ca8a04;

  /* Density padding */
  --pad: 4px;
  --pad2: 8px;
}

/* Compact density */
[data-density="compact"] {
  --pad: 2px;
  --pad2: 4px;
}

/* Comfortable density */
[data-density="comfortable"] {
  --pad: 8px;
  --pad2: 16px;
}

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

html {
  font-size: var(--font-size-base);
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Scrollbars ── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
  background: transparent;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-med);
  min-height: 20px;
  min-width: 20px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-bright);
}

/* ── Text Selection ── */
::selection {
  background: var(--accent);
  color: var(--bg-base);
}

/* ── Typography Hierarchy ── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  color: var(--text-primary);
}

/* Section title - used for panel headers */
.section-title {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  background: transparent;
  border: none;
  padding: 0;
}

/* Section header - used for sub-section labels */
.section-header {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-dim);
  padding-bottom: 4px;
}

/* Data label - left-aligned metric name */
.data-label {
  color: var(--text-secondary);
  font-size: 13px;
  background: transparent;
}

/* Data value - right-aligned metric value */
.data-value {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  background: transparent;
}

/* Status label - small status text */
.status-label {
  color: var(--text-secondary);
  font-size: 11px;
  background: transparent;
}

/* Dim label - near-invisible muted text */
.dim-label {
  color: var(--text-dim);
  font-size: 11px;
  background: transparent;
}

/* ── Semantic text colors ── */
.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }
.text-warning  { color: var(--warning); }
.text-info     { color: var(--info); }
.text-cyan     { color: var(--cyan); }
.text-accent   { color: var(--accent); }

/* ── Layout: Terminal Shell ── */
.terminal-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-base);
}

/* ── Top Navigation Bar ── */
.top-nav {
  display: flex;
  align-items: center;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border-dim);
  height: 40px;
  padding: 0 12px;
  gap: 4px;
  flex-shrink: 0;
}

.top-nav-brand {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  padding-right: 16px;
  border-right: 1px solid var(--border-dim);
  margin-right: 8px;
}

.top-nav-brand .accent {
  color: var(--accent);
}

/* ── Tab Bar (Main Navigation) ── */
.tab-bar {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-dim);
  height: 36px;
  padding: 0 8px;
  gap: 0;
  flex-shrink: 0;
}

.tab {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0 18px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-family: var(--font-family);
  cursor: pointer;
  height: 36px;
  display: flex;
  align-items: center;
  transition: background 0.15s, color 0.15s;
}

.tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab.active {
  background: transparent;
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

/* ── Stat Boxes (Top metric row) ── */
.stat-row {
  display: flex;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border-dim);
  gap: 0;
}

.stat-box {
  flex: 1;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-dim);
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-box:last-child {
  border-right: none;
}

.stat-value {
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 700;
}

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

/* ── Card / Panel ── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: 2px;
  padding: var(--pad2);
}

.card-header {
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border-dim);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.card-body {
  padding: 12px;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-dim);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border-dim);
  padding: 8px 14px;
}

.sidebar-title {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.sidebar-list {
  list-style: none;
  background: transparent;
  border: none;
  outline: none;
}

.sidebar-list-item {
  padding: 0 14px;
  height: 30px;
  color: var(--text-secondary);
  font-size: 12px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sidebar-list-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-list-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  border-left: 2px solid var(--accent);
  padding-left: 12px;
}

/* ── Data Table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 12px;
}

.data-table thead th {
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-align: left;
  padding: 0 8px;
  height: 26px;
  border: none;
  border-bottom: 1px solid var(--border-dim);
  border-right: 1px solid var(--border-dim);
  white-space: nowrap;
}

.data-table thead th:last-child {
  border-right: none;
}

.data-table tbody td {
  padding: 0 8px;
  height: 26px;
  border-bottom: 1px solid var(--border-dim);
  white-space: nowrap;
}

.data-table tbody tr:nth-child(even) {
  background: var(--row-alt);
}

.data-table tbody tr:nth-child(odd) {
  background: var(--row-base);
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.data-table tbody tr.selected {
  background: var(--accent-bg) !important;
  color: var(--text-primary);
}

/* Dense table variant */
.data-table.dense {
  font-size: 11px;
}
.data-table.dense thead th {
  font-size: 9px;
  padding: 2px 6px;
}
.data-table.dense tbody td {
  padding: 0 6px;
  height: 22px;
}

/* ── Buttons ── */
.btn {
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 700;
  padding: var(--pad) var(--pad2);
  border: 1px solid var(--border-dim);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn:active {
  background: var(--bg-raised);
}

.btn:disabled {
  color: var(--text-dim);
  cursor: not-allowed;
}

/* Primary / accent button */
.btn-accent {
  background: var(--accent);
  color: var(--text-on-accent);
  border: none;
  font-weight: 600;
}

.btn-accent:hover {
  background: var(--border-bright);
  color: var(--text-on-accent);
}

/* Muted button */
.btn-muted {
  background: var(--bg-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border-dim);
}

.btn-muted:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Danger button */
.btn-danger {
  background: var(--bg-raised);
  color: var(--negative);
  border: 1px solid var(--border-dim);
}

.btn-danger:hover {
  background: var(--bg-hover);
}

/* Positive (buy) button */
.btn-positive {
  background: var(--positive);
  color: var(--text-on-accent);
  border: none;
  font-weight: 600;
}

.btn-positive:hover {
  filter: brightness(1.15);
}

/* Negative (sell) button */
.btn-negative {
  background: var(--negative);
  color: var(--text-on-accent);
  border: none;
  font-weight: 600;
}

.btn-negative:hover {
  filter: brightness(1.15);
}

/* ── Input Fields ── */
.input {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-dim);
  padding: var(--pad) var(--pad2);
  font-family: var(--font-family);
  font-size: 12px;
  outline: none;
}

.input:focus {
  border-color: var(--border-bright);
}

.input::placeholder {
  color: var(--text-tertiary);
}

.input::selection {
  background: var(--accent);
  color: var(--bg-base);
}

/* ── Search bar ── */
.search-bar {
  background: var(--bg-base);
  color: var(--text-primary);
  border: 1px solid var(--border-dim);
  padding: 2px 10px;
  font-size: 12px;
  font-family: var(--font-family);
  outline: none;
}

.search-bar:focus {
  border-color: var(--border-bright);
}

/* ── Dropdown / Select ── */
.select {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-dim);
  padding: var(--pad) var(--pad2);
  font-family: var(--font-family);
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

.select:focus {
  border-color: var(--border-bright);
}

.select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* ── Checkbox ── */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}

.checkbox input[type="checkbox"] {
  appearance: none;
  width: 12px;
  height: 12px;
  border: 1px solid var(--border-bright);
  background: var(--bg-surface);
  cursor: pointer;
  position: relative;
}

.checkbox input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 4px;
  height: 8px;
  border: solid var(--text-on-accent);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ── Progress Bar ── */
.progress-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  height: 16px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  background: var(--accent);
  height: 100%;
  transition: width 0.3s;
}

/* ── Badges / Pills ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border: 1px solid var(--border-dim);
  background: transparent;
  color: var(--text-secondary);
}

.badge-active {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
}

.badge-positive {
  background: var(--positive-bg);
  color: var(--positive);
  border-color: var(--positive-dim);
}

.badge-negative {
  background: var(--negative-bg);
  color: var(--negative);
  border-color: var(--negative-dim);
}

.badge-warning {
  background: transparent;
  color: var(--warning);
  border-color: var(--warning);
}

/* ── Splitter / Divider ── */
.splitter {
  background: var(--border-dim);
}

.splitter:hover {
  background: var(--border-bright);
}

/* ── Tooltip ── */
.tooltip {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-dim);
  padding: var(--pad) var(--pad2);
  font-size: 11px;
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

/* ── Workspace Layout ── */
.workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.workspace-main {
  flex: 1;
  background: var(--bg-base);
  overflow: auto;
  padding: 8px;
}

.workspace-sidebar {
  width: 240px;
  min-width: 200px;
  flex-shrink: 0;
}

.workspace-right {
  width: 300px;
  min-width: 240px;
  flex-shrink: 0;
  border-left: 1px solid var(--border-dim);
}

/* ── Dock Widget (Panel Tab) ── */
.dock-tab-bar {
  display: flex;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-dim);
  height: 24px;
  align-items: center;
}

.dock-tab {
  background: var(--bg-surface);
  border: none;
  border-right: 1px solid var(--border-dim);
  padding: 2px 8px;
  height: 22px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.dock-tab.active {
  background: var(--bg-raised);
  border-bottom: 2px solid var(--accent);
}

.dock-tab-close {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 12px;
}

.dock-tab-close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* ── Status Bar ── */
.status-bar {
  background: var(--bg-base);
  border-top: 1px solid var(--border-dim);
  padding: 0 12px;
  height: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 11px;
  color: var(--text-secondary);
}

.status-bar .live-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--positive);
}

.status-bar .live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--positive);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Key-Value Grid (Metric Card) ── */
.kv-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
}

.kv-grid .kv-label {
  color: var(--text-secondary);
  font-size: 12px;
}

.kv-grid .kv-value {
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  text-align: right;
}

/* ── Price Display ── */
.price-display {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.price-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.price-change {
  font-size: 13px;
  font-weight: 600;
}

.price-change.up {
  color: var(--positive);
}

.price-change.down {
  color: var(--negative);
}

/* ── Command Bar ── */
.command-bar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-dim);
  padding: var(--pad) var(--pad2);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Clock (Terminal header) ── */
.clock {
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ── Group Box ── */
.group-box {
  border: 1px solid var(--border-dim);
  padding: var(--pad2) var(--pad);
  margin-top: 12px;
}

.group-box-title {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  padding: 0 4px;
  margin-top: -8px;
  margin-left: 8px;
  background: var(--bg-base);
  display: inline-block;
}

/* ── Slider ── */
.slider {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border-dim);
  border-radius: 2px;
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.slider::-webkit-slider-thumb:hover {
  background: var(--text-primary);
}

/* ── Utility Classes ── */
.text-right { text-align: right; }
.text-left  { text-align: left; }
.text-center { text-align: center; }
.text-bold { font-weight: 700; }
.text-mono { font-family: var(--font-family); }
.text-sm { font-size: 11px; }
.text-xs { font-size: 10px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 20px; }

.bg-surface { background: var(--bg-surface); }
.bg-raised { background: var(--bg-raised); }
.bg-hover { background: var(--bg-hover); }

.border-dim { border: 1px solid var(--border-dim); }
.border-med { border: 1px solid var(--border-med); }

.rounded { border-radius: 2px; }
.rounded-md { border-radius: 4px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.flex-1 { flex: 1; }

.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-4 { padding: 16px; }
.px-2 { padding-left: 8px; padding-right: 8px; }
.py-1 { padding-top: 4px; padding-bottom: 4px; }

.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

/* ================================================================
   Responsive Design — Mobile / Tablet Adaptation
   Breakpoints: 768px (tablet), 480px (phone)
   Strategy: sidebars -> drawers, tables -> horizontal scroll,
             tabs -> scrollable, font/padding -> scaled down
   ================================================================ */

/* ── Tablet: ≤768px ── */
@media (max-width: 768px) {
  :root {
    --font-size-base: 13px;
    --pad: 3px;
    --pad2: 6px;
  }

  /* Top nav: shrink brand, hide search on small screens */
  .top-nav {
    height: 36px;
    padding: 0 6px;
    gap: 4px;
    flex-wrap: nowrap;
    overflow: hidden;
  }
  .top-nav-brand {
    font-size: 12px;
    padding-right: 6px;
    margin-right: 2px;
  }
  .top-nav .search-bar {
    display: none;
  }
  .top-nav .btn {
    padding: 0 8px;
    font-size: 10px;
    min-height: 26px;
  }

  /* Tab bar: horizontal scroll, no wrap */
  .tab-bar {
    height: 32px;
    min-height: 32px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
  }
  .tab-bar::-webkit-scrollbar { display: none; }
  .tab {
    padding: 0 12px;
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Left sidebar: becomes off-canvas drawer */
  .workspace-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    min-width: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }
  .workspace-sidebar.open {
    transform: translateX(0);
  }

  /* Right panel: becomes off-canvas drawer from right */
  .workspace-right {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: calc(100vw - 48px);
    max-width: 320px;
    min-width: 0 !important;
    flex-shrink: 0;
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: -4px 0 24px rgba(0,0,0,0.5);
  }
  .workspace-right.open {
    transform: translateX(0);
  }

  /* Backdrop overlay when drawer is open */
  .drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 99;
  }
  .drawer-backdrop.show {
    display: block;
  }

  /* Main content: full width */
  .workspace-main {
    padding: 6px;
    flex: 1;
    overflow: auto;
  }

  /* Workspace: still flex but sidebars are fixed positioned (out of flow) */
  .workspace {
    overflow: visible;
  }

  /* Data table: horizontal scroll */
  .data-table {
    font-size: 11px;
  }
  .data-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Stat boxes: 2 per row */
  .stat-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  /* Cards: stack vertically */
  .card-row {
    flex-direction: column;
    gap: 8px;
  }
  .card-row > .card {
    width: 100%;
  }

  /* Buttons: larger tap targets */
  .btn {
    min-height: 32px;
    padding: 0 14px;
    font-size: 12px;
  }
  .btn-sm {
    min-height: 28px;
    padding: 0 10px;
  }

  /* Status bar: compact */
  .status-bar {
    height: 20px;
    font-size: 10px;
    padding: 0 8px;
    gap: 8px;
  }

  /* Mobile menu toggle button (hidden on desktop) */
  .mobile-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border-med);
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
  }
  .mobile-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
  }
  .mobile-toggle.right {
    margin-left: auto;
  }
}

/* ── Phone: ≤480px ── */
@media (max-width: 480px) {
  :root {
    --font-size-base: 12px;
    --pad: 2px;
    --pad2: 4px;
  }

  /* Top nav: hide timestamp, compact buttons */
  .top-nav-timestamp {
    display: none;
  }
  .top-nav {
    height: 34px;
    min-height: 34px;
    padding: 0 6px;
    gap: 4px;
    flex-shrink: 0;
  }
  .top-nav-brand {
    font-size: 11px;
    padding-right: 6px;
    margin-right: 4px;
  }

  /* Tab bar: even more compact */
  .tab {
    padding: 0 10px;
    font-size: 10px;
  }

  /* Stat boxes: 1 per row on very small screens */
  .stat-row {
    grid-template-columns: 1fr;
  }

  /* Sidebar narrower on phone */
  .workspace-sidebar {
    width: 180px;
  }
  .workspace-right {
    width: calc(100vw - 32px) !important;
    max-width: 280px !important;
  }

  /* Swatch grid: single column on phone */
  .swatch-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Data table: even smaller */
  .data-table {
    font-size: 10px;
  }
  .data-table thead th {
    font-size: 9px;
    padding: 0 4px;
    height: 22px;
  }
  .data-table tbody td {
    padding: 0 4px;
    height: 22px;
  }

  /* Typography: scale down */
  .stat-value {
    font-size: 18px;
  }
  .section-title {
    font-size: 12px;
  }
  .section-header {
    font-size: 10px;
  }

  /* Buttons: full width for primary actions */
  .btn-block {
    width: 100%;
  }

  /* Status bar: show only essential info */
  .status-bar {
    height: 18px;
    font-size: 9px;
  }
  .status-bar .status-detail {
    display: none;
  }
}

/* ── Desktop: mobile toggle hidden ── */
.mobile-toggle {
  display: none;
}
