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

:root {
  --bg: #0f1117;
  --surface: #1a1d28;
  --surface-2: #242736;
  --border: #2e3248;
  --text: #e1e4ed;
  --text-muted: #8b90a5;
  --accent: #4f8cff;
  --accent-hover: #6ba0ff;
  --green: #3dd68c;
  --red: #f25c5c;
  --orange: #f5a623;
  --radius: 10px;
  --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ────────────────────────────────────────────────── */
header {
  background: linear-gradient(135deg, #1e2235 0%, #141725 100%);
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}

.header-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: baseline;
  gap: 14px;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ── Layout ────────────────────────────────────────────────── */
main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  /* Sidebar widened from 380px → 420px so the 2-col form grids inside
     the launch pane have ~180px per cell (after gaps + card padding)
     instead of ~150px. Numeric inputs and short labels now fit on a
     single line without truncation. */
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.launch-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding-right: 4px;   /* room for the scrollbar */
}

.jobs-pane {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;         /* allow grid child to shrink instead of overflow */
}

/* On narrower viewports stack the panes vertically. */
@media (max-width: 1100px) {
  main {
    grid-template-columns: 1fr;
  }
  .launch-pane {
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

/* ── Card ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
}

.card h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 5px;
}

.tab {
  flex: 1 1 0;
  min-width: 0;          /* allow even shrinking of 5 tabs in narrow sidebar */
  padding: 9px 4px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.15s;
}

.tab:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Form grid ─────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px 18px;
}

/* Per-section overrides so 2-field cards don't look "lost" in a 4-col
   grid, and 7-field cards always balance on the same column count. */
#common-params .form-grid,
#spread-common-params .form-grid { grid-template-columns: repeat(4, 1fr); }
#params-auction .form-grid       { grid-template-columns: repeat(3, 1fr); }
#params-pov .form-grid           { grid-template-columns: repeat(2, 1fr); }
#params-planka .form-grid        { grid-template-columns: repeat(2, 1fr); }
#params-twap .form-grid          { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 880px) {
  #common-params .form-grid,
  #spread-common-params .form-grid { grid-template-columns: repeat(2, 1fr); }
  #params-auction .form-grid       { grid-template-columns: repeat(2, 1fr); }
}

/* ── Sidebar (launch-pane) overrides ───────────────────────── */
/* The form grids live inside a ~420px sticky sidebar, so the desktop
   per-section column counts (4, 3, 2) are wrong here. Force sensible
   column counts at the .launch-pane scope so they win regardless of
   viewport-based media queries above. */
.launch-pane .form-grid {
  gap: 12px 14px;
}

.launch-pane #common-params .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
/* Fields tagged .field-wide (Ticker combo) span the whole row.
   Order in DOM is: Account | Direction · Ticker(full) · Total Shares |
   Execution Time · Max Buy | Min Sell — all rows balance to 2 cells. */
.launch-pane .form-grid .field-wide,
.launch-pane #common-params .form-grid .field-wide {
  grid-column: 1 / -1;
}

.launch-pane #spread-common-params .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.launch-pane #params-pov .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.launch-pane #params-twap .form-grid {
  /* Only one field — single column avoids the half-empty row. */
  grid-template-columns: minmax(0, 1fr);
}

.launch-pane #params-auction .form-grid {
  /* Long labels + inline hints + checkbox rows — single column. */
  grid-template-columns: minmax(0, 1fr);
}

.launch-pane #params-planka .form-grid {
  /* Each field carries a paragraph-long field-hint — single column. */
  grid-template-columns: minmax(0, 1fr);
}

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

/* ── Sidebar label restyle ─────────────────────────────────────
   In the 420px launch pane, uppercase + letter-spacing labels wrap
   to 3-4 lines for anything beyond ~14 chars. Drop the typographic
   "section-label" treatment and use sentence-case for readability. */
.launch-pane .field label {
  font-size: 0.78rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 5px;
  line-height: 1.35;
}

/* Inline hint spans inside the label (e.g. "(bid 7.378 / ask 7.380)"
   next to "Max Buy Price") push the main label text to wrap. Break
   them onto their own line below in the sidebar. */
.launch-pane .field label .field-hint,
.launch-pane .field label .quote-hint {
  display: block;
  margin-top: 2px;
  font-weight: 400;
}

/* Checkbox-style fields keep the input inline with their own text. */
.launch-pane .field label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.field input,
.field select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  transition: border-color 0.15s;
}

/* Tighter inputs in the sidebar so they don't visually dominate
   their labels — same border + radius, just less vertical padding
   and a slightly smaller font. */
.launch-pane .field input,
.launch-pane .field select,
.launch-pane .ticker-combo input,
.launch-pane .ticker-combo select {
  padding: 7px 10px;
  font-size: 0.9rem;
  border-radius: 6px;
}

.launch-pane .field input[type="checkbox"] {
  width: auto;
  padding: 0;
  margin: 0;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}

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

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

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

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

.btn-danger:hover {
  background: rgba(242, 92, 92, 0.12);
}

.btn-lg {
  padding: 12px 36px;
  font-size: 1rem;
}

.btn-sm {
  padding: 4px 12px;
  font-size: 0.82rem;
}

/* ── Launch section ────────────────────────────────────────── */
.launch-section {
  display: flex;
  align-items: stretch;
  gap: 14px;
}

.launch-section .btn {
  min-height: 46px;
  padding: 0 28px;
  font-size: 0.95rem;
  font-weight: 600;
}

.launch-section .btn-primary { flex: 0 0 auto; min-width: 200px; }
.launch-section .btn-danger  { flex: 0 0 auto; min-width: 140px; }

/* ── Jobs table ────────────────────────────────────────────── */
.jobs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.jobs-table th {
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.jobs-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.jobs-table code {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent);
}

.side-buy { color: var(--green); font-weight: 600; }
.side-sell { color: var(--red); font-weight: 600; }

/* ── Progress cell ─────────────────────────────────────────── */
.progress-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 140px;
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

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

.progress-text {
  font-size: 0.78rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.progress-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ── Price display ─────────────────────────────────────────── */
.avg-price {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.last-price {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.limit-price {
  display: block;
  font-size: 0.72rem;
  color: var(--orange);
  font-variant-numeric: tabular-nums;
}

/* ── Status badges ─────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-running {
  background: rgba(61, 214, 140, 0.15);
  color: var(--green);
}

.status-stopped {
  background: rgba(245, 166, 35, 0.15);
  color: var(--orange);
}

.status-done {
  background: rgba(139, 144, 165, 0.15);
  color: var(--text-muted);
}

.status-error {
  background: rgba(242, 92, 92, 0.18);
  color: var(--red);
}

.status-finished {
  background: rgba(61, 214, 140, 0.14);
  color: var(--green);
}

.error-msg {
  font-size: 0.72rem;
  color: var(--red);
  margin-top: 3px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--accent);
}

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

/* ── Log viewer ────────────────────────────────────────────── */
.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.log-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--text-muted);
  max-height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Execution Report ──────────────────────────────────────── */
.btn-report {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}

.btn-report:hover {
  background: rgba(79, 140, 255, 0.12);
}

.report-box {
  padding: 12px 16px;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.report-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 1rem;
  border-bottom: 2px solid var(--border);
  color: var(--text);
}

.report-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.report-table td:first-child {
  color: var(--text);
  font-weight: 500;
  width: 45%;
}

.report-table td strong {
  color: var(--text);
}

/* ── Notifications ─────────────────────────────────────────── */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 22px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 4px 24px rgba(0,0,0,0.35);
  opacity: 0;
  transform: translateX(40px);
  transition: all 0.3s;
  z-index: 1000;
}

.notification.show {
  opacity: 1;
  transform: translateX(0);
}

.notification-success {
  background: var(--green);
  color: #0f1117;
}

.notification-error {
  background: var(--red);
  color: #fff;
}

/* ── Ticker combo ─────────────────────────────────────────── */
.ticker-combo {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ticker-combo select,
.ticker-combo input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  transition: border-color 0.15s;
}

.ticker-combo select:focus,
.ticker-combo input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}

.ticker-combo input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

/* ── Field hint (shares out of N) ─────────────────────────── */
.field-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
  font-style: italic;
}

/* ── Quote hint (bid/ask near limit price) ────────────────── */
.quote-hint {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--accent);
  text-transform: none;
  letter-spacing: 0;
}

/* ── Jobs toolbar (header: tabs + rate budget) ────────────── */
.jobs-toolbar {
  display: flex;
  align-items: center;
  /* Was justify-content: space-between, which pushed rate-budget to
     the far right of the very wide jobs-pane (~1100px+) and made it
     look disconnected from the title. Anchor everything on the left
     and let rate-budget wrap to the next row only when there's no
     space. */
  justify-content: flex-start;
  gap: 14px 18px;
  flex-wrap: wrap;
}

.jobs-toolbar__left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.jobs-toolbar h2 { margin: 0; }

/* ── Job tabs (Active / Finished / Errors) ────────────────── */
.job-tabs {
  display: flex;
  gap: 6px;
}

.job-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.job-tab:hover {
  background: var(--surface-2);
  color: var(--text);
}

.job-tab.is-active[data-tab="active"] {
  border-color: var(--accent);
  background: rgba(79, 140, 255, 0.14);
  color: var(--accent);
}

.job-tab.is-active[data-tab="finished"] {
  border-color: var(--green);
  background: rgba(61, 214, 140, 0.14);
  color: var(--green);
}

.job-tab.is-active[data-tab="errors"] {
  border-color: var(--red);
  background: rgba(242, 92, 92, 0.14);
  color: var(--red);
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 0 6px;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
}

.job-tab.is-active .tab-badge {
  background: rgba(255, 255, 255, 0.12);
}

/* ── Rate budget cells ────────────────────────────────────── */
.rate-budget {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.rate-budget__label { color: var(--text-muted); margin-right: 6px; }
.rate-cell { color: var(--text-muted); }
.rate-cell--warn { color: var(--orange); }
.rate-cell--over { color: var(--red); font-weight: 600; }

/* ── Jobs container — horizontal scroll on narrow screens ── */
#jobs-container {
  overflow-x: auto;
}

/* ── Job cards (Active tab — one card per running job) ───── */
.job-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.job-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-muted);
  border-radius: 10px;
  padding: 14px 16px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.job-card[data-status="running"]  { border-left-color: var(--green); }
.job-card[data-status="finished"] { border-left-color: var(--green); }
.job-card[data-status="stopped"]  { border-left-color: var(--orange); }
.job-card[data-status="error"]    { border-left-color: var(--red); }
.job-card[data-status="exited"]   { border-left-color: var(--text-muted); }

.job-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.job-card__title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.job-card__title .strat { color: var(--accent); }
.job-card__title .ticker { color: var(--text); }
.job-card__title .acc {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  background: rgba(255,255,255,0.04);
  padding: 1px 7px;
  border-radius: 5px;
}

.job-card__id {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--accent);
}

.job-card__progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.job-card .progress-bar-bg { height: 8px; }

.job-card__progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  gap: 12px;
  flex-wrap: wrap;
}

.job-card__progress-text .pct { color: var(--text-muted); }

.job-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.job-card__meta strong {
  color: var(--text);
  font-weight: 600;
}

.job-card__meta .meta-sep { color: var(--border); }

.job-card__error {
  background: rgba(242, 92, 92, 0.08);
  border: 1px solid rgba(242, 92, 92, 0.25);
  color: var(--red);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.4;
}

.job-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

/* ── Compact table for Finished / Errors ──────────────────── */
.compact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.compact-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 8px 8px;
  border-bottom: 1px solid var(--border);
}

.compact-table td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.compact-table code {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
}

.compact-table .ts-stack {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.3;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.compact-table .ts-stack .ts-arrow { opacity: 0.5; padding: 0 2px; }

.compact-table .duration {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ── Per-row sub-cells ────────────────────────────────────── */
.price-cell {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.25;
}

.price-cell .avg-price,
.price-cell .last-price,
.price-cell .limit-price {
  display: block;
}

.actions-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.actions-cell .btn { flex: 0 0 auto; white-space: nowrap; }

.job-ts {
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.job-ts--muted { opacity: 0.55; }

/* ── Generic modal (Edit Limit, etc.) ─────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(2px);
}

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

.modal__panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.modal__title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text);
}

.modal__row { margin-bottom: 14px; }

.modal__row label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.modal__input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
}

.modal__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Report diff colors (palette-tied) ────────────────────── */
.diff--better { color: var(--green); }
.diff--worse  { color: var(--red); }

/* ── Hidden utility ────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
  main { padding: 14px; }
  .card { padding: 16px; }
  .form-grid,
  #common-params .form-grid,
  #spread-common-params .form-grid,
  #params-auction .form-grid,
  #params-pov .form-grid,
  #params-planka .form-grid,
  #params-twap .form-grid { grid-template-columns: 1fr; }
  .launch-section { flex-direction: column; }
  .launch-section .btn { width: 100%; min-width: 0; }
  .jobs-table { font-size: 0.8rem; }
  .jobs-table th, .jobs-table td { padding: 6px 4px; }
}

/* ── Mobile app mode (phones, ≤820px) ─────────────────────────
   One pane at a time (Jobs ⇄ Launch) switched by the fixed bottom
   navigation. The .view-* classes are set by JS on <main> and are
   scoped inside this media query, so desktop layout is untouched. */
.mobile-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  background: rgba(17, 20, 32, 0.94);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}

.mobile-nav__btn {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.mobile-nav__btn.is-active {
  background: rgba(79, 140, 255, 0.16);
  border-color: rgba(79, 140, 255, 0.35);
  color: var(--accent);
}

.mobile-nav__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(61, 214, 140, 0.18);
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
}

.mobile-nav__badge:empty { display: none; }

@media (max-width: 820px) {
  .mobile-nav { display: flex; }

  main {
    grid-template-columns: 1fr;
    gap: 14px;
    /* room for the fixed bottom nav + iPhone home indicator */
    padding: 12px 12px calc(84px + env(safe-area-inset-bottom, 0px));
  }

  main.view-jobs .launch-pane { display: none; }
  main.view-launch .jobs-pane { display: none; }

  header { padding: 10px 0; }
  .header-inner { padding: 0 14px; }
  header h1 { font-size: 1.1rem; }
  .subtitle { display: none; }

  /* iOS Safari auto-zooms into focused inputs with font-size <16px —
     force 16px on every text control so the viewport stays put. */
  .field input,
  .field select,
  .ticker-combo input,
  .ticker-combo select,
  .launch-pane .field input,
  .launch-pane .field select,
  .launch-pane .ticker-combo input,
  .launch-pane .ticker-combo select,
  .modal__input {
    font-size: 16px;
  }

  /* Finger-sized touch targets */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .tab { padding: 12px 4px; }
  .job-tab { padding: 9px 14px; min-height: 38px; }
  /* Three status tabs + title don't fit one row at iPhone width */
  .job-tabs { flex-wrap: wrap; }
  .jobs-toolbar__left { gap: 10px 12px; }

  .card { padding: 16px 14px; }
  .log-box { max-height: 55dvh; font-size: 0.78rem; }
  .modal__panel { max-width: none; }

  /* Jobs: every tab renders cards on phones (see renderJobs), so the
     container never needs to scroll sideways. Action buttons become a
     two-column grid of full-width, finger-sized targets instead of a
     row that wraps unevenly. */
  #jobs-container { overflow-x: visible; }
  .job-card { padding: 14px 14px 12px; }
  .job-card__title { font-size: 1rem; gap: 8px; }
  .job-card__id { flex-basis: 100%; }
  .job-card__meta { gap: 4px 12px; font-size: 0.8rem; }
  .job-card__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding-top: 10px;
  }
  .job-card__actions .btn { width: 100%; min-height: 44px; }

  /* Secondary info the phone can live without */
  .rate-budget { font-size: 0.72rem; }
}
