:root {
  color-scheme: light;
  --paper: #f5f0e8;
  --paper-deep: #e8e0d3;
  --ink: #202522;
  --muted: #6d716b;
  --rule: #beb8ad;
  --teal: #1f6d70;
  --teal-deep: #174d50;
  --orange: #c95a32;
  --orange-soft: #f1d5c9;
  --yellow: #dcae45;
  --cream: #fffaf1;
  --danger: #9f342b;
  --focus: #005fcc;
  --shadow: 0 14px 36px rgb(32 37 34 / 0.1);
}

* { box-sizing: border-box; }
html { overflow-x: hidden; scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
  color: var(--ink);
  background-color: var(--paper);
  background-image: linear-gradient(rgb(32 37 34 / 0.045) 1px, transparent 1px), linear-gradient(90deg, rgb(32 37 34 / 0.035) 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
  line-height: 1.55;
}

button, input, select { font: inherit; }
button, select, input[type="file"] { cursor: pointer; }
button:disabled, select:disabled { cursor: not-allowed; opacity: 0.52; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }

.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; width: 1px; height: 1px; overflow: hidden; padding: 0; color: white; background: var(--ink); clip-path: inset(50%); }
.skip-link:focus { width: auto; height: auto; overflow: visible; padding: 8px 12px; clip-path: none; }
.eyebrow { margin: 0 0 8px; color: var(--teal); font: 700 0.72rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.14em; text-transform: uppercase; }

.masthead { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 32px clamp(20px, 4vw, 64px) 24px; border-bottom: 3px solid var(--ink); background: rgb(245 240 232 / 0.92); }
.masthead h1 { margin: 0; font: 800 clamp(2.2rem, 5vw, 4.5rem)/0.89 "Yu Mincho", "Hiragino Mincho ProN", serif; letter-spacing: -0.055em; }
.masthead h1 span { color: var(--teal); }
.masthead__note { display: flex; align-items: center; gap: 12px; min-width: 230px; padding: 12px 16px; border: 1px solid var(--rule); background: var(--cream); box-shadow: 5px 5px 0 var(--ink); }
.masthead__note strong, .masthead__note small { display: block; }
.masthead__note small { color: var(--muted); }
.status-light { width: 12px; height: 12px; flex: 0 0 auto; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 5px rgb(31 109 112 / 0.15); }

.privacy-banner { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; padding: 16px clamp(20px, 4vw, 64px); color: white; background: var(--teal-deep); }
.privacy-banner__mark { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid rgb(255 255 255 / 0.55); border-radius: 50%; font-family: "Yu Mincho", serif; }
.privacy-banner strong { font-family: "Yu Mincho", serif; }
.privacy-banner p { margin: 2px 0 0; color: rgb(255 255 255 / 0.76); font-size: 0.82rem; }
.privacy-banner__code { font: 700 0.68rem ui-monospace, monospace; letter-spacing: 0.12em; }

.workbench { display: grid; grid-template-columns: minmax(310px, 390px) minmax(0, 1fr); align-items: start; max-width: 1760px; margin-inline: auto; }
.setup-panel { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; padding: 24px; border-right: 2px solid var(--ink); background: var(--paper-deep); }
.results-panel { min-width: 0; padding: clamp(24px, 4vw, 56px); }

.section-heading { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 20px; }
.section-heading > span { flex: 0 0 auto; padding: 5px 8px; color: white; background: var(--ink); font: 700 0.66rem ui-monospace, monospace; letter-spacing: 0.12em; }
.section-heading h2, .section-heading p { margin: 0; }
.section-heading h2 { font: 800 clamp(1.25rem, 2vw, 1.7rem)/1.2 "Yu Mincho", serif; }
.section-heading p { margin-top: 4px; color: var(--muted); font-size: 0.84rem; }
.section-heading--compact { margin-bottom: 18px; }
.section-heading--with-control > div { flex: 1; }
.slot-filter { display: grid; flex: 0 0 112px; gap: 3px; color: var(--muted); font-size: 0.65rem; font-weight: 800; }
.slot-filter select { min-height: 34px; }

.setup-step { display: grid; grid-template-columns: 32px 1fr; gap: 10px; padding: 18px 0; border-top: 1px solid var(--rule); }
.step-number { color: var(--orange); font: 800 0.8rem ui-monospace, monospace; }
.setup-step h3 { margin: 0 0 12px; font-size: 0.96rem; }
.file-drop { display: grid; min-height: 84px; padding: 14px; place-content: center; text-align: center; border: 1px dashed var(--teal); background: rgb(255 250 241 / 0.7); }
.file-drop span { color: var(--teal-deep); font-weight: 800; }
.file-drop small { color: var(--muted); font-size: 0.7rem; }
.file-drop input { max-width: 100%; margin-top: 8px; font-size: 0.72rem; }
.button-row { display: flex; align-items: end; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 12px; padding: 9px 14px; border: 1px solid var(--ink); border-radius: 0; font-weight: 800; box-shadow: 3px 3px 0 var(--ink); transition: transform 120ms ease, box-shadow 120ms ease; }
.button:hover:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.button--primary { width: 100%; justify-content: space-between; color: white; background: var(--teal-deep); }
.button--quiet { background: var(--cream); font-size: 0.76rem; }
.button--accent { color: white; background: var(--orange); }
.button--danger { color: var(--danger); background: transparent; }
.compact-field { display: grid; gap: 3px; color: var(--muted); font-size: 0.68rem; }
.compact-field select { min-height: 34px; }
.inline-status { margin: 10px 0 0; color: var(--teal-deep); font: 700 0.7rem ui-monospace, monospace; overflow-wrap: anywhere; }
.mapping-grid, .hearing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mapping-grid label, .hearing-grid label, .result-controls label, .what-if__controls label { display: grid; position: relative; gap: 4px; color: var(--muted); font-size: 0.69rem; font-weight: 700; }
input, select { width: 100%; min-width: 0; min-height: 38px; padding: 7px 9px; color: var(--ink); border: 1px solid var(--rule); border-radius: 0; background: var(--cream); }
.hearing-grid label span, .what-if__controls label span { position: absolute; right: 8px; bottom: 9px; color: var(--muted); font-size: 0.65rem; pointer-events: none; }
.field-note { margin: -4px 0 12px; color: var(--muted); font-size: 0.72rem; }
.badge { display: inline-flex; align-items: center; padding: 3px 7px; border: 1px solid currentcolor; font-size: 0.65rem; font-weight: 800; letter-spacing: 0.04em; }
.badge--assumption { color: var(--orange); background: var(--cream); }
.badge--estimated { color: var(--teal-deep); background: rgb(31 109 112 / 0.1); }

.empty-state { min-height: 66vh; display: grid; align-content: center; padding: clamp(24px, 6vw, 80px); border: 1px solid var(--rule); background: rgb(255 250 241 / 0.72); box-shadow: var(--shadow); }
.empty-state h2 { max-width: 14ch; margin: 0; font: 800 clamp(2rem, 4vw, 4.2rem)/1 "Yu Mincho", serif; }
.empty-state ol { display: grid; grid-template-columns: repeat(7, minmax(70px, 1fr)); gap: 1px; margin: 40px 0 24px; padding: 0; list-style: none; background: var(--ink); border: 1px solid var(--ink); overflow-x: auto; }
.empty-state li { min-width: 82px; padding: 14px 10px; background: var(--paper); font-size: 0.75rem; font-weight: 800; }
.empty-state li span { display: block; color: var(--orange); font: 700 0.65rem ui-monospace, monospace; }
.empty-state > p:last-child { color: var(--muted); }
.error-state { display: flex; gap: 18px; margin-bottom: 24px; padding: 20px; border: 2px solid var(--danger); color: var(--danger); background: #fff1ed; }
.error-state > span { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border: 2px solid; border-radius: 50%; font-weight: 900; }
.error-state h2 { margin: 0; font: 800 1.2rem "Yu Mincho", serif; }
.error-state ul { margin: 8px 0 0; padding-left: 18px; }

.result-header { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding-bottom: 20px; border-bottom: 2px solid var(--ink); }
.result-header h2 { margin: 0; font: 800 clamp(1.8rem, 3vw, 3rem)/1 "Yu Mincho", serif; }
.result-header p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 0.8rem; }
.title-line { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.result-controls { display: flex; gap: 10px; }
.result-controls select { min-width: 145px; }
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 1px; margin: 24px 0; padding: 1px; background: var(--ink); }
.kpi-grid article { min-width: 0; padding: 16px; background: var(--cream); }
.kpi-grid article > * { display: block; }
.kpi-grid span { color: var(--muted); font-size: 0.68rem; font-weight: 800; }
.kpi-grid strong { margin: 6px 0 2px; font: 900 clamp(1.45rem, 2.5vw, 2.4rem)/1 ui-monospace, monospace; }
.kpi-grid small { color: var(--muted); font-size: 0.65rem; }
.kpi-grid__accent { color: white !important; background: var(--orange) !important; }
.kpi-grid__accent span, .kpi-grid__accent small { color: rgb(255 255 255 / 0.78); }

.analysis-section { min-width: 0; margin: 24px 0; padding: clamp(18px, 2.5vw, 30px); border: 1px solid var(--rule); background: rgb(255 250 241 / 0.86); box-shadow: var(--shadow); }
.timeline-section { border-top: 5px solid var(--teal); }
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 14px; font-size: 0.68rem; font-weight: 800; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; background: currentcolor; }
.legend__reception { color: #998b77; }.legend__wait { color: #dcae45; }.legend__transfer { color: #66a6a7; }.legend__treatment { color: #1f6d70; }.legend__checkout { color: #c95a32; }
.timeline-scroll { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; border: 1px solid var(--rule); background: var(--cream); }
.timeline-canvas { min-width: 900px; }
.timeline-axis, .timeline-row { display: grid; grid-template-columns: 134px 1fr; position: relative; }
.timeline-axis { min-height: 42px; border-bottom: 1px solid var(--ink); background: var(--paper-deep); }
.timeline-axis > span { align-self: center; padding-inline: 12px; font: 700 0.65rem ui-monospace, monospace; }
.timeline-axis__ticks { position: relative; margin-right: 18px; border-left: 1px solid var(--rule); }
.timeline-axis__ticks i { position: absolute; top: 12px; color: var(--muted); font: normal 0.61rem ui-monospace, monospace; transform: translateX(-50%); }
.timeline-row { min-height: 58px; border-bottom: 1px solid var(--rule); }
.timeline-row:last-child { border-bottom: 0; }
.timeline-row:hover, .timeline-row[aria-expanded="true"] { background: #f1eadf; }
.timeline-row__label { display: grid; align-content: center; padding: 8px 12px; border-right: 1px solid var(--rule); }
.timeline-row__label strong { font-size: 0.76rem; }
.timeline-row__label span { color: var(--muted); font-size: 0.61rem; }
.timeline-row__label em { width: max-content; margin-top: 2px; color: var(--danger); font: normal 700 0.58rem ui-monospace, monospace; }
.timeline-row__track { position: relative; margin-right: 18px; background-image: repeating-linear-gradient(90deg, transparent 0, transparent calc(11.111% - 1px), rgb(32 37 34 / 0.1) calc(11.111% - 1px), rgb(32 37 34 / 0.1) 11.111%); }
.stage { position: absolute; top: 17px; height: 22px; min-width: 3px; border-right: 1px solid rgb(255 255 255 / 0.65); }
.stage--reception { background: #998b77; }.stage--wait { background: #dcae45; }.stage--transfer { background: #66a6a7; }.stage--treatment { background: #1f6d70; }.stage--checkout { background: #c95a32; }
.timeline-marker { position: absolute; z-index: 2; top: 11px; width: 3px; height: 34px; background: var(--ink); }
.timeline-row__expanded { grid-column: 1 / -1; padding: 8px 12px; color: var(--teal-deep); border-top: 1px dashed var(--rule); font: 700 0.65rem ui-monospace, monospace; }

.analysis-columns { display: grid; grid-template-columns: 1.25fr 0.75fr; gap: 24px; }
.analysis-columns .analysis-section { margin: 0; }
.staff-breakdown { display: grid; gap: 16px; }
.staff-breakdown article > div:first-child { display: flex; justify-content: space-between; gap: 12px; font-size: 0.75rem; }
.staff-breakdown article > div:first-child span, .staff-breakdown p { color: var(--muted); }
.staff-breakdown p { margin: 5px 0 0; font-size: 0.65rem; }
.stacked-bar { display: flex; height: 18px; margin-top: 7px; overflow: hidden; border: 1px solid var(--ink); background: white; }
.stacked-bar span { min-width: 0; }.stacked-bar__treatment { background: var(--teal); }.stacked-bar__turnover { background: var(--orange); }.stacked-bar__idle { background: var(--paper-deep); }
.turnover-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.turnover-stats article { padding: 12px; border: 1px solid var(--rule); }
.turnover-stats article > * { display: block; }
.turnover-stats strong, .turnover-stats small { color: var(--muted); font-size: 0.63rem; }
.turnover-stats b { margin-block: 4px; font: 800 1.2rem ui-monospace, monospace; }
.warning-list { display: grid; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.warning-list li { padding: 8px 10px; border-left: 3px solid var(--orange); background: var(--orange-soft); font-size: 0.68rem; }
.warning-list__healthy { border-left-color: var(--teal) !important; background: rgb(31 109 112 / 0.1) !important; }

.heatmap-scroll, .comparison-wrap { max-width: 100%; overflow-x: auto; }
.heatmap, .comparison { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 0.68rem; }
.heatmap th, .heatmap td, .comparison th, .comparison td { padding: 7px 8px; border: 1px solid var(--rule); text-align: center; }
.heatmap th, .comparison th { background: var(--paper-deep); font-weight: 800; }
.heatmap__cell { color: color-mix(in srgb, var(--ink) calc((1 - var(--heat)) * 100%), white); background: color-mix(in srgb, var(--teal) calc(var(--heat) * 100%), var(--cream)); font-weight: 800; }
.heatmap__empty { color: var(--rule); }
.capacity-note { margin-top: 12px; padding: 10px 12px; border-left: 4px solid var(--yellow); background: #f8edd1; font-size: 0.72rem; }

.what-if { border: 2px solid var(--orange); box-shadow: 8px 8px 0 var(--orange-soft); }
.what-if__layout { display: grid; grid-template-columns: minmax(230px, 0.65fr) minmax(0, 1.35fr); gap: 20px; }
.what-if__controls { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; align-content: start; }
.what-if__controls .button-row { grid-column: 1 / -1; }
.comparison th:first-child, .comparison td:first-child { text-align: left; }
.delta { font-weight: 800; }.delta--good { color: var(--teal-deep); background: rgb(31 109 112 / 0.1); }.delta--watch { color: var(--danger); background: #fff1ed; }
.formula { margin: 24px 0; border: 1px solid var(--ink); background: var(--ink); color: white; }
.formula summary { padding: 13px 18px; cursor: pointer; font: 800 0.8rem ui-monospace, monospace; }
.formula__grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: rgb(255 255 255 / 0.22); border-top: 1px solid rgb(255 255 255 / 0.25); }
.formula article { padding: 16px; background: var(--ink); }
.formula h3 { margin: 0 0 6px; color: #8ec7c8; font: 800 0.8rem "Yu Mincho", serif; }
.formula p { margin: 0; color: rgb(255 255 255 / 0.72); font-size: 0.68rem; }
.report-actions { display: flex; gap: 12px; justify-content: flex-end; }
.report-actions .button--primary { width: auto; }
.print-privacy { margin: 20px 0 0; color: var(--muted); font-size: 0.68rem; text-align: right; }

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
@media (max-width: 1080px) {
  .workbench { grid-template-columns: 320px minmax(0, 1fr); }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .analysis-columns, .what-if__layout { grid-template-columns: 1fr; }
  .formula__grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .masthead { align-items: start; flex-direction: column; padding: 24px 18px; }
  .masthead__note { width: 100%; }
  .privacy-banner { grid-template-columns: auto 1fr; padding: 14px 18px; }
  .privacy-banner__code { display: none; }
  .workbench { display: block; }
  .setup-panel { position: static; max-height: none; overflow: visible; border-right: 0; border-bottom: 2px solid var(--ink); }
  .results-panel { padding: 24px 16px 40px; }
  .result-header { align-items: start; flex-direction: column; }
  .result-controls { width: 100%; }
  .result-controls label { flex: 1; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-grid article:last-child { grid-column: 1 / -1; }
  .timeline-section { padding-inline: 12px; }
  .analysis-columns { display: contents; }
  .analysis-columns .analysis-section { margin: 24px 0; }
  .what-if__controls { grid-template-columns: 1fr 1fr; }
  .formula__grid { grid-template-columns: 1fr; }
  .report-actions { align-items: stretch; flex-direction: column; }
  .report-actions .button--primary { width: 100%; }
}
@media (max-width: 430px) {
  .masthead h1 { font-size: 2.5rem; }
  .mapping-grid, .hearing-grid { grid-template-columns: 1fr 1fr; }
  .privacy-banner { align-items: start; }
  .privacy-banner__mark { width: 32px; height: 32px; }
  .privacy-banner p { font-size: 0.72rem; }
  .empty-state { padding: 24px 18px; }
  .empty-state ol { margin-top: 28px; }
  .result-header h2 { font-size: 1.7rem; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-grid article { padding: 13px; }
  .kpi-grid strong { font-size: 1.35rem; }
  .section-heading { align-items: flex-start; }
  .turnover-stats { grid-template-columns: 1fr; }
  .what-if__controls { grid-template-columns: 1fr; }
  .what-if__controls .button-row { grid-column: 1; }
}
