:root {
  --background: #f4f3ee;
  --card: #fffef9;
  --foreground: #17211c;
  --muted-foreground: #68726c;
  --muted: #eeeee8;
  --border: #dcded7;
  --sidebar: #14231d;
  --sidebar-foreground: #edf2ed;
  --sidebar-muted: #9fb0a6;
  --primary: #1f684b;
  --primary-foreground: #ffffff;
  --accent: #b78a3e;
  --success: #257153;
  --warning: #a2691d;
  --danger: #a33e35;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(23 33 28 / 6%), 0 12px 30px rgb(23 33 28 / 5%);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--foreground); background: var(--background); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button, label.file-button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: clamp(1.45rem, 2vw, 1.9rem); letter-spacing: -.035em; }
h2 { margin-bottom: 5px; font-size: clamp(1.45rem, 2vw, 1.85rem); letter-spacing: -.035em; }
h3 { margin-bottom: 3px; font-size: 1.05rem; letter-spacing: -.015em; }
p { margin-bottom: 0; color: var(--muted-foreground); line-height: 1.55; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; display: flex; width: 252px; flex-direction: column; padding: 24px 16px 18px; color: var(--sidebar-foreground); background: var(--sidebar); border-right: 1px solid rgb(255 255 255 / 8%); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; color: #16221d; background: var(--accent); border-radius: 8px; font-family: var(--mono); font-size: 12px; font-weight: 800; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 14px; }
.brand span { margin-top: 2px; color: var(--sidebar-muted); font-size: 11px; }
.sidebar-nav { display: grid; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; color: var(--sidebar-muted); border-radius: 7px; text-decoration: none; font-size: 13px; font-weight: 650; }
.nav-item span { color: #778c80; font-family: var(--mono); font-size: 10px; }
.nav-item:hover { color: var(--sidebar-foreground); background: rgb(255 255 255 / 6%); }
.nav-item.active { color: #fff; background: rgb(255 255 255 / 10%); box-shadow: inset 3px 0 var(--accent); }
.sidebar-note { display: flex; gap: 9px; margin-top: auto; padding: 13px 10px; background: rgb(255 255 255 / 5%); border: 1px solid rgb(255 255 255 / 7%); border-radius: 8px; }
.sidebar-note strong, .sidebar-note small { display: block; }
.sidebar-note strong { font-size: 11px; }
.sidebar-note small { margin-top: 4px; color: var(--sidebar-muted); font-size: 10px; line-height: 1.4; }
.status-dot { width: 7px; height: 7px; margin-top: 4px; flex: 0 0 auto; background: #69b892; border-radius: 50%; box-shadow: 0 0 0 3px rgb(105 184 146 / 12%); }
.worker-link { margin-top: 12px; color: #82968a; font-family: var(--mono); font-size: 9px; text-align: center; text-decoration: none; }

.workspace { min-width: 0; margin-left: 252px; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 24px; min-height: 92px; padding: 17px 30px; background: rgb(244 243 238 / 92%); border-bottom: 1px solid var(--border); backdrop-filter: blur(16px); }
.topbar-title { min-width: 260px; margin-right: auto; }
.topbar-title p { font-size: 12px; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.eyebrow { display: block; margin-bottom: 5px; color: var(--primary); font-family: var(--mono); font-size: 9px; font-weight: 800; letter-spacing: .13em; }
.save-status { padding-right: 7px; color: var(--muted-foreground); font-size: 11px; white-space: nowrap; }
.save-status.dirty { color: var(--warning); }
.button, .icon-button { min-height: 36px; padding: 8px 12px; color: var(--foreground); background: var(--card); border: 1px solid var(--border); border-radius: 7px; font-size: 12px; font-weight: 700; box-shadow: 0 1px 1px rgb(23 33 28 / 4%); }
.button:hover, .icon-button:hover { border-color: #bdc2ba; background: #faf9f4; }
.button.primary { color: var(--primary-foreground); background: var(--primary); border-color: var(--primary); }
.button.subtle-danger { color: var(--danger); }
.file-button { display: inline-flex; align-items: center; }
.icon-button { width: 38px; padding: 0; }
.menu-button { display: none; }

main { width: min(1580px, 100%); margin: 0 auto; padding: 24px 30px 90px; }
.notice { padding: 11px 14px; color: #6b5528; background: #fbf5e8; border: 1px solid #e8d6ad; border-radius: 8px; font-size: 12px; line-height: 1.5; }
.notice strong { margin-right: 5px; }
.page-section { padding-top: 34px; scroll-margin-top: 92px; }
.hero-section { padding-top: 27px; }
.section-heading, .panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.section-heading { margin-bottom: 16px; }
.section-heading p, .panel-heading p { font-size: 12px; }
.as-of { color: var(--muted-foreground); font-family: var(--mono); font-size: 10px; }
.text-link { color: var(--primary); font-size: 12px; font-weight: 750; text-decoration: none; }

.panel { margin-bottom: 14px; padding: 18px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel.flush { padding: 0; overflow: hidden; }
.panel-heading { margin-bottom: 15px; }
.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.summary-card { position: relative; min-height: 114px; padding: 15px; overflow: hidden; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.summary-card::before { position: absolute; inset: 0 auto 0 0; width: 3px; content: ""; background: var(--accent); }
.summary-card .label { color: var(--muted-foreground); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.summary-card .value { margin: 11px 0 5px; font-family: var(--mono); font-size: clamp(1.15rem, 1.8vw, 1.55rem); font-weight: 800; letter-spacing: -.045em; }
.summary-card .hint { color: var(--muted-foreground); font-size: 9px; line-height: 1.4; }
.overview-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 14px; }

.completeness { display: grid; gap: 13px; }
.progress-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.progress-head strong { font-family: var(--mono); font-size: 24px; }
.progress-head span { color: var(--muted-foreground); font-size: 11px; }
.progress-track { height: 7px; overflow: hidden; background: var(--muted); border-radius: 999px; }
.progress-bar { height: 100%; background: var(--primary); border-radius: inherit; transition: width .2s ease; }
.missing-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px; margin: 0; padding: 0; list-style: none; }
.missing-list li { color: var(--muted-foreground); font-size: 11px; }
.missing-list li::before { margin-right: 7px; color: var(--warning); content: "○"; }

.knowledge-list { display: grid; grid-template-columns: repeat(2, minmax(260px, 1fr)); gap: 0 22px; }
.knowledge-item { display: grid; grid-template-columns: 72px 1fr; gap: 10px; align-items: start; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 12px; line-height: 1.45; }
.checklist { display: grid; max-height: 230px; gap: 7px; margin: 0; padding-left: 20px; overflow: auto; color: var(--muted-foreground); font-size: 11px; line-height: 1.4; }

.badge { display: inline-flex; width: max-content; align-items: center; padding: 4px 7px; color: var(--muted-foreground); background: var(--muted); border: 1px solid var(--border); border-radius: 999px; font-family: var(--mono); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.badge.verified, .badge.known { color: var(--success); background: #edf7f1; border-color: #cfe5d7; }
.badge.assumed { color: var(--warning); background: #fbf4e6; border-color: #ead8b4; }
.badge.missing, .badge.review { color: var(--danger); background: #fbeeed; border-color: #eccdca; }
.rule-quality { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }

.form-grid { display: grid; grid-template-columns: repeat(4, minmax(170px, 1fr)); gap: 12px; }
.field { display: grid; min-width: 0; gap: 6px; }
.field label, .dialog-form label { color: #4f5b54; font-size: 10px; font-weight: 800; letter-spacing: .025em; }
.field small { color: var(--muted-foreground); font-size: 9px; }
input, select, textarea { width: 100%; min-height: 35px; padding: 7px 9px; color: var(--foreground); background: #fff; border: 1px solid var(--border); border-radius: 6px; outline: none; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(31 104 75 / 12%); outline: none; }
input[aria-invalid="true"] { background: #fff7f5; border-color: var(--danger); }
textarea { min-height: 84px; resize: vertical; }
.pension-card { display: grid; grid-template-columns: 1.15fr repeat(4, 1fr) 1.5fr auto; gap: 8px; align-items: end; margin-bottom: 8px; padding: 12px; background: #f8f8f3; border: 1px solid var(--border); border-radius: 8px; }

.topics { display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 8px; }
details.topic { background: #f9f9f4; border: 1px solid var(--border); border-radius: 7px; }
details.topic summary { padding: 10px 12px; cursor: pointer; font-size: 12px; font-weight: 800; }
.topic-content { padding: 0 12px 12px; color: var(--muted-foreground); font-size: 11px; line-height: 1.45; }
.topic-content p { font-size: 11px; }
.topic-content ul { margin-bottom: 0; padding-left: 17px; }
.topic-content li { margin: 6px 0; }

.filters { display: grid; grid-template-columns: minmax(280px, 2fr) 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: 7px; }
.panel.flush .table-wrap { border: 0; border-radius: 0; }
.data-table { width: 100%; min-width: 940px; border-collapse: collapse; }
.data-table th, .data-table td { height: 40px; padding: 7px 9px; font-size: 11px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
.data-table th:first-child, .data-table td:first-child, .data-table .left { text-align: left; }
.data-table thead th { position: sticky; top: 0; z-index: 2; color: #55615a; background: #f0f1eb; font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: .04em; }
.data-table tbody tr:hover { background: #fafaf6; }
.editable-table input, .editable-table select, .editable-table textarea { min-width: 92px; min-height: 30px; padding: 5px 7px; font-size: 10px; }
.editable-table textarea { width: 220px; min-height: 48px; }
.rules-wrap { max-height: 650px; }
.rules-wrap .data-table { min-width: 1750px; }
.settings-wrap { max-height: 560px; }
.settings-wrap .data-table { min-width: 1550px; }
.dependency-list { width: 320px; min-width: 320px; max-width: 380px; white-space: normal !important; }
.dependency-chip { display: inline-block; margin: 2px; padding: 3px 5px; color: var(--primary); background: #edf4f0; border: 1px solid #c9ddd2; border-radius: 4px; font-family: var(--mono); font-size: 8px; }
.cell-id { width: 126px; font-family: var(--mono); }
.cell-subject { width: 100px; }
.cell-name { width: 245px; }
.cell-value { width: 170px; }
.cell-source { width: 150px; }
.cell-url { width: 220px; }
.table-action { width: 30px; min-height: 30px; padding: 0; color: var(--danger); background: transparent; border: 0; border-radius: 5px; font-size: 16px; }
.projection-wrap { max-height: 560px; }
.projection-table th:first-child, .projection-table td:first-child { position: sticky; left: 0; z-index: 3; background: var(--card); font-weight: 700; }
.projection-table thead th:first-child { background: #f0f1eb; }
.negative { color: var(--danger); }
.positive { color: var(--success); }
.muted { color: var(--muted-foreground); font-size: 9px; font-weight: 400; }

.segmented { display: inline-flex; overflow: hidden; border: 1px solid var(--border); border-radius: 7px; }
.segmented button { min-height: 34px; padding: 7px 10px; color: var(--muted-foreground); background: var(--card); border: 0; border-right: 1px solid var(--border); font-size: 10px; }
.segmented button:last-child { border-right: 0; }
.segmented button.active { color: var(--primary); background: #edf4f0; font-weight: 800; }
.scenario-tabs { display: flex; gap: 6px; margin-bottom: 15px; overflow-x: auto; }
.scenario-tab { padding: 8px 11px; color: var(--muted-foreground); background: transparent; border: 1px solid var(--border); border-radius: 6px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.scenario-tab.active { color: var(--primary); background: #edf4f0; border-color: #b9d2c5; }
.scenario-editor-grid { display: grid; grid-template-columns: repeat(4, minmax(190px, 1fr)); gap: 9px; }
.scenario-control { padding: 12px; background: #f8f8f3; border: 1px solid var(--border); border-radius: 7px; }
.control-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.control-head strong { font-size: 10px; }
.control-head output { color: var(--primary); font-family: var(--mono); font-size: 10px; font-weight: 800; }
input[type="range"] { min-height: auto; padding: 0; accent-color: var(--primary); }
.event-box { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.scenario-cards { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 10px; margin-bottom: 14px; }
.scenario-card { padding: 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.scenario-card h3 { margin-bottom: 9px; }
.metric-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 10px; }
.metric-row:last-child { border: 0; }
.metric-row strong { font-family: var(--mono); }

dialog { padding: 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 24px 80px rgb(0 0 0 / 28%); }
dialog::backdrop { background: rgb(12 22 17 / 58%); backdrop-filter: blur(3px); }
.dialog-form { width: min(680px, calc(100vw - 30px)); padding: 22px; }
.dialog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 17px; }
.dialog-grid label { display: grid; gap: 5px; }
.span-2 { grid-column: span 2; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 1350px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .scenario-cards { grid-template-columns: repeat(3, 1fr); }
  .scenario-editor-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: repeat(3, 1fr); }
  .pension-card { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1050px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 12px 0 40px rgb(0 0 0 / 22%); }
  .workspace { margin-left: 0; }
  .menu-button { display: block; flex: 0 0 auto; }
  .topbar { padding-inline: 18px; }
  main { padding-inline: 18px; }
  .overview-grid { grid-template-columns: 1fr; }
  .topics { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .topbar { position: static; align-items: flex-start; flex-wrap: wrap; }
  .topbar-title { flex: 1; min-width: 220px; }
  .header-actions { width: 100%; justify-content: flex-start; }
  .save-status { width: 100%; }
  main { padding: 14px 12px 60px; }
  .page-section { padding-top: 28px; scroll-margin-top: 0; }
  .summary-grid, .scenario-cards, .scenario-editor-grid, .event-box, .form-grid, .knowledge-list, .missing-list { grid-template-columns: 1fr; }
  .topics { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: 1fr; }
  .pension-card { grid-template-columns: 1fr 1fr; }
  .section-heading { align-items: stretch; flex-direction: column; }
}
@media (max-width: 470px) {
  .summary-grid, .topics, .pension-card, .dialog-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
