:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #111827;
  --muted: #64748b;
  --line: #dbe4ee;
  --navy: #17213d;
  --blue: #2563eb;
  --teal: #0f766e;
  --green: #15803d;
  --amber: #b7791f;
  --red: #b42318;
  --purple: #6d5dfc;
  --radius: 8px;
  --roster-column-width: 190px;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button, input, select, textarea { font: inherit; }

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  min-height: 38px;
  padding: 0 13px;
  cursor: pointer;
}

button:hover { border-color: #9fb0c3; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
button.primary { background: var(--purple); border-color: var(--purple); color: #fff; font-weight: 800; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
}

textarea { resize: vertical; line-height: 1.35; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 800; color: #334155; }
h1, h2, h3, p { margin: 0; }

.hidden { display: none !important; }

.landing-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #17213d;
  color: #fff;
}

.landing-nav {
  height: 72px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 28px;
}

.brand-mark { font-size: 24px; font-weight: 900; }
.landing-nav button { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.24); color: #fff; font-weight: 800; }

.landing-main {
  width: min(1120px, calc(100vw - 36px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 44px;
  align-items: center;
  padding-bottom: 70px;
}

.landing-copy h1 { font-size: clamp(48px, 7vw, 84px); line-height: .95; letter-spacing: 0; }
.landing-copy p { margin: 18px 0 26px; max-width: 640px; color: #dbeafe; font-size: 19px; line-height: 1.45; }

.login-panel {
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 24px 70px rgba(2, 6, 23, .3);
}

.login-panel h2 { font-size: 24px; }
.login-panel p { color: var(--muted); margin: 6px 0 20px; }
.login-panel form { display: grid; gap: 14px; }
.login-error { margin-top: 12px; background: #fee2e2; color: #7f1d1d; border-radius: 7px; padding: 10px 12px; font-size: 13px; font-weight: 800; }

.app-frame {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: grid;
  align-content: start;
  gap: 28px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--purple);
  color: #fff;
  font-weight: 900;
  font-size: 22px;
}

.brand-lockup strong { display: block; font-size: 22px; }
.brand-lockup span { color: var(--muted); font-size: 12px; }

.main-nav { display: grid; gap: 8px; }
.nav-item {
  border: 0;
  background: transparent;
  min-height: 44px;
  padding: 0 12px;
  text-align: left;
  font-weight: 800;
  color: #475569;
}

.nav-item.active {
  background: #ede9fe;
  color: #5b3ee4;
}

.main-shell {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  min-height: 78px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 24px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 720px;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 0 12px;
}

.search-box span { color: #64748b; font-size: 12px; font-weight: 900; text-transform: uppercase; }
.search-box input { border: 0; background: transparent; min-height: 48px; padding-left: 0; }
.search-box input:focus { outline: none; }

.context-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.context-controls select { width: auto; min-width: 170px; }
.user-chip { color: #334155; font-size: 13px; font-weight: 800; }

.status-row { display: flex; gap: 8px; flex-wrap: wrap; }
.status-pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 900;
  background: #e2e8f0;
  color: #334155;
}
.status-pill.ok { background: #dcfce7; color: #14532d; }
.status-pill.warn { background: #fef3c7; color: #713f12; }

.view {
  display: none;
  padding: 28px;
  min-width: 0;
}
.view.active { display: grid; gap: 18px; align-content: start; }

.view-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}
.view-head h1 { font-size: 30px; line-height: 1.2; }
.view-head p { margin-top: 4px; color: var(--muted); font-size: 15px; }
.builder-preset-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: end;
  margin-top: 12px;
}
.builder-preset-bar label {
  min-width: 210px;
  max-width: 320px;
}
.builder-preset-bar input,
.builder-preset-bar select {
  min-height: 38px;
  background: #fff;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.panel h2, .panel-head h2 { font-size: 17px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.metric-card strong { display: block; font-size: 28px; }
.metric-card span { color: var(--muted); font-size: 13px; font-weight: 800; }

.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.list-stack { display: grid; gap: 9px; }
.list-item {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 11px 12px;
  display: grid;
  gap: 3px;
}
.list-item.selectable {
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: start;
}
.list-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.list-item strong { font-size: 14px; }
.list-item span { color: var(--muted); font-size: 12px; }
.list-item button { justify-self: start; min-height: 30px; margin-top: 6px; }
.list-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.list-actions button { margin-top: 0; }
.status-mini {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px !important;
  font-weight: 900;
  color: #475569 !important;
  background: #e2e8f0;
}
.status-mini.published { color: #065f46 !important; background: #d1fae5; }
button.danger { border-color: #fecaca; color: var(--red); background: #fff7f7; font-weight: 800; }
button.danger:hover { border-color: #f87171; }
.bulk-actions {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
}
.bulk-select,
.roster-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  min-width: 0;
  font-size: 13px;
}
.bulk-select input,
.roster-select input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  padding: 0;
  margin: 0;
  cursor: pointer;
}
.roster-select {
  justify-content: center;
  padding-top: 2px;
}
.bulk-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.roster-build-window { display: grid; gap: 14px; }
.build-accordion {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel.build-accordion {
  padding: 0;
}
.build-accordion > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  list-style: none;
  color: var(--navy);
  font-weight: 900;
}
.build-accordion > summary::-webkit-details-marker { display: none; }
.build-accordion > summary span { font-size: 17px; }
.build-accordion > summary small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.build-accordion > summary::after {
  content: "+";
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #ede9fe;
  color: var(--purple);
  font-size: 18px;
  line-height: 1;
  flex: 0 0 auto;
}
.build-accordion[open] > summary::after { content: "-"; }
.build-accordion[open] > summary { border-bottom: 1px solid var(--line); }
.accordion-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}
.build-window-head {
  align-items: flex-start;
  gap: 14px;
}
.build-mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
}
.build-mode-card {
  display: grid;
  gap: 4px;
  justify-items: start;
  align-content: center;
  min-height: 70px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}
.build-mode-card strong {
  font-size: 14px;
  line-height: 1.2;
}
.build-mode-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}
.build-mode-card.active {
  border-color: var(--purple);
  background: #f3efff;
  box-shadow: inset 0 0 0 1px rgba(111, 82, 255, .34);
}
.build-mode-card.active strong {
  color: var(--purple);
}
.build-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) 170px 140px minmax(200px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
}
.form-button { align-self: end; min-height: 42px; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.roster-input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}
.roster-input-grid textarea {
  min-height: 132px;
}
.roster-import-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 16px;
}
.roster-import-grid textarea {
  min-height: 150px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
.roster-relabel-panel textarea {
  min-height: 180px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.check-row { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.check-row input { width: 18px; min-height: 18px; height: 18px; }

.stage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.stage-actions button { font-weight: 800; }
.stage-actions .stage-button {
  border-width: 1px;
  color: #fff;
  box-shadow: 0 1px 0 rgba(15, 23, 42, .08);
}
.stage-actions .stage-button:disabled {
  opacity: 1;
}
.stage-actions .stage-button.is-ready {
  background: var(--purple);
  border-color: var(--purple);
}
.stage-actions .stage-button.is-complete {
  background: var(--green);
  border-color: var(--green);
}
.stage-actions .stage-button.is-progress {
  background: #d97706;
  border-color: #d97706;
}
.stage-actions .stage-button.is-locked {
  background: var(--red);
  border-color: var(--red);
}
.stage-actions .stage-button.is-ready:hover,
.stage-actions .stage-button.is-complete:hover,
.stage-actions .stage-button.is-progress:hover,
.stage-actions .stage-button.is-locked:hover {
  filter: brightness(.96);
}

.button-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.builder-metrics {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.builder-metrics span {
  min-width: 118px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 12px;
  display: grid;
  gap: 2px;
}
.builder-metrics strong {
  font-size: 20px;
  color: var(--navy);
}
.builder-metrics small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.builder-metrics span:last-child strong { color: var(--teal); }
.settings-builder-shell { display: grid; gap: 14px; }
.builder-steps { display: grid; gap: 10px; }
.builder-step {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.builder-step summary {
  min-height: 54px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 900;
  list-style: none;
}
.builder-step summary::-webkit-details-marker { display: none; }
.builder-step summary span {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: #ede9fe;
  color: var(--purple);
  font-weight: 900;
}
.builder-step[open] summary {
  border-bottom: 1px solid var(--line);
}
.builder-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  padding: 16px;
}
.builder-wide { grid-column: 1 / -1; }
.builder-hidden-source { display: none; }
.builder-table-card {
  display: grid;
  gap: 10px;
}
.builder-mini-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.builder-mini-head strong {
  color: #334155;
  font-size: 13px;
}
.builder-mini-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.builder-mode-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
}
.builder-mode-row label {
  min-width: 210px;
  max-width: 280px;
}
.builder-free-text {
  display: grid;
  gap: 6px;
}
[data-builder-mode-panel][hidden] { display: none; }
.builder-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.builder-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
  background: #fff;
}
.role-catalog-table { min-width: 1120px; }

.admin-create-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
  padding: 16px;
}
.admin-mini-form {
  display: grid;
  gap: 10px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}
.admin-mini-form h3 {
  margin: 0;
  font-size: 16px;
}
.admin-mini-form button { justify-self: start; }
.swap-request-item p {
  margin: 8px 0 0;
  color: var(--ink);
  line-height: 1.4;
}
.rotation-rule-table { min-width: 1220px; }
.builder-table th {
  background: var(--navy);
  color: #fff;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 9px;
}
.builder-table td {
  border-top: 1px solid var(--line);
  padding: 7px;
  vertical-align: middle;
}
.builder-table input,
.builder-table select {
  min-height: 34px;
  padding: 6px 8px;
}
.builder-table .icon-btn {
  min-height: 32px;
  padding: 0 9px;
  font-size: 12px;
}
.builder-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 16px 0;
  flex-wrap: wrap;
}
.builder-output {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
  padding: 16px;
}
.builder-output-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 8px;
}
.builder-output-card h3 {
  font-size: 15px;
}
.builder-output-card textarea {
  min-height: 140px;
  font-size: 12px;
  background: #f8fafc;
}

.build-settings-panel {
  display: block;
}

.build-settings-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.build-settings-head h2 {
  font-size: 20px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}
.settings-card {
  display: grid;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.settings-card.wide { grid-column: 1 / -1; }

.result-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
.result-header h2 { font-size: 21px; }
.result-header p { color: var(--muted); margin-top: 4px; }

.validation-summary { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.summary-chip { border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 900; color: #fff; }
.summary-chip.ok { background: var(--green); }
.summary-chip.warn { background: var(--amber); }
.summary-chip.bad { background: var(--red); }

.ai-review {
  background: #fffaf0;
  border: 1px solid #f2d49b;
  border-radius: var(--radius);
  padding: 12px 14px;
  color: #5f4213;
  font-size: 13px;
}

.workflow-panel {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 8px;
}
.workflow-step {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 78px;
}
.workflow-step strong { display: block; color: var(--navy); font-size: 13px; }
.workflow-step span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.3; }
.workflow-step.done { background: #f0fdfa; border-color: #8fd0bf; }

.diagnostics-list {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
}
.diagnostic-item {
  display: grid;
  grid-template-columns: minmax(220px, 360px) minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}
.diagnostic-main strong {
  display: block;
  color: var(--navy);
  font-size: 13px;
}
.diagnostic-main span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}
.diagnostic-item code {
  white-space: pre-wrap;
  word-break: break-word;
  color: #334155;
  font-size: 12px;
}

.workbook-shell {
  display: grid;
  gap: 12px;
}
.result-summary-accordion {
  background: transparent;
  border: 0;
  padding: 0;
}
.result-summary-accordion > summary {
  padding: 10px 0;
}
.result-summary-accordion[open] > summary {
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.result-summary-body {
  display: grid;
  gap: 12px;
}
.workbook-tab-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.workbook-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.workbook-width-control {
  display: flex;
  align-items: center;
  grid-template-columns: none;
  gap: 8px;
  font-size: 12px;
  white-space: nowrap;
}
.workbook-width-control select {
  width: 132px;
  min-height: 38px;
  padding: 6px 8px;
}
.tabs { display: flex; gap: 8px; }
.tab { background: #fff; font-weight: 800; }
.tab.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.workbook-maximize {
  background: #fff;
  font-weight: 900;
}
body.roster-fullscreen {
  overflow: hidden;
}
body.roster-fullscreen #workbookShell {
  position: fixed;
  inset: 10px;
  z-index: 95;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #f8fafc;
  box-shadow: 0 24px 90px rgba(15,23,42,.35);
  overflow: hidden;
}
body.roster-fullscreen #rosterView.table-wrap,
body.roster-fullscreen #metricsView.table-wrap,
body.roster-fullscreen #coverageView.table-wrap {
  max-height: none;
  height: 100%;
  min-height: 0;
}
body.roster-fullscreen .workflow-panel {
  max-height: 92px;
  overflow: auto;
}

.table-wrap {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
#rosterView.table-wrap {
  max-height: min(72vh, 760px);
  scrollbar-gutter: stable;
}
.table-wrap.small { max-height: 360px; }
.empty-state { padding: 18px; color: var(--muted); font-size: 13px; }

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 1160px;
}
th, td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
  text-align: center;
  font-size: 12px;
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--navy);
  color: #fff;
  font-weight: 900;
}
td:first-child, th:first-child { position: sticky; left: 0; z-index: 3; }
td:first-child { background: #f8fafc; text-align: left; font-weight: 900; }
th:first-child { z-index: 4; }

.sheet-table th, .sheet-table td { height: 30px; font-size: 13px; padding: 5px 8px; }
.sheet-table .sheet-title { position: static; background: #0f4c9a; color: #fff; font-size: 14px; text-align: center; border-bottom: 3px solid #1d8cff; }
.sheet-table .summary-row td { background: #eef1fb; font-weight: 900; }
.sheet-table .summary-row td:first-child { min-width: 280px; text-align: left; z-index: 5; }
.sheet-table .dark-row td, .sheet-table .block-label td { background: var(--navy); color: #fff; font-weight: 900; text-align: center; }
.workbook-edit-note {
  padding: 9px 12px;
  background: #f0fdfa;
  border-bottom: 1px solid var(--line);
  color: #0f766e;
  font-size: 13px;
  font-weight: 800;
}
.sheet-table .meta-row td {
  background: #f8fafc;
  font-weight: 800;
}
.sheet-table .meta-row td:first-child { z-index: 6; }
.sheet-table .reg-header th { position: sticky; top: 0; z-index: 12; background: var(--navy); color: #fff; font-size: 14px; }
.sheet-table .reg-header th:nth-child(-n+3) { z-index: 14; }
.sheet-table tr:not(.summary-row):not(.dark-row):not(.block-label) > :is(th, td):nth-child(1) { left: 0; min-width: 92px; }
.sheet-table tr:not(.summary-row):not(.dark-row):not(.block-label) > :is(th, td):nth-child(2) { position: sticky; left: 92px; z-index: 4; min-width: 116px; background: #f8fafc; }
.sheet-table tr:not(.summary-row):not(.dark-row):not(.block-label) > :is(th, td):nth-child(3) { position: sticky; left: 208px; z-index: 4; min-width: 72px; background: #f8fafc; }
.sheet-table .reg-header > th:nth-child(-n+3) { background: var(--navy); color: #fff; z-index: 14; }
.sheet-table .sheet-spacer { background: #fff; min-width: 18px; width: 18px; }
.sheet-table .count-cell { background: #fffdf2; }
.sheet-table tr.weekend-row > td:nth-child(-n+3),
.sheet-table tr.weekend-row > td.count-cell { background: #fce7f3 !important; }
.sheet-table .block-total td { background: #fff8dc; font-weight: 900; }
.sheet-table .extra-column.vacant-column { background: #f1f5f9; color: #475569; }
.sheet-table .extra-column.reliever-column { background: #ecfeff; color: #0e7490; }
.sheet-table .shift-empty { background: #fff; color: #94a3b8; }
.sheet-table .shift-cell.is-selected {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
  box-shadow: inset 0 0 0 999px rgba(37, 99, 235, .10);
}
.sheet-table .shift-cell.is-anchor {
  outline-color: #111827;
}
.shift-input,
.staff-meta-input {
  width: 100%;
  min-width: calc(var(--roster-column-width) - 20px);
  min-height: 26px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: center;
  padding: 2px 4px;
}
.shift-input {
  height: 50px;
  min-height: 50px;
  line-height: 1.22;
  resize: none;
  overflow: hidden;
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
  text-align: left;
  color: transparent;
  caret-color: #111827;
}
.staff-meta-input {
  min-width: calc(var(--roster-column-width) - 20px);
  font-size: 12px;
  font-weight: 700;
  color: #334155;
}
.shift-input:focus,
.staff-meta-input:focus {
  outline: 2px solid #6d5dfc;
  outline-offset: -2px;
  background: #fff;
  color: #111827;
}
.sheet-table .shift-cell {
  position: relative;
}
.shift-render,
.shift-static-render {
  white-space: pre-wrap;
  text-align: left;
  line-height: 1.22;
}
.shift-render {
  position: absolute;
  inset: 7px 12px;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}
.shift-input:focus + .shift-render {
  display: none;
}
.shift-callout,
.leave-token {
  color: #dc2626;
  font-weight: 900;
}
.button-row #publishBtn.is-complete {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.shift-OFF { background: #ffffff; color: #111827; }
.shift-NW1, .shift-NW2 { background: #ffff00; color: #111; font-weight: 900; }
.shift-DW1, .shift-SDW1, .shift-LDW1, .shift-MAU1, .shift-WBA-MAU, .shift-WBA-MAU1 { background: #dae3f3; color: #111827; }
.shift-DW2, .shift-SDW2, .shift-LDW2, .shift-MAU2 { background: #4472c4; color: #fff; font-weight: 900; }
.shift-LDW3, .shift-SDW3 { background: #c6e0b4; color: #111827; }
.shift-LDW4, .shift-SDW4 { background: #fff2cc; color: #111827; }
.shift-LDW5, .shift-SDW5 { background: #92d050; color: #111827; }
.shift-CAN1, .shift-SDW-CAN, .shift-LDW-CAN, .shift-SDW-CAN1, .shift-LDW-CAN1 { background: #f8cbad; color: #111827; }
.shift-CAN2, .shift-WBA-CAN, .shift-WBA-CAN2, .shift-SDW-CAN2, .shift-LDW-CAN2 { background: #ffc000; color: #111827; }
.shift-ADMEV, .shift-SDWDC { background: #adadad; color: #111827; }
.shift-OnC { background: #ffffff; color: #dc2626; font-weight: 900; }

.sheet-table .shift-cell.shift-OFF { background: #ffffff; color: #111827; }
.sheet-table .shift-cell.shift-NW1,
.sheet-table .shift-cell.shift-NW2 { background: #ffff00; color: #111; font-weight: 900; }
.sheet-table .shift-cell.shift-DW1,
.sheet-table .shift-cell.shift-SDW1,
.sheet-table .shift-cell.shift-LDW1,
.sheet-table .shift-cell.shift-MAU1,
.sheet-table .shift-cell.shift-WBA-MAU,
.sheet-table .shift-cell.shift-WBA-MAU1 { background: #dae3f3; color: #111827; }
.sheet-table .shift-cell.shift-DW2,
.sheet-table .shift-cell.shift-SDW2,
.sheet-table .shift-cell.shift-LDW2,
.sheet-table .shift-cell.shift-MAU2 { background: #4472c4; color: #fff; font-weight: 900; }
.sheet-table .shift-cell.shift-LDW3,
.sheet-table .shift-cell.shift-SDW3 { background: #c6e0b4; color: #111827; }
.sheet-table .shift-cell.shift-LDW4,
.sheet-table .shift-cell.shift-SDW4 { background: #fff2cc; color: #111827; }
.sheet-table .shift-cell.shift-LDW5,
.sheet-table .shift-cell.shift-SDW5 { background: #92d050; color: #111827; }
.sheet-table .shift-cell.shift-SDW-CAN,
.sheet-table .shift-cell.shift-SDW-CAN1,
.sheet-table .shift-cell.shift-LDW-CAN,
.sheet-table .shift-cell.shift-LDW-CAN1,
.sheet-table .shift-cell.shift-CAN1 { background: #f8cbad; color: #111827; }
.sheet-table .shift-cell.shift-CAN2,
.sheet-table .shift-cell.shift-WBA-CAN,
.sheet-table .shift-cell.shift-WBA-CAN2,
.sheet-table .shift-cell.shift-SDW-CAN2,
.sheet-table .shift-cell.shift-LDW-CAN2 { background: #ffc000; color: #111827; }
.sheet-table .shift-cell.shift-ADMEV,
.sheet-table .shift-cell.shift-SDWDC { background: #adadad; color: #111827; }
.sheet-table .shift-cell.shift-OnC { background: #ffffff; color: #dc2626; font-weight: 900; }
.sheet-table .staff-column,
.sheet-table .extra-column.vacant-column,
.sheet-table .extra-column.reliever-column {
  min-width: var(--roster-column-width);
  width: var(--roster-column-width);
}
.sheet-table .shift-cell {
  min-width: var(--roster-column-width);
  width: var(--roster-column-width);
  height: 58px;
  white-space: normal;
  vertical-align: top;
}
.sheet-table .shift-cell.shift-empty { min-width: var(--roster-column-width); }
.sheet-table .shift-cell.leave-marked {
  background: #fff !important;
  color: #111827 !important;
  font-weight: 900;
}
.sheet-table .shift-cell.leave-marked .shift-input {
  background: #fff;
  color: transparent;
}
.sheet-table .shift-cell.leave-marked .shift-input:focus {
  color: #111827;
}

.metric-bad { background: #fee2e2; color: #7f1d1d; font-weight: 900; }
.metric-warn { background: #fef3c7; color: #713f12; font-weight: 900; }
.metric-ok { background: #dcfce7; color: #14532d; }

.floating-chat {
  position: fixed;
  left: 18px;
  bottom: 18px;
  width: min(430px, calc(100vw - 36px));
  z-index: 30;
  pointer-events: none;
}
.chat-toggle {
  pointer-events: auto;
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 12px 30px rgba(15,23,42,.22);
}
.chat-panel {
  pointer-events: auto;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 60px rgba(15,23,42,.28);
  padding: 12px;
}
.floating-chat.collapsed .chat-panel { display: none; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.chat-head strong { color: var(--navy); font-size: 14px; }
.chat-head button { min-height: 30px; padding: 0 9px; font-size: 12px; }
.chat-messages { display: grid; gap: 8px; max-height: 280px; overflow: auto; margin-bottom: 10px; }
.chat-message { border: 1px solid var(--line); border-radius: 7px; padding: 9px 10px; background: #fff; font-size: 13px; line-height: 1.35; }
.chat-message.user { background: #eef6ff; }
.chat-message.assistant { background: #f0fdfa; }
.chat-message ul { margin: 8px 0 0 18px; padding: 0; }
.chat-message button { margin-top: 8px; min-height: 32px; }
.chat-form { display: grid; gap: 8px; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  background: #111827;
  color: #fff;
  padding: 11px 13px;
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(15,23,42,.26);
  font-size: 13px;
  z-index: 40;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, .34);
  backdrop-filter: blur(2px);
}
.busy-card {
  width: min(360px, calc(100vw - 36px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 22px 70px rgba(15, 23, 42, .28);
  padding: 22px;
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
}
.busy-card strong { color: var(--navy); font-size: 18px; }
.busy-card p { color: var(--muted); font-size: 13px; line-height: 1.35; }
.busy-spinner {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 4px solid #dbeafe;
  border-top-color: var(--purple);
  animation: spin .85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.muted { color: var(--muted); font-size: 13px; }

@media (max-width: 1180px) {
  .app-frame { grid-template-columns: 220px minmax(0, 1fr); }
  .topbar { grid-template-columns: 1fr; }
  .context-controls { justify-content: flex-start; }
  .build-form { grid-template-columns: repeat(2, minmax(200px, 1fr)); }
  .build-mode-grid { grid-template-columns: 1fr; }
  .metric-grid, .workflow-panel { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .split-grid, .settings-grid, .roster-input-grid, .roster-import-grid, .builder-grid, .builder-output { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .landing-main { grid-template-columns: 1fr; padding-top: 24px; }
  .app-frame { grid-template-columns: 1fr; }
  .sidebar { position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .main-nav { grid-template-columns: repeat(2, 1fr); }
  .view { padding: 18px; }
  .view-head { align-items: stretch; flex-direction: column; }
  .stage-actions, .button-row { justify-content: flex-start; }
  .build-form { grid-template-columns: 1fr; }
}
