/* ── Reset & Variables ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #1E293B;
  --text-muted: #64748B;
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --danger: #DC2626;
  --danger-hover: #B91C1C;
  --success: #16A34A;
  --shift-day: #FCD34D;
  --shift-day-text: #92400E;
  --shift-8a: #FB923C;
  --shift-8a-text: #7C2D12;
  --shift-10a: #34D399;
  --shift-10a-text: #064E3B;
  --shift-2p: #60A5FA;
  --shift-2p-text: #1E3A5F;
  --shift-overnight: #A78BFA;
  --shift-overnight-text: #3B1F6E;
  /* legacy aliases */
  --shift-swing: #60A5FA;
  --shift-swing-text: #1E3A5F;
  --shift-night: #A78BFA;
  --shift-night-text: #3B1F6E;
  --sidebar-width: 220px;
  --radius: 8px;
}

/* Reserve space for the vertical scrollbar even when content fits
   in the viewport. Without this, switching between page states
   that do/don't overflow (e.g. doctor tiles vs list view) makes the
   scrollbar appear/disappear, shifting the viewport width by ~15px
   and reflowing every horizontal element including header buttons. */
html {
  scrollbar-gutter: stable;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--text);
  color: #CBD5E1;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid #334155;
}

.sidebar-header h1 {
  font-size: 18px;
  color: #F8FAFC;
  font-weight: 700;
}

.nav-links {
  list-style: none;
  padding: 12px 0;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: #94A3B8;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-links a:hover { color: #E2E8F0; background: #334155; }
.nav-links a.active { color: #FFFFFF; background: var(--primary); }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }

/* Sidebar footer: shows the logged-in user + sign-out link, pinned to
   the bottom of the sidebar. */
.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px 20px;
  border-top: 1px solid #334155;
}
.current-user {
  margin-bottom: 10px;
}
.current-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #E2E8F0;
  word-break: break-all;
}
.current-user-role {
  font-size: 11px;
  color: #94A3B8;
  text-transform: capitalize;
  letter-spacing: 0.3px;
}
.logout-link {
  display: inline-block;
  font-size: 12px;
  color: #94A3B8;
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 1px dashed #475569;
  transition: color 80ms ease;
}
.logout-link:hover {
  color: #F8FAFC;
  border-bottom-color: #94A3B8;
}

/* ── Inline help icons (?) ──────────────────────────────────
   Hover (or keyboard-focus) a tiny "?" badge next to a field title
   to surface a tooltip with the field's explanation. The tip is
   position:fixed so it escapes any overflow:auto modal that contains
   the icon. JS positions it via showHelpTip / hideHelpTip in app.js. */
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 10px;
  font-weight: 700;
  color: #64748B;
  background: #E2E8F0;
  border-radius: 50%;
  cursor: help;
  margin-left: 6px;
  vertical-align: -2px;
  user-select: none;
  flex-shrink: 0;
}
.help-icon:hover,
.help-icon:focus-visible {
  background: #CBD5E1;
  color: #0F172A;
  outline: none;
}
.help-tip {
  /* Hidden by default but laid out (visibility:hidden, not display:none)
     so JS can measure it before showing — no positioning flicker. Parked
     off-screen so it doesn't affect the surrounding layout. */
  position: fixed;
  visibility: hidden;
  opacity: 0;
  top: -9999px;
  left: -9999px;
  background: #0F172A;
  color: #F8FAFC;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  width: 260px;
  max-width: calc(100vw - 24px);
  white-space: normal;
  text-align: left;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 9999;
  pointer-events: none;
  transition: opacity 100ms ease;
}
.help-tip.show {
  visibility: visible;
  opacity: 1;
}
.help-tip strong { color: #FFFFFF; font-weight: 600; }
.help-tip em { color: #FBBF24; font-style: italic; }

/* ── Auth pages (login / login_error) ───────────────────── */
/* Full-page centered card, sidebar removed. */
.auth-body {
  background: #F1F5F9;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.auth-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.10);
  padding: 40px 36px 32px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.auth-title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
  color: #0F172A;
}
.auth-sub {
  margin: 0 0 28px;
  color: #64748B;
  font-size: 14px;
}
.auth-footnote {
  margin-top: 20px;
  font-size: 12px;
}
.auth-error {
  color: #B91C1C;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  padding: 12px 14px;
  border-radius: 6px;
  margin: 16px 0 24px;
  font-size: 14px;
  line-height: 1.45;
}
.auth-error-email {
  margin: 4px 0 16px;
  color: #475569;
  font-size: 14px;
}

/* Google's branded sign-in button — white bg, gray border, Google logo. */
.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 11px 22px;
  background: white;
  color: #1F1F1F;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  border: 1px solid #DADCE0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 120ms ease, box-shadow 120ms ease;
}
.btn-google:hover {
  background: #F8F9FA;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.btn-google:focus-visible {
  outline: 2px solid var(--primary, #4A90D9);
  outline-offset: 2px;
}

/* ── Admin users page ───────────────────────────────────── */
#usersTable .user-name-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 6px;
  border-radius: 4px;
}
#usersTable .user-name-input:hover { border-color: var(--border, #ccc); }
#usersTable .user-name-input:focus {
  border-color: var(--primary, #4A90D9);
  background: white;
  outline: none;
}
#usersTable tr.row-inactive td {
  opacity: 0.45;
  text-decoration: line-through;
}
#usersTable tr.row-inactive td input[type="checkbox"],
#usersTable tr.row-inactive td button {
  opacity: 1;
  text-decoration: none;
}

/* ── Content ──────────────────────────────────────────── */
.content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px;
  max-width: 1200px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-header h2 { font-size: 24px; font-weight: 700; }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #CBD5E1; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Cards ────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-header h3 { font-size: 16px; font-weight: 600; }

/* ── Forms ────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input:not(.constraint-toggle),
.form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
}

/* Inside flex rows, let flex layout control sizing instead of width:100% */
.flex input,
.flex select {
  width: auto;
  min-width: 0;
}

.form-group input:not(.constraint-toggle):focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

/* ── Shift Preferences Grid ────────────────────────── */
.shift-pref-table {
  border-collapse: collapse;
  width: 100%;
}
.shift-pref-table th {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  padding: 4px 2px;
  text-align: center;
}
.shift-pref-table td {
  padding: 2px;
  text-align: center;
}
.shift-pref-label {
  font-size: 12px;
  font-weight: 600;
  text-align: right !important;
  padding-right: 8px !important;
  white-space: nowrap;
  color: var(--text);
}
.shift-pref-cell {
  width: 100%;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.15s;
  user-select: none;
}
.shift-pref-cell:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.shift-pref-neutral {
  background: var(--surface);
  color: transparent;
}
.shift-pref-preferred {
  background: #dcfce7;
  color: #16a34a;
  border-color: #86efac;
}
.shift-pref-avoided {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}
.shift-pref-disabled {
  background: var(--bg);
  border-color: var(--border);
  opacity: 0.35;
  cursor: not-allowed;
}
.shift-pref-disabled:hover {
  border-color: var(--border);
  box-shadow: none;
}

/* ── Allowed Shifts Grid ────────────────────────────── */
.allowed-shift-cell {
  width: 100%;
  height: 30px;
  border: 2px solid var(--border);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.15s;
  user-select: none;
}
.allowed-shift-cell:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.allowed-shift-off {
  background: var(--surface);
  color: transparent;
}
.allowed-shift-on {
  background: #dbeafe;
  color: #2563eb;
  border-color: #93c5fd;
}
.allowed-shift-inactive {
  background: var(--bg);
  border-color: var(--border);
  opacity: 0.35;
  cursor: not-allowed;
}
.allowed-shift-inactive:hover {
  border-color: var(--border);
  box-shadow: none;
}
#allowedShiftsTable.allowed-shifts-readonly .allowed-shift-cell {
  cursor: default;
  opacity: 0.55;
}
#allowedShiftsTable.allowed-shifts-readonly .allowed-shift-cell:hover {
  border-color: var(--border);
  box-shadow: none;
}
#allowedShiftsTable.allowed-shifts-readonly .allowed-shift-on:hover {
  border-color: #93c5fd;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all 0.15s;
}

.checkbox-group label:has(input:checked) {
  background: #EFF6FF;
  border-color: var(--primary);
  color: var(--primary);
}

.checkbox-group input { display: none; }

/* ── Constraint Toggles ──────────────────────────────── */
.constraint-toggle {
  width: 14px;
  height: 14px;
  margin-right: 6px;
  vertical-align: middle;
  cursor: pointer;
  accent-color: var(--primary);
}

.form-group.constraint-off > label {
  color: #CBD5E1;
}

.form-group.constraint-off select,
.form-group.constraint-off input:not(.constraint-toggle),
.form-group.constraint-off .checkbox-group {
  opacity: 0.3;
  pointer-events: none;
}

/* ── View Toggle ──────────────────────────────────────── */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.view-toggle-btn {
  background: var(--surface);
  color: var(--text-muted);
  border: none;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.view-toggle-btn + .view-toggle-btn { border-left: 1px solid var(--border); }
.view-toggle-btn:hover { background: var(--bg); }
.view-toggle-btn.active { background: var(--primary); color: white; }

/* ── Doctor List ──────────────────────────────────────── */
.doctor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

/* List view — one doctor per row, name and tags inline. */
.doctor-grid.list-view {
  grid-template-columns: 1fr;
  gap: 8px;
}

.doctor-grid.list-view .doctor-card {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 12px 16px;
}

.doctor-grid.list-view .doctor-name {
  margin-bottom: 0;
  min-width: 160px;
  flex-shrink: 0;
}

.doctor-grid.list-view .doctor-meta { flex: 1; }

.doctor-grid.list-view .doctor-card > .text-sm {
  flex-basis: 100%;
  margin-top: 0;
}

/* ── Spreadsheet-style Doctor table (list view) ──────────── */
/* The table replaces the card grid entirely when list view is on. It's
   wrapped in .doctor-table-wrap so we can scroll horizontally on narrow
   viewports without scrolling the whole page. */
.doctor-table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.doctor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.doctor-table thead th {
  position: sticky;
  top: 0;
  background: #F8FAFC;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 10px 10px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  z-index: 1;
}
.doctor-table th.sortable { cursor: pointer; user-select: none; }
.doctor-table th.sortable:hover { color: var(--text); background: #F1F5F9; }
.doctor-table th.sortable::after {
  content: '';
  display: inline-block;
  margin-left: 4px;
  opacity: 0.35;
  font-size: 10px;
  vertical-align: middle;
}
.doctor-table th.sortable::after { content: '⇅'; }
.doctor-table th.sort-asc::after  { content: '▲'; opacity: 1; color: var(--primary); }
.doctor-table th.sort-desc::after { content: '▼'; opacity: 1; color: var(--primary); }

.doctor-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}
.doctor-table tbody tr {
  cursor: pointer;
  transition: background 80ms ease;
}
.doctor-table tbody tr:hover { background: #F8FAFC; }
.doctor-table tbody tr:last-child td { border-bottom: none; }

.doctor-table .num { text-align: right; }
.doctor-table thead th.num { text-align: right; }
.doctor-table .muted { color: var(--text-muted); }

/* Color swatch column — small filled square anchored left. */
.doctor-table th.col-color,
.doctor-table td:first-child {
  width: 14px;
  padding-left: 12px;
  padding-right: 4px;
}
.color-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08) inset;
}

.doctor-table .doctor-name-cell {
  font-weight: 600;
  color: var(--text);
}

/* Notes column — flex-grow into remaining space, truncate with ellipsis. */
.doctor-table .notes-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
  color: var(--text-muted);
}

.doctor-card {
  border-left: 4px solid var(--primary);
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.doctor-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.doctor-name {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.doctor-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.doctor-meta .tag {
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg);
  font-size: 12px;
}

/* Inactive-doctor visual treatment. The .tag-inactive badge can appear
   anywhere a doctor's name is rendered (tile, table row, Generate page).
   .doctor-inactive dims the whole tile; .row-inactive on a <tr> dims
   the whole table row. */
.tag-inactive {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 4px;
  background: #FEE2E2;
  color: #991B1B;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  vertical-align: middle;
}

/* "Applied" badge for the currently-applied schedule of a period. */
.tag-applied {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  background: #DCFCE7;
  color: #166534;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  vertical-align: middle;
  margin-right: 6px;
}

/* ── Breadcrumb above page-header ───────────────────── */
.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}
.breadcrumb a:hover {
  color: var(--primary);
  text-decoration: underline;
}
.breadcrumb .sep {
  margin: 0 6px;
  color: #CBD5E1;
}

/* ── Periods list / detail ──────────────────────────── */
#periodsTable tr.clickable-row { cursor: pointer; }
#periodsTable tr.clickable-row:hover { background: #F8FAFC; }
#periodsTable .row-actions,
#candidatesTable .row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  white-space: nowrap;
}

/* ── Period calendar view ───────────────────────────── */
/* Two-column layout: calendar grid on the left, period legend on the
   right. Stacks on narrower viewports. */
.period-cal-wrap {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 1100px) {
  .period-cal-wrap { grid-template-columns: 1fr; }
}

.period-cal {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.period-cal-month {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px 14px;
}
.period-cal-month-label {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.period-cal-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}
.period-cal-grid th {
  padding: 4px 0;
  text-align: center;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.period-cal-grid td {
  text-align: center;
  vertical-align: top;
  height: 34px;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}
.period-cal-day-num {
  display: inline-block;
  font-size: 12px;
  color: var(--text);
  padding: 3px 2px 0;
}
.period-cal-day.is-weekend .period-cal-day-num {
  color: var(--text-muted);
}
.period-cal-day-empty {
  background: transparent;
}

/* Days that fall inside a period: colored background, click-to-navigate. */
.period-cal-day-in {
  cursor: pointer;
  transition: filter 80ms ease;
  border-color: transparent;
}
.period-cal-day-in:hover {
  filter: brightness(0.92) saturate(1.05);
}
/* Period-start and period-end get rounded corners on the appropriate
   sides, so a multi-day band reads as a single pill. */
.period-cal-day-in.is-start {
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
}
.period-cal-day-in.is-end {
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}
.period-cal-day-in.is-start.is-end {
  border-radius: 6px;
}
/* Tiny period-name label on the first day of the band. Visually
   identifies which period a band belongs to without needing hover. */
.period-cal-day-label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: rgba(0, 0, 0, 0.65);
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

/* "Today" marker — small circle around the number. */
.period-cal-grid td.is-today .period-cal-day-num {
  background: var(--primary);
  color: white;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  line-height: 19px;
  padding: 0;
  font-weight: 600;
}

/* ── Period legend (right-side chip list) ──────────── */
.period-cal-legend {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 8px;
  position: sticky;
  top: 16px;
}
.period-cal-legend h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
}
.period-cal-legend ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.period-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 80ms ease, background 80ms ease;
}
.period-chip:hover {
  border-color: var(--primary);
  background: #F8FAFC;
}
.period-chip-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid transparent;
  flex-shrink: 0;
}
.period-chip-body {
  flex: 1;
  min-width: 0;
}
.period-chip-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.period-chip-dates {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}
.period-chip-delete {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  opacity: 0;
  transition: opacity 80ms ease, color 80ms ease;
}
.period-chip:hover .period-chip-delete { opacity: 1; }
.period-chip-delete:hover { color: var(--danger); }

.applied-summary {
  border-left: 4px solid var(--success);
  padding: 14px 18px;
}
.applied-summary.applied-none {
  border-left-color: var(--border);
  background: #FAFBFC;
  color: var(--text-muted);
}
#candidatesTable tr.is-applied td {
  background: #F0FDF4;
}
#candidatesTable tr.is-applied:hover td {
  background: #DCFCE7;
}
.doctor-card.doctor-inactive {
  opacity: 0.55;
  background: #FAFBFC;
}
.doctor-card.doctor-inactive:hover {
  opacity: 0.85;
}
.doctor-table tr.row-inactive td {
  background: #FAFBFC;
  color: var(--text-muted);
}
.doctor-table tr.row-inactive:hover td {
  background: #F1F5F9;
}

/* Generate-page excluded row: dimmed, strikethrough on the name cell. */
#targetsTable tr.row-excluded {
  opacity: 0.45;
  background: #FAFBFC;
}
#targetsTable tr.row-excluded td:nth-child(2) {
  text-decoration: line-through;
}
#targetsTable tr.row-excluded:hover {
  opacity: 0.75;
}
#targetsTable .include-doctor-cb {
  cursor: pointer;
  transform: scale(1.15);
}

/* The `<label class="toggle-label">` wraps a checkbox + caption + (?)
   in the Basics section, all on one line. */
.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

/* ── Shift Badges ─────────────────────────────────────── */
.shift-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.shift-day       { background: var(--shift-day);       color: var(--shift-day-text); }
.shift-8a        { background: var(--shift-8a);        color: var(--shift-8a-text); }
.shift-10a       { background: var(--shift-10a);       color: var(--shift-10a-text); }
.shift-2p        { background: var(--shift-2p);        color: var(--shift-2p-text); }
.shift-overnight { background: var(--shift-overnight); color: var(--shift-overnight-text); }
/* legacy */
.shift-swing { background: var(--shift-swing); color: var(--shift-swing-text); }
.shift-night { background: var(--shift-night); color: var(--shift-night-text); }

/* ── Modal ────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
}

.modal-backdrop.open { display: block; }

.modal {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  z-index: 201;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal.open { display: block; }

.modal h3 {
  font-size: 18px;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ── Data List (blocked dates, time-off) ──────────────── */
.data-list {
  list-style: none;
  margin-top: 8px;
}

.data-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--bg);
  font-size: 13px;
}

.data-list li:last-child { border-bottom: none; }

.data-list .remove-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
}

.data-list .remove-btn:hover { color: var(--danger-hover); }

/* ── Shift Config Table ──────────────────────────────── */
.shift-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.shift-table th,
.shift-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.shift-table th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg);
}

.shift-table tr:hover { background: #F8FAFC; }

/* ── Schedule Grid ────────────────────────────────────── */
.schedule-container {
  overflow-x: auto;
  margin-top: 16px;
}

.schedule-grid {
  border-collapse: collapse;
  font-size: 12px;
  min-width: 100%;
}

.schedule-grid th,
.schedule-grid td {
  padding: 4px 6px;
  text-align: center;
  border: 1px solid var(--border);
  min-width: 42px;
  white-space: nowrap;
}

.schedule-grid th {
  background: var(--bg);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
}

.schedule-grid th.dow { font-size: 10px; color: var(--text-muted); }

.schedule-grid .doctor-label {
  text-align: left;
  font-weight: 600;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 5;
  /* Shrink to content: the table has min-width:100%, which would otherwise
     dump all the slack width into this column. With width:1px + nowrap the
     cell collapses to its content, and the date columns absorb the extra. */
  width: 1px;
  white-space: nowrap;
  border-right: 2px solid var(--border);
}

.schedule-grid td.weekend { background: #F8FAFC; }

.schedule-cell {
  display: inline-block;
  min-width: 26px;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Generate Page ────────────────────────────────────── */
.generate-form {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.generate-form .form-group { margin-bottom: 0; }

.schedule-list {
  margin-top: 24px;
}

.schedule-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
}

.schedule-item a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.schedule-item a:hover { text-decoration: underline; }

.schedule-item .meta {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Loading ──────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  z-index: 300;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 16px;
}

.loading-overlay.active {
  display: flex;
}

.loading-overlay .spinner {
  width: 40px;
  height: 40px;
}

.progress-bar-track {
  width: 320px;
  max-width: 80vw;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.5s linear;
}

/* ── Modal accordion sections ─────────────────────────── */
.modal-section {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 10px;
  background: white;
  overflow: hidden;
}
.modal-section > summary {
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  background: #f6f8fa;
  border-bottom: 1px solid transparent;
  list-style: none;             /* hide native marker (Firefox falls back) */
  user-select: none;
  position: relative;
  padding-left: 32px;
  transition: background 120ms ease;
}
.modal-section > summary::-webkit-details-marker {
  display: none;                /* hide native marker (WebKit) */
}
/* Custom chevron — rotates 90deg when open. */
.modal-section > summary::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 6px solid var(--text-muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transform: translateY(-50%);
  transition: transform 120ms ease;
}
.modal-section[open] > summary {
  border-bottom-color: var(--border);
}
.modal-section[open] > summary::before {
  transform: translateY(-25%) rotate(90deg);
}
.modal-section > summary:hover {
  background: #eef3fb;
}
.modal-section[open] > *:not(summary) {
  /* Horizontal padding for the body of an open section. */
  padding-left: 14px;
  padding-right: 14px;
}
.modal-section[open] > summary + * {
  /* First body element gets top padding. */
  padding-top: 12px;
}
.modal-section[open] {
  /* Bottom padding for the section body when open. */
  padding-bottom: 12px;
}

/* ── Clickable doctor cell in schedule grid ────────────── */
.schedule-grid .doctor-label {
  /* The cell as a whole opens the doctor's profile when clicked. */
  cursor: pointer;
  transition: filter 100ms ease, box-shadow 100ms ease;
}
.schedule-grid .doctor-label:hover {
  filter: brightness(1.05);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.schedule-grid .doctor-label .doctor-name {
  /* Subtle underline-on-hover to reinforce that the cell is clickable. */
  border-bottom: 1px dotted transparent;
  transition: border-color 100ms ease;
}
.schedule-grid .doctor-label:hover .doctor-name {
  border-bottom-color: currentColor;
}

/* Inside the doctor-label cell: name on left, happiness emoji on right
   with a comfortable gap. The cell sizes to its content now, so the emoji
   ends up close to the name without giant empty space between them. */
.doctor-label-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}
.doctor-label-inner .happiness-icon {
  margin-left: auto;
}

/* ── Score breakdown modal ────────────────────────────── */
.score-total {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 16px;
  background: #f6f8fa;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 16px;
}
.score-total-label {
  font-weight: 700;
  font-size: 14px;
}
.score-total-value {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #1f2937;
}
.score-row {
  margin-bottom: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.score-row:last-child { border-bottom: none; }
.score-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}
.score-row-value {
  font-weight: 700;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.score-row-bar {
  height: 6px;
  background: #f1f5f9;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}
.score-row-bar > span {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 200ms ease;
}
.score-row-meta {
  font-size: 12px;
  line-height: 1.4;
}

/* ── Per-doctor happiness icon ────────────────────────── */
.happiness-icon {
  display: inline-block;
  margin-left: 6px;
  font-size: 14px;
  cursor: help;
  vertical-align: middle;
  /* Slight opacity so it's a glanceable accent, not the dominant element. */
  opacity: 0.95;
}
.happiness-icon:hover {
  opacity: 1;
  transform: scale(1.15);
  transition: transform 80ms ease;
}
.happiness-score {
  display: inline-block;
  margin-left: 4px;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Combined Total / Target cell in doctor summary ────────
   Renders as "11/12" — the left number is the assigned count
   (static), the right number is an inline contenteditable span
   for the per-doctor target. The whole <td> picks up the
   off-target highlight (.cell-off-bad / .cell-off-soft). */
.total-target-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: center;
}
.total-assigned {
  font-weight: 600;
}
.cell-slash {
  color: var(--text-muted);
  margin: 0 2px;
  font-weight: 400;
}
.target-inline {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 3px;
  cursor: text;
  border-bottom: 1px dashed var(--border, #ccc);
  border-radius: 2px;
  outline: none;
  font-weight: 600;
}
.target-inline:hover {
  background: rgba(74, 144, 217, 0.10);
}
.target-inline:focus {
  background: rgba(74, 144, 217, 0.18);
  border-bottom-color: transparent;
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.55);
}
.target-inline .target-empty {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
}

/* ── Off-target highlights in Doctor Summary ─────────────
   cell-off-bad   – numeric value outside a hard min/max range
   cell-off-soft  – inside the range but off the soft target

   Both apply a tinted background, colored text, and a soft halo so
   they stand out without being obnoxious. Hover the cell for a
   tooltip explaining which target was missed. */
#summaryTable td.cell-off-bad {
  background: rgba(231, 76, 60, 0.18);
  color: #a02414;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(231, 76, 60, 0.55);
  cursor: help;
}
#summaryTable td.cell-off-soft {
  background: rgba(243, 156, 18, 0.18);
  color: #8a5300;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(243, 156, 18, 0.45);
  cursor: help;
}

/* ── Under-filled slot indicators ─────────────────────── */
/* By Shift view: striped background on under-filled cells. */
.schedule-grid td.shift-cell.under-fill {
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255, 180, 80, 0.18) 0,
    rgba(255, 180, 80, 0.18) 5px,
    rgba(255, 180, 80, 0.34) 5px,
    rgba(255, 180, 80, 0.34) 10px);
}
.under-fill-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  background: #fff7e6;
  border: 1px solid #fbbf24;
  border-radius: 4px;
  font-size: 10px;
  color: #92400E;
  font-weight: 700;
  vertical-align: middle;
}
.schedule-grid td.shift-cell.under-fill.empty-slot {
  /* Empty cells just show the count badge centered. */
  color: transparent;
  text-align: center;
}
/* By Doctor view: column-header marker when any slot on that date is short. */
.schedule-grid th.has-underfill {
  border-bottom: 2px solid #fbbf24;
}
.schedule-grid th.has-underfill .underfill-marker {
  display: inline-block;
  margin-left: 4px;
  color: #d97706;
  font-size: 10px;
  vertical-align: top;
}

/* ── Holiday columns ──────────────────────────────────── */
/* Light amber stripe to mark US federal holidays. Visual only —
   the solver does not treat these as time-off. */
.schedule-grid th.is-holiday,
.schedule-grid td.is-holiday {
  background:
    repeating-linear-gradient(
      135deg,
      rgba(252, 211, 77, 0.18) 0,
      rgba(252, 211, 77, 0.18) 4px,
      rgba(252, 211, 77, 0.32) 4px,
      rgba(252, 211, 77, 0.32) 8px);
}
.schedule-grid th.is-holiday {
  cursor: help;
}
.holiday-marker {
  display: inline-block;
  margin-left: 3px;
  color: #b7950b;
  font-size: 10px;
  vertical-align: top;
}

/* ── Per-doctor share view ────────────────────────────── */
.doctor-share-stats {
  display: flex;
  gap: 12px;
  margin: 0 0 16px 0;
  flex-wrap: wrap;
}
.stat-pill {
  padding: 8px 14px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
}
.stat-pill strong {
  font-size: 16px;
  margin-right: 4px;
}

.month-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.month-card h3 { margin: 0 0 12px 0; }

.month-calendar {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.month-calendar th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
}
.month-calendar td {
  vertical-align: top;
  border: 1px solid var(--border);
  height: 70px;
  padding: 4px 6px;
  position: relative;
}
.month-calendar td.empty-day {
  background: #fafafa;
  border-color: #f0f0f0;
}
.month-calendar td.cal-day.weekend {
  background: #f8fafc;
}
.month-calendar td.cal-day.out-of-range {
  background: #fafafa;
  color: #cbd5e1;
}
.month-calendar td.cal-day.working {
  background: rgba(80, 150, 255, 0.06);
}
.cal-day-num {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}
.cal-day-shift {
  margin-top: 4px;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

@media print {
  /* Hide chrome when printing the share view. */
  .sidebar { display: none !important; }
  .content { margin-left: 0 !important; padding: 12px !important; }
  .no-print { display: none !important; }
  .month-card { break-inside: avoid; box-shadow: none; }
  body { background: white; }
}

/* ── Inline-editable schedule name ────────────────────── */
h2[contenteditable="true"] {
  cursor: text;
  outline: none;
  padding: 2px 6px;
  margin-left: -6px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: border-color 120ms ease, background 120ms ease;
}
h2[contenteditable="true"]:hover {
  border-color: var(--border);
}
h2[contenteditable="true"]:focus {
  border-color: var(--primary);
  background: white;
}

.rename-hint {
  margin: 2px 0 0 0;
  font-style: italic;
  opacity: 0.7;
  transition: opacity 120ms ease;
}
h2[contenteditable="true"]:focus + .rename-hint {
  opacity: 1;
}

/* ── Manual Schedule Editing ──────────────────────────── */
.manual-edit-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: #f6f8fa;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.15);
  vertical-align: middle;
  margin-right: 4px;
}
.legend-swatch.sev-red    { background: #ffb3b3; border-color: #ff1f1f; }
.legend-swatch.sev-orange { background: #ffe2bd; border-color: #d35400; }
.legend-swatch.sev-yellow { background: #fff3a8; border-color: #b7950b; }

/* Severity outlines on shift blocks */
.schedule-cell.sev-red,
.shift-doc.sev-red {
  outline: 4px solid #ff1f1f;
  outline-offset: -4px;
  box-shadow: inset 0 0 0 9999px rgba(255,40,40,0.6),
              0 0 0 2px rgba(255,31,31,0.45);
}
.schedule-cell.sev-orange,
.shift-doc.sev-orange {
  outline: 4px solid #d35400;
  outline-offset: -4px;
  box-shadow: inset 0 0 0 9999px rgba(255,160,60,0.45),
              0 0 0 2px rgba(211,84,0,0.35);
}
.schedule-cell.sev-yellow,
.shift-doc.sev-yellow {
  outline: 4px solid #b7950b;
  outline-offset: -4px;
  box-shadow: inset 0 0 0 9999px rgba(255,220,40,0.45),
              0 0 0 2px rgba(183,149,11,0.35);
}

/* Manual mode cell affordances */
td.manual-cell {
  position: relative;
  cursor: pointer;
}
td.manual-cell:hover:not(:has([data-entry-id])) {
  background: rgba(80,150,255,0.08);
}
td.manual-cell.drag-over {
  background: rgba(80,150,255,0.25) !important;
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
}
.schedule-cell[draggable="true"],
.shift-doc[draggable="true"] {
  cursor: grab;
}
.schedule-cell[draggable="true"]:active,
.shift-doc[draggable="true"]:active {
  cursor: grabbing;
}

.cell-remove-btn {
  display: inline-block;
  margin-left: 4px;
  padding: 0 4px;
  font-size: 11px;
  line-height: 1.1;
  background: rgba(255,255,255,0.85);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 3px;
  cursor: pointer;
  color: #555;
}
.cell-remove-btn:hover {
  background: #c0392b;
  color: white;
  border-color: #c0392b;
}

.cell-lock-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
  transition: background 80ms ease, opacity 80ms ease,
              transform 80ms ease, border-color 80ms ease;
}
/* PINNED state: bright gold pill — pops out so locked entries are
   obvious at a glance. */
.cell-lock-btn.locked {
  width: 18px;
  height: 18px;
  font-size: 12px;
  background: #FFD43B;
  border: 1.5px solid #B8860B;
  color: #4a3500;
  opacity: 1;
  filter: none;
  box-shadow: 0 0 0 1px rgba(184, 134, 11, 0.25),
              0 1px 2px rgba(0, 0, 0, 0.15);
}
.cell-lock-btn.locked:hover {
  transform: scale(1.1);
  background: #FFE066;
}
/* UNLOCKED state: small dotted outline — recedes visually. Almost
   invisible until you hover, which surfaces it for clicking. */
.cell-lock-btn.unlocked {
  width: 14px;
  height: 14px;
  font-size: 10px;
  background: transparent;
  border: 1px dashed rgba(0, 0, 0, 0.3);
  color: rgba(0, 0, 0, 0.45);
  opacity: 0.55;
}
.cell-lock-btn.unlocked:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.85);
  border-style: solid;
  border-color: rgba(0, 0, 0, 0.5);
  transform: scale(1.15);
}
/* Visual cue: locked entries get a faint dashed outline so it's
   readable across all severity colors. */
.schedule-cell.is-locked,
.shift-doc.is-locked {
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.35);
}
/* Severity outlines win over the lock outline — re-apply them with the
   inset lock band stacked on top of the severity halo. */
.schedule-cell.sev-red.is-locked,
.shift-doc.sev-red.is-locked {
  box-shadow: inset 0 0 0 9999px rgba(255,40,40,0.6),
              inset 0 0 0 2px rgba(0,0,0,0.5),
              0 0 0 2px rgba(255,31,31,0.45);
}
.schedule-cell.sev-orange.is-locked,
.shift-doc.sev-orange.is-locked {
  box-shadow: inset 0 0 0 9999px rgba(255,160,60,0.45),
              inset 0 0 0 2px rgba(0,0,0,0.5),
              0 0 0 2px rgba(211,84,0,0.35);
}
.schedule-cell.sev-yellow.is-locked,
.shift-doc.sev-yellow.is-locked {
  box-shadow: inset 0 0 0 9999px rgba(255,220,40,0.45),
              inset 0 0 0 2px rgba(0,0,0,0.5),
              0 0 0 2px rgba(183,149,11,0.35);
}

/* Click-to-add inline picker */
.manual-add-menu {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  padding: 4px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 100px;
  max-height: 280px;
  overflow-y: auto;
}
.add-menu-btn {
  text-align: left;
  padding: 6px 10px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
.add-menu-btn:hover {
  background: #eef3fb;
}

/* ── Utilities ────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.items-center { align-items: center; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state p { margin-top: 8px; font-size: 14px; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-error {
  background: #FEF2F2;
  color: var(--danger);
  border: 1px solid #FECACA;
  text-align: left;
  line-height: 1.6;
}

.alert-success {
  background: #F0FDF4;
  color: var(--success);
  border: 1px solid #BBF7D0;
}

/* ── Import Page ─────────────────────────────────────── */
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.15s;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.change-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--surface);
}

.change-item code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
}

.remove-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  line-height: 1;
}

.remove-btn:hover { opacity: 0.7; }

.alert-warning {
  background: #FFFBEB;
  color: #92400E;
  border: 1px solid #FDE68A;
}

/* ── Priority Badges ──────────────────────────────────── */
.priority-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.priority-must_fill { background: #1F2937; color: #F9FAFB; }
.priority-high      { background: #FEE2E2; color: #991B1B; }
.priority-medium    { background: #FEF3C7; color: #92400E; }
.priority-low       { background: #E0E7FF; color: #3730A3; }

.priority-select {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  border: 1px solid transparent;
  cursor: pointer;
  appearance: auto;
}
.priority-select.priority-must_fill { background: #1F2937; color: #F9FAFB; border-color: #374151; }
.priority-select.priority-high      { background: #FEE2E2; color: #991B1B; border-color: #FECACA; }
.priority-select.priority-medium    { background: #FEF3C7; color: #92400E; border-color: #FDE68A; }
.priority-select.priority-low       { background: #E0E7FF; color: #3730A3; border-color: #C7D2FE; }

/* ── View Toggle ──────────────────────────────────────── */
.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.view-btn {
  padding: 4px 14px;
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.view-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}

.view-btn.active {
  background: var(--primary);
  color: white;
}

.view-btn:hover:not(.active) {
  background: var(--bg);
  color: var(--text);
}

/* ── Schedule By-Shift Grid ──────────────────────────── */
.schedule-grid-byshift td,
.schedule-grid-byshift th { font-size: 13px; }

.schedule-grid-byshift .shift-label {
  text-align: left;
  font-weight: 600;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 5;
  min-width: 120px;
  border-right: 2px solid var(--border);
  white-space: nowrap;
  /* No internal padding — the .shift-badge below fills edge-to-edge. */
  padding: 0;
}
/* Make the shift-type label fill the entire first-column cell so it reads
   as a strong row header, matching the visual weight of the doctor pills
   in the body cells. */
.schedule-grid-byshift .shift-label .shift-badge {
  display: block;
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-align: center;
  border-radius: 0;
}

.schedule-grid-byshift .shift-cell {
  vertical-align: top;
  font-size: 13px;
  line-height: 1.5;
  min-width: 58px;
  padding: 4px 4px;
}

.schedule-grid-byshift .shift-doc {
  display: block;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.3px;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 4px;
  margin: 2px 0;
}
.schedule-grid-byshift .shift-doc:first-child { margin-top: 0; }
.schedule-grid-byshift .shift-doc:last-child  { margin-bottom: 0; }

.schedule-grid-byshift .empty-slot {
  color: var(--text-muted);
  opacity: 0.4;
}

/* ── Target Shift Inputs ─────────────────────────────── */
/* ── Settings Page ────────────────────────────────────── */
.settings-grid {
  display: flex;
  flex-direction: column;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg);
}

.setting-item:last-child {
  border-bottom: none;
}

.setting-info {
  flex: 1;
  min-width: 0;
}

.setting-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.setting-input {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  margin-left: 24px;
  flex-shrink: 0;
}

.setting-input input {
  width: 80px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  text-align: center;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
}

.setting-input input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.setting-default {
  font-size: 11px;
}

/* ── Target Shift Inputs ─────────────────────────────── */
.target-total-input {
  width: 80px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  text-align: center;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
}

.target-total-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.target-total-input::placeholder {
  color: var(--text-muted);
}
