/* ─── ETF Risk Desk · Design System v2 ─────────────────────────────── */
:root {
  --nav: #14202e;
  --bg: #f6f5f1;
  --card: #ffffff;
  --surface: #f9fafb;
  --success: #0f6b54;
  --primary: #0f6b54;
  --review: #b45309;
  --blocked: #b91c1c;
  --text: #111827;
  --muted: #6b7280;
  --hint: #9ca3af;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --blue: #1f6f8b;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
}

/* ─── Icon font ─────────────────────────────────────────────────────── */
@font-face {
  font-family: "ETFLocalIconFallback";
  src: local("Segoe UI Symbol"), local("Arial Unicode MS"), local("Noto Sans Symbols");
  font-display: swap;
}
.ti { display: inline-flex; align-items: center; justify-content: center; width: 1.1em; height: 1.1em; font-family: "ETFLocalIconFallback", -apple-system, BlinkMacSystemFont, "Segoe UI Symbol", sans-serif; font-style: normal; font-weight: 600; line-height: 1; color: currentColor; }
.ti-layout-dashboard::before { content: "▦"; }
.ti-dashboard::before { content: "▦"; }
.ti-chart-line::before { content: "⌁"; }
.ti-chart-bar::before { content: "▥"; }
.ti-shield-check::before { content: "✓"; }
.ti-alert-triangle::before { content: "!"; }
.ti-database::before { content: "◆"; }
.ti-bell::before { content: "●"; }
.ti-settings::before { content: "⚙"; }
.ti-arrow-right::before { content: "→"; }
.ti-wallet::before { content: "□"; }
.ti-info-circle::before { content: "i"; }
.ti-test-pipe::before { content: "∴"; }
.ti-wave-sine::before { content: "⌁"; }
.ti-upload::before { content: "↑"; }
.ti-device-floppy::before { content: "▣"; }
.ti-refresh::before { content: "↻"; }
.ti-eye::before { content: "◉"; }
.ti-arrow-down::before { content: "↓"; }
.ti-arrow-up::before { content: "↑"; }
.ti-minus::before { content: "−"; }
.ti-player-play::before { content: "▶"; }

/* ─── Reset & base ──────────────────────────────────────────────────── */
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; font-size: .94rem; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Top nav ───────────────────────────────────────────────────────── */
.topbar { display: flex; align-items: stretch; padding: 0 20px; background: var(--nav); position: sticky; top: 0; z-index: 100; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand { font-size: .90rem; font-weight: 700; color: #fff; padding: 14px 0; margin-right: 16px; letter-spacing: .3px; white-space: nowrap; display: flex; align-items: center; }
.stage { display: none; }
.topbar nav { display: flex; gap: 0; align-items: stretch; flex: 1; overflow-x: auto; }
.topbar nav a { color: #94a8be; font-size: .84rem; padding: 0 13px; border-bottom: 2px solid transparent; display: inline-flex; align-items: center; gap: 5px; text-decoration: none; transition: color .12s; white-space: nowrap; }
.topbar nav a i { font-size: 13px; flex-shrink: 0; }
.topbar nav a:hover { color: #c8d8ea; text-decoration: none; }
.topbar nav a.active { color: #fff; border-bottom-color: var(--success); font-weight: 500; }
.nav-badge { background: #b91c1c; color: #fff; font-size: 9px; padding: 1px 5px; border-radius: 8px; font-weight: 700; line-height: 1.4; margin-left: 2px; }
.nav-spacer { flex: 1; }

/* ─── Layout ────────────────────────────────────────────────────────── */
.container { max-width: 960px; margin: 0 auto; padding: 20px; }
.footer { padding: 12px 20px; text-align: center; color: var(--hint); font-size: .78rem; background: var(--card); border-top: 1px solid var(--border); margin-top: 24px; }

/* ─── Hero / page header ────────────────────────────────────────────── */
.page-hero, .hero, .validation-hero { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; padding: 16px 20px; margin-bottom: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.page-hero h1, .hero h1, .validation-hero h1 { margin: 0 0 4px; font-size: 1.25rem; font-weight: 700; line-height: 1.25; }
.page-hero p, .hero p, .validation-hero p { margin: 0 0 4px; color: var(--muted); font-size: .87rem; }
.eyebrow { margin: 0 0 4px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; color: var(--success); text-transform: uppercase; }
.hero-tools { display: flex; flex-direction: column; gap: 7px; align-items: flex-end; flex-shrink: 0; }

/* ─── Grids ─────────────────────────────────────────────────────────── */
.section-grid, .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.config-layout, .m10-layout, .m10-detail, .validation-layout, .runtime-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(260px, .9fr); gap: 12px; align-items: start; margin-bottom: 14px; }
.decision-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.model-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.strategy-models-page .model-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); align-items: stretch; }
.strategy-models-page .section-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.strategy-models-page .config-layout { grid-template-columns: minmax(0, 1fr) minmax(300px, .9fr); }
.strategy-models-page .hero-tools { min-width: 170px; max-width: 100%; }
.strategy-models-page .summary-list { grid-template-columns: minmax(92px, .38fr) minmax(0, 1fr); }
.strategy-models-page .model-card { min-width: 0; overflow-wrap: anywhere; align-content: start; }
.strategy-models-page .price-map-card, .strategy-models-page .info-panel, .strategy-models-page .metric-tile { min-width: 0; overflow-wrap: anywhere; }
.strategy-models-page .table-wrap { max-width: 100%; overflow-x: auto; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-bottom: 14px; }
.metrics-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.event-first-screen { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); }

/* ─── Cards ─────────────────────────────────────────────────────────── */
.card, .metric-card, .model-card, .price-map-card, .action-card, .info-panel, .m10-panel, .validation-panel, .operation-panel {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px;
}
.metric-card { margin-bottom: 0; }
.metric-card .label { display: block; color: var(--muted); font-size: .77rem; margin-bottom: 4px; font-weight: 500; }
.metric-card strong { display: block; margin-bottom: 4px; color: var(--text); font-size: .95rem; font-weight: 600; }
.metric-card h2, .model-card h2, .price-map-card h2, .info-panel h2, .m10-panel h2 { margin: 0 0 10px; font-size: .97rem; font-weight: 600; color: var(--text); }
.metric-value { margin: 0 0 6px !important; color: var(--blue); font-size: 1.26rem; font-weight: 600; }
.model-card { display: grid; gap: 8px; margin-bottom: 0; }
.price-map-card { margin-bottom: 0; }
.price-map-card.compact { padding: 8px 10px; box-shadow: none; }
.action-card { display: grid; gap: 6px; text-decoration: none; color: var(--text); margin-bottom: 0; transition: border-color .12s, background .12s, box-shadow .12s; cursor: pointer; }
.action-card:hover { border-color: var(--success); background: #f0fdf9; text-decoration: none; box-shadow: var(--shadow-md); }
.info-panel { background: #f8fafd; }

/* ─── Cockpit / cold start ──────────────────────────────────────────── */
.cockpit-status-card { display: grid; grid-template-columns: minmax(0, .9fr) minmax(300px, 1.1fr); gap: 14px; align-items: stretch; margin-bottom: 14px; }
.cockpit-status-main, .cold-start-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.cockpit-status-main h2 { margin: 0 0 6px; font-size: 1.18rem; line-height: 1.25; font-weight: 700; }
.cockpit-status-main p { margin: 0 0 10px; color: var(--muted); font-size: .87rem; line-height: 1.6; }
.cockpit-status-card.status-ready .cockpit-status-main { border-left: 4px solid var(--success); border-radius: 0 12px 12px 0; }
.cockpit-status-card.status-warming .cockpit-status-main { border-left: 4px solid var(--review); border-radius: 0 12px 12px 0; }
.cockpit-status-card.status-blocked .cockpit-status-main { border-left: 4px solid var(--blocked); border-radius: 0 12px 12px 0; }
.progress-track { width: 100%; height: 8px; margin: 8px 0 12px; border-radius: 999px; background: var(--border); overflow: hidden; }
.progress-fill { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--success) 0%, #6d8fdb 100%); transition: width .4s ease; }
.cold-progress-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.cold-progress-item { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 8px 10px; min-width: 0; }
.cold-progress-item.done { background: #ecfdf5; border-color: #6ee7b7; }
.cold-progress-item span, .strategy-card-copy span { display: block; color: var(--muted); font-size: .73rem; line-height: 1.25; font-weight: 500; }
.cold-progress-item strong { display: block; color: var(--text); font-size: .85rem; line-height: 1.25; margin-top: 3px; font-weight: 600; }
.cold-progress-item.done strong { color: var(--success); }
.cold-progress-item small { display: block; color: var(--hint); font-size: .72rem; line-height: 1.3; margin-top: 3px; overflow-wrap: anywhere; }

/* ─── Status badges ─────────────────────────────────────────────────── */
.status-badge { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 9px; border-radius: 6px; border: 1px solid var(--border); font-size: .77rem; font-weight: 600; background: var(--surface); color: var(--muted); }
.status-pass .status-badge, .status-ready .status-badge, .status-ok .status-badge { background: #ecfdf5; color: #0f6b54; border-color: #6ee7b7; }
.status-warning .status-badge, .status-warn .status-badge, .status-needs_review .status-badge, .status-not_ready .status-badge { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.status-blocked .status-badge, .status-fail .status-badge { background: #fef2f2; color: #9b1c1c; border-color: #fecaca; }
.status-pass, .status-ok, .status-ready { border-left: 3px solid var(--success); border-radius: 0 12px 12px 0; }
.status-warning, .status-warn, .status-needs_review, .status-not_ready { border-left: 3px solid var(--review); border-radius: 0 12px 12px 0; }
.status-blocked, .status-fail { border-left: 3px solid var(--blocked); border-radius: 0 12px 12px 0; }

/* ─── Signal chips ──────────────────────────────────────────────────── */
.signal-chip { display: inline-block; font-size: .74rem; padding: 2px 8px; border-radius: 99px; font-weight: 600; }
.signal-chip.ready { background: #ecfdf5; color: #0f6b54; border: 1px solid #6ee7b7; }
.signal-chip.watch { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.signal-chip.blocked { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }

/* ─── Boundary strip ────────────────────────────────────────────────── */
.boundary-strip { display: flex; flex-wrap: wrap; gap: 5px; padding: 7px 12px; margin-bottom: 14px; background: #f4f7fc; border: 1px solid var(--border); border-radius: 8px; }
.boundary-strip span { border: 1px solid #c8d9ef; background: var(--card); color: var(--blue); border-radius: 4px; padding: 2px 8px; font-size: .77rem; font-weight: 500; }
.boundary-notice { font-size: .77rem; color: var(--hint); padding: 4px 0 10px; line-height: 1.6; }

/* ─── Lineage flow ──────────────────────────────────────────────────── */
.lineage-flow { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.lineage-flow span { border: 1px solid #c8d9ef; background: #f0f6fe; color: var(--blue); border-radius: 4px; padding: 3px 9px; font-size: .80rem; font-weight: 500; }
.lineage-flow.compact span { padding: 2px 7px; font-size: .75rem; }

/* ─── Empty state ───────────────────────────────────────────────────── */
.empty-state { border: 1px dashed var(--border); background: var(--surface); border-radius: 8px; padding: 20px 16px; color: var(--muted); font-size: .85rem; text-align: center; }

/* ─── Mode toggle ───────────────────────────────────────────────────── */
.mode-toggle { display: inline-flex; gap: 3px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); padding: 3px; }
.mode-toggle button { min-height: 28px; padding: 4px 10px; border-radius: 5px; background: transparent; color: var(--muted); font-size: .79rem; font-weight: 400; border: none; cursor: pointer; }
.mode-toggle button.active { background: var(--nav); color: #fff; font-weight: 500; }

/* ─── Panel head ────────────────────────────────────────────────────── */
.panel-head { flex-wrap: wrap; display: flex; justify-content: space-between; align-items: center; gap: 10px; min-width: 0; }
.panel-head strong { min-width: 0; overflow-wrap:anywhere; }

/* ─── Metric tiles ──────────────────────────────────────────────────── */
.metric-tile { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.metric-tile .val { font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1.2; font-variant-numeric: tabular-nums; }
.metric-tile .lbl { font-size: .74rem; color: var(--hint); margin-top: 3px; font-weight: 500; }
.metric-tile .sub { font-size: .79rem; margin-top: 4px; }
.metric-tile.accent { border-left: 3px solid var(--blocked); border-radius: 0 12px 12px 0; }
.sub-pos { color: var(--success); } .sub-neg { color: var(--blocked); } .sub-warn { color: var(--review); } .sub-muted { color: var(--hint); }

/* ─── Pending banner ────────────────────────────────────────────────── */
.action-banner { background: #fef3c7; border: 1px solid #fcd34d; border-left: 4px solid var(--review); border-radius: 0 12px 12px 0; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.action-banner .msg { font-size: .87rem; color: var(--review); font-weight: 600; }
.action-banner .sub { font-size: .78rem; color: #b45309; margin-top: 2px; }
.action-banner .abtn { background: var(--nav); color: #fff; border-radius: 7px; padding: 7px 16px; font-size: .80rem; font-weight: 600; cursor: pointer; white-space: nowrap; flex-shrink: 0; border: none; text-decoration: none; display: inline-flex; align-items: center; }
.action-banner .abtn:hover { background: #0f2a44; text-decoration: none; }

/* ─── Gate chain (TEST REQUIRED) ───────────────────────────────────── */
.gate-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin: 10px 0; }
.gate-item { background: #f0fdf4; border-radius: 6px; padding: 6px 5px; text-align: center; }
.gate-item.fail { background: #fef2f2; } .gate-item.warn { background: #fef3c7; }
.gate-item .gname { font-size: .71rem; color: #166534; } .gate-item .gval { font-size: .80rem; font-weight: 500; color: #166534; margin-top: 2px; }
.gate-item.fail .gname, .gate-item.fail .gval { color: #9b1c1c; } .gate-item.warn .gname, .gate-item.warn .gval { color: #92400e; }
.gate-chain { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 10px 0; }
.gate-step { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 8px 10px; min-width: 0; }
.gate-step.status-pass { background: #ecfdf5; border-color: #6ee7b7; }
.gate-step.status-warn { background: #fef3c7; border-color: #fcd34d; }
.gate-step.status-fail { background: #fef2f2; border-color: #fecaca; }
.gate-step .gname { display: block; color: var(--muted); font-size: .72rem; line-height: 1.25; font-weight: 500; }
.gate-step .gval { display: block; color: var(--text); font-size: .80rem; line-height: 1.3; margin-top: 3px; overflow-wrap: anywhere; font-weight: 600; }

/* ─── Readable reasons (TEST REQUIRED) ─────────────────────────────── */
.readable-reasons { margin-top: 8px; }

/* ─── Record-only alert (TEST REQUIRED) ────────────────────────────── */
.record-only-alert { border: 1px solid #bfdbfe; background: #eff6ff; color: var(--text); border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; border-left: 4px solid #3b82f6; }
.record-only-alert strong { color: #1e40af; font-size: .92rem; }
.record-only-alert p { margin: 4px 0 0; color: var(--muted); font-size: .84rem; }

/* ─── Reason list ───────────────────────────────────────────────────── */
.reason-list { display: grid; gap: 7px; }
.reason-row { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--card); }
.reason-row p { margin: 5px 0 0; font-size: .86rem; overflow-wrap:anywhere; }
.reason-row span { display: inline-block; border: 1px solid var(--border); background: var(--surface); border-radius: 4px; padding: 2px 7px; color: var(--muted); font-size: .75rem; margin-top: 4px; }
.reason-list.compact { gap: 5px; }
.muted { color: var(--muted); }
.notice-text { margin-top: 8px; border-left: 3px solid var(--success); background: #ecfdf5; padding: 8px 12px; border-radius: 0 6px 6px 0; color: var(--success); font-size: .84rem; }

/* ─── Amount box ────────────────────────────────────────────────────── */
.amount-box { background: var(--surface); border-radius: 8px; padding: 10px 14px; margin: 10px 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--border); }
.amount-box .range { font-size: 1.18rem; font-weight: 700; color: var(--text); }
.amount-box .note { font-size: .75rem; color: var(--hint); text-align: right; }

/* ─── Summary list ──────────────────────────────────────────────────── */
.summary-list { display: grid; grid-template-columns: minmax(110px, .42fr) minmax(0, 1fr); gap: 5px 10px; }
.summary-list dt { font-weight: 500; color: var(--muted); font-size: .84rem; }
.summary-list dd { margin: 0; overflow-wrap: anywhere; font-size: .86rem; }

/* ─── Forms ─────────────────────────────────────────────────────────── */
label { display: block; margin: 10px 0; }
.lbl { display: block; font-size: .77rem; color: var(--muted); font-weight: 500; margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); font-size: .86rem; transition: border-color .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--success); box-shadow: 0 0 0 3px rgba(15,107,84,.12); }
textarea { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .80rem; }
button, .link-button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 36px; padding: 7px 16px; border: none; border-radius: 8px; background: var(--success); color: #fff; text-decoration: none; font-weight: 600; font-size: .84rem; cursor: pointer; transition: background .12s, box-shadow .12s; }
button:hover, .link-button:hover { background: #0a5443; text-decoration: none; }
button:focus, input:focus, select:focus, textarea:focus, a:focus { outline: 3px solid rgba(15,107,84,.2); outline-offset: 2px; }
.link-button.secondary { background: var(--nav); }
.link-button.secondary:hover { background: #0f2a44; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-outline:hover { background: var(--surface); color: var(--text); border-color: var(--success); }
.btn-sm { min-height: 28px; padding: 4px 10px; font-size: .77rem; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.inline-check { display: flex; align-items: center; gap: 8px; }
.inline-check input { width: auto; }
.stack-form { display: grid; gap: 8px; }
.stack-form label { margin: 0; }

/* ─── Watchlist cards ───────────────────────────────────────────────── */
.watchlist-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); transition: box-shadow .15s; }
.watchlist-card:hover { box-shadow: var(--shadow-md); }
.watchlist-card.status-pass, .watchlist-card.status-ready { border-left: 3px solid var(--success); border-radius: 0 12px 12px 0; }
.watchlist-card.status-warning, .watchlist-card.status-warn { border-left: 3px solid var(--review); border-radius: 0 12px 12px 0; }
.watchlist-card.status-blocked, .watchlist-card.status-fail, .watchlist-card.status-not_ready { border-left: 3px solid var(--border); border-radius: 0 12px 12px 0; opacity: .85; }
.wcard-sym { font-size: 1rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.wcard-name { font-size: .76rem; color: var(--muted); margin-top: 1px; margin-bottom: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strategy-card-row { display: grid; gap: 7px; margin-top: 9px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: #f5f3ff; border-color: #ddd6fe; }
.strategy-card-copy strong { display: block; color: #7c3aed; font-size: .84rem; line-height: 1.3; margin-top: 2px; overflow-wrap: anywhere; font-weight: 600; }
.strategy-card-copy small { display: block; color: var(--hint); font-size: .72rem; line-height: 1.3; margin-top: 3px; }
.strategy-inline-picker { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.wcard-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 7px; padding-top: 6px; border-top: 1px solid var(--border-light); }

/* ─── Table ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; font-size: .84rem; }
th { color: var(--muted); font-size: .77rem; font-weight: 600; background: var(--surface); letter-spacing: .02em; }
tr:last-child td { border-bottom: none; }

/* ─── Misc ──────────────────────────────────────────────────────────── */
.result, .operation-result { white-space: pre-wrap; overflow: auto; max-width: 100%; min-height: 44px; margin-top: 10px; background: #f2f5fa; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-family: ui-monospace, Consolas, monospace; font-size: .78rem; color: var(--muted); }
td pre, .advanced-panel pre { white-space: pre-wrap; overflow: auto; max-width: 100%; font-size: .75rem; }
#toast { display: none; position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); padding: 9px 18px; border-radius: 8px; font-size: .86rem; font-weight: 500; z-index: 9999; white-space: nowrap; pointer-events: none; }
#toast.success { background: #ecfdf5; color: var(--success); border: 1px solid #6ee7b7; }
#toast.error { background: #fef2f2; color: #9b1c1c; border: 1px solid #fecaca; }
.advanced-panel { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 10px; }
.advanced-only { display: none; }
html[data-view-mode="advanced"] .advanced-only { display: block; }
html[data-view-mode="advanced"] details.advanced-only { display: block; }
.reason-row > .advanced-only,
html[data-view-mode="advanced"] .reason-row > .advanced-only { display: none; }
.manual-record-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.manual-record-grid label { margin: 0; }
.manual-record-grid span { display: block; margin-bottom: 4px; color: var(--muted); font-size: .78rem; }
.manual-record-note { grid-column: 1 / -1; }
.narrow { max-width: 380px; margin: 40px auto; }
.operation-hero { padding: 14px 0 10px; }
.operation-shell { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; align-items: start; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.compact-form { max-width: 520px; }
.tip-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.runtime-pill { font-weight: 500; border: 1px solid var(--border); border-radius: 20px; padding: 4px 12px; background: var(--card); color: var(--blue); font-size: .82rem; }
.p3-staged-brief .metric-card { background: #fffbeb; border-color: #fde68a; }

/* ─── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .topbar { padding: 0 14px; }
  .page-hero, .hero, .validation-hero { display: block; }
  .cockpit-status-card { grid-template-columns: minmax(0, 1fr); }
  .hero-tools { align-items: flex-start; margin-top: 8px; flex-direction: row; flex-wrap: wrap; }
  .config-layout, .m10-layout, .m10-detail, .validation-layout, .runtime-grid, .tip-grid { grid-template-columns: minmax(0, 1fr); }
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
  .gate-chain { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media(max-width:520px) {
  .topbar { flex-wrap: wrap; align-items: center; padding: 0 10px 8px; }
  .brand { width: 100%; margin-right: 0; padding: 10px 0 4px; justify-content: center; }
  .topbar nav { flex-wrap: wrap; overflow-x: visible; width: 100%; flex: 0 0 100%; justify-content: center; }
  .topbar nav a { flex: 1 1 58px; justify-content: center; min-height: 38px; padding: 0 7px; }
  .nav-spacer { display: none; }
  .container { padding: 12px; }
  .page-hero, .hero, .card, .metric-card, .model-card, .price-map-card, .info-panel, .m10-panel, .validation-panel, .operation-panel { padding: 10px 12px; }
  .page-hero h1, .hero h1 { font-size: 1.1rem; }
  .mode-toggle { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .strategy-models-page .hero-tools { min-width: 0; width: 100%; align-items: stretch; }
  .strategy-models-page .hero-tools .link-button { width: 100%; }
  .button-row { display: grid; grid-template-columns: minmax(0, 1fr); }
  .action-row, .manual-record-grid { display: grid; grid-template-columns: minmax(0, 1fr); }
  th, td { padding: 7px 8px; }
  .table-wrap { overflow-x: visible; }
  .table-wrap table { min-width: 0; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap tr { border: 1px solid var(--border); border-radius: 10px; background: var(--card); margin-bottom: 8px; overflow: hidden; }
  .table-wrap td { display: grid; grid-template-columns: minmax(82px, .38fr) minmax(0, 1fr); gap: 8px; align-items: start; border-bottom: 1px solid var(--border-light); overflow-wrap: anywhere; }
  .table-wrap td:last-child { border-bottom: none; }
  .table-wrap td::before { content: attr(data-label); color: var(--muted); font-size: .74rem; font-weight: 600; }
  .table-wrap td:not([data-label])::before { content: ""; display: none; }
  .table-wrap td[colspan] { display: block; }
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
  .gate-grid { grid-template-columns: repeat(3, 1fr); }
  .container:has(.action-row[data-event-id]) { padding-bottom: 84px; }
  .action-row[data-event-id] {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 8px;
    z-index: 80;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin: 0;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(248, 250, 253, .97);
    box-shadow: 0 -6px 18px rgba(20, 32, 46, .14);
  }
  .action-row[data-event-id] button {
    min-height: 42px;
    padding: 6px 5px;
    font-size: .76rem;
    line-height: 1.2;
    white-space: normal;
  }
}
@media(max-width:375px) {
  body { overflow-x: hidden; }
  .container, .page-shell { max-width: 100%; }
  .section-grid, .metrics-row, .card-grid, .action-grid, .two-col { grid-template-columns: minmax(0, 1fr); }
  .event-first-screen { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .event-first-screen .metric-tile { padding: 8px; border-radius: 10px; }
  .event-first-screen .metric-tile .val { font-size: 1rem; overflow-wrap: anywhere; }
  .event-first-screen .metric-tile .sub { font-size: .72rem; line-height: 1.3; }
  .gate-chain { grid-template-columns: minmax(0, 1fr); }
  input, select, textarea, button { max-width: 100%; min-height:44px; }
  .boundary-strip span, .reason-row, .reason-row span, .footer { max-width: 100%; overflow-wrap:anywhere; }
  .cold-progress-grid, .strategy-inline-picker { grid-template-columns: minmax(0, 1fr); }
  .strategy-models-page .summary-list { grid-template-columns: minmax(0, 1fr); }
  .advanced-panel, pre, textarea { overflow-x:auto; }
}
