/* ============================================================
   Dental Records — Clinical EMR design system
   Professional, dense, sidebar layout inspired by hospital software
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Steel / slate — the clinical palette */
  --steel-900: #1E2A38;
  --steel-800: #263547;
  --steel-700: #2F4159;
  --steel-600: #3D5470;
  --steel-500: #5A7290;
  --steel-400: #7E93AD;
  --steel-300: #A9B7C7;
  --steel-200: #CDD5DE;
  --steel-100: #E4E9EE;
  --steel-50:  #F4F6F8;
  --steel-25:  #FAFBFC;

  --ink: #14181D;
  --ink-soft: #4A5563;
  --ink-muted: #7A8595;
  --ink-faint: #A5AEBB;

  /* Accents — used sparingly */
  --accent: #14708C;          /* teal, but muted and steely */
  --accent-dark: #0A5A72;
  --accent-wash: #E6F0F3;

  --alert-red: #B3382E;
  --alert-red-wash: #FBEEEC;
  --alert-red-strong: #8A2A22;

  --amber: #A47409;
  --amber-wash: #FAF1D9;

  --ok: #1E7A4C;
  --ok-wash: #E5F1EA;

  /* Structural */
  --sidebar-w: 220px;
  --r-sm: 2px;
  --r: 4px;
  --r-md: 6px;
  --border: 1px solid var(--steel-200);
  --border-strong: 1px solid var(--steel-300);
  --shadow-1: 0 1px 2px rgba(30, 42, 56, 0.05);
  --shadow-2: 0 4px 12px rgba(30, 42, 56, 0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--steel-50);
  color: var(--ink);
  font-family: "Inter", -apple-system, "Segoe UI", system-ui, sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  font-feature-settings: "cv11", "ss01", "tnum";
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================ SIDEBAR LAYOUT */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--steel-900);
  color: var(--steel-200);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  padding: 18px 20px;
  font-size: 15px;
  font-weight: 600;
  color: white;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--steel-800);
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.sidebar .brand::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 20px;
  background: var(--accent);
  border-radius: 1px;
}
.sidebar .brand:hover { text-decoration: none; color: white; }

.sidebar-section {
  padding: 14px 12px 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--steel-500);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar nav {
  flex: 1;
  padding: 8px 8px;
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: var(--steel-200);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--r);
  margin-bottom: 1px;
  text-decoration: none;
  transition: background 0.1s;
}
.sidebar nav a:hover {
  background: var(--steel-800);
  color: white;
  text-decoration: none;
}
.sidebar nav a.active {
  background: var(--accent);
  color: white;
}

.sidebar .user-box {
  padding: 14px 16px;
  border-top: 1px solid var(--steel-800);
  font-size: 12px;
}
.sidebar .user-box .name {
  color: white;
  font-weight: 500;
  margin-bottom: 2px;
}
.sidebar .user-box .role {
  color: var(--steel-400);
  font-size: 11px;
  margin-bottom: 8px;
}
.sidebar .user-box a {
  display: block;
  color: var(--steel-300);
  font-size: 12px;
  padding: 3px 0;
  text-decoration: none;
}
.sidebar .user-box a:hover { color: white; text-decoration: none; }

.main {
  flex: 1;
  min-width: 0;
  background: var(--steel-50);
}

.burger {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 30;
  background: var(--steel-900);
  color: white;
  border: none;
  border-radius: var(--r);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 16px;
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 25;
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: var(--shadow-2);
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding-top: 48px; }
  .burger { display: block; }
}

/* ============================================================ PAGE */
.page {
  padding: 24px 28px 60px;
  max-width: 1280px;
}
.page.narrow { max-width: 720px; }

.page-header {
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: var(--border);
}
.page-header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin-bottom: 3px;
}
.page-header .sub {
  font-size: 13px;
  color: var(--ink-muted);
}

/* ============================================================ FLASH */
.flash {
  padding: 10px 14px;
  border-radius: var(--r);
  margin-bottom: 16px;
  font-size: 13px;
  background: var(--ok-wash);
  color: #124E36;
  border-left: 3px solid var(--ok);
}
.flash.error {
  background: var(--alert-red-wash);
  color: var(--alert-red-strong);
  border-left-color: var(--alert-red);
}

/* ============================================================ BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--r);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s;
  line-height: 1.3;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); text-decoration: none; color: white; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-wash); color: var(--accent-dark); }
.btn.quiet { background: white; border-color: var(--steel-300); color: var(--ink-soft); }
.btn.quiet:hover { background: var(--steel-50); border-color: var(--steel-500); color: var(--ink); }
.btn.danger { background: var(--alert-red); border-color: var(--alert-red); }
.btn.danger:hover { background: var(--alert-red-strong); border-color: var(--alert-red-strong); }
.btn.sm { font-size: 12px; padding: 4px 9px; }
.btn.xs { font-size: 11px; padding: 3px 7px; }
.btn.lg { font-size: 14px; padding: 9px 18px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================================ FORMS */
label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 4px;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
input:not([type]), input[type=text], input[type=search], input[type=password], input[type=date],
input[type=email], input[type=tel], input[type=number], select, textarea {
  font-family: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--steel-300);
  border-radius: var(--r);
  background: white;
  color: var(--ink);
  width: 100%;
  transition: border-color 0.1s, box-shadow 0.1s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(20, 112, 140, 0.15);
}
textarea { resize: vertical; min-height: 60px; font-family: inherit; }
.field { margin-bottom: 12px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.triple { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 12px; }
@media (max-width: 640px) {
  .pair, .triple { grid-template-columns: 1fr; }
}
.hint { font-size: 11px; color: var(--ink-muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

/* ============================================================ CARDS */
.card {
  background: white;
  border: var(--border);
  border-radius: var(--r-md);
  padding: 18px 20px;
}
.card h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
  letter-spacing: -0.005em;
  padding-bottom: 8px;
  border-bottom: var(--border);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}
.card h1 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

/* ============================================================ LOGIN */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--steel-100);
  padding: 20px;
}
.login {
  max-width: 380px;
  width: 100%;
  background: white;
  border: var(--border);
  border-radius: var(--r-md);
  padding: 32px 28px;
  box-shadow: var(--shadow-1);
}
.login .brand-lg {
  text-align: center;
  margin-bottom: 26px;
}
.login .brand-lg .mark {
  display: inline-block;
  width: 6px;
  height: 22px;
  background: var(--accent);
  border-radius: 1px;
  margin-right: 8px;
  vertical-align: -4px;
}
.login h1 {
  display: inline;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.login .sub {
  text-align: center;
  color: var(--ink-muted);
  font-size: 12px;
  margin-top: 4px;
  margin-bottom: 24px;
}

/* ============================================================ SEARCH / HOME */
.searchbar {
  display: flex;
  gap: 8px;
  max-width: 620px;
  margin-bottom: 20px;
}
.searchbar input {
  font-size: 14px;
  padding: 9px 12px;
  height: 38px;
}
.searchbar .btn { height: 38px; padding: 0 18px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
@media (max-width: 900px) { .stat-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .stat-grid { grid-template-columns: 1fr; } }

.stat {
  background: white;
  border: var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
}
.stat .k {
  font-size: 10px;
  color: var(--ink-muted);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.stat .v {
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat .foot {
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 4px;
}
.stat .upcoming-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.stat .upcoming-list a {
  display: flex;
  justify-content: space-between;
  padding: 5px 8px;
  background: var(--steel-50);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--ink);
  text-decoration: none;
}
.stat .upcoming-list a:hover { background: var(--steel-100); text-decoration: none; }
.stat .upcoming-list .when {
  color: var(--accent);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ============================================================ DATA TABLES */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: white;
  border: var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
table.data th, table.data td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: var(--border);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--steel-25); }
table.data thead th {
  background: var(--steel-50);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: var(--border-strong);
}

/* Search results table */
table.results {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: white;
  border: var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
table.results th, table.results td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: var(--border);
}
table.results thead th {
  background: var(--steel-50);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: var(--border-strong);
}
table.results tr { cursor: pointer; }
table.results tbody tr:hover { background: var(--accent-wash); }
table.results tr:last-child td { border-bottom: none; }
table.results .fn {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-weight: 500;
  color: var(--accent);
  font-size: 12px;
}
table.results .phone {
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  font-size: 12.5px;
}
table.results .badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* ============================================================ PILLS / BADGES */
.pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 10.5px;
  font-weight: 500;
  background: var(--steel-100);
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}
.pill.teal { background: var(--accent-wash); color: var(--accent-dark); }
.pill.amber { background: var(--amber-wash); color: var(--amber); }
.pill.red { background: var(--alert-red-wash); color: var(--alert-red); }
.pill.green { background: var(--ok-wash); color: var(--ok); }

.role-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.role-badge.admin { background: #E9DFF5; color: #55317F; }
.role-badge.doctor { background: var(--accent-wash); color: var(--accent-dark); }
.role-badge.staff { background: var(--steel-100); color: var(--ink-soft); }

/* ============================================================ EMPTY STATE */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-muted);
  background: white;
  border: var(--border);
  border-radius: var(--r-md);
  border-style: dashed;
}
.empty strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}

.count {
  font-size: 12px;
  color: var(--ink-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

/* ============================================================ FILTER BAR */
.filter-bar {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: white;
  border: var(--border);
  border-radius: var(--r-md);
  margin-bottom: 14px;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-group label {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0;
}
.filter-group select {
  width: auto;
  min-width: 140px;
  font-size: 13px;
  padding: 6px 10px;
}
.filter-check {
  justify-content: center;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  padding-bottom: 6px;
}
.checkbox-label input[type=checkbox] {
  width: auto;
  accent-color: var(--accent);
  cursor: pointer;
}
@media (max-width: 720px) {
  .filter-bar { gap: 10px; }
  .filter-group { flex: 1; min-width: 45%; }
  .filter-group select { width: 100%; min-width: 0; }
}

/* ============================================================ PATIENT BANNER (persistent identity strip) */
.patient-banner {
  background: white;
  border: var(--border);
  border-radius: var(--r-md);
  padding: 14px 18px;
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}
.patient-banner .identity {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  min-width: 0;
}
.patient-banner .file-num {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--ink-muted);
  padding: 3px 8px;
  background: var(--steel-100);
  border-radius: var(--r-sm);
  font-weight: 500;
}
.patient-banner .name {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.patient-banner .id-strip {
  display: flex;
  gap: 14px;
  color: var(--ink-muted);
  font-size: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.patient-banner .id-strip .label {
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-right: 3px;
}
.patient-banner .id-strip strong {
  color: var(--ink);
  font-weight: 500;
}
.patient-banner .actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.patient-banner .meta-foot {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--ink-faint);
  padding-top: 8px;
  border-top: var(--border);
  margin-top: 4px;
}

/* Medical alerts — sit right under banner */
.alerts-strip {
  background: white;
  border: var(--border);
  border-radius: var(--r-md);
  padding: 10px 16px;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.alerts-strip:empty { display: none; }
.alerts-strip .alerts-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-right: 8px;
}
.alert-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
}
.alert-badge.allergy {
  background: var(--alert-red-wash);
  color: var(--alert-red);
  border-color: #EBC5C1;
}
.alert-badge.condition {
  background: var(--amber-wash);
  color: var(--amber);
  border-color: #EDDBA6;
}
.alert-badge.medication {
  background: var(--accent-wash);
  color: var(--accent-dark);
  border-color: #C2DAE0;
}

/* Next visit strip */
.next-visit {
  padding: 10px 14px;
  background: var(--accent-wash);
  border: 1px solid #C2DAE0;
  border-radius: var(--r-md);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.next-visit .label {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.next-visit .when {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
}
.next-visit .rel {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
  margin-left: 6px;
}
.next-visit .note {
  color: var(--ink-soft);
  font-size: 13px;
}

/* ============================================================ PATIENT TABS */
.tabs {
  display: flex;
  gap: 0;
  background: white;
  border: var(--border);
  border-radius: var(--r-md) var(--r-md) 0 0;
  border-bottom: none;
  overflow-x: auto;
}
.tab {
  background: none;
  border: none;
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.1s;
}
.tab:hover { color: var(--ink); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab .count-badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-left: 6px;
  background: var(--steel-100);
  color: var(--ink-muted);
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  vertical-align: 1px;
}
.tab.active .count-badge { background: var(--accent-wash); color: var(--accent-dark); }

.tab-panel {
  background: white;
  border: var(--border);
  border-top: none;
  border-radius: 0 0 var(--r-md) var(--r-md);
  padding: 18px 20px;
}

/* ============================================================ TREATMENT TIMELINE */
.tx-add-form {
  background: var(--steel-25);
  border: 1px dashed var(--steel-300);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 18px;
}
.tx-add-form summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--accent);
  font-size: 13px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tx-add-form summary::before {
  content: "＋";
  color: var(--accent);
  font-weight: 600;
}
.tx-add-form[open] summary::before { content: "−"; }
.tx-add-form[open] summary { margin-bottom: 14px; padding-bottom: 10px; border-bottom: var(--border); }

.lab-toggle {
  margin: 10px 0;
  padding: 9px 12px;
  background: var(--amber-wash);
  border-radius: var(--r);
  font-size: 12px;
}
.lab-toggle label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--amber);
  margin: 0;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}
.lab-toggle input[type=checkbox] { width: auto; accent-color: var(--amber); }

/* Treatments as compact table rows */
table.tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  background: white;
}
table.tx-table th, table.tx-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: var(--border);
  vertical-align: top;
}
table.tx-table thead th {
  background: var(--steel-50);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: var(--border-strong);
}
table.tx-table tr:last-child td { border-bottom: none; }
table.tx-table .date {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}
table.tx-table .teeth {
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  color: var(--ink-soft);
  background: var(--steel-50);
  padding: 1px 6px;
  border-radius: var(--r-sm);
  display: inline-block;
}
table.tx-table .type {
  font-weight: 500;
  color: var(--ink);
}
table.tx-table .doctor {
  color: var(--ink-soft);
  font-size: 12px;
}
table.tx-table .branch {
  color: var(--ink-muted);
  font-size: 11px;
  display: block;
}
table.tx-table .notes {
  color: var(--ink-soft);
  font-size: 12px;
  max-width: 380px;
}
table.tx-table .lab-flag {
  display: inline-block;
  padding: 1px 6px;
  background: var(--amber-wash);
  color: var(--amber);
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 3px;
}
table.tx-table .lab-detail {
  display: block;
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 2px;
}
table.tx-table .tx-actions {
  white-space: nowrap;
  text-align: right;
}
table.tx-table .tx-actions a, table.tx-table .tx-actions button {
  font-size: 11px;
  color: var(--ink-muted);
  background: none;
  border: none;
  padding: 2px 6px;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
table.tx-table .tx-actions a:hover { color: var(--accent); text-decoration: underline; }
table.tx-table .tx-actions button:hover { color: var(--alert-red); text-decoration: underline; }
table.tx-table .lab-status-form select {
  width: auto;
  font-size: 11px;
  padding: 2px 6px;
}

/* ============================================================ TREATMENT PLAN */
.plan-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.plan-item {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 10px 14px;
  border: var(--border);
  border-radius: var(--r);
  background: white;
  border-left-width: 3px;
}
.plan-item.plan-urgent { border-left-color: var(--alert-red); }
.plan-item.plan-recommended { border-left-color: var(--accent); }
.plan-item.plan-optional { border-left-color: var(--steel-300); }
.plan-priority {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.plan-item.plan-urgent .plan-priority { color: var(--alert-red); }
.plan-item.plan-recommended .plan-priority { color: var(--accent); }
.plan-item.plan-optional .plan-priority { color: var(--ink-muted); }
.plan-type {
  font-weight: 500;
  font-size: 13.5px;
  color: var(--ink);
}
.plan-notes {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.plan-meta {
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 3px;
}
.plan-actions { display: flex; gap: 6px; }

/* ============================================================ FILE GRID */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.doc {
  border: var(--border);
  border-radius: var(--r);
  background: white;
  overflow: hidden;
  position: relative;
  transition: border-color 0.1s;
}
.doc:hover { border-color: var(--accent); }
.doc.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-wash); }
.doc .thumb {
  display: block;
  height: 96px;
  background: var(--steel-50);
  overflow: hidden;
  text-decoration: none;
}
.doc .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc .pdfmark {
  height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--alert-red-wash);
  color: var(--alert-red);
  font-weight: 700;
}
.doc .pdfmark .lbl { font-size: 18px; letter-spacing: 0.03em; }
.doc .pdfmark .ext { font-size: 9px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }
.doc .meta {
  padding: 7px 9px;
  border-top: var(--border);
  font-size: 11px;
  color: var(--ink-muted);
}
.doc .meta .fname {
  display: block;
  color: var(--ink);
  font-size: 11.5px;
  word-break: break-word;
  margin-bottom: 3px;
  font-weight: 500;
  line-height: 1.3;
}
.doc .meta .who {
  font-size: 10.5px;
  color: var(--ink-muted);
  margin-bottom: 2px;
}
.doc .meta .who .branch { color: var(--accent); }
.doc .pick {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  z-index: 2;
}
.del-link {
  background: none;
  border: none;
  color: var(--alert-red);
  cursor: pointer;
  font-size: 10.5px;
  padding: 0;
  font-family: inherit;
  text-decoration: none;
}
.del-link:hover { text-decoration: underline; }
.del-link.disabled {
  color: var(--steel-300);
  cursor: not-allowed;
  text-decoration: line-through;
}

/* Upload zone */
.upload-zone {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--steel-25);
  border: 1px dashed var(--steel-300);
  border-radius: var(--r);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.upload-zone .lbl {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.upload-zone form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex: 1;
  flex-wrap: wrap;
}
.upload-zone input[type=file] { font-size: 12px; flex: 1; min-width: 160px; }

.merge-tray {
  position: sticky;
  bottom: 10px;
  margin-top: 16px;
  background: var(--steel-900);
  color: white;
  border-radius: var(--r-md);
  padding: 10px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: var(--shadow-2);
  font-size: 13px;
}
.merge-tray .count-pill {
  background: var(--accent);
  color: white;
  padding: 2px 9px;
  border-radius: 3px;
  font-weight: 600;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.merge-tray label { color: var(--steel-300); margin: 0; font-weight: 400; text-transform: none; letter-spacing: 0; }
.merge-tray select {
  width: auto;
  background: var(--steel-800);
  color: white;
  border-color: var(--steel-700);
  font-size: 12px;
  padding: 4px 8px;
}
.merge-tray select option { color: var(--ink); background: white; }
.merge-tray .btn { background: white; color: var(--steel-900); border-color: white; }
.merge-tray .btn:hover { background: var(--steel-100); color: var(--steel-900); }
.merge-tray .spacer { flex: 1; }

/* Import guide */
table.map {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0 18px;
  font-size: 12px;
  background: white;
  border: var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
table.map th, table.map td { padding: 7px 12px; border-bottom: var(--border); text-align: left; }
table.map tr:last-child td { border-bottom: none; }
table.map th {
  background: var(--steel-50);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
table.map td .aliases {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--ink-muted);
}

/* Branches / lists page */
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border: var(--border);
  border-radius: var(--r);
  margin-bottom: 3px;
  background: white;
  font-size: 13px;
}
.list-row form { display: flex; gap: 6px; align-items: center; }

/* Scanner modal */
.scan-modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(30, 42, 56, 0.94);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 20px;
}
.scan-modal video { max-width: 100%; max-height: 60vh; border-radius: var(--r-md); }
.scan-modal .controls { display: flex; gap: 12px; margin-top: 18px; }
.scan-modal .controls .btn { font-size: 14px; padding: 10px 20px; border-radius: 4px; }
.scan-modal .status { color: rgba(255,255,255,0.7); font-size: 12px; margin-top: 10px; }

/* Small helpers */
.text-muted { color: var(--ink-muted); }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }

/* ============================================================ LAB BOARD / TABS */
.lab-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.lab-tab {
  padding: 8px 14px;
  background: white;
  border: var(--border);
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.lab-tab:hover { border-color: var(--accent); color: var(--ink); text-decoration: none; }
.lab-tab.active { background: var(--accent); color: white; border-color: var(--accent); }
.lab-tab .count-badge {
  min-width: 18px; padding: 1px 6px; border-radius: 10px;
  background: var(--steel-100); color: var(--ink-muted);
  font-size: 10px; font-weight: 600; text-align: center;
}
.lab-tab.active .count-badge { background: rgba(255,255,255,0.25); color: white; }

.lab-ready-banner {
  background: var(--ok-wash);
  color: var(--ok);
  border: 1px solid #B4DCC4;
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 14px;
}

.lab-list { display: flex; flex-direction: column; gap: 8px; }
.lab-case {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 16px;
  background: white;
  border: var(--border);
  border-radius: var(--r-md);
  border-left-width: 3px;
  flex-wrap: wrap;
}
.lab-case.lab-sent { border-left-color: var(--amber); }
.lab-case.lab-progress { border-left-color: #185FA5; }
.lab-case.lab-ready { border-left-color: var(--ok); }
.lab-case.lab-delivered { border-left-color: var(--steel-300); }
.lab-case-main { flex: 1; min-width: 200px; }
.lab-case-title { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.lab-case-title .teeth {
  font-family: "JetBrains Mono", monospace; font-size: 11.5px;
  color: var(--ink-soft); background: var(--steel-50);
  padding: 1px 6px; border-radius: var(--r-sm); margin-left: 6px;
}
.lab-case-meta { font-size: 12px; color: var(--ink-muted); }
.lab-case-notes { font-size: 12.5px; color: var(--ink-soft); margin-top: 5px; }
.lab-case-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

/* ============================================================ SUMMARY CARDS */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
@media (max-width: 900px) { .summary-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .summary-grid { grid-template-columns: 1fr; } }
.summary-card {
  background: white;
  border: var(--border);
  border-radius: var(--r-md);
  padding: 20px 18px;
  text-align: center;
}
.summary-card .v {
  font-size: 32px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.summary-card .k {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 8px;
  font-weight: 500;
}

/* ============================================================ ASSESSMENT TOOLS */
.cdi-domain { margin-bottom: 18px; background: white; border: var(--border); border-radius: var(--r-md); overflow: hidden; }
.cdi-domain-head {
  background: var(--steel-800); color: white; padding: 9px 14px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
}
.cdi-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cdi-table th { background: var(--steel-50); text-align: left; padding: 7px 10px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-muted); border-bottom: 1px solid var(--steel-200); }
.cdi-table td { padding: 8px 10px; border-bottom: 1px solid var(--steel-100); vertical-align: top; }
.cdi-table tr:last-child td { border-bottom: none; }
.crit-tag { display:inline-block; background:var(--gold,#C4A570); color:#5a4a00; font-size:9px; font-weight:700; padding:1px 4px; border-radius:2px; margin-top:2px; }
.score-sel { width: auto; min-width: 90px; font-size: 12px; padding: 4px 8px; }

.checklist-edit { width: 100%; border-collapse: collapse; font-size: 13px; background: white; border: var(--border); }
.checklist-edit th { background: var(--steel-800); color: white; padding: 8px 8px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; text-align: left; }
.checklist-edit td { padding: 4px 6px; border-bottom: 1px solid var(--steel-100); }
.checklist-edit input, .checklist-edit select { width: 100%; font-size: 12px; padding: 5px 7px; }
.checklist-edit .rownum { text-align: center; color: var(--ink-muted); font-size: 12px; }
.checklist-edit .delrow { background: none; border: none; color: var(--alert-red); cursor: pointer; font-size: 13px; padding: 2px 5px; }
.checklist-edit .delrow:hover { background: var(--alert-red-wash); border-radius: 3px; }
.ar { unicode-bidi: plaintext; }

/* ============================================================ PERMISSION GRID */
.perm-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
}
@media (max-width: 640px) { .perm-grid { grid-template-columns: 1fr; } }
.perm-check {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  background: var(--steel-25);
  border: var(--border);
  border-radius: var(--r);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  margin: 0;
}
.perm-check:hover { border-color: var(--accent); }
.perm-check input[type=checkbox] { width: auto; accent-color: var(--accent); cursor: pointer; }
.perm-check:has(input:checked) { background: var(--accent-wash); border-color: var(--accent); }

/* ============================================================ SCANNER v2 */
.sc2 {
  position: fixed; inset: 0; z-index: 70; background: #0c1116;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sc2-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); flex: 0 0 auto;
}
.sc2-title { color: #fff; font-weight: 600; font-size: 15px; }
.sc2-x { background: rgba(255,255,255,0.14); color: #fff; border: none; width: 34px; height: 34px; border-radius: 50%; font-size: 16px; cursor: pointer; }
.sc2-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: auto; padding: 10px; }
.sc2-stage { flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; min-height: 0; }
.sc2-stage video, .sc2-stage canvas { max-width: 100%; max-height: 100%; border-radius: 8px; display: block; }
.sc2-enh canvas { background: #fff; }
.sc2-adjust { position: relative; display: inline-block; max-width: 100%; }
.sc2-adjust canvas { display: block; border-radius: 6px; max-width: 100%; }
.sc2-adjust svg { position: absolute; top: 0; left: 0; touch-action: none; }
.sc2-handle { fill: #fff; stroke: #25D366; stroke-width: 3; cursor: grab; }
.sc2-handle:active { cursor: grabbing; }
.sc2-filters { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.sc2-f { background: rgba(255,255,255,0.1); color: #cfd8e2; border: 1px solid rgba(255,255,255,0.15); padding: 8px 15px; border-radius: 100px; font-size: 13px; cursor: pointer; font-family: inherit; }
.sc2-f.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.sc2-review { width: 100%; max-width: 620px; }
.sc2-thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.sc2-thumb { position: relative; }
.sc2-thumb img { height: 96px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.2); display: block; }
.sc2-thumb button { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; background: var(--alert-red); color: #fff; border: none; border-radius: 50%; font-size: 12px; cursor: pointer; }
.sc2-ocr { display: flex; align-items: center; gap: 8px; color: #cfd8e2; font-size: 13.5px; text-transform: none; letter-spacing: 0; font-weight: 400; margin: 0; }
.sc2-ocr input { width: auto; accent-color: var(--accent); }
.sc2-status { color: rgba(255,255,255,0.72); font-size: 12.5px; text-align: center; padding: 6px 16px; min-height: 16px; flex: 0 0 auto; }
.sc2-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255,255,255,0.08); flex: 0 0 auto;
}
.sc2-bar .btn { font-size: 14px; padding: 12px 20px; flex: 0 0 auto; }
.sc2-bar .btn.quiet { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.2); color: #fff; }
.sc2-bar .btn.ghost { background: transparent; border-color: rgba(255,255,255,0.35); color: #fff; }
.sc2-bar .btn:not(.quiet):not(.ghost) { flex: 1; justify-content: center; max-width: 260px; margin: 0 auto; }
.sc2-shutter {
  width: 64px; height: 64px; border-radius: 50%; background: #fff !important; border: 4px solid rgba(255,255,255,0.4) !important;
  flex: 0 0 auto; padding: 0 !important;
}
.sc2-shutter:disabled { opacity: 0.5; }

/* Language switch in the sidebar corner */
.lang-toggle { display: flex; gap: 6px; margin: 4px 0 10px; }
.lang-toggle a {
  flex: 1; text-align: center; padding: 6px 0; border-radius: 6px; font-size: 13px; font-weight: 600;
  background: rgba(255,255,255,0.07); color: var(--steel-200); text-decoration: none; line-height: 1.4;
}
.lang-toggle a.on { background: var(--accent, #14708c); color: #fff; }
/* Language switch on the sign-in page */
.login-lang { position: fixed; top: 14px; inset-inline-end: 16px; display: flex; gap: 6px; z-index: 5; }
.login-lang a { padding: 6px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; text-decoration: none;
  background: #fff; color: var(--ink-muted); border: var(--border); }
.login-lang a.on { background: var(--accent, #14708c); color: #fff; border-color: transparent; }

/* ============================================================
   APPOINTMENTS & VISITS
   One colour per status, used the same way everywhere:
   schedule blocks, pills, the status strip and the visit history.
   ============================================================ */
.st-booked    { --c: var(--steel-500); --w: var(--steel-100); }
.st-confirmed { --c: var(--accent);    --w: var(--accent-wash); }
.st-arrived   { --c: var(--amber);     --w: var(--amber-wash); }
.st-withdoc   { --c: #185FA5;          --w: #E6F1FB; }
.st-completed { --c: var(--ok);        --w: var(--ok-wash); }
.st-noshow    { --c: var(--alert-red); --w: var(--alert-red-wash); }
.st-cancelled { --c: var(--ink-faint); --w: var(--steel-50); }
:root { --st-arrived: var(--amber); }

.page.wide { max-width: none; }
input[type=time] {
  font-family: inherit; font-size: 13px; padding: 7px 10px; width: 100%;
  border: 1px solid var(--steel-300); border-radius: var(--r); background: white; color: var(--ink);
}

.appt-pill {
  display: inline-block; padding: 2px 9px; border-radius: 10px;
  font-size: 11.5px; font-weight: 600; line-height: 1.5; white-space: nowrap;
  background: var(--w); color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 25%, transparent);
}
.appt-pill.lg { font-size: 13px; padding: 4px 12px; }
.appt-alert {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--alert-red); color: white; font-size: 10px; font-weight: 700; line-height: 1;
}

/* ---- Day schedule: header and toolbar ---- */
.sched-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.sched-header .sub .mono { font-size: 12.5px; }
.today-tag { color: var(--accent); font-weight: 600; }
.sched-cta { display: flex; gap: 8px; }
.sched-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.day-nav { display: flex; align-items: center; gap: 6px; }
.day-nav input[type=date] { width: auto; }
.day-nav .btn.quiet { font-size: 16px; line-height: 1; padding: 5px 11px; }
.branch-pick { width: auto; max-width: 260px; }
.seg { display: inline-flex; border: 1px solid var(--steel-300); border-radius: var(--r); overflow: hidden; margin-inline-start: auto; }
.seg a { padding: 6px 12px; font-size: 12.5px; color: var(--ink-soft); background: white; }
.seg a + a { border-inline-start: 1px solid var(--steel-300); }
.seg a:hover { text-decoration: none; background: var(--steel-50); color: var(--ink); }
.seg a.on { background: var(--steel-800); color: white; }

.status-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.status-strip a {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  font-size: 12.5px; color: var(--ink-soft); background: white;
  border: 1px solid var(--steel-200); border-radius: 14px;
}
.status-strip a:hover { text-decoration: none; border-color: var(--steel-400); color: var(--ink); }
.status-strip a.on { border-color: var(--steel-800); color: var(--ink); box-shadow: inset 0 0 0 1px var(--steel-800); }
.status-strip a.zero { opacity: 0.55; }
.status-strip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); display: inline-block; }
.status-strip .count-badge, .sched-colhead .count-badge {
  display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; text-align: center;
  background: var(--steel-100); color: var(--ink-muted); font-size: 11px; font-weight: 600;
}

/* ---- Day schedule: the doctor grid ---- */
.sched { background: white; border: var(--border); border-radius: var(--r-md); overflow: hidden; }
.sched-scroll { overflow: auto; max-height: calc(100vh - 280px); min-height: 420px; position: relative; }
.sched-grid { display: grid; min-width: 100%; width: max-content; }
.sched-corner, .sched-colhead {
  position: sticky; top: 0; z-index: 3; background: var(--steel-25); border-bottom: var(--border-strong);
}
.sched-corner { inset-inline-start: 0; z-index: 4; }
.sched-colhead {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px; border-inline-start: var(--border);
  font-size: 12.5px; font-weight: 600; color: var(--ink);
}
.sched-colhead .col-doc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched-times {
  position: sticky; inset-inline-start: 0; z-index: 2; background: var(--steel-25);
  border-inline-end: var(--border);
}
.sched-times span {
  position: absolute; inset-inline-end: 8px; transform: translateY(3px);
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 11px; color: var(--ink-muted);
}
.sched-times span.now { color: var(--alert-red); font-weight: 600; background: var(--steel-25); transform: translateY(-50%); z-index: 1; }
.sched-col {
  position: relative; border-inline-start: var(--border); cursor: cell;
  background-image:
    repeating-linear-gradient(to bottom, var(--steel-200) 0 1px, transparent 1px var(--hour)),
    repeating-linear-gradient(to bottom, var(--steel-100) 0 1px, transparent 1px var(--row));
}
.sched-col.past { cursor: default; background-color: var(--steel-25); }
.sched-now { position: absolute; inset-inline: 0; height: 2px; background: var(--alert-red); z-index: 2; pointer-events: none; }
.sched-now::before {
  content: ""; position: absolute; inset-inline-start: -4px; top: -3px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--alert-red);
}
.appt {
  position: absolute; z-index: 1; display: flex; flex-direction: column; gap: 1px;
  padding: 3px 7px; overflow: hidden; border-radius: var(--r);
  background: var(--w); color: var(--ink); border-inline-start: 3px solid var(--c);
  box-shadow: 0 0 0 1px white; font-size: 12px; line-height: 1.3;
}
.appt:hover { text-decoration: none; z-index: 5; box-shadow: 0 0 0 1px white, var(--shadow-2); }
.appt-line { display: flex; align-items: center; gap: 5px; min-width: 0; white-space: nowrap; }
.appt-time { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 11px; color: var(--c); font-weight: 500; flex: none; }
.appt-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.appt-reason, .appt-timing { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appt-reason { color: var(--ink-soft); }
.appt-timing { color: var(--amber); font-weight: 500; }
.appt-timing.late { color: var(--alert-red); }
.appt.short { padding-top: 1px; padding-bottom: 1px; }
.appt.short .appt-reason, .appt.short .appt-timing { display: none; }
.appt.st-noshow { background: repeating-linear-gradient(135deg, var(--w) 0 6px, white 6px 12px); }
.appt.st-noshow .appt-name { text-decoration: line-through; color: var(--ink-muted); }
.appt.st-completed { opacity: 0.8; }
.slot-ghost {
  position: fixed; z-index: 50; pointer-events: none; padding: 2px 7px;
  border: 1.5px dashed var(--accent); border-radius: var(--r); background: rgba(20, 112, 140, 0.06);
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 11.5px; color: var(--accent-dark);
}
.sched-foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 8px 12px; border-top: var(--border); font-size: 12px; color: var(--ink-muted); background: var(--steel-25);
}
.sched-settings { margin-top: 18px; }

/* ---- Day schedule: list ---- */
.card.flush { padding: 0; overflow-x: auto; }
.card.flush table.data { border: 0; }
.appt-table td { vertical-align: top; }
.appt-table .pt-name { font-weight: 600; color: var(--ink); }
.appt-table a.pt-name { color: var(--accent-dark); }
.alert-badge.sm { font-size: 11px; padding: 0 6px; margin-inline-start: 6px; vertical-align: 1px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.row-actions form { display: inline; }
tr.row-cancelled td, tr.row-noshow td { color: var(--ink-muted); }
tr.row-cancelled .pt-name { text-decoration: line-through; }
.timing-late { color: var(--alert-red); font-weight: 500; }
.timing-waiting { color: var(--amber); font-weight: 500; }
.timing-withdoc { color: #185FA5; font-weight: 500; }

/* ---- Booking form ---- */
.form-block { margin-bottom: 14px; }
.form-block h2 { margin-bottom: 12px; }
.conflict-box {
  margin-bottom: 14px; padding: 12px 14px; border-radius: var(--r);
  background: var(--amber-wash); border-inline-start: 3px solid var(--amber); color: #5E4305;
}
.conflict-box ul { margin: 8px 0 10px; padding-inline-start: 18px; font-size: 13px; }
.conflict-box li { margin-bottom: 3px; }
.conflict-kind { font-size: 11px; font-weight: 600; margin-inline-start: 6px; color: var(--amber); }
.pt-results { margin-top: 6px; border-radius: var(--r); overflow: hidden; }
.pt-results:not(:empty) { border: var(--border); }
.pt-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px;
  background: white; border: 0; border-bottom: var(--border); text-align: start;
  font: inherit; color: var(--ink); cursor: pointer;
}
.pt-row:last-child { border-bottom: 0; }
.pt-row:hover, .pt-row:focus { background: var(--accent-wash); outline: none; }
.pt-row-name { flex: 1; font-weight: 600; }
.pt-row-fn, .pt-row-ph { font-size: 12px; color: var(--ink-muted); }
.pt-none { padding: 10px 12px; font-size: 12.5px; color: var(--ink-muted); background: white; }
.pt-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 12px 14px; background: var(--steel-25); border: var(--border); border-radius: var(--r);
}
.pt-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; width: 100%; }
.pt-card-name { font-size: 15px; font-weight: 600; }
.pt-card-next { font-size: 12.5px; color: var(--amber); }

/* ---- Appointment detail ---- */
.crumb { font-size: 12.5px; margin-bottom: 10px; }
.appt-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  padding: 16px 18px; margin-bottom: 14px; background: white;
  border: var(--border); border-inline-start: 4px solid var(--c); border-radius: var(--r-md);
}
.appt-head h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; margin: 2px 0; }
.appt-head h1 a { color: var(--ink); }
.appt-head-when { font-size: 13px; font-weight: 600; color: var(--c); }
.appt-head-status { text-align: end; }
.appt-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-bottom: 16px; }
.appt-actions form { display: inline; }
.cancel-pop summary { list-style: none; }
.cancel-pop summary::-webkit-details-marker { display: none; }
.cancel-pop form {
  display: flex !important; align-items: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 8px;
  padding: 10px 12px; background: white; border: var(--border); border-radius: var(--r);
}
.cancel-pop form label { width: 100%; margin: 0; }
.cancel-pop select { width: auto; min-width: 200px; }
dl.kv { display: grid; grid-template-columns: 120px 1fr; gap: 7px 14px; font-size: 13px; }
dl.kv dt { color: var(--ink-muted); font-size: 12.5px; }
dl.kv .teeth, .visit-tx .teeth, .other-appts .teeth {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 11.5px;
  background: var(--steel-100); padding: 1px 6px; border-radius: 3px;
}
.visit-steps { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.visit-steps li { border-top: 3px solid var(--steel-200); padding-top: 6px; display: flex; flex-direction: column; font-size: 14px; color: var(--ink-faint); }
.visit-steps li.done { border-top-color: var(--ok); color: var(--ink); }
.visit-steps .k { font-size: 12px; color: var(--ink-soft); }
.visit-tx { margin-top: 16px; padding-top: 12px; border-top: var(--border); }
.visit-tx-title { font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.visit-tx ul { padding-inline-start: 18px; font-size: 13px; }
table.history td { font-size: 12.5px; vertical-align: top; }
.hist-field { font-weight: 600; }
.hist-old { text-decoration: line-through; color: var(--ink-muted); }
.other-appts { list-style: none; }
.other-appts li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 0; border-bottom: var(--border); font-size: 13px; }
.other-appts li:last-child { border-bottom: 0; }
.other-appts .appt-pill { margin-inline-start: auto; }

/* ---- Patient page ---- */
.next-visit.next-appt { background: white; border-color: var(--steel-200); border-inline-start: 3px solid var(--accent); }
.next-visit.next-appt .appt-pill { margin-inline-start: 8px; }
tr.appt-past td { color: var(--ink-muted); }

@media (max-width: 640px) {
  .sched-cta { width: 100%; }
  .sched-cta .btn { flex: 1; }
  .seg { margin-inline-start: 0; }
  .sched-scroll { max-height: calc(100vh - 220px); }
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dd { margin-bottom: 8px; }
  .visit-steps { grid-template-columns: 1fr; }
  .appt-head-status { text-align: start; }
}

/* Phones: each appointment in the list becomes a compact card so the status and buttons stay in view */
@media (max-width: 640px) {
  .appt-table thead { display: none; }
  .appt-table, .appt-table tbody { display: block; width: 100%; }
  .appt-table tr {
    display: grid; grid-template-columns: 58px 1fr; gap: 3px 10px;
    padding: 11px 12px; border-bottom: var(--border);
  }
  .appt-table tr:last-child { border-bottom: 0; }
  table.data.appt-table td { display: block; padding: 0; border: 0; }
  .appt-table td:first-child { grid-row: 1 / span 5; }
  .appt-table td:not(:first-child) { grid-column: 2; }
  .appt-table td:nth-child(3), .appt-table td:nth-child(4) { font-size: 12.5px; color: var(--ink-soft); }
  .appt-table .row-actions { justify-content: flex-start; margin-top: 6px; }
}

/* ============================================================
   QUEUE BOARD
   ============================================================ */
.ticket-tag {
  display: inline-block; margin-inline-start: 6px; padding: 0 6px; border-radius: 4px;
  background: var(--steel-800); color: white; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; vertical-align: 1px;
}
.appt .ticket-tag { font-size: 10px; padding: 0 4px; margin: 0; flex: none; }
.q-toolbar { align-items: flex-end; }
.q-filters { display: flex; gap: 10px; flex-wrap: wrap; }
.q-inline { display: flex; flex-direction: column; gap: 3px; margin: 0; }
.q-inline > span { font-size: 11px; color: var(--ink-muted); font-weight: 500; }
.q-inline select, .q-inline input { width: auto; min-width: 170px; }
.q-room { padding-inline-start: 12px; border-inline-start: var(--border); }
.q-room select, .q-room input { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-wash); }
.q-live { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-muted); align-self: center; }
.q-live i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-wash); }
.q-live.off i { background: var(--alert-red); box-shadow: 0 0 0 3px var(--alert-red-wash); }
.q-live.off { color: var(--alert-red); }

.q-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; background: var(--steel-200); border: var(--border); border-radius: var(--r-md); overflow: hidden; margin-bottom: 14px; }
.q-stats > div { background: white; padding: 10px 14px; display: flex; flex-direction: column; }
.q-stats b { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.q-stats span { font-size: 12px; color: var(--ink-muted); }

.q-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.q-col h2 {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  font-size: 12px; font-weight: 600; color: var(--ink-soft); text-transform: none; letter-spacing: 0;
}
.q-col h2 .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); display: inline-block; }
.q-col .count-badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; text-align: center; background: var(--steel-100); color: var(--ink-muted); font-size: 11px; font-weight: 600; }
.q-empty { padding: 18px 14px; border: 1px dashed var(--steel-300); border-radius: var(--r); font-size: 12.5px; color: var(--ink-muted); text-align: center; }
.q-card {
  display: flex; gap: 12px; padding: 12px; margin-bottom: 8px; background: white;
  border: var(--border); border-inline-start: 4px solid var(--c); border-radius: var(--r);
}
.q-card.next { box-shadow: 0 0 0 1px var(--c); }
.q-card.fresh { background: var(--w); }
.q-ticket { flex: none; min-width: 56px; font-size: 24px; font-weight: 700; line-height: 1.1; color: var(--c); letter-spacing: 0.01em; }
.q-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.q-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.q-name a { color: var(--ink); }
.q-next-tag { font-size: 10.5px; font-weight: 600; color: var(--amber); background: var(--amber-wash); padding: 0 6px; border-radius: 8px; }
.q-meta { font-size: 12.5px; color: var(--ink-soft); }
.q-room-tag { display: inline-block; font-weight: 600; color: var(--c); background: var(--w); padding: 0 6px; border-radius: 4px; }
.q-time { font-size: 12px; color: var(--ink-muted); }
.q-time .warn { color: var(--amber); font-weight: 600; }
.q-time .late { color: var(--alert-red); }
.q-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.q-actions form { display: inline; }

/* Rooms & screens */
.q-branch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.q-branch-grid textarea { font-family: inherit; }
.q-link { display: flex; gap: 6px; }
.q-link input { flex: 1; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 11.5px; }
.q-branch .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.q-branch .actions form { display: inline; }

@media (max-width: 1000px) {
  .q-cols { grid-template-columns: 1fr; }
  .q-stats { grid-template-columns: repeat(3, 1fr); }
  .q-branch-grid { grid-template-columns: 1fr; }
  .q-stats > div:last-child { grid-column: span 2; }
}
@media (max-width: 640px) {
  .q-room { padding-inline-start: 0; border-inline-start: 0; }
  .q-live { margin-inline-start: 0; }
  .q-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   ESTIMATES, INVOICES & ACCOUNTS
   ============================================================ */
.num { text-align: end; }
input.num { text-align: end; font-variant-numeric: tabular-nums; }
td.neg, .neg { color: var(--alert-red); }
.bill-note { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.svc-row { display: grid; grid-template-columns: 2fr 1.4fr 0.8fr 1fr auto; gap: 10px; align-items: end; }
.svc-btn { align-self: end; }
.svc-edit { display: grid; grid-template-columns: 2fr 1.3fr 0.8fr 1fr 0.9fr auto; gap: 8px; align-items: center; padding: 8px 12px; }
.svc-edit input.zero { border-color: var(--amber); background: var(--amber-wash); }
.svc-table thead th:nth-child(1) { padding-inline-start: 12px; }

.lines-table td { vertical-align: top; padding: 8px 10px; }
.lines-table select.l-svc { margin-bottom: 6px; }
.lines-table .l-amt { padding-top: 16px; font-weight: 600; }
.lines-table .l-del { font-size: 16px; line-height: 1; padding: 4px 9px; }
.lines-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 12px 14px; border-top: var(--border); flex-wrap: wrap; }
dl.totals { display: grid; grid-template-columns: auto 130px; gap: 5px 18px; font-size: 13px; margin-inline-start: auto; }
dl.totals dt { color: var(--ink-soft); text-align: end; }
dl.totals dd { text-align: end; font-variant-numeric: tabular-nums; }
dl.totals .grand { font-size: 16px; font-weight: 700; color: var(--ink); padding-top: 6px; border-top: var(--border-strong); }
dl.totals.static { padding: 12px 14px; border-top: var(--border); }
.vat-choice { align-self: center; }
.vat-choice .hint { margin-top: 3px; }

.doc-head {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px 18px; margin-bottom: 14px; background: white; border: var(--border); border-radius: var(--r-md);
}
.doc-kind { font-size: 12px; font-weight: 600; color: var(--accent); }
.doc-head h1 { font-size: 20px; margin: 2px 0 4px; }
.doc-head .hint { margin-top: 2px; }
.doc-head-side { text-align: end; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.doc-total { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.doc-total span { font-size: 12px; color: var(--ink-muted); font-weight: 500; }
.doc-due { font-size: 12.5px; color: var(--ink-soft); }
.doc-due.owing { color: var(--alert-red); font-weight: 600; font-size: 14px; }
.doc-due.refund { color: var(--amber); font-weight: 600; font-size: 14px; }
.pay-row { display: grid; grid-template-columns: 1fr 1fr 1.4fr auto; gap: 10px; align-items: end; }
.pay-box { border-inline-start: 3px solid var(--accent); }

.bill-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.bill-balance { font-size: 13px; color: var(--ink-soft); }
.bill-balance b { font-size: 18px; color: var(--ink); }
.bill-balance.owing b { color: var(--alert-red); }
.bill-h { font-size: 12.5px; font-weight: 600; margin: 16px 0 8px; color: var(--ink-soft); }
.tab .count-badge.owe { background: var(--alert-red-wash); color: var(--alert-red); }

.acc-stats { grid-template-columns: repeat(6, 1fr); }
.acc-stats b { font-size: 18px; }
.method-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-bottom: 12px; }
.method-grid .card { padding: 12px 14px; }
.method-v { font-size: 18px; font-weight: 700; margin-top: 2px; }

@media (max-width: 1000px) {
  .acc-stats { grid-template-columns: repeat(3, 1fr); }
  .svc-row, .svc-edit, .pay-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .acc-stats { grid-template-columns: repeat(2, 1fr); }
  .lines-table thead { display: none; }
  .lines-table, .lines-table tbody { display: block; }
  .lines-table tr.ln { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 10px 12px; border-bottom: var(--border); }
  table.data.lines-table td { display: block; padding: 0; border: 0; }
  .lines-table tr.ln td:first-child { grid-column: 1 / -1; }
  .lines-table .l-amt { padding-top: 8px; }
  .doc-head-side { align-items: flex-start; text-align: start; }
}

table.data td.num, table.data th.num, table.tx-table td.num, table.tx-table th.num { text-align: end; }

/* ============================================================
   PRESCRIPTIONS · IMAGING · BIOPSIES · STERILIZATION
   ============================================================ */
.danger-box { background: var(--alert-red-wash); border-inline-start-color: var(--alert-red); color: #7a1f17; }
.card.danger, .rx-item.danger { border-inline-start: 3px solid var(--alert-red); }
.rx-allergy { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; padding: 10px 14px; margin-bottom: 14px;
  background: white; border: var(--border); border-radius: var(--r); font-size: 13px; }
.rx-allergy.has { background: var(--alert-red-wash); border-color: var(--alert-red); color: #7a1f17; }
.rx-item-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.rx-item-head select { flex: 1; }
.rx-n { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; flex: none;
  border-radius: 50%; background: var(--steel-800); color: white; font-size: 12px; font-weight: 600; }
.rx-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.rx-grid .wide { grid-column: span 2; }
.rx-warn { margin-top: 8px; font-size: 12.5px; font-weight: 600; color: var(--alert-red); }
.rx-show-name { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.rx-show-sig { margin: 6px 0 2px; font-size: 13.5px; }
.cssd-stats { grid-template-columns: repeat(7, 1fr); }
.q-stats b.amber { color: var(--amber); }
.q-stats b.red { color: var(--alert-red); }
.setup-row { grid-template-columns: 1.4fr 1.4fr 0.8fr 0.8fr auto; padding: 6px 0; }
.setup-row .span2 { grid-column: span 2; }
.set-qty { display: grid; gap: 6px; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 10px; margin: 0;
  border: var(--border); border-radius: var(--r); text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink); }
.set-row > span { display: flex; flex-direction: column; gap: 2px; }
.set-row input { width: 90px; flex: none; text-align: end; }
.incident.open { border-inline-start: 3px solid var(--alert-red); }
.inc-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inc-text { font-size: 13px; margin-top: 6px; }
.inc-close { display: flex; gap: 8px; margin-top: 10px; }
.pack-list { list-style: none; font-size: 13px; margin-bottom: 8px; }
.pack-list li { padding: 3px 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pack-add { display: flex; gap: 8px; }
.pack-add input { max-width: 340px; font-family: "JetBrains Mono", ui-monospace, monospace; }

.img-layout { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 14px; }
.img-layout.compare { grid-template-columns: 1fr 1fr; }
.viewer { background: #0f1720; border-radius: var(--r-md); overflow: hidden; }
.viewer-tools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 8px 12px; background: #16212e; }
.viewer-tools label { display: flex; align-items: center; gap: 6px; margin: 0; color: #9fb0c4; font-size: 11.5px; text-transform: none; letter-spacing: 0; }
.viewer-tools input[type=range] { width: 90px; }
.viewer-tools .btn.quiet { background: transparent; color: #cfd8e3; border-color: #2c3a4d; }
.viewer-stage { height: 62vh; min-height: 320px; overflow: auto; display: flex; align-items: center; justify-content: center; cursor: grab; touch-action: none; }
.viewer-stage img { width: 100%; max-width: none; height: auto; object-fit: contain; user-select: none; transition: filter .1s; }
.img-layout:not(.compare) .viewer-stage img { width: auto; max-height: 100%; }
.viewer-empty { color: #5d7087; font-size: 13px; }
.viewer-thumbs { display: flex; gap: 6px; padding: 8px; overflow-x: auto; background: #16212e; }
.thumb { flex: none; width: 72px; height: 56px; padding: 0; border: 2px solid transparent; border-radius: 4px; background: #0f1720; cursor: pointer; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.on { border-color: var(--accent); }
.thumb.file { color: #cfd8e3; font-size: 11px; text-decoration: none; }
.compare-head { font-size: 12.5px; margin-bottom: 6px; color: var(--ink-soft); }
.compare-pick { margin-bottom: 12px; align-items: flex-end; }
.upload-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.upload-row label { width: 100%; }
.report-text { white-space: pre-wrap; font-size: 13.5px; line-height: 1.55; }
.bx-steps { grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }

@media (max-width: 1000px) {
  .cssd-stats { grid-template-columns: repeat(4, 1fr); }
  .img-layout.compare { grid-template-columns: 1fr; }
  .rx-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .cssd-stats { grid-template-columns: repeat(2, 1fr); }
  .rx-grid { grid-template-columns: 1fr; }
  .rx-grid .wide { grid-column: auto; }
  .bx-steps { grid-template-columns: 1fr 1fr; }
  .setup-row { grid-template-columns: 1fr 1fr; }
  .viewer-stage { height: 48vh; }
}

/* ============================================================
   EMR: TOOTH CHART & BODY MAP
   ============================================================ */
:root { --tc-fill: #3b7dd8; --tc-caries: #d64545; --tc-crown: #a17c1f; --tc-implant: #1f6fb2; --tc-plan: #d9950b; }
.tc-wrap { display: flex; gap: 6px; align-items: stretch; width: 100%; }
.tc-wrap input { flex: 1; min-width: 0; }
.tc-btn { flex: none; font: inherit; font-size: 12px; padding: 0 10px; border: 1px solid var(--accent); border-radius: var(--r); background: var(--accent-wash); color: var(--accent-dark); cursor: pointer; }
.tc-btn:hover { background: var(--accent); color: white; }
.tc-pop { position: absolute; z-index: 60; width: min(760px, calc(100vw - 16px)); padding: 12px; background: white; border: var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-2), 0 12px 32px rgba(15, 23, 32, 0.18); }
.tc-pop-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.tc-seg { display: inline-flex; border: 1px solid var(--steel-300); border-radius: var(--r); overflow: hidden; }
.tc-seg button { font: inherit; font-size: 12px; padding: 4px 10px; border: 0; background: white; cursor: pointer; color: var(--ink-soft); }
.tc-seg button.on { background: var(--steel-800); color: white; }
.tc-hint { flex: 1; font-size: 11.5px; color: var(--ink-muted); }
.tc-clear, .tc-done { font: inherit; font-size: 12px; padding: 4px 12px; border-radius: var(--r); cursor: pointer; border: 1px solid var(--steel-300); background: white; }
.tc-done { background: var(--accent); color: white; border-color: var(--accent); }
.tc-svg { width: 100%; height: auto; display: block; user-select: none; }
.tc-num { font: 600 10px/1 "JetBrains Mono", ui-monospace, monospace; fill: var(--ink-muted); cursor: pointer; }
.tc-num.on { fill: var(--accent-dark); }
.tc-s { fill: white; stroke: var(--steel-300); stroke-width: 0.8; cursor: pointer; }
.tc-s:hover { fill: var(--accent-wash); }
.tc-s.sel { fill: var(--accent); }
.tc-s.filling { fill: var(--tc-fill); }
.tc-s.caries { fill: var(--tc-caries); }
.tc-outline { fill: none; stroke: var(--steel-400); stroke-width: 1; pointer-events: none; }
.tc-outline.picked { stroke: var(--accent); stroke-width: 2.5; }
.tc-outline.crown { stroke: var(--tc-crown); stroke-width: 3.5; }
.tc-tooth.missing .tc-s { fill: var(--steel-50); stroke: var(--steel-200); }
.tc-x { stroke: var(--ink-faint); stroke-width: 2; }
.tc-implant { stroke: var(--tc-implant); stroke-width: 3; fill: none; }
.tc-rct { stroke: var(--tc-caries); stroke-width: 3; }
.tc-rct-dot { fill: var(--tc-caries); }
.tc-bridge { fill: #7a4bc2; }
.tc-veneer { fill: #1a9e8f; }
.tc-fracture { fill: none; stroke: #e07b12; stroke-width: 2; }
.tc-treated { fill: var(--ink-muted); }
.tc-planned { fill: none; stroke: var(--tc-plan); stroke-width: 1.8; stroke-dasharray: 4 3; pointer-events: none; }
.tc-mid { stroke: var(--steel-200); stroke-width: 1; }
.tc-tooth.active .tc-outline { stroke: var(--steel-800); stroke-width: 2.5; }
.tc-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.tc-bar .seg { margin-inline-start: 0; }
.tc-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-soft); }
.tc-legend span { display: inline-flex; align-items: center; gap: 5px; }
.tc-lg { display: inline-block; width: 12px; height: 12px; border-radius: 2px; border: 1px solid var(--steel-300); }
.tc-lg.filling { background: var(--tc-fill); } .tc-lg.caries { background: var(--tc-caries); } .tc-lg.crown { border: 3px solid var(--tc-crown); }
.tc-lg.rct { background: white; box-shadow: inset 0 0 0 3px white, inset 0 0 0 12px var(--tc-caries); border-radius: 50%; }
.tc-lg.implant { background: var(--tc-implant); } .tc-lg.missing { background: var(--steel-50); position: relative; }
.tc-lg.planned { border: 2px dashed var(--tc-plan); }
.tc-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 14px; align-items: start; }
.tc-card { padding: 14px; }
.tc-side h2 { margin-bottom: 8px; }
.tc-hist { list-style: none; font-size: 13px; margin-bottom: 12px; }
.tc-hist li { padding: 6px 0; border-bottom: var(--border); }
.tc-plan { font-size: 12.5px; padding: 6px 8px; margin-bottom: 8px; border-radius: var(--r); background: var(--amber-wash); color: #5E4305; }
.tc-find { border-top: var(--border); padding-top: 12px; margin-top: 8px; }

.consent-strip { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px; border-radius: var(--r); font-size: 13px; border: var(--border); background: white; }
.consent-strip.missing { background: var(--amber-wash); border-color: var(--amber); }
.consent-form { display: flex; gap: 6px; }
.consent-form select { width: auto; }
.bm-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.bm-card { padding: 12px; }
.bm-svg { width: 100%; height: auto; display: block; }
.bm-svg[data-mode=pick] .bm-fig { cursor: crosshair; }
.bm-part { fill: #e6ebf1; }
.bm-limb { stroke: #e6ebf1; }
.bm-label { font: 600 12px var(--font, sans-serif); fill: var(--ink-soft); }
.bm-side { font: 600 10px var(--font, sans-serif); fill: var(--ink-faint); }
.bm-marker circle { stroke: white; stroke-width: 2; }
.bm-marker text { font: 700 9px sans-serif; fill: white; pointer-events: none; }
.bm-marker.amber circle { fill: var(--amber); } .bm-marker.blue circle { fill: #185FA5; } .bm-marker.green circle { fill: var(--ok); }
.bm-marker.grey circle { fill: var(--ink-faint); } .bm-marker.red circle { fill: var(--alert-red); }
.bm-marker.current circle { stroke: var(--steel-800); stroke-width: 3; r: 10; }
.bm-temp circle { fill: var(--accent); stroke: white; stroke-width: 2; }
.bm-temp text { font: 700 11px sans-serif; fill: white; }
.bm-mini .bm-svg { max-height: 320px; }
.lesion-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 14px; align-items: start; }
.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0; }
.photo-thumb { flex: none; width: 110px; display: flex; flex-direction: column; gap: 3px; text-decoration: none; font-size: 11px; color: var(--ink-soft); }
.photo-thumb img { width: 110px; height: 80px; object-fit: cover; border-radius: var(--r); border: 2px solid transparent; }
.photo-thumb.on img { border-color: var(--accent); }
@media (max-width: 1000px) { .tc-layout, .bm-layout, .lesion-layout { grid-template-columns: 1fr; } }
.bm-temp[hidden] { display: none; }

/* ============================================================
   INSURANCE · DASHBOARD · PERSONNEL
   ============================================================ */
.claim-strip { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; font-size: 13px; }
.claim-strip .actions { margin: 0; }
.claim-strip select { width: auto; }
.pol-edit summary { list-style: none; display: inline-block; }
.pol-edit summary::-webkit-details-marker { display: none; }
.pol-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 6px; min-width: 520px; }
.exp-expired { color: var(--alert-red); font-weight: 600; }
.exp-soon { color: var(--amber); font-weight: 600; }
input.exp-expired { border-color: var(--alert-red); background: var(--alert-red-wash); }
input.exp-soon { border-color: var(--amber); background: var(--amber-wash); }
.doc-row { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 13px; padding: 4px 0; }

.bi-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.bi-kpi { background: white; border: var(--border); border-radius: var(--r-md); padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; }
.bi-kpi .k { font-size: 12px; color: var(--ink-muted); }
.bi-kpi b { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bi-kpi .s { font-size: 11.5px; color: var(--ink-muted); }
.bi-delta { font-weight: 600; margin-inline-start: 4px; }
.bi-delta.up { color: var(--ok); }
.bi-delta.down { color: var(--alert-red); }
.bi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.bi-card { padding: 14px 16px; }
.bi-card.wide { grid-column: 1 / -1; }
.bi-card h2 { margin-bottom: 10px; }
.bi-chart { width: 100%; height: auto; display: block; }
.bi-bar { fill: var(--accent); }
.bi-bar.b { fill: var(--ok); } .bi-bar.c { fill: #185FA5; }
.bi-line { fill: none; stroke: var(--ok); stroke-width: 2.2; }
.bi-dot { fill: var(--ok); }

.bi-chart .bi-gl { stroke: var(--steel-100); stroke-width: 1; }
.bi-axis { font: 12px "JetBrains Mono", ui-monospace, monospace; fill: var(--ink-muted); }
.bi-lbl { font: 13px sans-serif; fill: var(--ink-soft); }
.bi-val { font: 600 12.5px "JetBrains Mono", ui-monospace, monospace; fill: var(--ink); }
.bi-legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-soft); margin: -4px 0 6px; }
.bi-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 5px; vertical-align: -1px; }
.bi-legend i.a { background: var(--accent); } .bi-legend i.b { background: var(--ok); }
.bi-owed dd { font-size: 15px; }
.bi-quality { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.bi-quality > * { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: var(--border); border-radius: var(--r); text-decoration: none; color: var(--ink); background: var(--steel-25); }
.bi-quality b { font-size: 20px; }
.bi-quality span { font-size: 12px; color: var(--ink-soft); }
.bi-quality .warn { border-color: var(--amber); background: var(--amber-wash); }
.bi-quality .bad { border-color: var(--alert-red); background: var(--alert-red-wash); }
@media (max-width: 1000px) { .bi-kpis, .bi-quality { grid-template-columns: repeat(2, 1fr); } .bi-grid { grid-template-columns: 1fr; } .pol-form { grid-template-columns: 1fr 1fr; min-width: 0; } }

/* ============================================================
   WORKING HOURS · ONLINE REQUESTS
   ============================================================ */
.st-requested { --c: #7a4bc2; --w: #f3edfb; }
.sched-off {
  position: absolute; inset-inline: 0; z-index: 0; pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(126,147,173,.10) 0 6px, rgba(126,147,173,.20) 6px 12px);
  display: flex; align-items: flex-start; justify-content: center;
}
.sched-off span { margin-top: 8px; font-size: 11px; font-weight: 600; color: var(--ink-muted); background: var(--steel-25); padding: 1px 6px; border-radius: 3px; }
.appt.st-requested { border-inline-start-style: dashed; background: repeating-linear-gradient(135deg, var(--w) 0 8px, white 8px 16px); }
.online-banner {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 10px 14px; border-radius: var(--r);
  background: #f3edfb; border: 1px solid #d9c8f0; color: #4b2a82; font-size: 13px; text-decoration: none;
}
.online-banner:hover { text-decoration: none; background: #ece2f9; }
.online-banner strong { font-size: 15px; }
.online-banner .rtl-flip { margin-inline-start: auto; }
.nav-badge { display: inline-block; min-width: 18px; padding: 0 6px; margin-inline-start: 6px; border-radius: 9px; background: #7a4bc2; color: white; font-size: 11px; font-weight: 700; text-align: center; }

.roster-table td { vertical-align: top; }
.roster-row { display: grid; grid-template-columns: 1.3fr repeat(7, minmax(0, 1fr)) auto; gap: 6px; align-items: end; padding: 10px 12px; border-bottom: var(--border); }
.roster-row:last-child { border-bottom: 0; }
.roster-row label { font-size: 10.5px; }
.roster-row input { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12px; padding: 6px 7px; }
.roster-doc strong { display: block; font-size: 13.5px; }
.roster-opts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; font-size: 12.5px; }
.roster-opts input[type=text] { width: 200px; font-family: inherit; }
.roster-opts select { width: auto; }
.roster-head { display: grid; grid-template-columns: 1.3fr repeat(7, minmax(0, 1fr)) auto; gap: 6px; padding: 8px 12px; background: var(--steel-25); border-bottom: var(--border-strong); font-size: 11px; font-weight: 600; color: var(--ink-soft); }
@media (max-width: 1000px) {
  .roster-head { display: none; }
  .roster-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .roster-doc { grid-column: 1 / -1; }
}
.mobile-only { display: none; }
@media (max-width: 1000px) { .roster-row .mobile-only { display: block; } }
.ok-text { color: var(--ok); font-weight: 600; }
.warn-text { color: var(--amber); font-weight: 600; }
.match-list { display: grid; gap: 6px; margin-top: 4px; }
.match { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; margin: 0; border: var(--border); border-radius: var(--r);
  text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink); cursor: pointer; background: white; }
.match:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }
.match input[type=radio] { margin-top: 3px; accent-color: var(--accent); }
.match .hint { display: block; }
.match .pill { margin-inline-start: 6px; }
.btn.wa-btn { background: #1fa855; border-color: #1fa855; }
.btn.wa-btn:hover { background: #178a45; border-color: #178a45; }
.setup-list { padding-inline-start: 0; list-style: none; display: grid; gap: 6px; font-size: 13.5px; counter-reset: s; }
.setup-list li { display: flex; gap: 8px; align-items: baseline; }
.setup-list li::before { counter-increment: s; content: counter(s); flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--steel-100);
  color: var(--ink-soft); font-size: 11.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.setup-list li.done::before { content: "✓"; background: var(--ok); color: white; }
.tpl-help { margin-top: 12px; }
.tpl-help summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 500; }
.tpl-item { padding: 8px 0; border-bottom: var(--border); font-size: 13px; }
.tpl-text { font-size: 12.5px; margin-top: 4px; padding: 6px 8px; background: var(--steel-25); border-radius: var(--r); white-space: normal; }
