:root {
  color-scheme: light;
  --bg: #f3f7f4;
  --surface: #ffffff;
  --surface-soft: #f7faf8;
  --surface-strong: #edf5f0;
  --line: #d5e2da;
  --line-strong: #b7ccbf;
  --text: #17241c;
  --muted: #627167;
  --brand: #18a15f;
  --brand-strong: #0c7542;
  --brand-soft: #dff5e9;
  --yellow: #bd7b00;
  --red: #c6424e;
  --shadow: 0 18px 48px rgba(26, 63, 41, 0.1);
  --radius: 16px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1511;
  --surface: #131f18;
  --surface-soft: #0f1914;
  --surface-strong: #19291f;
  --line: #294033;
  --line-strong: #3b5b49;
  --text: #edf7f0;
  --muted: #9cb1a3;
  --brand: #46d386;
  --brand-strong: #73e7a5;
  --brand-soft: #163b27;
  --yellow: #f2bd55;
  --red: #ff7882;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 12% -12%, color-mix(in srgb, var(--brand) 14%, transparent), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}
button, input, select { font: inherit; }
.app { width: min(1900px, 100%); margin: auto; padding: 14px 20px 34px; }

.beta-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 9px 14px;
  border: 1px solid color-mix(in srgb, var(--brand) 42%, var(--line));
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 12px;
  line-height: 1.5;
}
.beta-notice strong { letter-spacing: 0.06em; white-space: nowrap; }

.header {
  position: sticky;
  top: 8px;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(420px, 1.4fr) minmax(280px, 1fr);
  align-items: center;
  gap: 12px 16px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.brand { min-width: 0; justify-self: start; }
.brand-lockup { display: block; flex: 0 0 155px; width: 155px; }
.brand-lockup-image { display: block; width: 100%; height: auto; }
.brand-lockup-dark { display: none; }
html[data-theme="dark"] .brand-lockup-light { display: none; }
html[data-theme="dark"] .brand-lockup-dark { display: block; }
.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  background: var(--brand);
  color: #072a16;
  font-size: 20px;
  font-weight: 950;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--brand) 30%, transparent);
}
.product-identity { min-width: 0; justify-self: center; text-align: center; }
.product-title-line { display: flex; align-items: center; justify-content: center; gap: 9px; }
.product-title-line h1 { margin: 0; font-size: 21px; letter-spacing: -0.02em; }
.product-subtitle, .brand-promise { margin: 2px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.version { padding: 3px 7px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--brand-strong); font-size: 10px; font-weight: 900; }
.global-controls { display: flex; align-items: center; justify-self: end; gap: 10px; }
.feedback-availability { max-width: 260px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.tabs, .calculator-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.workspace-toolbar { position: sticky; top: 104px; z-index: 30; display: flex; align-items: center; gap: 8px 12px; margin-top: 8px; padding: 8px; overflow: visible; border: 1px solid var(--line); border-radius: 11px; background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.workspace-toolbar.menu-open { z-index: 70; }
.navigation-bar { flex: 0 0 auto; }
button {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}
button:hover { border-color: var(--brand); transform: translateY(-1px); }
button:disabled { opacity: 0.48; cursor: not-allowed; transform: none; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
button.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); }
button.primary { border-color: var(--brand); background: var(--brand); color: #062615; }
button.danger { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); background: transparent; color: var(--red); }
button.large { padding: 12px 18px; font-size: 13px; }

.status { margin: 10px 2px -4px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font-size: 11px; }
.status.good { border-color: var(--brand); color: var(--brand-strong); }
.status.warn { border-color: var(--yellow); color: var(--yellow); }
.status.bad { border-color: var(--red); color: var(--red); }
.calculator-actions { position: relative; flex: 1 1 720px; justify-content: flex-end; min-width: 0; padding-left: 12px; overflow: visible; border-left: 1px solid var(--line); }
.saved-plan-hint { color: var(--muted); font-size: 10px; }
.plan-state-badge { margin-left: auto; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--brand-strong); font-size: 9px; font-weight: 900; letter-spacing: 0.05em; }
.more-menu { position: relative; }
.more-menu[open] { z-index: 2; }
.more-menu > summary { padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); font-size: 11px; font-weight: 850; cursor: pointer; list-style: none; }
.more-menu > summary::-webkit-details-marker { display: none; }
.more-menu[open] > summary { border-color: var(--brand); color: var(--brand-strong); }
.more-menu-panel { position: absolute; top: calc(100% + 7px); right: 0; z-index: 80; width: min(300px, calc(100vw - 32px)); max-height: min(560px, calc(100vh - 32px)); padding: 10px; overflow-y: auto; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24); }
.more-menu.open-up .more-menu-panel { top: auto; bottom: calc(100% + 7px); }
.more-menu-panel section { display: grid; gap: 6px; padding: 8px 0; border-top: 1px solid var(--line); }
.more-menu-panel section:first-child { padding-top: 0; border-top: 0; }
.more-menu-panel h3 { margin: 0 0 2px; color: var(--muted); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; }
.more-menu-panel button { width: 100%; text-align: left; }
.more-menu-panel .destructive-separator { margin-top: 6px; border-top-width: 2px; }
.mobile-plan-actions { display: grid !important; }
.sample-notice { margin-bottom: 10px; padding: 10px 12px; border: 1px solid var(--yellow); border-radius: 10px; background: color-mix(in srgb, var(--yellow) 9%, var(--surface)); color: var(--yellow); font-size: 11px; font-weight: 800; line-height: 1.55; }

.page { display: none; margin-top: 15px; }
.page.active { display: block; }
.panel { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface-strong); }
.panel-head h2, .panel-head h3 { margin: 0; }
.panel-head h2 { font-size: 17px; }
.panel-head h3 { font-size: 14px; }
.panel-head small { color: var(--muted); }
.panel-body { padding: 13px; }

.guide-hero { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(250px, 0.7fr); gap: 28px; align-items: center; padding: 32px; background: linear-gradient(120deg, var(--surface), var(--surface-strong)); }
.eyebrow { color: var(--brand-strong); font-size: 10px; font-weight: 950; letter-spacing: 0.14em; }
.guide-hero h2 { max-width: 780px; margin: 8px 0 10px; font-size: clamp(26px, 3vw, 44px); line-height: 1.12; letter-spacing: -0.04em; }
.guide-hero p { max-width: 900px; margin: 0; color: var(--muted); line-height: 1.8; }
.guide-hero .product-boundary {
  margin-top: 12px;
  padding-left: 12px;
  border-left: 3px solid var(--brand);
  color: var(--brand-strong);
  font-weight: 700;
}
.guide-purpose { margin-top: 12px; overflow: hidden; }
.purpose-lead { max-width: 1100px; margin: 0; color: var(--text); font-size: 13px; line-height: 1.8; }
.purpose-lead strong { color: var(--brand-strong); }
.pain-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.pain-grid article { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-strong); }
.pain-grid article > span { color: var(--warn); font-size: 9px; font-weight: 900; letter-spacing: 0.08em; }
.pain-grid h3 { margin: 6px 0 7px; font-size: 13px; }
.pain-grid p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.65; }
.purpose-contrast { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.purpose-contrast > div { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 11px; }
.purpose-contrast span { flex: 0 0 auto; padding: 4px 7px; border-radius: 999px; font-size: 9px; font-weight: 900; }
.purpose-contrast strong { min-width: 0; }
.purpose-contrast b { color: var(--muted); }
.contrast-old { background: var(--warn-soft); }
.contrast-old span { background: var(--warn); color: #fff; }
.contrast-new { background: var(--brand-soft); }
.contrast-new span { background: var(--brand); color: #fff; }
.purpose-summary { margin: 12px 0 0; padding: 11px 13px; border-left: 3px solid var(--brand); background: var(--brand-soft); color: var(--brand-strong); font-size: 12px; line-height: 1.7; }
.trust-stack { display: grid; gap: 8px; }
.trust-stack span { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--brand-strong); font-size: 11px; font-weight: 800; }
.trust-stack span::before { content: "✓"; margin-right: 8px; }

.guide-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.guide-card { min-height: 240px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.step-number { color: var(--brand); font-size: 12px; font-weight: 950; letter-spacing: 0.12em; }
.guide-card h3 { margin: 8px 0 10px; font-size: 16px; }
.guide-card p, .guide-card li { color: var(--muted); font-size: 12px; line-height: 1.7; }
.guide-card ol, .guide-card ul { margin: 0; padding-left: 18px; }
.guide-panel { margin-top: 12px; }
.flow-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); }
.flow-grid div { display: flex; align-items: center; gap: 10px; min-height: 78px; padding: 14px; background: var(--surface); }
.flow-grid b { display: grid; flex: 0 0 28px; height: 28px; place-items: center; border-radius: 50%; background: var(--brand-soft); color: var(--brand-strong); }
.flow-grid span { font-size: 12px; line-height: 1.55; }
.guide-terms { margin-top: 12px; overflow: hidden; }
.term-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.term-grid article { padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-strong); }
.term-grid article b { color: var(--brand-strong); font-size: 12px; }
.term-grid article p { margin: 6px 0 0; color: var(--muted); font-size: 10.5px; line-height: 1.6; }
.guide-grid-wide { grid-template-columns: 1.25fr 0.75fr; }
.example-card, .support-card { min-width: 0; }
.example-table { min-width: 540px; }
.callout { margin: 12px 0 0; padding: 10px 12px; border-left: 3px solid var(--brand); background: var(--brand-soft); color: var(--brand-strong); font-size: 11px; line-height: 1.65; }
.support-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.support-columns h3 { margin: 0 0 8px; font-size: 13px; }
.support-columns ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 11px; line-height: 1.75; }
.feedback-panel { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 12px; padding: 24px; }
.feedback-panel h2 { margin: 6px 0; font-size: 20px; }
.feedback-panel p { max-width: 960px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; }

.grid { display: grid; grid-template-columns: minmax(430px, 0.95fr) minmax(760px, 2.05fr); align-items: start; gap: 14px; }
.results-column { min-width: 0; }
.quick-workflow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin-bottom: 12px; }
.quick-workflow div { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-strong); }
.quick-workflow b { display: grid; flex: 0 0 24px; height: 24px; place-items: center; border-radius: 50%; background: var(--brand); color: #fff; font-size: 11px; }
.quick-workflow span { display: grid; min-width: 0; gap: 2px; }
.quick-workflow strong { font-size: 10.5px; }
.quick-workflow small { overflow: hidden; color: var(--muted); font-size: 9px; line-height: 1.35; text-overflow: ellipsis; }
.quick-mode [data-page="system"],
.quick-mode [data-page="discipline"],
.quick-mode .quick-advanced,
.quick-mode .quick-result-advanced,
.quick-mode .quick-result-detail { display: none !important; }
.quick-mode-card {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--brand) 42%, var(--line));
  border-radius: 12px;
  background: var(--brand-soft);
}
.quick-mode-card h3 { margin: 4px 0; font-size: 16px; }
.quick-mode-card p { margin: 0; color: var(--muted); font-size: 10.5px; line-height: 1.55; }
.quick-risk-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.quick-risk-inputs .field {
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}
.quick-risk-inputs input[aria-invalid="true"] { border-color: var(--red); box-shadow: 0 0 0 1px color-mix(in srgb, var(--red) 25%, transparent); }
.quick-risk-error { margin: 0; color: var(--red); font-size: 10px; font-weight: 700; line-height: 1.5; }
.quick-risk-confirm {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid color-mix(in srgb, var(--red) 55%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--red) 8%, var(--surface));
  color: var(--red);
  font-size: 10px;
  line-height: 1.5;
}
.quick-risk-confirm[hidden] { display: none; }
.quick-risk-confirm input { width: auto; margin-top: 2px; }
.quick-mode-card .quick-mode-notice {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--brand-strong);
  font-weight: 750;
}
.quick-mode-card .quick-mode-notice.warn { color: var(--yellow); }
.quick-mode .input-panel .metadata-grid,
.quick-mode .input-panel .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.quick-mode .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.quick-mode .quick-single-exit-metric { grid-column: span 2; }
.quick-mode .constraint-notice:not(.is-active-quick-constraint) { display: none; }
.section { margin: 0 0 9px; color: var(--text); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.metadata-grid { grid-template-columns: 1.2fr 1fr 0.8fr; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
label { color: var(--muted); font-size: 11px; font-weight: 850; }
.field > label:first-child, .metric .k { display: flex; align-items: center; gap: 5px; }
.field > label:first-child { min-height: 30px; align-items: flex-start; line-height: 1.35; }
input, select { width: 100%; padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); color: var(--text); outline: none; font-size: 13px; }
input:disabled { opacity: 0.7; cursor: not-allowed; background: var(--surface-strong); }
input.is-invalid, select.is-invalid { border-color: var(--red); box-shadow: 0 0 0 1px color-mix(in srgb, var(--red) 32%, transparent); }
.field-note { color: var(--muted); font-size: 9px; line-height: 1.4; }
.inline-check { min-height: 36px; display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); color: var(--text); font-size: 11px; }
.inline-check input { width: auto; }
.divider { height: 1px; margin: 13px 0; background: var(--line); }
.hint, .foot { color: var(--muted); font-size: 10.5px; line-height: 1.6; }
.sizing-guidance {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--brand) 32%, var(--line));
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.local-only-notice { margin-bottom: 0; }
.release-feedback-note { margin: 18px 0 0; padding: 12px; color: var(--muted); font-size: 10px; text-align: center; }

.help-trigger {
  display: inline-grid;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  place-items: center;
  border-color: color-mix(in srgb, var(--brand) 48%, var(--line));
  border-radius: 50%;
  color: var(--brand-strong);
  font-size: 10px;
  line-height: 1;
}
.help-trigger:hover { transform: none; }
.help-popover {
  position: fixed;
  z-index: 100;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
  color: var(--text);
}
.help-popover strong { display: block; color: var(--brand-strong); font-size: 13px; }
.help-popover p { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.help-popover .help-warning { color: var(--yellow); }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.metric { min-height: 76px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.metric .k { color: var(--muted); font-size: 10.5px; }
.metric .v { margin-top: 5px; font-size: 18px; font-weight: 950; white-space: nowrap; }
#mTrendNet, #mCombinedProfit, #mCombinedRR { white-space: normal; }
.metric .s { margin-top: 4px; color: var(--muted); font-size: 9.5px; }
.pnl-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 6px; }
.pnl-line span { color: var(--muted); font-size: 9.5px; }
.pnl-line strong { color: var(--brand-strong); font-size: 14px; font-weight: 950; line-height: 1.15; }
.pnl-line strong.red { color: var(--red); }
.position-amount-metric { min-height: 112px; }
.quick-leverage-line { display: grid; grid-template-columns: auto auto; align-items: baseline; gap: 2px 7px; margin-top: 7px; padding-top: 6px; border-top: 1px solid var(--line); }
.quick-leverage-line span { color: var(--muted); font-size: 9.5px; }
.quick-leverage-line strong { color: var(--brand-strong); font-size: 13px; }
.quick-leverage-line small { grid-column: 1 / -1; color: var(--muted); font-size: 8.5px; }
.actual-leverage-metric { border-color: color-mix(in srgb, var(--brand) 48%, var(--line)); background: var(--brand-soft); }
.constraint-notice {
  display: grid;
  gap: 3px;
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--yellow) 60%, var(--line));
  border-radius: 9px;
  background: color-mix(in srgb, var(--yellow) 9%, transparent);
  color: var(--yellow);
}
.constraint-notice strong { font-size: 11.5px; }
.constraint-notice span { font-size: 10px; line-height: 1.5; }
.green { color: var(--brand-strong); }
.yellow { color: var(--yellow); }
.red { color: var(--red); }

.risk-breakdown { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin-top: 10px; }
.risk-breakdown > div { min-width: 0; padding: 8px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.risk-breakdown span { display: block; color: var(--muted); font-size: 9.5px; }
.risk-breakdown strong { display: block; margin-top: 3px; font-size: 10.5px; line-height: 1.45; }
.risk-breakdown .wide-item { grid-column: span 2; }
.risk-breakdown .leverage-rule { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); background: var(--brand-soft); color: var(--brand-strong); }
.pills { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.pill { padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: 10.5px; }
.pill.good { border-color: var(--brand); color: var(--brand-strong); }
.pill.warn { border-color: var(--yellow); color: var(--yellow); }
.pill.bad { border-color: var(--red); color: var(--red); }

.table-wrap { max-width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 10.5px; }
th, td { padding: 8px 7px; border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.5; overflow-wrap: anywhere; }
th { background: var(--surface-strong); color: var(--text); text-align: left; }
th.wide { width: 18%; }
tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.build-table { min-width: 980px; }
.build-table .col-stage { width: 9%; }
.build-table .col-percent { width: 8%; }
.build-table .col-price { width: 11%; }
.build-table .col-money { width: 13%; }
.build-table .col-quantity { width: 13%; }
.build-table .col-condition { width: 20%; }
.build-table th, .build-table td { overflow-wrap: normal; word-break: normal; }
.build-table .num { white-space: nowrap; }
.strong { font-weight: 900; }
.risk-triplet { white-space: pre-line; color: var(--brand-strong); font-variant-numeric: tabular-nums; }

.alert { margin-top: 8px; padding: 8px 10px; border: 1px solid; border-radius: 9px; font-size: 10.5px; line-height: 1.55; }
.alert.good { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); }
.alert.warn { border-color: var(--yellow); background: color-mix(in srgb, var(--yellow) 10%, transparent); color: var(--yellow); }
.alert.bad { border-color: var(--red); background: color-mix(in srgb, var(--red) 9%, transparent); color: var(--red); }
.summary { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 14px; margin-top: 14px; }
.box { min-height: 120px; padding: 11px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.box h4 { margin: 0 0 7px; font-size: 13px; }
.box ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 10.5px; line-height: 1.7; }
.matrix { min-width: 1500px; }
.matrix th, .matrix td { padding: 9px 7px; }
.grade { font-size: 13px; font-weight: 950; }
.grade-c { color: var(--muted); }
.grade-b { color: #3985d0; }
.grade-a { color: var(--brand-strong); }
.grade-s { color: var(--yellow); }
.rule-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.rule-card { padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.rule-card h3 { margin: 0 0 8px; font-size: 14px; }
.rule-card table { font-size: 10.2px; }

@media (max-width: 1500px) {
  .header { position: static; }
  .workspace-toolbar { top: 8px; }
  .grid { grid-template-columns: minmax(390px, 0.95fr) minmax(650px, 1.55fr); }
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1180px) {
  .app { padding-inline: 14px; }
  .header { grid-template-columns: auto minmax(0, 1fr); }
  .product-identity { justify-self: start; text-align: left; }
  .product-title-line { justify-content: flex-start; }
  .global-controls { grid-column: 1 / -1; width: 100%; justify-content: space-between; }
  .workspace-toolbar { align-items: flex-start; flex-direction: column; }
  .navigation-bar { width: 100%; }
  .calculator-actions { flex-basis: auto; width: 100%; justify-content: flex-start; padding: 8px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .grid { grid-template-columns: 1fr; }
  .guide-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pain-grid, .term-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .purpose-contrast { grid-template-columns: 1fr; }
  .rule-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .input-panel .form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .quick-risk-inputs { grid-template-columns: 1fr; }
  .quick-workflow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-mode .input-panel .metadata-grid,
  .quick-mode .input-panel .form-grid,
  .quick-mode .metric-grid { grid-template-columns: 1fr; }
  .quick-mode .quick-single-exit-metric { grid-column: auto; }
  .app { padding: 8px 8px 24px; }
  .beta-notice { align-items: flex-start; justify-content: flex-start; border-radius: 10px; }
  .header { top: 0; grid-template-columns: minmax(0, 1fr) auto; padding: 11px; border-radius: 12px; }
  .brand { grid-column: 1; grid-row: 1; min-width: 0; }
  .brand-lockup { flex-basis: 138px; width: 138px; }
  .brand-mark { width: 34px; height: 34px; }
  .product-identity { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; text-align: left; }
  .product-title-line { justify-content: flex-start; }
  .product-title-line h1 { font-size: 18px; }
  .brand-promise { display: none; }
  .global-controls { grid-column: 2; grid-row: 1; width: auto; justify-content: flex-end; }
  .feedback-availability { display: none; }
  .workspace-toolbar { position: static; width: 100%; }
  .navigation-bar { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calculator-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
  .calculator-actions .desktop-frequent { display: none; }
  .calculator-actions .saved-plan-hint { grid-column: 1 / 3; grid-row: 2; align-self: center; }
  .calculator-actions .plan-state-badge { grid-column: 3; grid-row: 2; align-self: center; justify-self: end; margin-left: 0; }
  .mobile-plan-actions { display: grid !important; }
  .more-menu { position: static; grid-column: 3; grid-row: 1; }
  .more-menu > summary { min-height: 40px; display: grid; place-items: center; }
  .more-menu-panel { top: 52px; right: 8px; left: 8px; width: auto; }
  button { min-height: 40px; }
  .guide-hero { grid-template-columns: 1fr; padding: 20px; }
  .guide-hero h2 { font-size: 29px; }
  .guide-grid, .guide-grid-wide, .support-columns, .summary, .system-summary { grid-template-columns: 1fr; }
  .pain-grid, .term-grid { grid-template-columns: 1fr; }
  .purpose-contrast > div { align-items: flex-start; flex-wrap: wrap; }
  .guide-card { min-height: 0; }
  .flow-grid { grid-template-columns: 1fr; }
  .feedback-panel { align-items: stretch; flex-direction: column; padding: 18px; }
  .metadata-grid, .input-panel .form-grid, .form-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .risk-breakdown { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .risk-breakdown .wide-item { grid-column: span 2; }
  .rule-grid { grid-template-columns: 1fr; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .help-trigger { min-height: 18px; }
  .matrix { min-width: 1320px; }
  .example-table { min-width: 0; table-layout: fixed; }
  .example-table th:nth-child(1), .example-table td:nth-child(1) { width: 27%; }
  .example-table th:nth-child(2), .example-table td:nth-child(2) { width: 31%; }
  .example-table th, .example-table td { padding-inline: 5px; overflow-wrap: anywhere; word-break: break-word; }
  table:not(.matrix):not(.example-table) { min-width: 760px; }
  .rule-card table { min-width: 0; }
  .field > label:first-child { min-height: 0; }
}

@media print {
  @page { size: A3 landscape; margin: 8mm; }
  :root, html[data-theme="dark"] { color-scheme: light; --bg: #fff; --surface: #fff; --surface-soft: #fff; --surface-strong: #eee; --line: #aaa; --line-strong: #888; --text: #111; --muted: #444; --brand: #11834a; --brand-strong: #0a5e35; --brand-soft: #edf7f1; --yellow: #7a5700; --red: #9d2530; --shadow: none; }
  body { min-width: 0; background: #fff; color: #111; }
  .app { max-width: none; padding: 0; }
  .beta-notice { display: flex !important; margin: 0 0 3mm; padding: 2mm; }
  .status { display: none !important; }
  .header { position: static; display: flex !important; margin-bottom: 5mm; padding: 0 0 3mm; border: 0; border-bottom: 1px solid #aaa; border-radius: 0; background: #fff; box-shadow: none; }
  .navigation-bar, .global-controls, .calculator-actions, .header .brand-promise, .release-feedback-note { display: none !important; }
  .header .brand { flex: 0 0 145px; }
  .header .product-identity { flex: 1 1 auto; justify-self: auto; text-align: left; }
  .header .product-title-line { justify-content: flex-start; }
  .header .brand-lockup { flex-basis: 145px; width: 145px; }
  .header .brand-lockup-light { display: block !important; }
  .header .brand-lockup-dark { display: none !important; }
  .page { display: none !important; margin: 0; }
  .page.printing { display: block !important; }
  .panel, .rule-card, .guide-card { border-color: #aaa; background: #fff; box-shadow: none; break-inside: avoid; }
  .panel-head, th { background: #eee !important; color: #111; }
  input, select, .inline-check, .metric, .box, .pill, .risk-breakdown > div { border-color: #aaa; background: #fff; color: #111; }
  label, .hint, .foot, .box ul, .metric .k, .metric .s, .field-note { color: #444; }
  .feedback-panel button { display: none !important; }
  .help-trigger, .help-popover, .more-menu { display: none !important; }
  th, td { padding: 4px; border-color: #bbb; }
  table { font-size: 7.5pt; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; page-break-inside: avoid; }
  .table-wrap { overflow: visible; }
  .build-table { min-width: 0; table-layout: fixed; }
  .alert { color: #111 !important; background: #fff !important; }
  .constraint-notice { border-color: #aaa; background: #fff; color: #111; }

  #calc.printing .grid { grid-template-columns: 0.9fr 2.1fr; gap: 6px; }
  #calc.printing .panel + .panel { margin-top: 4px; }
  #calc.printing .panel-head { padding: 4px 6px; }
  #calc.printing .panel-head h2 { font-size: 11px; }
  #calc.printing .panel-head h3 { font-size: 9px; }
  #calc.printing .panel-body { padding: 5px; }
  #calc.printing .section { margin-bottom: 3px; font-size: 9px; }
  #calc.printing .form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px 4px; }
  #calc.printing .metadata-grid { grid-template-columns: 1.2fr 1fr 0.8fr; }
  #calc.printing .field { gap: 1px; }
  #calc.printing label { font-size: 7px; }
  #calc.printing input,
  #calc.printing select { padding: 2px 3px; border-radius: 3px; font-size: 8px; }
  #calc.printing .field-note { display: none; }
  #calc.printing .inline-check { min-height: 20px; padding: 2px 3px; font-size: 7px; }
  #calc.printing .divider { margin: 4px 0; }
  #calc.printing .hint { margin: 3px 0 0; font-size: 6.8px; line-height: 1.2; }
  #calc.printing .metric-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; }
  #calc.printing .metric { min-height: 42px; padding: 3px 5px; border-radius: 5px; }
  #calc.printing .metric .k { font-size: 6.8px; }
  #calc.printing .metric .v { margin-top: 1px; font-size: 10px; }
  #calc.printing .metric .s { margin-top: 1px; font-size: 6px; }
  #calc.printing .pnl-line strong { font-size: 8px; }
  #calc.printing .constraint-notice { gap: 1px; margin-top: 3px; padding: 2px 4px; border-radius: 4px; }
  #calc.printing .constraint-notice strong { font-size: 6.4px; }
  #calc.printing .constraint-notice span { font-size: 5.8px; line-height: 1.2; }
  #calc.printing .risk-breakdown { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; margin-top: 3px; }
  #calc.printing .risk-breakdown > div { padding: 2px 4px; border-radius: 4px; }
  #calc.printing .risk-breakdown span { font-size: 5.8px; }
  #calc.printing .risk-breakdown strong { margin-top: 0; font-size: 6.4px; line-height: 1.2; }
  #calc.printing .risk-breakdown .wide-item { grid-column: span 2; }
  #calc.printing .pills { gap: 2px; margin-top: 3px; }
  #calc.printing .pill { padding: 2px 4px; font-size: 6px; }
  #calc.printing .alert { margin-top: 2px; padding: 2px 4px; font-size: 6px; line-height: 1.2; }
  #calc.printing th,
  #calc.printing td { padding: 1px 2px; line-height: 1.15; }
  #calc.printing table { font-size: 6pt; }
  #calc.printing .summary { gap: 4px; margin-top: 4px; break-inside: avoid; page-break-inside: avoid; }
  #calc.printing .box { min-height: 50px; padding: 4px; break-inside: avoid; page-break-inside: avoid; }
  #calc.printing .box h4 { margin-bottom: 2px; font-size: 7px; }
  #calc.printing .box ul { padding-left: 10px; font-size: 6px; line-height: 1.25; }

  #system.printing .matrix { min-width: 0; font-size: 5.8pt; }
  #system.printing .matrix th,
  #system.printing .matrix td { padding: 3px; line-height: 1.25; }
  #system.printing .summary { gap: 6px; margin-top: 6px; }
  #system.printing .panel-head { padding: 5px 7px; }
  #system.printing .foot { margin: 4px 0 0; }

  #discipline.printing .panel-head { padding: 5px 7px; }
  #discipline.printing .rule-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; margin-top: 6px; }
  #discipline.printing .rule-card { padding: 6px; }
  #discipline.printing .rule-card h3 { margin-bottom: 3px; font-size: 8pt; }
  #discipline.printing .rule-card table { min-width: 0; font-size: 6.5pt; }

  #guide.printing .guide-hero { padding: 16px; }
  #guide.printing .guide-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #guide.printing .guide-card { min-height: 0; }
}
