:root {
  color-scheme: light;
  --bg: #f2f4f7;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #667085;
  --line: #dde2ea;
  --brand: #155eef;
  --brand-dark: #004eeb;
  --warning: #b54708;
  --danger: #b42318;
  --success: #027a48;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(20px, 4vw, 64px);
  color: white;
  background: linear-gradient(118deg, #101828 0%, #1d2939 58%, #233b68 100%);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(24px, 3vw, 38px); }
h2 { margin-bottom: 0; font-size: 20px; }
.eyebrow { margin-bottom: 5px; color: #98a2b3; font-size: 12px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }

.identity, .filters, .week-navigation, .section-heading, .dialog-heading, .dialog-actions {
  display: flex;
  align-items: end;
  gap: 12px;
}

.identity label { color: #d0d5dd; }

main { padding: 24px clamp(16px, 4vw, 64px) 56px; }
.panel { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: 0 1px 3px rgba(16, 24, 40, .06); }
.toolbar { display: flex; justify-content: space-between; align-items: end; gap: 20px; padding: 16px; margin-bottom: 16px; }
.calendar-shell { overflow-x: auto; padding: 12px; }

label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cfd5df;
  border-radius: 9px;
  background: white;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(21, 94, 239, .12); }

.button, .icon-button {
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 700;
}
.button { min-height: 38px; padding: 9px 14px; }
.button.primary { color: white; background: var(--brand); }
.button.primary:hover { background: var(--brand-dark); }
.button.secondary { border: 1px solid #d0d5dd; background: white; color: #344054; }
.topbar .button.secondary { border-color: #475467; background: #344054; color: white; }
.icon-button { width: 38px; height: 38px; font-size: 24px; background: #eef2f6; color: #344054; }

.calendar { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); min-width: 1050px; gap: 8px; }
.day { min-height: 430px; border: 1px solid var(--line); border-radius: 12px; background: #fafbfc; overflow: hidden; }
.day.today { border-color: var(--brand); }
.day-heading { padding: 12px; border-bottom: 1px solid var(--line); background: white; }
.day-heading strong { display: block; }
.day-heading span { color: var(--muted); font-size: 12px; }
.day-body { display: grid; gap: 8px; padding: 8px; }
.empty-day { padding: 22px 8px; color: #98a2b3; font-size: 12px; text-align: center; }

.shift-card {
  width: 100%;
  border: 1px solid #b2ccff;
  border-left: 4px solid var(--brand);
  border-radius: 10px;
  background: #eff4ff;
  color: var(--ink);
  padding: 10px;
  text-align: left;
  cursor: pointer;
}
.shift-card.draft { border-color: #fedf89; border-left-color: #f79009; background: #fffaeb; }
.shift-card.cancelled { border-color: #fecdca; border-left-color: var(--danger); background: #fef3f2; opacity: .7; }
.shift-time { font-weight: 800; }
.shift-role { margin-top: 4px; color: #344054; font-size: 12px; text-transform: capitalize; }
.shift-staff { margin-top: 8px; color: #475467; font-size: 12px; }

.bottom-grid { display: grid; grid-template-columns: minmax(320px, .9fr) minmax(380px, 1.1fr); gap: 16px; margin-top: 16px; }
.bottom-grid .panel { padding: 18px; }
.section-heading { justify-content: space-between; margin-bottom: 16px; }
.section-heading.compact { align-items: center; margin-bottom: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.swap-list { display: grid; gap: 10px; }
.swap-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.swap-item strong { display: block; margin-bottom: 4px; }
.swap-meta { color: var(--muted); font-size: 12px; }
.status { display: inline-block; margin-top: 8px; border-radius: 999px; padding: 3px 8px; background: #eef2f6; font-size: 11px; font-weight: 800; }
.status.approved { color: var(--success); background: #ecfdf3; }
.status.pending-recipient, .status.pending-supervisor { color: var(--warning); background: #fffaeb; }
.status.rejected-recipient, .status.rejected-supervisor, .status.expired { color: var(--danger); background: #fef3f2; }

.notice { margin-bottom: 16px; border-radius: 10px; padding: 12px 14px; background: #ecfdf3; color: var(--success); font-weight: 650; }
.notice.error { background: #fef3f2; color: var(--danger); }

dialog { width: min(680px, calc(100vw - 30px)); max-height: calc(100vh - 30px); border: 0; border-radius: 16px; padding: 0; overflow-y: auto; box-shadow: 0 24px 48px rgba(16, 24, 40, .24); }
dialog::backdrop { background: rgba(16, 24, 40, .55); }
dialog form { padding: 22px; }
.staff-dialog { width: min(940px, calc(100vw - 30px)); }
.staff-dialog-content { padding: 22px; }
.staff-dialog form { padding: 0; }
.staff-manager-grid { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(380px, 1.2fr); gap: 22px; }
.staff-list { display: grid; gap: 8px; max-height: 520px; overflow-y: auto; }
.staff-row { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: white; padding: 11px; color: var(--ink); text-align: left; cursor: pointer; }
.staff-row:hover { border-color: #84adff; background: #f5f8ff; }
.staff-row.inactive { opacity: .6; }
.staff-row strong, .staff-row span { display: block; }
.staff-row span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.roles-fieldset { margin: 0; border: 1px solid #cfd5df; border-radius: 9px; padding: 10px; }
.roles-fieldset legend { padding: 0 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
.role-checkboxes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.weekday-checkboxes { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.role-checkboxes label, .weekday-checkboxes label, .checkbox-label { display: flex; align-items: center; gap: 8px; color: #344054; }
.role-checkboxes input, .weekday-checkboxes input, .checkbox-label input { width: auto; margin: 0; }
.staff-dialog h3 { margin: 0 0 16px; }
.recurring-dialog { width: min(760px, calc(100vw - 30px)); }
.recurring-dialog .dialog-heading { margin-bottom: 14px; }
.recurring-dialog .form-grid { gap: 10px 14px; }
.recurring-dialog .dialog-actions { margin-top: 12px; }
.recurring-preview { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; padding: 10px 12px; color: var(--muted); font-size: 12px; }
.recurring-preview.success { border-color: #abefc6; background: #ecfdf3; color: var(--success); }
.recurring-preview.error { border-color: #fecdca; background: #fef3f2; color: var(--danger); }
.preview-list { display: grid; gap: 5px; max-height: 180px; margin-top: 8px; overflow-y: auto; }
.preview-item { display: flex; justify-content: space-between; gap: 12px; }
.preview-item.conflict { color: var(--danger); font-weight: 700; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.dialog-heading { justify-content: space-between; align-items: start; margin-bottom: 20px; }
.dialog-actions { justify-content: flex-end; margin-top: 20px; }

@media (max-width: 900px) {
  .topbar, .toolbar { align-items: stretch; flex-direction: column; }
  .identity, .filters { align-items: stretch; flex-wrap: wrap; }
  .bottom-grid { grid-template-columns: 1fr; }
  .staff-manager-grid { grid-template-columns: 1fr; }
  .staff-list { max-height: 230px; }
  .weekday-checkboxes { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 560px) {
  .identity, .filters, .week-navigation { display: grid; grid-template-columns: 1fr 1fr; }
  .identity label, .filters label, .week-navigation h2 { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
}
