:root {
  font-family: Inter, "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  color: #17201d;
  background: #f4f6f4;
  font-synthesis: none;
  --ink: #17201d;
  --muted: #66716d;
  --line: #d9dfdc;
  --soft: #eef2ef;
  --panel: #ffffff;
  --accent: #1e6a51;
  --accent-strong: #14513d;
  --accent-soft: #e7f1ec;
  --warn: #9a6512;
  --warn-bg: #fff7e7;
  --danger: #9e3434;
  --danger-bg: #fff0f0;
  --info-bg: #eef6ff;
  --shadow: 0 1px 2px rgb(18 31 25 / 5%), 0 8px 24px rgb(18 31 25 / 5%);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #f4f6f4; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: #fcfdfc; border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 18px; z-index: 10; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 6px 14px; border-bottom: 1px solid var(--line); }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: var(--accent); color: white; display: grid; place-items: center; font-weight: 800; letter-spacing: -.04em; }
.brand-title { font-size: 14px; font-weight: 800; line-height: 1.3; }
.brand-sub { color: var(--muted); font-size: 10px; margin-top: 2px; }
.nav { display: grid; gap: 3px; }
.nav button { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: transparent; color: #49534f; border-radius: 7px; padding: 9px 10px; text-align: left; font-size: 13px; }
.nav button:hover { background: var(--soft); }
.nav button.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }
.nav-index { font-variant-numeric: tabular-nums; font-size: 10px; color: #89938f; width: 18px; }
.sidebar-footer { margin-top: auto; font-size: 10px; color: var(--muted); line-height: 1.5; padding: 10px 6px; }
.main-shell { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 9; display: flex; align-items: center; gap: 10px; padding: 10px 18px; min-height: 58px; border-bottom: 1px solid var(--line); background: rgb(252 253 252 / 94%); backdrop-filter: blur(10px); }
.project-select { min-width: 230px; max-width: 360px; border: 1px solid var(--line); background: white; border-radius: 7px; padding: 7px 10px; }
.topbar-spacer { flex: 1; }
.save-state { font-size: 11px; color: var(--muted); white-space: nowrap; }
.btn { border: 1px solid var(--line); background: white; color: var(--ink); border-radius: 7px; padding: 7px 10px; font-size: 12px; font-weight: 600; }
.btn:hover { border-color: #b7c0bc; background: #fafcfa; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--danger); }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; padding: 18px; max-width: 1540px; margin: 0 auto; align-items: start; }
.workspace { min-width: 0; }
.summary-rail { position: sticky; top: 76px; display: grid; gap: 12px; }
.page-title { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 14px; }
.page-title h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.page-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.section { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden; }
.section-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--line); background: #fbfcfb; }
.section-head h2 { margin: 0; font-size: 13px; }
.section-body { padding: 14px; }
.section-help { font-size: 10px; color: var(--muted); }
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field { display: grid; gap: 5px; align-content: start; }
.field > label, .field-label { color: #4f5955; font-size: 11px; font-weight: 650; }
.field small { color: var(--muted); font-size: 10px; line-height: 1.45; }
.input, .select, .textarea { width: 100%; border: 1px solid #cfd6d2; border-radius: 6px; background: white; color: var(--ink); padding: 7px 8px; min-height: 34px; outline: none; }
.input:focus, .select:focus, .textarea:focus { border-color: #7aa893; box-shadow: 0 0 0 2px #e5f1eb; }
.textarea { min-height: 74px; resize: vertical; }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline > * { min-width: 0; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.data-table th { text-align: left; font-weight: 700; color: #54605b; background: #f7f9f7; border-bottom: 1px solid var(--line); padding: 7px 8px; white-space: nowrap; }
.data-table td { border-bottom: 1px solid #edf0ee; padding: 7px 8px; vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.compact-input { border: 1px solid #d6dcd9; border-radius: 5px; padding: 5px 6px; width: 100%; min-width: 80px; }
.table-actions { width: 68px; text-align: right; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: #f7f9f7; border-radius: 999px; padding: 3px 7px; font-size: 9px; font-weight: 700; color: #56615c; }
.badge.accent { border-color: #bad8ca; background: var(--accent-soft); color: var(--accent-strong); }
.badge.warn { border-color: #ecd4a6; background: var(--warn-bg); color: var(--warn); }
.badge.danger { border-color: #ecc8c8; background: var(--danger-bg); color: var(--danger); }
.alert { border: 1px solid var(--line); border-left-width: 4px; border-radius: 7px; padding: 9px 11px; font-size: 11px; line-height: 1.55; background: white; }
.alert.warning { border-left-color: #d79b34; background: var(--warn-bg); }
.alert.blocking { border-left-color: #c75a5a; background: var(--danger-bg); }
.alert.info { border-left-color: #5b8cb4; background: var(--info-bg); }
.alert + .alert { margin-top: 7px; }
.metric-card { background: white; border: 1px solid var(--line); border-radius: 9px; padding: 12px; }
.metric-label { font-size: 10px; color: var(--muted); }
.metric-value { margin-top: 5px; font-size: 22px; font-weight: 800; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.metric-value.money { font-size: 20px; color: var(--accent-strong); }
.metric-sub { margin-top: 4px; font-size: 9px; color: var(--muted); line-height: 1.45; }
.summary-title { font-size: 11px; font-weight: 800; margin-bottom: 7px; }
.summary-lines { display: grid; gap: 6px; font-size: 10px; color: #4f5955; }
.summary-line { display: flex; justify-content: space-between; gap: 10px; }
.summary-line strong { color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.source-card { background: #fbfcfb; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: 10px; line-height: 1.55; color: var(--muted); }
.source-card strong { color: var(--ink); }
.rule-list { display: grid; gap: 8px; }
.rule-card { border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.rule-card.selected { border-color: #93b8a6; background: #fbfefc; }
.rule-title { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.rule-title strong { font-size: 11px; }
.rule-desc { margin: 5px 0 0 22px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.rule-values { display: grid; grid-template-columns: repeat(4, minmax(70px, 1fr)); gap: 7px; margin: 9px 0 0 22px; }
.rule-value { border: 1px solid #e3e7e4; background: #f8faf8; border-radius: 6px; padding: 6px; font-size: 9px; }
.rule-value b { display: block; margin-top: 2px; font-size: 12px; }
.override-grid { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 7px; margin: 8px 0 0 22px; }
.result-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border-radius: 9px; margin-bottom: 12px; }
.result-status.ok { background: var(--accent-soft); border: 1px solid #bdd9cc; }
.result-status.ng { background: var(--danger-bg); border: 1px solid #e5bbbb; }
.result-status strong { font-size: 14px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 9px; margin-bottom: 12px; }
details.audit { border: 1px solid var(--line); border-radius: 7px; background: white; margin-bottom: 7px; }
details.audit summary { cursor: pointer; padding: 9px 11px; font-size: 11px; font-weight: 700; }
.audit-body { border-top: 1px solid var(--line); padding: 10px 11px; }
.formula { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: #f5f7f6; border: 1px solid #e0e5e2; border-radius: 5px; padding: 7px; font-size: 10px; overflow-x: auto; }
.trace-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.trace-cell { border: 1px solid #e2e7e4; border-radius: 6px; padding: 7px; font-size: 10px; }
.trace-cell strong { display: block; margin-bottom: 3px; }
.document-toolbar { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 10px; }
.document-toolbar .btn.active { background: var(--accent-soft); border-color: #aacbbd; color: var(--accent-strong); }
.document-layout { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 12px; align-items: start; }
.paper-stage { background: #dfe3e1; border: 1px solid #cdd3d0; border-radius: 8px; padding: 18px; overflow: auto; }
.paper { background: white; color: #111; margin: 0 auto; box-shadow: 0 1px 8px rgb(0 0 0 / 12%); }
.paper.a4 { width: 210mm; min-height: 297mm; padding: 16mm 17mm; }
.paper-head { text-align: center; border-bottom: 2px solid #111; padding-bottom: 7mm; margin-bottom: 7mm; }
.paper-head h1 { font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-size: 19pt; letter-spacing: .2em; margin: 1mm 0 0; }
.paper-kicker { font-size: 8pt; letter-spacing: .1em; color: #555; }
.paper h2 { font-size: 10.5pt; margin: 6mm 0 2mm; }
.paper p { font-size: 9pt; line-height: 1.75; }
.doc-date { text-align: right; font-size: 9pt; margin-bottom: 5mm; }
.recipient { margin: 4mm 0 8mm; font-size: 9pt; }
.recipient-name { font-size: 13pt; font-weight: 700; border-bottom: 1px solid #111; display: inline-block; min-width: 90mm; padding-bottom: 2mm; }
.issuer { text-align: right; margin: 0 0 8mm auto; font-size: 8.5pt; line-height: 1.6; }
.doc-lead { margin: 8mm 0 4mm; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 8.5pt; margin: 3mm 0 5mm; }
.doc-table th, .doc-table td { border: .3mm solid #333; padding: 1.8mm 2mm; vertical-align: top; }
.doc-table th { background: #f2f2f2; font-weight: 600; }
.doc-table .num, .doc-table.totals td { text-align: right; font-variant-numeric: tabular-nums; }
.doc-table.totals { margin-left: auto; width: 75%; }
.doc-table.totals .em th, .doc-table.totals .em td { font-size: 10pt; font-weight: 800; border-top: .6mm solid #111; }
.grand-total { display: flex; align-items: baseline; justify-content: center; gap: 6mm; border-bottom: .5mm solid #111; width: 135mm; margin: 8mm auto 2mm; padding: 2mm 0; }
.grand-total strong { font-size: 18pt; font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.muted { color: #555; }
.footnote { font-size: 7.5pt !important; color: #555; }
.source-ribbon { margin: 4mm 0; padding: 2mm 3mm; background: #eef5f1; border-left: 1.5mm solid #1e6a51; font-size: 8pt; }
.override-note { margin-top: 6mm; padding-top: 3mm; border-top: .4mm dashed #777; font-size: 8pt; }
.blocking-text { color: #9e3434; font-weight: 700; text-align: center; }
.signature-line { margin-top: 12mm; text-align: right; font-size: 9pt; }
.contract-signatures { display: flex; gap: 12mm; margin-top: 15mm; font-size: 9pt; line-height: 2; }
.contract-signatures > div { flex: 1 1 0; }
.mode-card { border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.mode-card strong { font-size: 11px; }
.mode-card p { font-size: 10px; color: var(--muted); margin: 4px 0 0; line-height: 1.5; }
.kpi-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kpi-bar .badge { font-size: 10px; }
.mobile-menu { display: none; }
.hidden { display: none !important; }
@media (max-width: 1180px) {
  .content-grid { grid-template-columns: minmax(0, 1fr); }
  .summary-rail { position: static; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .source-card { grid-column: 1 / -1; }
  .document-layout { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); transition: transform .2s; width: 230px; box-shadow: 12px 0 28px rgb(0 0 0 / 12%); }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: inline-flex; }
  .topbar { padding: 9px 10px; }
  .project-select { min-width: 0; width: 160px; }
  .content-grid { padding: 12px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .metrics, .summary-rail, .rule-values, .override-grid, .trace-grid { grid-template-columns: 1fr; }
  .paper-stage { padding: 8px; }
  .paper.a4 { width: 100%; min-height: auto; padding: 8%; }
}
@media print {
  :root, html, body { background: white !important; }
  .sidebar, .topbar, .page-title, .document-toolbar, .document-side, .summary-rail, .print-hide { display: none !important; }
  .app-shell, .main-shell, .content-grid, .workspace, .document-layout { display: block; margin: 0; padding: 0; }
  .section { border: 0; box-shadow: none; margin: 0; }
  .section-head { display: none; }
  .section-body { padding: 0; }
  .paper-stage { padding: 0; border: 0; background: white; overflow: visible; }
  .paper { box-shadow: none; }
  .paper.a4 { width: auto; min-height: 0; padding: 0; }
  .paper-head, .grand-total, .signature-line, .contract-signatures, .doc-table, .doc-table tr { break-inside: avoid; page-break-inside: avoid; }
  .paper h2 { break-after: avoid; page-break-after: avoid; }
  @page { size: A4 portrait; margin: 14mm 16mm; }
}

/* application-specific refinements */
.nav-help { display: block; color: #8a938f; font-size: 9px; font-weight: 400; margin-top: 1px; }
.readonly-box { min-height: 34px; border: 1px solid #e0e5e2; border-radius: 6px; background: #f7f9f7; padding: 7px 8px; font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.top-gap { margin-top: 12px; }
.inline-note { display: block; color: var(--muted); font-weight: 400; }
.staff-fields { margin-top: 10px; }
.cell-note { margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.35; }
.class-guide { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.class-card { border: 1px solid var(--line); border-radius: 7px; padding: 9px; background: #fcfdfc; }
.class-card p { margin: 5px 0; color: #4f5955; font-size: 10px; line-height: 1.45; }
.class-card small { color: var(--muted); font-size: 9px; }
.mode-card.selectable { cursor: pointer; display: block; }
.mode-card.selectable input { margin-right: 6px; accent-color: var(--accent); }
.mode-card.selectable.selected { border-color: #8db8a4; background: var(--accent-soft); }
.additional-picker { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.empty-cell { padding: 24px !important; text-align: center; color: var(--muted); }
.warning-stack { margin-bottom: 12px; }
.fee-table th { width: 65%; }
.fee-table .total-row th, .fee-table .total-row td { border-top: 2px solid var(--ink); font-size: 13px; font-weight: 800; color: var(--accent-strong); }
.footer-status { display: inline-block; margin-top: 7px; font-weight: 700; }
.footer-status.ok { color: var(--accent); }
.footer-status.ng { color: var(--danger); }
.document-side { display: grid; gap: 12px; }
.document-side .section { margin: 0; box-shadow: none; }
.center { text-align: center; }
@media (max-width: 1180px) { .class-guide { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) { .class-guide { grid-template-columns: 1fr; } .additional-picker { grid-template-columns: 1fr; } }
