:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f0f3f5;
  --ink: #202327;
  --muted: #68727d;
  --line: #d9dee4;
  --line-strong: #b8c0c8;
  --teal: #167c72;
  --teal-dark: #0d5f57;
  --green: #138a55;
  --red: #b33434;
  --amber: #b76d1f;
  --blue: #346aa5;
  --violet: #7654a6;
  --shadow: 0 12px 32px rgba(26, 31, 36, 0.07);
  --radius: 8px;
  --sidebar: 252px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
}
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 25px; line-height: 1.15; }
h2 { margin-bottom: 3px; font-size: 16px; }
h3 { margin-bottom: 4px; font-size: 14px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  color: #f8fafb;
  background: #24282d;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 0 4px; }
.brand canvas { width: 44px; height: 44px; flex: 0 0 44px; border-radius: var(--radius); background: #fff; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 15px; }
.brand span { color: #aeb6be; font-size: 12px; }
.nav-list { display: grid; gap: 5px; }
.nav-item {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #d8dde2;
  background: transparent;
  text-align: left;
  font-weight: 700;
}
.nav-item:hover, .nav-item:focus-visible { background: #30353b; }
.nav-item.active { color: #fff; border-color: #3d8580; background: #31514f; }
.sync-box { margin-top: auto; padding: 12px; display: flex; gap: 10px; border: 1px solid #3b4147; border-radius: var(--radius); background: #2b3035; }
.sync-box strong, .sync-box span { display: block; }
.sync-box strong { font-size: 12px; }
.sync-box span:not(.status-dot) { color: #aeb6be; font-size: 11px; }
.status-dot { width: 8px; height: 8px; margin-top: 5px; flex: 0 0 8px; border-radius: 50%; background: #31b77b; box-shadow: 0 0 0 3px rgba(49, 183, 123, .15); }
.status-dot.pending { background: var(--amber); box-shadow: 0 0 0 3px rgba(183, 109, 31, .15); }

.main { min-width: 0; padding: 22px 26px 42px; }
.topbar { min-height: 74px; display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 18px; }
.eyebrow { margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.topbar-actions, .toolbar, .form-row, .manual-expense-entry { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.session-pill { min-height: 42px; min-width: 108px; padding: 6px 11px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.session-pill span, .session-pill strong { display: block; }
.session-pill span { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.session-pill strong { font-size: 13px; }

.view, .payroll-pane, .scenario-pane, .settings-pane { display: none; }
.view.active, .payroll-pane.active, .scenario-pane.active, .settings-pane.active { display: block; }
.view { animation: reveal .18s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

.button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}
.button:hover { filter: brightness(.98); }
.button.primary { color: #fff; border-color: var(--teal); background: var(--teal); }
.button.secondary { color: var(--teal-dark); border-color: #9dc9c5; background: #eaf6f4; }
.button.subtle { min-height: 34px; color: var(--muted); background: #fff; }
.button.danger { color: var(--red); border-color: #e5b2b2; background: #fff7f7; }
.button.mini { min-height: 30px; padding: 0 9px; font-size: 12px; }
.hidden { display: none !important; }
.app-shell.is-locked { display: none; }

.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, .9fr) minmax(440px, 1.1fr); background: #eef1f3; }
.login-screen.hidden { display: none; }
.login-brand-panel { min-height: 100vh; padding: 54px; display: flex; align-items: flex-end; color: #fff; background: #243033; border-right: 8px solid #167c72; }
.login-brand-lockup { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 18px; align-items: center; }
.login-brand-lockup img, .login-brand-lockup canvas { width: 72px; height: 72px; border-radius: var(--radius); background: #fff; object-fit: contain; }
.login-brand-lockup img[hidden] { display: none; }
.login-brand-lockup strong, .login-brand-lockup span { display: block; }
.login-brand-lockup strong { font-size: 28px; }
.login-brand-lockup span { margin-top: 4px; color: #c9d7d6; }
.login-form-panel { min-height: 100vh; padding: 30px; display: grid; place-items: center; }
.login-form { width: min(390px, 100%); padding: 28px; display: grid; gap: 17px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 24px 60px rgba(27, 35, 42, .12); }
.login-form h1 { font-size: 28px; }
.login-submit { min-height: 44px; }
.link-button { padding: 4px; border: 0; color: var(--teal-dark); background: transparent; font-weight: 800; text-align: center; }
.form-error { min-height: 20px; margin: -5px 0; color: var(--red); font-size: 12px; }

.field { display: grid; gap: 5px; min-width: 0; }
.field.compact { min-width: 150px; }
.field.narrow { width: 110px; }
.field span, .field-label { color: var(--muted); font-size: 11px; font-weight: 800; }
.field small { color: var(--muted); font-size: 10px; }
input, select {
  min-height: 38px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(22, 124, 114, .12); }
input[readonly], select:disabled { color: #59616a; border-color: var(--line); background: #f1f3f5; cursor: default; }
input[type="range"] { min-height: 26px; padding: 0; accent-color: var(--teal); }
input[type="checkbox"] { width: 17px; height: 17px; min-height: auto; accent-color: var(--teal); }

.source-summary {
  min-height: 54px;
  margin-bottom: 14px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  border: 1px solid #b9d9d4;
  border-radius: var(--radius);
  background: #edf7f5;
}
.relation-summary { margin-bottom: 14px; padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 7px 14px; align-items: center; border: 1px solid #c8d5e4; border-radius: var(--radius); background: #f1f5f9; }
.relation-summary strong { margin-right: 3px; }
.relation-summary span { color: var(--muted); font-size: 11px; }
.relation-summary span::before { content: ""; display: inline-block; width: 5px; height: 5px; margin: 0 7px 1px 0; border-radius: 50%; background: var(--blue); }
.source-summary > div { display: grid; grid-template-columns: auto auto; align-items: center; gap: 0 9px; }
.source-summary small { grid-column: 2; color: var(--muted); }

.panel { min-width: 0; margin-bottom: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.panel-header { min-height: 66px; padding: 15px 16px; display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; border-bottom: 1px solid var(--line); }
.panel-header p { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.toolbar input { width: 190px; }
.toolbar select { width: 170px; }
.table-wrap { width: 100%; overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
.data-table th { color: var(--muted); background: #f4f6f7; font-size: 11px; text-transform: uppercase; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td.numeric, .data-table th.numeric { text-align: right; }
.data-table input.amount-input { width: 132px; max-width: 100%; min-height: 34px; text-align: right; font-weight: 800; }
.data-table select.source-select { width: 140px; max-width: 100%; min-height: 34px; }
.cell-primary, .cell-secondary { display: block; }
.cell-primary { font-weight: 800; }
.cell-secondary { max-width: 310px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; }
.group-dot { width: 7px; height: 7px; margin-right: 6px; display: inline-block; border-radius: 50%; vertical-align: 1px; }
.actions { display: flex; gap: 6px; }
.concept-table { min-width: 900px; table-layout: fixed; }
.concept-table th:nth-child(1) { width: 29%; }
.concept-table th:nth-child(2) { width: 8%; }
.concept-table th:nth-child(3) { width: 16%; }
.concept-table th:nth-child(4) { width: 16%; }
.concept-table th:nth-child(5) { width: 15%; }
.concept-table th:nth-child(6) { width: 16%; }
.concept-table .actions .button { padding: 0 7px; }
.concept-table .cell-secondary { max-width: 250px; }

.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 999px; font-size: 10px; font-weight: 900; white-space: nowrap; }
.badge.income, .badge.active { color: #0d6f43; background: #e8f6ee; }
.badge.expense, .badge.inactive { color: #9c3131; background: #fbeaea; }
.badge.adjustment { color: #8a5a18; background: #f8efe2; }
.badge.api { color: var(--teal-dark); background: #e4f3f1; }
.badge.excel { color: var(--blue); background: #e9f0f8; }
.badge.manual { color: var(--violet); background: #f0eaf7; }
.badge.formula { color: var(--amber); background: #f7efe5; }
.badge.calculated { color: #59616a; background: #edf0f2; }
.status-text { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.status-text::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #31b77b; }
.status-select { min-width: 126px; min-height: 32px; padding-left: 28px; font-size: 11px; font-weight: 800; background-repeat: no-repeat; background-position: 10px center; background-size: 8px 8px; }
.color-swatch { width: 22px; height: 22px; display: inline-block; border: 1px solid rgba(0,0,0,.12); border-radius: 5px; vertical-align: middle; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric-card { min-height: 116px; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.metric-card span, .metric-card small, .scenario-card span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; }
.metric-card strong { display: block; margin: 10px 0 5px; font-size: 20px; line-height: 1.12; }
.amount-positive { color: var(--green); }
.amount-negative { color: var(--red); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(310px, .75fr); gap: 18px; }
.chart-canvas { display: block; width: 100%; height: 286px; }
.readout-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.readout-item { min-height: 82px; padding: 14px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.readout-item:nth-child(4n) { border-right: 0; }
.readout-item span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 800; }
.readout-item strong { font-size: 17px; }
.comparison-empty { padding: 28px 18px; color: var(--muted); text-align: center; }
.comparison-grid { padding: 16px; display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 10px; }
.comparison-item { padding: 13px; border: 1px solid var(--line); border-radius: var(--radius); background: #fbfcfc; }
.comparison-item span, .comparison-item small { display: block; color: var(--muted); font-size: 11px; }
.comparison-item strong { display: block; margin: 7px 0 3px; font-size: 18px; }

.subnav { display: flex; gap: 4px; margin-bottom: 14px; padding: 4px; width: fit-content; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #e9edef; }
.subnav-item, .segment { min-height: 34px; padding: 0 11px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-weight: 800; white-space: nowrap; }
.subnav-item.active, .segment.active { color: var(--ink); background: #fff; box-shadow: 0 1px 4px rgba(28, 34, 40, .12); }
.segmented { display: inline-grid; grid-auto-flow: column; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); }
.salary-total { padding: 26px 18px 30px; display: grid; place-items: center; gap: 15px; text-align: center; }
.salary-total label { color: var(--muted); font-weight: 800; }
.salary-total input { width: min(340px, 100%); min-height: 52px; text-align: center; font-size: 24px; font-weight: 900; }
.salary-total .summary-note { color: var(--muted); font-size: 12px; }
.salary-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; }
.payment-summary { padding: 14px 16px; display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); gap: 10px; }
.payment-summary article { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #f8fafb; }
.payment-summary span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; }
.payment-summary strong { display: block; margin-top: 6px; font-size: 18px; }
.warning-band { margin: 0 16px 14px; padding: 10px 12px; border: 1px solid #e4c69d; border-radius: var(--radius); color: #7a5019; background: #fff7e9; }
.wide-table { min-width: 1120px; }
.card-grid { padding: 16px; display: grid; grid-template-columns: repeat(3, minmax(240px, 1fr)); gap: 12px; }
.category-card { min-height: 176px; padding: 14px; display: grid; align-content: space-between; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.category-card header { display: flex; justify-content: space-between; gap: 10px; }
.category-card ul { margin: 10px 0; padding-left: 17px; color: var(--muted); font-size: 12px; }
.category-card footer { display: flex; justify-content: space-between; gap: 10px; align-items: flex-end; }
.category-card footer span { color: var(--muted); font-size: 10px; }
.category-card footer strong { display: block; }
.check-grid { margin-top: 7px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.check-card { min-height: 52px; padding: 9px 10px; display: flex; gap: 9px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); }
.check-card strong, .check-card small { display: block; }
.check-card small { color: var(--muted); font-size: 10px; }

.scenario-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 18px; }
.scenario-controls { padding: 18px; display: grid; gap: 20px; }
.slider-control { display: grid; gap: 8px; }
.slider-control > div { display: grid; grid-template-columns: minmax(0, 1fr) 110px 18px; gap: 6px; align-items: center; }
.slider-control label { font-weight: 800; }
.slider-control input[type="number"] { text-align: right; font-weight: 900; }
.form-row > .field:first-child { flex: 1 1 240px; }
.manual-expense-entry { padding-top: 4px; }
.manual-expense-entry .field { flex: 1 1 170px; }
.stack-list { display: grid; gap: 7px; }
.stack-item { min-height: 42px; padding: 7px 9px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #f8f9fa; }
.stack-item span { color: var(--muted); }
.scenario-result { padding: 16px; display: grid; gap: 10px; }
.scenario-card { min-height: 92px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #fbfcfc; }
.scenario-card strong { display: block; margin-top: 8px; font-size: 23px; }
.scenario-card.hero { color: #fff; border-color: var(--teal-dark); background: var(--teal-dark); }
.scenario-card.hero span { color: #cce5e2; }
.impact-list { padding: 2px 4px; display: grid; gap: 7px; }
.impact-row { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.period-metrics { padding: 16px; margin-bottom: 0; }
.projected-row td { background: #f1f7f6; }
.projection-badge { display: inline-flex; padding: 2px 7px; border-radius: 999px; color: var(--teal-dark); background: #dff0ed; font-size: 10px; font-weight: 900; }
.scenario-editor { padding: 16px; display: grid; gap: 14px; }
.scenario-titlebar { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.scenario-month-input { width: 140px; text-align: right; }
.scenario-notes-input { width: 220px; }
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.settings-nav { padding: 8px; display: grid; gap: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.settings-nav-group { display: grid; gap: 3px; }
.settings-nav-group > span { padding: 5px 8px 3px; color: var(--muted); font-size: 10px; font-weight: 900; text-transform: uppercase; }
.settings-nav-item { min-height: 36px; padding: 7px 9px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; text-align: left; font-weight: 800; }
.settings-nav-item:hover, .settings-nav-item:focus-visible { background: var(--surface-soft); }
.settings-nav-item.active { color: var(--teal-dark); background: #e7f3f1; }
.settings-content { min-width: 0; }
.settings-pane .panel { min-height: 220px; margin-bottom: 0; }
.settings-pane .panel + .panel { margin-top: 16px; }
.settings-form { padding: 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.group-table { min-width: 760px; }
.group-name { display: flex; gap: 9px; align-items: center; }
.group-name > span:last-child, .group-name strong, .group-name small { display: block; }
.group-name small { max-width: 360px; margin-top: 2px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; }
.form-note { margin: 0; color: var(--muted); font-size: 11px; }
.api-status { min-height: 44px; padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); background: #f8fafb; }
.api-status span:not(.badge), .api-status small { color: var(--muted); font-size: 12px; }
.inline-note { margin: 0; padding: 10px 16px; border-bottom: 1px solid var(--line); color: var(--muted); background: #f8fafb; }
.formula-builder { padding: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #f8fafb; }
.formula-preview, .api-mapping-card { min-height: 48px; padding: 10px 12px; display: grid; gap: 3px; border: 1px solid #c8d5e4; border-radius: var(--radius); background: #f1f5f9; }
.formula-preview span, .api-mapping-card span, .api-mapping-card small { color: var(--muted); font-size: 11px; font-weight: 800; }
.formula-preview strong, .api-mapping-card strong { font-size: 13px; }

.modal { width: min(640px, calc(100vw - 28px)); max-height: calc(100vh - 30px); padding: 0; border: 0; border-radius: var(--radius); box-shadow: 0 28px 80px rgba(0, 0, 0, .25); overflow: auto; }
.large-modal { width: min(780px, calc(100vw - 28px)); }
.small-modal { width: min(430px, calc(100vw - 28px)); }
.modal::backdrop { background: rgba(25, 29, 33, .46); }
.modal-header { padding: 15px 16px; display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.modal-header p { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.form-grid { padding: 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.span-2 { grid-column: span 2; }
.check-field { min-height: 42px; padding: 9px 10px; display: flex; gap: 9px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); background: #f8fafb; }
.check-field span { color: var(--ink); font-size: 12px; font-weight: 700; }
.seniority-preview { padding: 11px 12px; display: flex; justify-content: space-between; gap: 12px; border: 1px solid #b9d9d4; border-radius: var(--radius); background: #edf7f5; }
.seniority-preview span { color: var(--muted); font-size: 11px; font-weight: 800; }
.modal-actions { padding: 13px 16px; display: flex; justify-content: flex-end; gap: 9px; border-top: 1px solid var(--line); }
.danger-split { display: grid; grid-template-columns: auto 1fr auto auto; }
.info-copy { padding: 18px; }
.info-copy p:last-child { margin-bottom: 0; }
.payroll-fields { padding: 16px; display: grid; gap: 10px; }
.payroll-field { display: grid; grid-template-columns: minmax(0, 1fr) 170px; gap: 12px; align-items: center; }
.payroll-field small { display: block; color: var(--muted); }
.payroll-field input { text-align: right; font-weight: 800; }
.reset-content { padding: 22px; display: grid; gap: 12px; text-align: center; }
.reset-content span { color: var(--muted); font-size: 11px; font-weight: 800; }
.reset-content strong { padding: 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius); font-size: 20px; letter-spacing: 1px; background: #f6f8f9; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: 330px; padding: 11px 14px; border-radius: var(--radius); color: #fff; background: #202327; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .18s ease; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sync-box { display: none; }
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card-grid { grid-template-columns: repeat(2, minmax(240px, 1fr)); }
}
@media (max-width: 820px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-brand-panel { min-height: 220px; padding: 28px; align-items: center; }
  .login-form-panel { min-height: auto; padding: 22px 14px; }
  .main { padding: 18px 14px 34px; }
  .topbar { display: grid; }
  .topbar-actions > * { flex: 1 1 150px; }
  .nav-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .scenario-layout, .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-grid, .payment-summary, .comparison-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .readout-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .readout-item:nth-child(4n) { border-right: 1px solid var(--line); }
  .readout-item:nth-child(2n) { border-right: 0; }
  .card-grid, .check-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .sidebar { padding: 14px 10px; }
  .metric-grid, .payment-summary, .comparison-grid { grid-template-columns: 1fr; }
  .panel-header, .source-summary { display: grid; }
  .toolbar { display: grid; width: 100%; }
  .toolbar input, .toolbar select { width: 100%; }
  .settings-nav { grid-template-columns: 1fr; }
  .form-grid, .settings-form, .formula-builder { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .danger-split { grid-template-columns: 1fr 1fr; }
  .danger-split span { display: none; }
  .payroll-field { grid-template-columns: 1fr; }
  .slider-control > div { grid-template-columns: minmax(0, 1fr) 88px 18px; }
}
