:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #fff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #0f766e;
  --ok: #047857;
  --ok-bg: #e7f7ef;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .42; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 22px; letter-spacing: 0; }
h2 { font-size: 18px; letter-spacing: 0; }
h3 { font-size: 15px; letter-spacing: 0; }

.shell { width: min(1720px, calc(100vw - 32px)); margin: 0 auto; }
.date-strip, .record { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.date-strip { margin-top: 8px; padding: 8px; }
.strip-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.page-tabs { display: flex; align-items: center; gap: 3px; }
.tab { display: inline-flex; align-items: center; min-height: 35px; padding: 0 15px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff; font-size: 12px; font-weight: 800; text-decoration: none; }
.tab:hover, .tab.is-active { border-color: #99cbc5; background: #e3f1ef; color: var(--accent); }
.scope-note { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.scope-badge { border: 1px solid #b8d9d4; border-radius: 999px; padding: 5px 8px; color: var(--accent); background: #edf8f6; font-size: 11px; font-weight: 900; }
.small-button, .upload-button { border: 1px solid var(--accent); border-radius: 6px; background: #fff; color: var(--accent); padding: 8px 11px; font-size: 12px; font-weight: 800; }
.small-button.is-on { background: var(--accent); color: #fff; }
.group-navigation { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.group-bundle { overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: #fbfcfd; }
.group-bundle-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 10px; border-bottom: 1px solid var(--line); color: #344054; font-size: 12px; }
.group-bundle-head span { color: var(--muted); font-size: 11px; font-weight: 800; }
.group-bundle-rows { padding: 6px 8px; }
.group-role-row { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: 8px; min-height: 38px; }
.group-role-row + .group-role-row { border-top: 1px dashed #dfe5ec; }
.group-role-label { color: var(--muted); font-size: 11px; font-weight: 900; }
.group-buttons { display: flex; flex-wrap: wrap; gap: 5px; }
.group-button { min-height: 30px; border: 1px solid #c9d4df; border-radius: 6px; padding: 5px 9px; color: #344054; background: #fff; font-size: 11px; font-weight: 800; white-space: nowrap; }
.group-button:hover, .group-button.is-active { border-color: var(--accent); color: var(--accent); background: #e3f1ef; }
.group-button:disabled, .group-button:disabled:hover { border-color: #d8dee8; color: #98a2b3; background: #f8fafc; cursor: not-allowed; opacity: .62; }
.group-button.is-admin { border-color: #c7b9a4; color: #765b32; background: #fffaf1; }
.group-button.is-admin:hover, .group-button.is-admin.is-active { border-color: #9a6c2f; color: #694815; background: #fff1d9; }
.review-toolbar-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; min-width: 0; }
.review-filter-controls { display: flex; align-items: center; gap: 6px; }
.review-filter-dropdown { position: relative; min-width: 104px; }
.review-filter-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 32px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; color: #344054; background: #fff; cursor: pointer; font-size: 11px; font-weight: 900; list-style: none; }
.review-filter-summary::-webkit-details-marker { display: none; }
.review-filter-summary::after { content: "▾"; color: var(--muted); font-size: 10px; }
.review-filter-dropdown[open] .review-filter-summary { border-color: var(--accent); color: var(--accent); background: #edf8f6; }
.review-filter-dropdown[open] .review-filter-summary::after { content: "▴"; }
.review-filter-summary strong { color: var(--muted); font-size: 10px; }
.review-filter-menu { position: absolute; z-index: 20; top: calc(100% + 4px); right: 0; width: 190px; padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; box-shadow: 0 8px 22px rgb(16 24 40 / 14%); }
.review-filter-option { display: flex; align-items: center; gap: 7px; min-height: 30px; padding: 5px 6px; color: #344054; font-size: 11px; font-weight: 800; cursor: pointer; }
.review-filter-option:hover { border-radius: 4px; background: #f1f8f7; }
.review-filter-option input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }
.review-filter-all { border-bottom: 1px solid var(--line); margin-bottom: 4px; color: var(--accent); }
.review-filter-items { max-height: 240px; overflow-y: auto; }
.review-table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fbfcfd; color: #344054; font-size: 12px; }
.review-table-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.review-row-mode { display: inline-flex; gap: 4px; }
.review-row-mode .small-button { padding: 6px 9px; }
.review-date-table.is-collapsed { display: none; }
.date-total-table .saturday { color: #2563eb; }
.table-scroll { overflow-x: auto; }
.date-total-table { width: 100%; min-width: 920px; border-collapse: collapse; table-layout: fixed; font-size: 11px; line-height: 1.18; background: #fff; }
.date-total-table th, .date-total-table td { padding: 4px 6px; border: 1px solid var(--line); text-align: right; white-space: nowrap; }
.date-total-table th:first-child, .date-total-table td:first-child { width: 116px; text-align: left; background: #fbfcfd; color: #344054; font-weight: 900; }
.date-total-table .admin-total-row th:first-child { color: #765b32; background: #fffaf1; }
.date-total-table thead th { text-align: center; background: #fbfcfd; }
.date-total-table th.active-date, .date-total-table td.active-date { background: #ecfdf3; }
.date-total-table th.zero-date, .date-total-table td.zero-date { color: #98a2b3; background: #f8fafc; }
.date-total-table th.active-date.zero-date, .date-total-table td.active-date.zero-date { background: #f8fafc; }
.date-total-table .holiday { color: #b42318; }
.date-total-table th button { width: 100%; border: 0; padding: 0; background: transparent; color: inherit; font: inherit; font-weight: 900; }
.date-total-table th button:hover { color: var(--accent); }
.date-total-table th.zero-date button { color: #98a2b3; }
.review-empty-row th { height: 34px; color: var(--muted); background: #f8fafc !important; text-align: center !important; }

main { padding: 8px 0 32px; }
.shell-main { min-width: 0; }
.record { margin-top: 12px; overflow: hidden; }
.record-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.record-head-main { min-width: 0; }
.record-head h2 { margin-bottom: 4px; }
.subtitle { margin-bottom: 4px; color: var(--muted); font-size: 13px; }
.status { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 10px; background: var(--ok-bg); color: var(--ok); font-size: 11px; font-weight: 900; white-space: nowrap; }
.date-nav { display: inline-grid; grid-template-columns: 38px 38px minmax(170px, auto) 38px 38px; align-items: center; gap: 6px; }
.date-nav h2 { text-align: center; min-width: 170px; }
.day-title-button { border: 0; padding: 0; background: transparent; color: inherit; font: inherit; font-weight: 800; white-space: nowrap; }
.day-title-button:hover { opacity: .82; }
.day-picker { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.nav-button { width: 38px; height: 34px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; padding: 0; font-size: 18px; line-height: 1; }
.nav-button.is-muted { background: #a6d2ce; }
.review-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; }
.keyboard-hint { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 10px; color: var(--muted); font-size: 11px; font-weight: 700; text-align: right; }
.keyboard-hint span { white-space: nowrap; }
.magnifier-controls { display: inline-flex; gap: 6px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; }
.magnifier-button { min-width: 46px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: #344054; padding: 6px 8px; font-size: 12px; font-weight: 800; }
.magnifier-button.is-active { border-color: var(--accent); background: var(--accent); color: #fff; }

.review-grid { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr) minmax(420px, .95fr); gap: 12px; padding: 12px; align-items: start; }
.review-grid-viewport { overflow: auto; }
.review-grid > .pane { min-height: 440px; }
.magnifier-zone { position: relative; }
.magnifier-content { position: relative; z-index: 0; }
.magnifier-lens { position: absolute; z-index: 4; width: 180px; height: 180px; border: 3px solid #fff; border-radius: 50%; background: #fff; box-shadow: 0 8px 24px rgba(16, 24, 40, .28), 0 0 0 1px rgba(15, 118, 110, .45); pointer-events: none; transform: translate(-50%, -50%); overflow: hidden; }
.magnifier-lens[hidden] { display: none; }
.magnifier-lens-content { position: absolute; inset: 0; overflow: hidden; background: #fff; }
.magnifier-lens-content > .magnifier-content { position: absolute; top: 0; left: 0; max-width: none; transform-origin: 0 0; pointer-events: none; }
.pane { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.pane-title, .section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.section-title { min-height: 44px; }
.section-title > span { color: var(--muted); font-size: 11px; }
.empty-pane { display: grid; justify-items: center; align-content: center; min-height: 440px; padding: 28px 18px; color: var(--muted); text-align: center; }
.empty-pane.document-empty { background: #eef1f5; }
.empty-mark { display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 12px; border: 1px solid #b7c4cc; border-radius: 50%; color: var(--accent); background: #fff; font-size: 18px; }
.empty-pane strong { color: var(--ink); font-size: 14px; }
.empty-pane p { max-width: 260px; margin-top: 7px; font-size: 12px; line-height: 1.65; }
.record-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); }
.summary-line { color: var(--ok); font-size: 13px; font-weight: 800; white-space: pre-line; }
.summary-separator, .summary-people { color: #344054; font-size: 13px; font-weight: 800; }
.summary-table { padding: 8px; overflow-x: auto; }
.labor-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px; border-bottom: 1px solid var(--line); color: #344054; font-size: 12px; }
.labor-heading span { color: var(--muted); font-size: 11px; }
.labor-table { width: 100%; border-collapse: collapse; font-size: 11px; line-height: 1.18; }
.labor-table th, .labor-table td { padding: 5px 6px; border: 1px solid var(--line); text-align: right; white-space: nowrap; }
.labor-table th:first-child, .labor-table td:first-child { text-align: left; }
.labor-table th { background: #fbfcfd; color: #475467; font-size: 11px; }
.labor-table tfoot th, .labor-table tfoot td { background: #f8fafc; font-weight: 900; }
.table-empty { height: 78px; color: var(--muted); text-align: center !important; font-weight: 700; }
.grand-total { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; padding: 12px 8px; background: #eef4f3; color: #344054; font-size: 12px; }
.grand-total strong { color: var(--ink); font-size: 16px; }

.summary-page-table { min-height: 320px; }
.summary-page-table .empty-pane { min-height: 280px; background: #fff; }
.data-source-badge { color: var(--muted); font-size: 10px; font-weight: 800; white-space: nowrap; }
.summary-main { padding: 10px 0 32px; }
.summary-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.summary-topbar h1 { margin-right: 4px; font-size: 22px; }
.access-main { display: grid; min-height: 100vh; place-items: center; padding: 24px 16px; }
.access-panel { width: min(100%, 360px); padding: 24px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: 0 12px 28px rgba(16, 24, 40, .08); }
.access-panel h1 { margin-bottom: 8px; font-size: 22px; }
.access-panel > p { margin-bottom: 20px; color: var(--muted); font-size: 13px; }
.access-form { display: grid; gap: 8px; }
.access-form label { color: #344054; font-size: 12px; font-weight: 900; }
.access-input { width: 100%; min-height: 40px; border: 1px solid #c9d4df; border-radius: 6px; padding: 8px 10px; color: var(--ink); background: #fff; outline: none; }
.access-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, .12); }
.access-submit { min-height: 40px; margin-top: 6px; border: 1px solid var(--accent); border-radius: 6px; color: #fff; background: var(--accent); font-size: 13px; font-weight: 900; }
.access-submit:hover { background: #0b625c; }
.access-error { min-height: 18px; margin: 2px 0 0; color: #b42318; font-size: 12px; }
.monthly-summary { margin-top: 10px; }
.monthly-summary-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; font-weight: 800; }
.monthly-summary-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: #fbfcfd; }
.monthly-control-group { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.monthly-control-label { margin-right: 2px; color: var(--muted); font-size: 11px; font-weight: 900; }
.monthly-segmented { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.monthly-control-button { min-height: 29px; border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px; color: #344054; background: #fff; font-size: 11px; font-weight: 900; white-space: nowrap; }
.monthly-segmented .monthly-control-button { border-color: transparent; }
.monthly-control-button:hover, .monthly-control-button.is-active { border-color: var(--accent); color: var(--accent); background: #e3f1ef; }
.monthly-table-wrap { overflow-x: auto; }
.monthly-table { width: 100%; min-width: 1360px; border-collapse: collapse; table-layout: fixed; font-size: 11px; line-height: 1.2; background: #fff; }
.monthly-table th, .monthly-table td { height: 29px; padding: 4px 7px; border: 1px solid var(--line); white-space: nowrap; }
.monthly-table th { color: #344054; font-weight: 900; }
.monthly-table td { text-align: right; }
.monthly-table .monthly-month-cell { width: 84px; min-width: 84px; }
.monthly-table .monthly-day-cell { width: 54px; min-width: 54px; padding-right: 4px; padding-left: 4px; }
.monthly-table .monthly-row-total-header, .monthly-table .monthly-row-total { width: 76px; min-width: 76px; }
.monthly-table .monthly-row-total { color: #075e54; font-weight: 900; }
.monthly-table .monthly-shift { position: sticky; left: 0; z-index: 4; width: 76px; text-align: center; }
.monthly-table .monthly-group-label { position: sticky; left: 76px; z-index: 4; width: 148px; text-align: left; background: #fff; }
.monthly-table thead th { position: sticky; top: 0; z-index: 3; text-align: center; background: #f7f8fa; }
.monthly-table thead tr:first-child th:first-child { left: 0; width: 76px; }
.monthly-table thead tr:first-child th:nth-child(2) { left: 76px; width: 148px; }
.monthly-table thead tr:first-child th:first-child, .monthly-table thead tr:first-child th:nth-child(2) { z-index: 5; }
.monthly-table thead tr:nth-child(2) th { top: 29px; color: var(--accent); background: #fff8ee; }
.monthly-table thead tr:nth-child(2) th.monthly-weekday { color: #111827; }
.monthly-table thead tr:nth-child(2) th.monthly-saturday { color: #2563eb; }
.monthly-table thead tr:nth-child(2) th.monthly-holiday { color: #b42318; }
.monthly-period-toggle { width: 100%; border: 0; padding: 0; color: inherit; background: transparent; font: inherit; font-weight: 900; white-space: nowrap; }
.monthly-period-toggle:hover { color: var(--accent); }
.monthly-table tbody tr + tr th, .monthly-table tbody tr + tr td { border-top-color: #cbd5e1; }
.monthly-table .monthly-shift { vertical-align: middle; color: #344054; background: #f7f9fb; }
.monthly-table .monthly-cub .monthly-group-label { background: #f4f8fd; }
.monthly-table .monthly-fab .monthly-group-label { background: #f0faf5; }
.monthly-table .monthly-admin .monthly-group-label { color: #765b32; background: #fffaf1; }
.monthly-table .monthly-total-row th, .monthly-table .monthly-total-row td { background: #e9f8ef; font-weight: 900; }
.monthly-table .monthly-total-row .monthly-group-label { background: #e9f8ef; }
.monthly-table tfoot th, .monthly-table tfoot td { height: 34px; background: #dff4e8; color: #075e54; font-weight: 900; }
.monthly-table tfoot .monthly-shift { left: 0; }
.monthly-table tfoot .monthly-group-label { left: 76px; }
.monthly-table tfoot .monthly-grand-total th { position: sticky; left: 0; z-index: 4; background: #dff4e8; }
.summary-content { padding: 8px 12px 12px; overflow-x: auto; }
.summary-content + .summary-content { border-top: 1px solid var(--line); }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; line-height: 1.25; }
.data-table th, .data-table td { padding: 7px 8px; border: 1px solid var(--line); text-align: right; white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table thead th { background: #fbfcfd; color: #475467; }
.data-table tbody th { color: var(--ink); background: #fff; }
.data-table tfoot th, .data-table tfoot td { background: #eef4f3; font-weight: 900; }
.period-summary-content { padding-top: 0; }
.period-table th:first-child, .period-table td:first-child { text-align: center; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 12px; }
.setup-pane { min-height: 260px; }
.setup-row { display: flex; justify-content: space-between; gap: 16px; padding: 14px 14px 0; color: var(--muted); font-size: 12px; }
.setup-row strong { color: var(--ink); font-size: 12px; }
.upload-button { display: block; width: calc(100% - 28px); margin: 20px 14px 14px; border-color: var(--line); color: var(--muted); background: #f8fafc; }
.setup-note { margin: 22px 14px 14px; padding: 12px; border-left: 2px solid #8accc3; color: var(--muted); background: #f3faf8; font-size: 12px; line-height: 1.65; }
.data-contract { margin: 0 12px 12px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.data-contract .section-title { background: #fff; }
.contract-row { display: grid; grid-template-columns: 220px 1fr; gap: 12px; padding: 12px; border-top: 1px solid var(--line); font-size: 12px; }
.contract-row code { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.contract-row span { color: var(--muted); }

@media (hover: none), (pointer: coarse) {
  .magnifier-lens { display: none !important; }
}

@media (max-width: 1180px) {
  .review-grid { grid-template-columns: minmax(280px, 1fr) minmax(360px, 1fr); }
  .review-grid .pane:last-child { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .shell { width: min(100% - 16px, 1720px); }
  .strip-toolbar, .record-head { flex-direction: column; }
  .summary-topbar, .monthly-summary-meta { align-items: flex-start; flex-direction: column; }
  .summary-topbar h1 { font-size: 20px; }
  .monthly-summary-controls { align-items: flex-start; flex-direction: column; }
  .scope-note, .review-controls, .review-toolbar-actions { justify-content: flex-start; }
  .group-navigation { grid-template-columns: 1fr; }
  .review-filter-controls { width: 100%; }
  .review-filter-dropdown { flex: 1 1 140px; }
  .review-filter-menu { left: 0; right: auto; }
  .review-table-toolbar { align-items: flex-start; flex-direction: column; }
  .review-table-actions { width: 100%; justify-content: flex-start; }
  .keyboard-hint { justify-content: flex-start; text-align: left; }
  .review-grid, .admin-grid { grid-template-columns: 1fr; }
  .data-table { min-width: 620px; }
  .monthly-table { min-width: 1360px; }
  .review-grid .pane:last-child { grid-column: auto; }
  .date-nav { grid-template-columns: 34px 34px minmax(140px, auto) 34px 34px; gap: 4px; }
  .date-nav h2 { min-width: 140px; font-size: 16px; }
  .nav-button { width: 34px; height: 32px; }
  .empty-pane { min-height: 300px; }
  .contract-row { grid-template-columns: 1fr; gap: 4px; }
}

@media (max-width: 460px) {
  .page-tabs { width: 100%; }
  .tab { flex: 1; justify-content: center; padding: 0 7px; font-size: 11px; }
  .small-button { padding: 7px 8px; font-size: 11px; }
  .date-nav { grid-template-columns: 31px 31px minmax(120px, auto) 31px 31px; }
  .date-nav h2 { min-width: 120px; font-size: 14px; }
  .nav-button { width: 31px; font-size: 16px; }
}
