:root {
  color-scheme: light;
  --ink: oklch(26% 0.018 250);
  --muted: oklch(51% 0.016 250);
  --faint: oklch(54% 0.012 250);
  --line: oklch(89% 0.008 250);
  --line-strong: oklch(82% 0.012 250);
  --canvas: oklch(97% 0.006 250);
  --surface: oklch(99% 0.004 250);
  --surface-2: oklch(95.5% 0.009 250);
  --primary: oklch(48% 0.14 258);
  --primary-hover: oklch(43% 0.14 258);
  --primary-soft: oklch(95% 0.025 258);
  --focus: oklch(62% 0.16 255 / 0.32);
  --ds: oklch(95% 0.035 265);
  --ds-ink: oklch(39% 0.09 264);
  --fde: oklch(95% 0.04 158);
  --fde-ink: oklch(38% 0.085 158);
  --open: oklch(96% 0.055 83);
  --open-ink: oklch(42% 0.08 76);
  --danger: oklch(48% 0.16 28);
  --danger-soft: oklch(96% 0.03 28);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow: 0 18px 48px oklch(24% 0.02 250 / 0.13);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; background: var(--canvas); color: var(--ink); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 1.625rem; line-height: 1.2; letter-spacing: -0.025em; }
h2 { margin-bottom: 12px; font-size: 1.25rem; line-height: 1.25; letter-spacing: -0.015em; }
h3 { margin-bottom: 8px; font-size: 1rem; }
a { color: var(--primary); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button, .button, input, select, textarea { transition: color 180ms cubic-bezier(.16, 1, .3, 1), background-color 180ms cubic-bezier(.16, 1, .3, 1), border-color 180ms cubic-bezier(.16, 1, .3, 1), box-shadow 180ms cubic-bezier(.16, 1, .3, 1), opacity 180ms cubic-bezier(.16, 1, .3, 1); }

label { display: grid; gap: 4px; color: var(--muted); font-size: .75rem; font-weight: 650; }
input, select, textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 7px 9px;
  color: var(--ink);
}
textarea { min-height: 82px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:user-invalid, textarea:user-invalid, select:user-invalid, [aria-invalid="true"] { border-color: var(--danger); background: var(--danger-soft); }
input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; background: var(--surface-2); color: var(--faint); opacity: .8; }
button:focus-visible, .button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.button, button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 7px 11px;
  font-weight: 680;
  line-height: 1.2;
  text-decoration: none;
}
.button:hover, button:hover { border-color: var(--faint); background: var(--surface-2); }
.button:active, button:active { background: var(--line); }
.button.primary { border-color: var(--primary); background: var(--primary); color: var(--surface); }
.button.primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.button.quiet { background: transparent; }
.danger, .button.danger { border-color: oklch(78% 0.07 28); background: var(--surface); color: var(--danger); }
.danger:hover, .button.danger:hover { border-color: var(--danger); background: var(--danger-soft); }
button:disabled, .button[aria-disabled="true"], button[aria-busy="true"] { cursor: not-allowed; opacity: .55; }
button[aria-busy="true"]::after { content: "…"; margin-left: 4px; }
.icon-button { width: 36px; padding: 0; font-size: 1.25rem; }

.site-header {
  position: relative;
  z-index: 5;
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { flex: none; color: var(--ink); font-weight: 780; letter-spacing: -.015em; text-decoration: none; }
.primary-nav { display: flex; align-self: stretch; gap: 2px; }
.primary-nav a { display: grid; place-items: center; border-bottom: 2px solid transparent; padding: 0 11px; color: var(--muted); font-size: .8125rem; font-weight: 650; text-decoration: none; }
.primary-nav a:hover { color: var(--ink); background: var(--canvas); }
.primary-nav a[aria-current="page"] { border-color: var(--primary); color: var(--primary); }
.account { display: flex; align-items: center; gap: 9px; margin-left: auto; color: var(--muted); font-size: .75rem; }

.page { width: min(100%, 1600px); margin: 0 auto; padding: 22px 24px 40px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 17px; }
.page-heading > div { min-width: 0; }
.eyebrow { margin-bottom: 3px; color: var(--primary); font-size: .6875rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.muted { color: var(--muted); }
.page-heading .muted { margin-bottom: 0; font-size: .8125rem; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-bottom: 13px; }
.metrics article { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); padding: 11px 13px; }
.metrics span, .metrics small { display: block; overflow: hidden; color: var(--muted); font-size: .6875rem; text-overflow: ellipsis; white-space: nowrap; }
.metrics strong { display: block; margin: 2px 0 1px; font-size: 1.375rem; line-height: 1.25; letter-spacing: -.02em; }
.filters { display: flex; align-items: end; gap: 7px; margin-bottom: 11px; }
.filters label { min-width: 148px; }
.filters.compact label { min-width: 130px; }

.planner-scroll, .table-scroll { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.planner { width: 100%; min-width: 1120px; border-spacing: 0; border-collapse: separate; }
.planner th, .planner td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; }
.planner tr:last-child > * { border-bottom: 0; }
.planner tr > *:last-child { border-right: 0; }
.planner thead th { position: sticky; top: 0; z-index: 3; min-width: 154px; background: var(--surface-2); padding: 9px 8px; color: var(--muted); font-size: .6875rem; font-weight: 720; letter-spacing: .025em; text-align: center; text-transform: uppercase; }
.planner thead th:first-child { left: 0; z-index: 4; min-width: 184px; text-align: left; }
.planner tbody > tr > th { position: sticky; left: 0; z-index: 2; min-width: 184px; max-width: 184px; background: var(--surface); padding: 10px 11px; text-align: left; }
.planner tbody > tr > th strong, .planner tbody > tr > th span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.planner tbody > tr > th span { margin-top: 2px; color: var(--muted); font-size: .6875rem; font-weight: 450; }
.cell { display: grid; width: 100%; min-height: 74px; align-content: center; gap: 5px; border: 0; border-radius: 0; background: var(--surface); padding: 6px; text-align: left; }
.cell:hover { background: var(--primary-soft); }
.cell:focus-visible { position: relative; z-index: 1; outline-offset: -3px; }
.assignment { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 6px; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 5px 6px; font-size: .6875rem; }
.assignment b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assignment > span { flex: none; font-size: .625rem; font-weight: 650; }
.assignment.ds { background: var(--ds); color: var(--ds-ink); }
.assignment.fde { background: var(--fde); color: var(--fde-ink); }
.assignment.open { border-style: dashed; border-color: oklch(73% 0.1 80); background: var(--open); color: var(--open-ink); }
.assignment.unfilled { border-style: dotted; border-color: var(--faint); background: var(--surface-2); color: var(--muted); }
.conflict { color: var(--danger); font-size: .625rem; font-weight: 780; }
.outside-horizon { display: grid; min-height: 74px; place-items: center; background: var(--canvas); color: var(--faint); font-size: .6875rem; }
.empty-row td, .empty-state { padding: 24px !important; color: var(--muted); text-align: center; white-space: normal; }
.empty-row strong, .empty-row span, .empty-state strong, .empty-state span { display: block; }
.empty-row strong, .empty-state strong { margin-bottom: 3px; color: var(--ink); }

.drawer { position: fixed; inset: 64px 0 0 auto; z-index: 10; width: min(430px, 100%); overflow: auto; border-left: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); padding: 19px; }
.drawer-heading, .dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.drawer-heading h2, .dialog-heading h2 { margin-bottom: 0; }
.client-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 15px 0; border: 1px solid var(--line); border-radius: var(--radius-md); }
.client-facts div { min-width: 0; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.client-facts div:nth-last-child(-n+2) { border-bottom: 0; }
.client-facts .wide { grid-column: 1 / -1; }
.client-facts dt { color: var(--muted); font-size: .6875rem; font-weight: 700; }
.client-facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.edit-panel, .row-editor { margin: 12px 0; }
summary { cursor: pointer; color: var(--primary); font-weight: 680; }
.edit-panel > summary { margin-bottom: 10px; }
.drawer-section { margin-top: 18px; }
.drawer fieldset { display: grid; gap: 8px; margin: 0 0 9px; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 11px; }
.drawer legend { padding: 0 4px; font-size: .75rem; font-weight: 760; }
.scope-options { display: flex; gap: 12px; }
.scope-options label { display: flex; align-items: center; color: var(--ink); font-weight: 450; }
.scope-options input { width: auto; min-height: auto; }
.read-only-slot { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding: 9px 0; }
.role-mark { display: inline-flex; width: fit-content; border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px 6px; background: var(--surface-2); color: var(--muted); font-size: .625rem; font-weight: 800; letter-spacing: .04em; }

dialog { width: min(590px, calc(100% - 28px)); max-height: calc(100dvh - 28px); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); padding: 20px; }
dialog::backdrop { background: oklch(22% 0.02 250 / .38); }
.form-stack { display: grid; gap: 9px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; margin-top: 4px; }
.inline-form, .availability-form { display: flex; align-items: end; gap: 7px; }
.availability-form { margin: 6px 0; }
.availability-form > span { min-width: 74px; color: var(--muted); font-size: .75rem; }
.notice { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--primary-soft); padding: 9px 10px; }
.error-text { border-color: oklch(84% 0.04 28); background: var(--danger-soft); color: var(--danger); }

.data-table { width: 100%; border-spacing: 0; border-collapse: collapse; background: var(--surface); }
.data-table th, .data-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.data-table thead th { background: var(--surface-2); color: var(--muted); font-size: .6875rem; letter-spacing: .025em; text-transform: uppercase; white-space: nowrap; }
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table tbody > tr:hover > * { background: oklch(98% 0.008 250); }
.data-table form { min-width: 0; flex-wrap: wrap; }
.data-table form label { min-width: 0; flex: 1 1 140px; }
.plain-list { margin: 8px 0 0; padding-left: 17px; white-space: nowrap; }
.card, .admin-section { margin-top: 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); padding: 14px; }
.card.narrow { max-width: 780px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings-grid .card { margin-top: 0; }
.add-row { margin-top: 11px; }
.history { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.history li.card { margin: 0; }
.history time { margin-left: 5px; color: var(--muted); font-size: .75rem; }
.history pre { max-width: 100%; overflow: auto; border-radius: var(--radius-sm); background: var(--surface-2); padding: 9px; font-size: .75rem; white-space: pre-wrap; }
.error-page, .login-card { width: min(430px, calc(100% - 28px)); margin: 11vh auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); padding: 26px; }
.error-page p:not(.eyebrow) { max-width: 65ch; color: var(--muted); }
.login-page { min-height: 100dvh; }
.login-card { display: grid; gap: 14px; }
.login-card .form-stack .button { width: 100%; }

@media (max-width: 900px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .site-header { flex-wrap: wrap; gap: 0 12px; padding: 9px 14px 0; }
  .brand, summary { min-height: 44px; display: flex; align-items: center; padding-inline: 4px; }
  summary::before { content: "▸"; margin-right: 4px; }
  details[open] > summary::before { content: "▾"; }
  .account span { display: none; }
  .account .button { min-height: 44px; padding: 7px 9px; }
  .primary-nav { order: 3; width: 100%; overflow-x: auto; }
  .primary-nav a { min-height: 44px; flex: 1 0 auto; padding: 0 10px; }
  .button, button, input, select, textarea { min-height: 44px; }
  .page { padding: 14px; }
  .page-heading { align-items: start; }
  .metrics { gap: 7px; }
  .metrics article { padding: 9px 10px; }
  .metrics strong { font-size: 1.15rem; }
  .filters { align-items: stretch; flex-direction: column; }
  .filters label { min-width: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .planner-scroll { overflow: visible; border: 0; background: transparent; }
  .planner { display: block; min-width: 0; }
  .planner thead { display: none; }
  .planner tbody, .planner tr, .planner th, .planner td { display: block; }
  .planner tbody > tr { overflow: hidden; margin-bottom: 10px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
  .planner tbody > tr > th { position: static; max-width: none; padding: 11px 12px; border-right: 0; background: var(--surface-2); }
  .planner td { position: relative; display: grid; grid-template-columns: 92px 1fr; align-items: stretch; border-right: 0; }
  .planner td::before { content: attr(data-period-label); padding: 10px 8px; color: var(--muted); font-size: .6875rem; font-weight: 700; }
  .cell { min-width: 0; min-height: 58px; pointer-events: none; }
  .outside-horizon { min-height: 58px; }
  .empty-row td { display: block; }
  .empty-row td::before { content: none; }
  .table-scroll { overflow: visible; border: 0; background: transparent; }
  .data-table { display: block; min-width: 0; background: transparent; }
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .data-table tbody { display: grid; gap: 10px; }
  .data-table tbody tr { display: block; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
  .data-table tbody th, .data-table tbody td { display: grid; grid-template-columns: minmax(96px, .38fr) minmax(0, 1fr); gap: 10px; width: 100%; padding: 9px 10px; white-space: normal; overflow-wrap: anywhere; }
  .data-table tbody [data-label]::before { content: attr(data-label); color: var(--muted); font-size: .6875rem; font-weight: 720; letter-spacing: .025em; text-transform: uppercase; }
  .data-table tbody th[scope="row"] { background: var(--surface-2); }
  .data-table .empty-row td { display: block; border: 0; }
  .data-table .empty-row td::before { content: none; }
  .drawer, [data-open-client], [data-write-form], .row-editor, .card.narrow { display: none !important; }
  .data-table [data-label="Edit"], .data-table [data-label="Actions"], .data-table [data-label="Change"], .settings-grid .add-row { display: none; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .plain-list { white-space: normal; }
  .history time { display: block; margin: 4px 0 0; }
  .error-page, .login-card { margin-top: 7vh; padding: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
