:root {
  color-scheme: light;
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --ink: #0f172a;
  --ink-secondary: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-glass: rgba(255, 255, 255, 0.92);

  --teal: #0d9488;
  --teal-dark: #0f766e;
  --teal-soft: #ccfbf1;
  --primary-gradient: linear-gradient(135deg, #0d9488 0%, #047857 100%);

  --blue: #2563eb;
  --green: #10b981;
  --green-soft: #ecfdf5;
  --green-text: #047857;
  --amber: #f59e0b;
  --amber-soft: #fffbeb;
  --amber-text: #b45309;
  --red: #ef4444;
  --red-soft: #fef2f2;
  --red-text: #b91c1c;
  --purple: #7c3aed;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow: 0 10px 28px -4px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 40px -8px rgba(15, 23, 42, 0.16);
  --transition:
    color 0.18s ease,
    background-color 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 0;
  color: var(--ink);
  background: radial-gradient(circle at 50% 0%, #f0fdfa 0%, #f8fafc 45%, #e2e8f0 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button {
  cursor: pointer;
  transition: var(--transition);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

:where(button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid rgba(13, 148, 136, 0.28);
  outline-offset: 2px;
}

.app-shell {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 10px 14px 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 18px;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.topbar h1,
.section-heading h2 {
  margin: 0;
  font-family: Outfit, Inter, sans-serif;
  letter-spacing: -0.01em;
}

.topbar h1 {
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.25;
  background: linear-gradient(135deg, #0f172a 0%, #0d9488 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.main-layout {
  display: block;
}

.workspace,
.side-rail {
  min-width: 0;
}

.app-loading-status {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  background: #f0f9ff;
  color: #0c4a6e;
  font-size: 0.82rem;
  font-weight: 800;
}

.app-loading-status[hidden] {
  display: none;
}

.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #bae6fd;
  border-top-color: #0369a1;
  border-radius: 50%;
  animation: loading-spin 0.75s linear infinite;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.filters,
.panel,
.quick-booking,
.today-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.filters {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(150px, 0.8fr) minmax(220px, 1.2fr) auto;
  gap: 12px;
  align-items: end;
  padding: 12px 16px;
  margin-bottom: 12px;
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
}

label {
  display: grid;
  gap: 6px;
  color: var(--ink-secondary);
  font-size: 0.78rem;
  font-weight: 700;
}
.filter-field {
  display: grid;
  gap: 6px;
  color: var(--ink-secondary);
  font-size: 0.78rem;
  font-weight: 700;
}

.month-field {
  position: relative;
}

.month-field select {
  font-weight: 800;
}

.month-field option.month-option-booking-window {
  background: #f0fdfa;
  color: #0f766e;
  font-weight: 800;
}

.month-switcher {
  display: none;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  gap: 6px;
}

.month-step-button,
.month-current-button,
.month-option {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  transition: var(--transition);
}

.month-step-button {
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
}

.month-step-button:hover:not(:disabled) {
  border-color: var(--teal);
  color: var(--teal);
}

.month-step-button:disabled {
  opacity: 0.4;
}

.month-current-button {
  overflow: hidden;
  padding: 6px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.month-picker-menu {
  position: absolute;
  z-index: 40;
  top: 100%;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  max-height: 236px;
  overflow: auto;
  margin-top: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.month-picker-menu[hidden] {
  display: none;
}

.branch-switcher {
  display: none;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

.branch-option {
  min-width: 0;
  min-height: 36px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 5px 4px;
  font-size: 0.64rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: var(--transition);
}

.branch-option.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.month-option {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 7px 5px;
  text-align: center;
}

.month-option.month-option-booking-window {
  border-color: #9ed7ce;
  background: #f0fdfa;
  color: #0f766e;
}

.month-option span {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
}

.month-option.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

input,
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 6px 11px;
  outline: none;
  font-size: 0.88rem;
  transition: var(--transition);
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.16);
}

.toggle-row {
  display: flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  white-space: nowrap;
}

.toggle-row input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--teal);
}

.primary-button,
.secondary-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
  min-height: 38px;
}

.add-locum-form textarea {
  font-family: inherit;
  font-size: 14px;
  line-height: 1.35;
}

.primary-button {
  background: var(--primary-gradient);
  color: #fff;
  padding: 8px 16px;
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.25);
}

.primary-button:hover {
  opacity: 0.94;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35);
}

.secondary-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
  padding: 8px 14px;
}

.secondary-button:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
  background: var(--surface-soft);
}

.topbar-symbol-button {
  display: inline-grid;
  width: 40px;
  min-width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  font-size: 1.18rem;
  font-weight: 900;
  line-height: 1;
  border-radius: 10px;
}

.topbar-symbol-button span {
  display: block;
  min-width: 1.15em;
  text-align: center;
}

.app-icon {
  display: block;
  width: 22px;
  height: 22px;
  color: var(--ink-secondary);
  transition: var(--transition);
}

.topbar-symbol-button:hover .app-icon {
  color: var(--teal);
}

.app-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
  stroke: currentColor;
}

.topbar-symbol-button.primary-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.topbar-symbol-button.primary-button:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.topbar-symbol-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.read-only-user #addMonthButton,
.read-only-user #deleteMonthButton,
.read-only-user #whatsAppPasteButton,
.read-only-user .quick-booking,
.read-only-user #addDirectoryLocumButton,
.read-only-user #saveNewDirectoryLocumButton,
.read-only-user #cancelNewDirectoryLocumButton,
.read-only-user [data-dir-edit],
.read-only-user [data-dir-save],
.read-only-user [data-dir-cancel],
.read-only-user [data-dir-remove],
.read-only-user [data-paid-id],
.read-only-user #markPaidThroughApr2026Button {
  display: none !important;
}

.read-only-user .cell-input,
.read-only-user .vacancy-button,
.read-only-user .note-input,
.read-only-user .rate-input {
  cursor: default;
}

#addMonthButton .app-icon {
  width: 26px;
  height: 26px;
}

#whatsAppPasteButton .app-icon {
  width: 24px;
  height: 24px;
}

#printButton .app-icon,
#logoutButton .app-icon {
  width: 24px;
  height: 24px;
}

#exportButton .app-icon {
  width: 24px;
  height: 24px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.kpi-card {
  min-height: 52px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  padding: 6px 10px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.kpi-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.kpi-card.gap {
  border-left-color: var(--red);
}

.kpi-card.covered {
  border-left-color: var(--green);
}

.kpi-card.money {
  border-left-color: var(--purple);
}

.kpi-label {
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.kpi-value {
  margin-top: 2px;
  font-family: Outfit, Inter, sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink);
}

.kpi-note {
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.72rem;
}

.branch-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.branch-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  box-shadow: var(--shadow-sm);
}

.branch-card strong {
  display: block;
  margin-bottom: 3px;
  font-size: 0.82rem;
}

.coverage-bar {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line-soft);
}

.coverage-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--teal));
}

.branch-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
}

.opening-line {
  display: grid;
  gap: 1px;
  margin-bottom: 5px;
  color: var(--ink-secondary);
  font-size: 0.72rem;
  line-height: 1.2;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 10px;
  padding: 4px;
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.tab-button {
  flex: 1 1 120px;
  min-height: 36px;
  padding: 5px 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
  transition: var(--transition);
}

.tab-button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.6);
}

.tab-symbol-button {
  display: inline-grid;
  flex-basis: 0;
  place-items: center;
  padding-right: 8px;
  padding-left: 8px;
  font-size: 1.02rem;
  line-height: 1;
}

.tab-symbol-button span {
  display: block;
  min-width: 1.35em;
  text-align: center;
}

.tab-symbol-button .app-icon {
  width: 22px;
  height: 22px;
  margin: 0 auto;
}

.tab-symbol-button[data-tab="payments"] .app-icon,
.tab-symbol-button[data-tab="share"] .app-icon {
  width: 24px;
  height: 24px;
}

.tab-button.active {
  border-color: var(--teal);
  background: #ffffff;
  color: var(--teal-dark);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

.panel {
  padding: 14px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.08rem;
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.table-scroll {
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
}

th,
td {
  border-bottom: 2px solid #dfe5ec;
  padding: 9px 8px;
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef4f7;
  color: #344054;
  font-size: 0.76rem;
  text-transform: uppercase;
}

.cell-input:disabled {
  cursor: not-allowed;
  opacity: 1;
}

.cell-input[draggable="true"] {
  cursor: grab;
}

.cell-input.dragging-cell {
  cursor: grabbing;
  opacity: 0.62;
}

#rotaPanel td.drop-target {
  background: #eaf3ff !important;
  outline: 3px solid #2f6fed;
  outline-offset: -3px;
}

#rotaPanel td.drop-target .cell-input,
#rotaPanel td.drop-target .vacancy-button {
  border-color: #2f6fed;
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.18);
}

.status-assigned .cell-input {
  border-color: #acd6be;
  background: #f0fbf4;
}

.status-assigned.paid-shift .cell-input,
.status-tentative.paid-shift .cell-input {
  border-color: #15803d;
  background: #d6f5de;
  color: #064e3b;
  font-weight: 850;
  box-shadow: inset 0 0 0 2px rgba(21, 128, 61, 0.18);
}

.status-needs-locum .cell-input {
  border-color: #f3b2ab;
  background: #fff4f2;
}

.vacancy-button {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 38px;
  border: 2px solid #f09b92;
  border-radius: 6px;
  background: #fff4f2;
  color: #b42318;
  font-size: 1.55rem;
  line-height: 1;
  font-weight: 950;
}

.vacancy-button:hover,
.vacancy-button:focus {
  background: #ffe8e4;
  border-color: #d92d20;
  box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.14);
}

.status-tentative .cell-input {
  border-color: #dfbd67;
  background: #fff8e6;
}

.status-closed .cell-input {
  border-color: #d4d8df;
  background: #f3f5f7;
  color: transparent;
}

.drag-preview {
  position: fixed;
  top: -1000px;
  left: -1000px;
  z-index: 10000;
  border: 2px solid #2f6fed;
  border-radius: 6px;
  background: #eaf3ff;
  color: #173b8f;
  padding: 8px 12px;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
  pointer-events: none;
}

.note-cell {
  color: #4b5563;
  font-size: 0.86rem;
}

.note-input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  border: 1px solid #c8d0da;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 7px 9px;
  font-size: 0.86rem;
}

.note-input::placeholder {
  color: #98a2b3;
}

.locum-grid,
.pharmacist-grid,
.pay-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
}

.pay-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 18px;
}

.pay-table {
  table-layout: fixed;
  font-size: 0.76rem;
}

.directory-table {
  min-width: 1100px;
  border-collapse: separate;
  border-spacing: 0;
}

.directory-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: -2px 0 10px;
}

.directory-search {
  width: min(100%, 360px);
}

.directory-add-card {
  display: grid;
  grid-template-columns: minmax(150px, 0.55fr) minmax(0, 1.7fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  border: 1px solid #c8d0da;
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.directory-add-card > div:first-child {
  display: grid;
  gap: 3px;
}

.directory-add-card > div:first-child span {
  color: var(--muted);
  font-size: 0.78rem;
}

.directory-add-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
}

.payment-run-table {
  width: 100%;
  min-width: 100%;
}

.dir-input,
.dir-edit-input {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid #d7dde6;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
}

.dir-rate,
.dir-break,
.dir-edit-input[data-dir-field="payRate"],
.dir-edit-input[data-dir-field="unpaidBreakMinutes"] {
  text-align: right;
}

.pay-table th,
.pay-table td {
  white-space: normal;
  line-height: 1.25;
  padding: 7px 5px;
}

.pay-table th {
  overflow-wrap: normal;
  word-break: normal;
}

.pay-table td {
  overflow-wrap: normal;
}

.payment-run-table th:nth-child(1),
.payment-run-table td:nth-child(1) {
  width: 4%;
}

.payment-run-table th:nth-child(2),
.payment-run-table td:nth-child(2) {
  width: 11%;
}

.payment-run-table th:nth-child(3),
.payment-run-table td:nth-child(3) {
  width: 16%;
}

.payment-run-table th:nth-child(4),
.payment-run-table td:nth-child(4) {
  width: 12%;
}

.payment-run-table th:nth-child(5),
.payment-run-table td:nth-child(5) {
  width: 8%;
}

.payment-run-table th:nth-child(6),
.payment-run-table td:nth-child(6) {
  width: 9%;
}

.payment-run-table th:nth-child(7),
.payment-run-table td:nth-child(7) {
  width: 14%;
}

.payment-run-table th:nth-child(8),
.payment-run-table td:nth-child(8) {
  width: 5%;
}

.payment-run-table th:nth-child(9),
.payment-run-table td:nth-child(9) {
  width: 7%;
}

.payment-run-table th:nth-child(10),
.payment-run-table td:nth-child(10) {
  width: 6%;
}

.payment-run-table th:nth-child(11),
.payment-run-table td:nth-child(11) {
  width: 9%;
}

.payment-run-table th:nth-child(12),
.payment-run-table td:nth-child(12) {
  width: 6%;
}

.directory-table th:nth-child(1),
.directory-table td:nth-child(1) {
  width: 52px;
  text-align: center;
}

.directory-table th:nth-child(2),
.directory-table td:nth-child(2) {
  width: 130px;
}

.directory-table th:nth-child(3),
.directory-table td:nth-child(3) {
  width: 118px;
}

.directory-table th:nth-child(4),
.directory-table td:nth-child(4) {
  width: 180px;
}

.directory-table th:nth-child(5),
.directory-table td:nth-child(5) {
  width: 160px;
}

.directory-table th:nth-child(6),
.directory-table td:nth-child(6) {
  width: 105px;
}

.directory-table th:nth-child(7),
.directory-table td:nth-child(7) {
  width: 118px;
}

.directory-table th:nth-child(8),
.directory-table td:nth-child(8),
.directory-table th:nth-child(9),
.directory-table td:nth-child(9) {
  width: 82px;
}

.directory-table th:nth-child(10),
.directory-table td:nth-child(10) {
  width: 170px;
}

.directory-row td {
  vertical-align: middle;
}

.directory-row.favourite td {
  background: #fbfbfb;
}

.directory-row.editing td {
  background: #f8fafc;
}

.directory-favourite {
  display: inline-grid;
  width: 34px;
  min-height: 34px;
  place-items: center;
  border: 1px solid #c8d0da;
  border-radius: 6px;
  background: #fff;
  color: #111827;
  font-size: 1.08rem;
  font-weight: 900;
}

.directory-favourite.active {
  border-color: #111827;
  background: #111827;
  color: #fff;
}

.muted-cell {
  color: #98a2b3;
}

.dir-edit-field {
  gap: 3px;
  margin: 0;
}

.dir-edit-field span {
  display: none;
}

.directory-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.directory-actions button {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 0.72rem;
}

.secondary-button.danger {
  border-color: #d0d5dd;
  color: #344054;
}

.pay-table .pay-section-row th {
  background: #e7e2ef;
  color: #111827;
  font-size: 1rem;
  text-align: center;
}

.pay-table .pay-section-row.info th {
  background: #eeeeee;
}

.pay-table tfoot th,
.pay-table tfoot td {
  background: #a7a7a7;
  color: #111827;
  font-weight: 900;
}

.pay-row-paid td {
  background: #ecfdf3;
}

.paid-button {
  width: 100%;
  min-height: 30px;
  border: 1px solid #98a2b3;
  border-radius: 6px;
  background: #fff;
  color: #344054;
  font-size: 0.72rem;
  font-weight: 900;
}

.paid-button.active {
  border-color: #15803d;
  background: #15803d;
  color: #fff;
}

.number-cell,
.money-cell {
  text-align: right;
}

.money-cell {
  font-weight: 900;
}

.rate-input {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 5px;
  text-align: right;
}

.directory-heading {
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding-top: 16px;
}

.share-actions {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.share-preview-wrap {
  overflow: auto;
}

.share-rota-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
  font-family: Arial, sans-serif;
  font-size: 0.82rem;
}

.share-rota-table th,
.share-rota-table td {
  height: 30px;
  border: 1px solid #9b9b9b;
  padding: 5px 7px;
  text-align: left;
  vertical-align: middle;
}

.share-rota-table thead th,
.share-rota-table tbody th {
  background: #d9d9d9;
  color: #000;
  font-weight: 900;
}

.share-rota-table .share-off-row th,
.share-rota-table .share-off-row td {
  background: #ffff00;
}

.share-rota-table td.share-booked {
  background: #0f766e;
  color: #fff;
  font-weight: 800;
}

.share-rota-table td.share-vacant {
  background: #fff4f2;
  color: #b42318;
  font-weight: 800;
}

.share-rota-table td.share-tentative {
  background: #fff7cc;
  color: #7a4a00;
  font-weight: 800;
}

.locum-card,
.pharmacist-card,
.pay-card,
.gap-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.locum-card {
  border-left: 5px solid var(--red);
}

.locum-card.tentative {
  border-left-color: var(--amber);
}

.locum-card h3,
.pharmacist-card h3,
.pay-card h3 {
  margin: 0 0 6px;
  font-size: 0.98rem;
}

.meta-line {
  color: var(--muted);
  font-size: 0.82rem;
}

.fill-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: start center;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow: auto;
  padding: 24px 18px;
}

.modal-backdrop[hidden] {
  display: none;
}

.locum-picker-modal {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: min(980px, 100%);
  margin: 0;
  font-size: 1.1rem;
}

.modal-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.add-locum-form {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(140px, 0.75fr) minmax(96px, 0.45fr) minmax(128px, 0.55fr) auto;
  gap: 8px;
  align-items: end;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
}

.ai-command-modal {
  grid-template-rows: auto auto auto minmax(0, 1fr);
  width: min(840px, 100%);
}

.password-reset-modal {
  grid-template-rows: auto auto;
  width: min(440px, 100%);
}

#userSettingsButton[hidden] {
  display: none;
}

.user-settings-modal {
  grid-template-rows: auto minmax(0, 1fr);
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.user-settings-modal > .modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.user-settings-modal h2 {
  margin: 0;
  font-size: 1.2rem;
}

.user-settings-body {
  display: grid;
  gap: 12px;
  overflow: auto;
  padding: 16px 18px 18px;
  background: #f8fafc;
}

.user-settings-actions {
  display: flex;
  justify-content: flex-end;
}

.user-add-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(180px, 1fr) 120px auto;
  gap: 10px;
  align-items: end;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.user-add-form label,
.managed-password-reset-form label {
  display: grid;
  gap: 6px;
  color: var(--ink-secondary);
  font-size: 0.78rem;
  font-weight: 800;
}

.user-add-form input,
.user-add-form select,
.managed-password-reset-form input,
.user-settings-row select {
  min-height: 38px;
}

.user-settings-list {
  display: grid;
  gap: 8px;
}

.user-settings-empty {
  margin: 0;
  padding: 14px;
  color: var(--muted);
  text-align: center;
}

.user-settings-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 120px auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.user-settings-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
}

.user-settings-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}

.user-settings-row-actions button {
  min-height: 36px;
  padding: 7px 10px;
  white-space: nowrap;
}

.user-settings-row .danger-button:not(:disabled) {
  color: #991b1b;
  border-color: #fca5a5;
  background: #fef2f2;
}

.managed-password-reset-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
}

.managed-password-reset-form[hidden] {
  display: none;
}

.managed-password-reset-form strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.managed-password-reset-form p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.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;
}

.change-log-modal {
  grid-template-rows: auto minmax(0, 1fr);
  width: min(720px, 100%);
}

.change-log-filter-bar {
  display: flex;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.change-log-filter-bar input,
.change-log-filter-bar select {
  min-height: 36px;
  border: 1px solid #c8d0da;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.85rem;
}

.change-log-filter-bar input {
  flex: 1;
}

.danger-button {
  border-color: #fca5a5 !important;
  background: #fef2f2 !important;
  color: #991b1b !important;
}

.danger-button:hover {
  background: #fee2e2 !important;
}

.conflict-modal {
  width: min(480px, 100%);
  padding: 18px;
}

.conflict-modal #conflictTitle {
  color: #991b1b;
}

.conflict-body {
  display: grid;
  gap: 10px;
  padding: 1rem 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.conflict-body p {
  margin: 0;
}

.conflict-warning {
  border-left: 4px solid #f59e0b;
  background: #fffbeb;
  color: #854d0e;
  padding: 10px 12px;
  border-radius: 6px;
}

.change-log-content {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding: 14px 18px 18px;
  background: #f8fafc;
}

.change-log-row {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.change-log-row strong,
.change-log-row span,
.change-log-row p {
  min-width: 0;
}

.change-log-row strong {
  display: block;
  color: var(--ink);
  font-size: 0.96rem;
}

.change-log-row span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.change-log-row p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.change-log-row .change-log-pill {
  display: inline-flex;
  width: max-content;
  padding: 4px 8px;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  color: #065f46;
  background: #ecfdf5;
}

.password-reset-form {
  display: grid;
  gap: 12px;
  padding: 16px 18px 18px;
  background: #f8fafc;
}

.password-reset-form label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 850;
}

.password-reset-form input {
  min-height: 38px;
}

.password-reset-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.password-reset-message[data-type="error"] {
  color: #b42318;
}

.password-reset-message[data-type="success"] {
  color: #15803d;
}

.password-reset-actions {
  display: flex;
  justify-content: end;
  gap: 8px;
}

.ai-command-form {
  display: grid;
  grid-template-columns: minmax(190px, 0.42fr) minmax(320px, 1fr);
  gap: 12px;
  align-items: start;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.ai-command-form label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 850;
}

.ai-command-form input,
.ai-command-form textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #d7dde6;
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  background: #fff;
}

.ai-command-form textarea {
  min-height: 144px;
  resize: vertical;
  line-height: 1.4;
}

.ai-message-field {
  grid-row: span 2;
}

.ai-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  grid-column: 1 / -1;
  padding-top: 2px;
}

.ai-action-row button {
  min-width: 132px;
}

.ai-result-panel {
  min-height: 54px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  color: #334155;
  font-size: 0.86rem;
  line-height: 1.35;
  background: #fff;
}

.ai-result-panel strong {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
}

.ai-result-panel ul {
  margin: 8px 0 0 18px;
  padding: 0;
}

.picker-search {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.locum-picker-list {
  display: grid;
  gap: 7px;
  overflow: auto;
  padding: 12px 18px 18px;
}

.picker-current-shift {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid #d7dee8;
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
}

.picker-current-shift span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.picker-current-shift strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 1rem;
}

.picker-row {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 8px;
  align-items: stretch;
}

.favourite-toggle,
.picker-locum-button {
  border: 1px solid #c8d0da;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.favourite-toggle {
  min-height: 42px;
  color: var(--amber);
  font-size: 1.1rem;
  font-weight: 950;
}

.picker-row.favourite .favourite-toggle {
  background: #fff7e6;
  border-color: #e2aa45;
}

.picker-row.disabled .picker-locum-button {
  cursor: not-allowed;
  background: #f1f5f9;
  border-color: #d7dee8;
  color: #64748b;
}

.picker-row.disabled .picker-locum-button span {
  color: #b42318;
}

.picker-locum-button {
  display: grid;
  gap: 2px;
  min-height: 42px;
  padding: 7px 10px;
  text-align: left;
}

.picker-locum-button:hover,
.picker-locum-button:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.picker-locum-button span {
  color: var(--muted);
  font-size: 0.78rem;
}

.empty-state.compact {
  min-height: 94px;
}

.fill-row input {
  min-height: 36px;
}

.fill-row button {
  min-height: 36px;
  white-space: nowrap;
}

.pharmacist-card {
  display: grid;
  gap: 8px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.stat-row strong {
  color: var(--ink);
}

.branch-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #edf2f7;
  color: #344054;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 750;
}

.side-rail {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  align-items: start;
  gap: 10px;
  margin-top: 8px;
}

.side-rail[hidden] {
  display: none;
}

.quick-booking,
.today-list {
  padding: 12px;
}

.today-list .empty-state {
  min-height: 104px;
  padding: 14px;
}

.section-heading {
  margin-bottom: 12px;
}

.section-heading h2 {
  font-size: 1.02rem;
}

#bookingForm {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(120px, 0.7fr) minmax(180px, 1.35fr) max-content;
  gap: 8px;
  align-items: end;
}

.booking-date-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.booking-date-field legend {
  margin-bottom: 6px;
  color: #344054;
  font-size: 0.78rem;
  font-weight: 700;
}

.quick-dropdown {
  position: relative;
  min-width: 0;
}

.dropdown-button {
  position: relative;
  width: 100%;
  min-height: 34px;
  overflow: hidden;
  border: 1px solid #c8d0da;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 6px 30px 6px 9px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-button::after {
  content: "";
  position: absolute;
  right: 11px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid #667085;
  border-bottom: 2px solid #667085;
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

.dropdown-button:focus,
.dropdown-button:hover {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.quick-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  width: min(360px, 82vw);
  max-height: 360px;
  overflow: auto;
  border: 1px solid #c8d0da;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(17, 24, 39, 0.16);
  padding: 8px;
}

.quick-locum-menu {
  width: min(430px, 86vw);
}

.quick-locum-menu input {
  margin-bottom: 8px;
}

.booking-date-list {
  display: grid;
  gap: 6px;
}

.booking-date-option {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  min-height: 36px;
  overflow: hidden;
  border: 1px solid #c8d0da;
  border-radius: 6px;
  background: #fff;
}

.booking-date-option.selected {
  border-color: var(--teal);
  background: #ecfdf7;
}

.booking-date-option input {
  width: 16px;
  min-height: 16px;
  margin: 0 0 0 7px;
  padding: 0;
}

.booking-date-option button {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 5px 9px 5px 5px;
  font-size: 0.78rem;
  font-weight: 750;
  text-align: left;
  white-space: nowrap;
}

.booking-date-option button:hover,
.booking-date-option button:focus {
  color: var(--teal);
}

.booking-date-empty {
  display: grid;
  place-items: center;
  min-height: 36px;
  border: 1px dashed #c8d0da;
  border-radius: 6px;
  color: var(--muted);
  padding: 0 12px;
  font-size: 0.78rem;
}

.quick-locum-list {
  display: grid;
  gap: 7px;
}

.gap-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.gap-item {
  background: #fff8f6;
  flex: 0 0 210px;
}

.gap-item strong {
  display: block;
  margin-bottom: 5px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 180px;
  border: 1px dashed #c8d0da;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.empty-state strong {
  color: var(--ink);
}

@media (max-width: 1180px) {
  #bookingForm {
    grid-template-columns: minmax(118px, 0.75fr) minmax(118px, 0.7fr) minmax(170px, 1.25fr) max-content;
  }
}

@media (max-width: 880px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .filters,
  .kpi-grid,
  .branch-strip,
  .locum-grid,
  .pharmacist-grid,
  .pay-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .month-field,
  .branch-field {
    grid-column: 1 / -1;
  }

  .search-label {
    grid-column: 1;
  }

  .toggle-row {
    grid-column: 2;
    align-self: end;
  }

  .side-rail {
    grid-template-columns: minmax(0, 1fr);
  }

  .side-rail {
    margin-top: 8px;
  }

  .panel-header,
  .fill-row {
    flex-direction: column;
  }

  #bookingForm {
    grid-template-columns: 1fr;
  }

  .add-locum-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .add-locum-form label:first-child,
  .add-locum-form label:nth-child(2) {
    grid-column: 1 / -1;
  }

  .ai-command-form {
    grid-template-columns: 1fr;
  }

  .ai-message-field {
    grid-row: auto;
  }

  .share-actions {
    grid-template-columns: 1fr;
  }

  .share-actions .primary-button {
    width: 100%;
  }

  .directory-add-card {
    grid-template-columns: 1fr;
  }

  .directory-add-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .add-locum-form .primary-button {
    grid-column: 1 / -1;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(38px, 1fr));
    gap: 8px;
  }

  .topbar-actions button {
    width: 100%;
    min-width: 0;
  }

  .topbar-actions .topbar-symbol-button {
    width: 100%;
    min-width: 0;
    height: 42px;
    min-height: 42px;
    font-size: 1.25rem;
  }

  .primary-button {
    flex: 1;
  }

  .topbar-actions .primary-button {
    flex: 0 0 auto;
  }

  .user-add-form,
  .user-settings-row,
  .managed-password-reset-form {
    grid-template-columns: 1fr;
  }

  .user-settings-actions,
  .user-settings-row-actions,
  .managed-password-reset-form .password-reset-actions {
    justify-content: stretch;
  }

  .user-settings-actions button,
  .user-settings-row-actions button,
  .managed-password-reset-form .password-reset-actions button {
    flex: 1;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding: 10px 8px 14px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .topbar-actions .topbar-symbol-button {
    height: 40px;
    min-height: 40px;
    font-size: 1.24rem;
  }

  .change-log-row {
    grid-template-columns: 1fr;
  }

  .month-field select {
    display: none;
  }

  .month-switcher {
    display: grid;
  }

  .branch-field select {
    display: none;
  }

  .branch-switcher {
    display: grid;
  }

  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 4px;
  }

  .kpi-card {
    min-height: 42px;
    padding: 6px 7px;
    border-left-width: 4px;
  }

  .kpi-card.money {
    grid-column: span 2;
  }

  .kpi-label {
    font-size: 0.58rem;
  }

  .kpi-value {
    margin-top: 1px;
    font-size: 0.98rem;
  }

  .kpi-note {
    display: none;
  }

  .branch-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 5px;
  }

  .branch-card {
    padding: 6px;
  }

  .branch-card strong {
    margin-bottom: 4px;
    font-size: 0.68rem;
    line-height: 1.1;
  }

  .branch-card .opening-line {
    display: none;
  }

  .branch-card .coverage-bar {
    height: 5px;
  }

  .branch-meta {
    display: block;
    margin-top: 3px;
    font-size: 0.56rem;
    line-height: 1.15;
  }

  .branch-meta span:first-child {
    display: none;
  }

  .tabs {
    gap: 4px;
    margin: 2px 0 4px;
    padding-bottom: 0;
  }

  .tab-button {
    min-height: 32px;
    padding: 4px 8px;
  }

  .tab-symbol-button {
    font-size: 1rem;
  }

  #rotaPanel th:first-child,
  #rotaPanel td:first-child {
    width: 72px;
  }

  #rotaPanel th:last-child,
  #rotaPanel td:last-child {
    display: none;
  }

  #rotaPanel th,
  #rotaPanel td {
    padding: 7px 3px;
    font-size: 0.72rem;
  }

  #rotaPanel thead th:not(:first-child):not(:last-child) {
    padding-right: 1px;
    padding-left: 1px;
    overflow-wrap: normal;
    word-break: normal;
    white-space: nowrap;
    text-align: center;
    font-size: 0.62rem;
  }

  .date-cell {
    font-size: 0.75rem;
  }

  .date-cell em {
    font-size: 0.62rem;
  }

  .cell-input {
    min-height: 32px;
    padding: 5px 4px;
    font-size: 0.74rem;
  }

  .vacancy-button {
    min-height: 32px;
    font-size: 1.2rem;
  }

  .add-locum-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 10px 12px 12px;
  }

  .ai-command-form,
  .ai-result-panel,
  .picker-search,
  .locum-picker-list {
    padding-left: 12px;
    padding-right: 12px;
  }

  .ai-action-row {
    justify-content: stretch;
  }

  .ai-action-row button {
    width: 100%;
  }

  .picker-row {
    grid-template-columns: 36px 1fr;
  }

  .picker-current-shift {
    grid-template-columns: 1fr;
  }

  .picker-current-shift .danger {
    width: 100%;
  }

  .note-input {
    min-height: 32px;
    padding: 5px 4px;
    font-size: 0.74rem;
  }

  .directory-table-scroll {
    overflow-x: visible;
  }

  .directory-toolbar {
    justify-content: stretch;
    margin-top: 0;
  }

  .directory-search {
    width: 100%;
  }

  .directory-add-card {
    padding: 10px;
  }

  .directory-add-grid {
    grid-template-columns: 1fr;
  }

  .directory-table {
    min-width: 0;
    border-spacing: 0;
  }

  .directory-table thead {
    display: none;
  }

  .directory-table,
  .directory-table tbody,
  .directory-table tr,
  .directory-table td {
    display: block;
    width: 100% !important;
  }

  .directory-table tr.directory-row {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) minmax(82px, auto);
    gap: 4px 8px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    margin-bottom: 10px;
    padding: 8px;
  }

  .directory-table td {
    display: block;
    border-bottom: 0;
    padding: 1px 0;
    font-size: 0.82rem;
  }

  .directory-table td::before {
    content: attr(data-label);
    display: inline;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .directory-table td::before {
    content: attr(data-label) ": ";
  }

  .directory-table td:first-child {
    grid-column: 1;
    grid-row: 1;
    padding: 0;
  }

  .directory-table td:first-child::before {
    display: none;
  }

  .directory-table td:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
  }

  .directory-table td:nth-child(2)::before,
  .directory-table td:nth-child(3)::before {
    display: none;
  }

  .directory-table td:nth-child(2) strong {
    font-size: 0.98rem;
  }

  .directory-table td:nth-child(3) {
    grid-column: 3;
    grid-row: 1;
    align-self: center;
    color: var(--muted);
    font-weight: 800;
    text-align: right;
  }

  .directory-table td:nth-child(4),
  .directory-table td:nth-child(5) {
    grid-column: 1 / -1;
  }

  .directory-table td:nth-child(6),
  .directory-table td:nth-child(8) {
    grid-column: 1 / 3;
  }

  .directory-table td:nth-child(7),
  .directory-table td:nth-child(9) {
    grid-column: 3;
    text-align: right;
  }

  .directory-table td:nth-child(10) {
    grid-column: 1 / -1;
    padding-top: 5px;
  }

  .directory-row.editing td:not(:first-child) {
    grid-column: 1 / -1;
    text-align: left;
  }

  .directory-row.editing td::before {
    display: block;
    margin-bottom: 3px;
  }

  .directory-row.editing td:first-child::before {
    display: none;
  }

  .directory-favourite {
    width: 40px;
    min-height: 36px;
  }

  .directory-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .directory-row.editing .directory-actions {
    grid-template-columns: 1fr;
  }

  .directory-actions button {
    width: 100%;
  }

  .dir-edit-input {
    min-height: 36px;
    font-size: 0.86rem;
  }
}

@media print {
  body {
    background: #fff;
  }

  .filters,
  .tabs,
  .side-rail,
  .topbar-actions,
  .branch-strip {
    display: none;
  }

  .app-shell {
    padding: 0;
  }

  .main-layout {
    display: block;
  }

  .panel,
  .kpi-card {
    box-shadow: none;
  }

  .pay-row-paid td {
    background: #f0fdf4 !important;
    color: #0f172a !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .pay-table .pay-section-row th {
    background: #0f172a !important;
    color: #ffffff !important;
    font-family: Outfit, Inter, sans-serif;
    font-size: 0.92rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-align: center;
    padding: 10px 14px;
  }

  .pay-table .pay-section-row.info th {
    background: #1e293b !important;
    color: #ffffff !important;
  }

  .pay-table tfoot th,
  .pay-table tfoot td {
    background: #0f172a !important;
    color: #ffffff !important;
    font-weight: 800;
    font-size: 0.92rem;
  }

  .pay-table th {
    color: #0f172a !important;
    font-family: Outfit, Inter, sans-serif;
    font-weight: 800 !important;
    font-size: 0.76rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: #f1f5f9;
  }

  .pay-table td {
    color: #0f172a !important;
    font-weight: 600;
  }

  .paid-button {
    width: 100%;
    min-height: 32px;
    border: 1px solid #64748b;
    border-radius: 6px;
    background: #fff;
    color: #0f172a;
    font-size: 0.75rem;
    font-weight: 800;
    transition: var(--transition);
  }

  .paid-button.active {
    border-color: #059669 !important;
    background: #059669 !important;
    color: #fff !important;
    font-weight: 800;
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .number-cell,
  .money-cell {
    text-align: right;
    color: #0f172a !important;
  }

  .money-cell {
    font-weight: 800;
    font-size: 0.95rem;
  }

  .rate-input {
    width: 100%;
    min-width: 0;
    min-height: 32px;
    padding: 5px 8px;
    text-align: right;
    font-weight: 700;
    color: #0f172a !important;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.link-button {
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
}

.locum-nav-link {
  color: #0f172a !important;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition);
}

.locum-nav-link:hover,
.locum-nav-link:focus {
  color: var(--teal) !important;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.locum-nav-link::after {
  content: "↗";
  font-size: 0.72em;
  opacity: 0.4;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.locum-nav-link:hover::after {
  opacity: 1;
  transform: translate(1px, -1px);
}

.mobile-only-cell {
  display: none;
}

.pay-sub-name {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 500;
  margin-top: 1px;
}

@media (max-width: 768px) {
  .app-shell {
    padding: 4px 4px 16px;
  }

  .topbar {
    padding: 6px 10px;
    margin-bottom: 6px;
  }

  .topbar h1 {
    font-size: 1.1rem;
  }

  .topbar-actions {
    gap: 4px;
  }

  .topbar-symbol-button {
    width: 32px;
    min-width: 32px;
    height: 32px;
  }

  .filters {
    padding: 6px 8px;
    margin-bottom: 6px;
    gap: 6px;
  }

  .kpi-grid {
    gap: 4px;
    margin-bottom: 6px;
  }

  .kpi-card {
    min-height: 42px;
    padding: 4px 6px;
  }

  .branch-strip {
    gap: 4px;
    margin-bottom: 6px;
  }

  .branch-card {
    padding: 4px 6px;
  }

  .tabs {
    margin: 4px 0 6px;
    padding: 2px;
    gap: 3px;
  }

  .tab-button {
    min-height: 30px;
    padding: 3px 5px;
    font-size: 0.74rem;
  }

  .panel {
    padding: 8px;
  }

  .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 8px;
  }

  .header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    width: 100%;
  }

  .header-actions button {
    flex: 1 1 calc(50% - 4px);
    padding: 5px 6px;
    font-size: 0.72rem;
    min-height: 30px;
    text-align: center;
  }

  /* Single-Row Mobile Pay Table with Fixed 5-Column Alignment */
  .pay-table-scroll {
    margin-bottom: 8px;
    border-radius: 8px;
    overflow-x: hidden;
  }

  .payment-run-table {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
  }

  .payment-run-table .mobile-hide-cell {
    display: none;
  }

  .mobile-only-cell {
    display: table-cell;
  }

  /* Explicit column widths for exact alignment */
  .payment-run-table th:nth-child(2),
  .payment-run-table td:nth-child(2) {
    width: 36%;
    text-align: left;
    padding-left: 6px;
  }

  .payment-run-table th:nth-child(9),
  .payment-run-table td:nth-child(9) {
    width: 17%;
    text-align: right;
    padding-right: 4px;
  }

  .payment-run-table th:nth-child(10),
  .payment-run-table td:nth-child(10) {
    width: 14%;
    text-align: center;
  }

  .payment-run-table th:nth-child(11),
  .payment-run-table td:nth-child(11) {
    width: 20%;
    text-align: right;
    padding-right: 4px;
  }

  .payment-run-table th:nth-child(12),
  .payment-run-table td:nth-child(12) {
    width: 13%;
    text-align: center;
    padding-right: 4px;
  }

  .payment-run-table th,
  .payment-run-table td {
    padding: 6px 3px;
    font-size: 0.78rem;
    white-space: nowrap;
    vertical-align: middle;
    border-bottom: 1px solid #e2e8f0;
  }

  .payment-run-table th {
    font-size: 0.68rem;
    letter-spacing: 0.02em;
  }

  .locum-nav-link {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .pay-sub-name {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.65rem;
    color: var(--muted);
    font-weight: 500;
  }

  .pay-hours-cell {
    font-weight: 700;
    font-size: 0.78rem;
  }

  .pay-rate-cell .rate-input {
    width: 38px;
    min-height: 26px;
    padding: 2px 2px;
    font-size: 0.75rem;
    text-align: center;
  }

  .pay-total-cell {
    font-weight: 800;
    font-size: 0.78rem;
    color: #0f172a;
  }

  .pay-paid-cell .paid-button {
    min-height: 24px;
    padding: 2px 4px;
    font-size: 0.65rem;
    font-weight: 800;
    border-radius: 4px;
  }

  .pay-section-row th {
    font-size: 0.78rem;
    padding: 5px 6px;
    text-align: center;
  }
}
