/*
  Visual system
  Type: IBM Plex Sans / Microsoft YaHei, 36 / 28 / 22 / 18 / 15 / 13
  Palette: navy #0b2242, fog #f4f6f8, white #ffffff, semantic-only green/amber/red
  Rhythm: 8px base grid; section headers use compact eyebrow + strong title
  Surfaces: fine borders, 10px radius, almost no shadow
*/
:root {
  --navy-950: #07182f;
  --navy-900: #0b2242;
  --navy-800: #12345b;
  --navy-700: #1c4f82;
  --blue-500: #2e78c7;
  --blue-100: #e8f1fb;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #dfe5ec;
  --line-strong: #c9d2de;
  --text: #182538;
  --muted: #667386;
  --soft: #8b97a8;
  --good: #137a52;
  --good-bg: #e8f5ef;
  --warn: #a15c09;
  --warn-bg: #fff3dc;
  --risk: #b83333;
  --risk-bg: #fdecec;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(11, 34, 66, 0.06);
  font-family: "IBM Plex Sans", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(46, 120, 199, 0.24);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--navy-950); color: white; padding: 24px 16px 18px; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.22); border-radius: 8px; color: #9bc6f2; font: 700 15px/1 ui-monospace, monospace; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.brand-en { color: #8fa5bd; font-size: 10px; margin-top: 3px; letter-spacing: .04em; }
.nav { display: grid; gap: 6px; padding-top: 22px; }
.nav-btn { width: 100%; border: 0; background: transparent; color: #aebed0; min-height: 44px; border-radius: 8px; padding: 0 12px; text-align: left; display: flex; align-items: center; gap: 11px; }
.nav-btn:hover { color: white; background: rgba(255,255,255,.06); }
.nav-btn.active { color: white; background: #18395f; box-shadow: inset 3px 0 #6aaceb; }
.nav-icon { width: 22px; font: 700 12px/22px ui-monospace, monospace; color: #7fa7cd; text-align: center; }
.sidebar-foot { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid rgba(255,255,255,.1); color: #859aaf; font-size: 11px; line-height: 1.65; }

.main { min-width: 0; }
.topbar { height: 68px; display: flex; align-items: center; gap: 16px; padding: 0 32px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 15; backdrop-filter: blur(8px); }
.topbar-title { font-size: 14px; color: var(--muted); }
.topbar-title strong { color: var(--text); font-weight: 650; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.content { padding: 28px 32px 48px; max-width: 1540px; margin: 0 auto; }

.btn { border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); min-height: 40px; border-radius: 8px; padding: 0 15px; font-weight: 650; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:hover { border-color: #9eacbd; background: var(--surface-2); }
.btn.primary { color: white; background: var(--navy-800); border-color: var(--navy-800); }
.btn.primary:hover { background: var(--navy-700); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--navy-700); }
.btn.danger { color: var(--risk); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 12px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.eyebrow { color: var(--blue-500); font: 700 11px/1 ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 9px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 7px; color: var(--navy-950); font-size: 28px; line-height: 1.25; letter-spacing: -.025em; text-wrap: balance; }
h2 { margin-bottom: 16px; color: var(--navy-950); font-size: 20px; letter-spacing: -.015em; }
h3 { margin-bottom: 10px; font-size: 15px; }
.subtitle { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 28px 0 14px; }
.section-head h2 { margin: 0; }
.section-note { color: var(--muted); font-size: 12px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-pad { padding: 22px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 17px 17px 15px; min-height: 152px; transition: border-color .15s, transform .15s; text-align: left; position: relative; }
.metric-card:hover { border-color: #aebcca; transform: translateY(-1px); }
.metric-top { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.metric-name { color: var(--muted); font-size: 13px; font-weight: 650; }
.help-dot { width: 22px; height: 22px; border: 1px solid var(--line); border-radius: 50%; display: grid; place-items: center; color: var(--muted); font-size: 11px; background: var(--surface-2); }
.metric-value { font-size: 29px; line-height: 1.1; font-weight: 700; color: var(--navy-950); letter-spacing: -.035em; margin: 15px 0 9px; font-variant-numeric: tabular-nums; }
.metric-foot { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.metric-comment { color: var(--muted); font-size: 11px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { display: inline-flex; align-items: center; min-height: 23px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status.good { color: var(--good); background: var(--good-bg); }
.status.warn { color: var(--warn); background: var(--warn-bg); }
.status.risk { color: var(--risk); background: var(--risk-bg); }
.status.neutral { color: #526175; background: #eef2f6; }

.dashboard-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(330px, .6fr); gap: 14px; margin-top: 14px; }
.score-layout { display: grid; grid-template-columns: 180px minmax(0,1fr); gap: 24px; align-items: center; }
.score-ring { width: 166px; height: 166px; border-radius: 50%; display: grid; place-items: center; position: relative; background: conic-gradient(var(--navy-700) var(--score), #e8edf2 0); }
.score-ring::after { content: ""; position: absolute; inset: 13px; border-radius: 50%; background: white; }
.score-number { position: relative; z-index: 1; text-align: center; }
.score-number strong { display: block; font-size: 38px; line-height: 1; letter-spacing: -.04em; color: var(--navy-950); }
.score-number span { font-size: 11px; color: var(--muted); }
.dimension-list { display: grid; gap: 11px; }
.dimension-row { display: grid; grid-template-columns: 76px 1fr 28px; gap: 10px; align-items: center; font-size: 12px; }
.bar { height: 7px; border-radius: 99px; background: #edf1f5; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--navy-700); border-radius: inherit; }
.dimension-row strong { text-align: right; font-size: 12px; }
.risk-list { display: grid; gap: 10px; }
.risk-item { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 13px 14px; display: grid; grid-template-columns: 8px 1fr; gap: 12px; align-items: start; }
.risk-signal { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--soft); }
.risk-signal.good { background: var(--good); }.risk-signal.warn { background: var(--warn); }.risk-signal.risk { background: var(--risk); }
.risk-item strong { display: block; font-size: 12px; margin-bottom: 4px; }
.risk-item p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.analysis-copy { color: #3a485b; line-height: 1.9; font-size: 14px; }
.analysis-copy p:last-child { margin-bottom: 0; }
.disclaimer { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; color: var(--soft); font-size: 11px; line-height: 1.6; }

.form-shell { display: grid; grid-template-columns: 190px minmax(0,1fr); gap: 18px; align-items: start; }
.form-nav { position: sticky; top: 92px; padding: 10px; }
.form-nav button { width: 100%; border: 0; background: transparent; color: var(--muted); text-align: left; min-height: 40px; border-radius: 7px; padding: 0 11px; font-size: 12px; }
.form-nav button.active { background: var(--blue-100); color: var(--navy-800); font-weight: 700; }
.form-nav button:hover { color: var(--navy-800); }
.form-area { padding: 24px; }
.form-section { display: none; }
.form-section.active { display: block; }
.form-intro { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.form-intro h2 { margin-bottom: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); column-gap: 30px; row-gap: 16px; }
.field label { display: flex; min-height: 22px; justify-content: space-between; align-items: center; gap: 8px; color: #455367; font-size: 12px; font-weight: 620; margin-bottom: 6px; }
.field .optional { color: var(--soft); font-size: 10px; font-weight: 500; }
.input-wrap { display: flex; align-items: center; background: white; border: 1px solid var(--line-strong); border-radius: 7px; overflow: hidden; transition: box-shadow .15s, border-color .15s; }
.input-wrap:focus-within { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(46,120,199,.1); }
.input-wrap input { width: 100%; border: 0; outline: 0; height: 40px; padding: 0 11px; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.input-wrap span { color: var(--soft); background: var(--surface-2); align-self: stretch; min-width: 48px; padding: 0 8px; display: grid; place-items: center; font-size: 11px; border-left: 1px solid var(--line); }
.meta-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.text-input, .select-input { width: 100%; height: 40px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 0 11px; color: var(--text); background: white; }
.validation-box { margin-bottom: 18px; padding: 14px 16px; border: 1px solid #ead2a6; background: #fff9ed; border-radius: 8px; color: #7e5219; font-size: 12px; line-height: 1.65; }
.validation-box strong { display: block; margin-bottom: 5px; }

.calc-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.calc-card { padding: 20px; }
.calc-card .amount { font-size: 25px; font-weight: 720; letter-spacing: -.03em; color: var(--navy-950); margin: 13px 0 4px; font-variant-numeric: tabular-nums; }
.calc-card p { color: var(--muted); font-size: 11px; line-height: 1.55; margin-bottom: 0; }
.scenario { display: grid; grid-template-columns: minmax(300px,.7fr) minmax(0,1.3fr); gap: 14px; margin-top: 14px; }
.calc-inputs { padding: 22px; display: grid; gap: 16px; }
.result-table { width: 100%; border-collapse: collapse; }
.result-table th, .result-table td { padding: 12px 8px; border-bottom: 1px solid var(--line); font-size: 12px; text-align: left; }
.result-table th { color: var(--muted); font-weight: 600; }
.result-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.compare-chart { height: 180px; display: flex; align-items: end; gap: 30px; padding: 20px 24px 0; border-bottom: 1px solid var(--line); }
.chart-column { flex: 1; display: grid; align-items: end; height: 100%; text-align: center; }
.chart-column i { width: min(72px, 80%); min-height: 4px; margin: 0 auto; background: var(--navy-700); border-radius: 5px 5px 0 0; position: relative; }
.chart-column i.alt { background: #9db4ca; }
.chart-column i b { position: absolute; width: 140px; left: 50%; transform: translateX(-50%); top: -23px; font-size: 10px; color: var(--muted); }
.chart-column span { font-size: 10px; color: var(--muted); padding-top: 7px; }

.history-list { display: grid; gap: 10px; }
.history-row { padding: 15px 17px; display: grid; grid-template-columns: minmax(0,1fr) 120px 120px 116px; gap: 16px; align-items: center; }
.history-row strong { display: block; font-size: 13px; margin-bottom: 4px; }
.history-row small { color: var(--muted); }
.history-stat { color: var(--muted); font-size: 11px; }
.history-stat b { display: block; color: var(--text); margin-top: 3px; font-size: 13px; }
.empty { min-height: 300px; display: grid; place-items: center; text-align: center; padding: 40px; }
.empty strong { display: block; margin-bottom: 8px; }
.empty p { color: var(--muted); font-size: 13px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(4,14,29,.56); z-index: 80; display: grid; place-items: center; padding: 20px; }
.modal { width: min(650px,100%); max-height: 88vh; overflow: auto; background: white; border-radius: 12px; box-shadow: 0 28px 80px rgba(5,18,37,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 19px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: white; }
.modal-head h2 { margin: 0; font-size: 18px; }
.close { width: 36px; height: 36px; border: 0; background: var(--surface-2); border-radius: 50%; color: var(--muted); font-size: 20px; }
.modal-body { padding: 22px; }
.formula-block { background: var(--navy-950); color: #e9f2fb; border-radius: 8px; padding: 17px; font: 13px/1.7 ui-monospace, "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; }
.process-grid { display: grid; gap: 10px; margin-top: 18px; }
.process-row { display: flex; justify-content: space-between; gap: 18px; padding-bottom: 10px; border-bottom: 1px solid var(--line); font-size: 12px; }
.process-row span { color: var(--muted); }
.missing { padding: 13px 14px; background: var(--warn-bg); color: #805214; border-radius: 7px; font-size: 12px; line-height: 1.6; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; padding: 13px 16px; background: var(--navy-950); color: white; border-radius: 8px; box-shadow: 0 12px 40px rgba(0,0,0,.2); font-size: 12px; animation: toast-in .2s ease-out; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.mobile-menu { display: none; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dashboard-row, .scenario { grid-template-columns: 1fr; }
  .calc-grid { grid-template-columns: 1fr; }
}
@media (max-width: 840px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; position: fixed; width: 250px; }
  .sidebar.open { display: flex; }
  .mobile-menu { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 22px 16px 40px; }
  .form-shell { grid-template-columns: 1fr; }
  .form-nav { position: static; display: flex; overflow-x: auto; }
  .form-nav button { min-width: max-content; padding: 0 13px; }
  .form-grid, .meta-grid { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .metric-grid { grid-template-columns: 1fr; }
  .score-layout { grid-template-columns: 1fr; justify-items: center; }
  .dimension-list { width: 100%; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .topbar-title { display: none; }
  .history-row { grid-template-columns: 1fr; }
}
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; max-width: none; }
  .panel, .metric-card { box-shadow: none; break-inside: avoid; }
  body { background: white; }
}
