/* ==========================================================================
   MacroHub Stylesheet — Bloomberg / Terminal-Inspired High-Density UI
   Supports Dark Mode (default) and Clean Light Mode via CSS variables.
   ========================================================================== */

:root {
  --bg-app: #0a0e14;
  --bg-panel: #101620;
  --bg-panel-alt: #141c28;
  --bg-elevated: #192231;
  --bg-hover: #1f2a3c;
  --bg-active: #1b2f4b;
  --border-subtle: #1f2937;
  --border-strong: #2f3e52;

  --text-primary: #e6edf3;
  --text-secondary: #9ba8b8;
  --text-muted: #6e7b8b;

  --accent: #ff9f1c;
  --accent-soft: rgba(255, 159, 28, 0.14);
  --blue: #3b82f6;
  --blue-soft: rgba(59, 130, 246, 0.16);
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.14);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.14);

  --font-sans: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;

  --header-h: 46px;
  --ticker-h: 38px;
  --drawer-w: 296px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.55);
}

[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-panel: #ffffff;
  --bg-panel-alt: #f8fafc;
  --bg-elevated: #eef2f7;
  --bg-hover: #e2e8f0;
  --bg-active: #dbeafe;
  --border-subtle: #dbe2ea;
  --border-strong: #b8c4d4;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --accent: #d97706;
  --accent-soft: rgba(217, 119, 6, 0.12);
  --blue: #2563eb;
  --blue-soft: rgba(37, 99, 235, 0.12);
  --green: #059669;
  --green-soft: rgba(5, 150, 105, 0.12);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.12);

  --shadow-lg: 0 14px 36px rgba(15, 23, 42, 0.16);
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

/* ---------- App Shell ---------- */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ---------- Top Header ---------- */
.top-header {
  height: var(--header-h);
  min-height: var(--header-h);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 12px;
  z-index: 20;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 10px;
  border-right: 1px solid var(--border-subtle);
  user-select: none;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.brand-title {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
}

.tab-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

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

.tab-btn.active {
  background: var(--accent-soft);
  border-color: rgba(255, 159, 28, 0.35);
  color: var(--accent);
}

.hdr-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

.hdr-btn.accent {
  background: var(--accent-soft);
  border-color: rgba(255, 159, 28, 0.4);
  color: var(--accent);
}

.kbd-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

/* ---------- Live Custom Macro Ticker Bar ---------- */
.ticker-bar {
  height: var(--ticker-h);
  min-height: var(--ticker-h);
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 6px;
  overflow: hidden;
}

.ticker-strip {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  /* Smooth edge fade instead of an abrupt clip. */
  -webkit-mask-image: linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent);
  mask-image: linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent);
}

.ticker-marquee-wrap {
  display: flex;
  align-items: center;
  width: max-content;
  min-width: 100%;
  height: 100%;
  animation: ticker-marquee-scroll 60s linear infinite;
  will-change: transform;
}

.ticker-strip:hover .ticker-marquee-wrap {
  animation-play-state: paused;
}

.ticker-marquee-track {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-right: 7px;
  flex-shrink: 0;
}

@keyframes ticker-marquee-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  background: color-mix(in srgb, var(--bg-panel) 88%, transparent);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.ticker-item:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border-subtle));
  background: var(--bg-elevated);
  transform: translateY(-1px);
}

.ticker-label {
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.ticker-price {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.ticker-chg {
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid transparent;
}

.ticker-chg.up {
  color: #34d399;
  background: rgba(16, 185, 129, 0.13);
  border-color: rgba(16, 185, 129, 0.22);
}

.ticker-chg.down {
  color: #f87171;
  background: rgba(239, 68, 68, 0.13);
  border-color: rgba(239, 68, 68, 0.22);
}

.ticker-chg.flat {
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.08);
}

.ticker-daily-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  padding: 0 4px;
  border-radius: 2px;
  background: var(--blue-soft);
  color: var(--blue);
  letter-spacing: 0.03em;
}

.ticker-live-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  padding-left: 8px;
  border-left: 1px solid var(--border-subtle);
}

.ticker-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.35);
  animation: ticker-live-pulse 2.6s ease-in-out infinite;
  flex-shrink: 0;
}

.ticker-live-dot.is-stale {
  background: var(--accent);
  box-shadow: none;
  animation: none;
  opacity: 0.7;
}

@keyframes ticker-live-pulse {
  0%, 100% { opacity: 0.65; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.28); }
  50%      { opacity: 1;    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.10); }
}

.ticker-refresh-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.14s ease, border-color 0.14s ease;
}

.ticker-refresh-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- Workspace Main ---------- */
.workspace-main {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.tab-view {
  display: none;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.tab-view.active {
  display: flex;
  flex-direction: column;
}

/* ---------- Tab 0: Centre Console (Modular Command Deck) ---------- */
.console-toolbar {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  padding: 7px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.console-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.console-title {
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

.console-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
  position: relative;
}

.console-grid.freeform-mode {
  display: block;
  overflow: auto;
  min-height: 100%;
}

.console-grid.freeform-mode .console-card {
  position: absolute;
  margin: 0;
  z-index: 1;
}

.freeform-resize-handle {
  display: none;
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  opacity: 0.8;
  z-index: 10;
}

.console-grid.edit-mode.freeform-mode .freeform-resize-handle {
  display: block;
}

.console-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.console-card.span-1 {
  grid-column: span 1;
}

.console-card.span-2 {
  grid-column: span 2;
}

.console-card.span-3 {
  grid-column: span 3;
}

.console-card.h-compact {
  height: 300px;
}

.console-card.h-standard {
  height: 390px;
}

.console-card.h-tall {
  height: 500px;
}

.console-grid.edit-mode .console-card {
  border-style: dashed;
  border-color: var(--border-strong);
}

.console-card.drag-over {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.console-card-header {
  padding: 6px 10px;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.console-grid.edit-mode .console-card-header {
  cursor: grab;
}

.console-card-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.console-type-badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  text-transform: uppercase;
  flex-shrink: 0;
}

.console-card-title {
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.console-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.card-icon-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--font-mono);
  line-height: 1.3;
}

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

.card-icon-btn.active {
  color: var(--accent);
  border-color: var(--accent);
}

.card-icon-btn.danger:hover {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.5);
  background: var(--red-soft);
}

.console-edit-controls {
  display: none;
  align-items: center;
  gap: 3px;
  padding-right: 4px;
  border-right: 1px solid var(--border-subtle);
}

.console-grid.edit-mode .console-edit-controls {
  display: inline-flex;
}

.console-card-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.console-card-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* Fullscreen Focus Mode on Any Individual Console Card */
.console-card.card-fullscreen {
  position: fixed;
  inset: 10px;
  z-index: 95;
  height: auto !important;
  width: auto !important;
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}

.console-card.card-fullscreen .console-edit-controls {
  display: none !important;
}

.card-exit-focus-btn {
  display: none;
  background: var(--red-soft);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: var(--red);
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
}

.console-card.card-fullscreen .card-exit-focus-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.console-card.card-fullscreen .card-focus-btn {
  display: none;
}

/* Watchlist Table inside Console Card */
.wl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.wl-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 5px 8px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-panel-alt);
  position: sticky;
  top: 0;
}

.wl-table th.num,
.wl-table td.num {
  text-align: right;
  font-family: var(--font-mono);
}

.wl-row {
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.1s ease;
}

.wl-row:hover {
  background: var(--bg-hover);
}

.wl-row td {
  padding: 6px 8px;
}

.wl-sym {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  font-size: 11px;
}

.wl-name {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Quick Launcher Links Grid */
.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 7px;
  padding: 8px;
  overflow-y: auto;
}

.link-tile {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color 0.14s ease, background 0.14s ease;
}

.link-tile:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
}

.link-tile-title {
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.link-tile-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Native Lightweight Charts Shell ---------- */
.native-chart-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: relative;
  background: var(--bg-panel);
}

.native-chart-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 10px;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.native-legend-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.native-src-pill {
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--green-soft);
  color: var(--green);
  text-transform: uppercase;
}

.native-daily-badge {
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--blue-soft);
  color: var(--blue);
  text-transform: uppercase;
}

.native-ohlc-readout {
  color: var(--text-secondary);
  font-size: 11px;
}

.native-chart-canvas {
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
}

.native-chart-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px;
  text-align: center;
  color: var(--text-secondary);
  background: var(--bg-panel);
  z-index: 5;
}

/* ---------- Tab 1: Markets & Charts ---------- */
.markets-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.asset-drawer {
  width: var(--drawer-w);
  min-width: var(--drawer-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: width 0.22s ease, min-width 0.22s ease, opacity 0.18s ease;
  overflow: hidden;
}

.asset-drawer.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  border-right: none;
  opacity: 0;
  pointer-events: none;
}

.drawer-search-wrap {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-panel-alt);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 100%;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 28px 6px 9px;
  font-size: 12px;
  color: var(--text-primary);
  outline: none;
}

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

.search-clear-btn {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  padding: 0 3px;
  display: none;
}

.search-clear-btn.visible {
  display: inline-block;
}

.drawer-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.drawer-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 0 18px;
}

.drawer-section {
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-section-header {
  width: 100%;
  background: transparent;
  border: none;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.drawer-section-header:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.drawer-section-header .count-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
}

.drawer-section-items {
  display: none;
  padding-bottom: 4px;
}

.drawer-section.open .drawer-section-items {
  display: block;
}

.asset-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 10px 5px 12px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.1s ease, border-color 0.1s ease;
}

.asset-row:hover {
  background: var(--bg-hover);
}

.asset-row.active {
  background: var(--bg-active);
  border-left-color: var(--accent);
}

.asset-row-info {
  min-width: 0;
  flex: 1;
}

.asset-ticker-line {
  display: flex;
  align-items: center;
  gap: 5px;
}

.asset-ticker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.asset-src-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 0 4px;
  border-radius: 2px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  text-transform: uppercase;
}

.asset-src-tag.yahoo {
  color: var(--blue);
  background: var(--blue-soft);
}

.asset-src-tag.fred {
  color: var(--green);
  background: var(--green-soft);
}

.asset-row.active .asset-ticker {
  color: var(--text-primary);
}

.asset-name {
  font-size: 11.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.star-btn {
  background: transparent;
  border: none;
  padding: 2px 4px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1;
  border-radius: 3px;
  flex-shrink: 0;
}

.star-btn:hover {
  background: var(--bg-elevated);
  color: var(--accent);
}

.star-btn.pinned {
  color: var(--accent);
}

.drawer-empty {
  padding: 10px 12px;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Chart Area */
.chart-stage {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
}

.chart-toolbar {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  padding: 6px 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.toolbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border-subtle);
}

.tb-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.14s ease;
  white-space: nowrap;
}

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

.tb-btn.active {
  background: var(--blue-soft);
  border-color: rgba(59, 130, 246, 0.45);
  color: var(--blue);
}

.tb-btn.flip-btn {
  background: var(--accent-soft);
  border-color: rgba(255, 159, 28, 0.45);
  color: var(--accent);
  font-family: var(--font-mono);
}

.tb-btn.flip-btn:hover {
  filter: brightness(1.1);
}

.tb-btn.danger:hover {
  background: var(--red-soft);
  border-color: rgba(239, 68, 68, 0.45);
  color: var(--red);
}

.tb-input {
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-primary);
  outline: none;
}

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

.overlay-autocomplete-dropdown {
  font-size: 11px;
}

.overlay-ac-item:hover {
  background: var(--bg-hover);
}

.tb-select {
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 7px;
  font-size: 11.5px;
  color: var(--text-primary);
  outline: none;
}

.tf-group {
  display: inline-flex;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.tf-btn {
  background: transparent;
  border: none;
  border-right: 1px solid var(--border-subtle);
  padding: 4px 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.tf-btn:last-child {
  border-right: none;
}

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

.tf-btn.active {
  background: var(--accent);
  color: #0b0e14;
}

.macro-context-bar {
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border-subtle);
  padding: 5px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11.5px;
}

.macro-context-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.context-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.context-overlay-badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--blue-soft);
  color: var(--blue);
  white-space: nowrap;
  display: none;
}

.context-overlay-badge.visible {
  display: inline-block;
}

.context-why {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.charts-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 6px;
  background: var(--bg-app);
}

.charts-grid.split {
  grid-template-columns: 1fr 1fr;
}

.chart-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.chart-pane.active-target {
  border-color: var(--accent);
}

.chart-pane-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px;
  cursor: pointer;
}

.charts-grid.split .chart-pane-header {
  display: flex;
}

.pane-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-weight: 700;
}

.pane-tag {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-elevated);
  color: var(--text-muted);
}

.chart-pane.active-target .pane-tag {
  background: var(--accent);
  color: #0b0e14;
}

.chart-mount {
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
}

#chart-pane-b {
  display: none;
}

.charts-grid.split #chart-pane-b {
  display: flex;
}

/* ---------- Theatre / Centre-View Mode ---------- */
body.theatre-mode .top-header,
body.theatre-mode .ticker-bar,
body.theatre-mode .asset-drawer,
body.theatre-mode .macro-context-bar {
  display: none !important;
}

body.theatre-mode .charts-grid {
  padding: 2px;
  gap: 2px;
}

body.theatre-mode .chart-toolbar {
  padding: 4px 10px;
}

.theatre-exit-pill {
  display: none;
  background: var(--red-soft);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: var(--red);
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
}

body.theatre-mode .theatre-exit-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ---------- Tab 2: Economic Calendar ---------- */
.calendar-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.calendar-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.subview-toolbar {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  padding: 7px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.subview-title {
  font-weight: 700;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.pill-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

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

.pill-btn.active {
  background: var(--accent-soft);
  border-color: rgba(255, 159, 28, 0.45);
  color: var(--accent);
}

.calendar-widget-wrap {
  flex: 1;
  min-height: 0;
  padding: 8px;
}

.calendar-cheatsheet {
  width: 330px;
  min-width: 330px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.cheatsheet-header {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-subtle);
  font-weight: 700;
  font-size: 12px;
  color: var(--accent);
  background: var(--bg-panel-alt);
}

.cheatsheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cheat-card {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 9px 10px;
}

.cheat-card h4 {
  margin: 0 0 5px;
  font-size: 12px;
  color: var(--text-primary);
}

.cheat-card p {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.cheat-tag {
  display: inline-block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--blue-soft);
  color: var(--blue);
}

/* ---------- Tab 3: News & Macro Wire ---------- */
.wire-layout {
  display: grid;
  grid-template-columns: 330px 1fr 310px;
  gap: 8px;
  padding: 8px;
  flex: 1;
  min-height: 0;
  width: 100%;
  background: var(--bg-app);
}

.wire-col {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.wire-col-header {
  padding: 8px 10px;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.wire-col-title {
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wire-col-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.tv-timeline-wrap {
  flex: 1;
  min-height: 0;
}

/* RSS Reader */
.rss-controls {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--bg-panel);
}

.rss-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.rss-status-bar {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rss-list {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rss-card {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.rss-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.rss-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 10.5px;
}

.rss-source-badge {
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
}

.rss-source-badge.cb {
  background: var(--green-soft);
  color: var(--green);
}

.rss-source-badge.custom {
  background: var(--blue-soft);
  color: var(--blue);
}

.rss-time {
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.rss-title {
  display: block;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-primary);
  text-decoration: none;
  margin-bottom: 3px;
  line-height: 1.35;
}

.rss-title:hover {
  color: var(--accent);
  text-decoration: underline;
}

.rss-summary {
  margin: 0;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.rss-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* Social & Policy Wire Directory */
.policy-list {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.policy-callout {
  background: var(--blue-soft);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.policy-card {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 10px;
}

.policy-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
}

.policy-handle {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11.5px;
  color: var(--accent);
}

.policy-role {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-elevated);
  color: var(--text-muted);
}

.policy-desc {
  margin: 0 0 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

.policy-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.policy-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  text-decoration: none;
  padding: 3px 7px;
  border-radius: 3px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.policy-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 13, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 110;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-panel {
  width: 100%;
  max-width: 680px;
  max-height: 88vh;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 11px 14px;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  margin: 0;
  font-size: 13.5px;
}

.modal-body {
  padding: 12px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr 130px auto;
  gap: 6px;
  align-items: center;
}

.modal-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

.modal-textarea {
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-primary);
  resize: vertical;
  min-height: 76px;
  outline: none;
}

.modal-textarea:focus {
  border-color: var(--accent);
}

.modal-footer {
  padding: 10px 14px;
  background: var(--bg-panel-alt);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.feed-manage-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feed-manage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.feed-manage-info {
  min-width: 0;
  flex: 1;
}

.feed-manage-name {
  font-weight: 700;
  font-size: 12px;
}

.feed-manage-url {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast-banner {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast-banner.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Responsive Breakpoints ---------- */
@media (max-width: 1240px) {
  .console-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .console-card.span-3 {
    grid-column: span 2;
  }
  .wire-layout {
    grid-template-columns: 1fr 1fr;
    overflow-y: auto;
  }
  .wire-col:last-child {
    grid-column: span 2;
    min-height: 280px;
  }
  .calendar-cheatsheet {
    width: 260px;
    min-width: 260px;
  }
}

@media (max-width: 900px) {
  .console-grid {
    grid-template-columns: 1fr;
  }
  .console-card.span-1,
  .console-card.span-2,
  .console-card.span-3 {
    grid-column: span 1;
  }
  .asset-drawer {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    box-shadow: var(--shadow-lg);
  }
  .charts-grid.split {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
  .calendar-cheatsheet {
    display: none;
  }
  .wire-layout {
    grid-template-columns: 1fr;
  }
  .wire-col:last-child {
    grid-column: span 1;
  }
  .form-grid,
  .modal-field-row {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Price Alerts & Notification Hub (alerts.js)
   Reuses existing dark/light theme variables.
   ========================================================================== */

/* Header badge */
.alerts-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin-left: 2px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1;
}
.alerts-badge[hidden] { display: none; }
.alerts-badge.has-unread { background: var(--accent); color: #0b0e14; }

/* Set Alert compact panel */
.set-alert-panel { max-width: 420px; }
.alert-price-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 2px 0;
}

/* Notification Hub */
.alerts-hub-panel { max-width: 560px; }
.alerts-tabs {
  display: flex;
  gap: 2px;
  padding: 0 10px;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}
.alerts-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  padding: 8px 10px;
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.alerts-tab:hover { color: var(--text-primary); }
.alerts-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.alerts-tab-count {
  font-family: var(--font-mono);
  font-size: 9.5px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  min-width: 16px;
  text-align: center;
}
.alerts-hub-body {
  padding: 12px 14px;
  overflow-y: auto;
  max-height: 56vh;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.alerts-empty {
  padding: 22px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}
.alerts-list { display: flex; flex-direction: column; gap: 7px; }
.alerts-toolbar { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 2px; }

.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}
.alert-item.triggered { border-color: rgba(255, 159, 28, 0.35); }
.alert-item-main { min-width: 0; flex: 1; }
.alert-item-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.alert-sym { font-family: var(--font-mono); font-weight: 700; color: var(--accent); font-size: 12px; }
.alert-cond {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
}
.alert-cond-above { background: var(--green-soft); color: var(--green); }
.alert-cond-below { background: var(--red-soft); color: var(--red); }
.alert-item-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.alert-label { color: var(--text-secondary); }
.alert-target { font-family: var(--font-mono); color: var(--text-primary); }
.alert-time { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); margin-top: 3px; }

/* Delivery Settings form */
.delivery-form { display: flex; flex-direction: column; gap: 10px; }
.alert-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.alert-check input { width: 15px; height: 15px; }
.alerts-hint { font-size: 10.5px; color: var(--text-muted); line-height: 1.4; }



/* ---------- Notification & Audio Alert Hub (audio.js + alerts.js) ---------- */
.alerts-hub-panel { max-width: 640px; }
.alerts-tab { font-size: 11px; }
.alert-action-icons { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.alert-cond-audio { background: var(--blue-soft); color: var(--blue); }
.alert-check { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.alert-check input { width: 15px; height: 15px; }
.alert-actions-fieldset { border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.alert-actions-fieldset legend { font-size: 11px; font-weight: 700; color: var(--text-secondary); padding: 0 4px; }
.alert-price-hint { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); padding: 2px 2px 0; }

/* Arm Audio pill */
.audio-arm-pill { background: var(--bg-elevated); }
.audio-arm-pill.active { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.arm-pill { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--bg-elevated); color: var(--text-secondary); font-weight: 700; font-size: 11.5px; }
.arm-pill.armed { background: var(--green-soft); border-color: var(--green); color: var(--green); }

/* Audio controls + soundboard */
.audio-controls { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border-subtle); }
.audio-status-row { display: flex; gap: 8px; align-items: center; }
.audio-vol-row { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-secondary); }
.audio-vol-row input[type="range"] { flex: 1; }
.audio-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); margin-top: 10px; }
.soundboard { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.soundboard-btn { background: var(--bg-panel-alt); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); color: var(--text-secondary); padding: 7px 8px; font-size: 11px; font-weight: 600; text-align: left; }
.soundboard-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.audio-custom-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.audio-custom-name { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); }
.quiet-hours-form { display: flex; flex-direction: column; gap: 8px; }

/* Audio rules */
.rule-item.disabled { opacity: 0.5; }
.rule-actions { display: flex; gap: 5px; flex-shrink: 0; }
.alert-item.compact { padding: 6px 8px; }
.alerts-section-title { font-size: 10.5px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }

.add-rule-details { margin-top: 8px; }
.add-rule-details > summary { list-style: none; display: inline-flex; }
.add-rule-form { display: flex; flex-direction: column; gap: 8px; padding: 10px; margin-top: 8px; background: var(--bg-panel-alt); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); }


/* ---------- Universal Smart Ticker Picker ---------- */
.ticker-picker-wrap { position: relative; display: inline-block; width: 100%; }
.ticker-picker-wrap > input { width: 100%; position: relative; z-index: 1; background: transparent; }
.ticker-ghost { position: absolute; inset: 0; pointer-events: none; padding: 4px 8px; font-family: var(--font-mono); font-size: 11.5px; color: transparent; white-space: pre; overflow: hidden; z-index: 0; border: 1px solid transparent; border-radius: var(--radius-sm); }
.ticker-ghost .ghost-typed { color: transparent; }
.ticker-ghost .ghost-rest { color: var(--text-muted); }
.ticker-picker-panel { position: absolute; top: calc(100% + 4px); left: 0; z-index: 300; min-width: 280px; max-width: 360px; background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 6px; }
.ticker-pills { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 5px; }
.ticker-pill { background: var(--bg-panel); border: 1px solid var(--border-subtle); color: var(--text-muted); border-radius: 999px; padding: 2px 8px; font-size: 10px; font-weight: 600; }
.ticker-pill.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.ticker-list { max-height: 230px; overflow-y: auto; }
.ticker-card { padding: 5px 7px; cursor: pointer; border-radius: var(--radius-sm); border: 1px solid transparent; }
.ticker-card:hover, .ticker-card.active { background: var(--bg-hover); border-color: var(--border-subtle); }
.ticker-card-name { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.ticker-card-meta { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.ticker-card-sym { font-family: var(--font-mono); font-size: 10.5px; color: var(--accent); }
.ticker-card-tag { font-size: 9px; padding: 0 4px; border-radius: 2px; background: var(--blue-soft); color: var(--blue); }
.ticker-card-region { font-size: 9px; padding: 0 4px; border-radius: 2px; background: var(--bg-panel); color: var(--text-muted); }
.ticker-empty { padding: 10px; color: var(--text-muted); font-size: 11px; text-align: center; }

/* ---------- Visual + Add Widget builder ---------- */
.widget-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.widget-card { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 9px 10px; background: var(--bg-panel-alt); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); text-align: left; color: var(--text-secondary); }
.widget-card:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.widget-card.active { border-color: var(--accent); background: var(--accent-soft); color: var(--text-primary); }
.widget-card-icon { font-size: 18px; }
.widget-card-title { font-weight: 700; font-size: 12px; color: var(--text-primary); }
.widget-card-desc { font-size: 10.5px; color: var(--text-muted); line-height: 1.3; }
.chart-preset-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.preset-chip { background: var(--bg-panel-alt); border: 1px solid var(--border-subtle); color: var(--text-secondary); border-radius: 999px; padding: 3px 10px; font-size: 10.5px; font-weight: 600; }
.preset-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.watchlist-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; max-height: 180px; overflow-y: auto; }
.watchlist-toggle { display: flex; align-items: center; gap: 6px; font-size: 11px; padding: 4px 6px; background: var(--bg-panel-alt); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); }
.wl-toggle-name { color: var(--text-primary); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-toggle-sym { font-family: var(--font-mono); font-size: 9.5px; color: var(--text-muted); }

/* ---------- Freeform 8-handle resize + snapping guides ---------- */
.freeform-resize-handle { width: 12px; height: 12px; border-radius: 2px; background: var(--accent); opacity: 0.85; z-index: 12; }
.freeform-resize-handle.frh-n { top: -3px; left: 50%; transform: translateX(-50%); cursor: n-resize; bottom: auto; right: auto; }
.freeform-resize-handle.frh-s { bottom: -3px; left: 50%; transform: translateX(-50%); cursor: s-resize; top: auto; right: auto; }
.freeform-resize-handle.frh-e { right: -3px; top: 50%; transform: translateY(-50%); cursor: e-resize; left: auto; bottom: auto; }
.freeform-resize-handle.frh-w { left: -3px; top: 50%; transform: translateY(-50%); cursor: w-resize; right: auto; bottom: auto; }
.freeform-resize-handle.frh-ne { top: -3px; right: -3px; cursor: ne-resize; bottom: auto; left: auto; }
.freeform-resize-handle.frh-nw { top: -3px; left: -3px; cursor: nw-resize; bottom: auto; right: auto; }
.freeform-resize-handle.frh-se { bottom: -3px; right: -3px; cursor: se-resize; top: auto; left: auto; }
.freeform-resize-handle.frh-sw { bottom: -3px; left: -3px; cursor: sw-resize; top: auto; right: auto; }
.freeform-resize-handle { display: none; }
.console-grid.freeform-mode.edit-mode .freeform-resize-handle { display: block; }
.snap-guide { position: absolute; background: var(--accent); z-index: 9; pointer-events: none; opacity: 0.7; }
.snap-guide-v { top: 0; bottom: 0; width: 1px; }
.snap-guide-h { left: 0; right: 0; height: 1px; }
.console-grid.freeform-mode { overflow: auto; }

/* ---- active chart widget + margin filter + full symbol coverage ---- */
.console-card.active-widget { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.console-card.active-widget .console-card-header { background: var(--accent-soft); }
.ticker-margin-toggle { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--text-muted); padding: 4px 2px; }
.ticker-margin-toggle input { width: 14px; height: 14px; }

/* ---- marquee preset selector + customiser ---- */
.marquee-preset-select {
  height: 24px;
  max-width: 190px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 10.5px;
  padding: 0 6px;
  cursor: pointer;
}
.marquee-preset-select:hover { border-color: var(--border-strong); color: var(--text-primary); }
.marquee-preset-select:focus { outline: none; border-color: var(--accent); }
.marquee-customise-btn { white-space: nowrap; }

.marquee-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}
.marquee-modal-backdrop.open { display: flex; }
.marquee-modal {
  width: min(560px, calc(100vw - 32px));
  max-height: min(78vh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.marquee-modal-head,
.marquee-modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border-subtle);
}
.marquee-modal-foot { border-bottom: none; border-top: 1px solid var(--border-subtle); justify-content: flex-end; }
.marquee-modal-head h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-primary); }
.marquee-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.marquee-modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }
.marquee-modal-body {
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mc-field { display: flex; flex-direction: column; gap: 5px; font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.mc-select {
  height: 30px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 12px;
  padding: 0 8px;
}
.mc-select:focus { outline: none; border-color: var(--accent); }
.mc-section-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.mc-count { color: var(--accent); }
.mc-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 38px;
  padding: 8px;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}
.mc-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-size: 11px;
  color: var(--text-secondary);
}
.mc-pill-sym { color: var(--text-muted); font-family: var(--font-mono); font-size: 9.5px; }
.mc-pill-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
  padding: 2px 3px;
  border-radius: 3px;
}
.mc-pill-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.mc-pill-btn:disabled { opacity: 0.3; cursor: default; }
.mc-pill-remove:hover { color: var(--red); }
.mc-empty { font-size: 11px; color: var(--text-muted); padding: 4px; }
.mc-add-row { display: flex; gap: 8px; align-items: center; }
.mc-add-row .tb-input { flex: 1; min-width: 0; }

/* Picker inside the marquee customiser opens upward so it is never clipped. */
.marquee-modal .ticker-picker-panel { top: auto; bottom: calc(100% + 4px); z-index: 4500; }

.mc-add-row .ticker-picker-wrap { flex: 1; min-width: 0; width: auto; }

/* ---- Centre Console: prevent accidental text selection while dragging/resizing ---- */
.console-toolbar,
.console-grid,
.console-card,
.console-card-header,
.console-card-header *,
.console-card-body,
.console-card-body *,
.freeform-resize-handle {
  -webkit-user-select: none;
  user-select: none;
}

.console-card input,
.console-card textarea,
.console-card select,
.console-card [contenteditable="true"],
.console-card [contenteditable="true"] * {
  -webkit-user-select: text;
  user-select: text;
}

.console-grid.freeform-mode .console-card-header,
.console-grid.freeform-mode .freeform-resize-handle {
  touch-action: none;
}

/* ---- Cloudflare Pages browser-storage mode ---- */
.save-status {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 999px;
  padding: 3px 8px;
  white-space: nowrap;
}
.save-status.flash { animation: save-status-flash 0.5s ease-out; }
@keyframes save-status-flash { from { opacity: 0.35; } to { opacity: 1; } }
body.browser-storage-mode #btn-admin-lock,
body.browser-storage-mode [data-alerts-send-test] { display: none !important; }
