/* QuietWork application shell — one mobile-first material system for every
   owner, pilot, admin, and public surface. Page-specific styles stay in their
   existing documents; this file supplies the shared visual contract. */
:root {
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, .88);
  --surface-solid: #ffffff;
  --surface2: #ededf1;
  --border: rgba(60, 60, 67, .16);
  --separator: rgba(60, 60, 67, .13);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #5856d6;
  --accent-hover: #4845bd;
  --accent-tint: #eeedff;
  --bullish: #1f9d69;
  --bullish-text: #16754e;
  --bullish-tint: #e7f6ed;
  --bearish: #d43d5c;
  --bearish-text: #b52f4b;
  --bearish-tint: #fff0f2;
  --active: #b77700;
  --radius: 16px;
  --radius-lg: 22px;
  --tap: 44px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-in-out: cubic-bezier(.4, 0, .2, 1);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 20px rgba(0, 0, 0, .035);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, .08), 0 2px 6px rgba(0, 0, 0, .04);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0d0d0f;
  --surface: rgba(28, 28, 30, .84);
  --surface-solid: #1c1c1e;
  --surface2: #2c2c2e;
  --border: rgba(235, 235, 245, .14);
  --separator: rgba(235, 235, 245, .13);
  --text: #f5f5f7;
  --muted: #a1a1a6;
  --accent: #8f8cff;
  --accent-hover: #aaa8ff;
  --accent-tint: rgba(143, 140, 255, .16);
  --bullish: #38c888;
  --bullish-text: #52d998;
  --bullish-tint: rgba(56, 200, 136, .14);
  --bearish: #ff6b82;
  --bearish-text: #ff8295;
  --bearish-tint: rgba(255, 107, 130, .14);
  --active: #f0a12c;
  --shadow-sm: 0 1px 1px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .18);
  --shadow-md: 0 18px 42px rgba(0, 0, 0, .34), 0 2px 7px rgba(0, 0, 0, .2);
  color-scheme: dark;
}

html { background: var(--bg); scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
  transition: background-color .2s var(--ease-out), color .2s var(--ease-out);
}
button, input, select, textarea { font: inherit; }
button, a, input, summary { touch-action: manipulation; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 72%, transparent);
  outline-offset: 3px;
}
button:active, .btn:active, .operations-link:active { transform: scale(.975); }

.qw-page .topbar, .qw-page .topnav, .qw-page #header {
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  backdrop-filter: blur(18px) saturate(1.35);
  border-color: var(--separator);
}
.qw-page .card, .qw-page .operational-panel, .qw-page .settings-card,
.qw-page .chart-card, .qw-page .choice, .qw-page .pilot-card {
  background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-sm);
}
.qw-page button, .qw-page .btn, .qw-page .submit-btn, .qw-page .save-btn {
  min-height: var(--tap); border-radius: 12px;
  transition: background-color .18s var(--ease-out), border-color .18s var(--ease-out),
    color .18s var(--ease-out), transform .12s var(--ease-out), box-shadow .18s var(--ease-out);
}
.qw-page input, .qw-page select, .qw-page textarea {
  min-height: var(--tap); border-radius: 12px; border-color: var(--border);
  background: var(--surface-solid); color: var(--text);
}
.qw-page .theme-toggle { min-width: 44px; min-height: 44px; border-radius: 14px; }

/* Owner dashboard: the reference hierarchy is operations, status, a compact
   metric grid, then events. Market analysis remains below this cockpit layer. */
.qw-owner #main { max-width: 760px; width: 100%; margin: 0 auto; padding: 20px 16px 104px; }
.qw-owner .owner-hero { padding: 3px 4px 14px; }
.qw-owner .owner-hero h1 { margin: 4px 0 4px; color: var(--text); font-size: clamp(32px, 9vw, 40px); line-height: 1.02; letter-spacing: -.052em; }
.qw-owner .owner-hero p { max-width: 34ch; color: var(--muted); font-size: 15px; line-height: 1.4; }
.qw-owner #header { min-height: calc(54px + env(safe-area-inset-top)); padding-top: calc(10px + env(safe-area-inset-top)); }
.qw-owner #smart-status { margin: 0 4px 12px; padding: 0; border: 0; background: transparent; color: var(--muted); text-align: left; font-size: 12px; }
.qw-owner .portfolio-strip { padding: 8px 4px 14px; }
.qw-owner .card { border-radius: var(--radius-lg); padding: 16px; margin-bottom: 12px; }
.qw-owner .card-title { letter-spacing: .05em; font-size: 11px; }
.qw-owner #nav { left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); padding: 6px; border: 1px solid var(--separator); border-radius: 20px; background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: var(--shadow-md); -webkit-backdrop-filter: blur(20px) saturate(1.4); backdrop-filter: blur(20px) saturate(1.4); }
.qw-owner .nav-btn { min-height: 52px; border-radius: 14px; }
.qw-owner .nav-btn.active { background: var(--accent-tint); }
.qw-owner .operations-card { position: relative; overflow: hidden; border-color: color-mix(in srgb, var(--accent) 32%, var(--border)); }
.qw-owner .operations-card::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(125deg, color-mix(in srgb, var(--accent) 7%, transparent), transparent 52%); }
.qw-owner .operations-head, .qw-owner .operations-actions { position: relative; z-index: 1; }
.qw-owner .operations-eyebrow { color: var(--accent); }
.qw-owner .operations-title { font-size: 22px; line-height: 1.12; letter-spacing: -.035em; }
.qw-owner .operations-copy { font-size: 14px; line-height: 1.45; }
.qw-owner .operations-link { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--surface-solid); }
.qw-owner .owner-metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 12px; }
.qw-owner .operations-fact { min-height: 94px; display: flex; flex-direction: column; justify-content: flex-end; padding: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-sm); }
.qw-owner .operations-fact-label { font-size: 10px; letter-spacing: .09em; }
.qw-owner .operations-fact-value { margin-top: 6px; font-size: 15px; letter-spacing: -.015em; }
.qw-owner .owner-events-card { padding: 0; overflow: hidden; }
.qw-owner .owner-events-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; border-bottom: 1px solid var(--separator); }
.qw-owner .owner-events-head .label { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.qw-owner .owner-events-link { min-height: 40px; display: inline-flex; align-items: center; color: var(--accent); font-size: 13px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.qw-owner .owner-events-card .operations-events { gap: 0; margin: 0; padding: 0 16px; }
.qw-owner .owner-events-card .operations-event { margin: 0; padding: 12px 0 12px 11px; border-bottom: 1px solid var(--separator); }
.qw-owner .owner-events-card .operations-event:last-child { border-bottom: 0; }
.qw-owner .owner-events-card .operations-event-message { font-size: 13px; }
.qw-owner .view-header { padding: 10px 4px 16px; }
.qw-owner .view-header h1 { margin: 3px 0 6px; font-size: clamp(28px, 7vw, 36px); line-height: 1.03; letter-spacing: -.045em; }
.qw-owner .view-header p { color: var(--muted); font-size: 14px; line-height: 1.45; max-width: 42ch; }
.qw-owner .view-kicker { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }

/* Signals: immediate state, then deliberate filtering, then readable events. */
.qw-owner #view-signals #automation-bar { margin: 0 0 12px; border-radius: 16px; min-height: 58px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.qw-owner #sig-filters { position: sticky; top: 62px; z-index: 12; margin: 0 -4px 12px; padding: 8px 4px; background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.qw-owner .filter-bar { min-height: 48px; border-radius: 14px; background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-sm); }
.qw-owner .filter-toggle-btn { min-height: 44px; border-radius: 12px; }
.qw-owner .filter-dropdown { border-radius: 18px; border-color: var(--border); box-shadow: var(--shadow-md); }
.qw-owner .filter-chip { min-height: 38px; border-radius: 10px; }
.qw-owner .sig-card, .qw-owner .sig-skeleton { border-radius: 18px; border-color: var(--border); box-shadow: var(--shadow-sm); }
.qw-owner .sig-card { padding: 15px; margin-bottom: 10px; }

/* Stats: explain scope before filters, with controls that wrap safely. */
.qw-owner #view-stats .perf-live-badge { margin: 0 0 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.qw-owner #view-stats .perf-trust-line { margin: 0 2px 16px; line-height: 1.45; }
.qw-owner #view-stats .mode-row { gap: 8px; overflow-x: auto; padding: 1px 1px 5px; scrollbar-width: none; }
.qw-owner #view-stats .mode-row::-webkit-scrollbar { display: none; }
.qw-owner #view-stats .mode-chip-btn, .qw-owner #view-stats .stats-daterange-btn { min-height: 44px; border-radius: 12px; white-space: nowrap; }
.qw-owner #view-stats .perf-curve-card, .qw-owner #view-stats .perf-phase-card { margin: 0 0 12px; border-radius: 20px; }
.qw-owner #view-stats .perf-headline-strip { border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.qw-owner #view-stats .section-header { min-height: 52px; border-radius: 14px; margin: 10px 0 6px; padding: 0 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); display: flex; align-items: center; justify-content: space-between; }
.qw-owner #view-stats .perf-export-btn { min-height: 48px; border-radius: 14px; }

/* Settings: normal, safety, and account-management work are distinct jobs. */
.qw-owner #view-settings > .card { border-radius: 20px; }
.qw-owner .settings-automation-card > .card-title { margin-bottom: 14px; }
.qw-owner .settings-notification-card, .qw-owner .settings-pilots-card { margin-top: 16px; }
.qw-owner .setting-row { padding: 15px 0; gap: 14px; }
.qw-owner .setting-label { font-size: 14px; }
.qw-owner .setting-sub { line-height: 1.45; }
.qw-owner .mode-chip-btn { min-height: 42px; border-radius: 12px; }
.qw-owner .auto-risk-input { min-height: 46px; border-radius: 12px; }
.qw-owner .settings-danger-zone { display: grid; gap: 12px; margin-top: 16px; padding: 14px; border: 1px solid color-mix(in srgb, var(--bearish) 34%, var(--border)); border-radius: 16px; background: var(--bearish-tint); }
.qw-owner .settings-danger-zone .setting-sub { margin-top: 4px; }
.qw-owner .settings-danger-zone .close-all-btn { width: 100%; min-height: 46px; margin: 0; border-radius: 12px; background: var(--bearish); }
.qw-owner .settings-danger-zone .close-all-btn:hover { background: var(--bearish-text); }

/* Pilot pages: one-column account workspace that fits iPhone Pro Max first. */
.qw-pilot .page { max-width: 680px; padding: 28px 16px calc(84px + env(safe-area-inset-bottom)); }
.qw-pilot .topbar { padding-top: env(safe-area-inset-top); }
.qw-pilot .topbar-inner { min-height: 64px; }
.qw-pilot .operational-panel, .qw-pilot .settings-card, .qw-pilot .chart-card { border-radius: var(--radius-lg); }
.qw-pilot .status-item, .qw-pilot .stat-card { border-radius: 14px; background: var(--surface2); border-color: transparent; }
.qw-pilot .section-heading { margin-top: 28px; }
.qw-pilot .settings-row input { min-height: 48px; }
.qw-pilot .page-lede { font-size: 15px; }
.qw-pilot .operational-panel { padding: 18px; }
.qw-pilot .operational-headline { font-size: 23px; letter-spacing: -.03em; }
.qw-pilot .page-title { margin: 3px 0 4px; font-size: clamp(32px, 9vw, 40px); letter-spacing: -.052em; }
.qw-pilot .page-lede { margin-bottom: 18px; }
.qw-pilot .operational-panel { position: relative; overflow: hidden; }
.qw-pilot .operational-panel.ok { border-color: color-mix(in srgb, var(--bullish) 44%, var(--border)); background: linear-gradient(135deg, var(--surface), color-mix(in srgb, var(--bullish-tint) 58%, var(--surface))); }
.qw-pilot .operational-panel.warning { background: linear-gradient(135deg, var(--surface), color-mix(in srgb, var(--bearish-tint) 66%, var(--surface))); }
.qw-pilot .operational-kicker { color: var(--muted); }
.qw-pilot .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.qw-pilot .status-item { min-height: 78px; padding: 13px; }
.qw-pilot .today-section, .qw-pilot .page > section[aria-labelledby="performanceTitle"], .qw-pilot .page > section[aria-labelledby="activityTitle"], .qw-pilot .page > section[aria-labelledby="riskTitle"] { margin-top: 28px; }
.qw-pilot .summary-grid { gap: 10px; margin-bottom: 0; }
.qw-pilot .stat-card { min-height: 96px; display: flex; flex-direction: column; justify-content: flex-end; padding: 14px; border-radius: 18px; box-shadow: var(--shadow-sm); }
.qw-pilot .chart-card { margin-top: 12px; }
.qw-pilot .settings-card { padding: 0; overflow: hidden; }
.qw-pilot .settings-card > * { margin-left: 16px; margin-right: 16px; }
.qw-pilot .settings-card .settings-loading { padding: 16px 0; }
.qw-pilot .today-section { padding-top: 4px; }
.pilot-bottom-nav {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px;
  border: 1px solid var(--border); border-radius: 20px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow-md); -webkit-backdrop-filter: blur(20px) saturate(1.35); backdrop-filter: blur(20px) saturate(1.35);
}
.pilot-bottom-nav a { min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 14px; color: var(--muted); font-size: 11px; font-weight: 650; text-decoration: none; }
.pilot-bottom-nav svg, .admin-bottom-nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pilot-bottom-nav a.active { color: var(--accent); background: var(--accent-tint); }

/* Pilot admin: dense facts remain readable; actions are intentionally grouped. */
.qw-admin { max-width: 760px; padding: calc(18px + env(safe-area-inset-top)) 16px calc(92px + env(safe-area-inset-bottom)); }
.qw-admin .top-bar { min-height: 54px; margin-bottom: 16px; }
.qw-admin h1 { font-size: 28px; letter-spacing: -.035em; }
.qw-admin h2 { margin-top: 32px; font-size: 11px; letter-spacing: .09em; }
.qw-admin .admin-heading { min-width: 0; }
.qw-admin .admin-brand { color: var(--text); font-size: 15px; font-weight: 700; letter-spacing: -.02em; }
.qw-admin .admin-heading h1 { margin-top: 9px; }
.qw-admin .admin-heading p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.qw-admin .card, .qw-admin .reconnect-summary { border-radius: var(--radius-lg); padding: 16px; }
.qw-admin .admin-attention-card { margin: 4px 0 28px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.qw-admin .admin-attention-card.needs-attention { border-color: color-mix(in srgb, var(--bearish) 42%, var(--border)); background: linear-gradient(135deg, var(--surface), color-mix(in srgb, var(--bearish-tint) 64%, var(--surface))); }
.qw-admin .admin-attention-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.qw-admin .admin-kicker { color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.qw-admin .admin-attention-head h2 { margin: 6px 0 4px; color: var(--text); font-size: 20px; letter-spacing: -.03em; text-transform: none; }
.qw-admin .admin-attention-head p { max-width: 38ch; color: var(--muted); font-size: 13px; line-height: 1.45; }
.qw-admin .admin-attention-link { min-height: 40px; display: inline-flex; align-items: center; color: var(--accent); font-size: 13px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.qw-admin .admin-attention-card .reconnect-summary { display: block; margin: 14px 0 0; padding: 12px; border-radius: 14px; background: var(--surface2); border: 1px solid var(--separator); color: var(--text); }
.qw-admin .admin-attention-card .reconnect-summary.show { display: block; }
.qw-admin .admin-attention-card .reconnect-summary:not(:empty) { font-size: 13px; line-height: 1.45; }
.qw-admin .admin-attention-card.needs-attention .reconnect-summary { border-color: color-mix(in srgb, var(--bearish) 34%, var(--separator)); background: color-mix(in srgb, var(--bearish-tint) 70%, var(--surface)); }
.qw-admin .action-group { border-radius: 14px; background: var(--surface2); }
.qw-admin .danger-zone { border-radius: var(--radius); background: var(--bearish-tint); }
.qw-admin .actions button { min-height: 46px; }
.admin-bottom-nav {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 20;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 6px;
  border: 1px solid var(--border); border-radius: 20px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow-md); -webkit-backdrop-filter: blur(20px) saturate(1.35); backdrop-filter: blur(20px) saturate(1.35);
}
.admin-bottom-nav a { min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 14px; color: var(--muted); font-size: 10px; font-weight: 650; text-decoration: none; text-align: center; }
.admin-bottom-nav a.active { color: var(--accent); background: var(--accent-tint); }

/* Authentication and connection receipts become calm, native-feeling sheets. */
.qw-auth .card, .qw-connected .card { border-radius: 26px; background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-md); }
.qw-auth .brand-mark, .qw-connected .check { box-shadow: inset 0 1px rgba(255,255,255,.28); }
.qw-auth h1, .qw-connected h1 { letter-spacing: -.035em; }
.qw-auth .submit-btn, .qw-connected a.btn { border-radius: 14px; }
.qw-auth .top-actions, .qw-connected .top-actions { position: fixed; top: calc(14px + env(safe-area-inset-top)); right: 16px; z-index: 3; }
.qw-connected { text-align: center; }

/* Public entry is quieter than an admin dashboard: clear disclosure and one
   primary next step, using the same material palette as signed-in screens. */
.qw-join .topnav { padding-top: env(safe-area-inset-top); }
.qw-join .choice { border-radius: var(--radius-lg); }
.qw-join .choice.primary { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.qw-join .guide-callout { border-radius: 16px; border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }

@media (max-width: 480px) {
  .qw-owner #main { padding-left: 12px; padding-right: 12px; }
  .qw-owner .operations-actions { align-items: flex-start; flex-direction: column; }
  .qw-owner .operations-link { width: 100%; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .qw-owner .owner-events-head { align-items: flex-start; }
  .qw-owner #sig-filters { top: 54px; }
  .qw-owner #view-stats .perf-consistency-row { margin-left: 0; margin-right: 0; }
  .qw-owner #view-stats .perf-breakdown-table { font-size: 12px; }
  .qw-owner .setting-row { align-items: flex-start; flex-direction: column; }
  .qw-owner .setting-row > .toggle { align-self: flex-end; margin-top: -42px; }
  .qw-owner .setting-row > .mode-row { width: 100%; }
  .qw-owner .setting-row:has(.auto-risk-input) { flex-direction: row; align-items: center; }
  .qw-admin .row > input { min-width: 100%; }
  .qw-admin #create { width: 100%; }
  .qw-pilot .page-title { font-size: 34px; }
  .qw-pilot table, .qw-pilot tbody, .qw-pilot tr, .qw-pilot td { display: block; width: 100%; }
  .qw-pilot table thead { display: none; }
  .qw-pilot table { margin: 0; }
  .qw-pilot table tr { padding: 13px 0; border-bottom: 1px solid var(--separator); }
  .qw-pilot table td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .qw-pilot table td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 600; text-align: left; }
  .qw-pilot table td:nth-child(1)::before { content: "Symbol"; }
  .qw-pilot table td:nth-child(2)::before { content: "Direction"; }
  .qw-pilot table td:nth-child(3)::before { content: "Status"; }
  .qw-pilot table td:nth-child(4)::before { content: "Net P&L"; }
  .qw-pilot table td:nth-child(5)::before { content: "Closed"; }
}

@media (min-width: 760px) {
  .qw-owner #main { padding-top: 22px; }
  .qw-pilot .page { padding-left: 24px; padding-right: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media (prefers-reduced-transparency: reduce) {
  .qw-page .topbar, .qw-page .topnav, .qw-page #header { background: var(--surface-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* Pilot cockpit: three short, purpose-built screens rather than one long
   document. The visual rhythm is sized from the 428px iPhone viewport upward. */
.pilot-cockpit { min-width: 0; overflow-x: clip; }
.pilot-app-header {
  min-height: calc(60px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--separator); background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3);
}
.pilot-app-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-size: 17px; font-weight: 700; letter-spacing: -.03em; }
.pilot-app-brand span { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.pilot-app-actions { display: flex; align-items: center; gap: 4px; }
.pilot-signout { min-height: 44px; padding: 0 8px; border: 0; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; }
.pilot-app-main { width: min(100%, 720px); margin: 0 auto; padding: 28px 16px calc(100px + env(safe-area-inset-bottom)); box-sizing: border-box; }
.pilot-view { min-width: 0; }
.pilot-eyebrow { margin: 0 0 7px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.pilot-view h1 { margin: 0; color: var(--text); font-size: clamp(32px, 9vw, 42px); line-height: 1.03; letter-spacing: -.055em; text-wrap: balance; }
.pilot-intro { max-width: 35ch; margin: 9px 0 24px; color: var(--muted); font-size: 16px; line-height: 1.45; }
.pilot-status-card, .pilot-chart-card, .pilot-list-card, .pilot-risk-summary {
  box-sizing: border-box; border: 1px solid var(--border); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow-sm);
}
.pilot-status-card { padding: 18px; }
.pilot-status-card.is-healthy { border-color: color-mix(in srgb, var(--bullish) 42%, var(--border)); background: linear-gradient(135deg, var(--surface), color-mix(in srgb, var(--bullish-tint) 56%, var(--surface))); }
.pilot-status-card.needs-attention { border-color: color-mix(in srgb, var(--bearish) 46%, var(--border)); background: linear-gradient(135deg, var(--surface), color-mix(in srgb, var(--bearish-tint) 60%, var(--surface))); }
.pilot-card-topline { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 8px; color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: .075em; text-transform: uppercase; }
.pilot-state-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bullish); }
.needs-attention .pilot-state-dot { background: var(--bearish); }
.pilot-status-card h2 { margin: 15px 0 5px; font-size: 22px; line-height: 1.12; letter-spacing: -.032em; }
.pilot-status-card > p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.47; }
.pilot-status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 17px; }
.pilot-status-grid > div { min-width: 0; padding: 11px; border-radius: 13px; background: color-mix(in srgb, var(--surface2) 84%, transparent); }
.pilot-status-grid span, .pilot-risk-summary span { display: block; overflow-wrap: anywhere; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .075em; text-transform: uppercase; }
.pilot-status-grid strong { display: block; margin-top: 5px; overflow-wrap: anywhere; color: var(--text); font-size: 13px; line-height: 1.25; }
.pilot-status-card small { display: block; margin-top: 14px; color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.pilot-primary-button { width: 100%; min-height: 48px; margin-top: 16px; padding: 0 16px; border: 0; border-radius: 14px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 700; }
.pilot-primary-button:disabled { opacity: .6; }
.pilot-section { margin-top: 30px; }
.pilot-section-heading, .pilot-list-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.pilot-section-heading h2, .pilot-list-heading h2 { margin: 0; color: var(--text); font-size: 18px; line-height: 1.2; letter-spacing: -.022em; }
.pilot-section-heading p, .pilot-list-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.pilot-section-heading a { min-height: 32px; display: inline-flex; align-items: center; color: var(--accent); font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.pilot-metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.pilot-metric { min-width: 0; min-height: 88px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: flex-end; padding: 14px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); box-shadow: var(--shadow-sm); }
.pilot-metric span { color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: .075em; text-transform: uppercase; }
.pilot-metric strong { margin-top: 7px; overflow-wrap: anywhere; color: var(--text); font-size: 20px; line-height: 1.05; letter-spacing: -.025em; }
.positive { color: var(--bullish-text) !important; }.negative { color: var(--bearish-text) !important; }
.pilot-chart-card { min-height: 196px; margin-top: 12px; padding: 16px; overflow: hidden; }
.pilot-card-kicker { margin-bottom: 6px; color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: .075em; text-transform: uppercase; }
.pilot-empty { margin: 0; padding: 24px 0; color: var(--muted); font-size: 14px; line-height: 1.5; text-align: center; }
.pilot-list-card { padding: 16px; }
.pilot-trade-list { display: grid; }
.pilot-trade-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 14px 0; border-top: 1px solid var(--separator); }
.pilot-trade-row > div { min-width: 0; }.pilot-trade-row > div:last-of-type { text-align: right; padding-right: 4px; }
.pilot-trade-row strong, .pilot-trade-row span { display: block; overflow-wrap: anywhere; }.pilot-trade-row strong { color: var(--text); font-size: 14px; }.pilot-trade-row span { margin-top: 3px; color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.pilot-trade-status { width: 42px; min-height: 25px; display: inline-flex !important; align-items: center; justify-content: center; margin: 0 !important; border-radius: 8px; font-size: 10px !important; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }.pilot-trade-status.win { background: var(--bullish-tint); color: var(--bullish-text); }.pilot-trade-status.loss { background: var(--bearish-tint); color: var(--bearish-text); }
.pilot-risk-summary { display: grid; grid-template-columns: 1fr; gap: 0; overflow: hidden; margin-bottom: 16px; }.pilot-risk-summary > div { display: flex; justify-content: space-between; gap: 16px; padding: 13px 15px; border-bottom: 1px solid var(--separator); }.pilot-risk-summary > div:last-child { border-bottom: 0; }.pilot-risk-summary strong { color: var(--text); font-size: 13px; text-align: right; }
.pilot-settings-form { display: grid; }.pilot-form-row { display: grid; grid-template-columns: minmax(0, 1fr) 108px; gap: 14px; align-items: center; padding: 17px 0; border-top: 1px solid var(--separator); }.pilot-form-row label { min-width: 0; }.pilot-form-row label strong, .pilot-form-row label span { display: block; }.pilot-form-row label strong { font-size: 14px; }.pilot-form-row label span { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.4; }.pilot-form-row input { min-width: 0; width: 100%; height: 44px; box-sizing: border-box; padding: 0 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-solid); color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }.pilot-input-prefix, .pilot-input-suffix { position: relative; }.pilot-input-prefix span, .pilot-input-suffix span { position: absolute; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }.pilot-input-prefix span { left: 12px; }.pilot-input-prefix input { padding-left: 25px; }.pilot-input-suffix span { right: 12px; }.pilot-input-suffix input { padding-right: 25px; }.pilot-form-actions { padding-top: 15px; }.pilot-form-actions .pilot-primary-button { margin: 0; }.pilot-form-actions p { min-height: 18px; margin: 10px 0 0; font-size: 13px; }
.pilot-inline-error { margin-top: 16px; color: var(--bearish-text); font-size: 14px; line-height: 1.45; }

@media (max-width: 480px) {
  .pilot-app-header { min-height: calc(56px + env(safe-area-inset-top)); }
  .pilot-app-main { padding: 24px 16px calc(100px + env(safe-area-inset-bottom)); }
  .pilot-card-topline { grid-template-columns: 9px minmax(0, 1fr); }.pilot-card-topline > :last-child { grid-column: 2; font-size: 9.5px; }
  .pilot-status-card { padding: 16px; }.pilot-status-card h2 { font-size: 21px; }
  .pilot-trade-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; }.pilot-trade-row strong { font-size: 13px; }
  .pilot-form-row { grid-template-columns: 1fr; gap: 10px; }.pilot-form-row input, .pilot-input-prefix, .pilot-input-suffix { width: 100%; }
}

/* Owner signal view: preserve the existing trading controls while making the
   mobile hierarchy fit a 428px viewport without clipped actions or a blank
   toolbar. */
.qw-owner #view-signals .view-header { padding: 18px 4px 16px; }
.qw-owner #view-signals .view-header h1 { max-width: 12ch; font-size: clamp(31px, 8.6vw, 42px); line-height: 1.04; letter-spacing: -.052em; text-wrap: balance; }
.qw-owner #view-signals .view-header p { max-width: 40ch; font-size: 15px; line-height: 1.45; }
.qw-owner #view-signals #automation-bar { box-sizing: border-box; display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 9px; margin: 0 0 12px; padding: 14px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-sm); }
.qw-owner #view-signals #automation-bar.hidden { display: none; }
.qw-owner #view-signals #auto-status-text, .qw-owner #view-signals #auto-pnl { min-width: 0; overflow-wrap: anywhere; }
.qw-owner #view-signals #auto-toggle-btn, .qw-owner #view-signals #auto-open-btn { min-height: 42px; margin: 0; padding: 0 12px; border-radius: 12px; }
.qw-owner #view-signals #auto-other-track { grid-column: 1 / -1; min-height: 34px; display: flex; align-items: center; box-sizing: border-box; padding: 7px 10px; border-radius: 10px; overflow-wrap: anywhere; }
.qw-owner #view-signals #sig-filters { position: relative; top: auto; margin: 0 0 14px; }
.qw-owner #view-signals .filter-bar { min-height: 48px; box-sizing: border-box; padding: 5px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); }
.qw-owner #view-signals .filter-toggle-btn { min-height: 38px; padding: 0 13px; border-radius: 11px; }
.qw-owner #view-signals .filter-dropdown { box-sizing: border-box; max-width: 100%; padding: 14px; border-radius: 16px; }

@media (max-width: 480px) {
  .qw-owner { overflow-x: clip; }
  .qw-owner #header, .qw-owner #symbol-strip { max-width: 100%; }
  .qw-owner #symbol-strip { overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: none; }
  .qw-owner #symbol-strip::-webkit-scrollbar { display: none; }
  .qw-owner #view-signals .view-header { padding: 16px 4px 14px; }
  .qw-owner #view-signals #automation-bar { grid-template-columns: auto auto minmax(0, 1fr); padding: 12px; }
  .qw-owner #view-signals #auto-toggle-btn { grid-column: 1 / 3; width: 100%; }
  .qw-owner #view-signals #auto-open-btn { grid-column: 3; width: 100%; }
  .qw-owner #view-signals #auto-balance { grid-column: 1 / -1; justify-self: start; max-width: 100%; overflow-wrap: anywhere; }
  .qw-owner #view-signals #auto-other-track { grid-column: 1 / -1; }
  .qw-owner #view-signals .filter-dropdown { max-height: min(68dvh, 560px); overflow-y: auto; }
  .qw-owner #view-signals .filter-label { width: 100%; }
}
