:root {
  color-scheme: light;
  --red: #c9233b;
  --red-dark: #a9172e;
  --ink: #26272a;
  --muted: #666a73;
  --line: #e5e6e9;
  --surface: #f4f4f6;
  --low: #ecf1f4;
  --reduced: #dbe9e7;
  --normal: #a9c9bb;
  --elevated: #f5d9a0;
  --high: #f2ad75;
  --critical: #c9233b;
  --day-surplus: #8eb5df;
  --day-surplus-line: #3676b8;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--surface); }
button, input, select { font: inherit; }
button, select, summary { cursor: pointer; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid #315d9a; outline-offset: 3px; }
[hidden] { display: none !important; }
.container { max-width: 1440px; padding: 0 40px; margin: auto; }
select { border: 1px solid #d3d5d9; border-radius: 5px; background: #fff; padding: 11px 30px 11px 12px; min-height: 44px; color: var(--ink); }
main { min-height: 62vh; }
h2 { font-size: 20px; letter-spacing: -.4px; margin: 0; }
h3 { font-size: 17px; margin: 0; }
p { line-height: 1.6; margin: 0; }
.sub { color: var(--muted); font-size: 13px; line-height: 1.5; }
.panel { border: 1px solid var(--line); background: #fff; border-radius: 7px; }
.dashboard-panel { overflow: hidden; }
.context-controls { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.control { min-width: 0; }
.control > label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 7px; }
.control select { width: 210px; }
.period-control select { width: 185px; }
.date-control { position: relative; }
.date-trigger { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 225px; min-height: 44px; padding: 11px 13px; background: white; border: 1px solid #d3d5d9; border-radius: 5px; }
.date-trigger svg { width: 18px; height: 18px; fill: none; stroke: #646a73; stroke-width: 1.6; flex-shrink: 0; }
.calendar { position: absolute; right: 0; top: calc(100% + 8px); width: 354px; max-width: calc(100vw - 36px); padding: 16px; background: white; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 8px 28px #24272e24; z-index: 10; }
.calendar-head { display: flex; gap: 7px; align-items: center; margin-bottom: 15px; }
.calendar-head select { flex: 1; min-width: 0; padding: 8px 22px 8px 9px; font-size: 13px; font-weight: 600; }
.calendar-prompt { color: var(--muted); font-size: 11px; margin-bottom: 12px; }
.calendar-nav { flex-shrink: 0; width: 44px; min-height: 44px; background: white; border: 0; font-size: 23px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.calendar-grid button { height: 42px; border: 0; background: white; border-radius: 4px; font-size: 12px; }
.calendar-grid button:hover:enabled { background: #f8e8ec; }
.calendar-grid button.today { box-shadow: inset 0 0 0 1px #df8797; }
.calendar-grid button.in-range:enabled { background: #f8e8ec; }
.calendar-grid button.chosen { background: var(--red); color: white; }
.calendar-grid button.chosen:enabled { background: var(--red); }
.calendar-grid button.chosen:hover { background: var(--red-dark); }
.calendar button:disabled { opacity: .28; cursor: default; }
.weekday { text-align: center; font-size: 10px; color: var(--muted); margin-bottom: 7px; }
.calendar-note { color: var(--muted); font-size: 10px; border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.matrix-caption, .history-caption, .personnel-caption { padding: 15px 18px; }
.matrix-caption { display: flex; align-items: center; gap: 16px; min-height: 74px; color: var(--muted); font-size: 12px; }
.matrix-info > span:first-child { color: var(--ink); font-weight: 600; line-height: 14px; }
.matrix-info { display: flex; flex: 1; flex-direction: column; justify-content: center; gap: 2px; min-width: 0; min-height: 44px; }
.forecast-info { position: relative; border: 0; background: none; color: var(--muted); font-size: 12px; line-height: 14px; height: 14px; min-height: 14px; padding: 0 4px; vertical-align: top; }
.forecast-info::after { content: ""; position: absolute; inset: -15px -13px; }
.matrix-range { min-height: 26px; font-size: 11px; font-weight: 400; line-height: 13px; }
.matrix-controls { display: flex; flex-shrink: 0; justify-content: flex-end; max-width: 100%; gap: 16px; align-items: center; }
.matrix-metric { display: flex; align-items: center; gap: 10px; font-size: 11px; white-space: nowrap; }
.matrix-metric select { width: 150px; font-size: 12px; }
.matrix-sort { display: flex; align-items: center; gap: 10px; font-size: 11px; white-space: nowrap; }
.matrix-sort select { width: 240px; font-size: 12px; }
.view-switch { display: flex; border: 1px solid #d3d5d9; border-radius: 5px; overflow: hidden; flex-shrink: 0; }
.view-switch button { min-height: 42px; min-width: 84px; padding: 8px 12px; background: white; border: 0; font-size: 12px; }
.view-switch button + button { border-left: 1px solid #d3d5d9; }
.view-switch [aria-pressed="true"] { background: #f8e8ec; color: var(--red-dark); font-weight: 700; }
.view-switch button:focus-visible { outline-offset: -3px; }
.chart-scroll { flex: 1; min-height: 0; overflow: auto; border-top: 1px solid var(--line); padding: 12px 22px 20px; }
.workload-chart { display: block; width: 100%; height: 360px; }
.chart-axis-label { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart-axis-title { font-size: 11px; fill: var(--muted); }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-zero { stroke: #9197a1; stroke-width: 1.5; }
.chart-deficit { color: var(--red); }
.chart-surplus { color: var(--day-surplus-line); }
.chart-area { fill: currentColor; opacity: .1; }
.chart-line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.chart-dashed { stroke-dasharray: 4 4; }
.chart-dot { fill: currentColor; stroke: currentColor; stroke-width: 1.5; }
.chart-partial { fill: white; }
.chart-no-data { fill: #f0f1f3; background: #f0f1f3; }
.chart-hit { fill: transparent; cursor: crosshair; }
.chart-cursor { stroke: #9399a3; stroke-width: 1; stroke-dasharray: 3 3; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px 24px; color: var(--muted); font-size: 11px; margin: 6px 0 14px; }
.chart-legend span { display: flex; gap: 7px; align-items: center; }
.chart-key { display: inline-block; width: 18px; height: 3px; background: currentColor; }
.chart-key.chart-no-data { height: 10px; border: 1px solid #d3d5d9; background: #f0f1f3; }
.chart-note { font-size: 11px; color: var(--muted); margin: 8px 0; }
.chart-inspection { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: flex-end; border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.chart-inspection label { display: flex; flex-direction: column; gap: 7px; font-size: 11px; color: var(--muted); }
.chart-inspection input { min-height: 44px; width: 180px; border: 1px solid #d3d5d9; border-radius: 5px; padding: 10px; color: var(--ink); background: white; }
.chart-readout { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 12px; color: var(--muted); padding: 4px 0; }
.chart-readout strong { color: var(--ink); font-size: 18px; }
.chart-readout strong span { font-weight: 400; font-size: 12px; margin-left: 4px; color: var(--muted); }
.chart-readout small { width: 100%; font-size: 11px; }
.heatmap-wrap { overflow-x: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 0; }
.heatmap { --station-width: 212px; width: 100%; min-width: calc(var(--station-width) + var(--matrix-width)); border-collapse: separate; border-spacing: 0; table-layout: fixed; font-variant-numeric: tabular-nums; }
.heatmap thead th { position: sticky; top: 0; z-index: 3; height: 42px; font-size: 11px; font-weight: 400; background: #fff; color: var(--muted); border-bottom: 1px solid var(--line); text-align: center; }
.heatmap .station-column, .heatmap tbody th { width: var(--station-width); padding-left: 22px; text-align: left; }
.heatmap thead .station-column { left: 0; z-index: 5; }
.heatmap thead small { display: block; font-size: 10px; margin-top: 4px; }
.heatmap .day-start { border-left: 1px solid #cdd0d5; }
.heatmap tbody th { position: sticky; left: 0; z-index: 2; background: white; padding-right: 12px; border-bottom: 1px solid #eeeef0; box-shadow: 3px 0 5px #ffffffc0; }
.heatmap tbody td { border-bottom: 1px solid #eeeef0; height: 51px; padding: 4px 2px; }
.station-button { border: 0; background: none; padding: 8px 0; text-align: left; width: 100%; min-height: 62px; font-weight: 400; }
.station-name { font-weight: 700; font-size: 12px; display: flex; justify-content: space-between; margin-bottom: 5px; }
.station-address { font-size: 10px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.station-complex { display: block; margin-top: 4px; font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.station-arrow { color: #8c919a; font-weight: 400; }
.station-button:hover .station-name { color: var(--red); }
.cell { position: relative; height: 28px; width: 100%; border: 0; border-radius: 3px; display: grid; place-items: center; font-size: 11px; }
.day-deficit { background: var(--critical); color: white; }
.day-surplus { background: var(--day-surplus); }
.day-balanced { background: var(--low); color: #52616c; }
.cell-marker { position: absolute; right: 3px; top: 1px; font-size: 10px; font-weight: 700; }
.aggregate-help { padding: 0 22px 12px; font-size: 10px; color: var(--muted); }
.matrix-legend { flex-shrink: 0; position: relative; }
.matrix-legend > summary { display: none; }
.cell:hover { outline: 1px solid #4a505a; position: relative; z-index: 1; }
.transfer-scroll { overflow-x: auto; }
.transfer-table { border-collapse: collapse; width: 100%; text-align: left; }
.transfer-table th { font-weight: 400; color: var(--muted); font-size: 11px; padding: 12px 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap; }
.transfer-table td { padding: 16px 20px; border-bottom: 1px solid var(--line); font-size: 12px; }
.transfer-table tr:last-child td { border-bottom: 0; }
.transfer-table td strong { display: block; margin-bottom: 6px; font-size: 13px; }
.transfer-table td small { display: block; margin-top: 5px; font-size: 11px; color: var(--muted); }
.transfer-table td:last-child { white-space: nowrap; }
.load-effect { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 700; }
.load-effect span { color: #959aa4; padding: 0 5px; font-weight: 400; }
.low { background: var(--low); color: #52616c; }
.reduced { background: var(--reduced); color: #415f5c; }
.normal { background: var(--normal); color: #1c4937; }
.elevated { background: var(--elevated); color: #684716; }
.high { background: var(--high); color: #6c3514; }
.critical { background: var(--critical); color: white; }
.missing { background: repeating-linear-gradient(135deg,#ededf0,#ededf0 3px,#f8f8fa 3px,#f8f8fa 7px); color: #696d77; }
.shortage { background: #fbe8eb; border: 1px solid var(--red); color: var(--red); font-weight: bold; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 700; border-radius: 3px; padding: 5px 7px; white-space: nowrap; }
.badge.accepted { background: #e8f2ec; color: #286143; }
.badge.new { background: #f2f2f5; color: #5d626c; }
.badge.rejected { background: #eeeef1; color: #666a73; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; padding: 16px 22px 12px; color: var(--muted); font-size: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.swatch { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--red); color: white; border: 1px solid var(--red); padding: 12px 18px; min-height: 44px; border-radius: 4px; font-weight: 600; text-decoration: none; }
.button:hover { background: var(--red-dark); border-color: var(--red-dark); }
.button.secondary { background: white; border-color: #d3d5d9; color: var(--ink); }
.button.secondary:hover { background: #f4f4f6; }
.text-button { border: 0; color: var(--red); background: transparent; font-weight: 600; font-size: 12px; padding: 8px 0; min-height: 36px; }
.notice { background: #fff9f0; border: 1px solid #efd8b4; border-radius: 5px; padding: 17px; font-size: 12px; line-height: 1.6; }
.notice strong { display: block; margin-bottom: 5px; }
.notice.error { background: #fff1f3; border-color: #edbfc7; color: #96233a; }
.footer { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; color: var(--muted); font-size: 10px; padding-top: 24px; padding-bottom: 28px; }
.dashboard-page { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.dashboard-page main { width: 100%; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dashboard-page .dashboard-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dashboard-page .matrix-caption { flex-shrink: 0; }
.dashboard-page .heatmap-wrap { flex: 1; min-height: 0; max-height: none; overflow: auto; }
.dashboard-page main > .loading, .dashboard-page main > .empty-state { flex: 1; min-height: 0; overflow: auto; }
.dashboard-page .footer { width: 100%; flex-shrink: 0; padding-top: 12px; padding-bottom: 12px; }
.dashboard-page .footer details { position: relative; }
.dashboard-page .demo-controls { position: absolute; right: 0; bottom: 28px; width: min(330px,calc(100vw - 36px)); padding: 16px; background: white; border: 1px solid var(--line); border-radius: 5px; box-shadow: 0 5px 20px #24272e24; z-index: 12; }
.footer summary { text-align: right; font-size: 11px; }
.demo-controls { display: flex; gap: 12px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.demo-controls select { font-size: 11px; max-width: 265px; }
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); padding: 15px 22px; border-radius: 6px; color: white; background: #253c31; box-shadow: 0 5px 20px #0003; z-index: 20; max-width: 90vw; line-height: 1.5; }
dialog { width: min(1100px, calc(100% - 48px)); max-height: calc(100dvh - 48px); padding: 0; border: 0; border-radius: 8px; box-shadow: 0 10px 60px #0003; }
dialog::backdrop { background: #24282f8c; }
.dialog-header { flex-shrink: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 26px 30px 22px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { font-size: 25px; margin-top: 9px; }
.dialog-header p { margin-top: 8px; }
.transfer-meta { display: block; margin-top: 8px; }
.close { border: 1px solid var(--line); background: white; border-radius: 4px; font-size: 22px; min-width: 44px; height: 44px; }
.dialog-body { min-height: 0; overflow-y: auto; padding: 24px 30px; }
.graph-scroll { overflow-x: auto; margin: 15px 0 7px; }
.hour-grid { display: grid; grid-template-columns: 72px repeat(12, minmax(25px, 1fr)); gap: 4px; min-width: 438px; font-size: 10px; align-items: center; }
.hour-grid .cell { height: 30px; font-size: 10px; }
.hour-label { text-align: center; color: var(--muted); line-height: 1.4; }
.hour-grid .row-label { color: var(--muted); }
.cell.capacity-blocked { outline: 1px dashed #343841; outline-offset: -3px; }
.register-occupancy { text-align: center; color: var(--muted); padding: 7px 0; }
.register-occupancy.full { font-weight: 700; background: #f0f0f2; border-radius: 3px; }
.capacity-note { margin: 12px 0; padding: 12px 14px; }
.load-effect .capacity-summary { color: #865213; }
.station-registers { display: block; margin-top: 8px; font-size: 12px; color: var(--ink); }
.detail-section { margin-bottom: 24px; }
.detail-section h3 { margin-bottom: 12px; font-size: 15px; }
.dialog-actions { flex-shrink: 0; padding: 18px 30px; border-top: 1px solid var(--line); background: #fafafb; display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.dialog-actions.transfer-actions { justify-content: flex-end; }
.action-group { display: flex; gap: 10px; }
.confirm-panel { background: #fafafb; padding: 18px; border: 1px solid var(--line); border-radius: 5px; }
.confirm-panel h3 { margin-bottom: 10px; }
.confirm-panel p { margin-bottom: 16px; font-size: 12px; }
.empty-state { padding: 60px 24px; text-align: center; }
.empty-state h2 { margin-bottom: 12px; }
.empty-state .button { margin-top: 20px; }
.skeleton { background: linear-gradient(90deg,#f0f0f3,#fafafb,#f0f0f3); height: 20px; margin: 17px 24px; border-radius: 4px; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

@media (max-width: 1100px) {
  .matrix-caption { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; }
  .matrix-info { grid-column: 1; grid-row: 1; }
  .matrix-controls { grid-column: 1 / -1; grid-row: 2; }
  .view-switch { grid-column: 2; grid-row: 1; justify-self: end; }
  .container { padding-left: 24px; padding-right: 24px; }
  .transfer-table th, .transfer-table td { padding-left: 14px; padding-right: 14px; }
  .hour-grid { min-width: 550px; }
  .footer { flex-wrap: wrap; }
}
@media (max-width: 640px) {
  .container { padding-left: 18px; padding-right: 18px; }
  .context-controls { margin-top: 20px; gap: 10px; }
  .control { flex: 1; }
  .date-control { flex: 1.2; }
  .dashboard-controls { display: grid; grid-template-columns: 1fr 1fr; }
  .dashboard-controls .date-trigger { width: 100%; }
  .control select, .date-trigger { width: 100%; font-size: 11px; }
  .date-trigger { gap: 8px; padding: 11px 10px; }
  .date-trigger svg { width: 15px; height: 15px; }
  .matrix-caption { display: grid; grid-template-columns: minmax(0, 1fr) auto; min-height: 68px; padding: 12px; font-size: 10px; gap: 6px 8px; }
  .matrix-info { grid-column: 1; grid-row: 1; }
  .matrix-controls { grid-column: 1 / -1; grid-row: 2; }
  .matrix-range { font-size: 10px; }
  .matrix-sort { width: 100%; font-size: 10px; }
  .matrix-sort select { flex: 1; min-width: 0; width: auto; font-size: 11px; }
  .matrix-controls { width: 100%; flex-wrap: wrap; gap: 10px; }
  .matrix-metric { width: 100%; font-size: 10px; }
  .matrix-metric select { flex: 1; font-size: 11px; }
  .dashboard-page .context-controls { margin-top: 0; gap: 8px; }
  .dashboard-page .matrix-caption { padding: 12px; gap: 6px 8px; }
  .dashboard-page .matrix-controls { display: grid; grid-template-columns: 130px 1fr; gap: 8px; }
  .dashboard-page .view-switch { grid-column: 2; grid-row: 1; justify-self: end; }
  .chart-scroll { padding: 12px 15px 18px; }
  .chart-inspection { gap: 12px; }
  .chart-inspection label, .chart-inspection input { width: 100%; }
  .dashboard-page .matrix-metric, .dashboard-page .matrix-sort { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
  .dashboard-page .matrix-sort:only-child { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 10px; }
  .dashboard-page .matrix-controls select { width: 100%; }
  .dashboard-page .matrix-sort:only-child select { width: auto; }
  .dashboard-page .footer { display: flex; align-items: center; gap: 8px; padding-top: 10px; padding-bottom: 10px; font-size: 9px; }
  .dashboard-page .footer details { margin: 0; }
  .dashboard-page .footer summary { font-size: 10px; }
  .heatmap-wrap { max-height: 54vh; }
  .heatmap { --station-width: 160px; }
  .heatmap .station-column, .heatmap tbody th { padding-left: 15px; }
  .heatmap tbody th { padding-right: 10px; }
  .station-name { font-size: 11px; }
  .station-address, .station-complex { font-size: 9px; }
  .legend { padding-left: 15px; padding-right: 15px; font-size: 9px; gap: 10px; }
  .aggregate-help { padding-left: 15px; padding-right: 15px; font-size: 9px; }
  .footer { display: block; line-height: 1.6; }
  .footer details { margin-top: 12px; }
  .footer summary { text-align: left; }
  dialog { width: 100%; max-width: 100%; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; }
  .dialog-header { padding: 20px 18px; }
  .dialog-header h2 { font-size: 20px; }
  .dialog-body { padding: 20px 18px; }
  .dialog-actions { padding: 15px 18px; position: sticky; bottom: 0; flex-wrap: wrap; }
  .dialog-actions .action-group { width: 100%; }
  .dialog-actions .action-group .button { flex: 1; padding-left: 8px; padding-right: 8px; font-size: 12px; }
  .dialog-actions .sub { font-size: 10px; }
  .hour-grid { min-width: 520px; }
}

#detail-content { display: flex; flex-direction: column; width: 100%; max-height: calc(100dvh - 48px); }
.station-load-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 20px; }
.station-load-heading h3 { margin: 0; }
.station-load-heading .sub { font-size: 11px; }
.station-load-wrap { overflow-x: auto; margin-top: 14px; border: 1px solid var(--line); border-radius: 5px; }
.station-load { width: 100%; table-layout: fixed; border-spacing: 0; font-variant-numeric: tabular-nums; }
.station-load th, .station-load td { padding: 5px 2px; text-align: center; font-size: 10px; height: 34px; }
.station-load thead th { font-weight: 400; color: var(--muted); border-bottom: 1px solid var(--line); }
.station-load th:first-child { width: 90px; text-align: left; padding-left: 10px; position: sticky; left: 0; background: white; z-index: 2; }
.station-load small { display: block; margin-top: 3px; font-size: 9px; }
.candidate-heading { display: flex; gap: 20px; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.candidate-heading h3 { margin-top: 0; margin-bottom: 8px; }
.candidate-date-control { position: relative; flex-shrink: 0; }
.candidate-date-control .calendar { position: fixed; left: 50%; top: 50%; right: auto; transform: translate(-50%,-50%); }
.candidate-date-control .calendar-head { justify-content: center; font-weight: 600; }
.candidate-date-control .calendar-head span { flex: 1; text-align: center; }
.candidate-rank { width: 30px; color: var(--muted); }
.load-effect small { font-weight: 400; max-width: 160px; white-space: normal; line-height: 1.5; }
.station-feedback { padding: 12px 16px; margin-bottom: 16px; border-radius: 5px; background: #e8f2ec; color: #286143; font-size: 12px; }
.station-empty { padding: 28px 16px; border: 1px solid var(--line); border-radius: 5px; }
@media (max-width: 800px) {
  .transfer-table thead { display: none; }
  .transfer-table tbody, .transfer-table tr { display: block; }
  .transfer-table tr { display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; padding: 18px 0; border-bottom: 1px solid var(--line); }
  .transfer-table td { padding: 0; border: 0; font-size: 11px; }
  .transfer-table td:nth-child(1) { grid-column: 1; grid-row: 1; width: 24px; }
  .transfer-table td:nth-child(2) { grid-column: 1 / -1; grid-row: 1; padding-left: 30px; }
  .transfer-table td:nth-child(3) { grid-column: 1; grid-row: 2; }
  .transfer-table td:nth-child(4) { grid-column: 2; grid-row: 2; text-align: right; }
  .transfer-table td:nth-child(5) { grid-column: 1; grid-row: 3; }
  .transfer-table td:nth-child(6) { grid-column: 2; grid-row: 3; text-align: right; }
  .transfer-table .text-button { min-height: 44px; }
  .transfer-table tr:last-child { border: 0; }
  .transfer-table td strong { font-size: 13px; }
  .transfer-table td small { font-size: 10px; }
}

.navigation { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-shrink: 0; margin-top: 16px; border-bottom: 1px solid var(--line); }
.view-tabs { display: flex; gap: 24px; }
.view-tabs button { min-height: 44px; padding: 10px 0; border: 0; border-bottom: 3px solid transparent; background: none; font-size: 14px; }
.view-tabs [aria-current] { color: var(--red); border-bottom-color: var(--red); font-weight: 700; }
.manager-context { display: flex; gap: 14px; align-items: center; font-size: 11px; }
.manager-scope { display: block; color: var(--muted); font-size: 10px; margin-top: 4px; max-width: 350px; }
.escalation-note { margin: 0; font-size: 12px; max-width: 440px; line-height: 1.5; }
.personnel-panel, .personnel-results { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.personnel-caption { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; flex-shrink: 0; }
.personnel-add { min-width: 44px; padding: 6px 12px; font-size: 24px; line-height: 1; }
.personnel-results { border-top: 1px solid var(--line); }
.personnel-scroll { flex: 1; min-height: 0; overflow: auto; }
.personnel-table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; }
.personnel-table th, .personnel-table td { padding: 16px 18px; border-bottom: 1px solid var(--line); font-size: 12px; vertical-align: middle; }
.personnel-table th { position: sticky; top: 0; z-index: 1; background: white; color: var(--muted); font-weight: 400; }
.personnel-table .text-button { min-height: 44px; }
.personnel-actions { white-space: nowrap; }
.personnel-actions .text-button + .text-button { margin-left: 16px; }
.personnel-panel > .station-feedback { margin: 0 18px 12px; flex-shrink: 0; }
.personnel-results > .empty-state, .personnel-results > .loading { flex: 1; min-height: 0; overflow: auto; }
.personnel-filters { display: grid; grid-template-columns: 1.2fr 1.2fr .8fr 1fr 1.2fr; gap: 12px; margin-top: 12px; padding: 3px; max-height: 32dvh; overflow: auto; }
.personnel-filters select { width: 100%; }
.personnel-form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.personnel-form-row { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; }
.personnel-credentials { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; margin-top: 20px; }
.personnel-form select { width: 100%; }
.personnel-form .dialog-actions { justify-content: flex-end; }
.personnel-form .login-error { margin: 16px 0 0; }
.consent-control { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 16px; font-size: 13px; cursor: pointer; }
.consent-control input { width: 18px; height: 18px; accent-color: var(--red); }
.manager-context .text-button { min-height: 44px; }
.login-panel { width: min(420px,100%); margin: auto; padding: 30px; }
.login-panel h2 { margin-bottom: 24px; }
.login-panel .control { margin-bottom: 16px; }
.control input { width: 100%; min-width: 0; border: 1px solid #d3d5d9; border-radius: 5px; padding: 11px 12px; min-height: 44px; color: var(--ink); background: white; }
.login-panel .button { width: 100%; }
.login-error { color: var(--red); font-size: 12px; margin-bottom: 12px; }
.login-demo { font-size: 11px; margin-top: 20px; }
.filter-panel { flex-shrink: 0; margin: 14px 0; min-width: 0; }
.filter-panel > summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 5px; background: white; font-size: 12px; }
.filter-panel > summary::marker, .filter-panel > summary::-webkit-details-marker { display: none; }
.filter-expand, .filter-collapse { color: var(--muted); font-size: 11px; }
.filter-panel .filter-collapse, .filter-panel[open] .filter-expand { display: none; }
.filter-panel[open] .filter-collapse { display: inline; }
.filter-panel > .context-controls { margin-top: 14px; }
.filter-panel:not([open]) > .context-controls, .filter-panel:not([open]) > .history-filters { display: none; }
.history-filters { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; margin-top: 12px; padding: 3px; max-height: 32dvh; overflow: auto; }
.history-filter-group { min-width: 0; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 5px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-content: start; gap: 12px; }
.history-filter-group legend { padding: 0 6px; font-size: 12px; font-weight: 700; }
.history-filter-group:not(.history-employee) .control:last-child, .history-search { grid-column: 1 / -1; }
.history-sort { display: flex; align-items: center; gap: 10px; min-width: 0; }
.history-sort select { width: 240px; font-size: 12px; }
.history-results { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.history-results > .loading, .history-results > .empty-state { flex: 1; min-height: 0; overflow: auto; }
.history-filters select { width: 100%; font-size: 12px; }
.history-filters input { font-size: 12px; }
.history-filters .button { font-size: 12px; }
.history-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.history-caption { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.history-scroll { flex: 1; min-height: 0; overflow: auto; }
.history-more { padding: 20px; text-align: center; color: var(--muted); font-size: 12px; }
.history-table { width: 100%; min-width: 1000px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.history-table th { position: sticky; top: 0; z-index: 1; text-align: left; font-size: 10px; font-weight: 400; color: var(--muted); background: white; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 14px 12px; }
.history-table td { padding: 20px 12px; font-size: 11px; border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.5; overflow-wrap: anywhere; }
.history-table th:nth-child(1), .history-table th:nth-child(2) { width: 16%; }
.history-table th:nth-child(3) { width: 12%; }
.history-table th:nth-child(4) { width: 13%; }
.history-table th:nth-child(5) { width: 8%; }
.history-table th:nth-child(6) { width: 14%; }
.history-table th:nth-child(7) { width: 11%; }
.history-table th:nth-child(8) { width: 10%; }
.history-table td strong { display: block; font-size: 12px; margin-bottom: 6px; }
.history-table td small { display: block; color: var(--muted); margin-top: 5px; font-size: 10px; }
.history-table .load-effect { white-space: normal; }
.history-table .station-name { margin-bottom: 6px; }
.history-panel .empty-state { overflow: auto; }
.button:disabled { opacity: .4; cursor: default; }
@media (max-width: 640px) {
  .navigation { flex-wrap: wrap; gap: 0; margin-top: 8px; }
  .manager-context { width: 100%; justify-content: space-between; }
  .manager-context .text-button { min-height: 44px; }
  .filter-panel { margin: 12px 0; }
  .filter-panel > summary { padding: 12px; }
  .filter-panel > .context-controls { margin-top: 12px; }
  .history-filters { grid-template-columns: 1fr; gap: 10px; }
  .history-filter-group { padding: 10px; gap: 8px; }
  .history-filters label { margin-bottom: 4px; font-size: 10px; }
  .history-filters input, .history-filters select { font-size: 11px; padding: 9px 8px; }
  .history-filters .button { font-size: 11px; }
  .history-caption { padding: 12px; font-size: 11px; }
  .history-sort { gap: 8px; flex: 1; justify-content: flex-end; }
  .history-sort select { width: 165px; min-width: 0; padding: 9px 8px; font-size: 11px; }
  .history-table { min-width: 0; }
  .history-table thead, .history-table colgroup { display: none; }
  .history-table tbody, .history-table tr { display: block; }
  .history-table tr { padding: 16px 12px; border-bottom: 1px solid var(--line); }
  .history-table td { display: grid; grid-template-columns: 105px minmax(0,1fr); column-gap: 12px; padding: 6px 0; border: 0; font-size: 11px; }
  .history-table td::before { content: attr(data-label); color: var(--muted); font-size: 10px; grid-column: 1; grid-row: 1 / span 8; }
  .history-table td > * { grid-column: 2; }
  .history-table td strong { font-size: 11px; margin-bottom: 0; }
  .history-table .station-address, .history-table .station-complex { white-space: normal; }
  .history-table td .badge { justify-self: start; }
  .login-panel { padding: 24px; }
  .view-tabs { gap: 18px; }
  .personnel-filters { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .personnel-filters .personnel-search { grid-column: 1 / -1; }
  .personnel-filters input, .personnel-filters select { padding: 9px 8px; font-size: 11px; }
  .personnel-form-row, .personnel-credentials { grid-template-columns: 1fr; gap: 14px; }
  .personnel-caption { padding: 12px; }
  .personnel-table thead { display: none; }
  .personnel-table tbody, .personnel-table tr { display: block; }
  .personnel-table tr { padding: 12px; border-bottom: 1px solid var(--line); }
  .personnel-table td { display: grid; grid-template-columns: 105px minmax(0,1fr); column-gap: 12px; padding: 6px 0; border: 0; font-size: 11px; overflow-wrap: anywhere; }
  .personnel-table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 10px; }
  .personnel-table td.personnel-actions { display: flex; justify-content: flex-end; gap: 16px; }
  .personnel-actions .text-button + .text-button { margin-left: 0; }
  .transfer-actions:has(.escalation-note) .action-group { align-items: stretch; flex-wrap: wrap; }
  .escalation-note { flex: 1 1 100%; }
}
@media (max-width: 640px) {
  #detail-content { height: 100dvh; max-height: 100dvh; }
  #detail-content .dialog-body { flex: 1; }
  .candidate-heading { display: block; }
  .candidate-date-control { margin-top: 16px; }
  .candidate-date-control .date-trigger { width: 100%; }
}

@media (max-width: 640px), (max-height: 740px) {
  .matrix-legend > summary { display: block; padding: 10px 15px; font-size: 10px; color: var(--muted); }
  .matrix-legend:not([open]) > .legend-content { display: none; }
  .matrix-legend > .legend-content { position: absolute; left: 0; right: 0; bottom: 100%; background: white; border: 1px solid var(--line); border-radius: 5px; box-shadow: 0 5px 20px #24272e24; z-index: 6; }
}
@media (max-height: 740px) {
  .navigation { margin-top: 8px; }
  .filter-panel { position: relative; margin: 8px 0; }
  .filter-panel[open] > .context-controls,
  .filter-panel[open] > .history-filters,
  .filter-panel[open] > .personnel-filters {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 8;
    margin-top: 8px; max-height: 42dvh; overflow: auto; padding: 12px;
    background: white; border: 1px solid var(--line); border-radius: 5px; box-shadow: 0 5px 20px #24272e24;
  }
  .dashboard-page .matrix-caption, .history-caption, .personnel-caption { padding: 8px 12px; }
  .matrix-caption { min-height: 60px; gap: 6px 8px; }
  .dashboard-page .footer { padding-top: 4px; padding-bottom: 4px; }
  .matrix-legend > .legend-content { max-height: 42dvh; overflow: auto; }
  .dashboard-page .calendar { position: fixed; left: 50%; right: auto; top: 50%; transform: translate(-50%,-50%); max-height: calc(100dvh - 36px); overflow: auto; }
}
