:root {
  --bg: #0b1220;
  --bg-alt: #111a2e;
  --surface: #18243b;
  --surface-muted: #21314f;
  --text: #e8edf6;
  --muted: #9bb0cc;
  --border: #2a3b5c;
  --primary: #1d9bf0;
  --primary-hover: #117ec7;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.26);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(circle at top right, #102347, var(--bg));
  color: var(--text);
}
h1, h2, h3 { margin: 0 0 0.7rem; }
p { color: var(--muted); }

header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  background: rgba(11, 18, 32, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.subtitle { margin: 0 0 0.8rem; }
nav { display: flex; flex-wrap: wrap; gap: 0.55rem; }
nav a {
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
}
nav a[aria-current='page'] {
  background: #15416e;
  border-color: #2c78bc;
}

main { max-width: 1250px; margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); }


.site-footnote {
  padding: 0 1rem 1.25rem;
  text-align: center;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: rgba(155, 176, 204, 0.72);
}

.card {
  background: linear-gradient(160deg, rgba(30, 45, 75, 0.95), rgba(24, 36, 59, 0.95));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: clamp(1rem, 2vw, 1.35rem);
  margin-bottom: 1rem;
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0.8rem; }
.inline-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.6rem; align-items: end; }
.inline-actions { display: grid; grid-template-columns: minmax(240px, 1fr) auto; gap: 0.6rem; align-items: center; }
.compact-form label { margin-bottom: 0.35rem; display: block; }

.specialty-row { display: grid; grid-template-columns: minmax(180px, 1.4fr) minmax(110px, .6fr) minmax(160px, 1fr) auto; gap: 0.5rem; align-items: center; margin: 0.45rem 0; }
.row-actions { display: flex; gap: 0.6rem; margin-top: 0.5rem; }
.row-actions button { width: auto; min-width: 160px; }

input, select, textarea, button {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: #101a2f;
  border: 1px solid #2e4469;
  border-radius: var(--radius-sm);
  padding: 0.62rem 0.68rem;
}
button {
  cursor: pointer;
  font-weight: 600;
  background: var(--primary);
  border-color: #229ae9;
}
button:hover { background: var(--primary-hover); }
button.secondary { background: #1f6feb; }
button.danger { background: #b2333b; border-color: #cf4d56; }
.button-row { display: flex; gap: 0.7rem; flex-wrap: wrap; }
.action-row { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: end; }
.action-row label { min-width: 160px; }
.action-row select { width: min(280px, 100%); }
.action-row button { width: auto; min-width: 130px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 540px; }
th, td { border-bottom: 1px solid var(--border); padding: 0.62rem 0.65rem; }
th { color: #bed1ea; font-size: 0.8rem; text-transform: uppercase; letter-spacing: .03em; background: var(--surface-muted); }

.rota-matrix th:first-child, .rota-matrix td:first-child { position: sticky; left: 0; background: #1c2a44; z-index: 1; }
.cell-button { padding: 0.48rem; border-radius: 8px; border: 1px solid transparent; }

.rota-cell-assigned { background: rgba(34, 197, 94, 0.16); color: #a6f4c5; }
.rota-cell-warning { background: rgba(245, 158, 11, 0.2); color: #ffd88d; }
.rota-cell-gap { background: rgba(239, 68, 68, 0.2); color: #ffb4b4; font-weight: 700; }

.legend-items { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.legend-item { display: inline-flex; gap: 0.45rem; align-items: center; }
.legend-swatch { width: 14px; height: 14px; border-radius: 4px; border: 1px solid #3c537b; display: inline-block; }

.warning { color: #ffd88d; }

.hint { color: var(--muted); font-size: 0.9rem; margin: 0.45rem 0 0; }

.status-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  text-transform: capitalize;
  font-size: 0.82rem;
}

.status-draft { background: rgba(245, 158, 11, 0.2); border-color: rgba(245, 158, 11, 0.5); }
.status-published { background: rgba(34, 197, 94, 0.18); border-color: rgba(34, 197, 94, 0.45); }

.error {
  color: #ffc2c2;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 0.7rem;
  border-radius: 8px;
}
.today { font-size: 1.2rem; font-weight: 700; color: #d6e7fd; }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.7rem; }
.metric { border: 1px solid var(--border); border-radius: 12px; background: #121f36; padding: 0.75rem; display: grid; gap: 0.2rem; }
.metric strong { font-size: 1.4rem; }
.metric span { color: var(--muted); font-size: 0.84rem; }
.metric.warn { border-color: rgba(245, 158, 11, 0.5); }
.metric.danger { border-color: rgba(239, 68, 68, 0.55); }


.table-actions {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
}

.compact-action {
  width: auto;
  min-width: 74px;
  padding: 0.42rem 0.55rem;
}

td > button,
td .table-actions button {
  width: auto;
  min-width: 74px;
  padding: 0.42rem 0.55rem;
}

td > button + button {
  margin-left: 0.45rem;
}

.warning-summary {
  margin: 0.2rem 0 0;
}

tr.row-warning td {
  background: rgba(245, 158, 11, 0.14);
}

.advanced-options-panel {
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(16, 26, 47, 0.55);
  padding: 0.85rem 1rem;
}

.advanced-options-panel summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
}

.advanced-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
  margin-top: 0.85rem;
}

.advanced-options-grid fieldset {
  margin: 0;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(24, 36, 59, 0.85);
}

.advanced-options-grid legend {
  padding: 0 0.35rem;
  font-weight: 700;
}

.segmented-control {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.segmented-control label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #2e4469;
  border-radius: 999px;
  padding: 0.38rem 0.65rem;
  background: #101a2f;
}

.segmented-control input {
  width: auto;
  margin: 0;
}

.schedule-view-tabs {
  margin-bottom: 0.85rem;
}

.view-tab {
  width: auto;
  min-width: 140px;
  background: #101a2f;
  border-color: #2e4469;
}

.view-tab.is-active {
  background: #1f6feb;
  border-color: #4a8ff0;
}

.generation-settings-list {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
}

@media (max-width: 800px) {
  table { min-width: 470px; }
  .inline-actions { grid-template-columns: 1fr; }
}

@media print {
  header, .no-print { display: none; }
  body { background: #fff; color: #000; }
  .card { background: #fff; border-color: #ddd; box-shadow: none; }
}


.cell-editor-popover {
  position: fixed;
  z-index: 30;
  width: min(320px, calc(100vw - 24px));
  background: linear-gradient(160deg, rgba(30, 45, 75, 0.98), rgba(24, 36, 59, 0.98));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 0.8rem;
}

.cell-editor-popover p {
  margin-top: 0;
}

.status-locked { background: rgba(148, 163, 184, 0.2); border-color: rgba(148, 163, 184, 0.45); }
.lab-big-text { font-size: 1.15rem; font-weight: 700; }

.lab-view-page {
  min-height: 100vh;
  background: #080d18;
}

.lab-view-main {
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2rem);
}

.lab-view-header {
  margin-bottom: 1rem;
}

.lab-view-header h1 {
  font-size: clamp(2rem, 6vw, 3rem);
  margin-bottom: 0.2rem;
}

.lab-view-date {
  font-size: clamp(1.3rem, 3.2vw, 1.7rem);
  color: #d9e7ff;
  margin: 0.15rem 0;
}

.lab-view-subtitle {
  font-size: 1rem;
  margin: 0;
}

.lab-view-card h2 {
  font-size: 1.05rem;
}

.lab-view-table {
  min-width: 0;
}

.lab-view-table th {
  font-size: 0.95rem;
}

.lab-view-table td {
  font-size: clamp(1.15rem, 2.9vw, 1.6rem);
  padding-top: 1rem;
  padding-bottom: 1rem;
  vertical-align: top;
}

.lab-specialty {
  font-weight: 700;
  width: 38%;
}

.lab-consultant {
  font-size: clamp(1.3rem, 3.3vw, 1.8rem);
  font-weight: 800;
}

.lab-trainee {
  margin-top: 0.35rem;
  font-size: clamp(0.95rem, 2.2vw, 1.1rem);
  font-weight: 600;
  width: fit-content;
  padding: 0.2rem 0.45rem;
  border-radius: 8px;
}

.lab-status-assigned {
  color: #a6f4c5;
}

.lab-status-trainee {
  color: #c7d8ff;
  background: rgba(96, 165, 250, 0.15);
}

.lab-status-gap {
  color: #ff9a9a;
  font-weight: 800;
}

.subsection { margin-top: 1rem; }
.slot-group { border: 1px solid var(--border); border-radius: var(--radius-md); background: rgba(16, 26, 47, 0.55); padding: 0.9rem; margin-top: 0.8rem; }
.slot-group-header { display: flex; justify-content: space-between; gap: 0.8rem; align-items: start; margin-bottom: 0.8rem; }
.slot-group-header p { margin: 0.2rem 0 0; }
.slot-form-host { margin-top: 0.8rem; }
.slot-form { border-top: 1px solid var(--border); padding-top: 0.8rem; }
.slot-meta { color: var(--muted); font-size: 0.82rem; margin-top: 0.2rem; }

.specialty-admin-card {
  display: grid;
  gap: 0.9rem;
}

.specialty-admin-card--compact {
  gap: 0.75rem;
}

.specialty-card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: start;
}

.specialty-header-row {
  align-items: center;
  margin-bottom: 0;
}

.specialty-summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
}

.specialty-header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

.specialty-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.specialty-summary-grid > div {
  display: grid;
  gap: 0.18rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(16, 26, 47, 0.65);
}

.specialty-summary-grid strong {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.specialty-summary-grid span {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.specialty-summary-grid--compact {
  grid-template-columns: minmax(180px, 1.2fr) repeat(2, minmax(150px, 1fr));
}

.specialty-summary-grid--tight {
  grid-template-columns: repeat(3, minmax(96px, 112px));
  gap: 0.45rem;
}

.specialty-summary-grid--tight > div {
  padding: 0.6rem 0.7rem;
}

.specialty-summary-grid--tight strong {
  font-size: 0.72rem;
}

.specialty-summary-grid--tight span {
  font-size: 1.05rem;
}

.specialty-card-actions {
  display: flex;
  justify-content: flex-start;
}

.specialty-editor-form {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
}

.specialty-editor-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) repeat(3, minmax(150px, 1fr));
  gap: 0.8rem;
  align-items: end;
}

.specialty-editor-name {
  min-width: 0;
}

.slot-section {
  display: grid;
  gap: 0.45rem;
  margin-top: -0.1rem;
  padding-left: 1rem;
  border-left: 2px solid rgba(42, 59, 92, 0.85);
}

.slot-group-header--compact {
  margin-bottom: 0.2rem;
}

.slot-group-header--compact p {
  margin-bottom: 0;
}

.slot-list-header h3 {
  margin-bottom: 0;
}

.slot-list {
  display: grid;
  gap: 0.45rem;
}

.slot-list-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(16, 26, 47, 0.45);
}

.slot-list-row--minimal {
  grid-template-columns: auto auto;
  justify-content: space-between;
  padding: 0.55rem 0.7rem;
}

.slot-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  font-size: 0.82rem;
  color: #bed1ea;
  background: rgba(33, 49, 79, 0.8);
}

.slot-empty-state {
  margin: 0;
  font-size: 0.9rem;
}

.slot-list-name {
  font-weight: 600;
}

@media (max-width: 800px) {
  .specialty-card-top,
  .specialty-header-row {
    flex-direction: column;
  }

  .specialty-summary-row {
    grid-template-columns: 1fr;
  }

  .specialty-header-actions {
    justify-content: flex-start;
  }

  .specialty-editor-grid,
  .specialty-summary-grid--compact,
  .specialty-summary-grid--tight,
  .slot-list-row {
    grid-template-columns: 1fr;
  }
}

.rota-table-wrap {
  overflow-x: auto;
}

.sticky-scrollbar {
  position: sticky;
  top: calc(4.75rem + 1px);
  z-index: 10;
  overflow-x: auto;
  overflow-y: hidden;
  height: 18px;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(16, 26, 47, 0.9);
}

.sticky-scrollbar > div {
  height: 1px;
}

.workload-panel {
  margin-top: 1rem;
  display: grid;
  gap: 0.75rem;
}

.workload-panel-header h3 {
  margin-bottom: 0.25rem;
}

.workload-table {
  min-width: 520px;
}

.workload-variance-over {
  color: #ffd88d;
  font-weight: 700;
}

.workload-variance-under {
  color: #a6f4c5;
  font-weight: 700;
}

.lab-day-grid,
.print-day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.print-day-table {
  min-width: 0;
}
