/* =====================================================================
   TradeOps Control Panel — design tokens
   Three themes: dim (default mid-tone), dark, light.
   Toggle cycles dim → light → dark → dim.
   ===================================================================== */

:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
             "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Menlo", Consolas, monospace;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.18);
  --shadow-md: 0 6px 22px rgba(0,0,0,.18);
  --transition: 160ms ease;
  --side-w: 232px;
  --side-w-collapsed: 64px;
  --top-h: 56px;
  --foot-h: 32px;
}

/* DIM (default — neither pure white nor pure dark) */
:root, [data-theme="dim"] {
  --bg-app:        #2a2f3a;
  --bg-elev-1:     #303644;
  --bg-elev-2:     #353b4a;
  --bg-input:      #262b36;
  --bg-terminal:   #1d2230;
  --border:        #3e4555;
  --border-strong: #4a5266;
  --text:          #e1e4ec;
  --text-muted:    #a3a9b8;
  --text-faint:    #6f7689;
  --accent:        #6aa9ff;
  --accent-hover:  #8cbcff;
  --accent-soft:   rgba(106,169,255,.15);
  --success:       #4ade80;
  --warn:          #facc15;
  --danger:        #f87171;
  --log-text:      #cdd2dc;
  --log-meta:      #8aa1c8;
  --log-faint:     #6f7689;
}

/* DARK */
[data-theme="dark"] {
  --bg-app:        #14171f;
  --bg-elev-1:     #1a1e28;
  --bg-elev-2:     #20242f;
  --bg-input:      #11141b;
  --bg-terminal:   #0c0f15;
  --border:        #262a35;
  --border-strong: #303642;
  --text:          #e6e8ee;
  --text-muted:    #98a0b0;
  --text-faint:    #5e6573;
  --accent:        #7ab4ff;
  --accent-hover:  #99c5ff;
  --accent-soft:   rgba(122,180,255,.15);
  --success:       #4ade80;
  --warn:          #facc15;
  --danger:        #f87171;
  --log-text:      #cdd2dc;
  --log-meta:      #8aa1c8;
  --log-faint:     #5e6573;
}

/* LIGHT */
[data-theme="light"] {
  --bg-app:        #f4f5f8;
  --bg-elev-1:     #ffffff;
  --bg-elev-2:     #fafbfd;
  --bg-input:      #ffffff;
  --bg-terminal:   #ffffff;     /* white terminal in light mode (per request) */
  --border:        #e2e5ec;
  --border-strong: #ccd1da;
  --text:          #1c2230;
  --text-muted:    #5a6376;
  --text-faint:    #8a93a4;
  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-soft:   rgba(37,99,235,.10);
  --success:       #15803d;
  --warn:          #b45309;
  --danger:        #b91c1c;
  --log-text:      #1c2230;
  --log-meta:      #4f5b75;
  --log-faint:     #8a93a4;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  background: var(--bg-app);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.landing-shell {
  min-height: 100vh;
  padding: 48px clamp(20px, 5vw, 72px);
  background: var(--bg-app);
}
.landing-hero {
  min-height: 58vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  max-width: 980px;
}
.landing-kicker {
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 12px;
  margin-bottom: 12px;
}
.landing-hero h1 {
  font-size: clamp(36px, 7vw, 72px);
  line-height: .98;
  margin: 0;
  max-width: 860px;
}
.landing-hero p {
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1.6;
  max-width: 720px;
}
.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.landing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.landing-grid article {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.landing-grid h2 {
  font-size: 16px;
  margin: 0 0 8px;
}
.landing-grid p {
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

/* =====================================================================
   App shell
   ===================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  grid-template-rows: var(--top-h) 1fr var(--foot-h);
  grid-template-areas:
    "side top"
    "side main"
    "side foot";
  height: 100vh;
}
.app-shell.sidebar-collapsed { grid-template-columns: var(--side-w-collapsed) 1fr; }
.sidebar  { grid-area: side; }
.topbar   { grid-area: top; }
.content  { grid-area: main; min-height: 0; overflow: hidden; }
.footer   { grid-area: foot; }

/* Sidebar */
.sidebar {
  background: var(--bg-elev-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--top-h);
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
}
.brand:hover { background: var(--bg-elev-2); }
.brand-text { line-height: 1.1; }
.brand-title {
  font-weight: 800;
  color: var(--accent);
  letter-spacing: .01em;
}
.brand-sub { font-size: 11px; color: var(--text-muted); }

.nav {
  display: flex; flex-direction: column;
  padding: 8px; gap: 2px;
  flex: 1; min-height: 0;
  overflow: auto;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-md);
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
  font-weight: 500;
}
.nav-item:hover { background: var(--bg-elev-2); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-item.locked { opacity: .45; }
.nav-icon {
  width: 20px;
  height: 20px;
  position: relative;
  flex: 0 0 auto;
  opacity: .9;
}
.nav-icon::before,
.nav-icon::after {
  content: "";
  position: absolute;
  box-sizing: border-box;
}
.nav-icon-home::before {
  left: 3px; top: 8px; width: 14px; height: 9px;
  border: 2px solid currentColor; border-top: 0; border-radius: 2px;
}
.nav-icon-home::after {
  left: 4px; top: 4px; width: 12px; height: 12px;
  border-left: 2px solid currentColor; border-top: 2px solid currentColor;
  transform: rotate(45deg);
}
.nav-icon-terminal::before {
  left: 2px; top: 4px; width: 16px; height: 12px;
  border: 2px solid currentColor; border-radius: 3px;
}
.nav-icon-terminal::after {
  left: 6px; top: 8px; width: 7px; height: 7px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}
.nav-icon-schedule::before {
  left: 3px; top: 5px; width: 14px; height: 13px;
  border: 2px solid currentColor; border-radius: 3px;
}
.nav-icon-schedule::after {
  left: 6px; top: 2px; width: 8px; height: 5px;
  border-left: 2px solid currentColor; border-right: 2px solid currentColor;
}
.nav-icon-config::before {
  left: 4px; top: 4px; width: 12px; height: 12px;
  border: 2px solid currentColor; border-radius: 50%;
}
.nav-icon-config::after {
  left: 8px; top: 0; width: 4px; height: 20px;
  border-top: 3px solid currentColor; border-bottom: 3px solid currentColor;
}
.nav-icon-backup::before {
  left: 3px; top: 4px; width: 14px; height: 12px;
  border: 2px solid currentColor; border-radius: 3px;
}
.nav-icon-backup::after {
  left: 7px; top: 8px; width: 6px; height: 6px;
  border-left: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}
.auth-out .nav-item[data-route="terminal"],
.auth-out .nav-item[data-route="schedule"],
.auth-out .nav-item[data-route="configurations"],
.auth-out .nav-item[data-route="backup"] {
  display: none;
}
.app-shell.sidebar-collapsed .brand-text,
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .sidebar-foot span:not(.ws-dot) { display: none; }
.app-shell.sidebar-collapsed .nav-item { justify-content: center; }
.app-shell.sidebar-collapsed .brand { justify-content: center; padding: 12px 8px; }
.app-shell.sidebar-collapsed .tradeops-wordmark { gap: 0; }
.app-shell.sidebar-collapsed .tradeops-wordmark__text { display: none; }

.sidebar-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 8px;
  flex: 0 0 auto;
}
.ws-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-faint);
  flex: 0 0 auto;
}
.ws-dot.ok  { background: var(--success); }
.ws-dot.bad { background: var(--danger); }

/* Topbar */
.topbar {
  background: var(--bg-elev-1);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  min-width: 0;
}
.topbar-title { font-size: 16px; margin: 0; font-weight: 600; flex: 0 0 auto; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 16px;
  transition: var(--transition);
}
.icon-btn:hover { background: var(--bg-elev-2); border-color: var(--border); }
.icon-btn-menu {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 0 0 auto;
}
.icon-btn-menu span {
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}
.icon-btn-theme {
  position: relative;
}
.icon-btn-theme span {
  display: block;
  width: 16px;
  height: 16px;
  margin: 0 auto;
  border-radius: 50%;
  border: 2px solid currentColor;
  box-shadow: inset -5px -3px 0 color-mix(in srgb, var(--text) 42%, transparent);
}

.env-pill {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 230px;
  padding: 4px 9px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-elev-2) 82%, var(--accent-soft));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.user-pill-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: linear-gradient(135deg, var(--accent), var(--success));
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.user-pill-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.05;
}
.user-pill-name {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-pill-role {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* Active-pipeline indicator in header */
.run-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  min-width: 0;
  max-width: min(560px, 44vw);
  overflow: hidden;
}
.run-pill[hidden] { display: none; }
.run-pill.idle {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-color: color-mix(in srgb, var(--danger) 42%, transparent);
}
.run-pill.idle .run-pulse {
  background: var(--danger);
}
.run-pill.idle .run-pulse::before {
  display: none;
}
.run-pulse {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--success);
  position: relative;
  flex: 0 0 auto;
}
.run-pulse::before {
  content: "";
  position: absolute; inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--success);
  opacity: 0.7;
  animation: ringPulse 1.5s ease-out infinite;
}
@keyframes ringPulse {
  0%   { transform: scale(0.5); opacity: 0.8; }
  100% { transform: scale(1.8); opacity: 0; }
}
.run-info { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.run-label {
  font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.run-meta {
  font-size: 11px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.run-elapsed, .run-start { font-variant-numeric: tabular-nums; }

/* Footer */
.footer {
  background: var(--bg-elev-1);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  padding: 0 16px;
  font-size: 12px;
  color: var(--text-muted);
  gap: 16px;
  text-align: center;
}
.footer-spacer,
.footer-version { display: none; }

/* =====================================================================
   Content + pages  (every page fills available height)
   ===================================================================== */
.content {
  padding: 18px;
  display: flex;
  flex-direction: column;
}
.page {
  display: none;
  flex: 1;
  min-height: 0;
}
.page.active {
  display: flex;
  flex-direction: column;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* Cards */
.card {
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex: 0 0 auto;
}
.card-title { font-weight: 600; }
.card-sub { font-size: 12px; color: var(--text-muted); }
.card-actions { display: flex; gap: 6px; align-items: center; }
.card-body { padding: 14px 16px; flex: 1; min-height: 0; }
.card-body.scrollable { overflow: auto; }     /* trigger lists, file lists */
.editor-card { flex: 1; min-height: 0; }
.editor-body {
  display: flex; flex-direction: column;
  padding: 12px 14px;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

/* Two-column grids fill the page */
.grid-two {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
}
@media (max-width: 1100px) {
  .grid-two { grid-template-columns: 1fr; }
}

/* Hero (home page) */
.hero-card {
  background: linear-gradient(135deg, var(--bg-elev-1), var(--bg-elev-2));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 32px;
  box-shadow: var(--shadow-sm);
}
.hero-title { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.hero-sub { color: var(--text-muted); max-width: 680px; line-height: 1.55; }
.hero-actions { margin-top: 18px; display: flex; gap: 8px; }

/* =====================================================================
   Buttons
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  font: inherit; font-weight: 500;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev-2);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover  { background: var(--bg-elev-1); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; }
.btn-danger {
  background: var(--danger); border-color: var(--danger); color: #fff;
}
.btn-danger:hover { filter: brightness(1.05); }
.locked {
  opacity: .55;
}

/* =====================================================================
   Trigger tiles
   ===================================================================== */
.trigger-group { margin-bottom: 16px; }
.trigger-group h4 {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 700;
}
.trigger-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.trigger-group[data-group="server"] .trigger-grid {
  grid-template-columns: minmax(220px, 360px);
}
.trigger-tile {
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--bg-elev-2) 92%, #fff 8%), var(--bg-elev-2));
  border-radius: var(--r-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  position: relative;
  min-height: 112px;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.trigger-tile:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}
.trigger-tile.running {
  border-color: var(--success);
  animation: tilePulse 2s ease-in-out infinite;
}
@keyframes tilePulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 50%, transparent); }
  100% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--success) 0%, transparent); }
}
.trigger-tile-head {
  display: flex; align-items: center; gap: 8px;
  font-weight: 650; font-size: 13px;
  line-height: 1.25;
  min-height: 34px;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.dot.running {
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 25%, transparent);
}
.trigger-tile-actions { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.trigger-tile-actions .btn {
  padding: 7px 10px;
  font-size: 12px;
  flex: 1;
  justify-content: center;
  border-radius: 999px;
}
.trigger-tile-actions .act-keep-stopped {
  flex-basis: 100%;
  color: var(--text-muted);
}
.trigger-tile-actions .act-keep-stopped.is-off {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}
.trigger-tile-actions .btn:disabled {
  opacity: .38;
  pointer-events: none;
}
.trigger-tile-elapsed {
  min-height: 15px;
  font-size: 11px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* File list (configurations) */
.file-list { display: flex; flex-direction: column; gap: 4px; }
.file-list-group h4 {
  margin: 12px 0 6px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 700;
}
.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--text);
  transition: var(--transition);
  text-align: left;
  font: inherit;
  width: 100%;
}
.file-item:hover { background: var(--bg-elev-2); border-color: var(--border); }
.file-item.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.file-item .file-path { font-size: 11px; color: var(--text-muted); }
.file-item.active .file-path { color: var(--accent); opacity: .8; }

/* =====================================================================
   Editors + terminal panes (fill remaining height)
   ===================================================================== */
.editor {
  width: 100%;
  flex: 1;
  min-height: 0;
  resize: none;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px;
  outline: none;
  white-space: pre;
  overflow: auto;
}
.editor:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.editor[readonly] { opacity: .92; }

.terminal-card { display: flex; flex-direction: column; min-height: 0; }
.terminal-card .card-body { padding: 0; display: flex; min-height: 0; }
.terminal-pane {
  background: var(--bg-terminal);
  color: var(--log-text);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  padding: 12px 14px;
  margin: 0;
  border: 0;
  border-bottom-left-radius: var(--r-lg);
  border-bottom-right-radius: var(--r-lg);
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  flex: 1;
  min-height: 0;
  width: 100%;
}
.log-line { display: block; }
.log-line .ts   { color: var(--log-faint); margin-right: 8px; }
.log-line .src  { color: var(--accent);    margin-right: 6px; }
.log-line .text { color: var(--log-text); }
.log-line.lv-error .text { color: var(--danger); }
.log-line.lv-warn  .text { color: var(--warn); }
.log-line.lv-meta  .text { color: var(--log-meta); font-style: italic; }
.log-line.lv-ok    .text { color: var(--success); }

/* Form controls */
.select {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 5px 8px;
  font: inherit;
}
.input {
  width: 100%;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 9px 10px;
  font: inherit;
  outline: none;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(440px, 100%);
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 600; }
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
}
.auth-link {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 2px 0;
  width: fit-content;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}
.auth-link:hover {
  color: var(--text);
  text-decoration: underline;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 560px) {
  .topbar-actions { gap: 4px; }
  .user-pill { max-width: 110px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* Status / toast */
.status-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted);
  min-height: 18px;
  flex: 0 0 auto;
}
.status-row.ok  { color: var(--success); }
.status-row.err { color: var(--danger); }

.toast-host {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 999;
}
.toast {
  background: var(--bg-elev-1);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  min-width: 220px;
  animation: slideIn .18s ease;
}
.toast.ok  { border-left: 4px solid var(--success); }
.toast.err { border-left: 4px solid var(--danger); }
@keyframes slideIn { from { transform: translateX(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.muted { color: var(--text-muted); font-size: 13px; }

/* =====================================================================
   Splash overlay (intro)
   ===================================================================== */
.splash {
  position: fixed; inset: 0;
  background: var(--bg-app);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .45s ease;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash-inner {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  animation: splashIn .5s ease;
}
.splash .tradeops-wordmark--splash {
  filter: drop-shadow(0 8px 24px rgba(0,0,0,.25));
  animation: logoFloat 2.4s ease-in-out infinite;
}
@keyframes splashIn {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
@keyframes logoFloat {
  0%, 100% { transform: scale(1)    rotate(0); }
  50%      { transform: scale(1.06) rotate(-1.5deg); }
}
.splash-title {
  font-size: 22px; font-weight: 600; letter-spacing: .04em;
  color: var(--text);
}
.splash-tag {
  font-size: 12px; color: var(--text-muted);
}
.splash-spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   Mobile layout
   ===================================================================== */
@media (max-width: 760px) {
  :root {
    --top-h: auto;
    --foot-h: auto;
  }

  html, body {
    min-height: 100%;
    height: auto;
  }

  body {
    overflow-x: hidden;
  }

  .app-shell {
    min-height: 100dvh;
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas:
      "top"
      "side"
      "main"
      "foot";
  }

  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
    min-height: 0;
  }

  .topbar-title {
    font-size: 15px;
  }

  .topbar-spacer {
    display: none;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .icon-btn {
    width: auto;
    min-width: 38px;
    padding: 0 10px;
    font-size: 12px;
  }

  .run-pill {
    order: 3;
    width: 100%;
    max-width: none;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    min-height: 0;
  }

  .brand {
    display: none;
  }

  .nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 8px;
    gap: 6px;
  }

  .nav-item {
    flex: 0 0 auto;
    padding: 8px 10px;
    gap: 6px;
  }

  .nav-icon {
    width: auto;
    min-width: 18px;
    font-size: 11px;
  }

  .sidebar-foot {
    display: none;
  }

  .content {
    padding: 10px;
    overflow: visible;
  }

  .page,
  .page.active {
    min-height: auto;
  }

  .grid-two {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: auto;
  }

  .card,
  .editor-card,
  .terminal-card {
    min-height: auto;
  }

  .card-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 12px;
  }

  .card-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .card-body {
    padding: 10px 12px;
  }

  .trigger-grid {
    grid-template-columns: 1fr;
  }

  .trigger-tile-actions .btn {
    min-height: 36px;
  }

  .terminal-pane {
    min-height: 300px;
    max-height: 48vh;
    font-size: 11.5px;
  }

  .editor {
    min-height: 360px;
    font-size: 12px;
  }

  .hero-card {
    padding: 18px;
  }

  .hero-actions {
    flex-direction: column;
  }

  .hero-actions .btn {
    justify-content: center;
  }

  .modal-backdrop {
    align-items: flex-start;
    padding: 12px;
    overflow: auto;
  }

  .modal {
    width: 100%;
  }

  .footer {
    flex-wrap: wrap;
    padding: 8px 10px;
  }

  .toast-host {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }

  .toast {
    min-width: 0;
    width: 100%;
  }
}
