:root {
  --primary: #6d3d8e;
  --primary-dark: #4f2a6b;
  --ink: #182231;
  --muted: #687386;
  --line: #e2e8f0;
  --surface: #ffffff;
  --page: #f6f8fb;
  --coral: #ef6f6c;
  --indigo: #5b5fc7;
  --amber: #e4a11b;
  --shadow: 0 18px 45px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}
html { overflow-x: hidden; }

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  color: #f8fafc;
  background: #172033;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 800;
}

.brand-logo {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 8px;
  object-fit: contain;
  background: #ffffff;
}

.brand.has-logo .brand-mark {
  display: none;
}

.brand strong,
.user-card strong {
  display: block;
}

.brand span,
.user-card span {
  display: block;
  color: #b8c1d1;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.nav-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.nav-list::-webkit-scrollbar {
  width: 6px;
}

.nav-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.nav-item {
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 8px;
  color: #dbe4f0;
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.user-card {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

.role-switcher {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  color: #b8c1d1;
  font-size: 12px;
}

.role-switcher select {
  width: 100%;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #ffffff;
  background: #243047;
}

.nav-item.hidden-by-role {
  display: none;
}
/* Any element gated by role permission (e.g. revenue cards) */
.hidden-by-role {
  display: none !important;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #2dd4bf;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 14px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: 19px;
}

h3 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

#branchSelector {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
}
.cloud-sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 700;
  background: #f1f5f9;
  color: #475569;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  position: relative;
  /* FIXED width on every viewport — chip never expands based on content
     length so adjacent topbar items (version chip, switch button, etc.)
     stay rock-stable. Truncated detail is visible via the title tooltip
     (set in setCloudSyncStatus).
     • Desktop: 110px wide → shows icon + first ~12 chars of detail
     • Mobile: 44px wide → icon-only */
  width: 110px;
  flex: 0 0 110px;
  justify-content: flex-start;
  overflow: hidden;
  transition: background 0.15s, color 0.15s;
}
.cloud-sync-badge .cloud-sync-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
/* Mobile: shrink to icon-only — hide detail span entirely. */
@media (max-width: 600px) {
  .cloud-sync-badge {
    width: 44px;
    flex: 0 0 44px;
    padding: 5px 8px;
    gap: 0;
  }
  .cloud-sync-badge .cloud-sync-detail { display: none; }
}
/* Pulse animation when syncing (pushing/pulling) */
.cloud-sync-badge[data-level="pushing"],
.cloud-sync-badge[data-level="pulling"] {
  animation: cloud-pulse 1.4s ease-in-out infinite;
}
@keyframes cloud-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5); transform: scale(1); }
  50% { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0); transform: scale(1.03); }
}
/* Error state — gentle shake */
.cloud-sync-badge[data-level="error"] {
  animation: cloud-shake 0.5s ease-in-out;
}
@keyframes cloud-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}
/* Success — gentle bounce on every sync */
.cloud-sync-badge[data-level="synced"] {
  animation: cloud-bounce 0.5s ease-out;
}
@keyframes cloud-bounce {
  0% { transform: scale(0.95); opacity: 0.6; }
  50% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); }
}
.cloud-sync-badge:hover { opacity: 0.92; }
.cloud-sync-badge .cloud-sync-detail {
  font-weight: 500;
  opacity: 0.8;
  font-size: 11px;
}
/* (Old `max-width: 720px → hide detail` rule removed — now handled by the
   compact-idle + hover-expand strategy at line ~258. Mobile <600px hides
   detail entirely; tablets keep a 110px chip with truncated detail.) */

.icon-button,
.primary-action,
.ghost-button,
.chip,
.visit-card button,
.settings-menu button {
  min-height: 38px;
  border-radius: 8px;
}

.icon-button {
  width: 40px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
  font-size: 20px;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}

.icon-button:hover {
  border-color: var(--primary);
  background: #faf5ff;
  color: var(--primary);
}

.notification-button {
  position: relative;
  font-weight: 900;
}

.notification-button::after {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--coral);
  color: #ffffff;
  content: attr(data-count);
  font-size: 11px;
  line-height: 1;
}

.notification-button[data-count="0"]::after {
  display: none;
}

.primary-action {
  border: 0;
  padding: 0 18px;
  color: #ffffff;
  background: var(--primary);
  font-weight: 700;
  transition: background 0.14s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.primary-action:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(109, 61, 142, 0.32);
}

.primary-action:active {
  transform: translateY(0);
  box-shadow: none;
}

.primary-action.full {
  width: 100%;
}

.ghost-button {
  border: 1px solid var(--line);
  padding: 0 14px;
  color: var(--primary-dark);
  background: #ffffff;
  transition: border-color 0.14s ease, color 0.14s ease, background 0.14s ease;
}

.ghost-button:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #faf5ff;
}

.ghost-button:active {
  background: #f3e8ff;
}

/* Universal focus ring — visible only on keyboard navigation */
.primary-action:focus-visible,
.ghost-button:focus-visible,
.icon-button:focus-visible,
.chip:focus-visible,
button:focus-visible {
  outline: 2.5px solid var(--primary);
  outline-offset: 2px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric-card,
.panel,
.lane,
.receipt-preview {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 132px;
  padding: 20px;
  border-top: 4px solid var(--primary);
}

.metric-card.coral {
  border-top-color: var(--coral);
}

.metric-card.indigo {
  border-top-color: var(--indigo);
}

.metric-card.amber {
  border-top-color: var(--amber);
}

.metric-card span,
.muted,
.service-list span,
.invoice-list span {
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 10px 0 4px;
  font-size: 30px;
}

.metric-card small {
  color: var(--primary-dark);
  font-weight: 700;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.panel-head.wide {
  align-items: flex-start;
}

.appointment-list,
.service-list,
.invoice-list {
  display: grid;
  gap: 12px;
}

.appointment-row,
.service-list div,
.invoice-list div {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.appointment-row[data-dashboard-appointment] {
  cursor: pointer;
}

.calendar-event[data-appointment-event] {
  cursor: pointer;
}

.appointment-row[data-dashboard-appointment]:hover {
  border-color: var(--primary);
  background: var(--acc-50);
}

.calendar-event[data-appointment-event]:hover {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  filter: saturate(1.05);
}

.appointment-list .visit-card {
  display: none;
}

.appointment-row time {
  color: var(--primary-dark);
  font-weight: 800;
}

.appointment-row span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.badge.arrived,
.calendar-event.arrived {
  color: #0f766e;
  background: #ccfbf1;
}

.badge.treatment,
.calendar-event.treatment {
  color: #5b21b6;
  background: #ede9fe;
}

.badge.scheduled,
.calendar-event.scheduled {
  color: #9a3412;
  background: #ffedd5;
}

.badge.queued,
.badge.reminder,
.calendar-event.queued,
.calendar-event.reminder {
  color: #0f766e;
  background: #dffdf7;
}

.badge.consult,
.calendar-event.consult {
  color: #0369a1;
  background: #e0f2fe;
}

.badge.payment,
.calendar-event.payment {
  color: #92400e;
  background: #fef3c7;
}

.badge.done,
.calendar-event.done {
  color: #475569;
  background: #e2e8f0;
}

.appointment-row.synced {
  border-color: var(--acc-200);
  background: var(--acc-50);
}

.calendar-event.selected {
  outline: 3px solid var(--primary);
  outline-offset: -3px;
}

.queue-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.queue-columns div {
  min-height: 160px;
  padding: 14px;
  background: #f8fafc;
  border-radius: 8px;
}

.queue-columns p {
  margin-bottom: 8px;
  padding: 9px;
  background: #ffffff;
  border-radius: 8px;
}

.queue-columns [data-dashboard-queue-item] {
  cursor: pointer;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.queue-columns [data-dashboard-queue-item]:hover {
  border-color: var(--primary);
  background: var(--acc-50);
}

/* Backup reminder banner — shows when last full backup > 7 days */
/* Force-hide for banners that carry inline `style="display: flex"` — without
   this, `banner.hidden = true` is overridden by the inline style and the
   banner stays visible even after admin clicks "จ่ายแล้ว" or "ภายหลัง". */
.line-quota-banner[hidden],
.backup-reminder-banner[hidden] { display: none !important; }

/* ─── PWA install banner ─────────────────────────────────────────────
   Shown when the browser advertises installability (Android Chrome fires
   beforeinstallprompt) OR when we detect iOS Safari (manual share-sheet
   instructions). Sits above all other content in the workspace. */
.pwa-install-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 12px 0;
  padding: 14px 18px;
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  border: 1px solid #c4b5fd;
  border-left: 4px solid #7c3aed;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.12);
}
.pwa-install-banner[hidden] { display: none !important; }
.pwa-install-banner .pwa-install-icon { font-size: 32px; flex: 0 0 32px; }
.pwa-install-banner .pwa-install-text { flex: 1; min-width: 0; }
.pwa-install-banner .pwa-install-text strong {
  display: block;
  color: #4c1d95;
  font-size: 15px;
  margin-bottom: 2px;
}
.pwa-install-banner .pwa-install-text span {
  display: block;
  color: #5b21b6;
  font-size: 13px;
}
.pwa-install-banner .pwa-install-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.pwa-install-banner .pwa-install-actions .primary-action {
  background: #7c3aed;
  border: none;
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 700;
}
@media (max-width: 600px) {
  .pwa-install-banner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .pwa-install-banner .pwa-install-actions {
    width: 100%;
  }
  .pwa-install-banner .pwa-install-actions button {
    flex: 1;
  }
}

.backup-reminder-banner {
  margin: 0 0 14px 0;
  padding: 14px 18px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #fcd34d;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.15);
  animation: backup-reminder-pulse 3s ease-in-out infinite;
}
@keyframes backup-reminder-pulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(245, 158, 11, 0.15); }
  50%      { box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35); }
}
.backup-reminder-content {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.backup-reminder-icon {
  font-size: 32px;
}
.backup-reminder-text {
  flex: 1;
  min-width: 200px;
}
.backup-reminder-text strong {
  display: block;
  color: #78350f;
  font-size: 15px;
}
.backup-reminder-text span {
  display: block;
  font-size: 12px;
  color: #92400e;
  margin-top: 2px;
}
.backup-reminder-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .backup-reminder-content { flex-direction: column; align-items: stretch; }
  .backup-reminder-actions { width: 100%; }
  .backup-reminder-actions button { flex: 1; }
}

/* LINE Users — NEW badge for follows within last 24h */
.line-new-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  font-size: 11px;
  font-weight: 700;
  margin-right: 6px;
  border: 1px solid #fcd34d;
  animation: line-new-pulse 2s ease-in-out infinite;
}
@keyframes line-new-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}
.line-user-row-new {
  background: #fffbeb;
}
.line-users-count-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  background: #16a34a;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  vertical-align: middle;
}
.welcome-message-config summary:hover {
  color: #15803d;
}

/* Service catalog table — 7 columns (name/category/price/df/recipe/status/actions) */
.service-table .table-row {
  grid-template-columns: minmax(160px, 1.6fr) minmax(90px, 0.8fr) minmax(90px, 0.7fr) minmax(80px, 0.7fr) minmax(150px, 1.3fr) minmax(110px, 0.9fr) minmax(110px, 0.9fr);
  align-items: center;
}
.service-table .table-row.head {
  font-weight: 700;
  color: var(--muted);
  font-size: 13px;
}
.service-table .service-row {
  transition: background 0.15s, transform 0.1s;
}
.service-table .service-row:hover {
  background: #f8fafc;
}
.service-table .service-row.muted strong {
  color: var(--muted);
  text-decoration: line-through;
}
.service-table .row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.service-table .row-actions button {
  padding: 4px 8px;
  min-height: 28px;
  font-size: 13px;
}
.service-table .row-actions .delete-row-button {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}
.service-table .recipe-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: #ede9fe;
  color: #5b21b6;
  font-size: 12px;
  font-weight: 600;
}
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  font-style: normal;
}
.status-active {
  background: #d1fae5;
  color: #065f46;
}
.status-review {
  background: #fef3c7;
  color: #92400e;
}
.status-inactive {
  background: #e5e7eb;
  color: #4b5563;
}
.service-catalog-summary {
  margin: 6px 0;
}
@media (max-width: 820px) {
  .service-table .table-row {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 8px;
  }
  .service-table .table-row.head { display: none; }
  .service-table .service-row > span {
    display: block;
  }
}

.dashboard-queue-remove {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(220, 38, 38, 0.25);
  background: rgba(254, 226, 226, 0.5);
  color: #b91c1c;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.dashboard-queue-remove:hover {
  background: #fee2e2;
  border-color: #dc2626;
  transform: scale(1.08);
}

.dashboard-queue-remove:active {
  transform: scale(0.95);
}

.chart-panel,
.service-panel {
  min-height: 240px;
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 12px;
  height: 170px;
  padding-top: 18px;
}

.bar-chart span {
  display: block;
  height: var(--value);
  min-height: 8px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, var(--indigo), var(--primary));
  position: relative;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.bar-chart span:hover { filter: brightness(1.1); }
/* Today's bar — gradient stays the same but adds a glow + thicker label so
   user can spot "วันนี้" at a glance even if revenue is 0. */
.bar-chart span[data-today="1"] {
  background: linear-gradient(180deg, #f59e0b, #d97706);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3), 0 4px 12px rgba(245, 158, 11, 0.35);
}
.bar-chart span[data-today="1"]::after {
  color: #b45309;
  font-weight: 800;
}
/* Day label under each bar (data-day = "อา" / "จ" / "อ" / ...) */
.bar-chart span::after {
  content: attr(data-day);
  position: absolute;
  bottom: -20px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.bar-chart { padding-bottom: 22px; }

/* Selected hour bar (drill-down) — orange highlight + ring */
.bar-chart span.bar-selected {
  background: linear-gradient(180deg, #f59e0b, #d97706);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.45), 0 6px 16px rgba(245, 158, 11, 0.4);
}
/* Selection summary at the TOP of the chart area (hour drill-down) */
.reports-selection-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  margin: 0 0 12px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-left: 4px solid #f97316;
  border-radius: 10px;
  font-size: 15px;
  color: #9a3412;
}
.reports-selection-summary[hidden] { display: none; }
.reports-selection-summary strong { color: #7c2d12; }

/* Amount label ABOVE each bar — only on the Reports chart (.with-values).
   Empty (฿0) bars carry an empty data-amount-label so nothing renders. */
.bar-chart.with-values { padding-top: 26px; }
.bar-chart.with-values span::before {
  content: attr(data-amount-label);
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 10px;
  font-weight: 700;
  color: var(--indigo, #6366f1);
  pointer-events: none;
}
/* Service-row layout for "บริการขายดี" — matches dashboard look */
.service-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 8px 12px;
  background: #f9fafb;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 13px;
}
.service-row strong { color: #0f172a; font-weight: 600; }
.service-row span { color: var(--muted); font-size: 12px; align-self: center; }

/* Reports summary KPI cards */
.report-summary-card {
  padding: 14px;
  background: linear-gradient(135deg, #fff, #f9fafb);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.report-summary-card span { color: var(--muted); font-size: 12px; }
.report-summary-card strong { font-size: 22px; color: var(--ink); }
.report-summary-card em { font-size: 11px; color: var(--muted); font-style: normal; }

/* Category eyebrow at the top of each KPI card */
.report-summary-card .card-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: var(--muted);
}
/* Month anchor card — indigo accent */
.report-summary-card.is-month {
  background: linear-gradient(135deg, #f5f3ff, #eef2ff);
  border-color: #c7d2fe;
}
.report-summary-card.is-month .card-eyebrow { color: #6366f1; }
.report-summary-card.is-month strong { color: #4338ca; }
/* Selected-day card — orange accent (matches the highlighted bar) */
.report-summary-card.is-day {
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border-color: #fdba74;
  border-left: 4px solid #f97316;
}
.report-summary-card.is-day .card-eyebrow { color: #ea580c; }
.report-summary-card.is-day strong { color: #c2410c; }

/* Cancel ✕ button on dashboard appointment rows — sits at the far right. */
.dashboard-appointment-cancel {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(220, 38, 38, 0.25);
  background: rgba(254, 226, 226, 0.5);
  color: #b91c1c;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-left: 8px;
  transition: background 0.15s, transform 0.1s;
}
.dashboard-appointment-cancel:hover {
  background: #fee2e2;
  border-color: #dc2626;
  transform: scale(1.08);
}
.dashboard-appointment-cancel:active { transform: scale(0.95); }

.service-list div,
.invoice-list div {
  grid-template-columns: minmax(0, 1fr) auto;
}

.calendar-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.chip,
.calendar-toolbar select {
  border: 1px solid var(--line);
  padding: 0 12px;
  background: #ffffff;
}

.chip.active {
  border-color: var(--primary);
  color: #ffffff;
  background: var(--primary);
}

.upload-chip {
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.upload-chip input {
  display: none;
}

.visually-hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  opacity: 0;
  overflow: hidden;
}

.print-tool-status {
  flex-basis: 100%;
  margin: 4px 0 0;
  font-weight: 800;
}

.calendar-grid {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.calendar-grid.calendar-mode-week,
.calendar-grid.calendar-mode-month {
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 0;
  overflow-x: auto;
}

.calendar-grid.calendar-mode-week > div,
.calendar-grid.calendar-mode-month > div {
  min-height: 150px;
  border-right: 1px solid var(--line);
}

.calendar-day-card,
.calendar-month-day {
  display: grid;
  align-content: start;
  gap: 8px;
  background: #ffffff;
}

.calendar-day-card strong,
.calendar-month-day strong {
  color: var(--ink);
}

.calendar-day-card small,
.calendar-month-day small {
  color: var(--muted);
  font-weight: 800;
}

.calendar-month-day.muted-day {
  background: #f8fafc;
  color: var(--muted);
}

.calendar-mini-event {
  display: block;
  padding: 7px 8px;
  border-radius: 7px;
  background: #ecfeff;
  color: #0f766e;
  font-size: 12px;
  font-weight: 900;
}

.appointment-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
}

.calendar-grid > div {
  min-height: 74px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.time-slot {
  color: var(--muted);
  background: #f8fafc;
  font-weight: 800;
}

.time-slot.locked,
.calendar-event.locked {
  color: #991b1b;
  background: #fef2f2;
}

.calendar-event {
  border-radius: 8px;
  font-weight: 800;
}

.attendance-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.attendance-row {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  background: #ffffff;
}

.attendance-row span {
  color: var(--muted);
  font-size: 13px;
}

.attendance-row.available {
  border-left: 4px solid var(--primary);
}

.attendance-row.unavailable {
  border-left: 4px solid var(--coral);
}

.recurring-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.recurring-panel section {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.recurring-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ffffff;
}

.recurring-row span {
  color: var(--muted);
}

.split-view,
.payment-layout,
.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.85fr);
  gap: 18px;
  align-items: start;
}

/* Sticky right detail panel — follows scroll so admin always sees selected customer */
#customers.view .split-view > .customer-profile {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  scrollbar-width: thin;
}
#customers.view .split-view > .customer-profile::-webkit-scrollbar { width: 6px; }
#customers.view .split-view > .customer-profile::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
#customers.view .split-view > .customer-profile::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 900px) {
  #customers.view .split-view > .customer-profile {
    position: static;
    max-height: none;
  }
}

.search-field {
  width: 100%;
  min-height: 42px;
  margin-bottom: 14px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.customer-workflow-guide {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.customer-workflow-guide > div {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.customer-workflow-guide .new {
  border-color: rgba(20, 184, 166, 0.45);
  background: var(--acc-50);
}

.customer-workflow-guide .returning {
  border-color: rgba(245, 158, 11, 0.45);
  background: #fffbeb;
}

.customer-workflow-guide strong {
  font-size: 0.95rem;
}

.customer-workflow-guide span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 750;
}

.customer-workflow-guide b {
  display: grid;
  flex: 0 0 24px;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--acc-bright);
}

.customer-workflow-guide .returning b {
  background: #f59e0b;
}

.data-table {
  display: grid;
  gap: 8px;
}

.customer-row > span:first-child {
  display: grid;
  gap: 2px;
  cursor: zoom-in;
}

.customer-row > span:first-child strong {
  color: var(--ink);
}

.customer-row > span:first-child em {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 850;
}

.save-status {
  display: block;
  margin-top: 3px;
  color: #0f766e;
  font-size: 0.82rem;
  font-weight: 850;
}

.table-row {
  display: grid;
  grid-template-columns: 1fr 1fr 0.8fr 0.7fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

#customers .table-row {
  grid-template-columns: 1fr 1fr 0.75fr 0.65fr auto;
  align-items: center;
}

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

.delete-row-button {
  min-height: 34px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 0 12px;
  color: #b91c1c;
  background: #fff5f5;
  font-weight: 900;
}

.delete-row-button:hover {
  border-color: #ef4444;
  background: #fee2e2;
}

.table-row.head {
  color: var(--muted);
  background: #f8fafc;
  font-weight: 800;
}

.table-row.selected {
  border-color: var(--primary);
  background: var(--acc-50);
}

.customer-row {
  cursor: pointer;
}

.customer-row > span:not(.row-actions) {
  cursor: zoom-in;
}

.customer-row:hover {
  border-color: rgba(20, 184, 166, 0.7);
  background: #f8fffd;
}

.customer-next-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

.selected-customer-next-step {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(20, 184, 166, 0.35);
  border-radius: 8px;
  color: #0f766e;
  background: var(--acc-50);
  font-weight: 800;
}

.products-table .table-row {
  grid-template-columns: 1.3fr 1fr 0.7fr 0.7fr 0.7fr;
}

.course-table .table-row {
  grid-template-columns: 1fr 1.3fr 0.7fr 0.9fr 0.7fr;
}

.table-row.warning {
  border-color: #f59e0b;
  background: #fffbeb;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--coral);
  font-weight: 900;
  font-size: 22px;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar.has-photo { background: #f1f5f9; padding: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.profile-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.tabs,
.payment-methods {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tabs button {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: #eef2f7;
}

.tabs button.active {
  color: #ffffff;
  background: var(--ink);
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.consent-status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.consent-status-strip div,
.consent-rule-list div,
.media-guard-banner {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.consent-status-strip span,
.consent-rule-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.consent-status-strip .safe,
.consent-rule-list .safe {
  border-color: var(--acc-200);
  background: #ecfeff;
}

.consent-status-strip .blocked,
.consent-rule-list .blocked,
.media-guard-banner {
  border-color: #fecaca;
  background: #fef2f2;
}

.consent-rule-list .warning {
  border-color: #fde68a;
  background: #fffbeb;
}

.media-guard-banner {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
  color: #991b1b;
}

.media-guard-banner span {
  color: #7f1d1d;
}

.integration-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.wallet-summary {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.wallet-summary span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.followup-panel {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.customer-care-strip {
  display: grid;
  grid-template-columns: 1.35fr 0.65fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.customer-care-strip div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.customer-care-strip span,
.timeline-item time {
  color: var(--muted);
  font-weight: 800;
}

.timeline-panel,
.case-gallery {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.timeline-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: #f8fafc;
}

.timeline-item div {
  display: grid;
  gap: 4px;
}

.timeline-item span,
.timeline-item em {
  color: var(--muted);
  font-style: normal;
}

.case-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.case-grid div {
  position: relative;
  display: grid;
  align-content: end;
  aspect-ratio: 1 / 1;
  min-height: 0;
  overflow: hidden;
  padding: 12px;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  background: linear-gradient(135deg, #f8fafc, #eef2ff);
}

.case-grid img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.case-grid span {
  position: relative;
  color: var(--ink);
  font-weight: 900;
  z-index: 1;
}

.case-grid strong {
  position: relative;
  color: var(--muted);
  font-size: 12px;
  z-index: 1;
}

.case-grid em {
  position: relative;
  color: #64748b;
  font-size: 11px;
  font-style: normal;
  line-height: 1.35;
  z-index: 1;
}

.case-gallery-item:has(img) {
  border: 0;
  background: linear-gradient(180deg, transparent 35%, rgba(15, 23, 42, 0.76));
}

.case-gallery-item:has(img) span,
.case-gallery-item:has(img) strong,
.case-gallery-item:has(img) em {
  color: #ffffff;
  text-shadow: 0 1px 4px rgba(15, 23, 42, 0.55);
}

.timeline-drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  justify-items: end;
  pointer-events: none;
  background: rgba(15, 23, 42, 0);
  transition: background 0.2s ease;
}

.timeline-drawer.show {
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.28);
}

.drawer-panel {
  width: min(680px, 100%);
  height: 100%;
  overflow: auto;
  padding: 22px;
  background: #ffffff;
  box-shadow: -18px 0 40px rgba(15, 23, 42, 0.18);
  transform: translateX(100%);
  transition: transform 0.2s ease;
}

.timeline-drawer.show .drawer-panel {
  transform: translateX(0);
}

.timeline-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.drawer-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.drawer-summary div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.drawer-summary span {
  color: var(--muted);
  font-weight: 800;
}

.drawer-timeline {
  display: grid;
  gap: 12px;
}

.drawer-event {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: #ffffff;
}

.drawer-event time,
.drawer-event span,
.drawer-event em {
  color: var(--muted);
  font-style: normal;
}

.followup-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ffffff;
}

.followup-row span {
  color: var(--muted);
}

.followup-row.warning {
  color: #991b1b;
  background: #fef2f2;
}

.profile-stats div,
.note-box,
.integration-strip div,
.line-preview {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.integration-strip div,
.line-preview {
  background: #f8fafc;
}

.profile-stats span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.integration-strip span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(6, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.lane {
  min-height: 300px;
  padding: 12px;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.lane.empty {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.lane.empty::after {
  content: "ไม่มีคิว";
  display: grid;
  min-height: 72px;
  place-items: center;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: #94a3b8;
  font-weight: 850;
}

.lane.drag-over {
  border-color: rgba(20, 184, 166, 0.65);
  background: var(--acc-50);
  box-shadow: inset 0 0 0 2px rgba(20, 184, 166, 0.18);
}

.lane h2 {
  font-size: 1.05rem;
}

.visit-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  cursor: grab;
  user-select: none;
  position: relative;
  transition: opacity 0.18s, transform 0.18s;
  /* Allow vertical scroll on iPad but capture drag for our pointer handler.
     We block scroll only AFTER a drag actually starts (via .dragging class). */
  touch-action: pan-y;
}
.visit-card.dragging {
  /* During an active drag, block scroll so finger movement is interpreted as drag */
  touch-action: none;
}
.queue-card-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  z-index: 2;
}
.queue-card-remove:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}
.queue-assignment {
  display: block;
  font-size: 12px;
  font-style: normal;
  color: #475569;
  background: #f1f5f9;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
}
.queue-card-removing {
  opacity: 0;
  transform: translateX(20px) scale(0.95);
  pointer-events: none;
}

/* Queue assignment modal */
.queue-assign-form { display: grid; gap: 12px; max-height: 70vh; overflow-y: auto; padding-right: 4px; }
.queue-assign-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  padding: 10px 12px;
  background: linear-gradient(135deg, #eef2ff 0%, #ecfeff 100%);
  border-radius: 8px;
  font-size: 13px;
}
.queue-assign-head strong { font-size: 15px; }

/* ─── iOS Cloud Diagnostic Modal (task #252) ──────────────────────── */
.ios-diagnostic-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px 16px;
  overflow-y: auto;
}
.ios-diagnostic-card {
  background: #fff;
  border-radius: 14px;
  padding: 18px 20px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 24px 48px -8px rgba(15, 23, 42, 0.45);
  display: grid;
  gap: 12px;
}
.ios-diagnostic-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}
.ios-diagnostic-head strong { font-size: 15px; color: #0f172a; }
.ios-diagnostic-meta {
  font-size: 11px;
  color: #64748b;
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 6px;
  line-height: 1.6;
}
.ios-diagnostic-meta code {
  background: #fff;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  color: #475569;
  word-break: break-all;
  font-size: 11px;
}
.ios-diagnostic-rows {
  display: grid;
  gap: 8px;
}
.ios-diagnostic-row {
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}
.ios-diagnostic-note {
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
  word-break: break-all;
  font-family: ui-monospace, monospace;
}
.ios-diagnostic-error {
  font-size: 11px;
  color: #b91c1c;
  background: #fef2f2;
  border-radius: 4px;
  padding: 4px 6px;
  margin-top: 4px;
  font-family: ui-monospace, monospace;
  word-break: break-all;
}
.ios-diagnostic-running {
  text-align: center;
  color: #64748b;
  font-size: 12px;
  padding: 8px;
}
.ios-diagnostic-summary {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.ios-diagnostic-summary.success {
  background: #d1fae5;
  border: 1px solid #6ee7b7;
  color: #065f46;
}
.ios-diagnostic-summary.warning {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  color: #92400e;
}
.ios-diagnostic-summary.error {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}
.ios-diagnostic-summary code {
  background: #fff;
  padding: 1px 4px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}
.ios-diagnostic-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ios-diagnostic-actions button { flex: 1; min-width: 140px; }
@media (max-width: 480px) {
  .ios-diagnostic-actions { flex-direction: column; }
  .ios-diagnostic-actions button { width: 100%; }
}

/* ─── Cloud Pull Recovery Alert (task #251) ──────────────────────── */
#cloudPullRecoveryAlert {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  max-width: 540px;
  width: calc(100vw - 24px);
  box-sizing: border-box;
}
.cloud-recovery-card {
  background: #fff5f5;
  border: 2px solid #f87171;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 12px 36px -8px rgba(239, 68, 68, 0.35);
  display: grid;
  gap: 10px;
}
.cloud-recovery-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.cloud-recovery-head strong {
  color: #b91c1c;
  font-size: 15px;
}
.cloud-recovery-detail {
  background: #fff;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  display: grid;
  gap: 4px;
  color: #374151;
}
.cloud-recovery-detail code {
  background: #fef2f2;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  color: #b91c1c;
  word-break: break-all;
}
.cloud-recovery-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.cloud-recovery-actions button { flex: 1; min-width: 120px; }

@media (max-width: 480px) {
  .cloud-recovery-actions { flex-direction: column; }
  .cloud-recovery-actions button { width: 100%; }
}

/* ─── Topbar Version Chip — single-line + truncate (task #251) ─────── */
.topbar-version-chip {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: middle;
  line-height: 1.4;
}
.topbar-version-chip:hover { background: #e2e8f0; color: #1e293b; }

@media (max-width: 768px) {
  .topbar-version-chip {
    max-width: 90px;
    font-size: 10px;
    padding: 3px 7px;
  }
}
@media (max-width: 480px) {
  .topbar-version-chip {
    max-width: 70px;
  }
}

/* ─── Mobile overflow guards (topbar + banner buttons) ─────────────── */
@media (max-width: 600px) {
  .topbar-actions {
    flex-wrap: wrap;
    width: 100%;
    justify-content: flex-end;
    gap: 6px;        /* tighter from 10px so small chips fit one row */
    align-items: center;
  }
  .topbar-actions > * {
    max-width: 100%;
  }
  /* Small chips never grow/shrink — stay compact + cluster together */
  #topbarUserChip,
  #appVersionChip,
  .cloud-sync-badge,
  .topbar-actions > .icon-button {
    flex: 0 0 auto;
  }
  /* User chip on mobile: tighter padding so Dr.Golf + role pill fit in less width */
  .topbar-user-chip { padding: 4px 8px; font-size: 12px; gap: 6px; }
  .topbar-user-chip-avatar { width: 22px; height: 22px; font-size: 10px; }
  /* HIDE role label ("Super Admin", "Doctor", etc.) inside the user chip on
     mobile — saves ~70px so the cloud sync chip can join row 1 instead of
     wrapping alone. Role is still discoverable via the chip's title attribute
     and via the "👥 สลับ" button next to it. */
  .topbar-user-chip span:nth-child(3) { display: none !important; }
  /* Cap user name width — if someone's name is very long it would still push
     other chips off the row. Truncate with ellipsis. */
  .topbar-user-chip span:nth-child(2) {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* Icon buttons (🔒 ⌕ !) → smaller so 3+ can share row */
  .topbar-actions > .icon-button { width: 36px; min-height: 36px; font-size: 16px; }
  /* Branch selector takes its OWN row (full width) — it carries long Thai text
     "พัทยา (สำนักงานใหญ่)" and benefits from not being squished into a chip cluster. */
  #branchSelector {
    flex: 1 1 100%;
    min-height: 36px;
    padding: 0 10px;
    font-size: 13px;
  }
  /* "เปิด Visit" CTA stays compact, never grows */
  .topbar-actions > .primary-action {
    flex: 0 0 auto;
    padding: 0 14px;
    min-height: 36px;
    font-size: 13px;
  }
  /* LINE quota banner + backup banner: stack buttons full-width on mobile */
  .line-quota-banner > div:last-child,
  .backup-reminder-actions {
    width: 100%;
  }
  .line-quota-banner > div:last-child button,
  .backup-reminder-actions button {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }
  .workspace {
    padding: 14px;
    max-width: 100%;
    overflow-x: hidden;
  }
  .topbar h1 { font-size: 24px; }
}

/* ─── Pre-Print Vitals Quick-Fill Modal (task #250) ──────────────────── */
.vitals-quickfill-form {
  display: grid;
  gap: 12px;
  max-height: 75vh;
  overflow-y: auto;
  padding-right: 4px;
}
.vitals-quickfill-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #fbbf24;
  border-radius: 10px;
}
.vitals-quickfill-banner strong { color: #92400e; font-size: 14px; }
.vitals-quickfill-banner p { color: #92400e; }

.vitals-section {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}
.vitals-section-title {
  font-weight: 700;
  font-size: 13px;
  padding-bottom: 6px;
  border-bottom: 1px dashed #e2e8f0;
}
.vitals-section-title.required { color: #b91c1c; }
.vitals-section-title.warning { color: #92400e; }

.vitals-status-bad {
  display: inline-block;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 700;
  margin-left: 4px;
  vertical-align: middle;
}
.vitals-status-warn {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 700;
  margin-left: 4px;
  vertical-align: middle;
}

.vitals-consent-notice {
  padding: 10px 12px;
  background: #eff6ff;
  border: 1px dashed #93c5fd;
  border-radius: 8px;
  color: #1e40af;
  font-size: 12px;
  line-height: 1.5;
}

.vitals-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 4px;
}

.vitals-override-btn {
  background: #fff;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.vitals-override-btn:hover {
  background: #fee2e2;
  border-color: #ef4444;
}
.vitals-override-btn.vitals-override-armed {
  background: #dc2626;
  color: #fff;
  border-color: #b91c1c;
  animation: vitals-override-pulse 0.6s ease-in-out infinite alternate;
}
@keyframes vitals-override-pulse {
  from { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  to { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

@media (max-width: 640px) {
  .vitals-actions { flex-direction: column-reverse; }
  .vitals-actions button { width: 100%; }
}

.visit-card:active {
  cursor: grabbing;
}

.visit-card.dragging {
  opacity: 0.55;
  transform: scale(0.99);
}

.visit-card.active {
  border-color: var(--indigo);
  background: #eef2ff;
  box-shadow: 0 0 0 2px rgba(91, 95, 199, 0.08);
}

.visit-card.opd-open {
  border-color: var(--primary);
  background: var(--acc-50);
}

.visit-card.ready-payment {
  border-color: #f59e0b;
  background: #fffbeb;
}

.visit-card.ready-payment::before {
  content: "รอชำระเงิน";
  width: fit-content;
  padding: 2px 8px;
  border-radius: 999px;
  color: #92400e;
  background: #fef3c7;
  font-size: 12px;
  font-weight: 900;
}

.visit-card.opd-open::before {
  content: "OPD active";
  width: fit-content;
  padding: 2px 8px;
  border-radius: 999px;
  color: #0f766e;
  background: #ccfbf1;
  font-size: 12px;
  font-weight: 900;
}

.visit-card span {
  color: var(--muted);
}

.visit-card .queue-hn {
  width: fit-content;
  padding: 1px 7px;
  border-radius: 999px;
  color: #475569;
  background: #f1f5f9;
  font-size: 11px;
  font-weight: 900;
}

.visit-card .queue-meta {
  color: #64748b;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.visit-card .queue-handler {
  display: block;
  width: fit-content;
  margin-top: 2px;
  padding: 2px 8px;
  border-radius: 999px;
  color: #3730a3;
  background: #eef2ff;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}

/* ── OPD warning banner — terminal / typewriter look ────────────────── */
.opd-warning-banner {
  /* block (not flex) so the cursor flows inline right after the last character
     even when the text wraps to 2 lines — flex was floating it to the far right
     as a stray "dash". */
  display: block;
  margin-bottom: 14px;
  padding: 16px 20px;
  border-radius: 12px;
  background-color: #0c0f14;
  background-image: radial-gradient(rgba(148, 163, 184, 0.18) 1px, transparent 1px);
  background-size: 22px 22px;
  border: 1px solid #1f2733;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02), 0 6px 20px rgba(0, 0, 0, 0.25);
  /* Single Thai+Latin family so ไทย and อังกฤษ render at the SAME weight. The
     old mono stack made Latin use DejaVu Mono and Thai fall back to a different
     system font → uneven boldness. */
  font-family: "Sarabun", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 800;
  font-size: clamp(18px, 2.6vw, 30px);
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: #e8edf4;
  overflow-wrap: anywhere;
}
.opd-warning-banner .owb-text {
  white-space: pre-wrap;
}
.opd-warning-banner .owb-cursor {
  display: inline;
  margin-left: 3px;
  color: #84cc16;
  font-weight: 800;
  animation: owb-blink 1s steps(1) infinite;
}
@keyframes owb-blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}
.opd-warning-banner.owb-preview {
  margin-bottom: 0;
  font-size: clamp(15px, 2vw, 22px);
  padding: 14px 18px;
}

/* Compact variant — sits inline in the top bar (between page title and the
   action chips) so it doesn't eat a tall full-width row. Wraps if needed so
   bigger sizes still show the full message. Font-size comes from .owb-size-*. */
.opd-warning-banner.owb-compact {
  flex: 1 1 auto;
  min-width: 0;
  margin-bottom: 0;
  padding: 10px 18px;
  border-radius: 12px;
  line-height: 1.25;
  white-space: normal;
  overflow: hidden;
}
.opd-warning-banner.owb-compact .owb-text {
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Staff-adjustable size — applied to header banner AND the settings preview.
   Declared LAST so it wins over .owb-compact / .owb-preview base font-size. */
.opd-warning-banner.owb-size-sm { font-size: 16px; }
.opd-warning-banner.owb-size-md { font-size: 20px; }
.opd-warning-banner.owb-size-lg { font-size: 25px; }
.opd-warning-banner.owb-size-xl { font-size: 31px; }

@media (max-width: 768px) {
  .opd-warning-banner {
    padding: 12px 14px;
  }
  /* On phones the topbar stacks — the warning becomes a clean full-width strip
     directly under the page title (NOT shoved below the action chips). Natural
     DOM order (title → banner → actions) + flex-basis:100% places it there. */
  .opd-warning-banner.owb-compact {
    flex-basis: 100%;
    order: 0;
    text-align: center;
    padding: 12px 16px;
  }
  /* Cap the very largest size a touch on phones so it doesn't dominate */
  .opd-warning-banner.owb-size-lg { font-size: 22px; }
  .opd-warning-banner.owb-size-xl { font-size: 26px; }
}

/* OPD warning settings — toggle row */
.opd-warning-settings .owb-toggle-field {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-direction: row;
}
.opd-warning-settings .owb-toggle-field input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex: none;
}
.opd-warning-settings textarea {
  width: 100%;
  font-family: inherit;
  resize: vertical;
}
.opd-warning-settings .owb-color-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}
.opd-warning-settings .owb-color-field input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 2px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
}

.visit-card .queue-zone {
  width: fit-content;
  padding: 2px 8px;
  border-radius: 999px;
  color: #0f766e;
  background: #ccfbf1;
  font-size: 12px;
  font-weight: 900;
}

.visit-card .doctor-line-badge {
  width: fit-content;
  padding: 3px 8px;
  border-radius: 999px;
  color: #166534;
  background: #dcfce7;
  font-size: 12px;
  font-weight: 900;
}

.visit-card button {
  border: 1px solid var(--line);
  background: #f8fafc;
}

.visit-card button + button {
  margin-top: 2px;
}

.visit-card.opd-open button {
  color: #0f766e;
  background: #ecfeff;
}

.visit-card.status-consult {
  border-color: #38bdf8;
  background: #f0f9ff;
}

.visit-card.status-numbing {
  border-color: #f59e0b;
  background: #fffbeb;
}

.visit-card.status-treatment {
  border-color: var(--indigo);
  background: #eef2ff;
}

.visit-card.status-recovery {
  border-color: var(--acc-bright);
  background: var(--acc-50);
}

.visit-card.status-payment {
  border-color: #f59e0b;
  background: #fffbeb;
}

.opd-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.required-star {
  color: #dc2626;
  font-style: normal;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
}

textarea {
  min-height: 120px;
  padding: 12px;
  resize: vertical;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

.field-invalid {
  border-color: #dc2626 !important;
  background: #fff1f2 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.photo-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  grid-column: 1 / -1;
}

.photo-strip div {
  display: grid;
  place-items: center;
  min-height: 160px;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  color: var(--muted);
  background: #f8fafc;
  font-weight: 800;
}

.facechart-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.75fr) minmax(260px, 0.45fr);
  gap: 16px;
  margin-top: 16px;
}

.opd-start-guide {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.opd-start-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.opd-start-flow {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
}

.opd-start-flow h3 {
  margin: 0 0 4px;
}

.opd-start-flow div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 4px 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 8px;
  background: #ffffff;
}

.opd-start-flow span {
  grid-column: 1;
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #ffffff;
  font-weight: 900;
}

.opd-start-flow strong {
  grid-column: 2;
  grid-row: 1;
  color: #111827;
}

.opd-start-flow em {
  grid-column: 2;
  grid-row: 2;
  color: #64748b;
  font-size: 12px;
  font-style: normal;
}

.opd-start-flow button {
  grid-column: 3;
  grid-row: 1 / span 2;
  min-width: 118px;
}

.opd-start-flow.new-patient {
  border-color: rgba(20, 184, 166, 0.55);
  background: var(--acc-50);
}

.opd-start-flow.new-patient span {
  background: var(--acc-bright);
}

.opd-start-flow.returning-patient {
  border-color: rgba(245, 158, 11, 0.55);
  background: #fffbeb;
}

.opd-start-flow.returning-patient span {
  background: #f59e0b;
}

.opd-print-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.opd-print-tools h3 {
  margin: 0 0 4px;
}

.print-preset-note {
  margin-top: 4px;
  font-size: 12px;
}

.hybrid-opd-flow,
.pdpa-consent-panel,
.opd-card-pack-panel,
.opd-day-workflow,
.opd-complete-panel,
.opd-admin-worklist,
.opd-cloud-panel,
.opd-status-board,
.paper-folder-panel,
.opd-posting-panel,
.opd-evidence-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.opd-day-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.opd-day-grid div {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  min-height: 104px;
  padding: 12px;
  border: 1px solid #d7e1ef;
  border-radius: 8px;
  background: #f8fafc;
}

.opd-day-grid span {
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(14, 116, 144, 0.25);
  border-radius: 50%;
  color: #0f766e;
  background: #ecfeff;
  font-weight: 900;
}

.opd-day-grid strong {
  color: #111827;
  font-size: 15px;
}

.opd-day-grid em {
  color: #64748b;
  font-style: normal;
  line-height: 1.45;
}

.opd-day-note {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(20, 184, 166, 0.4);
  border-radius: 8px;
  background: var(--acc-50);
  color: #0f172a;
}

.opd-day-note span {
  color: #475569;
}

.opd-action-center {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  gap: 10px 14px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid rgba(109, 61, 142, 0.22);
  border-radius: 10px;
  background: #faf5ff;
}

.opd-action-summary {
  display: grid;
  gap: 5px;
  grid-row: 1 / span 2;
  align-self: start;
  padding: 10px 12px;
  border-right: 1px solid rgba(109, 61, 142, 0.15);
}

.opd-action-summary span,
.opd-action-summary em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.opd-action-summary > span:first-child {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  font-weight: 800;
  color: var(--primary);
  opacity: 0.7;
}

.opd-action-summary strong {
  color: var(--primary-dark);
  font-size: 0.92rem;
  line-height: 1.3;
}

.opd-progress {
  display: grid;
  gap: 5px;
  margin-top: 6px;
}

.opd-progress > span {
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.opd-progress > strong {
  display: block;
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(109, 61, 142, 0.15);
}

.opd-progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #cb2bb8);
  transition: width 280ms cubic-bezier(.4,0,.2,1);
}

.opd-steps-hint {
  grid-column: 2;
  margin: 0;
  font-size: 12px;
  color: var(--primary-dark);
  background: rgba(109, 61, 142, 0.06);
  border: 1px dashed rgba(109, 61, 142, 0.3);
  border-radius: 8px;
  padding: 8px 11px;
  line-height: 1.45;
  align-self: start;
}

.opd-action-buttons {
  display: grid;
  grid-column: 2;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.opd-action-buttons button {
  min-height: 44px;
}

.opd-action-buttons button[data-opd-step-button] {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 62px;
  padding: 8px 6px 6px;
  border: 1.5px solid #e2e8f0;
  border-radius: 9px;
  color: var(--ink);
  background: #ffffff;
  box-shadow: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

/* Real navigation affordance */
.opd-action-buttons button[data-opd-step-button]:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 16px rgba(109, 61, 142, 0.18);
  border-color: var(--primary);
  background: #faf5ff;
}
.opd-action-buttons button[data-opd-step-button]:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
}

.opd-action-buttons button[data-opd-step-button]::after {
  content: attr(data-step-status);
  display: block;
  margin-top: 3px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.15;
  opacity: 0.85;
  letter-spacing: 0.01em;
}

/* ── Done: purple filled (on-brand) ─────────────────────── */
.opd-action-buttons button.step-done {
  border-color: var(--primary);
  color: #ffffff;
  background: var(--primary);
}
.opd-action-buttons button.step-done:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: 0 4px 14px rgba(109, 61, 142, 0.3);
}

/* ── Next: pink pulse ──────────────────────────────────── */
.opd-action-buttons button.step-next {
  border-color: #db2777;
  border-width: 2px;
  color: #9d174d;
  background: #fff0f7;
  box-shadow: 0 0 0 3px rgba(219, 39, 119, 0.08);
  animation: opdStepPulse 1.8s ease-in-out infinite;
}
.opd-action-buttons button.step-next:hover {
  animation: none;
  background: #fce7f3;
  box-shadow: 0 4px 14px rgba(219, 39, 119, 0.25);
}
@keyframes opdStepPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(219, 39, 119, 0.10); }
  50%       { box-shadow: 0 0 0 7px rgba(219, 39, 119, 0.18); }
}
@media (prefers-reduced-motion: reduce) {
  .opd-action-buttons button.step-next { animation: none; }
}

/* ── Waiting: muted ──────────────────────────────────────── */
.opd-action-buttons button.step-waiting {
  border-color: #e9edf3;
  color: #94a3b8;
  background: #f8fafc;
  cursor: default;
}
.opd-action-buttons button.step-waiting:hover {
  transform: none;
  box-shadow: none;
  border-color: #e9edf3;
  background: #f8fafc;
}

/* ── Blocked: soft red ──────────────────────────────────── */
.opd-action-buttons button.step-blocked {
  border-color: #fca5a5;
  border-width: 2px;
  color: #b91c1c;
  background: #fff5f5;
}
.opd-action-buttons button.step-blocked:hover {
  background: #fee2e2;
  border-color: #f87171;
  box-shadow: 0 3px 12px rgba(185, 28, 28, 0.18);
}

.opd-status-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  grid-column: 1 / -1;
  padding-top: 6px;
  border-top: 1px solid rgba(109, 61, 142, 0.12);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.opd-status-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.opd-status-legend i {
  width: 12px;
  height: 12px;
  border: 1px solid #dbe3ef;
  border-radius: 999px;
  background: #ffffff;
}

.opd-status-legend .legend-done {
  border-color: var(--primary);
  background: var(--primary);
}

.opd-status-legend .legend-next {
  border-color: #db2777;
  background: #fff0f7;
}

.opd-status-legend .legend-waiting {
  border-color: #e2e8f0;
  background: #f8fafc;
}

.opd-status-legend .legend-blocked {
  border-color: #fca5a5;
  background: #fff5f5;
}

.opd-document-guard,
.opd-readiness-panel,
.opd-cloud-controls-panel,
.opd-integration-panel,
.opd-safety-panel,
.opd-production-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.opd-document-grid,
.opd-readiness-grid,
.opd-nonline-summary,
.opd-control-grid,
.opd-integration-grid,
.opd-safety-grid,
.opd-production-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.opd-document-grid button,
.opd-nonline-summary div,
.opd-control-grid button,
.opd-integration-grid button,
.opd-safety-grid button,
.opd-production-grid button,
.opd-readiness-grid div,
.opd-audit-list div,
.opd-pilot-grid div,
.opd-mini-log div {
  display: grid;
  gap: 4px;
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  text-align: left;
}

.opd-document-grid button,
.opd-control-grid button {
  cursor: pointer;
}

.opd-integration-grid button {
  cursor: pointer;
}

.opd-safety-grid button {
  cursor: pointer;
}

.opd-production-grid button {
  cursor: pointer;
}

.opd-document-grid button.done,
.opd-nonline-summary div.done,
.opd-control-grid button.done,
.opd-integration-grid button.done,
.opd-safety-grid button.done,
.opd-production-grid button.done,
.opd-readiness-grid div.done,
.opd-pilot-grid div.done,
.opd-mini-log div.done {
  border-color: rgba(15, 118, 110, 0.45);
  background: var(--acc-50);
}

.opd-document-grid button.missing,
.opd-nonline-summary div.pending,
.opd-control-grid button.missing,
.opd-integration-grid button.missing,
.opd-safety-grid button.missing,
.opd-production-grid button.missing,
.opd-readiness-grid div.pending,
.opd-pilot-grid div.pending,
.opd-mini-log div.pending {
  border-color: #fecaca;
  background: #fff5f5;
}

.opd-control-grid button.missing.soon {
  border-color: #fed7aa;
  background: #fff7ed;
}

.opd-control-grid button.missing.normal {
  border-color: #dbe4ef;
  background: #f8fafc;
}

.opd-document-grid span,
.opd-nonline-summary span,
.opd-control-grid span,
.opd-integration-grid span,
.opd-safety-grid span,
.opd-production-grid span,
.opd-readiness-grid span,
.opd-audit-list span,
.opd-pilot-grid span,
.opd-mini-log span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.opd-document-grid button.done span,
.opd-nonline-summary div.done span,
.opd-control-grid button.done span,
.opd-integration-grid button.done span,
.opd-safety-grid button.done span,
.opd-production-grid button.done span,
.opd-readiness-grid div.done span,
.opd-pilot-grid div.done span,
.opd-mini-log div.done span {
  color: #0f766e;
}

.opd-document-grid button.missing span,
.opd-nonline-summary div.pending span,
.opd-control-grid button.missing span,
.opd-integration-grid button.missing span,
.opd-safety-grid button.missing span,
.opd-production-grid button.missing span,
.opd-readiness-grid div.pending span,
.opd-pilot-grid div.pending span,
.opd-mini-log div.pending span {
  color: #b91c1c;
}

.opd-document-grid strong,
.opd-nonline-summary strong,
.opd-control-grid strong,
.opd-integration-grid strong,
.opd-safety-grid strong,
.opd-production-grid strong,
.opd-readiness-grid strong,
.opd-audit-list strong,
.opd-pilot-grid strong,
.opd-mini-log strong {
  color: var(--ink);
}

.opd-document-grid em,
.opd-nonline-summary em,
.opd-control-grid em,
.opd-integration-grid em,
.opd-safety-grid em,
.opd-production-grid em,
.opd-readiness-grid em,
.opd-audit-list em,
.opd-pilot-grid em,
.opd-mini-log em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.45;
}

.opd-audit-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.opd-audit-list div {
  min-height: auto;
  grid-template-columns: 130px minmax(0, 0.8fr) minmax(0, 1fr);
  align-items: center;
}

.opd-audit-list em {
  text-align: right;
}

.opd-pilot-panel {
  margin-top: 14px;
}

.opd-pilot-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.opd-pilot-grid div {
  min-height: 74px;
}

.opd-cloud-ops-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.opd-cloud-ops-grid section {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.opd-mini-log {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.opd-mini-log div {
  min-height: 68px;
}

.opd-payload-preview {
  min-height: 220px;
  max-height: 360px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #172033;
  background: #f8fafc;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.opd-attention {
  animation: opdAttention 1.8s ease;
}

@keyframes opdAttention {
  0%,
  100% {
    box-shadow: none;
  }
  20%,
  65% {
    box-shadow: 0 0 0 4px rgba(203, 43, 184, 0.18);
  }
}

.opd-visit-meta-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.opd-visit-meta-grid div {
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.opd-visit-meta-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.opd-visit-meta-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 0.95rem;
}

.opd-tabs {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding: 0 2px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.opd-tabs button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  color: #0f766e;
  background: #f8fafc;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
}

.opd-tabs button.active {
  color: var(--ink);
  background: #ffffff;
  border-color: rgba(203, 43, 184, 0.55);
  box-shadow: inset 0 -3px 0 var(--primary);
}

.opd-tab-panel {
  display: none !important;
}

.opd-tab-panel.active {
  display: block !important;
}

.opd-print-tools.opd-tab-panel.active {
  display: flex !important;
}

.opd-evidence-panel.opd-tab-panel.active,
.opd-admin-entry.opd-tab-panel.active,
.opd-grid.opd-tab-panel.active,
.facechart-layout.opd-tab-panel.active,
.photo-gallery.opd-tab-panel.active {
  display: grid !important;
}

.opd-print-preview-panel.opd-tab-panel.active {
  display: grid !important;
  gap: 14px;
}

.opd-completion-grid > div.active-step {
  border-color: rgba(203, 43, 184, 0.7);
  background: #fdf2f8;
  box-shadow: 0 0 0 2px rgba(203, 43, 184, 0.08);
}

.opd-completion-grid > div.active-step span {
  background: var(--primary);
}

.evidence-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.upload-dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 210px;
  padding: 18px;
  border: 2px dashed #94a3b8;
  border-radius: 8px;
  color: #475569;
  background: #ffffff;
  text-align: center;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.upload-dropzone strong {
  color: #334155;
  font-size: 1.05rem;
}

.upload-dropzone span,
.upload-dropzone em {
  color: #64748b;
  font-style: normal;
  line-height: 1.45;
}

.upload-dropzone img {
  max-width: 100%;
  max-height: 260px;
  border-radius: 8px;
  object-fit: contain;
}

.upload-dropzone.drag-over,
.upload-dropzone.upload-focus {
  border-color: var(--acc-bright);
  background: var(--acc-50);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.12);
}

.upload-dropzone.unsupported {
  border-color: #ef4444;
  background: #fff5f5;
}

.upload-dropzone.unsupported strong,
.upload-dropzone.unsupported span {
  color: #b91c1c;
}

.remove-upload-button {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  min-height: 32px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 0 10px;
  color: #b91c1c;
  background: #fff5f5;
  font-weight: 900;
  cursor: pointer;
}

.remove-upload-button:hover {
  border-color: #ef4444;
  background: #fee2e2;
}

.photo-dropzone {
  min-height: 160px;
}

.opd-admin-decision {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.8fr;
  gap: 10px;
  margin-top: 12px;
}

.opd-admin-decision div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.opd-admin-decision span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.opd-admin-decision strong {
  display: block;
  margin-top: 4px;
}

.opd-return-queue {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-left: 4px solid #94a3b8;
  border-radius: 8px;
  background: #f8fafc;
}

.opd-return-queue.pending {
  border-left-color: var(--amber);
  background: #fffbeb;
}

.opd-return-queue.overdue {
  border-left-color: var(--coral);
  background: #fef2f2;
}

.opd-return-queue.ready {
  border-left-color: var(--acc-bright);
  background: var(--acc-50);
}

.opd-return-queue div {
  display: grid;
  gap: 4px;
}

.opd-return-queue span,
.opd-return-queue em,
.opd-return-queue small {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.opd-return-queue small {
  font-weight: 800;
}

.opd-return-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.opd-return-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.opd-return-metrics div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.opd-return-metrics span,
.opd-return-metrics em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.pdpa-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.pdpa-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.pdpa-grid select,
.pdpa-grid input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
}

.pdpa-preview {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: var(--ink);
  background: #f8fafc;
  line-height: 1.55;
}

.workflow-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.opd-completion-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.opd-pack-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

/* ── ICD-10-TM Diagnosis picker ───────────────────────────────────────────── */
.opd-diagnosis-block {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.opd-optional-tag {
  display: inline-block;
  margin-left: 8px;
  vertical-align: middle;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 2px 9px;
  letter-spacing: 0.2px;
}
.icd-picker-wrap {
  position: relative;
  margin-top: 10px;
}
.icd-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.icd-search-input {
  flex: 1;
  padding: 7px 11px;
  border: 1.5px solid var(--border, #e5e7eb);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface, #fff);
  color: var(--text, #111);
  outline: none;
  transition: border-color .15s;
}
.icd-search-input:focus {
  border-color: var(--primary, #6d3d8e);
}
.icd-search-hint {
  font-size: 11px;
  color: var(--muted, #6b7280);
  white-space: nowrap;
}
/* dropdown */
.icd-dropdown {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 4px);
  z-index: 200;
  background: var(--surface, #fff);
  border: 1.5px solid var(--border, #e5e7eb);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}
.icd-result-row {
  display: grid;
  grid-template-columns: 58px 1fr auto auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 1px solid var(--border, #f3f4f6);
  transition: background .12s;
}
.icd-result-row:hover:not([disabled]) {
  background: var(--acc-50, #f3e8ff);
}
.icd-result-row[disabled], .icd-result-row.icd-added {
  opacity: .55;
  cursor: default;
}
.icd-result-code {
  font-size: 12px;
  font-weight: 700;
  font-family: monospace;
  color: var(--primary, #6d3d8e);
}
.icd-result-th {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #111);
}
.icd-result-en {
  font-size: 11px;
  color: var(--muted, #6b7280);
  grid-column: 2 / span 2;
}
.icd-result-added {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--acc-200, #d8b4fe);
  color: var(--primary, #6d3d8e);
  font-weight: 600;
}
.icd-no-results {
  padding: 14px;
  font-size: 13px;
  color: var(--muted, #6b7280);
  text-align: center;
}
/* selected chips */
.icd-selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  min-height: 30px;
}
.icd-empty-hint {
  font-size: 12px;
  color: var(--muted, #9ca3af);
  padding: 4px 0;
}
.icd-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px 3px 9px;
  border-radius: 20px;
  background: var(--acc-50, #f3e8ff);
  border: 1px solid var(--acc-200, #d8b4fe);
  font-size: 12px;
}
.icd-chip-code {
  font-family: monospace;
  font-weight: 700;
  color: var(--primary, #6d3d8e);
  font-size: 11px;
}
.icd-chip-name {
  color: var(--text, #111);
  font-weight: 500;
}
.icd-chip-remove {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted, #9ca3af);
  font-size: 15px;
  line-height: 1;
  padding: 0 0 0 2px;
  margin-left: 2px;
  border-radius: 50%;
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .12s, background .12s;
}
.icd-chip-remove:hover {
  color: #b91c1c;
  background: #fee2e2;
}
/* visit sheet ICD row (small text) */
.visit-sheet-icd {
  font-size: 9pt !important;
  word-break: break-word;
}

.opd-worklist-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1.3fr;
  gap: 10px;
  margin-top: 12px;
}

.opd-cloud-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.opd-cloud-grid div {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 4px 10px;
  min-height: 104px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.opd-cloud-grid div.done {
  border-color: var(--acc-bright);
  background: var(--acc-50);
}

.opd-cloud-grid span {
  display: grid;
  grid-row: span 2;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--primary);
  font-weight: 900;
}

.opd-cloud-grid div.done span {
  background: var(--acc-bright);
}

.opd-cloud-grid em {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.45;
}

.opd-worklist-grid div {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.opd-worklist-grid span,
.opd-worklist-grid em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.opd-worklist-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.opd-pack-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.workflow-steps div,
.opd-status-steps div,
.opd-completion-grid div,
.opd-pack-grid div {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 4px 10px;
  min-height: 104px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.workflow-steps span,
.opd-status-steps span,
.opd-completion-grid span,
.opd-pack-grid span {
  display: grid;
  grid-row: span 2;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--primary);
  font-weight: 900;
}

.workflow-steps strong,
.opd-status-steps strong,
.opd-completion-grid strong,
.opd-pack-grid strong {
  color: var(--ink);
}

.workflow-steps em,
.opd-status-steps em,
.opd-completion-grid em,
.opd-pack-grid em {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.45;
}

.opd-completion-grid div.done {
  border-color: var(--acc-bright);
  background: var(--acc-50);
}

.opd-completion-grid div.done span {
  background: var(--acc-bright);
}

.opd-completion-grid div.pending {
  border-color: #cbd5e1;
}

.visit-action-strip,
.photo-upload-actions,
.photo-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.photo-upload-actions {
  margin-top: 0;
}

.photo-status-row div {
  display: grid;
  gap: 3px;
  min-width: 220px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.photo-status-row span {
  color: var(--muted);
  font-size: 12px;
}

.opd-control-grid small {
  color: #64748b;
  font-size: 11px;
  font-weight: 900;
}

.opd-nonline-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 10px;
}

.opd-nonline-summary div {
  min-height: 68px;
}

.opd-nonline-blockers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 10px;
}

.opd-nonline-blockers .opd-blocker-head,
.opd-nonline-blockers button {
  display: grid;
  gap: 4px;
  min-height: 76px;
  padding: 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff5f5;
  text-align: left;
}

.opd-nonline-blockers button {
  cursor: pointer;
}

.opd-nonline-blockers .opd-blocker-head.done {
  border-color: rgba(15, 118, 110, 0.45);
  background: var(--acc-50);
}

.opd-nonline-blockers span,
.opd-nonline-blockers em {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.opd-nonline-blockers strong {
  color: var(--ink);
}

.opd-nonline-search {
  width: 100%;
  min-height: 46px;
  margin: 0 0 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.opd-nonline-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.opd-nonline-filters button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--teal);
  font-weight: 900;
  cursor: pointer;
}

.opd-nonline-filters button.active {
  border-color: rgba(15, 118, 110, 0.45);
  background: #ccfbf1;
  color: #0f766e;
}

.opd-scenario-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.opd-scenario-summary div,
.opd-scenario-grid > div {
  display: grid;
  gap: 4px;
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  text-align: left;
}

.opd-scenario-summary div.done,
.opd-scenario-grid > div.pass {
  border-color: rgba(15, 118, 110, 0.45);
  background: var(--acc-50);
}

.opd-scenario-summary div.pending,
.opd-scenario-grid > div.fail {
  border-color: #fecaca;
  background: #fff5f5;
}

.opd-scenario-grid > div.blocked {
  box-shadow: inset 4px 0 0 #ef4444;
}

.opd-scenario-grid > div.untested {
  border-color: #dbe4ef;
  background: #f8fafc;
}

.opd-scenario-search {
  width: 100%;
  min-height: 46px;
  margin: 0 0 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.opd-scenario-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.opd-scenario-filters button,
.scenario-actions button {
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--teal);
  font-weight: 900;
  cursor: pointer;
}

.opd-scenario-filters button.active {
  border-color: rgba(15, 118, 110, 0.45);
  background: #ccfbf1;
  color: #0f766e;
}

.opd-scenario-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.opd-scenario-grid span,
.opd-scenario-grid em,
.opd-scenario-grid small,
.opd-scenario-summary span,
.opd-scenario-summary em {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.scenario-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.certificate-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(520px, 1.1fr);
  gap: 16px;
}

/* ============================================================
   OFFICIAL Medical Certificate Template (Medical Council 2/2564)
   Used for driving license, employment, govt health checks.
   Bilingual (TH/EN) controlled via [data-cert-lang] on the page.
   ============================================================ */
.medical-certificate-official-page,
.medical-certificate-official-en-page,
.medical-certificate-gpo-page { display: none; }
body[data-certificate-type="official"] #medicalCertificatePage { display: none; }
/* Default to Thai (2/2564) layout */
body[data-certificate-type="official"] #medicalCertificateOfficialPage { display: block; }
/* When EN selected, swap to EN-only (4/2018) layout — that's the official translation form */
body[data-certificate-type="official"][data-certificate-lang="en"] #medicalCertificateOfficialPage { display: none; }
body[data-certificate-type="official"][data-certificate-lang="en"] #medicalCertificateOfficialEnPage { display: block; }
body[data-certificate-type="gpo"] #medicalCertificatePage { display: none; }
body[data-certificate-type="gpo"] #medicalCertificateGpoPage { display: block; }

/* ============================================================
 * Print mode — the clone in #opdPrintRoot loses its #id (the print helper
 * strips ids to avoid duplicates with the still-present source). That kills
 * the body[data-certificate-type="…"] #medicalCertificate…Page { display: block }
 * rules above, so the class-only ".medical-certificate-official-page { display: none }"
 * default wins and the clone disappears → blank A4. Force the cloned cert
 * pages visible inside #opdPrintRoot regardless of certificate-type body attr.
 * ============================================================ */
body.printing-opd #opdPrintRoot .medical-certificate-official-page,
body.printing-opd #opdPrintRoot .medical-certificate-official-en-page,
body.printing-opd #opdPrintRoot .medical-certificate-gpo-page {
  display: block !important;
}
body[data-certificate-type="official"] #certOfficialFields { display: block !important; }
body[data-certificate-type="official"] #certOfficialFields[hidden] { display: block !important; }

/* Language toggle on Thai page — for "bilingual" mode show both TH+EN, "th" shows only TH */
.medical-certificate-official-page .cert-en { display: none; }
.medical-certificate-official-page[data-cert-lang="bilingual"] .cert-en { display: inline; }
.medical-certificate-official-page[data-cert-lang="bilingual"] .cert-th + .cert-en::before { content: " / "; color: #64748b; }

/* English-only page styling tweaks */
.cert-official-translation-tag {
  text-align: center;
  font-style: italic;
  font-size: 11px;
  color: #64748b;
  margin: 4px 0;
}
.cert-official-title-en {
  font-family: "Times New Roman", "Sarabun", serif;
  font-size: 22px;
  letter-spacing: 0.5px;
}
.cert-history-other {
  font-style: normal;
  border-bottom: 1px dotted #94a3b8;
  display: inline-block;
  min-width: 200px;
  padding: 0 4px;
}
.cert-official-vitals-inline {
  display: block !important;
  grid-template-columns: none !important;
  background: transparent !important;
  padding: 4px 0 !important;
  margin: 8px 0 !important;
  border: 0;
  font-size: 13px !important;
}
.medical-certificate-official-en-page {
  background: #ffffff;
  color: #0f172a;
  padding: 28px 32px;
  font-size: 13px;
  line-height: 1.7;
  font-family: "Times New Roman", "Sarabun", serif;
}

.medical-certificate-official-page {
  background: #ffffff;
  color: #0f172a;
  padding: 28px 32px;
  font-size: 13px;
  line-height: 1.55;
  font-family: "Sarabun", "Noto Sans Thai", system-ui, -apple-system, sans-serif;
}
.cert-official-header {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 10px;
  margin-bottom: 14px;
  text-align: center;
}
.cert-official-clinic {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: 8px;
}
.cert-official-clinic strong {
  font-size: 16px;
  font-weight: 800;
}
.cert-official-clinic .muted { font-size: 11px; color: #475569; }
.cert-official-title {
  font-size: 17px;
  font-weight: 800;
  margin: 6px 0;
  line-height: 1.35;
}
.cert-official-title span { display: block; }
.cert-official-meta {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  font-size: 12px;
  margin-top: 6px;
}
.cert-official-section {
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  page-break-inside: avoid;
}
.cert-official-section h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
}
/* Rectangular black badge for "ส่วนที่ 1" / "ส่วนที่ 2" — matches the
 * official 2/2564 PDF reference (solid dark fill, white bold caps). */
.cert-section-badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 5px;
  background: #0f172a;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-right: 8px;
}
.cert-official-line { margin: 6px 0; line-height: 1.7; }
.cert-official-line strong { font-weight: 700; border-bottom: 1px dotted #94a3b8; padding: 0 4px; }

/* ============================================================
 * Signature rows — both screen + print use these layout rules.
 * Put them OUTSIDE @media print so the on-screen preview matches
 * what the printer outputs. Sizing-only tweaks (font/padding) stay
 * inside @media print where appropriate.
 * ============================================================ */
.cert-official-sig-row { text-align: right; }
/* Pin the patient signature line to the right edge. Belt + suspenders:
 * flex justify-content + margin-left auto on the child, both with
 * !important so print stylesheets can't accidentally override.
 * Without this the line drifts to the left because of inherited rules. */
.cert-official-sig-patient {
  display: flex !important;
  justify-content: flex-end !important;
  margin-top: 16px;
}
.cert-official-sig-patient .cert-sig-singleline {
  display: inline-block;
  white-space: nowrap;
  margin-left: auto !important;
}
.cert-official-sig-doctor { text-align: right; margin-top: 20px; }
.cert-official-sig-doctor .cert-official-doctor-sig {
  display: inline-block;
  text-align: right;
  vertical-align: top;
}
.cert-sig-stack {
  display: inline-block;
  vertical-align: top;
  text-align: center;
}
.cert-sig-stack .cert-sig-line,
.cert-sig-stack .cert-sig-role,
.cert-sig-stack strong {
  display: block;
  text-align: center;
}
.cert-sig-stack strong {
  font-style: normal;
  font-weight: 700;
  margin-top: 2px;
  /* Shift name slightly right so it centers under the DOTTED part of
   * "ลงชื่อ ............." (the dots take ~70% of the line width). Without
   * this, the name sits under the geometric middle including the "ลงชื่อ"
   * word, which looks shifted left of the actual signature line. */
  padding-left: 36px;
  line-height: 1.4;
}
.cert-official-sig-doctor .cert-sig-role-suffix {
  display: inline-block;
  vertical-align: top;
  margin-left: 8px;
}
.cert-official-statement { margin: 10px 0 6px; font-weight: 600; }
.cert-official-history { margin: 8px 0 12px; padding-left: 0; list-style: none; }
.cert-official-history li {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 6px 0;
  border-bottom: 1px dashed #e2e8f0;
}
.cert-history-check { font-size: 12px; color: #334155; }
.cert-history-check em { font-style: normal; font-weight: 600; color: #0f172a; border-bottom: 1px dotted #94a3b8; min-width: 80px; display: inline-block; padding: 0 4px; }
.cert-official-fine { margin-top: 10px; font-size: 11px; color: #475569; font-style: italic; }
.cert-official-sig-row {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
  font-size: 12px;
}
.cert-official-sig-row.right { justify-content: flex-end; }
.cert-official-vitals {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 14px;
  background: #f8fafc;
  padding: 8px 12px;
  border-radius: 6px;
  margin: 10px 0;
  font-size: 12.5px;
}
.cert-official-attestation { margin: 12px 0; }
.cert-official-attestation p { font-size: 12px; line-height: 1.7; text-align: justify; }
.cert-official-diseases { padding-left: 22px; margin-top: 8px; }
.cert-official-diseases li { font-size: 12px; line-height: 1.7; }
.cert-official-doctor-sig {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  font-size: 12px;
}
.cert-official-doctor-sig img { max-height: 60px; margin-bottom: 4px; }
.cert-official-doctor-sig strong { font-weight: 700; margin-top: 2px; }
.cert-official-doctor-sig em { font-style: normal; color: #64748b; }
.cert-official-notes { margin-top: 14px; font-size: 10.5px; color: #475569; }
.cert-official-notes p { line-height: 1.55; }
.cert-official-footnote { font-style: italic; margin-top: 6px; }

/* ============================================================
 * ใบรับรองแพทย์ กพ. (5 โรคต้องห้ามตามกฎ ก.พ. 2553)
 * Reuses .cert-official-* base; only the bits that differ from
 * the 2/2564 form live here.
 * ============================================================ */
.cert-gpo-meta { margin: 8px 0 12px; }
.cert-gpo-meta .cert-official-line { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.cert-gpo-body { font-size: 12.5px; line-height: 1.85; }
.cert-gpo-body .cert-official-line { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.cert-gpo-attestation { margin: 10px 0 4px; font-size: 13px; }
.cert-gpo-diseases { padding-left: 22px; margin: 6px 0 8px; }
.cert-gpo-diseases li { font-size: 12px; line-height: 1.75; margin-bottom: 4px; }
.cert-gpo-extra-note { font-size: 11px; font-style: italic; color: #64748b; margin: 4px 0 14px; }
.cert-gpo-opinion strong { font-weight: 500; }
.cert-gpo-sig-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 28px;
  align-items: end;
}
.cert-gpo-staff-sig { font-size: 12px; }
.cert-gpo-staff-sig em {
  display: block;
  font-style: normal;
  color: #64748b;
  font-size: 11px;
  margin-top: 2px;
  text-align: center;
}
.cert-gpo-notes { margin-top: 18px; font-size: 10.5px; }
.cert-gpo-notes ol { font-size: 10.5px; line-height: 1.55; }
.certificate-official-fields {
  margin: 12px 0;
  padding: 12px;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  border-radius: 8px;
}
.certificate-official-fields .certificate-form-grid label.wide {
  grid-column: 1 / -1;
  font-weight: 700;
  color: #15803d;
  padding-top: 8px;
}
@media print {
  /* Force A4 with zero margin so Chrome/Safari can't inject the URL footer
   * + date/title header. The clinic doesn't want those on a legal document. */
  @page {
    size: A4 portrait;
    margin: 0;
  }
  /* Print sizing — fill the A4 with generous line spacing matching the
   * official 2/2564 PDF reference, while still capping at ONE page. The
   * trick is bumping line-height (1.75) without bumping font (12.5px) so
   * each row breathes but the cumulative height stays within 297mm. */
  .medical-certificate-official-page,
  .medical-certificate-official-en-page,
  .medical-certificate-gpo-page {
    padding: 12mm 14mm;
    font-size: 12.5px;
    line-height: 1.75;
    color: #000 !important;
  }
  /* Pull text to black under print but KEEP border-color at its default
   * (light gray) so the section item separators look soft/clean — matches
   * the on-screen preview. Forcing all borders to #000 made them too heavy. */
  .medical-certificate-official-page *,
  .medical-certificate-official-en-page *,
  .medical-certificate-gpo-page * {
    color: #000 !important;
  }
  .cert-official-section {
    break-inside: avoid;
    padding: 10px 14px;
    margin: 12px 0;
  }
  .cert-official-header { padding-bottom: 6px; margin-bottom: 8px; }
  .cert-official-clinic { gap: 1px; margin-bottom: 4px; }
  .cert-official-clinic strong { font-size: 16px; }
  .cert-official-clinic .muted { font-size: 11px; }
  .cert-official-title { font-size: 17px; margin: 4px 0; }
  .cert-official-section h2 { font-size: 14px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
  /* Rectangular black "ส่วนที่ N" badge matching the official PDF — solid
   * dark block, white bold text, bigger horizontal padding so it reads as a
   * label not a number. Forced dark even under "all colors black" override. */
  .cert-section-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    background: #0f172a !important;
    color: #fff !important;
    font-size: 12.5px;
    font-weight: 800;
    letter-spacing: 0.5px;
    width: auto;
    height: auto;
  }
  /* Generous line height to match the official PDF — readable without
   * cramping, but stops short of overflowing the page. */
  .cert-official-line { font-size: 12.5px; line-height: 1.85; margin: 5px 0; }
  .cert-official-attestation p { line-height: 1.75; margin: 6px 0; }
  .cert-official-diseases,
  .cert-gpo-diseases { margin: 6px 0 8px; padding-left: 24px; }
  .cert-official-diseases li,
  .cert-gpo-diseases li { font-size: 11.5px; line-height: 1.8; margin-bottom: 2px; }
  .cert-official-notes,
  .cert-gpo-notes { font-size: 10.5px; line-height: 1.55; margin-top: 12px; }
  .cert-official-notes p,
  .cert-gpo-notes ol { line-height: 1.55; }
  .cert-official-footnote { font-size: 10px; }
  /* Signature rows — print-only sizing tweaks. Layout structure lives
   * outside @media print so the screen preview matches print. */
  .cert-official-sig-patient { font-size: 12.5px; line-height: 1.85; margin-top: 14px; }
  .cert-official-sig-doctor,
  .cert-gpo-sig-row { margin-top: 18px; }
  .cert-sig-stack strong { font-size: 12px; }
  .cert-official-sig-doctor .cert-sig-role-suffix { font-size: 12.5px; }
  .cert-official-doctor-sig img { max-height: 46px; }
}

.certificate-type-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.certificate-type-grid button {
  display: grid;
  gap: 5px;
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  text-align: left;
  cursor: pointer;
}

.certificate-type-grid button.active {
  border-color: rgba(15, 118, 110, 0.45);
  background: #ecfeff;
}

.certificate-type-grid span,
.certificate-type-grid em {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.certificate-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.certificate-form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.certificate-form-grid label.wide {
  grid-column: 1 / -1;
}

.certificate-form-grid input,
.certificate-form-grid select,
.certificate-form-grid textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.certificate-form-grid textarea {
  min-height: 96px;
  resize: vertical;
}

.certificate-log-panel {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.certificate-log-list {
  display: grid;
  gap: 8px;
}

.certificate-log-list div {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.certificate-log-list div.issued,
.certificate-log-list div.printed {
  border-color: rgba(15, 118, 110, 0.35);
  background: var(--acc-50);
}

.certificate-log-list span,
.certificate-log-list em {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.certificate-preview-panel {
  overflow: auto;
}

.medical-certificate-page {
  width: min(100%, 794px);
  min-height: 1123px;
  margin-inline: auto;
}

.certificate-header,
.certificate-sign-grid {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 3px solid var(--ink);
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.certificate-header strong {
  display: block;
  color: var(--ink);
  font-size: 30px;
}

.certificate-header span,
.certificate-sign-grid span {
  display: block;
  color: var(--ink);
  font-weight: 800;
}

.certificate-section {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}

.certificate-section h4 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 18px;
}

.certificate-section p {
  margin: 0 0 10px;
  color: var(--ink);
  font-weight: 800;
  line-height: 1.5;
}

.certificate-row {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed #cbd5e1;
}

.certificate-row span {
  color: var(--muted);
  font-weight: 800;
}

.certificate-checks {
  display: none;
  gap: 8px;
}

.certificate-checks.active {
  display: grid;
}

.certificate-sign-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 3px solid var(--ink);
  border-bottom: 0;
  padding-top: 24px;
  margin-top: 18px;
}

.opd-status-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.opd-status-steps div {
  min-height: 92px;
  background: #ffffff;
}

.opd-status-steps div.done {
  border-color: var(--acc-bright);
  background: var(--acc-50);
}

.opd-status-steps div.done span {
  background: var(--acc-bright);
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.folder-grid div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}

.folder-grid span,
.folder-grid em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.folder-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.opd-print-card {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid #94a3b8;
  border-radius: 6px;
  background: #ffffff;
  color: #111827;
  font-size: 13.5px;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
}

.opd-page-label {
  margin-bottom: 7px;
  color: #64748b;
  font-size: 11px;
  font-weight: 900;
  text-align: right;
}

.opd-print-card.paper-a4.portrait {
  width: min(100%, 794px);
  min-height: 1123px;
  margin-inline: auto;
}

.opd-print-card.paper-a4.landscape {
  width: min(100%, 1123px);
  min-height: 794px;
  margin-inline: auto;
}

.opd-print-card.paper-a5.portrait {
  width: min(100%, 560px);
  min-height: 794px;
  margin-inline: auto;
  padding: 14px;
  font-size: 10.5px;
}

.opd-intake-card {
  line-height: 1.35;
  border: 0;
  box-shadow: none;
}

.intake-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.intake-grid section {
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
}

.intake-line-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: end;
  gap: 8px;
  padding: 4px 0;
}

.intake-line-row span,
.intake-grid em {
  color: #475569;
  font-weight: 800;
}

.intake-line-row b {
  min-height: 18px;
  border-bottom: 1px dotted #64748b;
}

.intake-check-grid,
.intake-photo-grid {
  display: grid;
  gap: 5px 10px;
}

.intake-check-grid.two,
.intake-photo-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.intake-check-grid span,
.intake-photo-grid span {
  font-weight: 800;
}

.intake-note-box {
  min-height: 38px;
  margin-top: 6px;
  padding: 6px;
  border: 1px dotted #94a3b8;
  color: #64748b;
  font-weight: 800;
}

.intake-sign-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
  font-weight: 900;
}

.intake-sign-grid.final {
  padding-top: 8px;
  border-top: 2px solid #111827;
}

.intake-bottom-note {
  margin-top: 6px;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-align: right;
}

.opd-print-card.paper-a5.landscape {
  width: min(100%, 794px);
  min-height: 560px;
  margin-inline: auto;
  padding: 12px;
  font-size: 11.5px;
}

.opd-intake-card.paper-a5.landscape,
.opd-intake-card.paper-a5.portrait,
.opd-intake-card.paper-a4.landscape,
.opd-intake-card.paper-a4.portrait {
  width: min(100%, 794px);
  min-height: 0;
  margin-inline: auto;
  padding: 12px;
  font-size: 10px;
}

.opd-visit-log.paper-a4.portrait {
  padding: 22px;
  font-size: 13px;
}

.opd-print-card.landscape {
  display: block;
}

.opd-print-card.landscape .opd-card-header,
.opd-print-card.landscape .opd-card-sign {
  grid-column: auto;
}

.opd-card-header,
.opd-card-sign {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 2px solid #111827;
  padding-bottom: 8px;
}

.opd-card-header div {
  display: grid;
  gap: 3px;
}

.opd-card-header > div:first-child.has-logo {
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 10px;
}

.opd-card-logo {
  grid-row: 1 / span 2;
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.opd-card-header strong {
  font-size: 18px;
}

.opd-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.opd-print-card.paper-a5.landscape .opd-card-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.opd-print-card.paper-a5.portrait .opd-card-grid {
  grid-template-columns: 1fr;
  gap: 6px;
}

.opd-card-grid section,
.opd-card-chart > div {
  min-height: 112px;
  padding: 10px;
  border: 1px solid #cbd5e1;
}

.opd-print-card.paper-a5 .opd-card-grid section,
.opd-print-card.paper-a5 .opd-card-chart > div {
  min-height: auto;
  padding: 7px;
}

.opd-print-card h4 {
  margin: 0 0 7px;
  padding-bottom: 4px;
  border-bottom: 1px solid #cbd5e1;
}

.opd-print-card p {
  margin: 0;
  line-height: 1.5;
}

.opd-card-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
  border-bottom: 1px dotted #cbd5e1;
}

.opd-card-row.alert strong {
  color: #b91c1c;
}

.opd-card-row.alert span::before,
.visit-sheet-critical .critical span::before,
.visit-sheet-critical .wide span::before {
  color: #b91c1c;
}

.opd-card-pdpa {
  grid-column: 1 / -1;
}

/* Prominent active-patient banner at top of OPD Record panel */
.opd-active-patient-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--acc-50) 0%, #ecfeff 50%, #eef2ff 100%);
  border: 1px solid var(--acc-200);
  border-radius: 14px;
  box-shadow: 0 1px 0 rgba(15,23,42,0.04);
  position: sticky;
  top: 0;
  z-index: 5;
}
.opd-active-patient-banner.has-patient {
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(38, 182, 178, 0.18);
}
.opd-active-photo,
.opd-active-photo-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 8px rgba(15,23,42,0.12);
  background: linear-gradient(135deg, var(--primary), #6c5ce7);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 800;
}
/* Make sure [hidden] beats display:grid */
.opd-active-photo[hidden],
.opd-active-photo-placeholder[hidden] { display: none !important; }

/* Edit Customer Profile modal */
.edit-customer-form {
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 6px;
  display: grid;
  gap: 10px;
}
.edit-customer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #eef2ff 0%, #ecfeff 100%);
  border-radius: 8px;
}
.edit-customer-head strong { display: block; font-size: 15px; }
.edit-customer-head .muted { font-size: 12px; font-family: ui-monospace, monospace; }
.edit-customer-photo,
.edit-customer-photo-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(15,23,42,0.12);
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), #6c5ce7);
  color: #fff;
  font-size: 28px;
  font-weight: 800;
  flex-shrink: 0;
}
.edit-customer-photo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.edit-customer-photo-upload {
  cursor: pointer;
  padding: 4px 8px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  color: var(--ink);
  font-weight: 700;
  text-align: center;
}
.edit-customer-photo-upload:hover { background: var(--acc-50); border-color: var(--primary); }
.edit-customer-photo-clear {
  padding: 3px 6px;
  background: #fff;
  border: 1px solid #fecaca;
  border-radius: 6px;
  font-size: 10px;
  color: #b91c1c;
  cursor: pointer;
}
.edit-customer-form h4 {
  margin: 8px 0 4px;
  font-size: 13px;
  font-weight: 800;
  color: var(--primary-dark, #1d9692);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.edit-customer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.edit-customer-form .line-test-field input,
.edit-customer-form .line-test-field select,
.edit-customer-form .line-test-field textarea { width: 100%; }
.opd-active-info {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 4px;
}
.opd-active-name { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.opd-active-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--primary-dark, #1d9692);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: #ffffffcc;
  padding: 2px 8px;
  border-radius: 999px;
}
.opd-active-name strong { font-size: 20px; font-weight: 800; color: var(--ink); }
.opd-active-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: #475569;
}
.opd-active-hn {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-weight: 700;
  color: #1e40af;
  background: #dbeafe;
  padding: 1px 8px;
  border-radius: 6px;
}
.opd-active-alert {
  display: inline-block;
  margin-top: 2px;
  padding: 4px 10px;
  background: #fee2e2;
  color: #b91c1c;
  font-weight: 700;
  font-size: 12px;
  border-radius: 999px;
  align-self: flex-start;
  width: fit-content;
}
.opd-active-actions {
  /* 2×2 grid instead of a 4-tall vertical stack — keeps the right side the
     same height as the patient info on the left so the banner stays balanced
     (was: tall thin button column + short info = lopsided whitespace). */
  display: grid;
  grid-template-columns: repeat(2, minmax(132px, 1fr));
  gap: 8px;
  align-content: center;
  flex-shrink: 0;
}
.opd-active-actions button { white-space: nowrap; width: 100%; }
.opd-panel-subhead { margin-bottom: 8px; padding-top: 4px; }
.opd-panel-subhead h2 { display: none; }
.opd-meta-toggle { font-size: 11px; padding: 4px 8px; }

@media (max-width: 720px) {
  .opd-active-patient-banner { flex-direction: column; align-items: stretch; text-align: left; }
  .opd-active-actions { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.opd-card-patient-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
  padding-bottom: 6px;
  border-bottom: 1px dotted #cbd5e1;
}
.opd-card-patient-head-text { flex: 1; min-width: 0; }
.opd-card-patient-head-text .opd-card-row {
  border-bottom: none;
  padding: 1px 0;
}
.opd-card-patient-photo {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
  flex-shrink: 0;
  background: #f8fafc;
}
@media print {
  .opd-card-patient-photo { width: 50px; height: 50px; }
}

.pdpa-sign-line {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dotted #cbd5e1;
}

.pdpa-sign-line span {
  color: var(--muted);
  font-size: 12px;
}

.consent-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
}

.consent-split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.consent-statement,
.consent-section,
.media-consent-box {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #334155;
  background: #f8fafc;
  font-size: 12px;
  line-height: 1.55;
}

.consent-section {
  display: grid;
  gap: 3px;
}

.consent-mini-sign {
  display: grid;
  grid-template-columns: auto minmax(70px, 1fr) auto minmax(58px, 0.75fr);
  align-items: end;
  gap: 5px;
  margin-top: 4px;
}

.consent-mini-sign span {
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
}

.consent-mini-sign b {
  display: block;
  min-height: 13px;
  border-bottom: 1px solid #111827;
  color: transparent;
}

.consent-section strong,
.media-consent-box strong {
  color: var(--ink);
}

.media-consent-box {
  background: #fffafa;
  border-color: #fecaca;
}

.media-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-top: 5px;
  color: #172033;
  font-weight: 800;
}

.media-consent-box em {
  display: block;
  margin-top: 5px;
  color: #b91c1c;
  font-style: normal;
  font-weight: 900;
}

.consent-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 12px;
  margin-top: 8px;
  color: #172033;
  font-size: 12px;
  font-weight: 800;
}

.opd-card-chart {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(220px, 0.7fr);
  gap: 10px;
  margin-top: 10px;
}

.opd-card-chart.body-map-only {
  grid-template-columns: minmax(0, 1fr);
}

.opd-print-card.paper-a5.landscape .opd-card-chart {
  grid-template-columns: minmax(0, 1.35fr) minmax(190px, 0.65fr);
  gap: 6px;
}

.opd-print-card.paper-a5.landscape .opd-card-chart.body-map-only,
.opd-print-card.paper-a4.portrait .opd-card-chart.body-map-only {
  grid-template-columns: minmax(0, 1fr);
}

.opd-print-card.paper-a4.portrait .opd-card-chart {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
}

.opd-print-card.paper-a4.portrait .opd-map-sheet {
  min-height: 360px;
}

.opd-print-card.paper-a4.portrait .opd-map-sheet .chart-template-image {
  max-height: 360px;
}

.opd-print-card.paper-a4.portrait .mini-photo-grid span {
  min-height: 86px;
}

.opd-print-card.paper-a5.portrait .opd-card-chart {
  grid-template-columns: 1fr;
  gap: 6px;
}

.beauty-face-section {
  min-height: 380px;
}

.beauty-face-sheet {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 380px;
  margin: 8px 0;
  border: 1px dashed #94a3b8;
  background: #ffffff;
}

.chart-template-image {
  display: block;
  width: min(100%, 680px);
  max-height: 380px;
  object-fit: contain;
  border-radius: 6px;
  background: #ffffff;
  filter: contrast(1.04);
}

.opd-map-sheet {
  min-height: 380px;
  background: #ffffff;
}

.opd-map-sheet .chart-template-image {
  width: min(100%, 720px);
  max-height: 380px;
}

.opd-print-card.paper-a5.landscape .beauty-face-section,
.opd-print-card.paper-a5.landscape .opd-map-sheet {
  min-height: 170px;
}

.opd-print-card.paper-a5.landscape .opd-map-sheet .chart-template-image {
  max-height: 170px;
}

.opd-print-card.paper-a5.portrait .opd-map-sheet .chart-template-image {
  max-height: 220px;
}

.opd-print-card.paper-a5 .marker-legend {
  grid-template-columns: 1fr;
  gap: 4px;
}

.opd-print-card.paper-a5 .marker-legend div {
  min-height: 34px;
  padding: 5px 7px;
}

.opd-map-sheet .face-mark {
  display: none;
}

.opd-visit-log {
  margin-top: 18px;
}

.visit-sheet-layout {
  display: grid;
  grid-template-columns: 1fr 1.28fr 1.18fr;
  gap: 8px;
  margin-top: 10px;
}

.visit-sheet-critical {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.visit-sheet-critical div {
  display: grid;
  gap: 2px;
  padding: 7px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
}

.visit-sheet-critical .wide {
  grid-column: 1 / -1;
}

.visit-sheet-critical .critical {
  border-color: #fecaca;
  background: #fff1f2;
}

.visit-sheet-critical span {
  color: #64748b;
  font-size: 11px;
  font-weight: 900;
}

.visit-sheet-critical strong {
  color: #111827;
  font-size: 13px;
}

.visit-sheet-critical .critical strong,
.visit-sheet-critical .wide strong {
  color: #b91c1c;
}

.visit-sheet-layout section {
  min-height: 380px;
  padding: 8px;
  border: 1px solid #cbd5e1;
}

.opd-visit-log.paper-a4.portrait .visit-sheet-layout {
  grid-template-columns: 1fr;
  gap: 12px;
}

.opd-visit-log.paper-a4.portrait .visit-sheet-layout section {
  min-height: auto;
  padding: 12px;
}

.opd-visit-log.paper-a4.portrait .visit-sheet-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 16px;
}

.opd-visit-log.paper-a4.portrait .visit-sheet-summary h4,
.opd-visit-log.paper-a4.portrait .visit-sheet-checks {
  grid-column: 1 / -1;
}

.opd-visit-log.paper-a4.portrait .visit-sheet-checks {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.opd-visit-log.paper-a4.portrait .visit-sheet-map {
  min-height: 330px;
}

.opd-visit-log.paper-a4.portrait .visit-sheet-map img {
  width: min(100%, 690px);
  max-height: 300px;
}

.opd-visit-log.paper-a4.portrait .visit-sheet-note {
  min-height: 430px;
}

.opd-visit-log.paper-a4.portrait .handwriting-lines {
  min-height: 300px;
}

.visit-sheet-summary .opd-card-row {
  align-items: baseline;
}

.visit-sheet-checks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 10px;
  color: #111827;
  font-weight: 800;
}

.visit-sheet-checks span {
  padding: 5px;
  border: 1px solid #cbd5e1;
}

.visit-sheet-map {
  display: grid;
  align-content: start;
  justify-items: center;
}

.visit-sheet-map img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
}

/* ── Split body map: face on top, front+back bodies below (2 rows) ──
   Used instead of the single wide composite so each figure is bigger and
   the column's vertical space is fully used (no letterbox whitespace). */
.vs-map-composite { display: none; }            /* hidden unless custom upload */
.visit-sheet-map.custom-chart .vs-map-split { display: none; }
.visit-sheet-map.custom-chart .vs-map-composite { display: block; width: 100%; max-height: 320px; object-fit: contain; }

.vs-map-split {
  width: 100%;
  display: flex;
  flex-direction: row;            /* wide/screen default: 3 across (2-up overrides to column) */
  align-items: flex-start;
  justify-content: center;
  gap: 12px;
}

.vs-map-face-cell {
  margin: 0;
  flex: 1.1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.vs-map-body-cell {
  flex: 1.6;
  display: flex;
  gap: 10px;
  justify-content: center;
}

.vs-map-body-cell figure {
  margin: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.vs-map-split img {
  width: auto;
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
}

.vs-map-split figcaption {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
}

.handwriting-lines {
  min-height: 205px;
  border: 1px solid #cbd5e1;
  background: repeating-linear-gradient(#ffffff 0 25px, #cbd5e1 26px);
}

/* Vitals block (screen + single-A4 base styles; 2-up overrides in @media print) */
.visit-sheet-vitals {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.vs-vital-alerts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 13px;
}

.vs-vital-alerts .vs-allergy strong { color: #b91c1c; font-weight: 900; }
.vs-vital-alerts .vs-disease strong { color: #92400e; font-weight: 700; }

.vs-vital-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding: 8px 0;
  border-top: 1px dashed #cbd5e1;
  border-bottom: 1px dashed #cbd5e1;
  font-size: 13px;
  color: #475569;
}

.vs-vital-fields b { color: #0f172a; }

.mini-field-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1fr;
  margin-top: 8px;
  border: 1px solid #cbd5e1;
}

.mini-field-grid span {
  min-height: 42px;
  padding: 6px;
  border-right: 1px solid #cbd5e1;
  color: #64748b;
  font-weight: 800;
}

.mini-field-grid span:last-child {
  border-right: 0;
}

.signature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 2px solid #111827;
  font-weight: 800;
}

.visit-log-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
  padding: 8px 0;
  border-bottom: 1px solid #cbd5e1;
}

.visit-log-table {
  display: grid;
  border: 1px solid #cbd5e1;
}

.visit-log-row {
  display: grid;
  grid-template-columns: 90px 1.15fr 1.45fr 90px 110px;
  min-height: 46px;
  border-bottom: 1px solid #cbd5e1;
}

.visit-log-row:last-child {
  border-bottom: 0;
}

.visit-log-row span {
  padding: 8px;
  border-right: 1px solid #cbd5e1;
}

.visit-log-row span:last-child {
  border-right: 0;
}

.visit-log-row.head {
  min-height: 34px;
  color: #111827;
  background: #f8fafc;
  font-weight: 900;
}

.visit-log-row.empty {
  min-height: 58px;
}

.visit-log-note {
  margin: 12px 0;
}

.visit-log-note div {
  min-height: 170px;
  border: 1px solid #cbd5e1;
  background:
    repeating-linear-gradient(#ffffff 0 31px, #cbd5e1 32px);
}

.opd-visit-log.paper-a5.landscape .visit-log-row {
  grid-template-columns: 68px 1fr 1.45fr 72px 86px;
  min-height: 34px;
}

.opd-visit-log.paper-a5.landscape .visit-log-row.empty {
  min-height: 38px;
}

.opd-visit-log.paper-a5.landscape .visit-log-row span {
  padding: 5px;
}

.opd-visit-log.paper-a5.landscape .visit-log-note div {
  min-height: 104px;
  background: repeating-linear-gradient(#ffffff 0 24px, #cbd5e1 25px);
}

.opd-visit-log.paper-a5.landscape .opd-card-sign {
  margin-top: 10px;
}

.opd-visit-log.paper-a5.landscape {
  min-height: 560px;
}

.opd-visit-log.paper-a5.landscape .visit-sheet-layout section {
  min-height: 390px;
}

.opd-visit-log.paper-a5.landscape .visit-sheet-map img {
  max-height: 325px;
}

.opd-visit-log.paper-a4.portrait {
  font-size: 12.5px;
}

.opd-visit-log.paper-a4.portrait .opd-card-header {
  margin-bottom: 14px;
}

.opd-visit-log.paper-a4.portrait .visit-sheet-layout {
  grid-template-columns: 1fr;
  gap: 12px;
}

.opd-visit-log.paper-a4.portrait .visit-sheet-layout section {
  min-height: auto;
  padding: 12px;
}

.opd-visit-log.paper-a4.portrait .visit-sheet-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 14px;
}

.opd-visit-log.paper-a4.portrait .visit-sheet-summary h4,
.opd-visit-log.paper-a4.portrait .visit-sheet-checks {
  grid-column: 1 / -1;
}

.opd-visit-log.paper-a4.portrait .visit-sheet-checks {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.opd-visit-log.paper-a4.portrait .visit-sheet-map {
  min-height: 420px;
}

.opd-visit-log.paper-a4.portrait .visit-sheet-map img {
  width: min(100%, 700px);
  max-height: 360px;
}

.opd-visit-log.paper-a4.portrait .handwriting-lines {
  min-height: 265px;
  background: repeating-linear-gradient(#ffffff 0 29px, #cbd5e1 30px);
}

.opd-visit-log.paper-a4.portrait .mini-field-grid span {
  min-height: 58px;
}

.opd-visit-log.paper-a4.portrait .signature-grid {
  margin-top: 16px;
  padding-top: 12px;
}

.opd-evidence-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 14px;
}

.opd-evidence-panel section,
.opd-admin-entry section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.opd-admin-entry {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 14px;
  margin-top: 14px;
}

.opd-history-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.opd-history-list div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: #ffffff;
}

.opd-history-list span,
.opd-history-list em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.posting-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.posting-grid div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}

.posting-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.posting-grid em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.posting-grid .done {
  border-color: var(--acc-bright);
  background: var(--acc-50);
}

.posting-grid .done span,
.posting-grid .done strong {
  color: #047857;
}

.upload-evidence-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  overflow: hidden;
}

.upload-evidence-button input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.evidence-card {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.evidence-card div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dotted var(--line);
}

.evidence-card div:last-child {
  border-bottom: 0;
}

.evidence-preview {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 220px;
  margin-top: 12px;
  padding: 16px;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  text-align: center;
}

.evidence-preview img {
  display: block;
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.evidence-preview.pdf {
  align-content: center;
  background: #f8fafc;
}

.evidence-preview a {
  color: var(--primary-dark);
  font-weight: 800;
  text-decoration: none;
}

.ai-imported-evidence {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  background: #f0f9ff;
}

.ai-imported-evidence div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.ai-imported-evidence span,
.ai-imported-evidence em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.ai-imported-evidence strong {
  overflow-wrap: anywhere;
}

.ocr-quality-panel,
.field-review-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.ocr-quality-panel {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ocr-quality-panel div,
.field-review-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}

.ocr-quality-panel span,
.field-review-list span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.field-review-list .done {
  border-color: var(--acc-bright);
  background: var(--acc-50);
}

.field-review-list .done strong {
  color: #047857;
}

.field-review-list .review strong {
  color: #92400e;
}

.status-pill.review {
  color: #92400e;
}

.status-pill.success {
  color: #047857;
}

.ai-draft-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.ai-draft-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ai-draft-grid input,
.ai-draft-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
}

.ai-draft-grid textarea {
  min-height: 76px;
  resize: vertical;
}

.ai-review-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.face-mark {
  position: absolute;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 10px;
  font-weight: 900;
}

.face-mark.jaw-left {
  left: 35%;
  top: 64%;
}

.face-mark.jaw-right {
  right: 35%;
  top: 64%;
}

.face-mark.cheek-left {
  left: 39%;
  top: 47%;
}

.face-mark.cheek-right {
  right: 39%;
  top: 47%;
}

.template-male .face-mark.jaw-left {
  left: 34%;
  top: 65%;
}

.template-male .face-mark.jaw-right {
  right: 34%;
  top: 65%;
}

.template-male .face-mark.cheek-left {
  left: 36%;
  top: 38%;
}

.template-male .face-mark.cheek-right {
  right: 36%;
  top: 38%;
}

.template-side .face-mark.jaw-left {
  left: 57%;
  top: 69%;
}

.template-side .face-mark.jaw-right {
  right: 26%;
  top: 47%;
}

.template-side .face-mark.cheek-left {
  left: 58%;
  top: 28%;
}

.template-side .face-mark.cheek-right {
  right: 28%;
  top: 58%;
}

.template-body-front .face-mark.jaw-left,
.template-body-back .face-mark.jaw-left,
.template-female-body-front .face-mark.jaw-left,
.template-female-body-back .face-mark.jaw-left,
.template-male-body-front .face-mark.jaw-left,
.template-male-body-back .face-mark.jaw-left {
  left: 35%;
  top: 37%;
}

.template-body-front .face-mark.jaw-right,
.template-body-back .face-mark.jaw-right,
.template-female-body-front .face-mark.jaw-right,
.template-female-body-back .face-mark.jaw-right,
.template-male-body-front .face-mark.jaw-right,
.template-male-body-back .face-mark.jaw-right {
  right: 35%;
  top: 37%;
}

.template-body-front .face-mark.cheek-left,
.template-body-back .face-mark.cheek-left,
.template-female-body-front .face-mark.cheek-left,
.template-female-body-back .face-mark.cheek-left,
.template-male-body-front .face-mark.cheek-left,
.template-male-body-back .face-mark.cheek-left {
  left: 39%;
  top: 61%;
}

.template-body-front .face-mark.cheek-right,
.template-body-back .face-mark.cheek-right,
.template-female-body-front .face-mark.cheek-right,
.template-female-body-back .face-mark.cheek-right,
.template-male-body-front .face-mark.cheek-right,
.template-male-body-back .face-mark.cheek-right {
  right: 39%;
  top: 61%;
}

.mini-photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

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

.mini-photo-grid span {
  display: grid;
  place-items: center;
  min-height: 104px;
  border: 1px dashed #94a3b8;
  color: #64748b;
  font-weight: 800;
  overflow: hidden;
  text-align: center;
}

.master-baseline-grid span {
  aspect-ratio: 4 / 5;
  min-height: 0;
}

.mini-photo-grid img {
  width: 100%;
  height: 100%;
  min-height: 88px;
  object-fit: cover;
}

.master-baseline-grid img {
  min-height: 0;
}

.mini-photo-grid em {
  padding: 4px;
  color: #111827;
  font-size: 9px;
  line-height: 1.2;
}

.marker-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.marker-legend div {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 4px 7px;
  padding: 7px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
}

.marker-legend span {
  display: grid;
  place-items: center;
  grid-row: span 2;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-weight: 900;
}

.marker-legend strong,
.marker-legend em {
  min-width: 0;
}

.marker-legend em {
  color: #64748b;
  font-style: normal;
}

.opd-card-sign {
  margin-top: 12px;
  border-top: 1px solid #111827;
  border-bottom: 0;
  padding-top: 12px;
  padding-bottom: 0;
}

.facechart-panel,
.facechart-points,
.photo-gallery {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.facechart-canvas-wrap {
  display: grid;
  place-items: center;
  padding: 12px;
  border-radius: 8px;
  background: #ffffff;
}

#facechartCanvas {
  width: min(100%, 360px);
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff7ed;
  cursor: crosshair;
}

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

.point-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ffffff;
}

.point-list span {
  color: var(--muted);
}

.photo-gallery {
  margin-top: 16px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

/* Backup & Restore list — dated snapshot rows */
.backup-list { padding: 0 12px 12px; }
.backup-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) 1fr 1fr 1.2fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line, #e5e7eb);
  font-size: 14px;
}
.backup-row.head {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 2px solid var(--line, #e5e7eb);
}
.backup-row:not(.head):hover { background: #f9fafb; }
.backup-row:last-child { border-bottom: none; }
@media (max-width: 640px) {
  .backup-row { grid-template-columns: minmax(0, 1.6fr) 1fr auto; }
  .backup-row span:nth-child(3), .backup-row span:nth-child(4) { display: none; }
}

.gallery-grid div {
  position: relative;
  display: grid;
  align-items: end;
  aspect-ratio: 1 / 1;
  min-height: 0;
  overflow: hidden;
  padding: 10px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(15, 23, 42, 0.52)),
    linear-gradient(135deg, #dbeafe, #fce7f3);
}

.gallery-grid img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.gallery-grid span {
  position: relative;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  z-index: 1;
}

.gallery-grid em {
  position: relative;
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  font-style: normal;
  z-index: 1;
}

.gallery-grid .baseline-dropzone {
  grid-column: span 2;
  align-content: start;
  gap: 8px;
  overflow: visible;
  aspect-ratio: auto;
  min-height: 250px;
}

.gallery-grid .baseline-tile-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  aspect-ratio: auto;
  min-height: 0;
  overflow: visible;
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.gallery-grid .baseline-photo-tile {
  position: relative;
  display: grid;
  align-items: end;
  aspect-ratio: 1 / 1;
  min-height: 0;
  overflow: hidden;
  padding: 6px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(15, 23, 42, 0.58)),
    linear-gradient(135deg, #dbeafe, #fce7f3);
  color: #ffffff;
}

.gallery-grid .baseline-photo-tile.print-selected {
  outline: 3px solid var(--primary);
  outline-offset: -3px;
}

.gallery-grid .baseline-photo-tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-grid .baseline-photo-tile b {
  place-self: center;
  color: #ffffff;
  font-size: 30px;
}

.gallery-grid .baseline-photo-tile em {
  display: -webkit-box;
  overflow: hidden;
  color: #ffffff;
  font-size: 10px;
  line-height: 1.2;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.gallery-grid .baseline-photo-tile .print-select-button {
  position: absolute;
  left: 6px;
  top: 6px;
  z-index: 2;
  min-height: 26px;
  border: 0;
  border-radius: 999px;
  padding: 3px 8px;
  color: #0f766e;
  background: #ccfbf1;
  font-size: 11px;
  font-weight: 900;
}

.gallery-grid .baseline-photo-tile:not(.print-selected) .print-select-button {
  color: #475569;
  background: rgba(255, 255, 255, 0.86);
}

.gallery-grid .baseline-photo-tile .remove-upload-button {
  top: 6px;
  right: 6px;
  padding: 4px 6px;
  font-size: 12px;
}

.photo-status-row em {
  display: block;
  margin-top: 4px;
  color: #64748b;
  font-size: 12px;
  font-style: normal;
}

.receipt-preview {
  padding: 24px;
  background: #e8edf5;
}

.receipt-paper {
  max-width: 420px;
  margin: 0 auto;
  padding: 28px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 22px 50px rgba(15, 23, 42, 0.12);
}

.receipt-paper.thermal {
  max-width: 280px;
  padding: 20px 18px;
  font-size: 13px;
}

.receipt-paper.thermal h2 {
  font-size: 17px;
}

.receipt-paper h2,
.receipt-paper p {
  text-align: center;
}

.receipt-paper p {
  color: var(--muted);
}

.receipt-paper > div {
  display: flex;
  justify-content: space-between;
  margin: 12px 0;
}

/* Receipt items list — DON'T inherit the flex-row layout */
.receipt-paper .receipt-items {
  display: block;
  margin: 8px 0;
}
.receipt-paper .receipt-items .receipt-items-header,
.receipt-paper .receipt-items .receipt-item {
  display: flex !important;
  justify-content: space-between !important;
  margin: 3px 0 !important;
  align-items: flex-start;
}
.receipt-paper .receipt-items .receipt-item > div {
  display: block !important;
  margin: 0 !important;
}
.receipt-paper .receipt-items hr.receipt-items-divider {
  display: block !important;
  margin: 8px 0 !important;
}

.invoice-list .total {
  border-color: var(--primary);
  background: var(--acc-50);
}

.medical-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #991b1b;
  background: #fef2f2;
}

.medical-alert strong {
  white-space: nowrap;
}

.treatment-costing,
.course-layout,
.wallet-layout,
.stock-overview,
.document-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.treatment-costing section,
.recipe-panel,
.share-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.recipe-panel {
  margin-top: 18px;
}

.stock-lot-panel,
.stock-detail-panel,
.movement-panel,
.product-category-summary,
.stock-policy-summary,
.stock-policy-settings {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.stock-kpi-grid,
.stock-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.stock-kpi-grid div,
.stock-detail-grid div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.stock-kpi-grid span,
.stock-kpi-grid em,
.stock-detail-grid span,
.stock-detail-grid em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.category-rule-grid,
.category-settings-grid,
.category-editor-grid,
.policy-summary-grid,
.policy-editor-grid,
.supplier-grid {
  display: grid;
  gap: 10px;
}

.category-rule-grid,
.category-settings-grid,
.policy-summary-grid,
.supplier-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.category-rule-grid div,
.category-setting-card,
.policy-summary-grid div,
.supplier-grid div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.category-rule-grid span,
.category-setting-card span,
.category-rule-grid em,
.category-setting-card em,
.policy-summary-grid span,
.policy-summary-grid em,
.supplier-grid span,
.supplier-grid em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.product-category-settings {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.category-editor-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 12px;
}

.policy-editor-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 12px;
}

.category-editor-grid label,
.policy-editor-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.category-editor-grid input,
.category-editor-grid textarea,
.policy-editor-grid input,
.policy-editor-grid select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
}

.category-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

.lot-table .table-row {
  grid-template-columns: 1.25fr 0.85fr 0.85fr 0.7fr 0.85fr;
}

.products-table .table-row,
.lot-table .table-row {
  cursor: pointer;
}

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

.movement-list div {
  display: grid;
  grid-template-columns: 95px minmax(0, 1fr);
  gap: 4px 12px;
  padding: 12px;
  border-left: 4px solid var(--indigo);
  border-radius: 8px;
  background: #f8fafc;
}

.movement-list span {
  grid-row: span 2;
  color: var(--muted);
  font-weight: 800;
}

.movement-list em {
  color: var(--muted);
  font-style: normal;
}

.stock-transfer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.stock-transfer-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.transfer-row {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.transfer-row.selected {
  border-color: var(--primary);
  background: var(--acc-50);
}

.transfer-row.warning {
  color: #991b1b;
  background: #fef2f2;
}

.transfer-row span,
.transfer-row em {
  color: var(--muted);
  font-style: normal;
}

.costing-row,
.recipe-row,
.share-member {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ffffff;
}

.costing-row span,
.recipe-row span,
.share-card > span,
.share-member em {
  color: var(--muted);
}

.share-member em {
  font-style: normal;
  font-weight: 800;
}

.wallet-hero {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
  padding: 22px;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, #172033, var(--primary));
}

.wallet-hero strong {
  font-size: 38px;
}

.wallet-hero small {
  color: rgba(255, 255, 255, 0.78);
  font-weight: 700;
}

.wallet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tier-progress {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--indigo));
}

.tier-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ffffff;
}

.tier-row span {
  color: var(--muted);
}

.tier-settings {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.service-catalog {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.opd-template-settings {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.template-option-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.template-option {
  display: grid;
  gap: 6px;
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.template-option.active {
  border-color: rgba(38, 182, 178, 0.5);
  background: #ecfeff;
}

.template-option span {
  color: var(--muted);
  font-weight: 800;
}

.template-option strong {
  font-size: 20px;
}

.template-option em {
  color: var(--muted);
  font-style: normal;
  line-height: 1.45;
}

.service-table .table-row {
  grid-template-columns: 1.25fr 0.7fr 0.7fr 1.1fr 0.7fr;
}

.recipe-pill {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-weight: 800;
}

.catalog-rules {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.catalog-rules div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
}

.catalog-rules span {
  color: var(--muted);
  font-weight: 800;
}

.tier-rule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.tier-rule-card {
  display: grid;
  gap: 6px;
  min-height: 118px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.tier-rule-card.active {
  border-color: rgba(38, 182, 178, 0.5);
  background: #ecfeff;
}

.tier-rule-card span {
  color: var(--muted);
  font-weight: 800;
}

.tier-rule-card strong {
  font-size: 22px;
}

.tier-rule-card em {
  color: var(--muted);
  font-style: normal;
  line-height: 1.45;
}

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

.rule-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.rule-list span {
  color: var(--muted);
}

.document-table .table-row {
  grid-template-columns: 1.2fr 0.8fr 0.7fr 0.8fr;
}

.df-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.42fr);
  gap: 18px;
}

.df-table .table-row {
  grid-template-columns: 0.55fr 1.1fr 0.8fr 0.65fr 1fr;
}

.df-summary {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.notification-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.45fr);
  gap: 18px;
}

.notification-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

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

.notification-list div {
  display: grid;
  grid-template-columns: 0.55fr minmax(0, 1fr) minmax(160px, 0.45fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: #ffffff;
}

.notification-list div.warning {
  border-left-color: var(--amber);
  background: #fffbeb;
}

.notification-list div.critical {
  border-left-color: var(--coral);
  background: #fef2f2;
}

.notification-list div.done {
  opacity: 0.62;
  border-left-color: #94a3b8;
  background: #f8fafc;
}

.notification-list span,
.notification-list em {
  color: var(--muted);
  font-style: normal;
}

.data-tools-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.45fr);
  gap: 18px;
}

.import-dropzone {
  display: grid;
  place-items: center;
  min-height: 150px;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  background: #f8fafc;
  text-align: center;
  cursor: pointer;
}

.import-dropzone.drag-over {
  border-color: var(--teal);
  background: #ecfeff;
}

.import-dropzone span {
  margin-top: 6px;
  color: var(--muted);
}

.import-table .table-row {
  grid-template-columns: 1.3fr 0.8fr 0.6fr 0.6fr;
}

.export-list,
.validation-panel {
  display: grid;
  gap: 10px;
}

.export-list div,
.validation-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.prototype-state-panel {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.state-backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.file-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.file-action input {
  display: none;
}

.validation-panel {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.validation-row span,
.export-list span {
  color: var(--muted);
}

.validation-row.warning {
  color: #991b1b;
  background: #fef2f2;
}

.signature-pad {
  display: grid;
  place-items: center;
  min-height: 180px;
  margin-bottom: 16px;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
}

.signature-pad strong {
  color: var(--ink);
  font-size: 36px;
  font-family: "Brush Script MT", cursive;
  font-weight: 500;
}

.consent-preview,
.audit-panel,
.approval-queue {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.consent-preview p {
  margin-bottom: 0;
  color: var(--muted);
}

.audit-list,
.approval-list {
  display: grid;
  gap: 10px;
}

.audit-list div,
.approval-list div {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) minmax(180px, 0.45fr);
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #ffffff;
}

.audit-list span,
.audit-list em,
.approval-list span,
.approval-list em {
  color: var(--muted);
  font-style: normal;
}

.split-payment {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.coupon-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 16px 0;
}

.payment-link-panel {
  display: grid;
  gap: 10px;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.payment-control-panel,
.payment-evidence-panel {
  display: grid;
  gap: 12px;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.payment-control-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.payment-control-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.payment-control-row input {
  width: 100%;
}

.payment-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.payment-status-grid div {
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.payment-status-grid span {
  color: var(--muted);
}

.payment-status-grid .warning {
  color: #9a3412;
}

.payment-status-grid .success {
  color: #0f766e;
}

.payment-slip-dropzone {
  display: grid;
  gap: 6px;
  min-height: 112px;
  padding: 18px;
  border: 2px dashed #9db2d3;
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
}

.payment-slip-dropzone strong {
  color: var(--ink);
}

.payment-slip-dropzone.drag-over {
  border-color: var(--primary);
  background: #ecfeff;
}

.qr-preview {
  display: grid;
  place-items: center;
  width: 120px;
  height: 120px;
  border-radius: 8px;
  color: var(--ink);
  background:
    linear-gradient(90deg, #111827 10px, transparent 10px) 0 0 / 24px 24px,
    linear-gradient(#111827 10px, transparent 10px) 0 0 / 24px 24px,
    #ffffff;
  font-weight: 900;
}

.payment-link-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ffffff;
}

.payment-link-row span {
  color: var(--muted);
}

.marketing-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.45fr);
  gap: 18px;
}

.campaign-table .table-row {
  grid-template-columns: 1fr 0.8fr 0.6fr 0.8fr 0.7fr;
}

.marketing-consent-panel {
  grid-column: 1 / -1;
}

.consent-rule-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.consent-audit-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.consent-audit-list div {
  display: grid;
  grid-template-columns: 70px minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.consent-audit-list span,
.consent-audit-list em {
  color: var(--muted);
  font-style: normal;
}

.split-payment h3 {
  margin-bottom: 2px;
}

.split-payment div {
  display: flex;
  justify-content: space-between;
}

.split-payment .split-balance {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  font-weight: 800;
}

.split-payment .split-balance.warning {
  border-color: #fed7aa;
  color: #9a3412;
  background: #fff7ed;
}

.button-row,
.receipt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.installment-panel,
.outstanding-strip,
.approval-panel {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.installment-row,
.approval-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ffffff;
}

.installment-row span,
.outstanding-strip span,
.approval-row span {
  color: var(--muted);
}

.installment-row.warning,
.approval-row.warning {
  color: #991b1b;
  background: #fef2f2;
}

.outstanding-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.outstanding-strip div {
  padding: 12px;
  border-radius: 8px;
  background: #ffffff;
}

.outstanding-strip span {
  display: block;
  margin-bottom: 5px;
}

.receipt-size {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.receipt-size h3 {
  width: 100%;
  margin-bottom: 0;
}

/* OPD Print grouped chip layout */
.receipt-size.opd-print-config {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 10px;
}

.opd-print-group {
  display: grid;
  gap: 5px;
}

.opd-print-group-label {
  font-size: 10.5px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.opd-print-group-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* Visual separator between chip sub-groups (e.g. A4/A5 | แนวตั้ง/แนวนอน) */
.opd-print-separator {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 2px;
}

.opd-print-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.opd-print-action-row .primary-action {
  min-height: 36px;
  padding: 0 20px;
}

.daily-close-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.45fr);
  gap: 18px;
}

.cash-count {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.line-preview {
  margin-top: 16px;
}

.line-preview p {
  margin-bottom: 0;
  color: var(--muted);
}

.doctor-line-panel {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.doctor-line-list {
  display: grid;
  gap: 8px;
}

.doctor-line-list div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: #ffffff;
}

.doctor-line-list span,
.doctor-line-list em {
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.security-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.branch-readiness {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.branch-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ffffff;
}

.branch-row.active {
  border-left: 4px solid var(--primary);
}

.branch-row span {
  color: var(--muted);
}

.readiness-score {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.readiness-score div {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.readiness-score span,
.readiness-score em,
.readiness-list span,
.readiness-list em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.readiness-score strong {
  color: var(--ink);
  font-size: 28px;
}

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

.readiness-board section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.readiness-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.readiness-list div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: #ffffff;
}

.readiness-list.good div {
  border-left-color: var(--acc-bright);
}

.readiness-list.warning div {
  border-left-color: #f59e0b;
}

.readiness-list.action div {
  border-left-color: #6366f1;
}

.security-grid section {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.security-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ffffff;
}

.security-row span {
  color: var(--muted);
}

.reports-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.report-card {
  min-height: 180px;
  cursor: pointer;
}

.report-card.selected {
  border-color: var(--primary);
  box-shadow: inset 4px 0 0 var(--primary);
}

.report-card strong {
  display: block;
  margin: 28px 0 8px;
  font-size: 30px;
}

.report-detail-panel {
  margin-top: 18px;
}

.report-detail-list {
  display: grid;
  gap: 8px;
}

.report-detail-list div {
  display: grid;
  grid-template-columns: 0.7fr minmax(0, 1fr) minmax(160px, 0.5fr);
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.report-detail-list span,
.report-detail-list em {
  color: var(--muted);
  font-style: normal;
}

.settings-layout {
  position: relative;
  grid-template-columns: 220px minmax(0, 1fr);
}

.settings-menu {
  position: sticky;
  top: 18px;
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 6px 12px;
  scroll-behavior: smooth;
  /* subtle scrollbar */
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.settings-menu::-webkit-scrollbar { width: 6px; }
.settings-menu::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.settings-menu::-webkit-scrollbar-track { background: transparent; }

.settings-menu button {
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
}
.settings-menu button.active {
  transform: translateX(2px);
  font-weight: 700;
}

.settings-menu button {
  border: 1px solid var(--line);
  padding: 0 12px;
  background: #ffffff;
  text-align: left;
}

.settings-menu button.active {
  color: #ffffff;
  background: var(--ink);
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.settings-section-card {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

/* ============================================================
 * TAB MODE — click left nav swaps to ONE section in right pane.
 * No scrolling, no fatigue. activateSettingsSection() in app.js
 * applies .is-active-section to the target. Body gets
 * .settings-tab-mode the moment the Settings view opens.
 * ============================================================ */
body.settings-tab-mode .settings-section-card { display: none; }
body.settings-tab-mode .settings-section-card.is-active-section { display: block; }
/* security-grid contains 3 sub-sections. In tab mode hide all three by
 * default; the parent grid is hidden too. The active sub gets shown +
 * the parent gets .has-active-tab so it stays visible. */
body.settings-tab-mode .security-grid { display: none; }
body.settings-tab-mode .security-grid.has-active-tab { display: grid; }
body.settings-tab-mode .security-grid > section { display: none; }
body.settings-tab-mode .security-grid > section.is-active-section { display: block; }
/* Section-flash + opd-attention pulses are designed for scroll mode; mute
 * them in tab mode since the user already sees the section instantly. */
body.settings-tab-mode .opd-attention,
body.settings-tab-mode .section-flash { animation: none !important; }
/* Active nav button — bolder accent so the current tab is unmistakable. */
body.settings-tab-mode .settings-menu button.active {
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.18);
}

.settings-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.settings-mini-grid div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.settings-mini-grid span,
.settings-mini-grid em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

/* LINE OA test panel */
.line-test-panel {
  margin-top: 16px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #fdfdff;
  display: grid;
  gap: 10px;
}
.line-test-panel h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}
.line-test-panel p.muted {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
}
.line-test-field {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.line-test-field input,
.line-test-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 500;
  resize: vertical;
}
.line-test-field input:focus,
.line-test-field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(38, 182, 178, 0.16);
}
.line-test-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.line-test-result {
  margin: 0;
  padding: 10px 12px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  color: #1e293b;
  background: #0f172a08;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* LINE Routing card grid */
.line-routing-toggles {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.line-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}
.line-toggle input { width: 18px; height: 18px; cursor: pointer; }

.line-routing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

/* LINE troubleshooting block (collapsible) */
.line-troubleshoot {
  margin: 14px 0;
  padding: 12px 16px;
  background: #fff8e6;
  border: 1px solid #f5d77a;
  border-radius: 10px;
  font-size: 13px;
  color: #6a4c10;
}
.line-troubleshoot summary {
  cursor: pointer;
  font-weight: 700;
  color: #7d5400;
  user-select: none;
}
.line-troubleshoot ol { margin: 10px 0 6px 22px; padding: 0; line-height: 1.7; }
.line-troubleshoot ol li { margin-bottom: 6px; }
.line-troubleshoot code {
  padding: 1px 6px;
  background: #fff;
  border: 1px solid #e0c060;
  border-radius: 4px;
  font-size: 12px;
  color: #553700;
}
.line-troubleshoot p { margin: 8px 0 0; }

/* LINE Users captured-from-webhook panel */
.settings-line-users { display: grid; gap: 12px; }
.line-users-hint {
  padding: 12px 14px;
  background: #f4f7ff;
  border: 1px solid #d3deff;
  border-radius: 10px;
  font-size: 13px;
  color: #3c4f7a;
  line-height: 1.55;
}
.line-users-hint code {
  padding: 2px 6px;
  background: #ffffff;
  border: 1px solid #c8d3f0;
  border-radius: 4px;
  font-size: 12px;
  color: #1a2a55;
}
.line-users-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.line-users-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.line-users-tab:hover { border-color: #94a3b8; }
.line-users-tab.active {
  background: #6b21a8;
  border-color: #6b21a8;
  color: #fff;
}
.line-users-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(100, 116, 139, .18);
  color: inherit;
  font-size: 12px;
  font-weight: 700;
}
.line-users-tab.active .line-users-tab-count { background: rgba(255, 255, 255, .28); }
.line-users-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
}
.line-users-pagination button[disabled] { opacity: .45; cursor: default; }
.line-users-page-label { font-size: 13px; color: #475569; font-weight: 600; }
.line-users-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.line-users-table {
  width: 100%;
  min-width: 600px; /* avatar+name+id+pill+actions — scroll on mobile, not squish */
  border-collapse: collapse;
  font-size: 13px;
}
.line-users-table thead th {
  position: sticky;
  top: 0;
  background: #f8f9fb;
  text-align: left;
  padding: 10px 12px;
  font-weight: 700;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.line-users-table tbody td {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}
.line-users-table tbody tr:hover { background: #fafbff; }
.line-users-table .line-user-avatar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.line-users-table .line-user-avatar img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}
.line-users-table .line-user-avatar .placeholder {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #6c5ce7);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}
.line-users-table .line-user-name { font-weight: 700; }
.line-users-table .line-user-id-cell {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: #555;
}
.line-users-table .line-user-bound-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.line-users-table .line-user-bound-pill.bound { background: #e0f7e9; color: #176b3a; }
.line-users-table .line-user-bound-pill.unbound { background: #fdecec; color: #a02020; }
.line-users-table .line-user-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.line-users-table .line-user-actions button {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}
.line-users-table .line-user-actions button:hover { background: #f0f3ff; border-color: #b9c5e8; }
.line-users-table .line-user-actions button.danger { color: #a02020; border-color: #f0b3b3; }
.line-users-table .line-users-empty td {
  padding: 30px 20px;
  text-align: center;
  color: #888;
}
.line-users-table .line-users-empty code {
  padding: 2px 6px;
  background: #f0f3ff;
  border-radius: 4px;
  font-size: 12px;
}
.line-routing-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.line-routing-card h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}
.line-routing-card > span.muted {
  font-size: 11.5px;
  line-height: 1.4;
}

.line-recipient-list, .line-doctor-list, .line-audit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.line-recipient-list li,
.line-doctor-list li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid #f1f5f9;
  border-radius: 6px;
  background: #fafbfc;
  font-size: 12px;
}
.line-recipient-list li.line-empty,
.line-doctor-list li.line-empty {
  background: transparent;
  border: 1px dashed #cbd5e1;
  font-style: italic;
  color: var(--muted);
  justify-content: center;
}
.line-recipient-list strong, .line-doctor-list strong {
  flex: 1;
  font-weight: 700;
  color: var(--ink);
  font-size: 12.5px;
}
.line-recipient-list code, .line-doctor-list code {
  font-size: 10.5px;
  color: #475569;
  padding: 1px 5px;
  background: #e2e8f0;
  border-radius: 4px;
  font-family: ui-monospace, Menlo, monospace;
}

.line-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.line-badge.success { background: #d1fae5; color: #047857; }
.line-badge.warning { background: #fef3c7; color: #b45309; }

.line-add-recipient {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  gap: 6px;
  margin-top: 4px;
}
.line-add-recipient input {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
}
.line-add-recipient input:focus {
  outline: none;
  border-color: var(--primary);
}

.line-doctor-roster {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  display: grid;
  gap: 8px;
}
.line-doctor-roster h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
}
.line-doctor-roster > span.muted {
  font-size: 11.5px;
}

.line-audit-trail {
  margin-top: 12px;
}
.line-audit-trail summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px;
  background: #f1f5f9;
  border-radius: 6px;
  user-select: none;
}
.line-audit-list {
  margin-top: 8px;
}
.line-audit-list li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  font-size: 11.5px;
  background: #fafbfc;
  border: 1px solid #f1f5f9;
  border-radius: 6px;
}
.line-audit-time {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: var(--muted);
}

/* Broadcast section */
.line-broadcast-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}
.line-broadcast-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}
.line-broadcast-actions .muted { flex: 1; font-size: 12px; }

/* Doctor admin editor */
.doctor-roster-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.doctor-roster-empty {
  text-align: center;
  padding: 14px;
  font-style: italic;
}
.team-member-list,
.team-room-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}
.team-member-row,
.team-room-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) minmax(180px, 1.5fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.team-room-row { grid-template-columns: minmax(180px, 1fr) auto auto; }
.team-member-row.inactive,
.team-room-row.inactive { opacity: 0.55; background: #f8fafc; }
.team-member-row input[type="text"],
.team-room-row input[type="text"] {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  width: 100%;
}
.team-member-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}
.team-member-toggle input { width: 16px; height: 16px; cursor: pointer; }
.doctor-roster-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
}
.doctor-roster-card[open] {
  border-color: var(--primary, var(--primary));
  box-shadow: 0 4px 14px rgba(38, 182, 178, 0.10);
}
.doctor-roster-card summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  flex-wrap: wrap;
}
.doctor-roster-card summary::-webkit-details-marker { display: none; }
.doctor-roster-card summary::before {
  content: "▶";
  color: var(--primary);
  font-size: 11px;
  transition: transform 0.2s;
}
.doctor-roster-card[open] summary::before { transform: rotate(90deg); }
.doctor-roster-card summary strong {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}
.doctor-roster-card summary .muted {
  font-size: 12.5px;
}
.doctor-card-badges {
  margin-left: auto;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.doctor-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.3px;
}
.doctor-badge.owner { background: #fef3c7; color: #92400e; }
.doctor-badge.active { background: #d1fae5; color: #047857; }
.doctor-badge.inactive { background: #f3f4f6; color: #6b7280; }
.doctor-badge.line-linked { background: #ecfdf5; color: #047857; }
.doctor-badge.line-missing { background: #fef2f2; color: #b91c1c; }

.doctor-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #fafbfc;
}
.doctor-form-grid label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.doctor-form-grid label.wide-field { grid-column: 1 / -1; }
.doctor-form-grid input,
.doctor-form-grid textarea {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 500;
  font-family: inherit;
  resize: vertical;
}
.doctor-form-grid input:focus,
.doctor-form-grid textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(38, 182, 178, 0.14);
}
.doctor-flag-row {
  display: flex;
  gap: 16px;
  padding: 4px 0;
}
.doctor-flag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}
.doctor-flag input { width: 18px; height: 18px; }

.doctor-signature-row {
  display: grid;
  gap: 6px;
}
.doctor-signature-control {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.doctor-signature-preview {
  height: 64px;
  max-width: 200px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  padding: 4px;
}
.doctor-signature-empty {
  height: 64px;
  width: 200px;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  color: var(--muted);
  font-style: italic;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
}
.doctor-signature-actions {
  display: flex;
  gap: 6px;
}
.doctor-signature-actions .ghost-button {
  cursor: pointer;
  font-size: 12.5px;
}
.doctor-card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 4px;
}

/* QR Intake panel */
.qr-intake-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 1.4fr;
  gap: 18px;
  margin: 14px 0;
}
.qr-intake-display {
  text-align: center;
  padding: 18px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.qr-code-box img {
  width: 240px;
  height: 240px;
  border-radius: 12px;
  background: #fff;
  padding: 8px;
  box-shadow: 0 4px 12px rgba(15,23,42,0.06);
}
.qr-placeholder {
  width: 240px;
  height: 240px;
  display: grid;
  place-items: center;
  background: #fff;
  border-radius: 12px;
  color: var(--muted);
  margin: 0 auto;
}
.qr-intake-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn-link {
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  font-weight: 700;
}
.btn-link:hover { background: rgba(38, 182, 178, 0.08); }

.qr-intake-info { font-size: 13px; line-height: 1.6; }
.qr-intake-info h3 { font-size: 14px; font-weight: 800; margin: 0 0 8px; }
.qr-intake-info ol { padding-left: 18px; margin: 0; color: var(--ink); }
.qr-intake-info ol li { margin: 4px 0; }
.qr-intake-langs {
  margin-top: 12px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #eef2ff 0%, #fdf4ff 100%);
  border-radius: 8px;
  font-size: 12px;
  color: #4c1d95;
  font-weight: 600;
}

.intake-pending-list { display: grid; gap: 8px; margin-top: 8px; }
.intake-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.intake-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.intake-card-head strong { font-size: 14px; color: var(--ink); }
.intake-lang-pill {
  background: #ede9fe;
  color: #6d28d9;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.3px;
}
.intake-card {
  flex-direction: column;
  align-items: stretch;
}
.intake-card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: 12px;
}
.intake-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.intake-card.status-approved { background: #f0fdf4; border-color: #bbf7d0; }
.intake-card.status-rejected { background: #fef2f2; border-color: #fecaca; opacity: 0.85; }
.intake-status-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.3px;
}
.intake-status-pill.pending { background: #fef3c7; color: #92400e; }
.intake-status-pill.approved { background: #d1fae5; color: #047857; }
.intake-status-pill.rejected { background: #fee2e2; color: #b91c1c; }
.intake-hn-pill {
  background: #dbeafe;
  color: #1e40af;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.intake-list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 18px;
  flex-wrap: wrap;
  gap: 6px;
}
.intake-list-head h3 { margin: 0; }
.intake-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin-left: 4px;
}
.intake-processed-wrap {
  margin-top: 16px;
  padding: 8px 0;
  border-top: 1px dashed var(--line);
}
.intake-processed-wrap summary {
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  font-weight: 700;
}
.intake-processed-wrap summary h3 { margin: 0; }
.intake-processed-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

/* Intake review modal */
.intake-review {
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 6px;
}
.intake-review h3 {
  margin: 18px 0 8px;
  font-size: 13px;
  color: var(--primary);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}
.intake-summary-bar {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: linear-gradient(135deg, #eef2ff 0%, #ecfeff 100%);
  border-radius: 8px;
  font-size: 12.5px;
  margin-bottom: 10px;
}
.intake-summary-bar strong { font-size: 15px; }
.intake-field-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
  align-items: start;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid #f1f5f9;
}
.intake-field-label { color: var(--muted); font-weight: 700; }
.intake-orig { color: var(--ink); font-weight: 500; }
.intake-trans { color: var(--primary); font-size: 12.5px; margin-top: 2px; font-style: italic; }
.intake-consents-row { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 0; }
.consent-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
}
.consent-badge.ok { background: #d1fae5; color: #047857; }
.consent-badge.bad { background: #fee2e2; color: #b91c1c; }
.intake-signature {
  max-width: 240px;
  max-height: 100px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 4px;
}
.intake-summary-bar { align-items: center; }
.intake-selfie-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 8px rgba(15,23,42,0.15);
  cursor: zoom-in;
}
.intake-selfie-wrap {
  display: flex;
  justify-content: center;
  padding: 10px 0;
}
.intake-selfie-full {
  max-width: 240px;
  max-height: 320px;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(15,23,42,0.1);
  object-fit: cover;
}

@media (max-width: 720px) {
  .qr-intake-grid { grid-template-columns: 1fr; }
}

/* Vision intake modal */
.vision-intake {
  display: grid;
  gap: 14px;
  padding: 0 0 8px;
}
.vision-uploader {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 28px 16px;
  border: 2px dashed #94a3b8;
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}
.vision-uploader:hover, .vision-uploader.drag-over {
  border-color: var(--primary, var(--primary));
  background: #ecfeff;
}
.vision-uploader strong { font-size: 14px; color: var(--ink); }
.vision-uploader .muted { font-size: 12px; }

.vision-preview {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.vision-preview img {
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid var(--line);
}
.vision-preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}
.vision-preview-meta strong { color: var(--ink); font-weight: 700; }

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

.vision-loading {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.vision-error {
  padding: 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #b91c1c;
  font-size: 13px;
}

.vision-result-header {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  margin-bottom: 12px;
}
.vision-result-header strong { font-size: 13px; color: #047857; }
.vision-notes {
  font-size: 12px;
  color: #075985;
  background: #f0f9ff;
  padding: 6px 8px;
  border-radius: 6px;
}

.vision-draft-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.vision-draft-grid label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.vision-draft-grid label.wide-field { grid-column: 1 / -1; }
.vision-draft-grid input,
.vision-draft-grid select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 500;
  font-family: inherit;
}
.vision-draft-grid input:focus,
.vision-draft-grid select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(38, 182, 178, 0.14);
}

.conf-pill {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
  font-style: normal;
  letter-spacing: 0.3px;
}
.conf-pill.conf-high { background: #d1fae5; color: #047857; }
.conf-pill.conf-mid { background: #fef3c7; color: #b45309; }
.conf-pill.conf-low { background: #fee2e2; color: #b91c1c; }

/* Customer import */
.customer-import { display: grid; gap: 12px; }
.import-template-help {
  margin-top: 10px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  font-size: 12.5px;
}
.import-template-help strong { display: block; margin-bottom: 4px; font-size: 13px; }
.import-template-help p { margin: 4px 0; color: var(--muted); }
.import-template-help code { background: #fff; padding: 2px 6px; border-radius: 4px; font-size: 11px; color: #475569; }
.import-map-table { width: 100%; border-collapse: collapse; }
.import-map-table th, .import-map-table td { padding: 6px 8px; text-align: left; font-size: 12.5px; border-bottom: 1px solid #f1f5f9; }
.import-map-table th { background: #f8fafc; font-weight: 700; color: var(--muted); }
.import-map-table select { width: 100%; padding: 5px 8px; border: 1px solid var(--line); border-radius: 5px; font-size: 12.5px; font-family: inherit; }
.import-preview-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.import-stat { padding: 6px 12px; background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 6px; font-size: 12.5px; color: #047857; }
.import-stat.warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.import-stat strong { font-weight: 800; }
.import-preview-tbl { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.import-preview-tbl th, .import-preview-tbl td { padding: 4px 8px; border: 1px solid var(--line); text-align: left; }
.import-preview-tbl th { background: #f8fafc; font-weight: 700; }

.vision-thumbs {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.vision-thumbs-summary {
  font-size: 12.5px;
  color: var(--muted);
}
.vision-thumbs-summary strong { color: var(--ink); font-weight: 700; }
.vision-thumbs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 6px;
}
.vision-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
}
.vision-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vision-thumb .thumb-label {
  position: absolute; top: 4px; left: 4px;
  background: rgba(0,0,0,0.65); color: #fff;
  font-size: 11px; font-weight: 800;
  padding: 1px 6px; border-radius: 4px;
}
.vision-thumb .thumb-remove {
  position: absolute; top: 4px; right: 4px;
  background: rgba(239, 68, 68, 0.9); color: #fff;
  border: none; cursor: pointer;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: 12px; font-weight: 800;
  display: grid; place-items: center;
  padding: 0;
}

.vision-item-card {
  margin: 12px 0;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(15,23,42,0.02);
}
/* Select-all bar above the review item list */
.vision-select-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin: 10px 0;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: 8px;
  font-size: 14px;
}
/* Dim unchecked review cards so it's obvious they won't be imported */
.vision-item-card:has(.vision-item-select:not(:checked)) {
  opacity: 0.5;
  background: #f9fafb;
}
.vision-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}
.vision-item-header strong { font-size: 14px; color: var(--primary, var(--primary)); }

.vision-trackby-toggle {
  display: grid;
  gap: 6px;
  padding: 8px;
  background: #f8fafc;
  border-radius: 6px;
}
.vision-tb-opt {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.15s;
}
.vision-tb-opt:hover { background: #ffffff; }
.vision-tb-opt input { margin-top: 2px; cursor: pointer; }
.vision-tb-opt span { font-size: 12.5px; line-height: 1.5; }
.vision-tb-opt span strong { font-weight: 700; color: var(--ink); }
.vision-tb-opt span em { font-style: normal; color: var(--muted); font-size: 11.5px; }

.vision-ambig {
  margin-top: 8px;
  padding: 8px 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  color: #92400e;
  font-size: 12.5px;
}
.vision-ambig ul { margin: 4px 0 0 18px; padding: 0; }

@media (max-width: 600px) {
  .vision-draft-grid { grid-template-columns: 1fr; }
}

/* Editable vital signs on OPD card */
.editable-vital {
  cursor: text;
  border-bottom: 1px dashed #cbd5e1;
  padding: 0 4px 1px;
  border-radius: 3px;
  outline: none;
  transition: background 0.15s, border-color 0.15s;
}
.editable-vital:hover { background: #f0f9ff; border-bottom-color: var(--primary, var(--primary)); }
.editable-vital:focus { background: #ecfeff; border-bottom-style: solid; border-bottom-color: var(--primary, var(--primary)); }

/* Print: remove dashed underline */
@media print {
  .editable-vital { border-bottom: none; padding: 0; }
}

/* Product row highlight after add */
.table-row.highlight-new {
  animation: highlightNew 2.2s ease;
  background: linear-gradient(90deg, #fef9c3 0%, #ecfdf5 100%);
}
@keyframes highlightNew {
  0% { background: #fef9c3; transform: scale(1.01); }
  60% { background: #ecfdf5; transform: scale(1); }
  100% { background: transparent; }
}
.row-meta {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: #64748b;
  font-style: normal;
  font-weight: 500;
}

/* Branch admin editor */
.branch-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.branch-empty {
  text-align: center;
  padding: 14px;
  font-style: italic;
}
.branch-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.branch-card[open] {
  border-color: var(--primary, var(--primary));
  box-shadow: 0 4px 14px rgba(38, 182, 178, 0.10);
}
.branch-card summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  flex-wrap: wrap;
}
.branch-card summary::-webkit-details-marker { display: none; }
.branch-card summary::before {
  content: "▶";
  color: var(--primary);
  font-size: 11px;
  transition: transform 0.2s;
}
.branch-card[open] summary::before { transform: rotate(90deg); }
.branch-card summary strong {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}
.branch-card summary .muted { font-size: 12.5px; }
.branch-summary-badges {
  margin-left: auto;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.branch-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.3px;
}
.branch-badge.main { background: #fef3c7; color: #92400e; }
.branch-badge.warehouse { background: #e0e7ff; color: #4338ca; }
.branch-badge.success { background: #d1fae5; color: #047857; }
.branch-badge.warning { background: #fef3c7; color: #92400e; }
.branch-badge.muted { background: #f3f4f6; color: #6b7280; }
.branch-badge.info { background: #e0e7ff; color: #4338ca; }

.branch-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #fafbfc;
}
.branch-form-grid label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.branch-form-grid label.wide-field { grid-column: 1 / -1; }
.branch-form-grid input,
.branch-form-grid textarea,
.branch-form-grid select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 500;
  font-family: inherit;
  resize: vertical;
}
.branch-form-grid input:focus,
.branch-form-grid textarea:focus,
.branch-form-grid select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(38, 182, 178, 0.14);
}
.branch-flag-row {
  display: flex;
  gap: 16px;
  padding: 4px 0;
}

@media (max-width: 600px) {
  .branch-form-grid { grid-template-columns: 1fr; }
}

/* Medical certificate doctor signature block */
.cert-signature-block {
  display: grid;
  gap: 4px;
}
.cert-signature-line {
  font-size: 12px;
  color: #475569;
}
.cert-signature-image-slot {
  display: grid;
  gap: 6px;
  min-height: 60px;
}
#certPreviewSignature {
  max-height: 70px;
  max-width: 200px;
  object-fit: contain;
}
.cert-doctor-fullname {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}
.cert-doctor-specialty {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}
#certPreviewLicense {
  font-size: 12px;
  color: #1e293b;
}

@media (max-width: 600px) {
  .doctor-form-grid {
    grid-template-columns: 1fr;
  }
}

/* AI card buttons (clickable) */
.ai-card-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary, var(--primary)) 0%, #1d9692 100%);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.ai-card-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(38, 182, 178, 0.25);
}
.ai-card-button:active {
  transform: translateY(0);
}

.wide-field {
  grid-column: 1 / -1;
}

.clinic-logo-field,
.clinic-color-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.clinic-logo-control,
.clinic-color-control {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.clinic-logo-preview {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 96px;
  height: 96px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #ffffff;
  background: var(--primary);
  font-weight: 900;
  font-size: 22px;
  overflow: hidden;
}

.clinic-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffffff;
}

.clinic-logo-actions {
  display: grid;
  gap: 6px;
}

/* Logo display options — apply to ANY logo image with these classes */
img.logo-circular {
  border-radius: 50% !important;
  object-fit: cover !important;
  background: transparent !important;
}
/* White-blend: multiply with background → white pixels become transparent
   on top of darker backgrounds (purple, accent colors).
   Works best on logos with pure-white backgrounds.
   Note: looks slightly off on pure-white container, but designed for colored bg. */
img.logo-blend-white {
  mix-blend-mode: multiply;
  background: transparent !important;
}
/* When BOTH circular + blend are on, multiply still works inside the circle */
img.logo-circular.logo-blend-white {
  mix-blend-mode: multiply;
}

.clinic-logo-options {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.logo-process-actions {
  padding: 10px 12px;
  background: #ecfeff;
  border: 1px solid var(--acc-200);
  border-radius: 6px;
}
.logo-process-actions .ghost-button { font-size: 12px; padding: 6px 10px; }

/* Users & Roles management */
.users-role-legend {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}
.role-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}
.role-badge.role-super-admin { background: #dc2626; }
.role-badge.role-admin { background: #9333ea; }
.role-badge.role-doctor { background: var(--primary); }
.role-badge.role-sales { background: #16a34a; }
.role-badge.role-bt { background: #ea580c; }
.role-badge.role-marketing { background: #db2777; }
.role-badge.role-accounting { background: #475569; }

.users-table-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  /* Horizontal scroll instead of clipping — on mobile the action column
     (2FA/ลิงก์/devices/reset/delete) sits off-screen; this lets the user swipe
     left/right to reach it. -webkit-overflow-scrolling gives momentum on iOS. */
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 14px;
}
.users-table {
  width: 100%;
  /* Keep columns readable; on narrow screens this forces the wrap to scroll
     horizontally rather than squishing the action buttons into nothing. */
  min-width: 820px;
  border-collapse: collapse;
  font-size: 13px;
}
/* Scroll hint only matters where the table can't fit (mobile/tablet) */
@media (max-width: 860px) {
  .users-table-scroll-hint { display: block !important; }
}
.users-table thead {
  background: #f8fafc;
}
/* Clickable profile-photo avatar in the name cell */
.user-avatar-edit {
  position: relative;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: #0ea5e9;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid #e2e8f0;
}
.user-avatar-edit .user-avatar-cam {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #0f172a;
  color: #fff;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #fff;
}
.users-table th {
  padding: 8px 12px;
  text-align: left;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink);
}
.users-table tbody tr {
  border-top: 1px solid var(--line);
}
.users-table tbody tr.user-inactive { opacity: 0.5; }
.users-table tbody tr:hover { background: #fafbff; }
.users-table td { padding: 6px 8px; vertical-align: middle; }
.users-table input[type="text"],
.users-table input[type="email"],
.users-table select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
}
.users-table input[type="text"]:hover,
.users-table input[type="email"]:hover,
.users-table select:hover,
.users-table input[type="text"]:focus,
.users-table input[type="email"]:focus,
.users-table select:focus {
  background: #fff;
  border-color: var(--primary);
  outline: none;
}
.users-table small { display: block; font-size: 10px; padding-left: 8px; }
.users-active-toggle {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  cursor: pointer;
  font-size: 12px;
}
.users-active-toggle input { width: 14px; height: 14px; cursor: pointer; }

.users-perm-matrix {
  margin: 14px 0;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.users-perm-matrix summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  user-select: none;
}
/* Generic horizontal-scroll wrapper for any wide table on narrow screens. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 10px;
}
.perm-table {
  width: 100%;
  min-width: 640px; /* 8 columns — overflow + scroll on mobile, not squish */
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 10px;
}
.perm-table th, .perm-table td {
  padding: 5px 8px;
  border: 1px solid var(--line);
  text-align: center;
}
.perm-table th { background: #ede9fe; font-weight: 700; }
.perm-table td:first-child { text-align: left; font-weight: 600; }

.auth-roadmap-note {
  margin-top: 14px;
  padding: 12px 14px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  font-size: 12px;
  color: #92400e;
}
.auth-roadmap-note strong { display: block; margin-bottom: 4px; font-size: 13px; }
.auth-roadmap-note p { margin: 0; line-height: 1.55; }

/* Customer list filters: tag chips + HN-range tabs */
.customer-filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0;
}
.customer-filter-chips .chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.customer-filter-chips .chip:hover { background: #f1f5f9; }
.customer-filter-chips .chip.active {
  background: var(--primary, var(--primary));
  color: #ffffff;
  border-color: var(--primary, var(--primary));
}
.chip-count {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.7;
  margin-left: 4px;
}
.customer-range-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.range-tab {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fafbfc;
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  font-family: inherit;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  transition: all 0.15s;
}
.range-tab:hover { background: #e0e7ff; }
.range-tab.active {
  background: #4c1d95;
  color: #fff;
  border-color: #4c1d95;
}
.range-count {
  font-size: 10px;
  opacity: 0.7;
  margin-left: 4px;
  background: rgba(255,255,255,0.2);
  padding: 1px 6px;
  border-radius: 999px;
}
.range-tab:not(.active) .range-count {
  background: #e2e8f0;
}
.customer-list-info {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  padding: 4px 8px;
}

.customer-dedupe-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 8px 8px;
  padding: 8px 12px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  font-size: 13px;
  color: #92400e;
}
.customer-dedupe-bar button {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
}

.dedupe-group {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  background: #f9fafb;
}
.dedupe-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 700;
}
.dedupe-group-head .reason {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}
.dedupe-entry {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 12px;
}
.dedupe-entry.primary {
  background: #ecfdf5;
  border-color: #6ee7b7;
}
.dedupe-entry input[type="radio"] {
  margin: 0;
}
.dedupe-entry .meta {
  font-size: 11px;
  color: var(--muted);
}
.dedupe-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

/* Medicine label form */
.med-label-form {
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 6px;
  display: grid;
  gap: 10px;
}
.med-label-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  padding: 10px 12px;
  background: var(--acc-50);
  border: 1px solid var(--acc-200);
  border-radius: 8px;
}
.med-label-head strong { font-size: 15px; }
.med-label-form h4 {
  margin: 8px 0 4px;
  font-size: 13px;
  font-weight: 800;
  color: var(--primary-dark, #1d9692);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.med-label-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.med-timing-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 6px;
}
.med-timing-checkboxes label {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  cursor: pointer;
}
.med-timing-checkboxes input { width: 16px; height: 16px; cursor: pointer; }

/* Medicine templates + sets panel */
.med-tmpl-panel {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.med-tmpl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.med-tmpl-label {
  font-size: 12px;
  font-weight: 800;
  color: #475569;
  margin-right: 4px;
  white-space: nowrap;
}
.med-tmpl-chip {
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #4338ca;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
}
.med-tmpl-chip:hover { background: #4338ca; color: #fff; border-color: #4338ca; }
.med-set-chip {
  border: 1px solid #fbcfe8;
  background: #fdf2f8;
  color: #be185d;
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all .12s;
}
.med-set-chip em { font-style: normal; opacity: .7; font-size: 11px; }
.med-set-chip:hover { background: #be185d; color: #fff; border-color: #be185d; }

/* Drug-name autocomplete dropdown */
.med-dd {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  margin-top: 2px;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .18);
}
.med-dd-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: none;
  background: none;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
}
.med-dd-item:hover { background: #eef2ff; }
.med-dd-item:last-child { border-bottom: 0; }
.med-dd-tag {
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  color: #4338ca;
  background: #eef2ff;
  border-radius: 4px;
  padding: 1px 6px;
  flex-shrink: 0;
}
.med-dd-tag.stock { color: #047857; background: #ecfdf5; }

/* Rich Menu uploader */
.richmenu-config-block {
  padding: 14px;
  background: #faf5ff;
  border: 1px solid #e9d5ff;
  border-radius: 10px;
  margin-top: 14px;
}
.richmenu-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-top: 12px;
  flex-wrap: wrap;
}
.richmenu-side {
  flex: 1 1 240px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.richmenu-reqs {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.7;
}
.richmenu-reqs .warn { color: #b91c1c; list-style: none; margin-left: -18px; }
.richmenu-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
}
.richmenu-upload-area {
  position: relative;
  padding: 16px 14px;
  border: 2px dashed #c084fc;
  border-radius: 12px;
  text-align: center;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.15s;
  aspect-ratio: 2500 / 1686;
  flex: 0 0 clamp(260px, 40%, 440px);
  max-width: 440px;
  overflow: hidden;
}
.richmenu-upload-area.dragging { background: #f3e8ff; border-color: #9333ea; }
.richmenu-upload-area #richmenuPlaceholder {
  display: grid;
  gap: 6px;
  place-items: center;
  height: 100%;
}
.richmenu-upload-area #richmenuPlaceholder strong { font-size: 15px; color: #6d28d9; }
.richmenu-upload-area #richmenuPlaceholder small { font-size: 11px; color: #6b7280; }
.richmenu-upload-area img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.richmenu-upload-area #richmenuCellOverlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.richmenu-cell-marker {
  position: absolute;
  background: rgba(167, 139, 250, 0.2);
  border: 1px solid rgba(124, 58, 237, 0.5);
  color: #4c1d95;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  padding: 4px;
  text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}
.richmenu-cell-list {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}
.richmenu-cell-config {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.richmenu-cell-num {
  width: 28px; height: 28px;
  background: #a855f7;
  color: #fff;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800; font-size: 13px;
  flex-shrink: 0;
}
.richmenu-cell-fields {
  display: grid;
  grid-template-columns: 1fr 100px 2fr;
  gap: 6px;
  flex: 1;
}
.richmenu-cell-fields input,
.richmenu-cell-fields select {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  width: 100%;
}

.qr-intake-liff-warn {
  padding: 10px 14px;
  margin: 0 0 12px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  font-size: 13px;
  color: #92400e;
  line-height: 1.55;
}
.qr-intake-liff-warn code {
  padding: 1px 6px;
  background: rgba(255,255,255,0.5);
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

/* LINE OA config — editable form */
.line-oa-config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin: 10px 0;
}

/* Payment Methods settings */
.payment-config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin: 6px 0 10px;
}
.payment-toggle-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 8px;
}
.payment-preview-card {
  margin-top: 14px;
  padding: 12px;
  background: var(--acc-50);
  border: 1px solid var(--acc-200);
  border-radius: 10px;
}
.payment-preview-card h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--primary-dark, #1d9692);
}
.qr-test-result { margin-top: 10px; }
.qr-test-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 10px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.qr-test-card img {
  width: 160px;
  height: 160px;
  border-radius: 8px;
}
.qr-test-info {
  display: grid;
  gap: 4px;
}
.qr-test-info strong { font-size: 14px; }
.qr-test-info .muted { font-size: 12px; }
.qr-amount {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary-dark, #1d9692);
}

/* Payment modal QR preview (real PromptPay) */
.qr-preview img { max-width: 100%; }
.qr-amount-label {
  margin-top: 6px;
  text-align: center;
  font-weight: 800;
  font-size: 16px;
  color: var(--primary-dark, #1d9692);
}
.qr-payee-label {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.qr-placeholder, .qr-placeholder-warn {
  padding: 24px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.qr-placeholder-warn {
  color: #b91c1c;
  background: #fee2e2;
  border-radius: 8px;
}
.logo-option-toggle {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.5;
}
.logo-option-toggle input { margin-top: 3px; width: 16px; height: 16px; cursor: pointer; }
.logo-option-toggle span strong { font-weight: 700; }

.clinic-logo-dropzone {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 72px;
  min-width: 240px;
  border: 2px dashed var(--line);
  border-radius: 10px;
  padding: 12px 20px;
  color: var(--primary);
  background: #ffffff;
  font-weight: 900;
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.clinic-logo-dropzone:hover,
.clinic-logo-dropzone:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(38, 182, 178, 0.14);
  outline: none;
}

.clinic-logo-dropzone.drag-over {
  border-style: solid;
  border-color: var(--primary);
  background: rgba(38, 182, 178, 0.08);
}

.clinic-logo-dropzone small {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.clinic-logo-actions span,
.clinic-logo-actions em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.logo-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  opacity: 0;
  overflow: hidden;
}

.danger-text {
  color: #b91c1c;
}

.clinic-color-trigger {
  display: grid;
  grid-template-columns: 96px auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  border: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.clinic-color-trigger span {
  display: block;
  width: 96px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--primary);
  box-shadow: inset 0 0 0 4px #ffffff;
}

.clinic-color-popover {
  display: grid;
  gap: 10px;
  max-width: 430px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #ffffff;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
}

.clinic-shade-picker {
  position: relative;
  height: 180px;
  border-radius: 10px;
  background:
    linear-gradient(0deg, #000000, transparent),
    linear-gradient(90deg, #ffffff, hsl(var(--clinic-hue, 178), 100%, 50%));
  cursor: crosshair;
}

.clinic-shade-picker span {
  position: absolute;
  left: calc(var(--clinic-saturation, 67) * 1%);
  top: calc((100 - var(--clinic-value, 71)) * 1%);
  width: 18px;
  height: 18px;
  border: 3px solid #ffffff;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.35);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.clinic-color-popover label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 900;
}

.clinic-color-popover input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

#clinicColorHexInput {
  max-width: 150px;
  text-transform: uppercase;
}

.toast {
  display: none;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #065f46;
  background: #d1fae5;
  font-weight: 800;
}

.toast.show {
  display: block;
}

.global-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  box-shadow: var(--shadow);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.46);
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  padding: 20px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24);
}

.modal-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.modal-form .wide-field,
.modal-form .line-confirm-preview,
.modal-form .modal-actions {
  grid-column: 1 / -1;
}

.line-confirm-preview {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--acc-200);
  border-radius: 8px;
  color: #0f766e;
  background: var(--acc-50);
  white-space: pre-line;
  font-weight: 800;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
}

.modal-actions .ghost-button:first-child {
  margin-right: auto;
}

.ai-connector-settings {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.ai-connector-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.ai-connector-grid section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.ai-header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.ai-connector-grid label,
.ai-chat-input {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.ai-scope-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ai-scope-grid button.active {
  color: #0f766e;
  border-color: var(--acc-bright);
  background: #ccfbf1;
}

.ai-endpoint-display,
.ai-health-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}

/* Mobile-first: stack label + value vertically so URLs get full row width.
   Previously used display:grid with fixed 150px label column, which left URL
   only ~50px on narrow phones → broke into 1 char per line. The override that
   tried to fix this with `flex-direction: column` did NOTHING because grid
   ignores flex props. Now: explicit single-column grid on mobile. */
.ai-endpoint-display div,
.ai-health-panel div {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  align-items: start;
  min-width: 0;
}

.ai-endpoint-display span,
.ai-health-panel span,
.ai-health-panel em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.ai-endpoint-display strong,
.ai-health-panel strong {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-all;
  white-space: normal;
  display: block;
  text-align: left;
  font-family: ui-monospace, monospace;
  font-size: 11.5px;
  line-height: 1.45;
}

/* Tablet+ (≥700px): switch to 2-column grid with fixed label column */
@media (min-width: 700px) {
  .ai-endpoint-display div,
  .ai-health-panel div {
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
  }
}

.ai-health-panel.ok {
  color: #0f766e;
  border-color: var(--acc-bright);
  background: var(--acc-50);
}

.ai-health-panel.error {
  color: #991b1b;
  border-color: #fecaca;
  background: #fff1f2;
}

.ai-connector-status {
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #475569;
  background: #ffffff;
  font-weight: 900;
}

.ai-connector-status.on {
  color: #0f766e;
  border-color: var(--acc-bright);
  background: var(--acc-50);
}

.ai-security-note,
.ai-policy-banner,
.ai-save-warning {
  padding: 12px;
  border: 1px solid #fbbf24;
  border-radius: 8px;
  color: #78350f;
  background: #fffbeb;
  font-size: 13px;
  font-weight: 800;
}

.ai-save-warning {
  margin-top: 2px;
}

.ai-security-grid,
.ai-spec-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.ai-security-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.ai-security-grid div,
.ai-spec-grid section,
.ai-test-result-panel,
.ai-log-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.ai-security-grid span,
.ai-security-grid em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.ai-code-block {
  min-height: 260px;
  max-height: 420px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #0f172a;
  background: #ffffff;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.ai-log-list {
  display: grid;
  gap: 8px;
}

.ai-log-list div,
.ai-log-list button {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 4px 12px;
  padding: 10px;
  border-left: 4px solid #94a3b8;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  border-radius: 8px;
  background: #ffffff;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.ai-log-list div.success,
.ai-log-list button.success {
  border-left-color: var(--acc-bright);
}

.ai-log-list div.error,
.ai-log-list button.error,
.ai-log-list button.invalid-secret {
  border-left-color: #ef4444;
}

.ai-log-list button.timeout,
.ai-log-list button.missing-field,
.ai-log-list button.credit-low {
  border-left-color: #f59e0b;
}

.ai-log-list button.selected {
  outline: 2px solid rgba(20, 184, 166, 0.35);
  background: #ecfeff;
}

.ai-log-list span {
  grid-row: span 2;
  color: var(--muted);
  font-weight: 800;
}

.ai-log-list em {
  color: var(--muted);
  font-style: normal;
}

.ai-log-detail-panel,
.ai-result-detail {
  display: grid;
  gap: 10px;
}

.ai-result-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.ai-result-summary div,
.ai-result-section {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.ai-result-section.error {
  border-color: #fecaca;
  background: #fff7ed;
}

.ai-result-summary span,
.ai-result-section span,
.ai-log-detail-panel > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ai-result-section p,
.ai-result-section ul {
  margin: 0;
  white-space: pre-wrap;
}

.ai-result-section ul {
  padding-left: 18px;
}

.ai-result-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ai-result-card,
.ai-result-empty {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.ai-result-card.suggested,
.ai-result-empty {
  grid-column: 1 / -1;
}

.ai-result-card span {
  color: #0f766e;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.ai-result-card p,
.ai-result-card ul {
  margin: 0;
  white-space: pre-wrap;
}

.ai-result-card ul {
  padding-left: 18px;
}

.ai-result-empty {
  color: var(--muted);
  font-weight: 800;
}

.ai-log-detail-panel {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.ai-ops-readiness {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.ai-ops-readiness .panel-head strong {
  color: #0f766e;
  font-size: 1.45rem;
}

.ai-ops-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-ops-actions .active {
  color: #0f766e;
  border-color: var(--acc-bright);
  background: #ccfbf1;
}

.ai-ops-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: 520px;
  overflow: auto;
}

.ai-ops-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff7f7;
}

.ai-ops-item.ready {
  border-color: var(--acc-200);
  background: var(--acc-50);
}

.ai-ops-item span {
  color: #b91c1c;
  font-size: 0.82rem;
  font-weight: 900;
}

.ai-ops-item.ready span {
  color: #0f766e;
}

.ai-ops-item strong {
  color: var(--ink);
}

.ai-ops-item em {
  color: var(--muted);
  font-style: normal;
}

/* ============================================================
   AI Assistant launcher — premium gradient pill with subtle shimmer
   ============================================================ */
/* Back-to-top FAB — appears when scrolled down. Tap → smooth scroll to top
   so user can quickly switch to other views via the sidebar nav without
   manually scrolling all the way up. Sits below the AI launcher. */
.back-to-top-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 24;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #ffffff;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.15) inset,
    0 6px 18px -4px rgba(15, 23, 42, 0.5),
    0 10px 30px -8px rgba(15, 23, 42, 0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.85);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.back-to-top-fab.visible {
  opacity: 0.92;
  visibility: visible;
  transform: translateY(0) scale(1);
}
.back-to-top-fab:hover,
.back-to-top-fab:focus {
  opacity: 1;
  transform: translateY(-2px) scale(1.03);
  outline: none;
}
.back-to-top-fab:active {
  transform: translateY(0) scale(0.96);
}
/* On mobile, position higher so it doesn't sit on top of system gesture bar */
@media (max-width: 640px) {
  .back-to-top-fab {
    right: 16px;
    bottom: 16px;
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
}

.ai-assistant-launcher {
  position: fixed;
  right: 24px;
  bottom: 86px;
  z-index: 25;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  /* Collapsed by default → a compact circular orb. Expands to a pill on hover
     (see :hover rule). width/padding/gap are all transitioned so the reveal is
     smooth. Anchored right:24px → it grows leftward, never off-screen. */
  width: 52px;
  height: 52px;
  min-height: 52px;
  padding: 0;
  border: none;
  border-radius: 999px;
  color: #ffffff;
  background: linear-gradient(
    115deg,
    #6366f1 0%,    /* indigo */
    #8b5cf6 25%,   /* violet */
    #d946ef 50%,   /* fuchsia */
    #f97316 80%,   /* orange */
    #fbbf24 100%   /* amber */
  );
  background-size: 220% 220%;
  background-position: 0% 50%;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  overflow: hidden;
  white-space: nowrap;
  /* Layered glow — colored halo, never harsh */
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.22) inset,
    0 8px 24px -6px rgba(139, 92, 246, 0.55),
    0 12px 36px -10px rgba(217, 70, 239, 0.45),
    0 2px 8px rgba(15, 23, 42, 0.18);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.25s ease,
              width 0.3s cubic-bezier(0.34, 1.4, 0.64, 1),
              padding 0.3s cubic-bezier(0.34, 1.4, 0.64, 1),
              gap 0.3s ease,
              background-position 0.4s ease;
  animation: ai-launcher-gradient-drift 8s ease-in-out infinite;
}

.ai-assistant-launcher:hover {
  /* Expand to full pill + reveal the label */
  width: 178px;
  gap: 10px;
  padding: 0 22px 0 18px;
  justify-content: flex-start;
  transform: translateY(-2px);
  background-position: 100% 50%;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.32) inset,
    0 12px 32px -4px rgba(139, 92, 246, 0.7),
    0 16px 48px -8px rgba(217, 70, 239, 0.6),
    0 4px 12px rgba(15, 23, 42, 0.22);
  animation-play-state: paused;
}

/* While being dragged it stays collapsed (the JS adds .dragging). */
.ai-assistant-launcher.dragging:hover {
  width: 52px;
  gap: 0;
  padding: 0;
  justify-content: center;
}

.ai-assistant-launcher:active {
  transform: translateY(0) scale(0.98);
}

.ai-assistant-launcher.dragging {
  cursor: grabbing;
  animation-play-state: paused;
}

/* Sparkle icon — has its own gentle pulse */
.ai-launcher-orb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(4px);
  color: #ffffff;
  flex-shrink: 0;
  animation: ai-launcher-orb-pulse 3.5s ease-in-out infinite;
}

.ai-launcher-orb svg {
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.85));
}

.ai-launcher-label {
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
  /* Hidden when collapsed — clips to 0 width and fades. Revealed on hover. */
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-width 0.3s ease, opacity 0.2s ease 0.05s;
}

.ai-assistant-launcher:hover .ai-launcher-label {
  max-width: 140px;
  opacity: 1;
}

/* Keep the label hidden while dragging */
.ai-assistant-launcher.dragging:hover .ai-launcher-label {
  max-width: 0;
  opacity: 0;
}

/* Slow diagonal shine sweep — fires every 6s, never spammy */
.ai-launcher-shine {
  position: absolute;
  top: 0;
  left: -60%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(255, 255, 255, 0) 30%,
    rgba(255, 255, 255, 0.42) 50%,
    rgba(255, 255, 255, 0) 70%,
    transparent 100%
  );
  transform: skewX(-18deg);
  animation: ai-launcher-shine-sweep 6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes ai-launcher-gradient-drift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes ai-launcher-orb-pulse {
  0%, 100% {
    transform: scale(1);
    background: rgba(255, 255, 255, 0.18);
  }
  50% {
    transform: scale(1.08);
    background: rgba(255, 255, 255, 0.28);
  }
}

@keyframes ai-launcher-shine-sweep {
  0%   { left: -60%; opacity: 0; }
  10%  { opacity: 1; }
  45%  { left: 130%; opacity: 0.9; }
  46%, 100% { left: 130%; opacity: 0; }
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .ai-assistant-launcher,
  .ai-launcher-orb,
  .ai-launcher-shine {
    animation: none;
  }
}

.ai-assistant-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 35;
  display: none;
  width: min(520px, 100vw);
  padding: 18px;
  background: rgba(15, 23, 42, 0.28);
}

.ai-assistant-drawer.show {
  display: block;
}

.ai-assistant-panel {
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 14px;
  height: 100%;
  padding: 18px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24);
}

.ai-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-chat-log {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.ai-message {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #ffffff;
}

.ai-message.user {
  border-color: var(--acc-200);
  background: var(--acc-50);
}

.ai-message strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.ai-message span {
  color: #475569;
  white-space: pre-line;
}

/* ============================================================
   AI Assistant — Structured response cards
   ============================================================ */
.ai-message.assistant {
  padding: 10px 10px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-color: #e0e7ff;
}

.ai-card {
  display: grid;
  gap: 10px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 14px 12px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02), 0 4px 14px rgba(15, 23, 42, 0.04);
}

.ai-card.plain {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  gap: 6px;
}

.ai-card.plain p {
  margin: 0;
  color: #475569;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-line;
}

.ai-card-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink, #0f172a);
  line-height: 1.35;
  letter-spacing: 0.1px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
}

.ai-card-subtitle {
  margin-top: -4px;
  font-size: 12.5px;
  color: #64748b;
  font-weight: 500;
  line-height: 1.45;
}

.ai-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  letter-spacing: 0.2px;
}
.ai-badge.success { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.ai-badge.warning { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.ai-badge.danger  { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.ai-badge.info    { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }

.ai-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.ai-kpi {
  display: grid;
  gap: 1px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  min-width: 0;
}

.ai-kpi span {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: normal;
}

.ai-kpi strong {
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
  word-break: break-word;
  font-feature-settings: "tnum" 1;
}

.ai-card-section {
  display: grid;
  gap: 6px;
}

.ai-card-section h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.ai-card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.ai-card-list li {
  position: relative;
  padding: 6px 10px 6px 22px;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  border-radius: 6px;
  font-size: 13px;
  color: #334155;
  line-height: 1.5;
}

.ai-card-list li::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 14px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary, var(--primary));
}

.ai-action-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #0f766e;
  background: linear-gradient(135deg, #ecfeff 0%, var(--acc-50) 100%);
  border: 1px solid var(--acc-200);
  border-radius: 999px;
  width: fit-content;
}

.ai-quote {
  margin: 0;
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.6;
  color: #334155;
  font-style: italic;
  background: #fefce8;
  border-left: 3px solid #facc15;
  border-radius: 4px;
}

.ai-card-note {
  font-size: 11.5px;
  color: #64748b;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  padding: 6px 10px;
  border-radius: 6px;
  line-height: 1.5;
}

.ai-card-text {
  margin: 0;
  font-size: 14px;
  color: #475569;
  line-height: 1.55;
  white-space: pre-line;
}

.ai-card-divider {
  border: none;
  border-top: 1px dashed #e2e8f0;
  margin: 2px 0;
}

@media (max-width: 480px) {
  .ai-kpi-grid {
    grid-template-columns: 1fr;
  }
}

.danger-ghost {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fff7f7;
}

.danger-ghost:hover {
  color: #991b1b;
  border-color: #fca5a5;
  background: #fee2e2;
}

.secondary-action {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 700;
}

@media (max-width: 1180px) {
  .metrics-grid,
  .reports-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .split-view,
  .payment-layout,
  .daily-close-grid,
  .appointment-workbench,
  .workflow-steps,
  .opd-status-steps,
  .pdpa-grid,
  .folder-grid,
  .opd-worklist-grid,
  .opd-cloud-grid,
  .opd-evidence-panel,
  .opd-admin-entry,
  .posting-grid,
  .readiness-score,
  .readiness-board,
  .opd-pack-grid,
  .opd-completion-grid,
  .opd-action-center,
  .opd-visit-meta-grid,
  .opd-admin-decision,
  .category-rule-grid,
  .category-settings-grid,
  .category-editor-grid,
  .policy-summary-grid,
  .policy-editor-grid,
  .supplier-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .workspace {
    padding: 18px;
  }

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

  .metrics-grid,
  .queue-columns,
  .kanban,
  .opd-grid,
  .opd-start-columns,
  .facechart-layout,
  .opd-card-grid,
  .opd-card-chart,
  .gallery-grid,
  .recurring-panel,
  .treatment-costing,
  .course-layout,
  .wallet-layout,
  .wallet-summary,
  .stock-overview,
  .stock-kpi-grid,
  .stock-detail-grid,
  .stock-transfer-grid,
  .document-layout,
  .df-layout,
  .data-tools-grid,
  .notification-layout,
  .marketing-layout,
  .security-grid,
  .outstanding-strip,
  .integration-strip,
  .customer-care-strip,
  .profile-stats,
  .consent-status-strip,
  .consent-rule-list,
  .consent-audit-list div,
  .case-grid,
  .drawer-summary,
  .marker-legend,
  .workflow-steps,
  .opd-day-grid,
  .opd-action-buttons,
  .customer-workflow-guide,
  .pdpa-grid,
  .opd-evidence-panel,
  .ai-draft-grid,
  .ai-security-grid,
  .ai-spec-grid,
  .template-option-grid,
  .catalog-rules,
  .tier-rule-grid,
  .settings-layout,
  .settings-form,
  .modal-form {
    grid-template-columns: 1fr;
  }

  .opd-start-flow div {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .opd-start-flow button {
    grid-row: auto;
    grid-column: 1 / -1;
  }

  .table-row,
  .products-table .table-row,
  .course-table .table-row,
  .document-table .table-row,
  .df-table .table-row,
  .campaign-table .table-row,
  .lot-table .table-row,
  .import-table .table-row,
  .notification-list div,
  .audit-list div,
  .approval-list div {
    grid-template-columns: 1fr;
  }

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

  .opd-return-queue {
    align-items: stretch;
    flex-direction: column;
  }

  .opd-return-actions {
    justify-content: stretch;
  }

  .opd-return-actions .ghost-button {
    flex: 1 1 140px;
  }

  .opd-return-metrics {
    grid-template-columns: 1fr;
  }
}

@media print {
  html,
  body {
    margin: 0;
    background: #ffffff;
  }

  body.printing-opd > :not(#opdPrintRoot) {
    display: none !important;
  }

  body.printing-opd #opdPrintRoot {
    display: block;
    margin: 0;
    padding: 0;
    background: #ffffff;
  }

  body.printing-opd #opdPrintRoot .opd-print-card {
    box-sizing: border-box;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #ffffff;
  }

  body.printing-opd #opdPrintRoot .opd-print-card + .opd-print-card {
    break-before: page;
  }

  body.printing-opd #opdPrintRoot.two-up {
    display: grid;
    grid-template-columns: 1fr;
    /* Explicit px rows: Chrome print does NOT reliably resolve 1fr in a fixed-height
       container — each visit gets an explicit 128mm row. 128+128+2(gap)+~15(header) = 273mm
       which fits the 277mm usable A4 area (@page margin:10mm each side). */
    grid-template-rows: auto 128mm 128mm;
    row-gap: 2mm;
    width: 190mm;
    height: 277mm;
    overflow: hidden;
  }

  /* ── 2-up header: compact single-row + conditional alert strip ── */
  body.printing-opd #opdPrintRoot.two-up .opd-two-up-header {
    display: flex;
    flex-direction: column;
    gap: 1.5mm;
    padding-bottom: 2mm;
    border-bottom: 1.4mm solid #111827;
    color: #111827;
  }

  body.printing-opd #opdPrintRoot.two-up .two-up-h-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 4mm;
  }

  body.printing-opd #opdPrintRoot.two-up .two-up-clinic strong {
    font-size: 11pt;
    font-weight: 900;
    line-height: 1;
  }

  body.printing-opd #opdPrintRoot.two-up .two-up-clinic em {
    font-size: 6.5pt;
    font-style: normal;
    color: #64748b;
    margin-left: 2mm;
    font-weight: 400;
  }

  body.printing-opd #opdPrintRoot.two-up .two-up-patient-info {
    font-size: 7.5pt;
    font-weight: 600;
    color: #0f172a;
    text-align: right;
    flex-shrink: 0;
  }

  /* Alert strip — only rendered when allergy/disease present */
  body.printing-opd #opdPrintRoot.two-up .two-up-alert-strip {
    display: flex;
    gap: 4mm;
    flex-wrap: wrap;
    padding: 1mm 2mm;
    background: #fff7ed;
    border: 0.3mm solid #fed7aa;
    border-radius: 1mm;
    font-size: 7pt;
    line-height: 1.35;
  }

  body.printing-opd #opdPrintRoot.two-up .two-up-alert-allergy {
    color: #b91c1c;
    font-weight: 900;
  }

  body.printing-opd #opdPrintRoot.two-up .two-up-alert-disease,
  body.printing-opd #opdPrintRoot.two-up .two-up-alert-meds {
    color: #92400e;
    font-weight: 700;
  }

  body.printing-opd #opdPrintRoot.two-up .opd-print-card + .opd-print-card {
    break-before: auto;
  }

  body.printing-opd #opdPrintRoot.two-up.intake-print {
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 2mm;
    width: 190mm;
    min-height: 277mm;
  }

  body.printing-opd #opdPrintRoot.two-up.intake-print .opd-print-card + .opd-print-card {
    border-top: 0.4mm dashed #94a3b8;
    padding-top: 2mm;
  }

  body.printing-opd #opdPrintRoot.two-up.intake-print .opd-intake-card.paper-a4.portrait {
    width: auto;
    min-height: 136.5mm;
    height: 136.5mm;
    padding: 0;
    border: 0;
    font-size: 9.2pt;
  }

  /* ── Visit slot: flex column so map fills full 128mm ── */
  body.printing-opd #opdPrintRoot.two-up .opd-visit-log {
    position: relative;
    width: auto;
    height: 128mm;
    min-height: 0;
    padding: 0;
    border: 1px solid #cbd5e1;
    font-size: 9px;
    overflow: hidden;
    break-inside: auto;
    display: flex;
    flex-direction: column;
  }

  body.printing-opd #opdPrintRoot.two-up .opd-visit-log::before {
    content: attr(data-visit-copy);
    position: absolute;
    top: 2mm;
    right: 3mm;
    color: #94a3b8;
    font-weight: 900;
    font-size: 8pt;
    z-index: 1;
  }

  body.printing-opd #opdPrintRoot.two-up .opd-card-header {
    display: none;
  }

  body.printing-opd #opdPrintRoot.two-up .visit-sheet-critical {
    display: none;
  }

  body.printing-opd #opdPrintRoot.two-up .visit-sheet-summary {
    display: none;
  }

  /* ── Visit layout: SIDE-BY-SIDE — body map LEFT (big), doctor writes RIGHT ──
     Left column = full body map filling the slot height.
     Right column = vitals + allergy/disease + doctor handwriting + treatment table. */
  body.printing-opd #opdPrintRoot.two-up .visit-sheet-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1.02fr 0.98fr;   /* left map ≈ right writing */
    grid-template-rows: 1fr;                  /* single row fills the slot height */
    gap: 2mm;
    margin-top: 1.5mm;
    padding: 0 2mm 2mm;
  }

  body.printing-opd #opdPrintRoot.two-up .visit-sheet-layout section {
    min-height: 0;
    min-width: 0;
    padding: 1.5mm;
    border: 1px solid #cbd5e1;
    box-sizing: border-box;
  }

  /* LEFT — body map fills its column edge-to-edge */
  body.printing-opd #opdPrintRoot.two-up .visit-sheet-map {
    min-height: 0;
    max-height: none;
    display: flex;
    flex-direction: column;
    align-content: unset;
    justify-items: unset;
  }

  body.printing-opd #opdPrintRoot.two-up .visit-sheet-map h4 {
    flex-shrink: 0;
    margin: 0 0 0.5mm 0;
    font-size: 6pt;
    font-weight: 800;
    color: #334155;
  }

  /* Split map: face = LEFT column (slightly smaller), front+back STACKED on the
     RIGHT (top/bottom) — the arrangement the owner approved. Spacing around the
     figures is squeezed (tiny h4 + captions) so the stacked bodies get max height. */
  body.printing-opd #opdPrintRoot.two-up .vs-map-split {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 1.5mm;
  }

  body.printing-opd #opdPrintRoot.two-up .vs-map-face-cell {
    flex: 1.7;             /* face on the left, a touch smaller than before */
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  body.printing-opd #opdPrintRoot.two-up .vs-map-body-cell {
    flex: 1;               /* bodies stacked: front on top, back below */
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1mm;
    justify-content: center;
    align-items: center;
  }

  body.printing-opd #opdPrintRoot.two-up .vs-map-body-cell figure {
    flex: 1;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  body.printing-opd #opdPrintRoot.two-up .vs-map-split img {
    flex: 1;
    min-height: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    max-width: 100%;
    object-fit: contain;
    object-position: center;
  }

  body.printing-opd #opdPrintRoot.two-up .vs-map-split figcaption {
    flex-shrink: 0;
    margin-top: 0.2mm;
    font-size: 5pt;
    font-weight: 700;
    color: #94a3b8;
    line-height: 1;
  }

  /* RIGHT — vitals + doctor writing, stacked in a flex column */
  body.printing-opd #opdPrintRoot.two-up .visit-sheet-note {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 1mm;
  }

  /* Vitals block (allergy/disease + blank BP/PR/Temp/Wt/Ht) */
  body.printing-opd #opdPrintRoot.two-up .visit-sheet-vitals {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1mm;
  }

  body.printing-opd #opdPrintRoot.two-up .vs-vital-alerts {
    display: flex;
    flex-direction: column;
    gap: 0.5mm;
    font-size: 7pt;
    line-height: 1.3;
  }

  body.printing-opd #opdPrintRoot.two-up .vs-vital-alerts .vs-allergy strong {
    color: #b91c1c;
    font-weight: 900;
  }

  body.printing-opd #opdPrintRoot.two-up .vs-vital-alerts .vs-disease strong {
    color: #92400e;
    font-weight: 700;
  }

  body.printing-opd #opdPrintRoot.two-up .vs-vital-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5mm 3mm;
    padding: 1mm 0;
    border-top: 0.3mm dashed #cbd5e1;
    border-bottom: 0.3mm dashed #cbd5e1;
    font-size: 7pt;
    color: #475569;
  }

  body.printing-opd #opdPrintRoot.two-up .vs-vital-fields b {
    color: #0f172a;
    letter-spacing: 0.2mm;
  }

  body.printing-opd #opdPrintRoot.two-up .visit-sheet-note h4 {
    flex-shrink: 0;
    font-size: 7pt;
    font-weight: 800;
    color: #334155;
    margin: 0.5mm 0 0.5mm 0;
  }

  /* Handwriting area grows to fill remaining right-column height */
  body.printing-opd #opdPrintRoot.two-up .handwriting-lines {
    flex: 1;
    min-height: 24mm;
  }

  body.printing-opd #opdPrintRoot.two-up .mini-field-grid {
    flex-shrink: 0;
  }

  body.printing-opd #opdPrintRoot.two-up .mini-field-grid span {
    min-height: 8mm;
    font-size: 6.8pt;
  }

  body.printing-opd #opdPrintRoot.two-up .signature-grid {
    flex-shrink: 0;
    margin-top: 1.5mm;
    padding-top: 1.5mm;
    font-size: 7pt;
  }

  body.printing-opd .opd-card-grid,
  body.printing-opd .opd-card-chart,
  body.printing-opd .visit-log-table {
    break-inside: avoid;
  }

  /* Single-visit A4 portrait — clamp to exactly one page (same strategy as master-print).
     min-height:1123px from the screen rule causes overflow without this. */
  body.printing-opd #opdPrintRoot:not(.two-up) .opd-visit-log.paper-a4.portrait {
    width: 190mm;
    min-height: 0;
    height: 277mm;
    overflow: hidden;
  }

  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait .opd-card-chart {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(43mm, 0.55fr);
    gap: 2.5mm;
    min-height: 0;
    margin-top: 3mm;
    padding-top: 0;
    break-inside: avoid;
  }

  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait .opd-card-chart.body-map-only {
    grid-template-columns: minmax(0, 1fr);
  }

  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait .beauty-face-section {
    min-height: auto;
    padding: 2mm;
  }

  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait .opd-map-sheet {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 92mm;
    margin: 1.5mm 0;
  }

  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait .chart-template-image {
    display: block !important;
    width: 100%;
    max-width: 176mm;
    max-height: 92mm;
    object-fit: contain;
    visibility: visible !important;
    opacity: 1 !important;
  }

  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait .marker-legend {
    display: none;
  }

  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait .opd-card-chart h4 {
    margin-bottom: 2mm;
    padding-bottom: 1.5mm;
  }

  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait .opd-card-chart small {
    display: none;
  }

  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait .mini-photo-grid span {
    min-height: 32mm;
  }

  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait .opd-card-sign {
    margin-top: 3mm;
    padding-top: 3mm;
    break-inside: avoid;
  }

  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait .opd-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2.5mm;
    margin-top: 3mm;
  }

  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait .opd-card-grid section,
  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait .opd-card-chart > div {
    min-height: auto;
    padding: 2mm;
  }

  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait .opd-card-pdpa {
    grid-column: 1 / -1;
  }

  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait .opd-page-label {
    margin-bottom: 2mm;
    font-size: 8pt;
  }

  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait h4 {
    margin-bottom: 1.5mm;
    padding-bottom: 1mm;
  }

  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait p,
  body.printing-opd #opdPrintRoot:not(.two-up) .opd-print-card.paper-a4.portrait .opd-card-row {
    line-height: 1.25;
  }

  body.printing-opd #opdPrintRoot.master-print .opd-print-card.paper-a4.portrait {
    width: 190mm;
    min-height: 0;
    height: 277mm;
    overflow: hidden;
    font-size: 9.9pt;
  }

  body.printing-opd #opdPrintRoot.master-print .opd-page-label {
    display: none;
  }

  body.printing-opd #opdPrintRoot.master-print .opd-card-header {
    padding-bottom: 2.2mm;
  }

  body.printing-opd #opdPrintRoot.master-print .opd-card-header strong {
    font-size: 17.2pt;
    line-height: 1;
  }

  body.printing-opd #opdPrintRoot.master-print .opd-card-header span {
    font-size: 10pt;
    line-height: 1.15;
  }

  body.printing-opd #opdPrintRoot.master-print .opd-card-logo {
    width: 12mm;
    height: 12mm;
  }

  body.printing-opd #opdPrintRoot.master-print .opd-card-grid {
    gap: 1.5mm;
    margin-top: 1.8mm;
  }

  body.printing-opd #opdPrintRoot.master-print .opd-card-grid section,
  body.printing-opd #opdPrintRoot.master-print .opd-card-chart > div {
    padding: 1.5mm;
  }

  body.printing-opd #opdPrintRoot.master-print h4 {
    margin-bottom: 0.8mm;
    padding-bottom: 0.7mm;
    font-size: 10.6pt;
  }

  body.printing-opd #opdPrintRoot.master-print .opd-card-row {
    padding: 0.55mm 0;
    gap: 2mm;
  }

  body.printing-opd #opdPrintRoot.master-print .opd-card-row span,
  body.printing-opd #opdPrintRoot.master-print .opd-card-row strong {
    font-size: 9.9pt;
  }

  body.printing-opd #opdPrintRoot.master-print .opd-print-card p {
    font-size: 9.8pt;
    line-height: 1.2;
  }

  body.printing-opd #opdPrintRoot.master-print .opd-card-row strong {
    text-align: right;
  }

  body.printing-opd #opdPrintRoot.master-print .pdpa-sign-line {
    margin-top: 1.2mm;
    padding-top: 1.2mm;
  }

  body.printing-opd #opdPrintRoot.master-print .pdpa-sign-line span {
    font-size: 9.2pt;
  }

  body.printing-opd #opdPrintRoot.master-print .consent-summary-grid {
    gap: 0 2mm;
  }

  body.printing-opd #opdPrintRoot.master-print .consent-check-grid {
    gap: 0.6mm 3mm;
    margin-top: 1mm;
    font-size: 9.2pt;
  }

  body.printing-opd #opdPrintRoot.master-print .opd-card-chart {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.8mm;
    margin-top: 1.2mm;
  }

  body.printing-opd #opdPrintRoot.master-print .opd-map-sheet {
    min-height: 76mm;
    margin: 1mm 0;
  }

  body.printing-opd #opdPrintRoot.master-print .chart-template-image {
    max-width: 176mm;
    max-height: 76mm;
  }

  body.printing-opd #opdPrintRoot.master-print .opd-card-chart small {
    display: none;
  }

  body.printing-opd #opdPrintRoot.master-print .mini-photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.2mm;
  }

  body.printing-opd #opdPrintRoot.master-print .mini-photo-grid span {
    min-height: 0;
    aspect-ratio: 4 / 5;
    font-size: 6.8pt;
  }

  body.printing-opd #opdPrintRoot.master-print .mini-photo-grid img {
    min-height: 0;
  }

  body.printing-opd #opdPrintRoot.master-print .mini-photo-grid em {
    font-size: 5.8pt;
  }

  body.printing-opd #opdPrintRoot.master-print .opd-card-sign {
    margin-top: 2mm;
    padding-top: 2mm;
  }

  body.printing-opd #opdPrintRoot.intake-print .opd-intake-card.paper-a5.landscape {
    width: 190mm;
    min-height: 136.5mm;
    height: 136.5mm;
    padding: 0;
    border: 0;
    font-size: 9.2pt;
  }

  body.printing-opd #opdPrintRoot.intake-print .opd-intake-card.paper-a4.portrait {
    width: 190mm;
    min-height: 136.5mm;
    height: 136.5mm;
    padding: 0;
    border: 0;
    font-size: 9.2pt;
  }

  body.printing-opd #opdPrintRoot.intake-print .opd-card-header {
    padding-bottom: 3mm;
  }

  body.printing-opd #opdPrintRoot.intake-print .opd-card-header strong {
    font-size: 18pt;
  }

  body.printing-opd #opdPrintRoot.intake-print .opd-card-header span {
    font-size: 10.5pt;
  }

  body.printing-opd #opdPrintRoot.intake-print .intake-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2.7mm;
    margin-top: 3mm;
  }

  body.printing-opd #opdPrintRoot.intake-print .intake-grid section {
    min-height: 36mm;
    padding: 2.4mm;
    border-radius: 0;
  }

  body.printing-opd #opdPrintRoot.intake-print .intake-line-row {
    grid-template-columns: 33mm 1fr;
    padding: 1.25mm 0;
  }

  body.printing-opd #opdPrintRoot.intake-print .intake-line-row b {
    min-height: 6.2mm;
  }

  body.printing-opd #opdPrintRoot.intake-print .intake-check-grid,
  body.printing-opd #opdPrintRoot.intake-print .intake-photo-grid {
    gap: 1.8mm 3mm;
  }

  body.printing-opd #opdPrintRoot.intake-print .intake-check-grid span,
  body.printing-opd #opdPrintRoot.intake-print .intake-photo-grid span {
    min-height: 6.2mm;
  }

  body.printing-opd #opdPrintRoot.intake-print .intake-note-box {
    min-height: 16.5mm;
    padding: 2mm;
  }

  body.printing-opd #opdPrintRoot.intake-print .intake-sign-grid.final {
    margin-top: 3mm;
    padding-top: 2.8mm;
    font-size: 10.5pt;
  }

  body.printing-opd #opdPrintRoot.intake-print .intake-bottom-note {
    margin-top: 1.8mm;
    font-size: 8pt;
  }

  body.printing-opd .opd-print-card.paper-a5.landscape {
    width: 198mm;
    min-height: 136mm;
    padding: 0;
    font-size: 9.5px;
  }

  body.printing-opd .opd-print-card.paper-a4.portrait {
    width: 190mm;
    min-height: 277mm;
    padding: 0;
    font-size: 12px;
  }

  body.printing-opd .opd-print-card.paper-a4.landscape {
    width: 277mm;
    min-height: 190mm;
    padding: 0;
    font-size: 11px;
  }

  body.printing-opd .opd-print-card.paper-a5.portrait {
    width: 136mm;
    min-height: 198mm;
    padding: 0;
    font-size: 9.5px;
  }

  body.printing-opd .opd-visit-log.paper-a4.portrait .visit-sheet-layout {
    grid-template-columns: 1fr;
    gap: 3mm;
    margin-top: 3mm;
    break-inside: auto;
  }

  body.printing-opd .opd-visit-log.paper-a4.portrait .opd-card-header {
    padding-bottom: 3mm;
  }

  body.printing-opd .opd-visit-log.paper-a4.portrait .visit-sheet-critical {
    gap: 1.5mm;
    margin-top: 2mm;
  }

  body.printing-opd .opd-visit-log.paper-a4.portrait .visit-sheet-critical div {
    padding: 1.5mm;
  }

  body.printing-opd .opd-visit-log.paper-a4.portrait .visit-sheet-layout section {
    min-height: auto;
    padding: 2.5mm;
  }

  body.printing-opd .opd-visit-log.paper-a4.portrait .visit-sheet-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1mm 6mm;
  }

  body.printing-opd .opd-visit-log.paper-a4.portrait .visit-sheet-checks {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 1.5mm;
  }

  body.printing-opd .opd-visit-log.paper-a4.portrait .visit-sheet-map {
    min-height: 58mm;   /* leaves room for signature */
  }

  body.printing-opd .opd-visit-log.paper-a4.portrait .visit-sheet-map img {
    width: 100%;
    max-height: 54mm;
  }

  /* Single-A4 (full-width column): split shows 3 across like the composite */
  body.printing-opd .opd-visit-log.paper-a4.portrait .vs-map-split {
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 4mm;
  }

  body.printing-opd .opd-visit-log.paper-a4.portrait .vs-map-face-cell { flex: 1.1; }
  body.printing-opd .opd-visit-log.paper-a4.portrait .vs-map-body-cell { flex: 1.6; gap: 4mm; }

  body.printing-opd .opd-visit-log.paper-a4.portrait .vs-map-split img {
    width: 100%;
    max-height: 56mm;
  }

  body.printing-opd .opd-visit-log.paper-a4.portrait .vs-map-split figcaption {
    font-size: 7pt;
    color: #94a3b8;
  }

  body.printing-opd .opd-visit-log.paper-a4.portrait .handwriting-lines {
    min-height: 62mm;   /* reduced from 70mm — signature stays visible */
  }

  body.printing-opd .opd-visit-log.paper-a4.portrait .mini-field-grid span {
    min-height: 9mm;    /* reduced from 10mm */
  }

  body.printing-opd .opd-visit-log.paper-a4.portrait .signature-grid {
    margin-top: 3mm;
    padding-top: 2mm;
  }

  body.printing-opd .opd-visit-log.paper-a5.landscape .visit-sheet-layout section {
    min-height: 122mm;
  }

  body.printing-opd .opd-visit-log.paper-a5.landscape .visit-sheet-map img {
    max-height: 105mm;
  }
}

/* Empty state placeholders — production-ready (no demo data) */
/* Gallery (photo grid) — cross-device synced via R2 */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  padding: 12px;
  max-height: 70vh;
  overflow-y: auto;
}
.gallery-item {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
}
.gallery-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #f1f5f9;
  display: block;
}
.gallery-item .gallery-meta {
  padding: 8px 10px;
  font-size: 11px;
  color: #475569;
}
.gallery-item .gallery-meta strong {
  display: block;
  color: #0f172a;
  font-size: 12px;
  margin-bottom: 2px;
}
.gallery-item .gallery-meta .kind-tag {
  display: inline-block;
  padding: 2px 6px;
  background: #ede9fe;
  color: #5b21b6;
  border-radius: 4px;
  font-weight: 600;
  margin-top: 4px;
}
/* Grouped-by-patient gallery — each patient is its own card */
.gallery-grouped {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px;
  max-height: 70vh;
  overflow-y: auto;
}
.gallery-group {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.gallery-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #eef2f7;
  position: sticky;
  top: 0;
  z-index: 1;
  cursor: pointer;
  user-select: none;
}
.gallery-group-header:hover { background: #f1f5f9; }
.gallery-group-header .gg-chevron {
  display: inline-block;
  margin-left: 4px;
  transition: transform 0.2s ease;
  font-size: 11px;
}
.gallery-group.expanded .gg-chevron { transform: rotate(180deg); }
/* Collapsed (default): one neat horizontal preview row (swipe to peek). Click
   the header/count badge to expand into a full wrapping grid that shows every
   photo. Expanded uses the base .gallery-group-grid rule (auto-fill wrap). */
.gallery-group:not(.expanded) .gallery-group-grid {
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: 140px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.gallery-group-header .gg-id strong {
  display: block;
  font-size: 14px;
  color: #0f172a;
}
.gallery-group-header .gg-id .gg-hn {
  font-size: 11px;
  color: #64748b;
}
.gallery-group-header .gg-count {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: #5b21b6;
  background: #ede9fe;
  padding: 3px 10px;
  border-radius: 999px;
}
.gallery-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  padding: 12px;
}
/* Force a visible thumbnail height inside groups — the aspect-ratio square was
   collapsing to a thin sliver in the column-flow preview strip. */
.gallery-group-grid .gallery-item img {
  height: 130px;
  aspect-ratio: auto;
}
@media (max-width: 600px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    padding: 8px;
  }
  .gallery-group-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    padding: 8px;
  }
}

/* ════════════════════════════════════════════════════════════════════
   Gallery (R2 photos) — pro redesign. Everything is scoped under .rg-*
   so the legacy .gallery-grid / .gallery-item rules above never bleed in
   (the new selectors win on specificity). Left filter rail + clean,
   fixed-size thumbnails (no aspect-ratio collapse, no sliver-clipping).
   ════════════════════════════════════════════════════════════════════ */
.rg-layout { display: flex; gap: 16px; align-items: flex-start; padding: 4px 2px 2px; }
.rg-rail {
  flex: 0 0 198px; width: 198px; position: sticky; top: 8px;
  display: flex; flex-direction: column; gap: 10px;
  background: #faf9fe; border: 1px solid #eceaf6; border-radius: 14px; padding: 12px;
}
.rg-search {
  width: 100%; box-sizing: border-box; padding: 9px 12px;
  border: 1px solid #e2e0ee; border-radius: 10px; font-size: 13px; background: #fff;
}
.rg-search:focus { outline: none; border-color: #a78bfa; box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12); }
.rg-rail-label { font-size: 11px; font-weight: 800; letter-spacing: 0.4px; color: #9a93b3; text-transform: uppercase; margin-top: 2px; }
.rg-tabs { display: flex; flex-direction: column; gap: 4px; }
.rg-tab {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border: none; background: transparent; border-radius: 9px;
  font-size: 13px; font-weight: 600; color: #475569; cursor: pointer; text-align: left;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}
.rg-tab .rg-ic { font-size: 15px; line-height: 1; width: 18px; text-align: center; }
.rg-tab .rg-tx { flex: 1 1 auto; white-space: nowrap; }
.rg-tab .rg-ct {
  flex: none; min-width: 20px; text-align: center; font-size: 11px; font-weight: 700;
  color: #8b87a3; background: #efedf7; border-radius: 999px; padding: 1px 7px;
}
.rg-tab:hover { background: #f1edfd; color: #5b21b6; }
.rg-tab.active { background: #7c3aed; color: #fff; box-shadow: 0 4px 12px rgba(124, 58, 237, 0.28); }
.rg-tab.active .rg-ct { background: rgba(255, 255, 255, 0.26); color: #fff; }
.rg-rail-divider { height: 1px; background: #eceaf6; margin: 4px 0; }
.rg-field { display: flex; flex-direction: column; gap: 5px; font-size: 11px; font-weight: 700; color: #9a93b3; text-transform: uppercase; letter-spacing: 0.3px; }
.rg-select { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid #e2e0ee; border-radius: 9px; font-size: 13px; font-weight: 600; color: #475569; background: #fff; cursor: pointer; }
.rg-switch { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; color: #475569; cursor: pointer; user-select: none; }
.rg-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.rg-switch-track { flex: none; width: 38px; height: 22px; background: #d6d3e6; border-radius: 999px; position: relative; transition: background 0.18s; }
.rg-switch-thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.18s; }
.rg-switch input:checked + .rg-switch-track { background: #7c3aed; }
.rg-switch input:checked + .rg-switch-track .rg-switch-thumb { transform: translateX(16px); }
.rg-status { font-size: 11px; color: #9a93b3; }
.rg-main { flex: 1 1 auto; min-width: 0; }

/* Flat grid (เรียงรวม) */
.rg-flat {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 13px; max-height: 74vh; overflow-y: auto; padding: 2px;
}
.rg-flat .gallery-item, .rg-grouped .gallery-item {
  position: relative; background: #fff; border: 1px solid #e8e6f0; border-radius: 13px;
  overflow: hidden; cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.rg-flat .gallery-item:hover, .rg-grouped .gallery-item:hover {
  transform: translateY(-3px); box-shadow: 0 10px 24px rgba(91, 33, 182, 0.16);
}
.rg-flat .gallery-item img { width: 100%; height: 150px; object-fit: cover; display: block; background: #eef1f7; }
.rg-flat .gallery-item .gallery-meta, .rg-grouped .gallery-item .gallery-meta { padding: 7px 9px; font-size: 11px; color: #64748b; line-height: 1.45; }
.rg-flat .gallery-item .gallery-meta strong { display: block; color: #0f172a; font-size: 12px; margin-bottom: 2px; }
.rg-flat .gallery-meta .kind-tag, .rg-grouped .gallery-meta .kind-tag {
  display: inline-block; padding: 1px 8px; background: #f3f0ff; color: #6d28d9;
  border-radius: 999px; font-weight: 700; font-size: 10px; margin-top: 3px;
}

/* Grouped-by-patient (จัดกลุ่มตามคนไข้) */
.rg-grouped { display: flex; flex-direction: column; gap: 14px; max-height: 74vh; overflow-y: auto; padding: 2px; }
.rg-grouped .gallery-group { border: 1px solid #e8e6f0; border-radius: 15px; background: #fff; overflow: hidden; }
.rg-grouped .gallery-group-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; background: linear-gradient(180deg, #faf9ff, #f5f3fb);
  border-bottom: 1px solid #efedf6; cursor: pointer; user-select: none; transition: background 0.12s;
}
.rg-grouped .gallery-group-header:hover { background: #f0ebff; }
.rg-grouped .gg-id { min-width: 0; }
.rg-grouped .gg-id strong { display: block; font-size: 14px; font-weight: 700; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rg-grouped .gg-id .gg-hn { font-size: 11px; color: #8b8698; }
.rg-grouped .gg-count {
  flex: none; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700;
  color: #fff; background: #7c3aed; padding: 4px 12px; border-radius: 999px;
}
.rg-grouped .gg-chevron { font-size: 12px; }
/* Filmstrip — one neat horizontal row (swipe to peek); click header → full album */
.rg-grouped .gallery-group-grid {
  display: flex; gap: 10px; padding: 13px 16px; overflow-x: auto;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.rg-grouped .gallery-group-grid::-webkit-scrollbar { height: 8px; }
.rg-grouped .gallery-group-grid::-webkit-scrollbar-track { background: transparent; }
.rg-grouped .gallery-group-grid::-webkit-scrollbar-thumb { background: #dcd8ec; border-radius: 999px; }
.rg-grouped .gallery-group-grid .gallery-item { flex: 0 0 auto; width: 124px; scroll-snap-align: start; }
.rg-grouped .gallery-group-grid .gallery-item img { width: 124px; height: 124px; object-fit: cover; display: block; background: #eef1f7; }
.rg-grouped .gallery-group-grid .gallery-meta { padding: 5px 8px; font-size: 10px; }
.rg-grouped .gallery-group-grid .gallery-meta .kind-tag { font-size: 9px; padding: 1px 6px; }
/* Expanded (if a group ever toggles open) → wrapping grid */
.rg-grouped .gallery-group.expanded .gallery-group-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); overflow-x: visible;
}
.rg-grouped .gallery-group.expanded .gallery-group-grid .gallery-item { width: auto; }
.rg-grouped .gallery-group.expanded .gallery-group-grid .gallery-item img { width: 100%; height: 140px; }

/* Responsive — rail collapses to a horizontal strip on top */
@media (max-width: 820px) {
  .rg-layout { flex-direction: column; }
  .rg-rail { position: static; width: 100%; flex: none; }
  .rg-tabs { flex-direction: row; flex-wrap: wrap; }
  .rg-tab { width: auto; }
  .rg-tab .rg-tx { flex: 0 0 auto; }
}

/* ════ App theme: Luxe (gold floral) — opt-in via <html data-theme="luxe"> ════ */
/* Motif defined once on :root so the picker swatch can preview it regardless of
 * the active theme. Luxe rules apply it only in safe, low-distraction zones. */
:root {
  --luxe-motif: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%23BFA24A' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M30 196 C 60 150 76 120 88 86'/%3E%3Cpath d='M88 120 C 116 104 138 92 152 64'/%3E%3Cpath d='M70 150 C 88 150 108 144 120 130 C 104 150 86 158 70 150 Z'/%3E%3Cpath d='M96 112 C 116 108 134 100 146 84 C 132 106 114 116 96 112 Z'/%3E%3Cg transform='translate(150 56)'%3E%3Cellipse cx='0' cy='-13' rx='6' ry='12'/%3E%3Cellipse cx='0' cy='-13' rx='6' ry='12' transform='rotate(60)'/%3E%3Cellipse cx='0' cy='-13' rx='6' ry='12' transform='rotate(120)'/%3E%3Cellipse cx='0' cy='-13' rx='6' ry='12' transform='rotate(180)'/%3E%3Cellipse cx='0' cy='-13' rx='6' ry='12' transform='rotate(240)'/%3E%3Cellipse cx='0' cy='-13' rx='6' ry='12' transform='rotate(300)'/%3E%3Ccircle cx='0' cy='0' r='4'/%3E%3C/g%3E%3Cg transform='translate(88 78)'%3E%3Cellipse cx='0' cy='-16' rx='7' ry='14'/%3E%3Cellipse cx='0' cy='-16' rx='7' ry='14' transform='rotate(72)'/%3E%3Cellipse cx='0' cy='-16' rx='7' ry='14' transform='rotate(144)'/%3E%3Cellipse cx='0' cy='-16' rx='7' ry='14' transform='rotate(216)'/%3E%3Cellipse cx='0' cy='-16' rx='7' ry='14' transform='rotate(288)'/%3E%3Ccircle cx='0' cy='0' r='5'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
:root[data-theme="luxe"] .empty-state {
  background-image: var(--luxe-motif);
  background-repeat: no-repeat;
  background-position: right 14px bottom 10px;
  background-size: 88px;
}
:root[data-theme="luxe"] #loginOverlay {
  background-image: var(--luxe-motif);
  background-repeat: no-repeat;
  background-position: right -24px top -14px;
  background-size: 300px;
}
:root[data-theme="luxe"] .workspace::before {
  content: "";
  position: fixed;
  right: -36px;
  bottom: -36px;
  width: 240px;
  height: 240px;
  background: var(--luxe-motif) no-repeat center / contain;
  opacity: 0.05;
  pointer-events: none;
  z-index: 0;
}
/* App theme picker (Settings → ธีมแอป) */
.app-theme-picker { display: flex; flex-direction: column; gap: 10px; padding: 6px 0 2px; }
.app-theme-card { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 14px; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; cursor: pointer; text-align: left; transition: border-color .12s, box-shadow .12s; }
.app-theme-card:hover { border-color: #cbd5e1; }
.app-theme-card.is-active { border-color: #7c3aed; box-shadow: 0 0 0 2px rgba(124, 58, 237, .18); }
.app-theme-swatch { width: 46px; height: 46px; border-radius: 10px; flex: 0 0 auto; border: 1px solid rgba(15, 23, 42, .08); }
.app-theme-swatch--std { background: #f8fafc; }
.app-theme-swatch--luxe { background: #fbf5e6 var(--luxe-motif) no-repeat center / 74%; }
.app-theme-meta { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.app-theme-meta strong { font-size: 14px; color: #0f172a; font-weight: 700; }
.app-theme-meta small { font-size: 12px; color: #64748b; line-height: 1.4; }
.app-theme-check { color: #7c3aed; font-weight: 800; font-size: 18px; flex: 0 0 auto; }

.empty-state {
  padding: 28px 16px;
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 500;
  background: rgba(148, 163, 184, 0.06);
  border: 1px dashed rgba(148, 163, 184, 0.35);
  border-radius: 10px;
  margin: 6px 0;
}
.appointment-list .empty-state,
.queue-columns .empty-state,
.case-grid .empty-state,
.timeline-list .empty-state,
.followup-panel .empty-state,
.notification-list .empty-state,
.audit-list .empty-state,
.approval-list .empty-state,
.consent-rule-list .empty-state,
.consent-audit-list .empty-state,
.drawer-timeline .empty-state,
.invoice-list .empty-state,
.import-table .empty-state,
.campaign-table .empty-state,
.df-table .empty-state,
.wallet-history .empty-state {
  font-size: 13px;
  padding: 18px 12px;
}
.empty-state[data-empty-state="services"],
.empty-state[data-empty-state="invoice"],
.empty-state[data-empty-state="split"],
.empty-state[data-empty-state="df-summary"] {
  padding: 16px;
  font-size: 13px;
}

/* ============================================================
   LINE Groups & Incoming Slips (Payment slip 2-way sync)
   ============================================================ */
.line-groups-help {
  margin-top: 8px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 8px 12px;
}
.line-groups-help summary {
  cursor: pointer;
  font-weight: 600;
  color: #166534;
  font-size: 14px;
}
.line-groups-help ol {
  margin: 8px 0 0;
  padding-left: 18px;
  line-height: 1.7;
  color: #15803d;
  font-size: 13px;
}
.line-groups-help strong { color: #064e3b; }

.incoming-slips-panel {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  margin-top: 12px;
}
.incoming-slips-list {
  display: grid;
  gap: 10px;
  max-height: 480px;
  overflow-y: auto;
}
.incoming-slip-card {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 12px;
  align-items: center;
  background: #fff;
  border: 1px solid #e0e7ff;
  border-radius: 10px;
  padding: 10px;
}
/* Flash the newest slip card when staff taps the Payments nav badge → jumps here */
@keyframes slipFlashPulse {
  0% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.55); }
  60% { box-shadow: 0 0 0 9px rgba(124, 58, 237, 0); }
  100% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0); }
}
.incoming-slip-card.slip-flash {
  animation: slipFlashPulse 1.3s ease-out 2;
  outline: 2px solid var(--primary, #7c3aed);
  outline-offset: 2px;
}

/* ── OPD card: patient name must POP — owner feedback "กลืนกันไปหมด" ──
   Strong blue + bigger so the name is findable at arm's length on paper.
   Prints dark on B/W printers (size carries the emphasis there). */
#opdCardPatientName,
#visitSheetPatientNameTop,
#visitSheetPatientName {
  color: #1d4ed8 !important;
  font-size: 1.32em !important;
  font-weight: 800 !important;
  letter-spacing: 0.01em;
}
#visitSheetHnTop,
#opdCardHn {
  color: #1d4ed8 !important;
  font-weight: 800 !important;
}

/* ── OPD stepper ยุบได้ — เช็คลิสต์ 9 ขั้นเกะกะ แทบไม่มีใครกาง ──
   หุบ = แถวเดียวแบนจริงๆ (ฆ่า grid 220px เดิม คืนพื้นที่ให้จอ)
   กาง = ปุ่ม 9 ขั้นเต็มความกว้าง. */
details.opd-action-center {
  display: block; /* override grid-template-columns 220px */
}
details.opd-action-center:not([open]) {
  padding: 8px 14px;
}
details.opd-action-center > summary.opd-action-summary {
  display: flex;
  align-items: center;
  gap: 8px 14px;
  flex-wrap: wrap;
  padding: 0;
  border-right: none;
  cursor: pointer;
  list-style: none;
}
details.opd-action-center > summary::-webkit-details-marker { display: none; }
details.opd-action-center > summary::marker { content: ""; }
details.opd-action-center > summary .opd-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  flex: 1;
  min-width: 150px;
}
details.opd-action-center > summary strong { font-size: 0.88rem; }
/* คำใบ้ขั้นถัดไปโชว์เฉพาะตอนกาง — ตอนหุบเอาพื้นที่คืน */
details.opd-action-center:not([open]) > summary em { display: none; }
details.opd-action-center[open] > summary { margin-bottom: 8px; }
.opd-stepper-toggle-hint {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary, #7c3aed);
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: 999px;
  padding: 3px 12px;
  white-space: nowrap;
}
details.opd-action-center[open] .opd-stepper-toggle-hint { background: #ede9fe; }

/* ── OPD 360 — มุมมองคนไข้ 360° ── */
.opd360-hero {
  background: linear-gradient(135deg, #f5f3ff, #fff);
  border: 1px solid #ddd6fe;
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.opd360-name {
  color: #1d4ed8;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.opd360-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.opd360-kpi {
  background: #fff;
  border: 1px solid #e8e6f0;
  border-radius: 10px;
  padding: 8px 12px;
}
.opd360-kpi span { display: block; font-size: 11px; color: #8b8698; }
.opd360-kpi strong { font-size: 15.5px; color: #0f172a; }
.opd360-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 12px;
}
.opd360-col {
  background: #fff;
  border: 1px solid #e8e6f0;
  border-radius: 12px;
  padding: 12px 14px;
}
.opd360-col h4 { margin: 0 0 8px; font-size: 13.5px; }
.opd360-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid #f4f2fa;
  font-size: 12.5px;
}
.opd360-row:last-child { border-bottom: none; }
.opd360-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
}
.opd360-thumbs img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  background: #eef1f7;
  cursor: pointer;
}

/* ── Reports view tabs — แยกหน้า รายงานยอดขาย / ส่งบัญชี / คีย์ยอดย้อนหลัง / Barter ── */
.reports-tab-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 6px;
  background: var(--surface, #fff);
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 12px;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}
.reports-tab {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 9px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.18s cubic-bezier(0.4, 0, 0.2, 1), color 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.reports-tab:hover { background: #f1f5f9; color: #334155; }
.reports-tab.active {
  background: var(--primary, #7c3aed);
  color: #fff;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.28);
}
.rtab-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 999px;
  background: #f59e0b;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.reports-tab.active .rtab-badge { background: rgba(255, 255, 255, 0.25); }
.incoming-slip-preview {
  width: 84px;
  height: 84px;
  background: linear-gradient(135deg, #eef2ff, #ddd6fe);
  border: 1px dashed #a78bfa;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  color: #6d28d9;
  font-weight: 700;
  text-align: center;
  padding: 4px;
  transition: transform 0.15s;
}
.incoming-slip-preview:hover { transform: scale(1.03); }
.incoming-slip-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}
.incoming-slip-info strong { font-size: 14px; color: #0f172a; }
.incoming-slip-info span { color: #64748b; font-size: 12px; }
.incoming-slip-info em { color: #94a3b8; font-size: 11px; font-style: normal; }
.incoming-slip-info code {
  font-family: ui-monospace, monospace;
  background: #f1f5f9;
  padding: 1px 4px;
  border-radius: 4px;
}
.slip-verify-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin: 2px 0;
  width: fit-content;
}
.slip-verify-badge.ok { background: #dcfce7; color: #15803d; }
.slip-verify-badge.dup { background: #fef3c7; color: #b45309; }
.slip-verify-badge.fail { background: #fee2e2; color: #b91c1c; }
.incoming-slip-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: stretch;
  min-width: 130px;
}
.incoming-slip-actions button {
  font-size: 12px;
  padding: 4px 8px;
  white-space: nowrap;
}

/* ============================================================
   ONLINE BOOKING — deposit credit row + booking queue + dashboard card
   ============================================================ */
.bill-deposit-credit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  color: #065f46;
}
.bill-deposit-credit strong { color: #047857; }
.bill-deposit-credit button { padding: 5px 12px; font-size: 12px; }

/* Dashboard alert card — only shown when pending bookings exist */
.booking-dashboard-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #eef2ff, #faf5ff);
  border: 1px solid #c7d2fe;
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 18px;
}
.booking-dashboard-main { display: flex; flex-direction: column; gap: 2px; }
.booking-dashboard-main strong { font-size: 16px; color: #3730a3; }
.booking-dashboard-badge,
.booking-panel-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #4f46e5;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  margin-left: 4px;
}

/* Booking queue panel (Appointments view) */
.booking-panel-list { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.booking-section-title { margin: 8px 0 2px; font-size: 13px; color: #475569; }
.booking-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #6366f1;
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
}
.booking-card-done { border-left-color: #10b981; opacity: 0.85; }
.booking-card-main { display: flex; flex-direction: column; gap: 3px; min-width: 200px; flex: 1; }
.booking-card-main strong { font-size: 15px; }
.booking-slot { font-size: 13px; color: #4338ca; font-weight: 600; }
.booking-service { font-size: 13px; color: #0f172a; }
.booking-dep { font-size: 12px; color: #047857; }
.booking-card-main .muted { font-size: 12px; }
.booking-slip-link { font-size: 12px; color: #2563eb; text-decoration: none; }
.booking-card-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; min-width: 120px; }
.booking-card-actions button { font-size: 12px; padding: 6px 10px; white-space: nowrap; }
.booking-confirmed-tag { font-size: 12px; color: #047857; font-weight: 600; }
@media (max-width: 640px) {
  .booking-card-actions { flex-direction: row; flex-wrap: wrap; }
}

/* ============================================================
   BARTER CARD (Mediqueen-only) — recorded off real revenue
   ============================================================ */
.barter-card-panel {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px dashed #f59e0b;
  border-radius: 12px;
  background: #fffbeb;
}
.barter-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.barter-card-head strong { font-size: 14px; color: #92400e; }
.barter-card-flag {
  font-size: 11px;
  font-weight: 700;
  color: #b45309;
  background: #fef3c7;
  border-radius: 999px;
  padding: 3px 8px;
}
.barter-card-desc { margin: 6px 0 10px; font-size: 12px; color: #78716c; line-height: 1.4; }
.barter-card-row { display: flex; gap: 8px; flex-wrap: wrap; }
.barter-card-row input[type="number"] { width: 150px; }
.barter-card-row input[type="text"] { flex: 1; min-width: 140px; }
.barter-card-row input {
  padding: 8px 10px;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  font-size: 14px;
}
.barter-card-row button { white-space: nowrap; }
.barter-card-today { margin-top: 8px; font-size: 13px; color: #92400e; }
.barter-slip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: #92400e;
  cursor: pointer;
  white-space: nowrap;
}
.barter-slip-btn:hover { background: #fffbeb; }
.barter-slip-preview { margin-top: 8px; display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.barter-slip-preview img {
  max-height: 130px;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}
.barter-slip-preview button { font-size: 12px; padding: 5px 10px; }

.barter-enable-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
}
.barter-ledger-table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: 13px; }
.barter-ledger-table th, .barter-ledger-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
}
.barter-ledger-table thead th { font-size: 12px; color: #64748b; background: #fffbeb; }
.barter-disabled-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}

/* ============================================================
   Notification Matrix + Routing recipient enrichment
   ============================================================ */
.notification-matrix-wrap {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 16px;
  margin: 12px 0;
}
.notification-matrix-wrap summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  color: #0f172a;
  padding: 4px 0;
}
.notification-matrix-wrap[open] summary { margin-bottom: 10px; }
/* Inner div that holds the matrix table — scroll it horizontally on mobile. */
.notification-matrix {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.matrix-table {
  width: 100%;
  min-width: 560px; /* event × recipient grid — scroll on mobile, not squish */
  border-collapse: collapse;
  font-size: 13px;
}
.matrix-table th {
  background: #f8fafc;
  color: #475569;
  padding: 10px 8px;
  text-align: center;
  border-bottom: 2px solid #e2e8f0;
  font-weight: 600;
  font-size: 12px;
}
.matrix-table th:first-child { text-align: left; }
.matrix-table td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid #f1f5f9;
}
.matrix-table td:first-child { text-align: left; font-weight: 500; color: #0f172a; }
.matrix-table tbody tr:hover { background: #fafbfc; }
.matrix-legend {
  margin-top: 12px;
  padding: 10px;
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
  border-radius: 6px;
  font-size: 13px;
}
.matrix-legend ul { margin: 6px 0 0; padding-left: 18px; line-height: 1.7; }

.line-recipient-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 6px;
}
.recipient-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, #c4b5fd, #a78bfa);
  color: #fff;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.recipient-avatar.placeholder { font-size: 14px; }
.line-recipient-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.line-recipient-top { display: flex; align-items: center; gap: 6px; }
.line-recipient-info code { font-size: 11px; color: #64748b; }
.line-recipient-line-name { color: #16a34a; font-weight: 600; }
.line-recipient-warn { color: #d97706; font-style: italic; }

/* ============================================================
   Slip verification modal — admin reviews AI findings + decides
   ============================================================ */
.slip-verify-backdrop {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.78);
  z-index: 2000;
}
.slip-verify-modal {
  max-width: 720px;
  width: 92%;
  max-height: 92vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}
.slip-verify-header {
  padding: 22px 28px;
  color: #fff;
  border-radius: 16px 16px 0 0;
}
.slip-verify-header h2 {
  font-size: 22px;
  margin: 0 0 8px;
  color: #fff;
}
.slip-verify-header span { font-size: 13px; opacity: 0.95; }
.slip-source-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.25);
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 600;
}
.slip-verify-body { padding: 24px 28px; }
.slip-comparison {
  display: grid;
  grid-template-columns: 1fr 40px 1fr;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.slip-comparison-side { text-align: center; }
.slip-comparison-side h4 {
  font-size: 12px;
  color: #64748b;
  margin: 0 0 8px;
  font-weight: 600;
  text-transform: uppercase;
}
.slip-comparison-side .big-amount {
  font-size: 28px;
  font-weight: 800;
  color: #0f172a;
  display: block;
}
.slip-comparison-divider {
  font-size: 32px;
  font-weight: 800;
  color: #94a3b8;
  text-align: center;
}
.slip-flags-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.slip-flag {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
}
.slip-flag span { font-size: 22px; text-align: center; }
.slip-flag-success { background: #f0fdf4; color: #166534; border-left: 4px solid #16a34a; }
.slip-flag-warning { background: #fffbeb; color: #92400e; border-left: 4px solid #f59e0b; }
.slip-flag-error { background: #fef2f2; color: #991b1b; border-left: 4px solid #dc2626; }
.slip-details-expand {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
}
.slip-details-expand summary { cursor: pointer; font-weight: 600; color: #475569; }
.slip-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
  margin-top: 10px;
  font-size: 13px;
}
.slip-details-grid div { display: flex; flex-direction: column; gap: 2px; }
.slip-details-grid span { color: #94a3b8; font-size: 11px; text-transform: uppercase; }
.slip-details-grid strong { color: #0f172a; font-size: 13px; }
.slip-decision-help {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: #1e40af;
}
.slip-decision-help ul { margin: 6px 0 0; padding-left: 18px; line-height: 1.7; }
.slip-verify-actions {
  display: flex;
  gap: 10px;
  padding: 16px 28px 24px;
  justify-content: flex-end;
  border-top: 1px solid #f1f5f9;
}
.danger-action {
  background: #dc2626;
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}
.danger-action:hover { background: #b91c1c; }

/* ============================================================
   Settings section visual categorization
   Color-code each card by category to reduce monotony when scrolling
   ============================================================ */

/* Base improvements: bigger spacing + lift + section badge */
.settings-section-card {
  position: relative;
  padding: 24px 24px 20px;
  margin-bottom: 28px;
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  border-left-width: 6px;
  border-left-style: solid;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  transition: box-shadow 0.2s, transform 0.2s;
}
.settings-section-card:hover {
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

/* Category badge — floats in top-right corner */
.settings-section-card[data-category-label]::before {
  content: attr(data-category-label);
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.3px;
  background: var(--cat-tint, #f1f5f9);
  color: var(--cat-text, #475569);
  border: 1px solid var(--cat-border, #cbd5e1);
  pointer-events: none;
  z-index: 1;
}
/* FIX (overlap bug): the chip floats top-right; section headers that carry action
   buttons in the SAME corner (e.g. AI Connector's เปิด/ปิด toggle) sat UNDER it.
   On desktop, reserve a top strip on those .wide headers so the buttons drop below
   the chip. (Mobile already clears it via the card's 60px top padding.) */
@media (min-width: 721px) {
  .settings-section-card[data-category-label] .panel-head.wide {
    padding-top: 16px;
  }
}

/* Subtle background tint matching category */
.settings-section-card[data-category] {
  background: linear-gradient(180deg, var(--cat-tint, #fff) 0%, #fff 60px);
}

/* Category palettes */
.settings-section-card[data-category="line"] {
  --cat-color: #16a34a;
  --cat-tint: #f0fdf4;
  --cat-border: #86efac;
  --cat-text: #166534;
  border-left-color: #16a34a;
}
.settings-section-card[data-category="broadcast"] {
  --cat-color: #9333ea;
  --cat-tint: #faf5ff;
  --cat-border: #d8b4fe;
  --cat-text: #6b21a8;
  border-left-color: #9333ea;
}
.settings-section-card[data-category="intake"] {
  --cat-color: #0284c7;
  --cat-tint: #f0f9ff;
  --cat-border: #7dd3fc;
  --cat-text: #075985;
  border-left-color: #0284c7;
}
.settings-section-card[data-category="payment"] {
  --cat-color: #d97706;
  --cat-tint: #fffbeb;
  --cat-border: #fcd34d;
  --cat-text: #92400e;
  border-left-color: #d97706;
}
.settings-section-card[data-category="people"] {
  --cat-color: #db2777;
  --cat-tint: #fdf2f8;
  --cat-border: #f9a8d4;
  --cat-text: #9d174d;
  border-left-color: #db2777;
}
.settings-section-card[data-category="clinic"] {
  --cat-color: var(--acc-deep);
  --cat-tint: var(--acc-50);
  --cat-border: var(--acc-bright);
  --cat-text: var(--acc-deep);
  border-left-color: var(--acc-deep);
}

/* Make panel-head inside section more prominent */
.settings-section-card .panel-head {
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.08);
}
.settings-section-card .panel-head h2 {
  font-size: 19px;
  font-weight: 800;
  color: var(--cat-color, #0f172a);
  margin: 0;
}
.settings-section-card .panel-head .muted {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: #64748b;
}

/* When a card is hovered, intensify its left border */
.settings-section-card[data-category]:hover {
  border-left-width: 8px;
}

/* For non-section cards that still need category color (e.g. broadcast inside Settings) */
.settings-section-card .panel-head .primary-action {
  background: var(--cat-color);
}

/* Anchor target highlight when navigating via menu */
.settings-section-card.section-flash {
  animation: section-flash-anim 1.4s ease-out;
}
@keyframes section-flash-anim {
  0% { box-shadow: 0 0 0 4px var(--cat-color, #94a3b8); }
  100% { box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04); }
}

/* Mobile: badge moves below header to avoid overlap */
@media (max-width: 720px) {
  .settings-section-card {
    padding: 60px 16px 16px;
  }
  .settings-section-card[data-category-label]::before {
    top: 16px;
    right: 16px;
    font-size: 10px;
  }
}

/* Settings menu — color-coded by category */
.settings-menu button[data-menu-cat] {
  position: relative;
  padding-left: 14px;
  font-weight: 500;
}
.settings-menu button[data-menu-cat]::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60%;
  border-radius: 2px;
  background: var(--menu-dot, #cbd5e1);
}
.settings-menu button[data-menu-cat="line"]::before     { background: #16a34a; }
.settings-menu button[data-menu-cat="broadcast"]::before { background: #9333ea; }
.settings-menu button[data-menu-cat="intake"]::before    { background: #0284c7; }
.settings-menu button[data-menu-cat="payment"]::before   { background: #d97706; }
.settings-menu button[data-menu-cat="people"]::before    { background: #db2777; }
.settings-menu button[data-menu-cat="clinic"]::before    { background: var(--acc-deep); }

.settings-menu button.active[data-menu-cat="line"]     { background: #f0fdf4; color: #166534; }
.settings-menu button.active[data-menu-cat="broadcast"] { background: #faf5ff; color: #6b21a8; }
.settings-menu button.active[data-menu-cat="intake"]    { background: #f0f9ff; color: #075985; }
.settings-menu button.active[data-menu-cat="payment"]   { background: #fffbeb; color: #92400e; }
.settings-menu button.active[data-menu-cat="people"]    { background: #fdf2f8; color: #9d174d; }
.settings-menu button.active[data-menu-cat="clinic"]    { background: var(--acc-50); color: var(--acc-deep); }

/* ============================================================
   Receipt Template editor form
   ============================================================ */
.receipt-template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.receipt-template-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.receipt-template-field.wide { grid-column: 1 / -1; }
.receipt-template-field span {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}
.receipt-template-field input,
.receipt-template-field textarea,
.receipt-template-field select {
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.receipt-template-field input:focus,
.receipt-template-field textarea:focus,
.receipt-template-field select:focus {
  outline: none;
  border-color: #d97706;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
}
.receipt-template-help {
  margin-top: 14px;
  padding: 10px 14px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
}
.receipt-template-help summary {
  cursor: pointer;
  font-weight: 600;
  color: #92400e;
  font-size: 13px;
}
.receipt-template-help ul {
  margin: 8px 0 0;
  padding-left: 18px;
  line-height: 1.8;
  font-size: 13px;
  color: #78350f;
}
.receipt-template-help strong {
  background: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid #fcd34d;
  font-family: ui-monospace, monospace;
}

@media (max-width: 720px) {
  .receipt-template-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Receipt preview modal
   ============================================================ */
.receipt-preview-backdrop {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: rgba(15, 23, 42, 0.78);
  z-index: 2000;
  overflow-y: auto;
  padding: 24px 12px;
}
.receipt-preview-modal {
  width: 92%;
  max-width: 920px;
  background: #f1f5f9;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}
.receipt-preview-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
  background: linear-gradient(135deg, #d97706, #92400e);
  color: #fff;
  flex-wrap: wrap;
}
.receipt-preview-modal-head h2 { margin: 0; color: #fff; font-size: 20px; }
.receipt-preview-size-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.receipt-preview-size-tabs .chip {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 6px 12px;
  border-radius: 16px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.receipt-preview-size-tabs .chip.active { background: #fff; color: #92400e; }
.receipt-preview-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.receipt-preview-actions .ghost-button {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}
.receipt-preview-stage {
  padding: 24px;
  background: #cbd5e1;
  max-height: 75vh;
  overflow-y: auto;
  display: flex;
  justify-content: center;
}

/* The receipt paper itself — clean white background, official look */
.receipt-preview-paper {
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  padding: 28px 32px;
  color: #0f172a;
  font-family: 'Sarabun', sans-serif;
  line-height: 1.5;
}
.receipt-paper-thermal { width: 280px; padding: 16px 12px; font-size: 11px; }
.receipt-paper-a5 { width: 540px; }
.receipt-paper-a4 { width: 720px; }

.receipt-preview-header {
  text-align: center;
  padding-bottom: 16px;
  border-bottom: 2px solid #0f172a;
}
.receipt-preview-logo {
  max-width: 80px;
  max-height: 80px;
  display: block;
  margin: 0 auto 8px;
}
.receipt-preview-logo-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 24px;
  margin: 0 auto 8px;
  color: #0f766e;
}
.receipt-preview-header h1 {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 4px;
}
.receipt-paper-thermal .receipt-preview-header h1 { font-size: 14px; }
.receipt-preview-en-name {
  font-size: 13px;
  color: #475569;
  margin: 0 0 6px;
  font-weight: 600;
}
.receipt-preview-header p {
  margin: 2px 0;
  font-size: 12px;
  color: #475569;
}

.receipt-preview-title {
  text-align: center;
  margin: 16px 0 12px;
}
.receipt-preview-title h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
}
.receipt-preview-title p {
  margin: 2px 0 0;
  font-size: 11px;
  color: #94a3b8;
  font-style: italic;
}

.receipt-preview-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px;
  background: #f8fafc;
  border-radius: 6px;
  font-size: 13px;
}
.receipt-paper-thermal .receipt-preview-meta { grid-template-columns: 1fr; gap: 4px; font-size: 11px; }
.receipt-preview-meta span { display: block; color: #94a3b8; font-size: 11px; }
.receipt-preview-meta strong { color: #0f172a; }

.receipt-preview-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
  font-size: 13px;
}
.receipt-paper-thermal .receipt-preview-table { font-size: 11px; }
.receipt-preview-table th {
  background: #0f172a;
  color: #fff;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}
.receipt-preview-table td {
  padding: 8px 6px;
  border-bottom: 1px dashed #e2e8f0;
  vertical-align: top;
}

.receipt-preview-totals {
  border-top: 2px solid #0f172a;
  padding-top: 10px;
  margin-bottom: 14px;
}
.receipt-preview-totals > div {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 14px;
}
.receipt-preview-net {
  font-size: 18px !important;
  font-weight: 800;
  border-top: 1px solid #cbd5e1;
  margin-top: 6px;
  padding-top: 8px !important;
}
.receipt-preview-vat-note small {
  color: #94a3b8;
  font-size: 11px;
  font-style: italic;
}

.receipt-preview-payment {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
  padding: 10px 0;
  border-top: 1px dashed #e2e8f0;
  border-bottom: 1px dashed #e2e8f0;
}
.receipt-paper-thermal .receipt-preview-payment { grid-template-columns: 1fr; gap: 4px; }
.receipt-preview-payment > div { font-size: 12px; }
.receipt-preview-payment span { display: block; color: #94a3b8; }

.receipt-preview-terms {
  margin: 14px 0;
  padding: 8px 12px;
  background: #fafbfc;
  border-left: 3px solid #cbd5e1;
  font-size: 11px;
  color: #475569;
  line-height: 1.6;
}

.receipt-preview-footer {
  text-align: center;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}
.receipt-preview-footer p { margin: 4px 0; font-size: 12px; color: #475569; }
.receipt-preview-sample-watermark {
  color: #fbbf24 !important;
  font-weight: 800;
  letter-spacing: 2px;
  font-size: 11px !important;
}

@media (max-width: 720px) {
  .receipt-preview-paper { padding: 16px; }
  .receipt-paper-a5, .receipt-paper-a4 { width: 100%; }
}

/* ============================================================
   LINE OA usage quota card (Broadcast section)
   ============================================================ */
.line-quota-card {
  background: #fff;
  border: 1px solid #e9d5ff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #faf5ff 0%, #ffffff 100%);
}
.line-quota-loading,
.line-quota-error {
  text-align: center;
  padding: 18px;
  color: #94a3b8;
  font-size: 13px;
}
.line-quota-error { color: #dc2626; }

.line-quota-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.line-quota-cell {
  background: #fff;
  border: 1px solid #e9d5ff;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.line-quota-cell strong {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
}
.line-quota-cell small {
  font-size: 11px;
  color: #94a3b8;
}
.line-quota-label {
  font-size: 12px;
  font-weight: 600;
  color: #6b21a8;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.line-quota-plan-badge {
  display: inline-block;
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  align-self: flex-start;
}
.line-quota-remaining.ok      { color: #16a34a; }
.line-quota-remaining.warn    { color: #d97706; }
.line-quota-remaining.danger  { color: #dc2626; }

.line-quota-progress-wrap {
  margin-bottom: 10px;
}
.line-quota-progress {
  height: 12px;
  background: #f1f5f9;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}
.line-quota-progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #a78bfa, #d946ef);
  transition: width 0.6s ease-out;
}
.line-quota-progress.warn > span   { background: linear-gradient(90deg, #f59e0b, #ea580c); }
.line-quota-progress.danger > span { background: linear-gradient(90deg, #dc2626, #991b1b); }
.line-quota-progress-label {
  display: block;
  text-align: center;
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
}

.line-quota-warn {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  margin: 8px 0 12px;
}
.line-quota-warn-warn   { background: #fffbeb; border-left: 4px solid #f59e0b; color: #92400e; }
.line-quota-warn-danger { background: #fef2f2; border-left: 4px solid #dc2626; color: #991b1b; }

.line-quota-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px dashed #e9d5ff;
  font-size: 11px;
  color: #64748b;
}
.line-quota-meta small { font-size: 11px; }

@media (max-width: 720px) {
  .line-quota-grid { grid-template-columns: repeat(2, 1fr); }
  .line-quota-meta { flex-direction: column; gap: 4px; }
}

/* ============================================================
   State size diagnostic modal
   ============================================================ */
.state-diag-backdrop {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.78);
  z-index: 2000;
}
.state-diag-modal {
  max-width: 760px;
  width: 92%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
}
.state-diag-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #fff;
}
.state-diag-head h2 { color: #fff; margin: 0; font-size: 19px; }
.state-diag-head .icon-button { color: #fff; background: rgba(255,255,255,0.18); border: none; padding: 4px 12px; border-radius: 6px; font-size: 20px; cursor: pointer; }
.state-diag-body { padding: 20px 24px; overflow-y: auto; flex: 1; }

.state-diag-warn {
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 600;
  margin-bottom: 14px;
}
.state-diag-warn.ok      { background: #f0fdf4; border-left: 4px solid #16a34a; color: #166534; }
.state-diag-warn.warn    { background: #fffbeb; border-left: 4px solid #f59e0b; color: #92400e; }
.state-diag-warn.danger  { background: #fef2f2; border-left: 4px solid #dc2626; color: #991b1b; }

.state-diag-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.state-diag-summary > div {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
}
.state-diag-summary span { display: block; font-size: 11px; color: #94a3b8; }
.state-diag-summary strong { font-size: 18px; color: #0f172a; }

.state-diag-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.state-diag-table th {
  background: #f1f5f9;
  padding: 8px;
  text-align: left;
  border-bottom: 2px solid #e2e8f0;
  font-weight: 600;
  color: #475569;
}
.state-diag-table td {
  padding: 8px;
  border-bottom: 1px solid #f1f5f9;
}
.state-diag-table code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 12px; }
.state-diag-table tr.heavy { background: #fef2f2; }
.state-diag-table tr.heavy code { background: #fecaca; color: #991b1b; }

.state-diag-help {
  margin-top: 16px;
  padding: 10px 14px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
}
.state-diag-help summary { cursor: pointer; font-weight: 600; color: #92400e; }
.state-diag-help ul { margin: 8px 0 8px; padding-left: 18px; font-size: 13px; line-height: 1.7; }
.state-diag-help code { background: #fff; padding: 1px 5px; border-radius: 3px; }

.state-diag-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid #f1f5f9;
}

/* ============================================================
   LINE Users — 3-status pills (HN bind / Routing / Doctor roster)
   ============================================================ */
.line-user-status-cell { min-width: 180px; }
.line-status-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.line-status-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
  cursor: help;
}

/* HN bind status */
.line-status-pill.hn-bound {
  background: #f0fdf4;
  color: #166534;
  border-color: #86efac;
}
.line-status-pill.hn-unbound {
  background: #f8fafc;
  color: #94a3b8;
  border-color: #e2e8f0;
}

/* Routing membership */
.line-status-pill.routing-active {
  background: #faf5ff;
  color: #6b21a8;
  border-color: #d8b4fe;
}
.line-status-pill.routing-empty {
  background: #f8fafc;
  color: #94a3b8;
  border-color: #e2e8f0;
}

/* Doctor roster */
.line-status-pill.doctor-active {
  background: #f0f9ff;
  color: #075985;
  border-color: #7dd3fc;
}
.line-status-pill.doctor-empty {
  background: #f8fafc;
  color: #94a3b8;
  border-color: #e2e8f0;
}

/* Doctor card variant — same shape as routing cards but tinted differently */
.line-routing-card-doctor {
  border-left: 4px solid #0284c7;
  background: linear-gradient(180deg, #f0f9ff 0%, #ffffff 80%);
}
.line-routing-card-doctor h3 { color: #075985; }

.line-users-table th small {
  display: block;
  font-weight: 400;
  font-size: 10px;
  color: #94a3b8;
  margin-top: 2px;
}

/* Field auto-save indicator — subtle green checkmark next to inputs */
.field-saved-mark {
  display: inline-block;
  margin-left: 6px;
  color: #16a34a;
  font-weight: 700;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.field-saved-mark.show {
  opacity: 1;
}

/* ============================================================
   Dashboard Intake Strip — pending intake widget at top of dashboard
   ============================================================ */
.dashboard-intake-strip {
  background: linear-gradient(135deg, #faf5ff 0%, #fdf4ff 100%);
  border: 2px solid #d8b4fe;
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 18px;
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.12);
  transition: background 0.4s, border-color 0.4s, box-shadow 0.4s;
}
.dashboard-intake-strip[data-state="has-pending"] {
  border-color: #a855f7;
  background: linear-gradient(135deg, #f3e8ff 0%, #fae8ff 100%);
  box-shadow: 0 6px 18px rgba(168, 85, 247, 0.22);
  animation: intake-strip-attention 1.2s ease-out;
}
.dashboard-intake-strip[data-state="empty"] { opacity: 0.85; }
.dashboard-intake-strip[data-state="error"],
.dashboard-intake-strip[data-state="no-secret"] {
  border-color: #fcd34d;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}
@keyframes intake-strip-attention {
  0%   { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.7); transform: translateY(-4px); opacity: 0; }
  100% { box-shadow: 0 6px 18px rgba(168, 85, 247, 0.22); transform: translateY(0); opacity: 1; }
}
.dashboard-intake-badge {
  background: #a855f7;
  color: #fff;
  padding: 2px 12px;
  border-radius: 999px;
  font-size: 15px;
  margin: 0 4px;
  font-weight: 800;
  display: inline-block;
  min-width: 28px;
  text-align: center;
}
.dashboard-intake-strip[data-state="has-pending"] .dashboard-intake-badge {
  animation: intake-badge-pulse 1.5s ease-in-out infinite;
}
@keyframes intake-badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.25); }
}
.dashboard-intake-empty {
  text-align: center;
  padding: 22px 14px;
  color: #94a3b8;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px dashed rgba(168, 85, 247, 0.3);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dashboard-intake-empty small { font-size: 11px; color: #cbd5e1; }
.dashboard-intake-more {
  text-align: center;
  font-size: 12px;
  color: #6b21a8;
  font-style: italic;
  margin-top: 6px;
  padding: 6px;
  background: rgba(168, 85, 247, 0.08);
  border-radius: 6px;
}
.dashboard-intake-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.dashboard-intake-head strong {
  font-size: 16px;
  color: #6b21a8;
}
.dashboard-intake-head strong span {
  background: #a855f7;
  color: #fff;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 14px;
  margin: 0 4px;
}
.dashboard-intake-head .muted {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}
.dashboard-intake-list {
  display: grid;
  gap: 8px;
}
.dashboard-intake-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #e9d5ff;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.dashboard-intake-row:hover {
  transform: translateX(4px);
  border-color: #a855f7;
  box-shadow: 0 4px 10px rgba(168, 85, 247, 0.18);
}
.dashboard-intake-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a855f7, #9333ea);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
}
.dashboard-intake-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dashboard-intake-info strong {
  color: #0f172a;
  font-size: 14px;
}
.dashboard-intake-info span {
  color: #64748b;
  font-size: 12px;
}
.dashboard-intake-row button {
  padding: 6px 14px;
  font-size: 13px;
}
.dashboard-intake-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.dashboard-intake-actions .primary-action {
  background: #a855f7;
}
.dashboard-intake-actions .primary-action:hover {
  background: #9333ea;
}
.dashboard-intake-actions .ghost-button {
  padding: 6px 10px;
}

/* ============================================================
   Slip Match Banner — auto-suggestion when bill amount matches a pending slip
   ============================================================ */
.slip-match-banner {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 2px solid #f59e0b;
  border-radius: 12px;
  padding: 14px 18px;
  margin: 14px 0;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.25);
  animation: slip-match-pulse 1.2s ease-out;
}
@keyframes slip-match-pulse {
  0%   { transform: scale(0.96); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); }
  60%  { transform: scale(1.02); box-shadow: 0 0 0 12px rgba(245, 158, 11, 0); }
  100% { transform: scale(1); }
}
.slip-match-banner-content {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 14px;
  align-items: center;
}
.slip-match-icon {
  font-size: 32px;
  text-align: center;
}
.slip-match-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.slip-match-info strong {
  font-size: 16px;
  color: #78350f;
}
.slip-match-info span {
  font-size: 12px;
  color: #92400e;
}
.slip-match-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.slip-match-actions .primary-action {
  background: #f59e0b;
  color: #fff;
  padding: 8px 14px;
  font-weight: 700;
}
.slip-match-actions .primary-action:hover { background: #d97706; }
.slip-match-more {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #f59e0b;
  font-size: 12px;
  color: #92400e;
  font-style: italic;
  text-align: center;
}

@media (max-width: 720px) {
  .slip-match-banner-content { grid-template-columns: 1fr; text-align: center; }
}

/* ============================================================
 * Mobile-narrow (<600px) — LINE in-app browser / phone portrait
 * Without this, Settings sections overlap with the main sidebar
 * brand-mark and content stacks chaotically. Forces a clean
 * single-column layout with extra padding-bottom so floating AI
 * Assistant button doesn't cover the last section.
 * ============================================================ */
@media (max-width: 600px) {
  /* Main shell already collapses to 1 col at 820px, but the sidebar
     "sticky" behavior on iOS Safari + LINE in-app browser can still
     overlap. Force it to release sticky and shrink padding. */
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    padding: 12px 14px;
    gap: 12px;
    overflow: visible;
  }
  .brand {
    gap: 8px;
  }
  .brand-mark,
  .brand-logo {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
  }
  /* Settings — settings menu becomes a horizontal scroll strip so it
     doesn't take 60% of the screen vertically. */
  #settings .settings-layout {
    /* minmax(0,1fr) — NOT plain 1fr. Plain "1fr" = minmax(auto,1fr) whose auto
       minimum refuses to shrink below content min-width, so a wide table (e.g.
       Users & Roles, min-width 820px) stretches the whole column to 820px and
       the in-table horizontal scroll never engages (body overflow-x:hidden then
       just clips the right side). minmax(0,…) lets the column shrink to the
       viewport so .users-table-wrap can scroll internally. */
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  #settings .panel { min-width: 0; }
  #settings .settings-menu {
    /* Sticky at top of viewport on mobile — user can switch tabs without
       scrolling back up. z-index above section content but below modals. */
    position: sticky;
    top: 0;
    z-index: 50;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    padding: 8px 4px;
    gap: 6px;
    border-bottom: 1px solid var(--line);
    -webkit-overflow-scrolling: touch;
  }
  /* Long URL/code fields — never break character-by-character */
  .settings-section-card input[type="text"],
  .settings-section-card input[type="url"],
  .settings-section-card textarea,
  .settings-section-card pre,
  .settings-section-card code {
    word-break: break-all;
    overflow-wrap: anywhere;
    white-space: normal;
    font-size: 13px;
  }
  /* Force any field showing a URL to use normal layout (not one-char-per-line) */
  .settings-section-card .field-url-display,
  .settings-section-card [data-base-worker-url],
  .settings-section-card [data-endpoint-url] {
    display: block;
    width: 100%;
    word-break: break-all;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    font-family: ui-monospace, monospace;
    font-size: 12px;
  }
  #settings .settings-menu button {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 13px;
    padding: 0 10px;
    min-height: 36px;
  }
  .settings-section-card {
    padding: 18px 14px 14px;
    margin-bottom: 16px;
    border-left-width: 4px;
    background: #ffffff; /* hard solid so nothing bleeds through */
    overflow: hidden; /* clip floating badges */
  }
  .settings-section-card[data-category-label]::before {
    /* Hide the floating category chip — saves space and removes overlap risk */
    display: none;
  }
  .settings-form,
  .settings-mini-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  /* Workspace padding tighter so content uses every pixel */
  .workspace {
    padding: 12px;
  }
  .topbar {
    padding: 10px 0;
    gap: 8px;
  }
  /* AI Assistant floating button — leave room at bottom so it doesn't
     cover the last settings section */
  body {
    padding-bottom: 80px;
  }
  /* Modals fill the screen on tiny viewports */
  .modal-content {
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
  }
}

/* ============================================================ */
/* LOGIN OVERLAY (Phase 2) — sits above app-shell until login    */
/* ============================================================ */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, #1f3f4f 0%, #0c1f2a 60%, #060f15 100%);
  padding: 24px;
  overflow-y: auto;
  -webkit-font-smoothing: antialiased;
}
.login-overlay[hidden] { display: none !important; }

.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 36px 32px 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04);
  position: relative;
}

.login-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.login-brand {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #1a8e8a);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 22px;
  overflow: hidden;
  flex-shrink: 0;
}
.login-brand-logo {
  width: 100%; height: 100%;
  object-fit: cover;
}
.login-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
  color: #1a2d3a;
}
.login-subtitle {
  margin: 0;
  font-size: 14px;
  color: #6a7a86;
}

.login-tabs {
  display: flex;
  gap: 4px;
  background: #f0f4f6;
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 20px;
}
.login-tab {
  flex: 1;
  padding: 10px 14px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #6a7a86;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.login-tab:hover { color: #1a2d3a; }
.login-tab.active {
  background: #fff;
  color: #1a2d3a;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.login-tab-icon { margin-right: 4px; }

.login-pane[hidden] { display: none; }
.login-pane-hint {
  font-size: 13px;
  color: #6a7a86;
  margin: 0 0 16px;
  text-align: center;
}

/* Staff grid */
.login-staff-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.login-staff-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px;
  background: #f7f9fa;
  border: 2px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
}
.login-staff-card:hover {
  border-color: var(--primary);
  background: #fff;
  transform: translateY(-2px);
}
.login-staff-card.no-credentials {
  border-style: dashed;
  border-color: #f0b400;
  background: #fffaea;
}
.login-staff-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5db8b5, #2c8b88);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  overflow: hidden;
}
.login-staff-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.login-staff-name {
  font-size: 13px;
  font-weight: 600;
  color: #1a2d3a;
  text-align: center;
  line-height: 1.25;
  width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
}
.login-staff-role {
  font-size: 11px;
  color: #6a7a86;
  text-align: center;
  width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.login-staff-setup-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  color: #b07900;
  background: #fff1c4;
  border-radius: 8px;
  padding: 2px 6px;
  margin-top: 2px;
}

.login-empty {
  text-align: center;
  padding: 32px 16px;
  color: #6a7a86;
}
.login-empty-hint { font-size: 12px; }

/* Owner form */
.login-owner-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.login-field span {
  font-size: 13px;
  font-weight: 600;
  color: #1a2d3a;
}
.login-field input,
.login-field select {
  padding: 10px 12px;
  border: 1.5px solid #e0e6ea;
  border-radius: 10px;
  font-size: 15px;
  background: #fff;
  transition: border-color 0.12s;
}
.login-field input:focus,
.login-field select:focus {
  outline: none;
  border-color: var(--primary);
}
.login-submit {
  padding: 12px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s;
}
.login-submit:hover { background: #1f9d99; }
.login-submit:disabled { background: #b0c6c5; cursor: not-allowed; }

.login-error {
  padding: 10px 12px;
  background: #fde8e6;
  color: #c0392b;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
}

.login-footer-note {
  margin: 22px 0 0;
  text-align: center;
  font-size: 11px;
  color: #97a4ab;
}

/* ============================================================ */
/* PIN KEYPAD                                                    */
/* ============================================================ */
.pin-keypad-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 22, 30, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border-radius: 20px;
}
.pin-keypad-backdrop[hidden] { display: none; }

.pin-keypad-card {
  background: #fff;
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 320px;
  width: 100%;
  position: relative;
  text-align: center;
}
.pin-keypad-back {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 36px;
  height: 36px;
  border: none;
  background: #f0f4f6;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  color: #1a2d3a;
}
.pin-keypad-back:hover { background: #e0e6ea; }

.pin-keypad-user {
  margin-bottom: 18px;
}
.pin-keypad-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5db8b5, #2c8b88);
  margin: 0 auto 10px;
  color: #fff;
  font-weight: 700;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.pin-keypad-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pin-keypad-name {
  font-size: 17px;
  font-weight: 700;
  color: #1a2d3a;
}
.pin-keypad-role {
  font-size: 12px;
  color: #6a7a86;
  margin-top: 2px;
}
.pin-keypad-prompt {
  font-size: 13px;
  color: #6a7a86;
  margin-bottom: 12px;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 16px;
}
.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e0e6ea;
  transition: background 0.1s, transform 0.1s;
}
.pin-dot.filled {
  background: var(--primary);
  transform: scale(1.1);
}
.pin-dot.error {
  background: #e74c3c;
  animation: pin-shake 0.4s;
}
@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.pin-error {
  padding: 8px 12px;
  background: #fde8e6;
  color: #c0392b;
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 12px;
}

.pin-keys {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.pin-key {
  padding: 16px;
  background: #f0f4f6;
  border: none;
  border-radius: 12px;
  font-size: 20px;
  font-weight: 600;
  color: #1a2d3a;
  cursor: pointer;
  transition: background 0.1s, transform 0.05s;
}
.pin-key:hover { background: #e0e6ea; }
.pin-key:active { transform: scale(0.95); }
.pin-key-blank {
  background: transparent !important;
  pointer-events: none;
}
.pin-key-back {
  font-size: 22px;
  color: #6a7a86;
}

/* ============================================================ */
/* SETUP WIZARD (first-time)                                     */
/* ============================================================ */
.login-setup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 22, 30, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border-radius: 20px;
}
.login-setup-backdrop[hidden] { display: none; }

.login-setup-card {
  background: #fff;
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 420px;
  width: 100%;
}
.login-setup-card h2 {
  margin: 0 0 12px;
  font-size: 22px;
}
.login-setup-intro {
  font-size: 14px;
  color: #6a7a86;
  margin: 0 0 20px;
  line-height: 1.5;
}
.login-setup-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ============================================================ */
/* TOPBAR USER CHIP (Phase 5 prep)                               */
/* ============================================================ */
.topbar-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #f0f4f6;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  border: none;
  transition: background 0.12s;
}
.topbar-user-chip:hover { background: #e0e6ea; }
.topbar-user-chip-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5db8b5, #2c8b88);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.topbar-user-chip-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Mobile login adjustments */
@media (max-width: 520px) {
  .login-card { padding: 28px 20px 20px; border-radius: 16px; }
  .login-staff-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .login-staff-card { padding: 12px 6px; gap: 6px; }
  .login-staff-name { font-size: 12px; }
  .login-staff-role { font-size: 10.5px; }
  .login-staff-avatar { width: 46px; height: 46px; font-size: 17px; }
  .login-staff-setup-badge { font-size: 8.5px; padding: 1px 6px; }
  .pin-keypad-card { padding: 22px 18px; }
  .pin-key { padding: 14px; font-size: 18px; }
}

/* ============================================================ */
/* SETTINGS — System Tools / Backup buttons grid                 */
/* ============================================================ */
.settings-action-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.settings-action-grid > button,
.settings-action-grid > label {
  flex: 0 0 auto;
}
.security-grid section h3 {
  display: flex;
  align-items: center;
  gap: 6px;
}
.security-grid details {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 12px;
}
.security-grid details summary::-webkit-details-marker {
  display: none;
}
.security-grid details summary::before {
  content: "▸ ";
  display: inline-block;
  margin-right: 4px;
  transition: transform 0.15s;
}
.security-grid details[open] summary::before {
  transform: rotate(90deg);
}
.security-grid details code {
  background: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

/* ============================================================ */
/* Import duplicate summary modal                                */
/* Shows totals + per-type counts + radio for action strategy    */
/* ============================================================ */
.import-dup-modal {
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.import-dup-modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eef2f4;
}
.import-dup-modal header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}
.import-dup-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}
.import-dup-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}
.import-dup-stat {
  background: #f7f9fa;
  border: 1.5px solid #e2e8ec;
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.import-dup-stat.clean {
  background: #ecfdf5;
  border-color: #6ee7b7;
}
.import-dup-stat.warn {
  background: #fef3c7;
  border-color: #fbbf24;
}
.import-dup-stat .num {
  font-size: 24px;
  font-weight: 800;
  color: #1a2d3a;
}
.import-dup-stat.clean .num { color: #065f46; }
.import-dup-stat.warn .num { color: #92400e; }
.import-dup-stat .lbl {
  font-size: 12px;
  color: #6a7a86;
}
.import-dup-total {
  text-align: center;
  margin: 12px 0 18px;
  color: #6a7a86;
  font-size: 13px;
}
.import-dup-section-title {
  margin: 8px 0 10px;
  font-size: 15px;
  font-weight: 700;
}
.import-dup-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.import-dup-choice {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border: 1.5px solid #e2e8ec;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  align-items: flex-start;
}
.import-dup-choice:hover { border-color: var(--primary); background: #fafdfd; }
.import-dup-choice input[type="radio"] {
  margin-top: 3px;
  cursor: pointer;
  flex-shrink: 0;
}
.import-dup-choice input[type="radio"]:checked + div {
  color: #1a2d3a;
}
.import-dup-choice:has(input:checked) {
  border-color: var(--primary);
  background: #ecfeff;
}
.import-dup-choice strong {
  display: block;
  margin-bottom: 3px;
  font-size: 14px;
  font-weight: 700;
}
.import-dup-choice small {
  display: block;
  font-size: 12px;
  color: #6a7a86;
  line-height: 1.4;
}
.import-dup-choice .recommended {
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
}
.import-dup-details {
  margin: 6px 0;
  background: #fafbfc;
  border: 1px solid #eef2f4;
  border-radius: 8px;
  padding: 8px 12px;
}
.import-dup-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: #1a2d3a;
  padding: 4px 0;
  user-select: none;
}
.import-dup-details ul {
  margin: 8px 0 0;
  padding-left: 20px;
  font-size: 12.5px;
  color: #4a5764;
}
.import-dup-details li { margin: 4px 0; line-height: 1.4; }
.import-dup-details li.more {
  list-style: none;
  margin-left: -20px;
  color: #97a4ab;
  font-style: italic;
  font-size: 11.5px;
}
.import-dup-details li small {
  color: #97a4ab;
  font-weight: normal;
  font-size: 11.5px;
}
.import-dup-clean-msg {
  text-align: center;
  padding: 24px 12px;
  background: #ecfdf5;
  border: 1.5px solid #6ee7b7;
  border-radius: 10px;
  color: #065f46;
  font-weight: 600;
  font-size: 15px;
}
.import-dup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #eef2f4;
}
@media (max-width: 600px) {
  .import-dup-summary { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================ */
/* Bill items + Item picker modal                                */
/* ============================================================ */
.invoice-item-row {
  display: grid;
  grid-template-columns: 1fr 110px 100px 90px 32px;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid #f0f4f6;
  background: #fff;
}
.invoice-item-row:hover { background: #fafdfd; }
.invoice-item-row.invoice-below-floor {
  background: #fef3c7;
}
.invoice-item-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  line-height: 1.3;
}
.invoice-item-name strong { font-weight: 600; color: #1a2d3a; }
.invoice-kind-icon { font-size: 16px; flex-shrink: 0; }
.invoice-floor-warn {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: #b45309;
  background: #fef3c7;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
  font-style: normal;
}
.invoice-item-qty {
  display: flex;
  align-items: center;
  gap: 2px;
}
.invoice-item-qty button {
  width: 26px; height: 26px;
  background: #f0f4f6;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  color: #1a2d3a;
}
.invoice-item-qty button:hover { background: #e0e6ea; }
.invoice-item-qty input {
  width: 44px;
  text-align: center;
  border: 1px solid #e0e6ea;
  border-radius: 4px;
  padding: 3px 0;
  font-size: 13px;
  -moz-appearance: textfield;
}
.invoice-item-qty input::-webkit-outer-spin-button,
.invoice-item-qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.invoice-item-price input {
  width: 100%;
  border: 1px solid #e0e6ea;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 13px;
  text-align: right;
}
.invoice-item-total {
  font-weight: 700;
  text-align: right;
  color: #1a2d3a;
  font-size: 14px;
}
.invoice-item-remove {
  width: 28px; height: 28px;
  background: #fee2e2;
  border: none;
  border-radius: 50%;
  color: #b91c1c;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.invoice-item-remove:hover { background: #fecaca; }

/* Item picker modal */
.item-picker-backdrop .item-picker-modal {
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.item-picker-modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #eef2f4;
}
.item-picker-modal header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}
.item-picker-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 18px 0;
  border-bottom: 1px solid #eef2f4;
}
.item-picker-tabs button {
  padding: 9px 14px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 14px;
  font-weight: 600;
  color: #6a7a86;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.item-picker-tabs button:hover { color: #1a2d3a; }
.item-picker-tabs button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.item-picker-tabs .count {
  display: inline-block;
  background: #f0f4f6;
  color: #6a7a86;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  margin-left: 4px;
}
.item-picker-tabs button.active .count {
  background: var(--primary);
  color: #fff;
}
.item-picker-search {
  padding: 12px 18px 8px;
}
.item-picker-search input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #e0e6ea;
  border-radius: 8px;
  font-size: 14px;
}
.item-picker-search input:focus { outline: none; border-color: var(--primary); }

.item-picker-body {
  overflow-y: auto;
  flex: 1;
  padding: 4px 18px 18px;
}
.item-picker-row {
  display: grid;
  grid-template-columns: 1fr auto auto 32px;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid #f0f4f6;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s, transform 0.08s;
  font: inherit;
}
.item-picker-row:hover {
  border-color: var(--primary);
  background: #fafdfd;
  transform: translateX(2px);
}
.item-picker-row.low-stock {
  background: #fef3c7;
  border-color: #fbbf24;
}
.item-picker-name {
  font-size: 14px;
  font-weight: 600;
  color: #1a2d3a;
  line-height: 1.3;
}
.item-picker-name small {
  display: block;
  font-size: 11.5px;
  font-weight: 400;
  color: #97a4ab;
  margin-top: 2px;
}
.item-picker-cat {
  font-size: 11.5px;
  color: #6a7a86;
}
.item-picker-price {
  font-size: 14px;
  font-weight: 700;
  color: #1a2d3a;
  text-align: right;
}
.item-picker-add {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.item-picker-more {
  text-align: center;
  padding: 12px;
  color: #97a4ab;
  font-size: 12px;
  font-style: italic;
}
.item-picker-empty {
  text-align: center;
  padding: 40px 20px;
  color: #97a4ab;
  font-size: 14px;
}
.item-picker-custom {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 4px;
}
.item-picker-custom .muted {
  margin: 0;
  font-size: 12.5px;
  color: #6a7a86;
}
.item-picker-custom label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #1a2d3a;
}
.item-picker-custom input {
  padding: 9px 12px;
  border: 1.5px solid #e0e6ea;
  border-radius: 8px;
  font-size: 14px;
}
.item-picker-custom input:focus { outline: none; border-color: var(--primary); }

@media (max-width: 600px) {
  .invoice-item-row {
    grid-template-columns: 1fr 88px 80px 70px 28px;
    gap: 4px;
    font-size: 12px;
  }
  .invoice-item-qty input { width: 32px; }
  .item-picker-row {
    grid-template-columns: 1fr auto 28px;
  }
  .item-picker-row .item-picker-cat { display: none; }
}

/* ============================================================ */
/* Collapsed customer-workflow-guide — saves vertical space      */
/* ============================================================ */
.customer-workflow-guide-collapsed {
  margin: 6px 0 12px;
  border: 1px solid #e2e8ec;
  border-radius: 8px;
  background: #fafbfc;
}
.customer-workflow-guide-collapsed summary {
  cursor: pointer;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: #6a7a86;
  user-select: none;
  list-style: none;
}
.customer-workflow-guide-collapsed summary::-webkit-details-marker {
  display: none;
}
.customer-workflow-guide-collapsed summary::before {
  content: "▸ ";
  display: inline-block;
  margin-right: 4px;
  transition: transform 0.15s;
}
.customer-workflow-guide-collapsed[open] summary::before {
  transform: rotate(90deg);
}
.customer-workflow-guide-collapsed summary:hover { color: #1a2d3a; }
.customer-workflow-guide-collapsed .customer-workflow-guide {
  padding: 4px 14px 12px;
}

/* Ensure import-dup modal stacks ABOVE the import modal that opened it. */
.import-dup-modal-backdrop {
  z-index: 10000 !important;
}
.import-dup-modal {
  z-index: 10001 !important;
}

/* ============================================================ */
/* Bill row v2 — full / discount / sale columns                   */
/* ============================================================ */
.invoice-item-row {
  grid-template-columns: 1.6fr 100px 90px 90px 90px 30px !important;
}
.invoice-item-header {
  background: #f7f9fa;
  font-size: 11px;
  font-weight: 600;
  color: #6a7a86;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.invoice-item-header > div { padding: 4px 2px; }
.invoice-item-header .invoice-item-name { padding-left: 8px; }
.invoice-item-header .total-label { color: #16a34a; }
.invoice-item-qty-label,
.invoice-item-cell-label { text-align: center; }
.invoice-item-fullprice {
  text-align: right;
  font-size: 12.5px;
  color: #4a5764;
  align-self: center;
}
.invoice-item-fullprice input {
  width: 100%;
  text-align: right;
  padding: 4px 6px;
  border: 1px solid #e0e6ea;
  border-radius: 4px;
  font-size: 13px;
  color: #475569;
  background: #f8fafc;
  text-decoration: none;
}
.invoice-item-fullprice input:focus {
  outline: none;
  border-color: #818cf8;
  background: #fff;
}
.invoice-item-discount input {
  width: 100%;
  text-align: right;
  padding: 4px 6px;
  border: 1px solid #e0e6ea;
  border-radius: 4px;
  font-size: 13px;
  color: #c2410c;
  background: #fff7ed;
}
.invoice-item-discount input:focus {
  outline: none;
  border-color: #f97316;
  background: #fff;
}

/* ============================================================ */
/* Split payment grid                                            */
/* ============================================================ */
.payment-split-host {
  margin-top: 12px;
  padding: 14px;
  background: #fafbfc;
  border: 1.5px solid #e2e8ec;
  border-radius: 10px;
}
.payment-split-host:empty { display: none; }
.pay-split-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.pay-split-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: #1a2d3a;
}
.pay-split-row label span { color: #4a5764; }
.pay-split-row input {
  padding: 7px 10px;
  border: 1.5px solid #e0e6ea;
  border-radius: 8px;
  font-size: 14px;
  text-align: right;
  background: #fff;
}
.pay-split-row input:focus {
  outline: none;
  border-color: var(--primary);
}
.pay-split-row input:not([value=""]):not([value="0"]) {
  background: #ecfeff;
  border-color: #67e8f9;
}
.pay-split-summary {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border-radius: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.pay-split-summary > div {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pay-split-summary span { font-size: 12px; color: #6a7a86; }
.pay-split-summary strong { font-size: 16px; font-weight: 700; color: #1a2d3a; }
.pay-status {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}
.pay-status.ok           { background: #ecfdf5; color: #065f46; }
.pay-status.outstanding  { background: #fee2e2; color: #991b1b; }
.pay-status.change       { background: #fef3c7; color: #92400e; }
.pay-status.empty        { background: #f1f5f9; color: #6a7a86; }
.pay-split-quickfill {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pay-split-quickfill button {
  font-size: 12px;
  padding: 5px 10px;
}

@media (max-width: 700px) {
  .pay-split-row { grid-template-columns: repeat(2, 1fr); }
  .invoice-item-row {
    grid-template-columns: 1.4fr 70px 70px 70px 70px 24px !important;
    font-size: 11px;
  }
}

/* =====================================================================
   REDESIGN 2026.06 — Maprang light shell (override layer, appended last)
   Derives every shade from --primary (= state.clinicColor) via color-mix,
   so each clinic's brand colour re-themes the whole UI. Delete this block
   to fully revert to the previous look.
   ===================================================================== */
:root{
  --acc: var(--primary);
  --acc-deep: color-mix(in srgb, var(--primary), #190f26 36%);
  --acc-bright: color-mix(in srgb, var(--primary), #ffffff 22%);
  --acc-50: color-mix(in srgb, var(--primary), #ffffff 94%);
  --acc-100: color-mix(in srgb, var(--primary), #ffffff 88%);
  --acc-200: color-mix(in srgb, var(--primary), #ffffff 78%);
  --gold:#c2a05b; --gold-100:#f4ecd9; --gold-deep:#9a7c3c; --gold-line:#e2cb93;
  --ink:#2b2230; --muted:#6b5e69;
  --line: color-mix(in srgb, var(--primary), #ffffff 90%);
  --line-2: color-mix(in srgb, var(--primary), #ffffff 84%);
  --surface:#ffffff;
  --surface-2: color-mix(in srgb, var(--primary), #f8f6fa 96%);
  --page: color-mix(in srgb, var(--primary), #fbf9fb 95%);
  --shadow: 0 2px 6px rgba(43,34,48,.05), 0 12px 28px -14px color-mix(in srgb, var(--primary), transparent 84%);
}
body{ font-family:"IBM Plex Sans Thai","Inter",ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif; background:var(--page); }

/* ---- light sidebar ---- */
.sidebar{ background:var(--surface); color:var(--ink); border-right:1px solid var(--line); padding:16px 14px; gap:14px; }
.brand strong{ color:var(--ink); }
.brand span, .user-card span{ color:var(--muted); }
.brand-mark{ border-radius:11px; background:linear-gradient(140deg,var(--acc-bright),var(--primary) 55%,var(--acc-deep)); box-shadow:0 0 0 1.5px var(--gold-line),0 4px 10px -3px color-mix(in srgb,var(--primary),transparent 55%); }
.nav-list{ gap:3px; }
.nav-item{ color:var(--muted); border-radius:11px; padding:9px 12px; font-weight:500; font-size:14px; }
.nav-item:hover{ background:var(--acc-50); color:var(--ink); }
.nav-item.active{ background:var(--acc-100); color:var(--primary); font-weight:600; }
.user-card{ border:1px solid var(--line); background:var(--acc-50); }
.user-card strong{ color:var(--ink); }
.role-switcher{ color:var(--muted); }
.role-switcher select{ background:#fff; color:var(--ink); border:1px solid var(--line); }
.status-dot{ background:#3f9a72; }
/* fix language toggle (was white-on-dark inline styles) */
.lang-toggle-wrap{ border-bottom:1px solid var(--line) !important; }
.lang-toggle-wrap > span{ color:var(--muted) !important; }
.lang-btn{ color:var(--muted) !important; border-color:var(--line) !important; background:#fff !important; }
.lang-btn:hover,.lang-btn.active{ background:var(--acc-100) !important; color:var(--primary) !important; border-color:var(--acc-200) !important; }

/* ---- modern cards + topbar ---- */
.metric-card,.panel,.lane,.receipt-preview{ border-radius:16px; box-shadow:var(--shadow); border-color:var(--line); }
.metric-card{ border-top:0; padding:18px; }
.metric-card strong{ color:var(--ink); }
.metric-card small{ color:var(--primary); }
.topbar h1{ font-weight:600; letter-spacing:.2px; }
.eyebrow{ color:var(--muted); }

/* ---- sidebar nav groups (added in index.html) ---- */
.nav-group{ display:grid; gap:3px; }
.nav-group + .nav-group{ margin-top:12px; }
.nav-group-label{ font-size:11px; font-weight:600; color:var(--muted); letter-spacing:.5px; padding:2px 10px 4px; opacity:.85; }
/* ---- sidebar bottom: system status + version ---- */
.sidebar-status{ background:var(--acc-50); border:1px solid var(--line); border-radius:11px; padding:11px 12px; font-size:12.5px; }
.sidebar-status .ss-title{ font-size:11px; font-weight:600; color:var(--muted); letter-spacing:.5px; margin-bottom:7px; }
.sidebar-status .ss-row{ display:flex; align-items:center; gap:8px; padding:2px 0; color:var(--ink); }
.sidebar-status .ss-row .d{ width:7px; height:7px; border-radius:50%; background:#3f9a72; flex:0 0 auto; }
.sidebar-status .ss-row .v{ margin-left:auto; color:var(--muted); font-size:11px; }
.sidebar-version{ display:flex; align-items:center; gap:6px; font-size:10.5px; color:color-mix(in srgb,var(--muted),#fff 30%); padding:8px 6px 0; letter-spacing:.3px; }
.sidebar-version .vd{ width:5px; height:5px; border-radius:50%; background:#3f9a72; flex:0 0 auto; }

/* ---- Phase 2 — Dashboard interior (clean cards, maprang/gold) ---- */
.metrics-grid{ gap:16px; margin-bottom:18px; }
.dashboard-grid{ gap:16px; }
.panel-head{ margin-bottom:14px; }
.panel-head h2{ font-size:16px; font-weight:700; color:var(--ink); margin:0; }
.panel-head .ghost-button{ color:var(--primary); font-weight:600; }
.appointment-row,.service-list div,.invoice-list div{ border-radius:12px; border-color:var(--line); padding:11px 13px; }
.appointment-row time{ color:var(--primary); }
.appointment-row[data-dashboard-appointment]:hover,.appointment-row.synced{ border-color:var(--acc-200); background:var(--acc-50); }
.queue-columns{ gap:12px; }
.queue-columns div{ background:var(--surface-2); border:1px solid var(--line); border-radius:12px; }
.queue-columns h3{ color:var(--muted); font-weight:700; font-size:12px; letter-spacing:.3px; margin-bottom:8px; }
.queue-columns p{ background:#fff; border:1px solid var(--line); border-radius:9px; }
.queue-columns [data-dashboard-queue-item]:hover{ border-color:var(--acc-200); background:var(--acc-50); }
.bar-chart span{ background:linear-gradient(180deg,var(--acc-bright),var(--primary)); border-radius:7px 7px 4px 4px; }
.bar-chart span:last-child{ background:linear-gradient(180deg,var(--gold),var(--gold-deep)); }
.dashboard-intake-strip{ border-radius:14px; border-color:var(--line); }
.dashboard-intake-badge,.booking-dashboard-badge{ background:var(--acc-100); color:var(--primary); }
.metric-card strong{ letter-spacing:-.3px; }
/* KPI icon chips (mockup-fidelity) */
.metric-card .mc-top{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:6px; }
.metric-card .mc-top span:first-child{ color:var(--muted); font-weight:500; }
.mc-ic{ width:34px; height:34px; border-radius:10px; display:grid; place-items:center; background:var(--acc-100); color:var(--primary); flex:0 0 auto; }
.mc-ic svg{ width:18px; height:18px; stroke-width:1.9; }
.mc-ic-gold{ background:var(--gold-100); color:var(--gold-deep); }

/* ============ Commercial simplification (declutter / progressive disclosure) ============ */
/* version now lives bottom-left of the sidebar → drop the redundant top-bar chip */
#appVersionChip{ display:none !important; }
/* hide internal-only dev tool from the commercial nav (view still reachable for admins) */
.nav-item[data-view="readiness"]{ display:none !important; }
/* ============ OPD warning banner — clean, modern, readable ============
   Colours (bg/text/cursor) + size class + FONT all come INLINE from each clinic's
   Settings (_applyOwbColors) — never override colour/background/font-size/font-
   family here (the 05d bug forced amber+14px and hid the staff's red/green +
   "ใหญ่มาก"). Every selectable font (OWB_FONTS) ships matched Thai+Latin glyphs so
   ไทย and อังกฤษ render at the SAME size = balanced. No pixel font, no hard retro
   shadow. Size stays from owb-size-* (xl = ใหญ่มาก = 31px). */
.opd-warning-banner{
  /* font-family is set INLINE per clinic (OWB_FONTS) — don't force it here */
  font-weight: 700 !important;
  background-image: none !important;              /* drop the gray dotted mesh → clean flat colour */
  border: 1px solid rgba(0,0,0,0.10) !important;
  border-radius: 12px !important;
  box-shadow: 0 4px 14px rgba(0,0,0,0.10) !important;   /* soft modern lift, no hard offset */
  text-shadow: none !important;
  letter-spacing: 0.005em !important;
  line-height: 1.4 !important;
}
.opd-warning-banner .owb-text{ white-space: normal; overflow-wrap: anywhere; }
.opd-warning-banner .owb-cursor{ display:inline !important; }
/* No size overrides → the clinic's choice maps to the original scale
   (sm16 / md20 / lg25 / xl31) so both scripts stay big + balanced. */

/* ============ Commercial polish — global components ============ */
:root{ --warn-100:#f8eede; --ok:#3f9a72; --ok-100:#e6f3ec; }
/* ── Buttons ──────────────────────────────────────────────── */
.icon-button,.primary-action,.ghost-button,.chip,.visit-card button,.settings-menu button{ border-radius:10px; }

/* primary-action: gradient base + lift on hover */
.primary-action{
  background:linear-gradient(135deg,var(--acc-bright),var(--primary));
  box-shadow:0 6px 16px -8px color-mix(in srgb,var(--primary),transparent 45%);
  font-weight:600;
  transition:transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}
.primary-action:hover{
  transform:translateY(-1px);
  box-shadow:0 8px 22px -6px color-mix(in srgb,var(--primary),transparent 35%);
  filter:brightness(1.06);
}
.primary-action:active{ transform:translateY(0); box-shadow:none; filter:brightness(0.97); }

/* ghost-button: subtle accent on hover */
.ghost-button{ color:var(--primary); border-color:var(--line-2); font-weight:600; transition:background 0.13s ease, border-color 0.13s ease; }
.ghost-button:hover{ background:var(--acc-50); border-color:var(--acc-200); }
.ghost-button:active{ background:var(--acc-100); }

/* icon-button */
.icon-button{ border-color:var(--line-2); color:var(--muted); transition:border-color 0.13s ease, color 0.13s ease, background 0.13s ease; }
.icon-button:hover{ border-color:var(--acc-200); color:var(--primary); background:var(--acc-50); }

/* tabs */
.tabs button{ font-weight:500; transition:background 0.13s ease, color 0.13s ease; }
.tabs button:hover:not(.active){ background:var(--acc-100); color:var(--primary); }
.tabs button.active{ background:var(--primary); color:#fff; }

/* delete/danger ghost */
.delete-row-button{ transition:background 0.13s ease, border-color 0.13s ease; }
.delete-row-button:active{ background:#fecaca !important; }

/* ── Table rows ──────────────────────────────────────────── */
.customer-row:hover{ border-color:var(--acc-200) !important; background:var(--acc-50) !important; }
.table-row:not(.head):hover{ border-color:var(--acc-200); background:var(--acc-50); }

/* ── Status indicators ──────────────────────────────────── */
.save-status{ color:var(--primary); }
.selected-customer-next-step{ border-color:var(--acc-200); color:var(--primary); background:var(--acc-50); font-weight:700; }

/* ── Timeline / cards ──────────────────────────────────── */
.timeline-item{ transition:box-shadow 0.14s ease; }
.timeline-item:hover{ box-shadow:0 4px 14px -4px color-mix(in srgb,var(--primary),transparent 72%); }
.drawer-event{ transition:box-shadow 0.14s ease; }
.drawer-event:hover{ box-shadow:0 3px 10px -3px color-mix(in srgb,var(--primary),transparent 75%); }

/* ── visit-card (kanban) ───────────────────────────────── */
.visit-card:hover{ border-color:var(--acc-200); box-shadow:0 4px 16px -6px color-mix(in srgb,var(--primary),transparent 68%); }

/* ── Utility: consistent border-radius for pills ─────── */
.badge,.status-badge{ border-radius:999px; }
.status-active{ color:var(--ok) !important; background:var(--ok-100) !important; }
.status-review{ background:#fef3c7; color:#92400e; }
.status-inactive{ background:var(--line); color:var(--muted); }
/* chips / tabs as soft pills */
.chip,.calendar-toolbar select{ border-radius:999px; border-color:var(--line-2); }
.chip.active{ background:var(--acc-100) !important; color:var(--primary) !important; border-color:var(--acc-200) !important; }
/* form controls — consistent rounded + maprang focus ring */
input,select,textarea{ border-radius:10px; }
input:focus,select:focus,textarea:focus{ outline:none; border-color:var(--acc-200); box-shadow:0 0 0 3px var(--acc-100); }
#branchSelector{ border-color:var(--line-2); border-radius:10px; }
.cloud-sync-badge{ border-radius:999px; }
/* modal */
.modal{ border-radius:18px; box-shadow:0 30px 70px -24px color-mix(in srgb,var(--primary),transparent 55%); }
.modal-backdrop{ backdrop-filter:blur(3px); }
/* tables */
.data-table{ border-radius:12px; overflow:hidden; border:1px solid var(--line); }
.data-table th{ background:var(--surface-2); color:var(--muted); font-weight:600; }
/* settings menu active */
.settings-menu button.active{ background:var(--acc-100); color:var(--primary); }
/* PWA install banner -> maprang (was hardcoded purple) */
.pwa-install-banner{ background:linear-gradient(135deg,var(--acc-100),var(--acc-50)) !important; border-color:var(--acc-200) !important; border-left-color:var(--primary) !important; box-shadow:none !important; }
.pwa-install-banner .pwa-install-text strong{ color:var(--acc-deep) !important; }
.pwa-install-banner .pwa-install-text span{ color:var(--primary) !important; }
.pwa-install-banner .pwa-install-actions .primary-action{ background:var(--primary) !important; }
/* backup reminder -> calm amber, no pulse (commercial) */
.backup-reminder-banner{ animation:none !important; background:var(--warn-100) !important; border:1px solid #f0d9a8 !important; box-shadow:none !important; border-radius:12px !important; }
/* declutter: hide dev/QA-only tools from the commercial UI (reachable in code if needed) */
[data-action="run-app-smoke-test"],
[data-action="run-quality-hardening-200"],
[data-action="audit-ui-buttons"],
[data-action="export-ui-button-audit"],
[data-action="reset-prototype-state"],
[data-action="export-prototype-state"],
[data-action="export-queue-movement-log"]{ display:none !important; }
/* OPD tabs as soft maprang pills */
.opd-tabs button{ border-radius:999px !important; font-weight:600; }
.opd-tabs button.active{ background:var(--acc-100) !important; color:var(--primary) !important; border-color:var(--acc-200) !important; }
/* hide dev-only fake-data generators (commercial) */
[data-action^="simulate-"]{ display:none !important; }
/* sidebar nav — Lucide line icons (replaced emoji); label moved to .lbl span so the bilingual swap doesn't wipe the icon */
.nav-item{ display:flex; align-items:center; gap:11px; }
.nav-item .ico{ width:20px; height:20px; display:inline-flex; align-items:center; justify-content:center; flex:0 0 auto; color:var(--muted); }
.nav-item .ico svg{ width:18px; height:18px; stroke-width:1.75; }
.nav-item .lbl{ flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.nav-item:hover .ico{ color:var(--ink); }
.nav-item.active .ico{ color:var(--primary); }
/* settings submenu — Lucide icons, NO colored left stripes (anti-pattern), clean maprang active (was dark) */
.settings-menu button{ display:flex; align-items:center; gap:10px; border:1px solid var(--line) !important; border-radius:10px !important; }
.settings-menu button .ico{ width:18px; height:18px; display:inline-flex; align-items:center; justify-content:center; flex:0 0 auto; color:var(--muted); }
.settings-menu button .ico svg{ width:17px; height:17px; stroke-width:1.75; }
.settings-menu button.active{ background:var(--acc-100) !important; color:var(--primary) !important; border-color:var(--acc-200) !important; transform:none !important; }
.settings-menu button.active .ico{ color:var(--primary); }
/* safeguard: clicks on icon/label pass through to the button (direct-target handlers) */
.nav-item .ico,.nav-item .lbl,.settings-menu button .ico,.settings-menu button .lbl{ pointer-events:none; }
/* kill the per-category coloured left stripe (::before anti-pattern) + neutralise per-category active tints (higher specificity) */
.settings-menu button[data-menu-cat]::before{ display:none !important; }
.settings-menu button[data-menu-cat]{ padding-left:12px !important; }
.settings-menu button.active[data-menu-cat]{ background:var(--acc-100) !important; color:var(--primary) !important; }

/* ============ OPD screen — bigger fonts (readability for counter/tablet) + maprang ============ */
.opd-action-center{
  background:var(--acc-50) !important;
  border-color:var(--acc-200) !important;
  padding:16px !important;
  gap:14px !important;
  border-radius:14px !important;
  /* layout: summary pinned left, hint+buttons in right column */
  grid-template-columns:220px minmax(0,1fr) !important;
}
.opd-action-summary{
  grid-row:1 / span 2 !important;
  align-self:start !important;
  padding:10px 14px 10px 0 !important;
  border-right:1px solid var(--acc-200) !important;
}
.opd-action-summary strong{ color:var(--primary) !important; font-size:1.1rem !important; line-height:1.3 !important; }
.opd-action-summary span,.opd-action-summary em{ font-size:13px !important; }
.opd-action-summary > span:first-child{ font-size:10px !important; font-weight:800 !important; text-transform:uppercase !important; letter-spacing:0.06em !important; opacity:0.65 !important; }
.opd-progress > span{ color:var(--primary) !important; font-size:12px !important; font-weight:900 !important; }
.opd-progress > strong{ height:8px !important; background:var(--acc-200) !important; }
.opd-progress i{ background:linear-gradient(90deg,var(--primary),var(--gold)) !important; }
.opd-steps-hint{
  grid-column:2 !important;
  font-size:13px !important;
  color:var(--primary) !important;
  background:var(--acc-100) !important;
  border-color:var(--acc-200) !important;
  padding:9px 13px !important;
  margin:0 !important;
}
.opd-action-buttons{
  grid-column:2 !important;
  grid-template-columns:repeat(3,minmax(0,1fr)) !important;
  gap:8px !important;
}
.opd-action-buttons button{ min-height:46px !important; }
.opd-action-buttons button[data-opd-step-button]{
  min-height:68px !important;
  font-size:13.5px !important;
  font-weight:700 !important;
  border-color:var(--acc-200) !important;
  border-radius:12px !important;
  border-width:1.5px !important;
  padding:8px 6px 7px !important;
}
.opd-action-buttons button[data-opd-step-button]::after{ font-size:11.5px !important; margin-top:4px !important; font-weight:800 !important; }
/* Step states */
.opd-action-buttons button.step-done{
  background:var(--primary) !important;
  border-color:var(--primary) !important;
  border-width:2px !important;
  color:#fff !important;
  box-shadow:0 3px 10px -2px color-mix(in srgb,var(--primary),transparent 48%) !important;
}
.opd-action-buttons button.step-done:hover{
  background:var(--acc-deep) !important;
  border-color:var(--acc-deep) !important;
  transform:translateY(-2px) !important;
  box-shadow:0 6px 16px -4px color-mix(in srgb,var(--primary),transparent 38%) !important;
}
.opd-action-buttons button.step-next{
  border-width:2px !important;
  border-color:#db2777 !important;
  color:#9d174d !important;
  background:#fff0f7 !important;
}
.opd-action-buttons button.step-next:hover{
  background:#fce7f3 !important;
  border-color:#be185d !important;
  transform:translateY(-2px) !important;
  box-shadow:0 5px 14px rgba(219,39,119,0.24) !important;
}
.opd-action-buttons button.step-waiting{
  border-color:var(--line) !important;
  color:var(--muted) !important;
  background:var(--surface) !important;
  opacity:0.7 !important;
}
.opd-action-buttons button.step-waiting:hover{
  transform:none !important;
  box-shadow:none !important;
  opacity:0.85 !important;
}
.opd-action-buttons button.step-blocked{
  border-width:2px !important;
  border-color:#fca5a5 !important;
  color:#b91c1c !important;
  background:#fff5f5 !important;
}
.opd-action-buttons button.step-blocked:hover{
  background:#fee2e2 !important;
  border-color:#f87171 !important;
  transform:translateY(-2px) !important;
  box-shadow:0 4px 12px rgba(185,28,28,0.2) !important;
}
/* OPD metadata + completion cards — bigger */
.opd-visit-meta-grid{ font-size:13.5px !important; }
.opd-visit-meta-grid strong,.opd-visit-meta-grid b{ font-size:15px !important; }
.opd-completion-grid{ gap:14px !important; }
.opd-completion-grid strong,.opd-completion-grid h4{ font-size:15.5px !important; }
.opd-completion-grid em,.opd-completion-grid p,.opd-completion-grid span{ font-size:13px !important; }

/* ---- Gallery: kind filter as chips (was dropdown) + show full slip (was cropped) ---- */
.gallery-kind-chips{ flex-basis:100%; display:flex; gap:8px; flex-wrap:wrap; }
.gallery-kind-chips .chip{ font-size:13px; min-height:34px; padding:0 14px; }
.gallery-grid img{ object-fit:contain !important; background:var(--surface-2); }

/* ============ Chat launcher menu (AI / ลูกค้า) + OmniDesk drawer ============
   Reuses the .ai-assistant-launcher orb (gradient/shine/drift). Clicking it now
   opens this choice menu; the orb morphs to ✕ via .menu-open. Menu is position:
   fixed and JS-anchored above the (draggable) launcher. */
.chat-menu{ position:fixed; z-index:26; display:flex; flex-direction:column; align-items:flex-end; gap:11px; pointer-events:none; }
.chat-opt{ pointer-events:none; opacity:0; transform:translateY(14px) scale(.85); transform-origin:bottom right;
  display:inline-flex; align-items:center; gap:11px; border:none; cursor:pointer; color:#fff; height:50px; padding:0 18px 0 8px;
  border-radius:999px; white-space:nowrap; position:relative; overflow:hidden; background-size:220% 220%; background-position:0% 50%;
  box-shadow:0 0 0 1px rgba(255,255,255,.22) inset, 0 10px 28px -6px rgba(139,92,246,.5), 0 3px 10px rgba(15,23,42,.16);
  transition:opacity .35s cubic-bezier(.34,1.56,.64,1), transform .45s cubic-bezier(.34,1.56,.64,1), background-position .4s; }
.chat-menu.show .chat-opt{ pointer-events:auto; opacity:1; transform:none; }
.chat-menu.show .chat-opt:nth-child(1){ transition-delay:.13s; }
.chat-menu.show .chat-opt:nth-child(2){ transition-delay:.05s; }
.chat-opt:hover{ transform:translateY(-2px); background-position:100% 50%; }
.chat-opt .copt-orb{ width:34px; height:34px; border-radius:50%; flex:none; display:grid; place-items:center; font-size:17px; background:rgba(255,255,255,.2); backdrop-filter:blur(4px); }
.chat-opt .copt-txt{ text-align:left; text-shadow:0 1px 2px rgba(0,0,0,.22); }
.chat-opt .copt-txt b{ display:block; font-size:14.5px; font-weight:600; line-height:1.15; }
.chat-opt .copt-txt small{ display:block; font-size:10.5px; opacity:.9; }
.chat-opt .copt-shine{ position:absolute; top:0; left:-60%; width:50%; height:100%; transform:skewX(-18deg); pointer-events:none;
  background:linear-gradient(100deg,transparent,rgba(255,255,255,0) 30%,rgba(255,255,255,.42) 50%,rgba(255,255,255,0) 70%,transparent);
  animation:ai-launcher-shine-sweep 5s ease-in-out infinite; }
.chat-opt-ai{ background-image:linear-gradient(115deg,#6366f1 0%,#8b5cf6 25%,#d946ef 50%,#f97316 80%,#fbbf24 100%); }
.chat-opt-cust{ background-image:linear-gradient(115deg,#0ea5e9 0%,#06b6d4 30%,#10b981 70%,#34d399 100%);
  box-shadow:0 0 0 1px rgba(255,255,255,.22) inset, 0 10px 28px -6px rgba(6,182,212,.5), 0 3px 10px rgba(15,23,42,.16); }
.chat-opt .copt-badge{ position:absolute; top:5px; right:8px; background:#c9a86a; color:#3a2c12; font-weight:700; font-size:10px;
  min-width:18px; height:18px; border-radius:999px; display:grid; place-items:center; padding:0 5px; border:2px solid #fff; }
/* launcher ↔ ✕ morph when the menu is open */
.ai-assistant-launcher .lx-x{ position:absolute; inset:0; display:grid; place-items:center; opacity:0; transform:rotate(-90deg) scale(.5);
  transition:opacity .25s, transform .4s cubic-bezier(.34,1.56,.64,1); pointer-events:none; }
.ai-assistant-launcher.menu-open .ai-launcher-orb{ opacity:0; transform:scale(.4); }
.ai-assistant-launcher.menu-open .lx-x{ opacity:1; transform:none; }
.ai-assistant-launcher.menu-open{ background-position:100% 50%; }
/* OmniDesk slide-in drawer */
.omnidesk-drawer{ position:fixed; inset:0; z-index:40; pointer-events:none; }
.omnidesk-drawer::before{ content:""; position:absolute; inset:0; background:rgba(44,34,51,.42); backdrop-filter:blur(3px); opacity:0; transition:opacity .4s; }
.omnidesk-drawer.show{ pointer-events:auto; }
.omnidesk-drawer.show::before{ opacity:1; }
.omnidesk-panel{ position:absolute; top:0; right:0; bottom:0; width:440px; max-width:100vw; background:#fff;
  box-shadow:-24px 0 60px rgba(44,34,51,.25); transform:translateX(105%); transition:transform .5s cubic-bezier(.34,1.56,.64,1);
  display:flex; flex-direction:column; }
.omnidesk-drawer.show .omnidesk-panel{ transform:none; }
.omnidesk-head{ padding:15px 18px; color:#fff; background:linear-gradient(120deg,#54306e,#6d3d8e 60%,#9159b4);
  display:flex; align-items:center; justify-content:space-between; gap:12px; }
.omnidesk-head b{ font-size:16px; font-weight:600; }
.omnidesk-head small{ display:block; font-size:11px; opacity:.85; }
.omnidesk-head .icon-button{ background:rgba(255,255,255,.18); color:#fff; border:none; }
.omnidesk-body{ flex:1; position:relative; background:#faf7fc; }
.omnidesk-body iframe{ width:100%; height:100%; border:0; display:block; }
.omnidesk-empty{ height:100%; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px;
  text-align:center; color:#8b7e96; padding:30px; font-size:34px; }
.omnidesk-empty b{ font-size:15px; color:#54306e; }
.omnidesk-empty span{ font-size:12.5px; line-height:1.6; }
/* expand / collapse — gives the embedded OmniDesk room (the narrow 440px squeezes
   its list+detail layout). Toggled by #omnideskExpand, remembered in localStorage. */
.omnidesk-head-actions{ display:flex; align-items:center; gap:8px; }
.omnidesk-head-actions .icon-button{ font-size:18px; line-height:1; }
.omnidesk-drawer.expanded .omnidesk-panel{ width:min(1040px, 94vw); }
@media (max-width:520px){ .omnidesk-panel, .omnidesk-drawer.expanded .omnidesk-panel{ width:100vw; } }

/* ══════════════════════════════════════════════════════════════════════════════
   200-POINT UI POLISH — v2026.06.08m
   Comprehensive pass: hover states, focus rings, transitions, spacing,
   typography, accessibility, empty states, animations.
   Uses !important where commercial block overrides are needed.
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── 1. SIDEBAR ──────────────────────────────────────────────────────────────── */

/* Left-bar indicator on active nav item */
.nav-item.active {
  position: relative;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  border-radius: 0 3px 3px 0;
  background: var(--primary, #6d3d8e);
}

/* Smooth nav transitions */
.nav-item {
  transition: background 0.14s ease, color 0.14s ease !important;
}

/* Nav keyboard focus */
.nav-item:focus-visible {
  outline: 2px solid rgba(255,255,255,0.4) !important;
  outline-offset: -2px !important;
}

/* Status dot — subtle ambient pulse */
@keyframes status-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.55); }
  50%       { box-shadow: 0 0 0 5px rgba(45, 212, 191, 0); }
}
.status-dot {
  animation: status-pulse 2.4s ease-in-out infinite;
}

/* Sidebar scrollbar hover */
.nav-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.5) !important;
}

/* ── 2. GLOBAL BUTTONS ────────────────────────────────────────────────────────── */

/* Disabled state */
.primary-action:disabled,
.ghost-button:disabled,
button:disabled {
  opacity: 0.45 !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
  filter: saturate(0.5);
}

/* primary-action active — keep subtle inset shadow */
.primary-action:active {
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.15) !important;
}

/* ghost-button active — tint */
.ghost-button:active {
  background: var(--acc-50, #f3e8ff) !important;
  transform: scale(0.98);
}

/* Chip transition */
.chip {
  transition: border-color 0.14s ease, color 0.14s ease, background 0.14s ease, transform 0.12s ease !important;
}
.chip:hover:not(.active):not(:disabled) {
  border-color: var(--primary, #6d3d8e) !important;
  color: var(--primary, #6d3d8e) !important;
  transform: translateY(-1px);
}

/* Icon button lift */
.icon-button:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08) !important;
}

/* ── 3. GLOBAL INPUTS / FORMS ─────────────────────────────────────────────────── */

/* Focus ring on all form inputs */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):focus,
select:focus,
textarea:focus {
  border-color: var(--primary, #6d3d8e) !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(109,61,142,0.1) !important;
}

/* Placeholder color */
input::placeholder,
textarea::placeholder,
select:invalid {
  color: #c4c9d4 !important;
}

/* Disabled inputs */
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  background: #f8fafc !important;
}

/* Resize textarea vertically only */
textarea {
  resize: vertical;
}

/* Search field focus */
.search-field:focus {
  border-color: var(--primary, #6d3d8e) !important;
  background: #faf5ff !important;
  box-shadow: 0 0 0 3px rgba(109,61,142,0.08) !important;
  outline: none !important;
}

/* ── 4. CUSTOMER LIST / TABLE ─────────────────────────────────────────────────── */

/* Table head — stronger visual separation */
.table-row.head {
  background: var(--surface-2, #f8f7fb) !important;
  font-weight: 700 !important;
  border-bottom: 2px solid var(--line, #e5e7eb) !important;
}

/* Customer row — selection feel */
.customer-row.selected,
.customer-row[aria-selected="true"] {
  background: var(--acc-50, #f3e8ff) !important;
  border-color: var(--primary, #6d3d8e) !important;
}

/* ── 5. METRIC CARDS ──────────────────────────────────────────────────────────── */
.metric-card {
  transition: transform 0.14s ease, box-shadow 0.14s ease !important;
  cursor: pointer;
}
.metric-card:hover {
  transform: translateY(-2px) !important;
  box-shadow: var(--shadow), 0 0 0 2px rgba(109,61,142,0.12) !important;
}

/* ── 6. VISIT / QUEUE CARDS ───────────────────────────────────────────────────── */
.visit-card {
  transition: opacity 0.18s, transform 0.18s, box-shadow 0.18s, border-color 0.14s !important;
}
.visit-card:hover:not(.dragging) {
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 14px rgba(0,0,0,0.09) !important;
  border-color: var(--acc-200, #d8b4fe) !important;
}
.visit-card.active {
  border-color: var(--primary, #6d3d8e) !important;
  box-shadow: 0 0 0 3px rgba(109,61,142,0.15) !important;
  background: var(--acc-50, #f3e8ff) !important;
}
.queue-card-remove {
  transition: background 0.12s, color 0.12s, border-color 0.12s !important;
}
.queue-assignment {
  transition: background 0.14s, color 0.14s !important;
}

/* Dashboard queue item hover (columns variant) */
.queue-columns [data-dashboard-queue-item]:hover {
  border-color: var(--acc-200, #d8b4fe) !important;
  background: var(--acc-50, #f3e8ff) !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(109,61,142,0.07) !important;
}

/* ── 7. APPOINTMENT / SERVICE / INVOICE ROWS ─────────────────────────────────── */
.appointment-row,
.service-list div,
.invoice-list div {
  transition: background 0.13s ease, border-color 0.13s ease, box-shadow 0.13s ease !important;
  cursor: pointer;
}
.appointment-row:hover:not(.head),
.service-list div:hover:not(.head),
.invoice-list div:hover:not(.head) {
  border-color: var(--acc-200, #d8b4fe) !important;
  background: var(--acc-50, #f3e8ff) !important;
}

/* Invoice total row — stronger visual */
.invoice-list .total {
  font-weight: 800 !important;
  border-top: 2px solid var(--line, #e5e7eb) !important;
  background: var(--surface-2, #f8f7fb) !important;
}

/* ── 8. OPD TABS ──────────────────────────────────────────────────────────────── */
.opd-tabs button {
  transition: background 0.13s, color 0.13s, border-color 0.13s !important;
}
.opd-tabs button:hover:not(.active) {
  background: #f3e8ff !important;
  color: var(--primary, #6d3d8e) !important;
  border-color: var(--acc-200, #d8b4fe) !important;
}

/* ── 9. CUSTOMER PROFILE TABS ─────────────────────────────────────────────────── */
.tabs button {
  transition: background 0.13s, color 0.13s !important;
  cursor: pointer;
}
.tabs button:hover:not(.active) {
  background: #e2e8f0 !important;
  color: var(--ink, #1e293b) !important;
}

/* Profile stats card hover */
.profile-stats > div {
  transition: box-shadow 0.14s, transform 0.14s !important;
  cursor: default;
}
.profile-stats > div:hover {
  box-shadow: 0 2px 10px rgba(0,0,0,0.07) !important;
  transform: translateY(-1px);
}

/* Consent status strip transitions */
.consent-status-strip div,
.consent-rule-list div {
  transition: border-color 0.15s, background 0.15s !important;
}

/* ── 10. OPD STEP BUTTONS ─────────────────────────────────────────────────────── */
/* Stronger pulse for step-next */
@keyframes step-next-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(236,72,153,0.0); }
  50%       { box-shadow: 0 0 0 5px rgba(236,72,153,0.22); }
}
[data-opd-step-button].step-next {
  animation: step-next-pulse 1.4s ease-in-out infinite !important;
}

/* Progress bar fill — more visible */
.opd-progress strong {
  background: var(--acc-50, #f3e8ff) !important;
}
.opd-progress i {
  background: linear-gradient(90deg, var(--primary, #6d3d8e), var(--acc-bright, #a855f7)) !important;
  min-width: 4px;
  transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

/* Progress text — more visible */
#opdProgressText {
  color: var(--primary, #6d3d8e) !important;
  font-weight: 700 !important;
  font-size: 13px !important;
}

/* ── 11. PANEL HEADS ──────────────────────────────────────────────────────────── */
.panel-head {
  flex-wrap: wrap !important;
  gap: 10px !important;
}
.panel-head.wide {
  flex-wrap: wrap !important;
  gap: 10px !important;
}

/* ── 12. BAR CHART ─────────────────────────────────────────────────────────────── */
.bar-chart span {
  transition: transform 0.15s ease, box-shadow 0.15s !important;
  cursor: pointer;
}
.bar-chart span:hover {
  transform: scaleY(1.04) !important;
  filter: brightness(1.1);
}
/* Today's bar — stronger glow */
.bar-chart span[data-today="1"],
.bar-chart span:last-child {
  box-shadow: 0 0 0 3px rgba(245,158,11,0.3), 0 6px 18px rgba(245,158,11,0.3) !important;
}

/* ── 13. EMPTY STATES ─────────────────────────────────────────────────────────── */
.lane.empty::before {
  content: "📭";
  display: block;
  font-size: 28px;
  margin-bottom: 6px;
  opacity: 0.5;
}
.lane:empty,
.empty-placeholder {
  min-height: 80px;
}

/* ── 14. TIMELINE DRAWER ──────────────────────────────────────────────────────── */
.drawer-panel {
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* ── 15. MODAL BACKDROPS ──────────────────────────────────────────────────────── */
.modal-overlay,
.ios-diagnostic-overlay,
.share-vial-modal,
.treatment-plan-modal {
  backdrop-filter: blur(3px) !important;
}

/* ── 16. STATUS PILLS ─────────────────────────────────────────────────────────── */
.status-pill {
  transition: background 0.16s, color 0.16s, border-color 0.16s !important;
}

/* ── 17. NOTIFICATION BADGE ──────────────────────────────────────────────────── */
.notification-button::after {
  box-shadow: 0 1px 4px rgba(0,0,0,0.18) !important;
}

/* ── 18. SCROLLBARS ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar-thumb:hover {
  background: rgba(109,61,142,0.3) !important;
}

/* ── 19. TYPOGRAPHY CONSISTENCY ───────────────────────────────────────────────── */
h1, h2, h3 {
  line-height: 1.25;
}
h3 {
  margin-bottom: 4px;
}
.panel-head h2,
.panel-head h3 {
  margin-bottom: 2px;
}

/* Muted text — ensure readability */
.muted,
.opd-card-row span {
  color: #546070 !important;
}

/* ── 20. RECEIPT PREVIEW ──────────────────────────────────────────────────────── */
.receipt-preview-outer {
  background: #dde3ee !important;
}

/* ── 21. PRINT — SIGNATURE LINE CLARITY ──────────────────────────────────────── */
@media print {
  .signature-grid span {
    display: inline-block;
    border-bottom: 1px solid #333;
    min-width: 120px;
  }
  .handwriting-lines > * {
    border-bottom: 1px solid #ccc;
  }
}

/* ── 22. OPAQUE FOCUS RING FOR INPUT WRAPPERS ─────────────────────────────────── */
input[type="search"]:focus-visible,
input[type="text"]:focus-visible,
input[type="number"]:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2.5px solid var(--primary, #6d3d8e) !important;
  outline-offset: 1px !important;
}

/* ── 23. AUDIT TRAIL / HISTORY LIST ROWS ─────────────────────────────────────── */
#opdAuditTrailList > div,
#opdHistoryList > div {
  transition: background 0.12s !important;
  border-radius: 6px;
  padding: 4px 8px;
}
#opdAuditTrailList > div:hover,
#opdHistoryList > div:hover {
  background: var(--surface-2, #f8f7fb) !important;
}

/* ── 24. VISIT SHEET IMPROVEMENTS ────────────────────────────────────────────── */
.visit-sheet-checks span {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  letter-spacing: 0.2px;
}
.mini-field-grid span {
  font-size: 9.5pt;
  font-weight: 700;
  color: #374151;
  border-top: 1.5px solid #9ca3af;
  padding-top: 3px;
}
.visit-sheet-critical .critical strong {
  color: #b91c1c !important;
  font-weight: 900 !important;
}

/* ── 25. OPD WORKLIST GRID ROWS ───────────────────────────────────────────────── */
.opd-worklist-grid div,
.opd-admin-decision div {
  transition: background 0.12s !important;
  border-radius: 8px;
  padding: 6px 8px;
}
.opd-worklist-grid div:hover,
.opd-admin-decision div:hover {
  background: var(--surface-2, #f8f7fb) !important;
}

/* ── 26. COMPLETION GRID STEP ITEMS ───────────────────────────────────────────── */
#opdCompletionGrid > div {
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s !important;
}
#opdCompletionGrid > div.done {
  box-shadow: 0 0 0 2px rgba(16,185,129,0.2) !important;
}
#opdCompletionGrid > div.active-step {
  box-shadow: 0 0 0 2px rgba(236,72,153,0.2) !important;
}

/* ── 27. PANEL PADDING CONSISTENCY ────────────────────────────────────────────── */
.opd-diagnosis-block,
.opd-admin-worklist,
.opd-complete-panel,
.opd-admin-decision {
  padding-bottom: 14px;
}

/* ── 28. DOCUMENT GUARD LIST BUTTONS ─────────────────────────────────────────── */
#opdDocumentGuardList button {
  transition: background 0.13s, border-color 0.13s, transform 0.12s !important;
}
#opdDocumentGuardList button:hover {
  transform: translateX(2px) !important;
}

/* ── 29. SAVE STATUS BADGE ────────────────────────────────────────────────────── */
.save-status {
  transition: color 0.2s, background 0.2s !important;
}

/* ── 30. GLOBAL TRANSITION ON STATUS-ACTIVE ────────────────────────────────────── */
.status-active {
  transition: background 0.2s, color 0.2s !important;
}

/* ── 31. QUEUE LANE DROP TARGET GLOW ─────────────────────────────────────────── */
.lane.drag-over {
  border-color: var(--primary, #6d3d8e) !important;
  background: var(--acc-50, #f3e8ff) !important;
  box-shadow: inset 0 0 0 2px var(--primary, #6d3d8e) !important;
}

/* ── 32. CUSTOMER ROW AVATAR INITIALS ─────────────────────────────────────────── */
.customer-avatar-initial,
.opd-active-photo-placeholder {
  font-weight: 700;
  letter-spacing: -0.5px;
  background: var(--acc-100, #e9d5ff) !important;
  color: var(--primary, #6d3d8e) !important;
}

/* End of 200-point polish block */

/* ── OPD progress bar ต้องอ่าน % ได้ด้วยตา ──────────────────────────
   ของเดิมรางถูก theme ทับเป็นม่วง (--acc-200) จนกลืนกับตัว fill —
   38% ก็ดูเหมือนเต็มหลอด. ราง = ม่วงจางเกือบขาว, ส่วนที่ทำแล้ว =
   ม่วงเข้ม gradient → เห็นทันทีว่า OPD คืบไปแค่ไหน ขาดอีกเท่าไหร่ */
.opd-progress > strong {
  background: #efeaf8 !important;
  border: 1px solid rgba(124, 58, 237, 0.18);
  height: 10px !important;
}
.opd-progress i {
  background: linear-gradient(90deg, var(--primary, #7c3aed), #cb2bb8) !important;
}
details.opd-action-center > summary .opd-progress > span { white-space: nowrap; }

/* ── opd-collapsible — panel ที่หุบได้ทั่วหน้า OPD (ไกด์/PDPA) ── */
details.opd-collapsible > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
details.opd-collapsible > summary::-webkit-details-marker { display: none; }
details.opd-collapsible > summary::marker { content: ""; }
details.opd-collapsible[open] > summary { margin-bottom: 6px; }
