/* 暮らしの資金計画 — local, readable, responsive. */
:root {
  color-scheme: light;
  --page: #f6f5f1;
  --surface: #fff;
  --surface-soft: #fafaf7;
  --ink: #20342e;
  --muted: #7a837b;
  --primary: #173f36;
  --primary-hover: #24574b;
  --primary-soft: #eaf1eb;
  --lime: #dbe9ac;
  --line: #e5e8e0;
  --line-strong: #d1d8ce;
  --negative: #b6584f;
  --positive: #2d7460;
  --amber: #a47730;
  --shadow: 0 3px 18px #263e2e05;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  font-size: 14px;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; background: var(--page); color: var(--ink); line-height: 1.65; }
button, input, select, textarea { font: inherit; }
button, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
a { color: var(--primary); text-underline-offset: 3px; }
button, a, input, select, textarea { outline-offset: 3px; }
:focus-visible { outline: 2px solid #5b8d6c; }
button { color: inherit; }
button svg, a svg { flex: 0 0 auto; }
button svg { pointer-events: none; }
svg { vertical-align: middle; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 27px; font-weight: 650; line-height: 1.45; letter-spacing: -.045em; }
h2 { font-size: 17px; font-weight: 650; letter-spacing: -.02em; }
h3 { font-size: 15px; font-weight: 650; }
small { font-size: 11px; }
.numeric, .metric-value, .metric-unit, .band-total, .stat-strip, input[type="number"], table { font-variant-numeric: tabular-nums; }
.numeric, td.numeric, th.numeric { text-align: right; }
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.subtle { color: var(--muted); font-size: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* App shell */
.sidebar { width: 232px; position: fixed; inset: 0 auto 0 0; background: #fff; border-right: 1px solid var(--line); padding: 31px 18px 20px; display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 7px 31px; }
.brand-mark { display: grid; place-items: center; width: 35px; height: 35px; flex: 0 0 35px; color: #fff; background: var(--primary); border-radius: 10px; }
.brand-mark svg { width: 23px; height: 23px; }
.brand-title { font-size: 14px; line-height: 1.55; font-weight: 700; letter-spacing: -.025em; white-space: nowrap; }
.brand-sub { font-size: 9px; color: #8b948b; letter-spacing: .12em; margin-top: 2px; text-transform: uppercase; }
.nav-list { display: flex; flex-direction: column; gap: 7px; }
.nav-label { padding: 0 13px 9px; color: #92998f; font-size: 10px; letter-spacing: .12em; }
.nav-item { display: flex; align-items: center; gap: 12px; border: 0; background: transparent; padding: 12px 13px; width: 100%; text-align: left; border-radius: 8px; font-size: 12px; color: #6c786f; font-weight: 500; transition: background-color .12s, color .12s; white-space: nowrap; }
.nav-item:hover { background: #f5f7f1; color: var(--primary); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.nav-icon { display: inline-flex; width: 19px; align-items: center; justify-content: center; opacity: .85; }
.nav-icon svg { width: 18px; height: 18px; }
.nav-count { margin-left: auto; font-size: 10px; opacity: .6; }
.sidebar-bottom { margin-top: auto; padding: 20px 9px 0; color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; }
.local-badge { display: flex; align-items: center; gap: 6px; font-size: 10px; color: #59725d; }
.status-dot { width: 6px; height: 6px; display: inline-block; border-radius: 50%; background: #6d9d66; flex: 0 0 6px; }
.scenario-name { margin-top: 10px; font-size: 12px; font-weight: 600; color: #516356; overflow-wrap: anywhere; }
.sidebar-note { font-size: 10px; color: #969d92; margin-top: 6px; }
.workspace { margin-left: 232px; padding: 0 38px 56px; max-width: 1720px; }
.topbar { min-height: 77px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); margin-bottom: 29px; }
.breadcrumb { display: flex; align-items: center; gap: 10px; font-size: 11px; color: #899185; }
.breadcrumb span:last-child { color: #546654; }
.breadcrumb svg { width: 14px; height: 14px; }
.topbar-actions, .header-actions, .panel-actions, .row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.topbar-actions .subtle { font-size: 10px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin-bottom: 25px; }
.eyebrow { color: #6e866b; font-size: 10px; letter-spacing: .15em; font-weight: 650; margin-bottom: 7px; text-transform: uppercase; }
.page-description { color: var(--muted); font-size: 12px; margin-top: 8px; max-width: 740px; }
.view { animation: appear .2s ease; }
@keyframes appear { from { opacity: .3; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }

/* Buttons, tabs, and controls */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 37px; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--line-strong); background: #fff; font-size: 11px; font-weight: 600; line-height: 1.5; text-decoration: none; transition: background .12s, border-color .12s; }
.button:hover { background: #f6f8f2; border-color: #b8c7b7; }
.button.primary, .button-primary { background: var(--primary); color: white; border-color: var(--primary); }
.button.primary:hover, .button-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.button.secondary { background: white; color: #4e6453; }
.button.ghost { background: transparent; border-color: transparent; color: #647462; }
.button.ghost:hover { background: #edf1e8; }
.button.danger { color: var(--negative); background: #fff; border-color: #edd9d5; }
.button.danger:hover { background: #fff6f4; }
.button.small { min-height: 30px; padding: 5px 10px; font-size: 10px; }
.button svg { width: 14px; height: 14px; }
.icon-button { border: 1px solid transparent; background: transparent; border-radius: 6px; width: 29px; height: 29px; display: inline-flex; align-items: center; justify-content: center; color: #82907e; }
.icon-button:hover { background: #f2f4ee; border-color: var(--line); color: var(--primary); }
.icon-button.danger:hover { color: var(--negative); background: #fff3f0; }
.icon-button svg { width: 15px; height: 15px; }
.tabs { display: inline-flex; gap: 3px; padding: 3px; background: #f0f2eb; border: 1px solid #e8ece2; border-radius: 7px; }
.tab { border: 0; background: transparent; color: #7e877a; font-size: 10px; padding: 6px 11px; border-radius: 4px; line-height: 1.5; white-space: nowrap; }
.tab.active { background: white; color: var(--primary); font-weight: 650; box-shadow: 0 1px 3px #203c2b10; }
.control-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 17px; flex-wrap: wrap; }
.control-row > div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.control-row label { color: var(--muted); font-size: 11px; }
.child-tabs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.child-tabs button { border: 1px solid var(--line); background: white; color: #7a8678; padding: 8px 14px; border-radius: 7px; font-size: 11px; }
.child-tabs button.active { color: var(--primary); border-color: #a9bd9f; background: #f0f5e9; font-weight: 650; }
.stage-pills { display: flex; flex-wrap: wrap; gap: 7px; }
.stage-pill { border: 1px solid var(--line); background: white; color: #778474; font-size: 10px; padding: 6px 12px; border-radius: 20px; }
.stage-pill.active { color: white; background: var(--primary); border-color: var(--primary); }
.badge { display: inline-flex; gap: 5px; align-items: center; border-radius: 4px; background: #f1f3ed; color: #71816a; font-size: 9px; line-height: 1.5; padding: 3px 6px; font-weight: 500; white-space: nowrap; }
.badge.green { color: #4a7755; background: #eaf3e8; }
.badge.amber { color: #997339; background: #f8f1df; }

/* Summary and panels */
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 24px; }
.metric-card { position: relative; background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 21px 17px; box-shadow: var(--shadow); overflow: hidden; }
.metric-card.featured { background: var(--primary); border-color: var(--primary); color: white; }
.metric-label { color: #7a8778; font-size: 10px; letter-spacing: .01em; margin-bottom: 11px; }
.metric-card.featured .metric-label, .metric-card.featured .metric-caption { color: #b9cdbf; }
.metric-value { font-size: 30px; line-height: 1.25; font-weight: 550; letter-spacing: -.035em; white-space: nowrap; }
.metric-unit { font-size: 12px; font-weight: 500; margin-left: 5px; color: #7f8a7b; letter-spacing: 0; }
.metric-card.featured .metric-unit { color: #c0d2c5; }
.metric-caption { font-size: 9px; margin-top: 10px; color: #8a9384; }
.metric-icon { width: 29px; height: 29px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #829779; background: #f3f5ed; position: absolute; top: 15px; right: 15px; }
.metric-icon svg { width: 15px; height: 15px; }
.metric-card.featured .metric-icon { color: #d7e4c5; background: #315447; }
.panel { background: white; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 22px; box-shadow: var(--shadow); min-width: 0; overflow: hidden; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 21px 24px 17px; }
.panel-title { font-size: 14px; font-weight: 650; letter-spacing: -.025em; display: flex; align-items: center; gap: 8px; }
.panel-title svg { width: 16px; height: 16px; color: #729067; }
.panel-subtitle { margin-top: 5px; color: #92998c; font-size: 10px; }
.panel-body { padding: 0 24px 23px; }
.panel-body > :last-child { margin-bottom: 0; }
.panel-body.padded { padding-top: 4px; }
.panel-footer { padding: 12px 24px; border-top: 1px solid var(--line); font-size: 10px; color: #8a9484; background: #fcfcf9; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; }
.two-col .panel { margin-bottom: 0; }
.two-col { margin-bottom: 22px; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid { display: grid; gap: 18px; }
.span-2 { grid-column: span 2; }
.section-heading { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin: 26px 0 13px; font-size: 14px; font-weight: 600; }
.notice { background: #f0f4e9; border: 1px solid #e1e9d6; color: #6c7c5b; padding: 12px 15px; border-radius: 8px; font-size: 11px; margin-bottom: 20px; line-height: 1.8; }
.notice.amber { background: #fcf7e9; border-color: #eee2bc; color: #937b42; }
.notice.error { background: #fff3f0; border-color: #efd4ce; color: #a35649; }
.notice strong { font-weight: 650; }
.empty-state { padding: 35px 24px; text-align: center; color: #8d9686; font-size: 12px; border: 1px dashed var(--line-strong); border-radius: 10px; }
.help-details { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 17px; color: #86907e; font-size: 10px; }
.help-details summary { cursor: pointer; color: #76866a; }
.help-details p, .help-details ul { margin-top: 8px; }
.help-details ul { padding-left: 18px; }

/* Forms and editable rows */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 20px; }
.field { min-width: 0; }
.field label, .field > .field-label { display: block; font-size: 11px; color: #64735d; margin-bottom: 6px; font-weight: 500; }
input, select, textarea { border: 1px solid #dce2d5; background: #fff; color: #2c4430; border-radius: 6px; padding: 9px 10px; font-size: 12px; min-height: 37px; max-width: 100%; transition: border-color .12s, box-shadow .12s; }
input:hover, select:hover { border-color: #b9c8ad; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #7c9b68; box-shadow: 0 0 0 3px #8da56d13; }
input[type="number"] { text-align: right; }
input[type="checkbox"] { width: 15px; height: 15px; min-height: 0; accent-color: var(--primary); margin: 0; }
input[readonly], input:disabled { background: #f6f7f2; color: #91998b; }
.field > input, .field > select, .field > textarea { width: 100%; }
.input-unit { display: flex; align-items: center; gap: 8px; }
.input-unit input { width: 100%; min-width: 0; }
.input-unit > span { font-size: 11px; color: #849079; white-space: nowrap; }
.field-hint { font-size: 9px; color: #98a08f; margin-top: 5px; line-height: 1.65; }
.form-section { padding: 20px 0; border-top: 1px solid var(--line); }
.form-section:first-child { padding-top: 0; border-top: none; }
.form-section h3 { margin-bottom: 15px; }
.number-input { width: 95px; min-width: 65px; text-align: right; }
.item-input { width: 100%; min-width: 130px; }
.year-input { width: 82px; }
.checkbox-label { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; color: #60745b; cursor: pointer; }
.checkbox-switch { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; color: #60745b; cursor: pointer; }
.checkbox-switch input { appearance: none; width: 29px; height: 17px; min-height: 17px; border: 0; border-radius: 20px; background: #d9dfd1; position: relative; transition: background .15s; }
.checkbox-switch input::after { content: ''; width: 11px; height: 11px; border-radius: 50%; background: white; position: absolute; left: 3px; top: 3px; box-shadow: 0 1px 3px #173f3620; transition: transform .15s; }
.checkbox-switch input:checked { background: var(--primary); }
.checkbox-switch input:checked::after { transform: translateX(12px); }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: #cfd8c5 transparent; }
table { width: 100%; border-collapse: collapse; font-size: 11px; text-align: left; }
th { font-size: 10px; color: #839078; font-weight: 500; background: #f8f9f4; padding: 11px 13px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 13px; border-bottom: 1px solid #edf0e7; color: #4b6246; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfcf8; }
.data-table .total-row td, .editable-table .total-row td { font-weight: 650; background: #f4f7ed; border-top: 1px solid var(--line-strong); }
.data-table .selected-row td { background: #f0f5e8; }
.data-table th:not(:first-child), .data-table td:not(:first-child) { text-align: right; }
.data-table th:first-child, .data-table td:first-child { position: sticky; left: 0; z-index: 1; background: white; }
.data-table th:first-child { background: #f8f9f4; }
.data-table tbody tr:hover td:first-child { background: #fbfcf8; }
.data-table .total-row td:first-child { background: #f4f7ed; }
.data-table .year-cell { color: var(--primary); font-weight: 600; }
.data-table .year-sub { display: block; color: #96a08b; font-size: 9px; font-weight: 400; margin-top: 2px; white-space: nowrap; }
.editable-table { min-width: 460px; }
.editable-table th { background: transparent; padding: 8px 7px; }
.editable-table td { padding: 7px; }
.editable-table td:first-child, .editable-table th:first-child { padding-left: 0; }
.editable-table td:last-child, .editable-table th:last-child { padding-right: 0; }
.editable-table input, .editable-table select { min-height: 32px; padding: 5px 8px; font-size: 11px; }
.editable-table .number-input { width: 91px; }
.editable-table .unit-select { width: 74px; }
.editable-table .action-cell { width: 29px; text-align: center; }
.editable-table .readonly-cell { color: #6c7d61; font-size: 11px; text-align: right; }
.editable-table .override-input { border-color: #b9cda3; background: #f7fbf0; }

/* Age-band editor */
.band-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.band-card { background: white; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; min-width: 0; }
.band-header { padding: 15px 17px; background: #fafbf6; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 9px; justify-content: space-between; flex-wrap: wrap; }
.band-title { font-size: 13px; font-weight: 650; }
.band-title input { background: transparent; border-color: transparent; padding: 2px 4px; width: 130px; font-size: 13px; font-weight: 600; min-height: 25px; }
.band-title input:hover, .band-title input:focus { border-color: var(--line-strong); background: white; }
.band-ages { display: inline-flex; align-items: center; gap: 4px; color: #87967c; font-size: 10px; }
.band-ages input { width: 43px; min-height: 26px; padding: 2px 4px; font-size: 10px; background: white; border-color: #e6ebdf; }
.band-total { font-size: 15px; font-weight: 650; color: var(--primary); margin-left: auto; white-space: nowrap; }
.band-total small { font-size: 9px; color: #8b987f; font-weight: 400; margin-left: 3px; }
.band-body { padding: 8px 16px 14px; }
.band-body .editable-table { min-width: 330px; }
.band-body .editable-table th { font-size: 9px; }
.band-body .editable-table .item-input { min-width: 105px; }
.band-body .editable-table .number-input { width: 67px; min-width: 55px; }
.band-body .editable-table select { width: 63px; padding-left: 4px; padding-right: 2px; }
.band-body .button { margin-top: 9px; }
.band-note { font-size: 9px; color: #99a18e; margin-top: 8px; }

/* Charts */
.chart-wrap { width: 100%; position: relative; min-height: 160px; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg text { font-family: inherit; font-size: 10px; fill: #8c9782; font-variant-numeric: tabular-nums; }
.chart-svg .chart-label, .chart-label { fill: #87927c; font-size: 10px; }
.chart-svg .chart-axis, .chart-axis { stroke: #e5e9df; }
.chart-svg .chart-grid, .chart-grid { stroke: #edf0e6; stroke-dasharray: 3 4; }
.chart-svg .zero-line { stroke: #c8d2bb; stroke-dasharray: 0; }
.chart-svg .chart-hover-line { stroke: #a8b69c; stroke-dasharray: 3 3; pointer-events: none; }
.chart-svg .chart-hit { fill: transparent; cursor: pointer; }
.chart-svg .chart-hit:hover { fill: #c6d5a018; }
.chart-svg .selected-marker { fill: #eef4df; }
.chart-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 9px 17px; margin: 15px 0 1px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 9px; color: #87917d; white-space: nowrap; }
button.legend-item { border: 0; padding: 2px 0; background: transparent; }
button.legend-item:hover { color: var(--primary); }
.legend-dot { display: inline-block; width: 7px; height: 7px; border-radius: 2px; flex: 0 0 7px; }
.legend-dot.line { height: 2px; width: 12px; flex-basis: 12px; border-radius: 1px; }
.chart-tooltip { position: absolute; z-index: 15; top: 20px; right: 30px; min-width: 150px; pointer-events: none; background: #fff; border: 1px solid #d5dec9; border-radius: 8px; padding: 11px 13px; box-shadow: 0 6px 25px #273f2d14; font-size: 10px; }
.chart-tooltip strong { display: block; color: var(--primary); margin-bottom: 6px; }
.chart-tooltip .tooltip-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 4px; color: #7e8c73; }
.chart-tooltip .tooltip-row span:last-child { font-variant-numeric: tabular-nums; color: #475f3e; }
.chart-caption { font-size: 9px; color: #99a08f; margin-top: 10px; }
.chart-heading { color: #829274; font-size: 10px; margin: 7px 0 4px; }
.stat-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; padding: 17px 0 0; margin-top: 16px; border-top: 1px solid var(--line); }
.stat-strip > div { border-right: 1px solid var(--line); padding-right: 14px; }
.stat-strip > div:last-child { border-right: 0; }
.stat-strip .label { font-size: 9px; color: #8d9981; }
.stat-strip .value { font-size: 17px; line-height: 1.4; font-weight: 600; margin-top: 5px; letter-spacing: -.025em; }
.stat-strip .value small { font-weight: 400; color: #91a081; font-size: 9px; }
.year-detail { margin-top: 16px; border: 1px solid #e2e9d8; border-radius: 9px; padding: 16px; background: #fafcf5; }
.year-detail h3 { font-size: 13px; margin-bottom: 11px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.detail-grid .label { font-size: 10px; color: #8d9b7f; }
.detail-grid .value { font-size: 16px; font-variant-numeric: tabular-nums; margin-top: 3px; }
.detail-grid .subtle { font-size: 9px; }
.comparison-controls { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.comparison-controls .field { flex: 1; min-width: 180px; }

/* Dialogs and alerts */
.modal-overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: #172e255c; backdrop-filter: blur(3px); z-index: 100; }
.modal { display: flex; flex-direction: column; max-height: min(90vh, 850px); width: min(640px, 100%); border-radius: 15px; background: white; border: 1px solid #ffffff70; box-shadow: 0 20px 80px #10291c30; overflow: hidden; }
.modal.wide { width: min(980px, 100%); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 22px 25px 17px; border-bottom: 1px solid var(--line); }
.modal-header h2 { font-size: 17px; }
.modal-body { overflow-y: auto; padding: 22px 25px; }
.modal-footer { display: flex; gap: 9px; align-items: center; justify-content: flex-end; padding: 17px 25px; border-top: 1px solid var(--line); background: #fbfcf7; }
.modal .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.toast { position: fixed; bottom: 27px; left: calc(50% + 116px); transform: translateX(-50%); background: #244b3c; color: white; padding: 11px 20px; border-radius: 9px; font-size: 12px; box-shadow: 0 7px 22px #233d2c25; z-index: 150; max-width: calc(100% - 32px); animation: appear .2s ease; }
.error-list { margin: 0; padding-left: 18px; }
.save-indicator { display: flex; align-items: center; gap: 6px; color: #96a088; font-size: 10px; }
.import-input { display: none; }

/* Concrete app components */
.brand { text-decoration: none; }
.brand-title, .brand-sub { display: block; }
.nav-section-label { padding: 0 13px 10px; color: #92998f; font-size: 9px; letter-spacing: .14em; }
.main-content { min-width: 0; }
.app-footer { display: flex; gap: 18px; justify-content: space-between; align-items: center; color: #9aa38f; font-size: 9px; padding-top: 22px; margin-top: 10px; border-top: 1px solid var(--line); }
.app-footer > :last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.autosave-label { display: inline-flex; align-items: center; gap: 5px; color: #8b9a80; white-space: nowrap; font-size: 10px; }
.autosave-label svg { color: #6d9160; }
.compare-select-label { display: flex; min-width: 0; }
.compare-select-label select { min-height: 31px; padding: 5px 26px 5px 10px; font-size: 10px; max-width: 210px; text-overflow: ellipsis; }
.topbar-actions { flex-wrap: nowrap; }
.topbar-actions > .button { white-space: nowrap; }
.more-menu-wrap { position: relative; }
.more-menu { position: absolute; top: calc(100% + 9px); right: 0; z-index: 50; width: 230px; padding: 6px; border: 1px solid #dce4d4; border-radius: 10px; background: white; box-shadow: 0 9px 32px #203b271c; }
.more-menu .button { width: 100%; display: flex; justify-content: flex-start; padding: 10px 11px; border-radius: 5px; font-size: 11px; }
.more-menu .button:last-child { margin-top: 4px; border-top: 1px solid var(--line); }
.summary-grid > .metric-card:last-child, .metric-card.highlight { background: var(--primary); border-color: var(--primary); color: white; }
.summary-grid > .metric-card:last-child .metric-label, .metric-card.highlight .metric-label { color: #c2d3bf; }
.summary-grid > .metric-card:last-child .metric-unit, .metric-card.highlight .metric-unit { color: #cfddc8; }
.summary-grid > .metric-card:last-child .metric-caption, .metric-card.highlight .metric-caption { color: #9eb49e; }
.metric-card:last-child::after { content: ''; position: absolute; width: 75px; height: 75px; bottom: -41px; right: -16px; border: 1px solid #b9d79a25; border-radius: 50%; box-shadow: 0 0 0 15px #b9d79a08, 0 0 0 30px #b9d79a05; pointer-events: none; }
.chart-section + .chart-section { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.chart-section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #536e49; font-size: 11px; font-weight: 550; margin-bottom: 14px; }
.chart-section-title .subtle { font-size: 9px; font-weight: 400; }
.chart-svg text.chart-axis { stroke: none; fill: #8c9782; font-size: 10px; }
.chart-svg .chart-hit:focus { outline: none; stroke: #779466; stroke-width: 1.5; fill: #a8c08212; }
.chart-tooltip > div { display: flex; align-items: center; gap: 6px; margin-top: 5px; color: #819072; }
.chart-tooltip > div b { margin-left: auto; padding-left: 12px; font-weight: 600; color: #536849; font-variant-numeric: tabular-nums; }
.chart-tooltip > small { display: block; margin-top: 7px; padding-top: 6px; border-top: 1px solid var(--line); font-size: 8px; color: #99a08e; }
.legend-dot.dashed { width: 12px; height: 2px; flex-basis: 12px; border-radius: 0; }
.quick-links { display: flex; flex-direction: column; gap: 8px; }
.quick-links .button { justify-content: flex-start; padding: 12px 0; font-size: 11px; border-bottom: 1px solid #edf1e6; border-radius: 0; }
.quick-links .button:last-child { border-bottom: 0; }
.quick-links .button svg:last-child { margin-left: auto; color: #a1ae93; }
.quick-links .button:hover { background: transparent; color: #487631; }
.stat-strip { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 0; padding: 11px 0; border-top: 0; border-bottom: 1px solid var(--line); font-size: 10px; color: #8b987d; }
.stat-strip:last-child { border-bottom: 0; }
.stat-strip strong { color: #4a623f; font-size: 11px; font-weight: 600; text-align: right; white-space: nowrap; }
.stat-strip strong.negative { color: var(--negative); }
.stat-strip strong.positive { color: var(--positive); }
.stat-strip.total { border-bottom: 0; margin-top: 5px; padding-top: 13px; font-weight: 600; color: var(--primary); }
.stat-strip.total strong { font-size: 13px; }
.peak-display { padding: 12px 0 19px; }
.peak-display .eyebrow { display: block; }
.peak-display .metric-value { margin: 7px 0 10px; }
.peak-display .subtle { font-size: 10px; }
.editor-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 28px 0 17px; }
.editor-toolbar .eyebrow { margin-bottom: 3px; }
.editor-toolbar .section-heading { margin: 0; font-size: 17px; }
.scope-select { display: flex; align-items: center; gap: 8px; font-size: 10px; color: #819173; }
.scope-select select { min-height: 33px; font-size: 11px; }
.editor-tabs { margin-bottom: 10px; }
.editor-tabs .tab { padding: 8px 17px; font-size: 11px; }
.editor-note { margin: 0 0 18px; font-size: 10px; }
.children-rows { display: flex; flex-direction: column; gap: 14px; margin-bottom: 10px; }
.child-row { display: flex; align-items: flex-end; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.child-row:last-child { border-bottom: 0; }
.child-row .field { flex: 1; max-width: 290px; }
.child-row .icon-button { margin-bottom: 4px; }
.child-avatar { display: flex; align-items: center; justify-content: center; width: 31px; height: 31px; flex: 0 0 31px; border-radius: 50%; font-size: 12px; color: #819b68; background: #f0f5e8; margin-bottom: 3px; }
.child-row .input-unit input, .field .input-unit select { width: 100%; }
.band-heading { min-width: 0; }
.band-heading > .item-input { min-width: 0; width: 180px; max-width: 100%; font-weight: 650; font-size: 13px; padding: 2px 3px; background: transparent; border-color: transparent; min-height: 26px; }
.band-heading > .item-input:hover, .band-heading > .item-input:focus { background: white; border-color: var(--line-strong); }
.band-heading .band-ages { display: flex; margin-top: 5px; }
.band-heading .band-ages input { min-width: 0; width: 43px; }
.band-heading h3 { font-size: 13px; }
.band-header { gap: 7px; flex-wrap: nowrap; }
.band-total { font-size: 12px; font-weight: 600; }
.band-header > .icon-button { width: 24px; height: 24px; flex: 0 0 24px; }
.band-table td:nth-child(2) { white-space: nowrap; }
.band-table .item-input { font-size: 10px; }
.override-dot { display: inline-flex; margin-left: 5px; padding: 1px 4px; font-size: 8px; color: #77934f; background: #eef5e3; border-radius: 3px; }
.loan-estimate { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 14px 17px; margin-top: 21px; background: #f1f5e9; border: 1px solid #e7eddc; border-radius: 8px; font-size: 11px; color: #7b8a6b; }
.loan-estimate strong { color: var(--primary); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.opening-strip { display: flex; gap: 15px 30px; flex-wrap: wrap; padding: 12px 15px; margin-bottom: 16px; background: #f4f7ef; border-radius: 7px; font-size: 10px; color: #819172; }
.opening-strip strong { color: #506a41; margin-left: 8px; font-size: 12px; }
.annual-table { min-width: 790px; }
.annual-table tbody tr { cursor: pointer; }
.annual-table tbody tr:focus-visible { outline-offset: -2px; }
.table-sub { display: block; color: #9aa48e; font-size: 9px; white-space: nowrap; margin-top: 3px; font-weight: 400; }
.strong { font-weight: 650; }
.table-note { margin-top: 12px; font-size: 9px; }
.year-detail { background: #fbfcf8; border-color: #e3ead9; margin-top: 10px; }
.year-detail-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.year-detail-heading h3 { margin: 0; }
.child-age-labels { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 19px; }
.year-detail .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }
.detail-grid h4 { margin: 0 0 6px; font-size: 11px; color: #5c764e; font-weight: 600; }
.year-detail .stat-strip { font-size: 9px; gap: 8px; padding: 9px 0; border-color: #eaf0df; }
.year-detail .stat-strip strong { font-size: 10px; }
.year-detail .stat-strip.total strong { font-size: 12px; }
.year-detail .help-details summary { font-size: 10px; }
.help-content { display: grid; gap: 4px; }
.help-content p { line-height: 1.9; }
.saved-cases { display: flex; flex-direction: column; }
.saved-case { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.saved-case:first-child { padding-top: 0; }
.saved-case:last-child { padding-bottom: 0; border-bottom: 0; }
.saved-case > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.saved-case strong { font-size: 12px; font-weight: 600; }
.saved-case .subtle { font-size: 10px; margin-top: 3px; }
.saved-case .row-actions { flex-shrink: 0; }
.modal-open { overflow: hidden; }
.notice.warning { background: #fcf7e9; border-color: #eee2bc; color: #937b42; }
.notice ul { margin: 6px 0 0; padding-left: 18px; }
.small { font-size: 10px; }

/* Compact laptop and mobile */
@media (min-width: 1800px) { .workspace { margin-right: auto; } }
@media (max-width: 1250px) {
  .sidebar { width: 208px; padding-left: 13px; padding-right: 13px; }
  .workspace { margin-left: 208px; padding-left: 26px; padding-right: 26px; }
  .summary-grid { gap: 11px; }
  .metric-card { padding: 18px 15px 15px; }
  .metric-value { font-size: 26px; }
  .metric-icon { width: 23px; height: 23px; right: 12px; top: 12px; }
  .metric-label { font-size: 9px; max-width: calc(100% - 20px); }
  .panel-header { padding: 19px 20px 16px; }
  .panel-body { padding-left: 20px; padding-right: 20px; }
  .band-grid { grid-template-columns: minmax(0, 1fr); }
  .band-body .editable-table { min-width: 400px; }
  .band-body .editable-table .number-input { width: 100px; }
  .toast { left: calc(50% + 104px); }
  .topbar-actions { gap: 7px; }
  .autosave-label { font-size: 9px; }
  .compare-select-label select { max-width: 175px; }
}
@media (max-width: 1000px) {
  .workspace { padding-left: 22px; padding-right: 22px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-value { font-size: 30px; }
  .metric-label { font-size: 10px; }
  .metric-icon { width: 29px; height: 29px; }
  .two-col { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-header { align-items: flex-start; }
  .header-actions { flex-shrink: 0; }
  .topbar-actions .save-indicator { display: none; }
  .autosave-label { display: none; }
  .compare-select-label select { max-width: 165px; }
  h1 { font-size: 25px; }
  .panel-header { flex-wrap: wrap; gap: 10px; }
  .panel-actions { margin-left: auto; }
}
@media (max-width: 760px) {
  .sidebar { position: sticky; top: 0; width: 100%; height: auto; padding: 12px 16px 0; border-right: 0; border-bottom: 1px solid var(--line); box-shadow: 0 3px 12px #173f3604; }
  .brand { padding: 0 2px 12px; gap: 9px; }
  .brand-mark { width: 29px; height: 29px; flex-basis: 29px; border-radius: 8px; }
  .brand-mark svg { width: 20px; height: 20px; }
  .brand-title { font-size: 13px; }
  .brand-sub { font-size: 8px; }
  .nav-label, .sidebar-bottom { display: none; }
  .nav-section-label { display: none; }
  .nav-list { flex-direction: row; gap: 4px; overflow-x: auto; margin: 0 -16px; padding: 0 14px 9px; scrollbar-width: none; }
  .nav-list::-webkit-scrollbar { display: none; }
  .nav-item { width: auto; padding: 9px 11px; font-size: 10px; border-radius: 6px; gap: 6px; flex-shrink: 0; }
  .nav-icon { width: 15px; }
  .nav-icon svg { width: 15px; height: 15px; }
  .nav-count { display: none; }
  .workspace { margin-left: 0; padding: 0 18px 35px; }
  .topbar { min-height: 61px; margin-bottom: 21px; gap: 8px; }
  .topbar { flex-wrap: wrap; padding: 13px 0; }
  .breadcrumb { font-size: 10px; gap: 6px; }
  .topbar-actions { gap: 4px; }
  .topbar-actions { margin-left: auto; }
  .compare-select-label select { min-height: 31px; padding-top: 5px; padding-bottom: 5px; font-size: 10px; max-width: 145px; }
  .topbar-actions .button { padding: 6px 8px; font-size: 9px; min-height: 31px; }
  .topbar-actions .button svg { width: 12px; height: 12px; }
  .page-header { margin-bottom: 21px; gap: 15px; flex-wrap: wrap; }
  .page-header .header-actions { width: 100%; justify-content: flex-start; }
  .eyebrow { font-size: 9px; }
  h1 { font-size: 24px; }
  .page-description { font-size: 11px; }
  .summary-grid { gap: 10px; margin-bottom: 19px; }
  .metric-card { padding: 16px 14px 14px; border-radius: 11px; }
  .metric-label { font-size: 9px; max-width: calc(100% - 15px); margin-bottom: 10px; }
  .metric-icon { width: 21px; height: 21px; top: 11px; right: 10px; border-radius: 6px; }
  .metric-icon svg { width: 12px; height: 12px; }
  .metric-value { font-size: 26px; }
  .metric-unit { font-size: 10px; margin-left: 3px; }
  .metric-caption { font-size: 8px; margin-top: 8px; }
  .panel { border-radius: 11px; margin-bottom: 19px; }
  .panel-header { padding: 17px 16px 13px; }
  .panel-title { font-size: 13px; }
  .panel-subtitle { font-size: 9px; }
  .panel-body { padding: 0 16px 18px; }
  .panel-footer { padding: 11px 16px; font-size: 9px; }
  .panel-actions { gap: 6px; }
  .panel-actions .button { font-size: 9px; }
  .panel-actions .tabs { padding: 2px; }
  .tab { font-size: 9px; padding: 5px 8px; }
  .chart-wrap { min-height: 110px; }
  .chart-svg { min-width: 480px; }
  .chart-wrap { overflow-x: auto; }
  .chart-legend { gap: 8px 12px; }
  .legend-item { font-size: 8px; }
  .chart-tooltip { position: fixed; top: auto; right: 18px; bottom: 18px; font-size: 10px; }
  .stat-strip { gap: 8px; padding-top: 13px; margin-top: 13px; }
  .stat-strip { margin-top: 0; padding: 10px 0; }
  .stat-strip strong { font-size: 10px; }
  .stat-strip > div { padding-right: 8px; }
  .stat-strip .label { font-size: 8px; }
  .stat-strip .value { font-size: 15px; }
  .two-col { gap: 18px; margin-bottom: 19px; }
  .three-col { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .modal .form-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .span-2 { grid-column: auto; }
  .field label { font-size: 11px; }
  input, select, textarea { font-size: 16px; }
  .editable-table input, .editable-table select { font-size: 13px; }
  .band-grid { gap: 15px; }
  .band-header { padding: 13px 14px; }
  .band-body { padding: 7px 13px 13px; }
  .band-body .editable-table { min-width: 355px; }
  .band-body .editable-table .number-input { width: 74px; }
  .band-total { font-size: 14px; }
  .band-total { font-size: 11px; }
  .band-heading > .item-input { width: 145px; font-size: 12px; }
  .band-title input { font-size: 13px; }
  .band-ages input { font-size: 11px; }
  .notice { font-size: 10px; padding: 10px 12px; margin-bottom: 16px; }
  .section-heading { margin-top: 22px; font-size: 13px; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .year-detail .detail-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .year-detail .stat-strip { font-size: 10px; }
  .year-detail .stat-strip strong { font-size: 11px; }
  .year-detail { padding: 13px; }
  .modal-overlay { padding: 13px; }
  .modal { max-height: 90vh; border-radius: 12px; }
  .modal-header { padding: 18px; }
  .modal-body { padding: 18px; }
  .modal-footer { padding: 14px 18px; }
  .toast { left: 50%; bottom: 18px; font-size: 11px; }
  .comparison-controls .field { min-width: 100%; }
  .editor-toolbar { margin-top: 23px; align-items: flex-end; gap: 10px; }
  .editor-toolbar .section-heading { font-size: 15px; }
  .scope-select { flex-direction: column; align-items: flex-start; gap: 4px; font-size: 9px; }
  .scope-select select { font-size: 11px; padding: 5px 7px; min-height: 30px; max-width: 145px; }
  .editor-tabs .tab { font-size: 10px; padding: 7px 13px; }
  .editor-note { font-size: 9px; margin-bottom: 14px; }
  .child-row { gap: 9px; }
  .child-avatar { width: 25px; height: 25px; flex-basis: 25px; }
  .child-row .field { min-width: 0; }
  .child-row .field label { font-size: 10px; }
  .child-row .field:first-of-type { flex: 1.2; }
  .child-row .field input { font-size: 13px; }
  .child-row .icon-button { flex: 0 0 25px; width: 25px; }
  .chart-section-title { flex-wrap: wrap; gap: 4px; font-size: 10px; }
  .chart-section-title .subtle { font-size: 8px; }
  .app-footer { align-items: flex-start; flex-direction: column; gap: 5px; font-size: 8px; }
  .loan-estimate { padding: 12px; }
  .loan-estimate strong { font-size: 14px; }
  .opening-strip { flex-direction: column; gap: 5px; font-size: 9px; }
  .saved-case { gap: 10px; }
  .saved-case strong { font-size: 11px; }
  .saved-case .subtle { font-size: 9px; }
}
@media (max-width: 390px) {
  .workspace { padding-left: 13px; padding-right: 13px; }
  .metric-card { padding-left: 11px; padding-right: 11px; }
  .metric-value { font-size: 23px; }
  .metric-icon { display: none; }
  .metric-label { max-width: 100%; }
  .breadcrumb { display: none; }
  .topbar { justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print {
  body { background: white; }
  .sidebar, .topbar-actions, .header-actions, .panel-actions, .button, .toast, .modal-overlay { display: none !important; }
  .workspace { margin: 0; padding: 0; max-width: none; }
  .topbar { min-height: auto; padding-bottom: 10px; margin-bottom: 18px; }
  .panel, .metric-card, .band-card { break-inside: avoid; box-shadow: none; }
  .summary-grid { grid-template-columns: repeat(4, 1fr); }
  .chart-svg { min-width: 0; }
}

.income-card { padding: 18px 0; border-bottom: 1px solid var(--line); }
.income-card:first-child { padding-top: 0; }
.income-card .control-row > input { max-width: 360px; }
.income-card .form-grid { margin-bottom: 16px; }
.monthly-expense-summary { margin: 20px 0 26px; }
.monthly-expense-summary h4 { font-size: 13px; margin: 0 0 12px; }
.monthly-expense-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 12px; }
.monthly-expense-card { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.monthly-expense-card > span { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; }
.monthly-expense-card > strong { display: block; font-size: 23px; margin-top: 7px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.monthly-expense-card small { font-size: 11px; margin-left: 6px; font-weight: 400; }
.monthly-expense-card:last-child { background: var(--primary-soft); border-color: #cfdfd3; }
.monthly-living-trigger { text-align: left; width: 100%; color: inherit; }
.monthly-living-trigger:hover, .monthly-living-trigger[aria-expanded="true"] { background: var(--primary-soft); border-color: #a7c3af; }
.monthly-living-trigger > span:first-child { display: block; }
.monthly-living-trigger > .monthly-toggle-label { display: inline-flex; margin-top: 8px; }
.monthly-toggle-label { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; color: var(--primary); }
.monthly-living-trigger[aria-expanded="true"] .monthly-toggle-label svg { transform: rotate(180deg); }
.monthly-living-breakdown { margin-top: 14px; padding: 18px; background: white; border: 1px solid var(--line); border-radius: 8px; }
.monthly-living-breakdown .data-table { min-width: 420px; }
.monthly-living-breakdown .data-table td { white-space: nowrap; }
.monthly-living-breakdown .breakdown-group th { background: var(--surface-soft); color: var(--primary); padding-top: 14px; }
.monthly-living-breakdown tfoot th { border-top: 1px solid var(--line-strong); color: var(--primary); }
.monthly-expense-summary > p { margin-top: 10px; font-size: 10px; }

/* Keep yearly breakdown labels and amounts together at every panel width. */
.modal.wide { width: min(1120px, 100%); }
.year-detail { width: 100%; overflow-x: auto; }
.year-detail .detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 28px;
  width: 100%;
}
.year-detail .detail-grid > div { min-width: 0; }
.year-detail .detail-grid h4 { font-size: 13px; margin-bottom: 12px; }
.year-detail .stat-strip {
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) max-content;
  align-items: baseline;
  gap: 20px;
  padding: 12px 0;
  font-size: 12px;
}
.year-detail .stat-strip > span,
.year-detail .stat-strip > strong { white-space: nowrap; }
.year-detail .stat-strip > strong {
  text-align: right;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.year-detail .stat-strip.total strong { font-size: 14px; }
@media (max-width: 480px) {
  .year-detail .stat-strip { gap: 12px; font-size: 11px; }
  .year-detail .stat-strip > strong { font-size: 12px; }
  .year-detail .stat-strip.total strong { font-size: 12px; }
}

.detail-result { background: var(--primary-soft); border: 1px solid #cfdfd3; border-radius: 8px; padding: 16px; margin: 0 0 14px; }
.detail-result > span { display: block; font-size: 11px; color: var(--muted); }
.detail-result > strong { display: block; font-size: 25px; line-height: 1.4; margin-top: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.detail-result > strong small { font-size: 12px; margin-left: 7px; font-weight: 400; }
.detail-result .detail-result-note { margin-top: 5px; color: var(--primary); font-variant-numeric: tabular-nums; }

/* Payroll detail editor: observed payslip inputs remain ordinary editable rows. */
.income-card { min-width: 0; }
.income-card > p { font-size: 11px; line-height: 1.8; color: var(--muted); }
.payroll-group { min-width: 0; margin: 22px 0 0; padding: 19px 0 0; border-top: 1px solid var(--line); }
.payroll-group:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.payroll-group-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.payroll-group-heading h4 { margin: 0; font-size: 13px; font-weight: 600; color: var(--primary); }
.payroll-group-heading p { margin: 4px 0 0; font-size: 10px; color: var(--muted); }
.payroll-group-heading .button { flex-shrink: 0; }
.payroll-group > .table-wrap { width: 100%; }
.payroll-table { min-width: 640px; table-layout: auto; }
.payroll-table th { font-size: 10px; white-space: nowrap; }
.payroll-table td { vertical-align: middle; }
.payroll-table .item-input { min-width: 120px; width: 100%; max-width: 250px; }
.payroll-table input.number-input { width: 100px; min-width: 80px; max-width: 100%; }
.payroll-table input[type="number"][aria-label*="単価"],
.payroll-table input[type="number"][aria-label*="時間"],
.payroll-table input[type="number"][aria-label*="金額"] { width: 108px; }
.payroll-table input[type="number"][aria-label*="年齢"],
.payroll-table input[type="number"][aria-label*="開始年"],
.payroll-table input[type="number"][aria-label*="終了年"] { width: 80px; min-width: 70px; }
.payroll-table select { min-width: 78px; max-width: 100%; }
.payroll-table .input-unit { display: inline-flex; gap: 6px; white-space: nowrap; }
.payroll-table .input-unit input { width: 104px; min-width: 80px; }
.payroll-table .input-unit > span { font-size: 10px; color: #849079; }
.payroll-table .numeric { white-space: nowrap; }
.payroll-table .field-hint { font-size: 9px; max-width: 180px; }
.payroll-wide-table { min-width: 1080px; }
.payroll-wide-table .item-input { min-width: 130px; }
.payroll-wide-table th:first-child, .payroll-wide-table td:first-child { white-space: nowrap; }
.payroll-subtotal { display: block; width: 100%; overflow-x: auto; padding: 11px 0 0; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; scrollbar-width: thin; scrollbar-color: #cfd8c5 transparent; }
.payroll-subtotal > .stat-strip { display: grid; grid-template-columns: minmax(max-content, 1fr) max-content; align-items: baseline; gap: 20px; min-width: 455px; padding: 11px 0; }
.payroll-subtotal > .stat-strip > span { white-space: nowrap; }
.payroll-subtotal strong { font-size: 13px; font-weight: 600; color: var(--primary); white-space: nowrap; }
.income-card [id^="payroll-preview-"] { min-width: 0; max-width: 100%; }
.income-card > .help-details > .form-grid { margin-top: 15px; }
.income-card > .help-details > p { margin-top: 10px; }
.payroll-table input[data-money-yen] { width: 108px; min-width: 100px; }
.payroll-preset-row > .payroll-secondary { margin-top: 0; }
.payroll-overview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 26px; margin-top: 16px; }
.payroll-overview > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.payroll-overview > div > span { color: var(--muted); font-size: 10px; }
.payroll-overview strong { font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; white-space: nowrap; }
.payroll-overview .stat-strip { margin: 0; }
.slip-reference { margin-top: 13px; padding: 11px 13px; border-radius: 7px; background: var(--surface-soft); border: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 1.85; font-variant-numeric: tabular-nums; }
.slip-reference strong { font-weight: 600; color: #65765c; }
.slip-reference .badge { background: #edf1e7; color: #8a967e; margin-right: 5px; }
.payroll-preset-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 13px 0 18px; }
.payroll-preset-row .button { flex-shrink: 0; }
.payroll-preset-row .subtle, .payroll-preset-row p { font-size: 10px; line-height: 1.75; color: var(--muted); }
.payroll-checkbox { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 10px; color: #718369; cursor: pointer; }
.payroll-checkbox input { flex: 0 0 15px; }
.payroll-secondary { font-size: 10px; line-height: 1.8; color: var(--muted); margin-top: 8px; }
.payroll-period { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.payroll-period .number-input, .payroll-period input { width: 80px; min-width: 70px; }
.payroll-group .form-grid { margin-top: 13px; margin-bottom: 0; }
.payroll-group .field { min-width: 0; }
.payroll-group .field label { min-height: 18px; }
.payroll-group .input-unit select { min-width: 0; width: 100%; }
@media (max-width: 760px) {
  .income-card > p { font-size: 10px; }
  .payroll-group { margin-top: 18px; padding-top: 16px; }
  .payroll-group-heading { align-items: flex-start; gap: 8px; flex-wrap: wrap; }
  .payroll-group-heading h4 { font-size: 12px; }
  .payroll-group-heading p { font-size: 9px; }
  .payroll-table input.number-input { font-size: 13px; }
  .payroll-preset-row { align-items: flex-start; gap: 8px; padding-top: 8px; }
  .payroll-preset-row .subtle, .payroll-preset-row p { font-size: 9px; }
  .payroll-overview { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .payroll-subtotal { font-size: 9px; }
  .payroll-subtotal > .stat-strip { gap: 16px; font-size: 10px; }
  .payroll-subtotal strong { font-size: 12px; }
  .slip-reference { padding: 10px 11px; font-size: 9px; }
  .payroll-secondary { font-size: 9px; }
}

/* Shared plans, authentication, and review */
.login-page { min-height:100dvh; display:grid; place-items:center; padding:24px; }
.login-card { width:min(100%,460px); padding:38px; border:1px solid var(--line); background:white; border-radius:20px; box-shadow:var(--shadow); }
.login-card h1 { margin:10px 0 16px; }
.login-card p { margin:14px 0; }
.login-card .button.primary { width:100%; margin:10px 0; min-height:46px; font-size:14px; }
.review-summary { white-space:pre-line; padding:18px 0; font-size:14px; }
.review-meta { display:flex; align-items:center; gap:12px; flex-wrap:wrap; color:var(--muted); font-size:11px; margin-top:15px; }
.review-group { margin-top:20px; }
.review-observation { margin-top:12px; padding:14px 16px; background:var(--surface-soft); border:1px solid var(--line); border-radius:10px; }
.review-observation p { white-space:pre-line; margin:6px 0; font-size:12px; }
.review-evidence { display:block; margin-top:8px; padding-top:8px; border-top:1px solid var(--line); color:var(--muted); }
.deduction-options { display:flex; flex-direction:column; gap:12px; }
.checkbox-label { align-items:flex-start; }
.import-preview { max-height:300px; overflow:auto; padding-left:22px; }
.saved-case strong { overflow-wrap:anywhere; }
.notice .button { margin:8px 4px 0; }
@media(max-width:760px) {
  .workspace { min-width:0; }
  .panel-actions { width:100%; justify-content:flex-start; }
  .panel-header { flex-wrap:wrap; }
  .topbar-actions { width:100%; gap:8px; }
  .topbar-actions #save-state { flex-basis:100%; }
  .compare-select-label { flex:1; min-width:0; }
  #compare-select { max-width:100%; width:100%; }
  .saved-case { flex-direction:column; align-items:stretch; gap:14px; }
  .saved-case .row-actions { justify-content:flex-start; }
  .saved-case .row-actions .button { flex:1; }
  .editable-table, .payroll-table, .payroll-wide-table { display:block; min-width:0 !important; width:100%; }
  .editable-table thead { display:none; }
  .editable-table tbody { display:grid; gap:14px; width:100%; }
  .editable-table tbody tr { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); border:1px solid var(--line); border-radius:10px; padding:12px; background:var(--surface); }
  .editable-table tbody td { display:flex; flex-direction:column; justify-content:flex-start; min-width:0 !important; width:auto !important; max-width:none; padding:7px !important; border:0; text-align:left; white-space:normal; }
  .editable-table tbody td::before { content:attr(data-label); display:block; color:var(--muted); font-size:10px; margin-bottom:5px; }
  .editable-table input, .editable-table select { width:100% !important; max-width:100%; min-width:0 !important; font-size:16px; }
  .editable-table input[type=checkbox] { width:22px !important; height:22px; }
  .editable-table .icon-button { margin-top:12px; }
  .form-grid input, .form-grid select { font-size:16px; }
  .chart-wrap svg { min-width:0 !important; }
  .year-detail .stat-strip { gap:14px; }
  .year-detail .stat-strip strong { white-space:nowrap; }
  .monthly-expense-card strong { white-space:nowrap; }
  .login-card { padding:25px; }
  .button { min-height:42px; }
  .icon-button { min-width:36px; min-height:36px; }
  .deduction-options .checkbox-label { display:flex; gap:10px; }
  .review-observation { padding:13px; }
}

/* Plan loading and chart comparison have distinct controls. */
.plan-select-label { display:flex; align-items:center; gap:7px; min-width:0; font-size:11px; color:var(--muted); }
.plan-select-label > span { white-space:nowrap; }
.plan-select-label select { min-height:35px; max-width:250px; padding:6px 26px 6px 10px; font-size:12px; text-overflow:ellipsis; }
.comparison-menu-label { display:flex; flex-direction:column; gap:7px; padding:10px; font-size:11px; color:var(--muted); border-bottom:1px solid var(--line); }
.comparison-menu-label select { width:100%; min-height:35px; font-size:12px; }
@media(max-width:760px) {
  .plan-select-label { flex:1; }
  .plan-select-label select { width:100%; max-width:100%; min-width:0; }
}

.save-orb { display:inline-block; width:9px; height:9px; border-radius:50%; background:#57997b; flex-shrink:0; }
.save-orb.save-error { background:#c68b43; }
@media(max-width:760px){.topbar-actions{flex-wrap:wrap}.topbar-actions #save-state{flex-basis:auto}}

.update-plan-button[hidden] { display:none !important; }
@media(max-width:760px) {
  .update-plan-button { position:fixed; right:20px; bottom:calc(22px + env(safe-area-inset-bottom)); z-index:90; border-radius:28px; padding:14px 25px !important; font-size:15px !important; min-height:50px !important; box-shadow:0 5px 20px #173f3644; }
}

.consultation-text { width:100%; height:38vh; min-height:220px; resize:vertical; padding:14px; border:1px solid var(--line); border-radius:10px; font:12px/1.7 monospace; background:var(--surface-soft); }
@media(max-width:760px){.consultation-text{font-size:16px}.modal-footer{flex-wrap:wrap}}
