:root {
  --color-bg: #e8ecf2;
  --color-surface: #ffffff;
  --color-text: #0f172a;
  --color-muted: #475569;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-border: #94a3b8;
  --color-table-grid: #cbd5e1;
  --color-table-head: #dbeafe;
  --color-error: #b91c1c;
  --color-success: #15803d;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  /* spațiu deasupra tabelului (toolbar, hint, butoane derulare) + header app */
  --patients-table-chrome: 13.25rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: clamp(0.9rem, 0.85rem + 0.2vw, 1rem);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
}

.header-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.nav-link {
  color: var(--color-muted);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.user-label {
  color: var(--color-muted);
  font-size: 0.9rem;
}

.page-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.search-wrap {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  margin: 0;
  padding: 0.35rem 0;
  list-style: none;
  max-height: 16rem;
  overflow: auto;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
}

.search-suggest-empty {
  padding: 0.55rem 0.85rem;
  font-size: 0.88rem;
  color: var(--color-muted);
}

.search-suggest-item {
  padding: 0.5rem 0.85rem;
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
}

.search-suggest-item:last-child {
  border-bottom: none;
}

.search-suggest-item:hover,
.search-suggest-item--active {
  background: #eff6ff;
  color: #1e3a8a;
}

.data-row--highlight td {
  animation: row-highlight-pulse 0.6s ease-in-out 3;
}

@keyframes row-highlight-pulse {
  0%,
  100% {
    box-shadow: inset 0 0 0 0 transparent;
  }
  50% {
    box-shadow: inset 0 0 0 2px #2563eb;
  }
}

.search-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font: inherit;
}

.search-input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.save-status {
  font-size: 0.85rem;
  color: var(--color-success);
  min-width: 4rem;
}

.table-wrap {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 2px solid var(--color-border);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.1);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  max-width: 100%;
}

/* Derulare verticală în container → thead sticky (top: 0) rămâne vizibil */
#grid-desktop.table-wrap {
  max-height: calc(100dvh - var(--patients-table-chrome));
  overscroll-behavior: contain;
}

.table-hint {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--color-muted);
}

.th-short {
  display: none;
}

.table-scroll-toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.table-scroll-btn {
  flex: 1;
  border: 1px solid #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
}

.table-scroll-btn:active {
  background: #dbeafe;
}

.table-scroll-cue {
  display: none;
  margin: 0.4rem 0 0;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: #2563eb;
  line-height: 1.4;
}

.table-wrap--dragging {
  cursor: grabbing;
  user-select: none;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1100px;
}

.data-table th,
.data-table td {
  border-right: 1px solid var(--color-table-grid);
  border-bottom: 1px solid var(--color-table-grid);
  padding: 0.5rem 0.55rem;
  vertical-align: middle;
}

.data-table th:first-child,
.data-table td:first-child {
  border-left: 1px solid var(--color-table-grid);
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 7.5rem;
  max-width: 9rem;
  box-shadow: 2px 0 6px rgba(15, 23, 42, 0.06);
}

.data-table thead th:first-child {
  z-index: 7;
}

.data-table tbody tr.data-row td:first-child {
  background: #ffffff;
}

.data-table tbody tr.data-row:nth-child(even) td:first-child {
  background: #f1f5f9;
}

.data-table tbody tr.data-row--draft td:first-child {
  background: #fffbeb;
}

.data-table thead tr:first-child th {
  border-top: 1px solid var(--color-table-grid);
}

.data-table th {
  text-align: left;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1e3a5f;
  background: var(--color-table-head);
  position: sticky;
  top: 0;
  z-index: 4;
  padding: 0.65rem 0.55rem;
  box-shadow: 0 2px 0 var(--color-table-grid);
}

.data-table tbody tr.data-row:nth-child(even) td {
  background: #f1f5f9;
}

.data-table tbody tr.data-row td {
  background: #ffffff;
}

.data-table tbody tr.data-row--draft td {
  background: #fffbeb;
  box-shadow: inset 0 0 0 1px #fcd34d;
}

.data-table tbody tr.detail-row td {
  background: #f8fafc;
  border-bottom: 2px solid var(--color-border);
}

.cell-input {
  width: 100%;
  min-width: 6rem;
  min-height: 2.5rem;
  border: 1px solid #94a3b8;
  border-radius: 6px;
  padding: 0.5rem 0.55rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--color-text);
  background: #ffffff;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06);
}

.cell-input::placeholder {
  color: #64748b;
  opacity: 1;
}

.cell-input:hover {
  border-color: #64748b;
}

.cell-input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

.datetime-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.datetime-wrap .cell-input--datetime-ro {
  padding-right: 2.25rem;
}

.datetime-wrap-icon {
  position: absolute;
  right: 0.5rem;
  width: 1.15rem;
  height: 1.15rem;
  pointer-events: none;
  opacity: 0.55;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%232563eb' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E");
}

.cell-input--datetime-ro {
  min-width: 10.5rem;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

/* Flatpickr — curat, lizibil; azi = cerc albastru în jurul numărului */
.flatpickr-calendar.fp-app {
  font-family: var(--font);
  z-index: 10050 !important;
  border-radius: 10px;
  border: 1px solid #64748b;
  background: #ffffff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
  margin-top: 6px;
}

.flatpickr-calendar.fp-app .flatpickr-innerContainer {
  overflow: visible !important;
}

.flatpickr-calendar.fp-app .flatpickr-rContainer {
  overflow: visible !important;
}

.flatpickr-calendar.fp-app .flatpickr-months {
  background: #2563eb;
  padding: 0.45rem 0.3rem;
}

.flatpickr-calendar.fp-app .flatpickr-current-month,
.flatpickr-calendar.fp-app .flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-calendar.fp-app .flatpickr-current-month input.cur-year {
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff !important;
}

.flatpickr-calendar.fp-app .flatpickr-months .flatpickr-prev-month svg,
.flatpickr-calendar.fp-app .flatpickr-months .flatpickr-next-month svg {
  fill: #ffffff;
}

.flatpickr-calendar.fp-app .flatpickr-weekdays {
  background: #f1f5f9;
  border-bottom: 1px solid #cbd5e1;
}

.flatpickr-calendar.fp-app span.flatpickr-weekday {
  color: #1e293b;
  font-weight: 700;
  font-size: 0.78rem;
}

.flatpickr-calendar.fp-app .flatpickr-day {
  position: relative;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  line-height: 38px;
  height: 38px;
  color: #0f172a;
}

.flatpickr-calendar.fp-app .flatpickr-day.prevMonthDay,
.flatpickr-calendar.fp-app .flatpickr-day.nextMonthDay {
  color: #64748b;
}

.flatpickr-calendar.fp-app .flatpickr-day.selected,
.flatpickr-calendar.fp-app .flatpickr-day.startRange,
.flatpickr-calendar.fp-app .flatpickr-day.endRange {
  background: #2563eb !important;
  color: #ffffff !important;
  font-weight: 700;
}

.flatpickr-calendar.fp-app .flatpickr-day.today:not(.selected) {
  background: transparent !important;
  border: none !important;
  color: #0f172a;
  font-weight: 700;
}

.flatpickr-calendar.fp-app .flatpickr-day.today:not(.selected)::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  margin-left: -17px;
  margin-top: -17px;
  border: 2px solid #dc2626;
  border-radius: 50%;
  box-sizing: border-box;
  pointer-events: none;
}

.flatpickr-calendar.fp-app .flatpickr-day.today.selected {
  border-radius: 50% !important;
}

.flatpickr-calendar.fp-app .flatpickr-day:hover {
  background: #e0e7ff !important;
}

/* Ascunde weekend — doar Luni–Vineri vizibile */
.flatpickr-calendar.fp-app .flatpickr-weekdays .flatpickr-weekday:nth-child(6),
.flatpickr-calendar.fp-app .flatpickr-weekdays .flatpickr-weekday:nth-child(7) {
  display: none;
}

.flatpickr-calendar.fp-app .dayContainer {
  width: 100%;
}

.flatpickr-calendar.fp-app .flatpickr-day:not(.fp-weekend-hidden) {
  flex: 1 0 20%;
  max-width: 20%;
}

.flatpickr-calendar.fp-app .flatpickr-day.fp-weekend-hidden {
  flex: 0 0 0 !important;
  width: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  overflow: hidden;
  visibility: hidden;
}

.flatpickr-calendar.fp-app .flatpickr-day.flatpickr-disabled.fp-weekend-hidden {
  display: none !important;
}

.flatpickr-calendar.fp-app.hasTime .flatpickr-time {
  border-top: 1px solid #cbd5e1;
  background: #f8fafc;
  height: auto !important;
  max-height: none !important;
  line-height: normal !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 0.5rem 0.75rem !important;
  box-sizing: border-box;
  border-radius: 0 0 10px 10px;
  overflow: visible !important;
}

.flatpickr-calendar.fp-app .flatpickr-time input {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a !important;
  background: #ffffff !important;
  border: 1px solid #94a3b8 !important;
  border-radius: 6px;
  box-shadow: none !important;
  height: 2.5rem !important;
  line-height: 2.5rem !important;
  min-width: 3rem;
}

.flatpickr-calendar.fp-app .flatpickr-time .flatpickr-time-separator {
  color: #0f172a;
  font-weight: 700;
}

.flatpickr-calendar.fp-app .flatpickr-time .flatpickr-am-pm {
  display: none !important;
}

@media (max-width: 767px) {
  .flatpickr-calendar.fp-app {
    width: min(100vw - 1.5rem, 320px) !important;
    left: 50% !important;
    transform: translateX(-50%);
  }

  .flatpickr-calendar.fp-app .flatpickr-day:not(.fp-weekend-hidden) {
    height: 44px;
    line-height: 44px;
    font-size: 1.1rem;
  }

  .flatpickr-calendar.fp-app .flatpickr-day.today:not(.selected)::before {
    width: 38px;
    height: 38px;
    margin-left: -19px;
    margin-top: -19px;
  }
}

.cell-input--tel {
  font-variant-numeric: tabular-nums;
}

.col-actions {
  width: 9.5rem;
  min-width: 9.5rem;
  text-align: center;
  position: sticky;
  right: 0;
  background: var(--color-surface);
  box-shadow: -4px 0 8px rgba(15, 23, 42, 0.04);
  z-index: 2;
}

.data-table thead .col-actions {
  background: var(--color-table-head);
  z-index: 8;
}

.data-table tbody tr.data-row:nth-child(even) td.col-actions {
  background: #f1f5f9;
}

.data-table tbody tr.data-row--draft td.col-actions {
  background: #fffbeb;
}

.col-actions-head {
  font-size: 1rem;
  line-height: 1;
  color: var(--color-muted);
}

.row-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: stretch;
}

.actions-muted {
  color: #94a3b8;
  font-size: 0.85rem;
}

.btn-row {
  border: 1px solid var(--color-border);
  background: #f1f5f9;
  color: var(--color-text);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  min-height: 32px;
  padding: 0.25rem 0.35rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-row.btn-more {
  font-size: 1.1rem;
  font-weight: 700;
  min-height: 32px;
}

.btn-row.btn-more--labeled {
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.15;
}

.btn-save {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
  font-weight: 700;
}

.btn-save:hover {
  background: #bbf7d0;
}

.btn-edit {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.btn-edit:hover {
  background: #dbeafe;
}

.btn-delete {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.btn-delete:hover {
  background: #fee2e2;
}

.btn-more {
  border: 1px solid var(--color-border);
  background: #f1f5f9;
  color: var(--color-text);
}

.data-row--editing td {
  box-shadow: inset 0 0 0 2px var(--color-primary);
}

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-table-grid);
}

.panel-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-muted);
}

.patient-card .btn-more {
  margin-top: 0.25rem;
}

.btn-more:hover:not(:disabled) {
  background: #eef2ff;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-more:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  background: #f8fafc;
  color: #94a3b8;
}

.btn-more.has-extra::after {
  content: '•';
  color: var(--color-primary);
  font-size: 0.65rem;
  vertical-align: super;
  margin-left: 1px;
}

.detail-row td {
  background: #f8fafc;
  padding: 0.75rem 1rem;
}

.detail-panel-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text);
}

.detail-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: none;
  width: 100%;
}

.detail-panel-extra {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: stretch;
}

.detail-panel-extra label {
  min-width: 0;
  height: 100%;
}

.detail-panel-extra .panel-textarea {
  flex: 1;
  min-height: 4.5rem;
  width: 100%;
}

.detail-panel-audit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1rem;
}

.patient-audit-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  flex: 1 1 auto;
  min-width: min(100%, 20rem);
  padding: 0.4rem 0.65rem;
  background: var(--color-surface-alt, #f4f6f8);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--color-text);
}

.patient-audit-chip-label {
  font-weight: 600;
  color: var(--color-muted);
  margin-right: 0.25rem;
}

.patient-audit-details {
  flex: 0 0 auto;
  font-size: 0.8rem;
  margin: 0;
}

.patient-audit-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  list-style: none;
  user-select: none;
}

.patient-audit-details summary::-webkit-details-marker {
  display: none;
}

.patient-audit-details summary::before {
  content: '▸ ';
  font-size: 0.65rem;
}

.patient-audit-details[open] summary::before {
  content: '▾ ';
}

.patient-audit-details--empty summary {
  opacity: 0.75;
}

.patient-audit-history-list {
  margin: 0.35rem 0 0;
  padding-left: 1rem;
  max-height: 8rem;
  overflow-y: auto;
  font-size: 0.78rem;
  color: var(--color-text);
}

.patient-audit-history-list li {
  margin-bottom: 0.25rem;
}

.patient-audit-history-empty {
  color: var(--color-muted);
  list-style: none;
  margin-left: -1rem;
}

.detail-panel-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.detail-panel-footer .panel-hint {
  margin: 0;
  flex: 1 1 12rem;
  font-size: 0.78rem;
}

.admin-inline-link {
  margin-left: 0.35rem;
  font-size: 0.85rem;
}

.audit-changes-list,
.patient-audit-changes {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: var(--color-muted);
}

.audit-details-cell .audit-changes-list {
  color: var(--color-text);
}

.patient-audit-change-label {
  font-weight: 600;
  color: var(--color-text);
}

.patient-audit-history-item {
  margin-bottom: 0.5rem;
}

.detail-overlay-mobile {
  position: fixed;
  inset: 0;
  z-index: 10040;
  display: flex;
  align-items: flex-end;
  justify-content: stretch;
  pointer-events: none;
}

.detail-overlay-mobile:not([hidden]) {
  pointer-events: auto;
}

.detail-overlay-mobile[hidden] {
  display: none !important;
}

.detail-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.detail-overlay-sheet {
  position: relative;
  width: 100%;
  max-height: 88vh;
  overflow: auto;
  background: #f8fafc;
  border-radius: 14px 14px 0 0;
  padding: 1rem 1rem 1.25rem;
  box-shadow: 0 -10px 36px rgba(15, 23, 42, 0.28);
  -webkit-overflow-scrolling: touch;
}

.detail-overlay-sheet .detail-panel {
  max-width: none;
}

body.detail-overlay-open {
  overflow: hidden;
}

.detail-panel label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-muted);
}

.panel-textarea {
  font: inherit;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  resize: vertical;
}

.cards-wrap {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.patient-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 2px solid var(--color-border);
  box-shadow: var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.patient-card .cell-input {
  min-height: 2.75rem;
}

.card-field span {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-muted);
  margin-bottom: 0.2rem;
}

.btn-block {
  width: 100%;
}

@media (max-width: 767px) {
  body {
    overflow-x: hidden;
  }

  .page-main {
    padding: 0.5rem;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .save-status {
    text-align: right;
  }

  .table-hint {
    font-size: 0.82rem;
    line-height: 1.45;
  }

  .table-wrap {
    border-radius: 8px;
    margin-left: -0.25rem;
    margin-right: -0.25rem;
    width: calc(100% + 0.5rem);
    max-width: 100vw;
  }

  #grid-desktop.table-wrap {
    --patients-table-chrome: 15.5rem;
    max-height: calc(100dvh - var(--patients-table-chrome));
  }

  .data-table .th-long {
    display: none !important;
  }

  .data-table .th-short {
    display: inline !important;
  }

  .table-scroll-cue {
    display: block;
  }

  .table-wrap {
    cursor: grab;
    touch-action: pan-x;
    scrollbar-color: #64748b #e2e8f0;
  }

  .table-wrap::-webkit-scrollbar {
    height: 12px;
  }

  .table-wrap::-webkit-scrollbar-thumb {
    background: #64748b;
    border-radius: 6px;
    border: 2px solid #e2e8f0;
  }

  .table-wrap::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 6px;
  }

  .data-table {
    min-width: 940px;
  }

  /* Fără Acțiuni lipite peste Telefon (simulator Chrome / telefon) */
  .col-actions {
    position: static !important;
    right: auto;
    z-index: auto;
    box-shadow: none;
    width: 6.75rem;
    min-width: 6.75rem;
  }

  .data-table thead .col-actions {
    z-index: 4;
  }

  .data-table th:first-child,
  .data-table td:first-child {
    min-width: 5.25rem;
    max-width: 5.75rem;
  }

  .data-table th {
    font-size: 0.65rem;
    letter-spacing: 0.02em;
    padding: 0.35rem 0.22rem;
  }

  .cell-input {
    min-width: 4.25rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.4rem 0.4rem;
  }

  .cell-input,
  .cell-input--datetime-ro {
    min-height: 2.75rem;
    font-size: 16px;
  }

  .header-inner {
    padding: 0.5rem 0.65rem;
  }

  .brand {
    font-size: 0.95rem;
  }

  .header-nav {
    gap: 0.5rem;
    font-size: 0.9rem;
  }

  .user-label {
    display: none;
  }

  .row-actions {
    gap: 0.25rem;
  }

  .btn-row {
    font-size: 0.68rem;
    min-height: 34px;
    padding: 0.2rem 0.25rem;
  }

  .btn-row.btn-more--labeled {
    font-size: 0.65rem;
  }

  .detail-panel-extra {
    grid-template-columns: 1fr;
  }

  .panel-textarea {
    font-size: 16px;
  }
}

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
}

.auth-card h1 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.checkbox-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  font-size: 0.9rem;
}

.checkbox-label input {
  width: auto;
}

.form-stack label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 500;
}

.form-stack input {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font: inherit;
}

.form-narrow {
  max-width: 360px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--color-text);
}

.btn-close-panel {
  background: #dc2626 !important;
  color: #fff !important;
  border: none;
}

.btn-close-panel:hover {
  background: #b91c1c !important;
  color: #fff !important;
}

.btn-sm {
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.error {
  color: var(--color-error);
  margin: 0 0 0.75rem;
}

.success {
  color: var(--color-success);
  margin: 0 0 0.75rem;
}

.muted {
  color: var(--color-muted);
}

.warn {
  color: #b45309;
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  left: 1.25rem;
  max-width: 320px;
  margin-left: auto;
  padding: 0.75rem 1rem;
  background: var(--color-text);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 100;
}

.toast-error {
  background: var(--color-error);
}

.page-title {
  margin: 0 0 0.5rem;
}

.admin-page .user-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.user-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
}

.user-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge {
  font-size: 0.75rem;
  background: #e0f2fe;
  color: #0369a1;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.user-card-actions {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.stack-sm {
  flex-direction: column;
  align-items: stretch;
}

.input-sm {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font: inherit;
}

.admin-page .card {
  margin-bottom: 1rem;
}

.admin-page h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.admin-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.admin-subnav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  color: #334155;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}

.admin-subnav-link:hover {
  background: #e2e8f0;
}

.admin-subnav-link--active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.admin-subnav-link--muted {
  background: transparent;
  border-color: transparent;
  color: var(--color-muted);
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.admin-stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
}

.admin-stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 800;
  color: #1d4ed8;
  line-height: 1.1;
}

.admin-stat-label {
  font-size: 0.78rem;
  color: var(--color-muted);
  margin-top: 0.25rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--color-border);
  padding: 0.45rem 0.5rem;
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-muted);
}

.checklist {
  margin: 0 0 1rem;
  padding-left: 1.1rem;
}

.checklist li {
  margin-bottom: 0.35rem;
}

.check-ok {
  color: #166534;
}

.check-warn {
  color: #b45309;
}

.admin-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.btn-active {
  background: #2563eb !important;
  border-color: #2563eb !important;
  color: #fff !important;
}

.user-reset-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.user-reset-input {
  flex: 1 1 10rem;
  min-width: 8rem;
}

.admin-users-table .user-reset-form .btn-primary {
  white-space: nowrap;
}

.btn-delete-user {
  border: 1px solid #fca5a5;
  background: #fef2f2;
  color: #b91c1c;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
}

.btn-delete-user:hover {
  background: #fee2e2;
}

.admin-h3 {
  margin: 1rem 0 0.35rem;
  font-size: 0.95rem;
}

.admin-steps {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.82rem;
}

@media (max-width: 767px) {
  .admin-users-table thead {
    display: none;
  }

  .admin-users-table tr {
    display: block;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    padding: 0.65rem;
  }

  .admin-users-table td {
    display: block;
    border: none;
    padding: 0.35rem 0;
  }

  .admin-users-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-muted);
    margin-bottom: 0.2rem;
  }
}

.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;
}
