/* ============================================================
   StockPile – Design System
   Dark mode, technical, minimal
   ============================================================ */

:root {
  /* Color palette */
  --bg-base:       #080c10;
  --bg-primary:    #0d1117;
  --bg-surface:    #131920;
  --bg-elevated:   #1a2030;
  --bg-input:      #0d1520;

  --border:        #1e2836;
  --border-muted:  #263040;
  --border-focus:  #2d5a8e;

  --text-primary:  #d8e4f0;
  --text-secondary:#7a9ab8;
  --text-muted:    #3d5470;

  --accent:        #4d9de0;
  --accent-hover:  #5eb0f5;
  --accent-muted:  #1a3d60;

  --green:         #3ecf6a;
  --green-muted:   #1a4a2e;
  --red:           #e05252;
  --red-muted:     #4a1a1a;
  --yellow:        #d4a843;
  --yellow-muted:  #3d2f10;
  --purple:        #a78bfa;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;

  /* Spacing */
  --radius-sm:  3px;
  --radius:     6px;
  --radius-lg:  10px;

  /* Transitions */
  --transition: 140ms ease;
}

/* ============================================================
   Reset & base
   ============================================================ */

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

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
}
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

/* ============================================================
   Layout shell
   ============================================================ */

.shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.brand-icon {
  color: var(--accent);
  font-size: 1.1rem;
  line-height: 1;
}

.brand-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-primary);
}

.nav-links {
  list-style: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 0.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}

.nav-link:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--accent-muted);
  color: var(--accent);
}

.nav-icon {
  font-size: 0.9rem;
  width: 1rem;
  text-align: center;
  color: inherit;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.version-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Main content */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content-area {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1400px;
}

/* ============================================================
   Page header
   ============================================================ */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.page-header h1 {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.page-subtitle {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-secondary);
}

.timestamp {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  padding-top: 0.35rem;
}

.breadcrumb {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.breadcrumb a {
  color: var(--text-muted);
}

.breadcrumb a:hover {
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

/* ============================================================
   Sections
   ============================================================ */

.section {
  margin-top: 2rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.section-title {
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.card-title {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  flex: 1;
}

.chart-card {
  padding: 1rem 1rem 0.5rem;
}

.form-card {
  max-width: 640px;
  margin-bottom: 1.5rem;
}

/* ============================================================
   Stat cards (dashboard)
   ============================================================ */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  transition: border-color var(--transition);
}

.stat-card.clickable {
  cursor: pointer;
}

.stat-card.clickable:hover {
  border-color: var(--border-muted);
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.stat-card-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-card-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.stat-card-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.stat-card-day {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ============================================================
   Metrics row
   ============================================================ */

.metrics-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  min-width: 120px;
}

.metric-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.2;
}

.metric-sub {
  margin-top: 0.3rem;
}

.signal-value {
  font-size: 0.85rem;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--text-primary);
}

/* ============================================================
   Charts
   ============================================================ */

.chart-container {
  position: relative;
  width: 100%;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.chart-label {
  font-family: var(--font-mono);
  font-size: 9px;
  fill: var(--text-muted);
}

.chart-x-labels {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
}

.volume-sub {
  margin-top: 0.25rem;
  opacity: 0.7;
}

/* Chart legend */
.chart-legend {
  display: flex;
  gap: 1rem;
}

.legend-item {
  font-size: 0.72rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-item::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 2px;
  background: var(--c, var(--accent));
  border-radius: 1px;
}

/* Chart toggles */
.chart-toggles {
  display: flex;
  gap: 1rem;
  margin-left: auto;
}

/* Range tabs */
.range-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 1rem;
}

.range-tab {
  padding: 0.3rem 0.7rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-mono);
}

.range-tab:hover {
  border-color: var(--border-muted);
  color: var(--text-primary);
}

.range-tab.active {
  background: var(--accent-muted);
  border-color: var(--border-focus);
  color: var(--accent);
}

/* ============================================================
   Tables
   ============================================================ */

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table thead {
  background: var(--bg-elevated);
}

.data-table th {
  padding: 0.6rem 1rem;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

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

.row-highlight {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.clickable-row {
  cursor: pointer;
  transition: background var(--transition);
}

.text-right { text-align: right; }
.data-table th.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); font-size: 0.82rem; }

.symbol-tag {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-elevated);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.4rem;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-decoration: none;
  display: inline-block;
}
.symbol-tag:hover {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.link-arrow {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  font-family: var(--font-sans);
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-base);
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-muted);
}

.btn-danger {
  color: var(--red);
  border-color: transparent;
}

.btn-danger:hover:not(:disabled) {
  background: var(--red-muted);
  border-color: var(--red-muted);
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
}

.btn-buy {
  background: var(--green-muted);
  color: var(--green);
  border-color: var(--green-muted);
  font-weight: 700;
  letter-spacing: 0.06em;
  font-family: var(--font-mono);
  min-width: 80px;
}

.btn-buy:hover:not(:disabled) {
  background: #1e5a38;
  border-color: var(--green);
}

.btn-sell {
  background: var(--red-muted);
  color: var(--red);
  border-color: var(--red-muted);
  font-weight: 700;
  letter-spacing: 0.06em;
  font-family: var(--font-mono);
  min-width: 80px;
}

.btn-sell:hover:not(:disabled) {
  background: #5a2020;
  border-color: var(--red);
}

/* ============================================================
   Forms
   ============================================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.input {
  background: var(--bg-input);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  padding: 0.45rem 0.75rem;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: var(--font-sans);
  transition: border-color var(--transition);
  outline: none;
  width: 100%;
}

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

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

select.input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%233d5470' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-row > .form-group {
  flex: 1;
  min-width: 160px;
}

.form-row-compact {
  align-items: flex-end;
  margin-bottom: 1.25rem;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.toggle-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* Search box */
.toolbar {
  margin-bottom: 1.25rem;
}

.search-box {
  display: flex;
  gap: 0.5rem;
  max-width: 480px;
}

.search-box .input {
  flex: 1;
}

/* Cash display */
.cash-display {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.cash-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* ============================================================
   Tab bar
   ============================================================ */

.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: -1px;
  font-family: var(--font-sans);
}

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

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ============================================================
   Badges
   ============================================================ */

.badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.badge-sim {
  background: var(--yellow-muted);
  color: var(--yellow);
  border: 1px solid var(--yellow-muted);
}

.badge-fx {
  background: rgba(99, 179, 237, 0.15);
  color: #63b3ed;
  border: 1px solid rgba(99, 179, 237, 0.3);
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  white-space: nowrap;
}

.text-xs {
  font-size: 0.7rem;
}

.money-ccy {
  font-size: 0.72em;
  opacity: 0.6;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.badge-warn {
  background: var(--red-muted);
  color: var(--red);
}

.badge-ok {
  background: var(--green-muted);
  color: var(--green);
}

/* ============================================================
   Alerts
   ============================================================ */

.alert {
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}

.alert-error {
  background: var(--red-muted);
  border-color: #5a2020;
  color: var(--red);
}

.alert-ok {
  background: var(--green-muted);
  border-color: #1e5a38;
  color: var(--green);
}

/* ============================================================
   State helpers
   ============================================================ */

.positive { color: var(--green); }
.negative { color: var(--red); }

.loading-state {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ============================================================
   Spinners
   ============================================================ */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-sm {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   Danger zone
   ============================================================ */

.danger-zone {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* ============================================================
   Not found
   ============================================================ */

.not-found {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 50vh;
  color: var(--text-muted);
}

.not-found h1 {
  font-size: 4rem;
  font-family: var(--font-mono);
  color: var(--border-muted);
}

/* ============================================================
   Trend Quality card (StockDetail)
   ============================================================ */

.tq-card {
  padding: 1rem 1.25rem 1.25rem;
}

.tq-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 0.5rem;
}

.tq-block {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.tq-period {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tq-score {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.tq-meta {
  display: flex;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  cursor: default;
}

.tq-bar-track {
  margin-top: 0.5rem;
  height: 3px;
  background: var(--border-muted);
  border-radius: 2px;
  overflow: hidden;
}

.tq-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
  opacity: 0.8;
}

/* ============================================================
   Scanner
   ============================================================ */

.scanner-import-card {
  max-width: 100%;
}

.import-log {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.import-progress-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.progress-bar-track {
  flex: 1;
  height: 4px;
  background: var(--border-muted);
  border-radius: 2px;
  overflow: hidden;
}

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

.progress-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.log-lines {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.log-line {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.25rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
}

.log-line:last-child { border-bottom: none; }
.log-line.log-error .log-msg { color: var(--red); }

.log-sym {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
}

.log-msg {
  color: var(--text-secondary);
}

.log-time {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Filter chips */
.filter-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.chip {
  padding: 0.2rem 0.6rem;
  background: transparent;
  border: 1px solid var(--border-muted);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  font-family: var(--font-sans);
}

.chip:hover { border-color: var(--accent); color: var(--text-primary); }
.chip-active { background: var(--accent-muted); border-color: var(--border-focus); color: var(--accent); }

/* Scan table */
.scan-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
}

.scan-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.scan-table th.sortable:hover { color: var(--text-primary); }

.flag-cell {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.flag {
  font-size: 0.85rem;
  font-weight: 700;
  cursor: default;
}

.flag-gold  { color: var(--yellow); }
.flag-red   { color: var(--red); }
.flag-green { color: var(--green); }
.flag-warn  { color: var(--yellow); }

.badge-bull {
  background: var(--green-muted);
  color: var(--green);
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.badge-bear {
  background: var(--red-muted);
  color: var(--red);
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* ============================================================
   Scrollbar
   ============================================================ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   Selection
   ============================================================ */

::selection { background: var(--accent-muted); color: var(--text-primary); }

/* ============================================================
   Dashboard — Portfolio cards
   ============================================================ */

.dash-port-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.dash-port-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
}

.dash-port-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.dash-port-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.2rem;
}

.dash-port-name {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.dash-port-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 0.15rem;
}

.dash-port-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin: 0.15rem 0 0.3rem;
}

.dash-port-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.dash-port-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.82rem;
  gap: 0.5rem;
}

.dash-port-divider {
  height: 1px;
  background: var(--border);
  margin: 0.2rem 0;
}

.dash-port-footer {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ============================================================
   Dashboard — Market section
   ============================================================ */

.dash-market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: start;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.dash-market-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.4rem;
  min-width: 130px;
  text-align: center;
}

.dash-market-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.dash-market-rate {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.dash-market-change {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  margin-top: 0.25rem;
}

.dash-market-scanning {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  justify-content: center;
  padding: 1rem 1.5rem;
}

.dash-signal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.4rem;
}

.dash-signal-rows {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.dash-signal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  gap: 1.5rem;
}

/* ============================================================
   Dashboard — Movers
   ============================================================ */

.dash-movers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 640px) {
  .dash-movers-grid { grid-template-columns: 1fr; }
}

.dash-movers-header {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* ============================================================
   Pagination
   ============================================================ */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.75rem 0 0.25rem;
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
}

.pagination-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 160px;
  text-align: center;
}

/* ============================================================
   Mobile navigation
   ============================================================ */

.mobile-header {
  display: none;
}

.mobile-overlay {
  display: none;
}

@media (max-width: 700px) {
  /* Top bar */
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    padding: 0 1rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    z-index: 90;
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .mobile-brand .brand-icon {
    color: var(--accent);
    font-size: 1.1rem;
  }

  .mobile-brand .brand-name {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.06em;
  }

  .hamburger {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius);
    line-height: 1;
    transition: background var(--transition);
  }

  .hamburger:hover {
    background: var(--bg-elevated);
  }

  /* Overlay backdrop */
  .mobile-overlay {
    display: block;
    position: fixed;
    inset: 0;
    top: 52px;
    background: rgba(0, 0, 0, 0.6);
    z-index: 95;
  }

  /* Sidebar as off-screen drawer */
  .sidebar {
    display: none;
    position: fixed;
    top: 52px;
    left: 0;
    height: calc(100vh - 52px);
    width: 230px;
    z-index: 100;
  }

  .sidebar--open {
    display: flex;
    animation: sidebar-slide-in 220ms ease;
  }

  @keyframes sidebar-slide-in {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
  }

  /* Shell & content */
  .shell {
    flex-direction: column;
  }

  .main-content {
    padding-top: 52px;
  }

  .content-area {
    padding: 1.25rem 1rem;
    max-width: 100%;
  }

  /* Page header stacks on narrow screens */
  .page-header {
    flex-direction: column;
    gap: 0.75rem;
  }

  .header-actions {
    flex-wrap: wrap;
  }

  /* Tables scroll horizontally */
  .data-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ============================================================
   Gantt Chart
   ============================================================ */

.gantt-svg {
  display: block;
  width: 100%;
}

.gantt-row-alt {
  fill: var(--bg-elevated);
  opacity: 0.45;
}

.gantt-label {
  font-family: var(--font-mono);
  font-size: 9px;
  fill: var(--text-muted);
}

.gantt-symbol {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  fill: var(--accent);
  cursor: pointer;
}

.gantt-symbol:hover {
  text-decoration: underline;
}

.gantt-price {
  font-family: var(--font-mono);
  font-size: 8px;
  fill: var(--text-secondary);
}

.gantt-price-open {
  fill: var(--accent);
}

.gantt-bar-open {
  fill: var(--accent);
  opacity: 0.85;
}

.gantt-bar-profit {
  fill: #4ade80;
  opacity: 0.8;
}

.gantt-bar-loss {
  fill: #f87171;
  opacity: 0.8;
}

.gantt-today {
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  opacity: 0.5;
}
