/* RxVault Admin — extends Doctor Portal v7 design system */

.portal-brand-mark {
  width: 46px;
  height: 46px;
  display: block;
  flex: 0 0 46px;
  object-fit: contain;
}

.portal-brand-mark--login {
  width: 60px;
  height: 60px;
  flex-basis: 60px;
}

.admin-body.session-expired .app-inner {
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
}

.session-expired-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.session-expired-card {
  width: min(420px, 100%);
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-hover);
  text-align: center;
}

.session-expired-card h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.session-expired-card p {
  margin: 0 0 20px;
  color: var(--text-muted);
}

.adm-privacy-item {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Admin top bar — match Doctor Portal (search primary, no breadcrumbs) */
.admin-portal .portal-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-portal .topbar-left {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-portal .topbar-right {
  flex-shrink: 0;
}

.admin-portal .topbar-search {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
}

/* Consistent page layout */
#app-panel {
  width: 100%;
  min-width: 0;
}

.adm-page {
  --adm-page-gap: 24px;
}

.adm-page .page-header {
  margin: 0 0 20px;
}

.adm-page .page-header h1 {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.adm-page .page-header-desc {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--text-muted);
  max-width: 72ch;
}

.adm-page .page-header-row {
  align-items: baseline;
}

.adm-page .page-header-actions {
  align-items: center;
  flex-shrink: 0;
}

.adm-page-banner {
  margin: 0 0 20px;
}

.adm-page > .adm-filter-bar,
.adm-page > .adm-list-status,
.adm-page > .adm-table-panel,
.adm-page > .adm-ops-main,
.adm-page > .adm-health-section,
.adm-page > .adm-kpi-primary,
.adm-page > #audit-content,
.adm-page > #security-content,
.adm-page > #system-content,
.adm-page > #developer-content {
  margin-bottom: var(--adm-page-gap);
}

.adm-overview #overview-metrics-error {
  margin-bottom: 16px;
}

.adm-meta-line {
  margin: 8px 0 0;
  font-size: 13px;
}

.adm-source-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--primary-soft);
  color: var(--primary);
}

.adm-source-tag-legacy {
  background: var(--neutral-soft);
  color: var(--text-muted);
}

.adm-overview {
  --adm-space-section: 24px;
  --adm-space-legacy: 24px;
  padding-top: 10px;
}

.adm-overview-header {
  margin-bottom: 20px;
}

.adm-overview-header .page-header-row {
  align-items: flex-start;
  gap: 20px;
}

.adm-overview-header-main {
  flex: 1 1 auto;
  min-width: 0;
}

.adm-overview-header .page-header-desc {
  margin-top: 6px;
}

.adm-overview-header .adm-meta-line {
  margin: 4px 0 0;
}

.adm-overview-actions {
  flex-shrink: 0;
  align-items: center;
  gap: 12px;
}

.adm-overview-range {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
}

.adm-overview-range-label {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.adm-overview-range select {
  min-width: 112px;
  height: 34px;
  padding: 6px 28px 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-panel);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-soft) 50%), linear-gradient(135deg, var(--text-soft) 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 2px), calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.adm-overview-range select:hover {
  border-color: var(--border-strong);
}

.adm-overview-range select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.adm-overview #overview-metrics-error {
  margin-bottom: 16px;
}

/* Primary KPI row */
.adm-kpi-primary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.adm-kpi-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 6px;
  padding: 21px;
  min-height: 122px;
}

.adm-kpi-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.adm-kpi-value {
  font-size: clamp(2rem, 2.8vw, 2.5rem);
  font-weight: 600;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  align-self: end;
}

.adm-kpi-hint {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.35;
}

.adm-kpi-card-warn .adm-kpi-value {
  color: #b45309;
}

.adm-kpi-value.summary-value-muted {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Operational main row: pipeline + attention */
.adm-ops-main {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--adm-space-section);
  align-items: stretch;
}

.adm-ops-main .panel-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
  min-height: 0;
}

.adm-ops-main .section-title {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
}

.adm-ops-main .widget-caption {
  margin: 6px 0 0;
  font-size: 14px;
}

.adm-ops-pipeline { grid-column: span 8; }
.adm-ops-attention { grid-column: span 4; }

.adm-pipeline-flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
  margin-top: 18px;
}

.adm-pipeline-stage {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 64px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-panel-tint);
  border: 1px solid var(--border);
  text-align: center;
}

.adm-pipeline-stage-muted {
  border-style: dashed;
  background: var(--bg-panel);
}

.adm-pipeline-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
  line-height: 1.25;
}

.adm-pipeline-stage strong {
  display: block;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.adm-pipeline-helper {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.25;
  color: var(--text-muted);
}

.adm-pipeline-helper[hidden] {
  display: none;
}

.adm-pipeline-connector {
  align-self: center;
  width: 14px;
  height: 2px;
  background: var(--border-strong);
  position: relative;
  flex-shrink: 0;
}

.adm-pipeline-connector::after {
  content: '';
  position: absolute;
  right: -1px;
  top: 50%;
  transform: translateY(-50%);
  border: 4px solid transparent;
  border-left-color: var(--border-strong);
}

.adm-pipeline-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 0;
  font-size: 13px;
  line-height: 1.3;
}

.adm-pipeline-footer strong {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

.adm-pipeline-footer-sep {
  color: var(--text-soft);
}

/* Needs attention list */
.adm-attention-list {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.adm-attention-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px auto;
  gap: 12px;
  align-items: center;
  min-height: 52px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.adm-attention-label {
  color: var(--text);
  font-weight: 500;
  min-width: 0;
}

.adm-attention-value {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
  text-align: right;
}

.adm-attention-status {
  justify-self: end;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--text-muted);
  white-space: nowrap;
}

.adm-attention-status-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.adm-attention-status-good {
  background: var(--success-soft);
  color: var(--success);
}

.adm-attention-status-neutral {
  background: var(--neutral-soft);
  color: var(--text-muted);
}

/* Full-width system health */
.adm-health-section {
  padding: 24px;
}

.adm-health-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.adm-health-header-text {
  min-width: 0;
}

.adm-health-header .section-title {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
}

.adm-health-header .widget-caption {
  margin: 4px 0 0;
  font-size: 14px;
}

.adm-health-summary {
  margin: 0;
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}

.adm-health-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.adm-health-tile {
  position: relative;
  padding: 17px 16px 17px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-panel-tint);
  min-height: 88px;
}

.adm-health-tile::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
  background: var(--border);
}

.adm-health-tile[data-state="healthy"]::before {
  background: var(--success);
}

.adm-health-tile[data-state="degraded"]::before {
  background: var(--warn);
}

.adm-health-tile[data-state="not_configured"]::before,
.adm-health-tile[data-state="unavailable"]::before {
  background: var(--text-soft);
}

.adm-health-tile-name {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.adm-health-tile-status {
  margin: 0 0 2px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
}

.adm-health-tile-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-muted);
}

.adm-health-tile[data-state="healthy"] .adm-health-tile-status { color: var(--text); }
.adm-health-tile[data-state="degraded"] .adm-health-tile-status { color: var(--text); }
.adm-health-tile[data-state="not_configured"] .adm-health-tile-status,
.adm-health-tile[data-state="unavailable"] .adm-health-tile-status { color: var(--text-muted); }

@media (prefers-reduced-motion: reduce) {
  .adm-legacy-chevron,
  .admin-portal .portal-sidebar {
    transition: none;
  }
}

.adm-legacy-collapsible {
  margin-top: var(--adm-space-legacy);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-panel-tint);
  overflow: hidden;
}

.adm-legacy-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 16px 18px;
  border: 0;
  background: transparent;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}

.adm-legacy-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.55);
}

.adm-legacy-toggle-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.adm-legacy-toggle-title .section-title {
  margin: 0;
  font-size: 1rem;
}

.adm-legacy-collapsed-summary {
  font-size: 12px;
  flex: 1;
  text-align: right;
}

.adm-legacy-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.adm-legacy-toggle-btn[aria-expanded="true"] .adm-legacy-chevron {
  transform: rotate(180deg);
}

.adm-legacy-panel {
  padding: 0 18px 18px;
  border-top: 1px dashed var(--border);
}

.adm-dashboard-row {
  margin-top: 20px;
}

.adm-pipeline-list,
.adm-exception-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.adm-legacy-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.adm-legacy-metrics > div {
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-strong);
  background: var(--bg-panel-tint);
}

.adm-legacy-metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 1.25rem;
}

.adm-legacy-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.adm-chart-panel {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-panel);
}

.adm-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.adm-chart-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.adm-chart {
  width: 100%;
  height: 160px;
  display: block;
}

.adm-chart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 140px;
  color: var(--text-muted);
  font-size: 13px;
}

.adm-kv {
  display: grid;
  grid-template-columns: minmax(120px, auto) 1fr;
  gap: 8px 16px;
  margin: 0;
  font-size: 13px;
}

.adm-kv dt { color: var(--text-muted); margin: 0; }
.adm-kv dd { margin: 0; }

.adm-kv-inline {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.page-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.adm-field-inline {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.adm-filter-bar {
  display: grid;
  gap: 12px 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.adm-filter-bar-prescriptions {
  grid-template-columns: minmax(220px, 2.2fr) repeat(5, minmax(128px, 1fr));
}

.adm-filter-bar-doctors {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.adm-filter-bar-users {
  grid-template-columns: minmax(240px, 1fr);
}

.adm-filter-bar .form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  min-width: 0;
}

.adm-filter-bar label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.adm-filter-bar input,
.adm-filter-bar select {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  font-size: 14px;
}

.adm-filter-bar input:focus-visible,
.adm-filter-bar select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.adm-list-status {
  margin: 0 0 10px;
  font-size: 13px;
}

.adm-table-panel {
  padding: 0;
  overflow: hidden;
}

.adm-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.adm-table-panel .data-table {
  margin: 0;
}

.adm-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.adm-detail {
  margin-top: 16px;
}

.adm-detail-back { margin-bottom: 12px; }

.adm-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.adm-detail-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-panel);
}

.adm-detail-card h3 { margin: 0 0 12px; }

.adm-panel {
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-panel);
  margin-bottom: 16px;
}

.adm-panel h3 { margin: 0 0 8px; }

.adm-panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.adm-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.adm-toggle-row:last-child { border-bottom: none; }

.adm-toggle-row-label { font-weight: 600; font-size: 14px; }
.adm-toggle-row-help { font-size: 12px; margin-top: 2px; }

.adm-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.adm-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.adm-toggle-track {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.15s ease;
  position: relative;
}

.adm-toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
}

.adm-toggle input:checked + .adm-toggle-track {
  background: var(--primary);
}

.adm-toggle input:checked + .adm-toggle-track::after {
  transform: translateX(18px);
}

.adm-toggle input:focus-visible + .adm-toggle-track {
  box-shadow: var(--focus-ring);
}

.adm-badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.adm-badge-good, .status-pill.status-success { background: var(--success-soft); color: var(--success); }
.adm-badge-warn, .status-pill.status-warn { background: var(--warn-soft); color: var(--warn); }
.adm-badge-bad, .status-pill.status-danger { background: var(--danger-soft); color: var(--danger); }
.adm-badge-neutral, .status-pill.status-neutral { background: var(--neutral-soft); color: var(--text-muted); }

.adm-state-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.adm-state-chip {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid rgba(37, 99, 235, 0.15);
}

.adm-row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
}

.adm-table-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.btn-table {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text);
  white-space: nowrap;
}

.btn-table:hover {
  background: var(--bg-panel-tint);
  border-color: var(--border-strong);
}

.btn-table:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.btn-table-outline-danger {
  color: var(--text-muted);
  background: transparent;
}

.btn-table-outline-danger:hover,
.btn-table-outline-danger:focus-visible {
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.45);
  background: var(--danger-soft);
}

#doctors-table.adm-doctors-table {
  table-layout: fixed;
  width: 100%;
  min-width: 1120px;
}

#doctors-table.adm-doctors-table col.col-doctor { width: 21%; }
#doctors-table.adm-doctors-table col.col-email { width: 21%; }
#doctors-table.adm-doctors-table col.col-states { width: 10%; }
#doctors-table.adm-doctors-table col.col-status { width: 10%; }
#doctors-table.adm-doctors-table col.col-access { width: auto; }
#doctors-table.adm-doctors-table col.col-actions { width: 280px; }

#doctors-table.adm-doctors-table thead th {
  white-space: nowrap;
}

#doctors-table.adm-doctors-table th.col-access,
#doctors-table.adm-doctors-table td.col-access {
  min-width: 0;
  overflow: hidden;
}

#doctors-table.adm-doctors-table th.col-actions,
#doctors-table.adm-doctors-table td.col-actions {
  width: 280px;
  min-width: 280px;
  max-width: 280px;
  text-align: right;
  white-space: nowrap;
}

#doctors-table.adm-doctors-table tbody td {
  padding: 14px 16px;
  vertical-align: middle;
}

#doctors-table.adm-doctors-table tbody tr {
  min-height: 72px;
}

.adm-doctor-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.adm-doctor-name {
  display: block;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.adm-doctor-username {
  display: block;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.adm-doctor-email {
  display: block;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.adm-doctor-access {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.adm-doctor-access-mode {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.adm-doctor-access-login {
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}

#doctors-table.adm-doctors-table td.col-actions.adm-row-actions {
  display: table-cell;
}

#doctors-table.adm-doctors-table .adm-table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
  width: 100%;
}

#doctors-table.adm-doctors-table .adm-state-chips {
  gap: 4px;
}

#doctors-table.adm-doctors-table .btn-table {
  min-height: 32px;
  padding: 5px 10px;
}

.adm-row-menu {
  position: relative;
  display: inline-block;
}

.adm-row-menu > summary {
  list-style: none;
  cursor: pointer;
}

.adm-row-menu > summary::-webkit-details-marker {
  display: none;
}

.adm-row-menu-btn {
  min-width: 32px;
  padding-inline: 9px;
  font-size: 16px;
  line-height: 1;
}

.adm-row-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  min-width: 168px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-panel);
  box-shadow: var(--shadow-sm);
}

.adm-row-menu:not([open]) .adm-row-menu-panel {
  display: none;
}

.adm-row-menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

.adm-row-menu-item:hover,
.adm-row-menu-item:focus-visible {
  background: var(--bg-panel-tint);
  outline: none;
}

.adm-row-menu-item[data-action="disable-doctor"] {
  color: var(--text-muted);
}

.adm-row-menu-item[data-action="disable-doctor"]:hover,
.adm-row-menu-item[data-action="disable-doctor"]:focus-visible {
  color: var(--danger);
  background: var(--danger-soft);
}

.adm-doctors-table-wrap {
  overflow-x: auto;
}

@media (min-width: 1200px) {
  .adm-doctors-table-wrap {
    overflow-x: visible;
  }
}

@media (max-width: 1199px) {
  #doctors-table.adm-doctors-table {
    min-width: 1120px;
  }
}

@media (max-width: 767px) {
  .adm-filter-bar-doctors {
    grid-template-columns: minmax(0, 1fr);
  }

  .adm-doctors-table-wrap {
    overflow-x: visible;
  }

  #doctors-table.adm-doctors-table {
    min-width: 0;
    table-layout: auto;
  }

  #doctors-table.adm-doctors-table thead {
    display: none;
  }

  #doctors-table.adm-doctors-table tbody tr {
    display: block;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
  }

  #doctors-table.adm-doctors-table tbody td {
    display: grid;
    grid-template-columns: 108px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 7px 0;
    border-bottom: 0;
    text-align: left;
  }

  #doctors-table.adm-doctors-table tbody td::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-top: 2px;
  }

  #doctors-table.adm-doctors-table .col-doctor::before,
  #doctors-table.adm-doctors-table .col-email::before,
  #doctors-table.adm-doctors-table .col-states::before,
  #doctors-table.adm-doctors-table .col-status::before,
  #doctors-table.adm-doctors-table .col-access::before {
    display: block;
  }

  #doctors-table.adm-doctors-table .col-actions {
    display: block;
    grid-template-columns: 1fr;
    padding-top: 10px;
    width: auto;
    min-width: 0;
    max-width: none;
    white-space: normal;
  }

  #doctors-table.adm-doctors-table .col-actions::before {
    display: block;
    margin-bottom: 8px;
    padding-top: 0;
  }

  #doctors-table.adm-doctors-table td.col-actions.adm-row-actions {
    display: block;
  }

  #doctors-table.adm-doctors-table .adm-table-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    white-space: normal;
  }

  #doctors-table.adm-doctors-table .adm-doctor-name,
  #doctors-table.adm-doctors-table .adm-doctor-username,
  #doctors-table.adm-doctors-table .adm-doctor-email,
  #doctors-table.adm-doctors-table .adm-doctor-access-login {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  #doctors-table.adm-doctors-table .adm-row-menu-panel {
    right: auto;
    left: 0;
  }
}

.adm-empty,
.adm-error {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-muted);
}

.adm-empty-compact {
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.adm-table-empty td {
  padding: 0 !important;
  border-bottom: 0 !important;
  background: var(--bg-panel);
}

.adm-empty h3,
.adm-error h3 {
  margin: 12px 0 6px;
  color: var(--text);
}

.adm-empty-icon,
.adm-error-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  opacity: 0.5;
}

.adm-empty-icon svg,
.adm-error-icon svg {
  width: 100%;
  height: 100%;
}

.adm-skeleton {
  background: linear-gradient(90deg, var(--bg-panel-tint) 25%, #e8edf5 50%, var(--bg-panel-tint) 75%);
  background-size: 200% 100%;
  animation: adm-shimmer 1.2s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.adm-skeleton-row { height: 14px; margin: 8px 0; }

@keyframes adm-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .adm-skeleton { animation: none; background: var(--bg-panel-tint); }
}

.adm-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.adm-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.adm-input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
}

.adm-status-list {
  display: grid;
  gap: 10px;
}

.adm-status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-panel);
}

.adm-status-item-label { font-weight: 600; }
.adm-status-item-help { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.adm-integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.adm-integration-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
}

.adm-integration-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.adm-integration-card p {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.adm-integration-meta {
  display: grid;
  gap: 6px;
  font-size: 12px;
}

.adm-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--text);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-hover);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.45);
}

.modal-card {
  width: min(520px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-hover);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.modal-body label {
  display: block;
  margin: 12px 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.modal-body input,
.modal-body select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 12px; }
.right { text-align: right; }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--neutral-soft);
  font-size: 12px;
  font-weight: 600;
}

.adm-license-expired { color: var(--danger); }
.adm-license-expiring { color: var(--warn); }

.adm-actions-group {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.adm-actions-group h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.adm-error-details {
  margin-top: 12px;
  text-align: left;
  font-size: 12px;
}

.adm-error-details pre {
  overflow: auto;
  max-height: 160px;
  padding: 8px;
  background: var(--bg-panel-tint);
  border-radius: var(--radius-sm);
}

.mobile-nav-btn { display: none; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 23, 42, 0.35);
}

/* System Status page */
.adm-system-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 20px 22px;
  margin-bottom: var(--adm-page-gap);
}

.adm-system-summary-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.adm-system-summary-stat span {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.adm-system-summary-stat strong {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.adm-system-summary-overall strong {
  font-size: 1.35rem;
}

.adm-system-summary-overall[data-state="healthy"] strong { color: var(--success); }
.adm-system-summary-overall[data-state="degraded"] strong { color: var(--warn); }
.adm-system-summary-overall[data-state="notice"] strong { color: var(--text); }

.adm-system-summary-checked {
  grid-column: 1 / -1;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.adm-system-section {
  margin-bottom: var(--adm-page-gap);
}

.adm-system-section h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 600;
}

.adm-system-table-wrap {
  overflow-x: auto;
}

.adm-system-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.adm-system-table th,
.adm-system-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.adm-system-table th {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-panel-tint);
}

.adm-system-table td:last-child,
.adm-system-table th:last-child {
  white-space: nowrap;
}

.adm-system-status-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--neutral-soft);
  color: var(--text-muted);
}

.adm-system-status-pill.is-healthy { background: var(--success-soft); color: var(--success); }
.adm-system-status-pill.is-degraded { background: var(--warn-soft); color: var(--warn); }
.adm-system-status-pill.is-failed { background: var(--danger-soft); color: var(--danger); }
.adm-system-status-pill.is-neutral { background: var(--neutral-soft); color: var(--text-muted); }

.adm-system-notices {
  display: grid;
  gap: 10px;
}

.adm-system-notice {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(180, 83, 9, 0.2);
  background: var(--warn-soft);
  font-size: 13px;
  color: var(--text);
}

.adm-system-notice strong {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
}

.adm-system-notice span {
  color: var(--text-muted);
  font-size: 12px;
}

.adm-system-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 20px;
  padding: 18px 20px;
  margin: 0;
  font-size: 13px;
}

.adm-system-details dt {
  color: var(--text-muted);
  font-weight: 500;
}

.adm-system-details dd {
  margin: 0;
  font-weight: 500;
  color: var(--text);
}

.adm-system-cards {
  display: none;
  gap: 10px;
}

.adm-system-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-panel);
}

.adm-system-card h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.adm-system-card p {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--text-muted);
}

@media (min-width: 1400px) {
  .adm-health-tiles {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 1280px) {
  .adm-ops-attention { grid-column: span 12; }
  .adm-health-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .adm-system-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .adm-filter-bar-prescriptions {
    grid-template-columns: minmax(200px, 1.8fr) repeat(3, minmax(120px, 1fr));
  }
  .adm-filter-bar-prescriptions .form-group:nth-child(n+5) {
    grid-column: span 1;
  }
}

@media (max-width: 1100px) {
  .adm-kpi-primary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
  .adm-ops-pipeline,
  .adm-ops-attention { grid-column: span 12; }
  .adm-pipeline-flow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .adm-pipeline-connector { display: none; }
  .adm-health-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .adm-filter-bar-prescriptions,
  .adm-filter-bar-doctors {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .adm-filter-bar-prescriptions .form-group:first-child,
  .adm-filter-bar-doctors .form-group:first-child {
    grid-column: 1 / -1;
  }
  .adm-system-details { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .adm-system-table-wrap { display: none; }
  .adm-system-cards { display: grid; }
}

@media (max-width: 640px) {
  .adm-kpi-primary { grid-template-columns: minmax(0, 1fr); }
  .adm-health-tiles { grid-template-columns: minmax(0, 1fr); }
  .adm-legacy-collapsed-summary { display: none; }
  .adm-pipeline-flow { grid-template-columns: 1fr; }
  .adm-overview-header .page-header-row {
    flex-direction: column;
    align-items: stretch;
  }
  .adm-overview-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .adm-overview-range {
    flex: 1 1 auto;
    min-width: 0;
  }
  .adm-overview-actions .btn {
    flex-shrink: 0;
  }
  .adm-health-header {
    flex-direction: column;
    align-items: stretch;
  }
  .adm-health-summary {
    text-align: left;
    white-space: normal;
  }
  .adm-attention-item {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "label status"
      "value value";
    row-gap: 4px;
  }
  .adm-attention-item .adm-attention-label { grid-area: label; }
  .adm-attention-item .adm-attention-status { grid-area: status; }
  .adm-attention-item .adm-attention-value {
    grid-area: value;
    text-align: left;
  }
  .adm-system-summary { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .mobile-nav-btn { display: inline-flex; }
  .topbar-search { display: none; }
  .admin-portal.mobile-open .portal-sidebar {
    transform: translateX(0);
  }
  .admin-portal .portal-sidebar {
    position: fixed;
    z-index: 100;
    transform: translateX(-110%);
    transition: transform 0.2s ease;
    height: 100%;
    max-height: 100vh;
  }
}

.adm-legacy-prescriptions-note {
  margin: 0 0 20px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  border: 1px solid rgba(180, 83, 9, 0.18);
  font-size: 13px;
  color: var(--text-muted);
  width: 100%;
  box-sizing: border-box;
}

.adm-subrow td {
  padding-top: 0;
  padding-bottom: 10px;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
}

@media (prefers-reduced-motion: reduce) {
  .admin-portal .portal-sidebar { transition: none; }
}

