.admin-header {
  background: #0f4c81;
  color: #fff;
  padding: max(1.25rem, env(safe-area-inset-top, 0px))
    max(1.25rem, env(safe-area-inset-right, 0px)) 0
    max(1.25rem, env(safe-area-inset-left, 0px));
}

/* Must beat .god-clinic-bar { display: flex } or [hidden] bars stay visible */
[hidden] {
  display: none !important;
}

.admin-header-inner {
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
}

.admin-brand {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.75;
}

.admin-header h1 {
  margin: 0.15rem 0 0;
  font-size: 1.5rem;
  color: #fff;
}

.admin-sub {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7) !important;
}

.god-clinic-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1px solid #d8dee9;
  border-radius: 0.5rem;
}

.god-clinic-bar label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
}

.god-clinic-bar select {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  font: inherit;
  padding: 0.45rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.35rem;
  box-sizing: border-box;
}

a.btn-secondary.god-admin-link,
a.btn-secondary#admin-facility-link {
  display: inline-block;
  text-decoration: none;
  line-height: 1.4;
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-header .muted {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
}

.session-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1rem;
  margin: 0 auto;
  max-width: 72rem;
  padding: 1.5rem max(1.25rem, env(safe-area-inset-right, 0px))
    max(1.5rem, env(safe-area-inset-bottom, 0px))
    max(1.25rem, env(safe-area-inset-left, 0px));
  text-align: center;
  border-top: 1px solid #d8dee9;
}

.session-footer-email {
  flex: 1 1 100%;
  color: #64748b;
  font-size: 0.9rem;
  word-break: break-all;
}

.session-footer .btn-secondary {
  min-height: 44px;
}

.admin-tabs {
  max-width: 72rem;
  margin: 1rem auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.admin-tabs .tab {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  padding: 0.65rem 0.9rem;
  border-radius: 0.4rem 0.4rem 0 0;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.admin-tabs .tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.admin-tabs .tab.active {
  background: #f5f7fa;
  color: #0f4c81;
}

.admin-tabs--select {
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1rem;
}

.admin-section-label {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.admin-section-select {
  flex: 1 1 14rem;
  max-width: 22rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-weight: 600;
  color: #0f4c81;
  background: #f5f7fa;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 0.4rem;
  cursor: pointer;
}

.admin-section-select:focus,
.admin-section-select:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.65);
  outline-offset: 2px;
}

.admin-main {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.25rem max(1.25rem, env(safe-area-inset-right, 0px))
    max(1.25rem, env(safe-area-inset-bottom, 0px))
    max(1.25rem, env(safe-area-inset-left, 0px));
  overflow-x: clip;
}

.panel-head {
  margin-bottom: 1rem;
}

.panel-head h2 {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
}

.muted {
  color: #64748b;
  margin: 0;
}

.card-form {
  background: #fff;
  border: 1px solid #d8dee9;
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1.25rem;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(14rem, 100%), 1fr));
  gap: 0.75rem 1rem;
  align-items: end;
}

.grid-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  min-width: 0;
  max-width: 100%;
}

.grid-form .check-label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.4rem;
}

.grid-form .span-2 {
  grid-column: 1 / -1;
}

.grid-form .field-hint {
  font-weight: 400;
  font-size: 0.8rem;
  line-height: 1.35;
}

.hue-control {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.hue-control input[type="range"] {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  border: 0;
  accent-color: #0f4c81;
  background: linear-gradient(
    90deg,
    hsl(0, 70%, 45%),
    hsl(60, 70%, 45%),
    hsl(120, 70%, 45%),
    hsl(180, 70%, 45%),
    hsl(240, 70%, 45%),
    hsl(300, 70%, 45%),
    hsl(360, 70%, 45%)
  );
  border-radius: 999px;
  height: 0.55rem;
}

.hue-control input[type="number"] {
  flex: 0 0 4.5rem;
  width: 4.5rem;
}

.hue-swatch {
  flex: 0 0 1.75rem;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.35rem;
  border: 1px solid #cbd5e1;
  background: hsl(205, 79%, 28%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.grid-form input,
.grid-form select,
.grid-form textarea {
  font: inherit;
  font-weight: 400;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.5rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.35rem;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

button,
.btn-secondary {
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: 0.35rem;
  border: 1px solid #0f4c81;
  background: #0f4c81;
  color: #fff;
  cursor: pointer;
}

.btn-secondary,
button.btn-secondary {
  background: #fff;
  color: #0f4c81;
}

button.linkish,
.btn-link {
  background: none;
  border: none;
  color: #0f4c81;
  padding: 0.2rem 0.4rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

button.danger {
  color: #b91c1c;
}

/* Solid primary-style buttons: red fill, white label (not link-style Delete) */
button.danger:not(.btn-link) {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

button.danger:not(.btn-link):hover {
  background: #991b1b;
  border-color: #991b1b;
  color: #fff;
}

.table-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid #d8dee9;
  border-radius: 0.5rem;
}

.data-view {
  display: block;
}

.data-cards {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
}

.data-cards-empty {
  margin: 0;
  padding: 1rem 1.1rem;
  background: #fff;
  border: 1px solid #d8dee9;
  border-radius: 0.5rem;
  font-size: 0.9rem;
}

.data-card {
  background: #fff;
  border: 1px solid #d8dee9;
  border-radius: 0.5rem;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.data-card-title {
  font-size: 1.05rem;
  font-weight: 650;
  color: #0f172a;
  line-height: 1.35;
  word-break: break-word;
}

.data-card-fields {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.data-card-field {
  display: grid;
  grid-template-columns: minmax(5.5rem, 34%) 1fr;
  gap: 0.35rem 0.75rem;
  align-items: start;
  font-size: 0.9rem;
}

.data-card-field--bare {
  grid-template-columns: 1fr;
}

.data-card-field dt {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #64748b;
  padding-top: 0.15rem;
}

.data-card-field dd {
  margin: 0;
  color: #1a1a1a;
  word-break: break-word;
}

.data-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: center;
  padding-top: 0.15rem;
  border-top: 1px solid #e8edf3;
}

.data-card-actions .queue-actions,
.data-card-actions .comm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
}

.action-chooser {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  max-width: 18rem;
}

.action-chooser-select {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0.4rem 0.55rem;
  font: inherit;
  font-size: 0.9rem;
  color: #0f172a;
  background: #fff;
  border: 1px solid #c5d0de;
  border-radius: 0.4rem;
}

.action-chooser-select--danger {
  border-color: #f1a8a8;
  color: #991b1b;
}

.action-chooser-go {
  flex: 0 0 auto;
  width: 2.35rem;
  height: 2.35rem;
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  line-height: 1;
  color: #fff;
  background: #0f4c81;
  border: 1px solid #0f4c81;
  border-radius: 0.4rem;
  cursor: pointer;
}

.action-chooser-go:hover,
.action-chooser-go:focus-visible {
  background: #0a3559;
  border-color: #0a3559;
}

.data-card-actions .action-chooser {
  max-width: none;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #e8edf3;
  vertical-align: top;
}

.data-table th {
  background: #f8fafc;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #64748b;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table .col-drag {
  width: 2rem;
  padding-left: 0.5rem;
  padding-right: 0.25rem;
}

.data-table .drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.75rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0.25rem;
  background: transparent;
  color: #94a3b8;
  font-size: 1rem;
  line-height: 1;
  letter-spacing: -0.08em;
  cursor: grab;
  user-select: none;
}

.data-table .drag-handle:hover {
  color: #475569;
  background: #f1f5f9;
}

.data-table .drag-handle:active {
  cursor: grabbing;
}

.data-table .drag-handle[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.35;
  pointer-events: none;
}

.data-table tr.is-dragging {
  opacity: 0.45;
}

.data-table tr.drag-over-above td {
  box-shadow: inset 0 2px 0 #38bdf8;
}

.data-table tr.drag-over-below td {
  box-shadow: inset 0 -2px 0 #38bdf8;
}

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin: 0 0 0.75rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1px solid #d8dee9;
  border-radius: 0.5rem;
}

.toolbar-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
  margin: 0;
  min-width: 0;
}

.toolbar-field input,
.toolbar-field select {
  font: inherit;
  font-weight: 400;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.4rem 0.55rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.35rem;
}

.toolbar-reset {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: #0f4c81;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  align-self: flex-end;
}

.toolbar-reset:hover {
  color: #0a3559;
}

.toolbar-count {
  margin: 0 0 0.35rem auto;
  font-size: 0.85rem;
  font-weight: 400;
}

.toolbar-view-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.toolbar-view-toggle .view-toggle.active {
  background: #0f4c81;
  color: #fff;
  border-color: #0f4c81;
}

.roster-month-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.roster-month-nav .btn-secondary {
  min-width: 2.25rem;
  padding: 0.35rem 0.5rem;
}

.roster-month-label {
  min-width: 8.5rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: #0f172a;
}

.roster-calendar-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid #d8dee9;
  border-radius: 0.5rem;
}

.roster-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(8.5rem, 1fr));
  min-width: 42rem;
}

.roster-cal-dow {
  padding: 0.5rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid #e8edf3;
  border-right: 1px solid #eef2f7;
}

.roster-cal-dow:nth-child(7n),
.roster-cal-day:nth-child(7n) {
  border-right: none;
}

.roster-cal-day {
  min-height: 7.5rem;
  padding: 0.4rem 0.45rem 0.5rem;
  border-right: 1px solid #eef2f7;
  border-bottom: 1px solid #eef2f7;
  vertical-align: top;
  background: #fff;
}

.roster-cal-day.outside {
  background: #f8fafc;
  color: #94a3b8;
}

.roster-cal-day.today {
  background: #f0f7fc;
}

.roster-cal-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.roster-cal-day-num {
  font-size: 0.85rem;
  font-weight: 700;
  color: #334155;
}

.roster-cal-day.outside .roster-cal-day-num {
  color: #94a3b8;
}

.roster-cal-day.today .roster-cal-day-num {
  color: #0f4c81;
}

.roster-cal-add {
  appearance: none;
  border: 0;
  background: transparent;
  color: #0f4c81;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}

.roster-cal-add:hover {
  text-decoration: underline;
}

.roster-cal-entries {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.roster-cal-entry {
  padding: 0.3rem 0.35rem;
  border-radius: 0.3rem;
  background: #f1f5f9;
  border-left: 3px solid #0f4c81;
  font-size: 0.72rem;
  line-height: 1.3;
}

.roster-cal-entry-doctor {
  display: block;
  font-weight: 600;
  color: #0f172a;
}

.roster-cal-entry-meta {
  display: block;
  color: #64748b;
  margin-top: 0.1rem;
}

.roster-cal-entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.2rem;
}

.roster-cal-empty {
  font-size: 0.72rem;
  color: #94a3b8;
  padding: 0.15rem 0;
}

.th-sort {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: 600;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  text-align: left;
}

.th-sort:hover {
  color: #0f4c81;
}

.th-sort[aria-sort="ascending"]::after {
  content: " ↑";
  font-weight: 700;
}

.th-sort[aria-sort="descending"]::after {
  content: " ↓";
  font-weight: 700;
}

.status {
  min-height: 1.25rem;
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: #334155;
}

.status.error {
  color: #b91c1c;
}

.status.ok {
  color: #047857;
}

code {
  font-size: 0.85em;
  background: #e8edf3;
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
}

.catalog-panel {
  margin-bottom: 1.25rem;
}

.catalog-title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.catalog-picker {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
  max-width: 28rem;
}

#specialty-catalog-controls {
  display: grid;
  gap: 0.75rem;
}

.catalog-picker-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
}

.catalog-picker-label select {
  font: inherit;
  font-weight: 500;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.5rem 0.65rem;
  min-height: 2.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.35rem;
  background: #fff;
}

#specialty-catalog-controls > button {
  justify-self: start;
  min-height: 44px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(10rem, 100%), 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stats-row.card-form {
  display: grid;
}

.stat-card {
  padding: 1rem;
  background: #fff;
  border: 1px solid #d8dee9;
  border-radius: 0.5rem;
}

.stat-label {
  margin: 0;
  font-size: 0.8rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-value {
  margin: 0.35rem 0 0;
  font-size: 1.75rem;
  font-weight: 600;
  color: #0f4c81;
}

.empty-hint {
  color: #64748b;
  font-style: italic;
}

.import-box {
  margin-bottom: 1.25rem;
}

.import-actions {
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.file-pick {
  display: inline-block;
  cursor: pointer;
  margin: 0;
}

.file-pick input[type="file"] {
  display: none;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(14rem, 100%), 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.media-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.media-bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.85rem;
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.85rem;
  background: #f4f7fb;
  border: 1px solid #d8dee9;
  border-radius: 0.5rem;
}

.media-bulk-select-all {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.media-bulk-bar #media-bulk-count {
  margin: 0;
  min-width: 5.5rem;
}

.media-col-check {
  width: 2rem;
  text-align: center;
}

.media-card-check {
  position: absolute;
  top: 0.45rem;
  left: 0.45rem;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 0.25rem;
  box-shadow: 0 0 0 1px rgba(11, 31, 51, 0.12);
}

.media-card--selected {
  border-color: #0b5cab;
  box-shadow: 0 0 0 1px #0b5cab;
}

.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;
}

.media-crumb {
  border: none;
  background: transparent;
  color: #0b5cab;
  padding: 0.15rem 0.25rem;
  cursor: pointer;
  font: inherit;
  border-radius: 0.25rem;
}

.media-crumb:hover,
.media-crumb:focus-visible {
  background: #e8f1fb;
  outline: none;
}

.media-crumb-sep {
  color: #8b97a8;
  user-select: none;
}

.media-card--folder .media-thumb--folder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #e8eef5 0%, #d5dee9 100%);
}

.media-folder-icon {
  width: 2.75rem;
  height: 2rem;
  border-radius: 0.2rem 0.2rem 0.15rem 0.15rem;
  background: #e2b203;
  box-shadow: inset 0 0.35rem 0 #f0c94a;
  position: relative;
}

.media-folder-icon::before {
  content: "";
  position: absolute;
  left: 0;
  top: -0.35rem;
  width: 1.1rem;
  height: 0.45rem;
  background: #c99900;
  border-radius: 0.15rem 0.15rem 0 0;
}

.media-card {
  position: relative;
  background: #fff;
  border: 1px solid #d8dee9;
  border-radius: 0.5rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.media-thumb {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: #0b1f33;
  cursor: pointer;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.media-thumb img,
.media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.media-card-body {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.media-card-body strong {
  font-size: 0.85rem;
  word-break: break-all;
}

.media-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.media-preview-stage {
  background: #0b1f33;
  border-radius: 0.5rem;
  min-height: 12rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.media-preview-stage img,
.media-preview-stage video {
  max-width: 100%;
  max-height: 24rem;
  display: block;
}

.panel-actions {
  margin: 0 0 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top, 0px))
    max(1rem, env(safe-area-inset-right, 0px))
    max(1rem, env(safe-area-inset-bottom, 0px))
    max(1rem, env(safe-area-inset-left, 0px));
}

.admin-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 40, 70, 0.55);
}

.admin-modal-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 40rem);
  max-height: min(90vh, 44rem);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 0.6rem;
  border: 1px solid #d8dee9;
  box-shadow: 0 1rem 2.5rem rgba(15, 76, 129, 0.28);
  overflow: hidden;
}

.admin-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: #0f4c81;
  color: #fff;
  flex-shrink: 0;
}

.admin-modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
}

.admin-modal-close {
  appearance: none;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.15rem 0.4rem;
  cursor: pointer;
  border-radius: 0.3rem;
}

.admin-modal-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

.admin-modal-body {
  padding: 1rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-modal-body .card-form {
  margin-bottom: 0;
  border: none;
  padding: 0;
  background: transparent;
  border-radius: 0;
}

/* Compact dialogs (e.g. Call confirm): hug content, stack full-width actions */
.call-confirm-actions {
  flex-direction: column;
  align-items: stretch;
  margin-top: 1rem;
}

.call-confirm-actions > button {
  width: 100%;
  box-sizing: border-box;
  justify-content: center;
  text-align: center;
}

.call-confirm-specialty-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.call-confirm-specialty-options[hidden] {
  display: none;
}

.call-confirm-specialty-options > button {
  width: 100%;
  box-sizing: border-box;
  text-align: center;
}

#call-confirm-issues {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

#call-confirm-issues li {
  margin: 0.35rem 0;
}

#call-confirm-hint {
  margin: 0.5rem 0 0;
}

.confirm-modal-message {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
  color: #334155;
}

.creative-delete-usage-list,
.delete-usage-list {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  max-height: min(40vh, 14rem);
  overflow: auto;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 0.45rem;
}

.creative-delete-usage-list li,
.delete-usage-list li {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border, #e2e8f0);
  font-size: 0.9rem;
  line-height: 1.35;
  color: #334155;
}

.creative-delete-usage-list li:last-child,
.delete-usage-list li:last-child {
  border-bottom: none;
}

.creative-delete-usage-list .usage-meta,
.delete-usage-list .usage-meta {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.8rem;
  color: #64748b;
}

body.admin-modal-open {
  overflow: hidden;
}

.display-pair-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
  max-height: min(50vh, 22rem);
  overflow: auto;
}

.display-pair-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 0.45rem;
  background: #fff;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.display-pair-option:hover,
.display-pair-option:focus-visible {
  border-color: #0f4c81;
  outline: 2px solid #93c5fd;
  outline-offset: 1px;
}

.display-pair-option:disabled {
  opacity: 0.55;
  cursor: default;
}

.display-pair-option--demo {
  border-color: #f59e0b;
  background: #fffbeb;
}

.display-pair-option--demo .display-pair-option-title {
  color: #b45309;
}

.display-pair-option-title {
  font-weight: 700;
}

.display-pair-option-sub {
  font-size: 0.9rem;
  color: #334155;
}

.display-pair-option-meta {
  font-size: 0.8rem;
  color: #64748b;
}

#display-pair-code {
  font-size: 1.35rem;
  letter-spacing: 0.2em;
  font-variant-numeric: tabular-nums;
  max-width: 10rem;
}

@media (max-width: 40rem) {
  .admin-tabs--select {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-section-select {
    max-width: none;
    width: 100%;
    flex: 1 1 auto;
  }

  .table-toolbar {
    align-items: stretch;
  }

  .toolbar-field {
    flex: 1 1 100%;
  }

  .toolbar-field input,
  .toolbar-field select {
    min-width: 0;
    width: 100%;
  }

  .toolbar-count {
    margin-left: 0;
    margin-right: auto;
  }

  .toolbar-view-toggle {
    width: 100%;
  }

  .toolbar-view-toggle .view-toggle {
    flex: 1 1 auto;
  }

  /* ALL_DATA_TABLES: cards-only on mobile; keep month calendars via [hidden] table-wrap */
  .data-view:has(> .table-wrap:not([hidden])) > .table-wrap {
    display: none !important;
  }

  .data-view:has(> .table-wrap:not([hidden])) > .data-cards {
    display: flex;
  }

  /* Media library: force cards, hide Table toggle */
  .toolbar-view-toggle:has([data-media-view]) [data-media-view="table"] {
    display: none !important;
  }

  .toolbar-view-toggle:has([data-media-view]) [data-media-view="cards"] {
    display: none !important;
  }

  #media-table-wrap {
    display: none !important;
  }

  #media-grid {
    display: grid !important;
  }

  .admin-modal {
    align-items: stretch;
  }

  .admin-modal-panel {
    width: 100%;
    max-height: none;
    height: 100%;
    border-radius: 0;
  }

  /* Keep confirm-style dialogs content-sized on phones */
  .admin-modal--compact {
    align-items: center;
    justify-content: center;
  }

  .admin-modal--compact .admin-modal-panel {
    width: min(100%, 28rem);
    height: auto;
    max-height: min(90vh, calc(100% - 2rem));
    margin: 1rem;
    border-radius: 0.6rem;
  }

  .grid-form {
    grid-template-columns: 1fr;
  }

  .session-footer {
    flex-direction: column;
  }

  .session-footer .btn-secondary,
  .session-footer a.btn-secondary {
    width: 100%;
    text-align: center;
  }

  .stats-row {
    grid-template-columns: 1fr;
  }

  .god-clinic-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .god-clinic-bar select {
    min-width: 0;
    width: 100%;
  }
}

