/* Serenity Dental Clinic — Stylesheet (RTL Arabic, 5 Structural Blue & Gray Themes, Authentic Corner Logo, Dual-View Chart) */

:root,
html[data-theme="serenity_blue_mix"] {
  --navy: #135170;
  --navy-light: #1A658A;
  --navy-muted: #7CA5C9;
  --bg: #F5F7FB;
  --rail-bg: #F1F4F9;
  --card: #FFFFFF;
  --border: #E6ECF4;
  --border-grid: #EDF1F7;
  --border-input: #CBD5E1;
  --border-soft: #EEF2F7;
  --text: #182230;
  --text-muted: #526277;
  --text-subtle: #8494A7;
  --primary: #1D72B8;
  --primary-hover: #155B96;
  --primary-soft: #EAF4FD;
  --primary-soft-strong: #D6EBFC;
  --primary-border: #CBE4FA;
  --teal: #0EA5E9;
  --success: #1D72B8;
  --success-soft: #EAF4FD;
  --warning: #B45309;
  --warning-soft: #FEF6DC;
  --danger: #B91C1C;
  --danger-soft: #FDE8E8;
  --danger-border: #FECACA;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(15, 35, 60, 0.035);
  --shadow-lg: 0 12px 32px rgba(24, 34, 48, 0.14);
  --app-font: 'IBM Plex Sans Arabic', 'Inter', 'Segoe UI', Tahoma, sans-serif;

  /* Default: LinkHMS Medical Blue Mix (Zero Green, Zero Purple) */
  --sidebar-bg: #F1F4F9;
  --sidebar-border: #E6ECF4;
  --sidebar-divider: #E2E8F0;
  --sidebar-title: #135170;
  --sidebar-muted: #526277;
  --sidebar-text: #526277;
  --sidebar-hover-bg: #E7EEF8;
  --sidebar-hover-text: #1D72B8;
  --sidebar-active-bg: #FFFFFF;
  --sidebar-active-text: #1D72B8;
  --sidebar-active-border: #1D72B8;
  --sidebar-badge-bg: #E2E8F0;
  --sidebar-badge-text: #182230;
  --sidebar-active-badge-bg: #EAF4FD;
  --sidebar-active-badge-text: #1D72B8;
  --role-wrap-bg: #E6ECF4;
  --role-btn-text: #526277;
  --role-active-bg: #1D72B8;
  --role-active-text: #FFFFFF;
  --btn-primary-bg: #1D72B8;
  --btn-primary-hover: #155B96;
  --btn-primary-border: #1D72B8;
  --btn-primary-text: #FFFFFF;
}

html[data-theme="linkhms_clinical"] {
  --bg: #F7F8FA;
  --card: #FFFFFF;
  --border: #E5E7EB;
  --border-input: #D1D5DB;
  --border-soft: #EEF0F3;
  --text: #111827;
  --text-muted: #4B5563;
  --primary: #0B74B8;
  --primary-hover: #085E96;
  --primary-soft: #EDF6FC;
  --primary-border: #BAE0F7;
  --success: #0B74B8;
  --success-soft: #EDF6FC;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: none;
  --sidebar-bg: #F3F4F6;
  --sidebar-border: #E5E7EB;
  --sidebar-divider: #E5E7EB;
  --sidebar-title: #111827;
  --sidebar-muted: #4B5563;
  --sidebar-text: #374151;
  --sidebar-hover-bg: #E5E7EB;
  --sidebar-hover-text: #111827;
  --sidebar-active-bg: #FFFFFF;
  --sidebar-active-text: #0B74B8;
  --sidebar-active-border: #0B74B8;
  --sidebar-badge-bg: #E5E7EB;
  --sidebar-badge-text: #111827;
  --sidebar-active-badge-bg: #D6ECFA;
  --sidebar-active-badge-text: #085E96;
  --role-wrap-bg: #E5E7EB;
  --role-btn-text: #4B5563;
  --role-active-bg: #FFFFFF;
  --role-active-text: #0B74B8;
  --btn-primary-bg: #0B74B8;
  --btn-primary-hover: #085E96;
  --btn-primary-border: #0B74B8;
  --btn-primary-text: #FFFFFF;
}

html[data-theme="figma_airy_cards"] {
  --bg: #EFF5FB;
  --card: #FFFFFF;
  --border: #DCE8F4;
  --border-input: #CBD5E1;
  --border-soft: #E5EFF9;
  --text: #0F172A;
  --text-muted: #475569;
  --primary: #0B74B8;
  --primary-hover: #085E96;
  --primary-soft: #E8F3FB;
  --primary-border: #BAE0F7;
  --success: #0B74B8;
  --success-soft: #E8F3FB;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 14px rgba(15, 45, 74, 0.05);
  --sidebar-bg: #FFFFFF;
  --sidebar-border: #DCE8F4;
  --sidebar-divider: #E5EFF9;
  --sidebar-title: #0F2D4A;
  --sidebar-muted: #475569;
  --sidebar-text: #1E3A5F;
  --sidebar-hover-bg: #DCEBF8;
  --sidebar-hover-text: #0F2D4A;
  --sidebar-active-bg: #0F2D4A;
  --sidebar-active-text: #FFFFFF;
  --sidebar-active-border: transparent;
  --sidebar-badge-bg: #D5E6F6;
  --sidebar-badge-text: #0F2D4A;
  --sidebar-active-badge-bg: rgba(255, 255, 255, 0.22);
  --sidebar-active-badge-text: #FFFFFF;
  --role-wrap-bg: #EAF2FA;
  --role-btn-text: #334155;
  --role-active-bg: #0F2D4A;
  --role-active-text: #FFFFFF;
  --btn-primary-bg: #0F2D4A;
  --btn-primary-hover: #091E33;
  --btn-primary-border: #0F2D4A;
  --btn-primary-text: #FFFFFF;
}

html[data-theme="slate_gray_studio"] {
  --bg: #ECEFF4;
  --card: #FFFFFF;
  --border: #D8DEE9;
  --border-input: #CBD5E1;
  --border-soft: #E5E9F0;
  --text: #1E293B;
  --text-muted: #475569;
  --primary: #0B74B8;
  --primary-hover: #085E96;
  --primary-soft: #EEF4F9;
  --primary-border: #CBD5E1;
  --success: #0B74B8;
  --success-soft: #EEF4F9;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
  --sidebar-bg: #E5E9F0;
  --sidebar-border: #CBD5E1;
  --sidebar-divider: #CBD5E1;
  --sidebar-title: #0F172A;
  --sidebar-muted: #475569;
  --sidebar-text: #334155;
  --sidebar-hover-bg: #D8DEE9;
  --sidebar-hover-text: #0F172A;
  --sidebar-active-bg: #1E293B;
  --sidebar-active-text: #FFFFFF;
  --sidebar-active-border: transparent;
  --sidebar-badge-bg: #CBD5E1;
  --sidebar-badge-text: #0F172A;
  --sidebar-active-badge-bg: rgba(255, 255, 255, 0.2);
  --sidebar-active-badge-text: #FFFFFF;
  --role-wrap-bg: #D8DEE9;
  --role-btn-text: #334155;
  --role-active-bg: #1E293B;
  --role-active-text: #FFFFFF;
  --btn-primary-bg: #1E293B;
  --btn-primary-hover: #0F172A;
  --btn-primary-border: #1E293B;
  --btn-primary-text: #FFFFFF;
}

html[data-theme="serenity_ocean_navy"] {
  --bg: #F1F5F9;
  --card: #FFFFFF;
  --border: #CBD5E1;
  --border-input: #CBD5E1;
  --border-soft: #E2E8F0;
  --text: #0F172A;
  --text-muted: #475569;
  --primary: #0B74B8;
  --primary-hover: #085E96;
  --primary-soft: #EDF6FC;
  --primary-border: #BAE0F7;
  --success: #0B74B8;
  --success-soft: #EDF6FC;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 3px rgba(15, 45, 74, 0.08);
  --sidebar-bg: linear-gradient(180deg, #0D253F 0%, #091B2E 100%);
  --sidebar-border: transparent;
  --sidebar-divider: rgba(255, 255, 255, 0.14);
  --sidebar-title: #FFFFFF;
  --sidebar-muted: #BAE0F7;
  --sidebar-text: #CBD5E1;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.1);
  --sidebar-hover-text: #FFFFFF;
  --sidebar-active-bg: #0B74B8;
  --sidebar-active-text: #FFFFFF;
  --sidebar-active-border: transparent;
  --sidebar-badge-bg: rgba(255, 255, 255, 0.16);
  --sidebar-badge-text: #FFFFFF;
  --sidebar-active-badge-bg: rgba(255, 255, 255, 0.24);
  --sidebar-active-badge-text: #FFFFFF;
  --role-wrap-bg: rgba(255, 255, 255, 0.1);
  --role-btn-text: #CBD5E1;
  --role-active-bg: #FFFFFF;
  --role-active-text: #0D253F;
  --btn-primary-bg: #0D253F;
  --btn-primary-hover: #173862;
  --btn-primary-border: #0D253F;
  --btn-primary-text: #FFFFFF;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--app-font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Strict BiDi isolation for codes, phones, numbers */
.ltr-num {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

/* App Shell Layout — LinkHMS Global Top Bar + Retractable Slim Icon Rail */
#app-shell {
  min-height: 100vh;
}

.shell-frame {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 54px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 60;
}

.topbar-brand-btn {
  border: none;
  background: transparent;
  padding: 2px 4px;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.topbar-logo-img {
  height: 36px;
  width: auto;
  max-width: 170px;
  object-fit: contain;
  display: block;
}

.global-search-btn {
  flex: 1;
  max-width: 390px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #F5F7FB;
  color: var(--text-muted);
  text-align: right;
  font-size: 12.5px;
  transition: border-color 0.15s, background 0.15s;
}

.global-search-btn:hover {
  border-color: var(--primary);
  background: #FFFFFF;
}

.kbd-hint {
  margin-right: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 10.5px;
  color: var(--text-subtle);
}

.topbar-actions {
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-add-pat {
  padding: 6px 14px !important;
  font-size: 12px !important;
}

.pill-cta {
  border-radius: 999px !important;
  padding-left: 15px !important;
  padding-right: 15px !important;
}

.account-menu-wrap {
  position: relative;
}

.doc-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 8px;
  background: #F8FAFD;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  transition: all 0.15s ease;
}

.doc-pill:hover,
.doc-pill.open {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

.doc-avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: linear-gradient(135deg, #2882C2, #135170);
  color: #FFFFFF;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.doc-avatar.is-nurse {
  background: linear-gradient(135deg, #0EA5E9, #1D72B8);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.account-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 230px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 85;
}

.account-pop-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-subtle);
  padding: 4px 8px 6px;
}

.account-pop-item {
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: right;
  color: var(--text);
  transition: background 0.12s;
}

.account-pop-item span {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.account-pop-item strong {
  font-size: 13px;
}

.account-pop-item small {
  font-size: 11px;
  color: var(--text-muted);
}

.account-pop-item:hover {
  background: var(--bg);
}

.account-pop-item.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.shell-body {
  display: flex;
  flex: 1;
  min-width: 0;
}

/* Retractable Slim Icon Rail (64px default <-> 214px expanded — Exact LinkHMS Polish) */
.sidebar-rail {
  width: 64px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-left: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
  position: sticky;
  top: 54px;
  height: calc(100vh - 54px);
  z-index: 30;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1), padding 0.22s ease;
  overflow-x: hidden;
}

.sidebar-rail.is-expanded {
  width: 214px;
  padding: 12px 12px;
}

.rail-toggle-row {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid #E3E9F2;
}

.sidebar-rail.is-expanded .rail-toggle-row {
  justify-content: space-between;
  padding-right: 4px;
}

.rail-toggle-label {
  display: none;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-subtle);
  white-space: nowrap;
}

.sidebar-rail.is-expanded .rail-toggle-label {
  display: inline;
}

.rail-toggle-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid #DCE4EF;
  background: #FFFFFF;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.rail-toggle-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.sidebar-rail.is-expanded .rail-toggle-btn svg {
  transform: rotate(180deg);
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.rail-divider {
  height: 1px;
  background: #E2E8F0;
  margin: 6px 6px;
}

.rail-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  height: 42px;
  padding: 0 10px;
  border-radius: 11px;
  border: none;
  background: transparent;
  color: #5B6B7F;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  transition: all 0.15s ease;
}

.sidebar-rail.is-expanded .rail-item {
  justify-content: flex-start;
  padding: 0 12px;
}

.rail-item:hover {
  background: rgba(255, 255, 255, 0.78);
  color: var(--primary);
}

.rail-item.active {
  background: #FFFFFF;
  color: var(--primary);
  box-shadow: 0 2px 7px rgba(19, 81, 112, 0.08);
  font-weight: 700;
}

.rail-item.active::before {
  content: '';
  position: absolute;
  right: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 99px;
  background: var(--primary);
}

.rail-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rail-label,
.rail-badge {
  display: none;
}

.sidebar-rail.is-expanded .rail-label {
  display: inline;
}

.sidebar-rail.is-expanded .rail-badge {
  display: inline-flex;
  margin-right: auto;
  background: var(--sidebar-badge-bg);
  color: var(--sidebar-badge-text);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
}

.sidebar-rail.is-expanded .rail-item.active .rail-badge {
  background: var(--sidebar-active-badge-bg);
  color: var(--sidebar-active-badge-text);
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 18px 24px 36px;
  max-width: 1540px;
  margin: 0 auto;
}

/* Crisp Rectangular Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-input);
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.14s;
}

.btn:hover {
  background: #F8FAFC;
  border-color: #94A3B8;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--btn-primary-bg);
  border-color: var(--btn-primary-border);
  color: var(--btn-primary-text);
}

.btn-primary:hover {
  background: var(--btn-primary-hover);
  border-color: var(--btn-primary-hover);
}

.btn-success {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

.btn-success:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #FFFFFF;
}

.btn-danger-outline {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger);
}

.btn-whatsapp {
  background: #F8FAFC;
  border-color: #CBD5E1;
  color: var(--navy);
}

.btn-whatsapp:hover {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

.btn-quiet {
  background: #F8FAFC;
  border-color: var(--border);
  color: #475569;
}

.btn-quiet:hover {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11.5px;
  border-radius: 3px;
}

.input, .select, .textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-input);
  background: #FFFFFF;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 116, 184, 0.12);
}

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

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 5px;
}

.phone-hint {
  font-size: 11.5px;
  margin-top: 4px;
  font-weight: 600;
}
.phone-hint.ok { color: var(--primary); }
.phone-hint.err { color: var(--danger); }

/* Cards & Grids */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--navy);
}

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

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  margin-top: 4px;
  line-height: 1.2;
}

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Badges & Chips (Zero Green, Zero Purple) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-blue { background: var(--primary-soft); color: var(--primary); border: 1px solid var(--primary-border); }
.badge-green { background: #E0F2FE; color: #075985; border: 1px solid #BAE6FD; }
.badge-completed-solid { background: var(--primary); color: #FFFFFF; border: 1px solid var(--primary-hover); font-weight: 700; }
.badge-amber { background: var(--warning-soft); color: #B45309; border: 1px solid #FDE68A; }
.badge-red { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-border); }
.badge-slate { background: #F1F5F9; color: #475569; border: 1px solid #E2E8F0; }
.badge-purple { background: #E0F2FE; color: #0369A1; border: 1px solid #BAE6FD; }

/* Alert Chips (STRICTLY Medical Alerts) */
.alert-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  background: var(--danger);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
}

.alert-chip.chronic {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

/* Rectangular Pills & Tabs */
.pill-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pill-btn {
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.14s;
}

.pill-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pill-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

.tabs-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
  overflow-y: hidden;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 10px 15px;
  font-weight: 600;
  font-size: 13.5px;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--navy);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #FFFFFF;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: right;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-subtle);
  padding: 10px 14px;
  border-bottom: 1px solid #E6ECF4;
  background: #FAFBFD;
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #F4F7FB;
  vertical-align: middle;
  color: var(--text);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: #F8FBFF;
}

.clickable-row {
  cursor: pointer;
}

/* Patients List Table — Aligned Phone (Starts at 0) + Separate WhatsApp Column */
.patients-list-table .pat-phone-td {
  white-space: nowrap;
  text-align: left;
  padding-left: 10px;
}
.patients-list-table .pat-phone-num {
  display: inline-block;
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.patients-list-table .pat-wa-td {
  text-align: right;
  padding-right: 10px;
  white-space: nowrap;
}

/* Visit-Date-Grouped Procedure Rows — Theme 3 (Navy & Gold Duo) + Variation #4 (Solid / Dash-Dot) */
.op-row-completed,
.op-row-planned,
.op-row-condition {
  background: #FFFFFF;
}
.op-row-completed:hover,
.op-row-planned:hover,
.op-row-condition:hover {
  background: #EEF6FF !important;
}

.compact-ops-table tr.op-date-group-start td {
  border-top: 2px solid #E2EAF4;
}
.compact-ops-table tr.op-date-group-cont td {
  border-top: 1px solid #F1F5FA;
}
.compact-ops-table tbody tr:first-child td {
  border-top: none;
}

.compact-ops-table tbody tr td:first-child {
  position: relative;
  padding-right: 16px;
}
.compact-ops-table tbody tr td:first-child::before {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  pointer-events: none;
}

.compact-ops-table tr.op-date-grp-0 { background: #FFFFFF; }
.compact-ops-table tr.op-date-grp-0 td:first-child::before {
  background: #1D72B8;
}

.compact-ops-table tr.op-date-grp-1 { background: #F8FAFC; }
.compact-ops-table tr.op-date-grp-1 td:first-child::before {
  background: repeating-linear-gradient(to bottom, #64748B 0 11px, transparent 11px 15px, #64748B 15px 18px, transparent 18px 22px);
}

.compact-ops-table tr.op-date-grp-2 { background: #FFFFFF; }
.compact-ops-table tr.op-date-grp-2 td:first-child::before {
  background: #B45309;
}

.compact-ops-table tr.op-date-grp-3 { background: #F8FAFC; }
.compact-ops-table tr.op-date-grp-3 td:first-child::before {
  background: repeating-linear-gradient(to bottom, #0F294A 0 11px, transparent 11px 15px, #0F294A 15px 18px, transparent 18px 22px);
}

.compact-ops-table tr.op-complaint-row {
  background: #F3F8FE;
}
.compact-ops-table tr.op-complaint-row td {
  font-family: inherit;
}
.compact-ops-table tr.op-checkup-row {
  background: #FAFBFD;
}
.compact-ops-table tr.op-checkup-row td {
  font-family: inherit;
}
.compact-ops-table tr[data-op-expand-row] {
  display: none;
}
.compact-ops-table tr[data-op-expand-row].is-open {
  display: table-row;
}

.med-pain-dep-field {
  transition: opacity 0.16s ease;
}
.med-pain-dep-field.med-pain-locked {
  opacity: 0.42;
  pointer-events: none;
  user-select: none;
}

/* Operations Log Header & Complaints/Checkups Toggle Switch */
.ops-log-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
  background: #FAFBFD;
}
.ops-log-title {
  color: var(--navy);
  font-size: 14.5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.ops-cmp-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
}
@media (max-width: 768px) {
  .ops-log-header {
    padding: 10px 12px;
    gap: 8px;
  }
  .ops-log-title {
    font-size: 13.5px;
  }
  .ops-cmp-switch {
    gap: 6px;
    font-size: 11.5px;
  }
}
.ops-cmp-switch-track {
  position: relative;
  width: 34px;
  height: 19px;
  border-radius: 999px;
  background: #CBD5E1;
  transition: background 0.18s ease;
  flex-shrink: 0;
}
.ops-cmp-switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 2px rgba(15, 41, 74, 0.25);
  transition: transform 0.18s ease;
}
.ops-cmp-switch.is-on .ops-cmp-switch-track {
  background: var(--primary);
}
.ops-cmp-switch.is-on .ops-cmp-switch-track::after {
  transform: translateX(-15px);
}

/* Calendar Layout */
.calendar-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}

.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  text-align: center;
}

.mini-cal-dow {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 4px 0;
}

.mini-cal-day {
  border: none;
  background: transparent;
  border-radius: 4px;
  padding: 6px 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  position: relative;
}

.mini-cal-day:hover {
  background: var(--primary-soft);
}

.mini-cal-day.active {
  background: var(--primary);
  color: #fff;
}

.mini-cal-day.friday {
  color: #B91C1C;
  background: #FEF2F2;
  font-weight: 700;
}

.mini-cal-day.has-apts::after {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--success);
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
}

.slots-board {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.slot-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  min-height: 54px;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.15s;
}

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

.slot-row.drag-over {
  background: #DBEAFE !important;
  outline: 2px dashed var(--primary);
}

.slot-time {
  background: #F8FAFC;
  border-left: 1px solid var(--border-soft);
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot-body {
  padding: 6px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  position: relative;
}

.slot-empty-btn {
  border: 1px dashed transparent;
  background: transparent;
  color: #64748B;
  width: 100%;
  height: 100%;
  min-height: 40px;
  text-align: right;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  transition: all 0.15s;
}

.slot-empty-btn:hover {
  border-color: #93C5FD;
  background: var(--primary-soft);
  color: var(--primary);
}

.apt-card {
  flex: 1;
  min-width: 240px;
  border: 1px solid var(--border);
  border-right: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: grab;
  transition: box-shadow 0.15s;
}

.apt-card:hover {
  box-shadow: var(--shadow);
}

.apt-card.status-arrived { border-right-color: var(--warning); background: #FFFDF7; }
.apt-card.status-done { border-right-color: var(--primary); background: #F4F9FD; }
.apt-card.status-cancelled { border-right-color: #94A3B8; opacity: 0.65; }
.apt-card.status-noshow { border-right-color: var(--danger); opacity: 0.85; }

.week-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 10px;
  overflow-x: auto;
}

.week-col {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #F8FAFC;
  padding: 10px;
  min-height: 260px;
}

.week-col-header {
  font-weight: 700;
  font-size: 13px;
  color: var(--navy);
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Patient Profile Header & Full-Width Layout (LinkHMS Clean Hierarchy) */
.patient-sticky-header {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 22px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.patient-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.patient-identity-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.btn-icon-back {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #F8FAFC;
  color: var(--navy);
  font-size: 16px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.14s;
}

.btn-icon-back:hover {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

.patient-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.patient-identity-text {
  min-width: 0;
}

.patient-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.patient-name-title {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.25;
}

.patient-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.patient-meta-row .meta-sep {
  color: #CBD5E1;
}

.patient-wa-link {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  transition: all 0.14s;
}

.patient-wa-link:hover {
  background: var(--primary);
  color: #FFFFFF;
}

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

.patient-balance-pill {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.patient-balance-pill.has-due {
  background: var(--warning-soft);
  border-color: #FDE68A;
  color: #B45309;
}

.patient-balance-pill.is-clear {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

.patient-balance-pill .balance-lbl {
  font-size: 11.5px;
  font-weight: 600;
  opacity: 0.85;
}

.patient-balance-pill .balance-val {
  font-size: 14px;
  font-weight: 700;
}

.patient-btn-group {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.btn-icon-pill {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #F8FAFC;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.14s;
}

.btn-icon-pill:hover {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

/* LinkHMS Clean Underline Tabs */
.lh-underline-tabs {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  border-bottom: 1.5px solid var(--border) !important;
  gap: 6px !important;
  margin-bottom: 16px;
}

.lh-underline-tabs .tab-btn {
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border-bottom: 2.5px solid transparent !important;
  margin-bottom: -1.5px !important;
  padding: 10px 16px !important;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
}

.lh-underline-tabs .tab-btn:hover {
  color: var(--navy);
}

.lh-underline-tabs .tab-btn.active {
  color: var(--primary) !important;
  border-bottom-color: var(--primary) !important;
  font-weight: 700;
}

/* Compact Single-Line Procedure Table & Tiny Icon Buttons */
.compact-ops-table td {
  padding: 8px 12px;
}

.compact-row-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.row-icon-btn {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.13s;
}

.row-icon-btn:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
}

.row-icon-btn.is-done {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

.row-icon-btn.is-danger:hover {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

/* ==========================================================================
   LinkHMS Open-Canvas System, Page Header, Controls, Schedule Grid & EMR
   ========================================================================== */

.lhms-screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lhms-card {
  background: #FFFFFF;
  border: 1px solid #E6ECF4;
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(15, 35, 60, 0.035);
}

/* Open-Canvas Page Header Bar */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 2px 2px 4px;
}

.page-title-block {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  flex: 1 1 auto;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  position: relative;
  flex-shrink: 0;
}

.back-chevron {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.back-chevron:hover {
  background: var(--primary-soft);
}

.entity-badge-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #FFFFFF;
  border: 1px solid #E6ECF4;
  color: var(--navy);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  font-weight: 800;
  font-size: 15px;
  flex-shrink: 0;
}

.page-h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.page-sub {
  font-size: 12.5px;
  color: var(--text-subtle);
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Controls Row & LinkHMS Action Buttons */
.controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  position: relative;
  flex-shrink: 0;
}

@media (min-width: 1060px) {
  .page-header {
    flex-wrap: nowrap;
  }
}

.btn-soft-blue {
  background: #EAF4FD;
  color: var(--primary);
  border: 1px solid #D3E7FA;
  border-radius: 9px;
  padding: 7.5px 14px;
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-soft-blue:hover {
  background: #D6EBFC;
}

.date-picker-btn {
  background: #FFFFFF;
  border: 1px solid #DCE4EF;
  border-radius: 10px;
  padding: 7.5px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease;
}

.date-picker-btn:hover {
  border-color: var(--primary);
}

.btn-pill-primary {
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  border-radius: 999px;
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(29, 114, 184, 0.24);
  transition: all 0.15s ease;
}

.btn-pill-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-pill-outline {
  background: #FFFFFF;
  color: var(--text);
  border: 1px solid #D8E2EE;
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-pill-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Month Picker Popover (LinkHMS Exact Rounded Card + Pill Grid) */
.month-picker-wrap {
  position: relative;
}

.month-picker-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 236px;
  background: #FFFFFF;
  border: 1px solid #E6ECF4;
  border-radius: 14px;
  box-shadow: 0 14px 32px rgba(15, 35, 60, 0.14);
  padding: 14px;
  z-index: 55;
}

.mp-year-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
  font-size: 13.5px;
  margin-bottom: 12px;
  color: var(--text);
}

.mp-months-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.mp-month-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 7px 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}

.mp-month-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.mp-month-btn.active {
  background: var(--primary);
  color: #FFFFFF;
}

/* Week / Day Mode Switcher Pill */
.lh-mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #F1F5FA;
  border: 1px solid #E6ECF4;
  border-radius: 999px;
  padding: 3px;
}

.lh-mode-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.lh-mode-btn:hover {
  color: var(--primary);
}

.lh-mode-btn.active {
  background: #FFFFFF;
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(19, 81, 112, 0.12);
}

/* Open-Canvas Status Legend Row (Directly on #F5F7FB, Zero Green) */
.status-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 4px;
}

.sl-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sl-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  flex-shrink: 0;
}

/* LinkHMS Schedule Matrix Table */
.schedule-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  position: relative;
  border-radius: 16px;
}

.schedule-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  table-layout: fixed;
}

.schedule-table th {
  height: 44px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid #E6ECF4;
  border-left: 1px solid #EDF1F7;
  background: #FFFFFF;
  text-align: center;
}

.schedule-table th:first-child {
  width: 162px;
  text-align: right;
  padding-right: 18px;
  border-left: 2px solid #E5ECF5;
}

.schedule-table th:last-child,
.schedule-table td:last-child {
  border-left: none;
}

.schedule-table th.active-slot {
  background: #EEF6FE;
  color: var(--primary);
}

.schedule-table td {
  height: 58px;
  border-bottom: 1px solid #EDF1F7;
  border-left: 1px solid #EDF1F7;
  padding: 5px 6px;
  vertical-align: middle;
  position: relative;
  background: #FFFFFF;
}

.schedule-table tbody tr:last-child td {
  border-bottom: none;
}

.schedule-table td:first-child {
  padding: 0 18px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  border-left: 2px solid #E5ECF5;
  background: #FFFFFF;
}

.schedule-table td.lh-date-cell {
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s ease, color 0.14s ease;
}

.schedule-table td.lh-date-cell:hover {
  background: #F4F9FE;
  color: var(--primary);
}

.schedule-table tr.today-row td:first-child {
  background: #EEF6FE;
  color: var(--primary);
  font-weight: 700;
}

.schedule-table tr.off-day td:first-child {
  background: #FEF2F2;
  color: #B91C1C;
  font-weight: 700;
  border-right: 3.5px solid #DC2626;
}

.schedule-table tr.off-day td:first-child:hover {
  background: #FEE2E2;
  color: #991B1B;
}

.lh-off-pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  background: #FEE2E2;
  color: #B91C1C;
  border: 1px solid #FCA5A5;
  line-height: 1.45;
}

.schedule-table tr.off-day td.lh-off-span,
.schedule-table td.lh-slot-td.is-off {
  background: repeating-linear-gradient(
    -45deg,
    #FFF5F5,
    #FFF5F5 6px,
    #FEE2E2 6px,
    #FEE2E2 8.5px
  );
  border-left: none;
  padding: 0;
}

.schedule-table tr.off-day td.lh-slot-td {
  background: #FFF9F9;
}

.schedule-table td.lh-slot-td {
  transition: background 0.12s ease;
}

.schedule-table td.lh-slot-td.drag-over,
.lh-slot-td.drag-over {
  background: #DCEEFF !important;
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
}

.lh-cell-inner {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 46px;
  height: 100%;
  position: relative;
}

.lh-cell-add {
  border: 1px dashed transparent;
  background: transparent;
  color: var(--primary);
  opacity: 0;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 700;
  padding: 0;
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.14s ease, background 0.14s ease, border-color 0.14s ease;
}

.lh-slot-td:hover .lh-cell-add {
  opacity: 1;
  border-color: var(--primary-border);
  background: var(--primary-soft);
}

/* Calm Multi-Color Pastel Appointment Chips (Crisp 1px Border, Zero Green, Zero Purple) */
.appt-chip {
  border-radius: 9px;
  padding: 6px 10px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.14s ease;
  line-height: 1.25;
  border: 1px solid transparent;
}

.appt-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(19, 81, 112, 0.12);
}

.appt-name {
  font-size: 12px;
  font-weight: 700;
  color: #0F294A;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
}

.appt-name-left {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appt-name-left span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.appt-st-check {
  color: #0F294A;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  flex-shrink: 0;
}

.appt-st-miss {
  color: #B91C1C;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1;
  flex-shrink: 0;
}

.appt-proc-label {
  font-size: 10px;
  font-weight: 700;
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
  min-width: 0;
}

.appt-chip.is-noshow,
.lh-day-apt-card.is-noshow {
  opacity: 0.78;
}

/* Sleek Serenity Floating Appointment Hover Card (Replaces Native Black OS Tooltip) */
.apt-hover-card {
  position: fixed;
  z-index: 190;
  width: 300px;
  max-width: calc(100vw - 24px);
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(15, 35, 60, 0.18);
  overflow: hidden;
  pointer-events: none;
  direction: rtl;
}

.ahc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid #E2EAF4;
}

.ahc-body {
  padding: 9px 12px 10px;
}

.ahc-ops {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid #EDF1F7;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ahc-op-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--navy);
}

.ahc-op-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ahc-note {
  margin-top: 7px;
  padding: 5px 8px;
  border-radius: 7px;
  background: #F8FAFC;
  border-right: 2.5px solid var(--primary);
  font-size: 11.5px;
  color: #475569;
  line-height: 1.45;
}

.appt-phone {
  font-size: 10.5px;
  color: #64748B;
  margin-top: 1px;
  direction: ltr;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lh-apt-alert-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #DC2626;
  flex-shrink: 0;
}

.lh-day-apt-card {
  flex: 1;
  min-width: 240px;
  border: 1px solid #E6ECF4;
  border-radius: 10px;
  padding: 10px 14px;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.14s ease;
}

.lh-day-apt-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(19, 81, 112, 0.1);
}

.appt-confirmed,
.lh-day-apt-card.appt-confirmed { background: #DCEEFF; border-color: #BBDDFB; }
.appt-completed,
.lh-day-apt-card.appt-completed { background: #E6EEF8; border-color: #C3D5EB; }
.appt-conflict,
.lh-day-apt-card.appt-conflict  { background: #FDE8E8; border-color: #F8C4C4; }

.appt-chip.is-menu-open,
.lh-day-apt-card.is-menu-open {
  box-shadow: 0 0 0 2px var(--primary), 0 6px 14px rgba(19, 81, 112, 0.16);
}

.cal-legends-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.cal-legend-sep {
  width: 1px;
  height: 16px;
  background: #DCE4EF;
  display: inline-block;
}

.cal-vtype-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.cal-vtype-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--navy);
}

.vt-swatch-bar {
  width: 4px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
}

.appt-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  margin-top: 3px;
  min-width: 0;
}

.appt-vtype-tag {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.55;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.same-day-warn-box {
  background: #FEF6DC;
  border: 1.5px solid #EAB308;
  border-right: 4px solid #D97706;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12px;
  color: #78350F;
  line-height: 1.55;
}

.proc-cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.45;
  white-space: nowrap;
  vertical-align: middle;
}

.proc-cat-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  display: inline-block;
  flex-shrink: 0;
}

.lh-empty-friday {
  text-align: center;
  padding: 46px 20px;
  border: 1px solid #FECACA;
  border-radius: 12px;
  background: repeating-linear-gradient(
    -45deg,
    #FFF5F5,
    #FFF5F5 6px,
    #FEE2E2 6px,
    #FEE2E2 8.5px
  );
}

/* Global Serenity Arabic Date Picker Popover (Highlights Friday ONLY in Red as Clinic Off-Day) */
.sdp-popover {
  position: fixed;
  z-index: 260;
  width: 282px;
  background: #FFFFFF;
  border: 1px solid #DCE4EF;
  border-radius: 14px;
  box-shadow: 0 16px 38px rgba(15, 35, 60, 0.20);
  padding: 12px;
  direction: rtl;
  user-select: none;
}

.sdp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  margin-bottom: 10px;
}

.sdp-nav-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid #E2EAF4;
  background: #F8FAFD;
  color: var(--navy);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.12s ease;
}

.sdp-nav-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.sdp-sel-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.sdp-sel {
  border: 1px solid #E2EAF4;
  background: #F8FAFD;
  color: var(--navy);
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.sdp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  text-align: center;
}

.sdp-dow {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 4px 0 5px;
  border-radius: 6px;
}

.sdp-dow.is-friday {
  color: #B91C1C;
  background: #FEF2F2;
}

.sdp-day {
  height: 31px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--navy);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
}

.sdp-day:hover:not(:disabled) {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

.sdp-day.is-today {
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 800;
}

.sdp-day.is-friday {
  color: #B91C1C;
  background: repeating-linear-gradient(
    -45deg,
    #FFF5F5,
    #FFF5F5 4px,
    #FEE2E2 4px,
    #FEE2E2 6px
  );
  border-color: #FECACA;
  font-weight: 700;
}

.sdp-day.is-friday:hover:not(:disabled) {
  background: #FEE2E2;
  border-color: #DC2626;
  color: #991B1B;
}

.sdp-day.is-selected {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #FFFFFF !important;
  font-weight: 700;
}

.sdp-day.is-friday.is-selected {
  background: #DC2626 !important;
  border-color: #B91C1C !important;
  color: #FFFFFF !important;
}

.sdp-day:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.sdp-footer {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid #EDF1F7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

/* Unified Arabic Day-Month-Year Display Wrapper for ALL <input type="date"> across the app */
.sdp-field-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  min-height: 35px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #FFFFFF;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
  box-sizing: border-box;
  direction: rtl;
}

.sdp-field-wrap:hover {
  border-color: var(--primary-border);
}

.sdp-field-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 114, 184, 0.12);
}

.sdp-field-wrap.is-empty .sdp-field-text {
  color: var(--text-subtle);
  font-weight: 500;
}

.sdp-field-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  flex: 1;
  text-align: right;
}

.sdp-field-icon {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  pointer-events: none;
}

.sdp-field-wrap > input[type="date"].sdp-native-hidden {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  opacity: 0;
  cursor: pointer;
  margin: 0;
  padding: 0;
  border: none;
}

.sdp-fri-legend {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 700;
  color: #B91C1C;
}

.sdp-fri-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #DC2626;
  display: inline-block;
}

/* Patient EMR Sub-Tabs (Clean LinkHMS Underline Tabs) */
.emr-tabs {
  display: flex;
  align-items: center;
  gap: 26px;
  border-bottom: 1px solid #E6ECF4;
  padding: 0 6px;
  overflow-x: auto;
  overflow-y: hidden;
}

.emr-tab {
  border: none;
  background: transparent;
  padding: 10px 4px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-subtle);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  transition: color 0.14s ease;
}

.emr-tab:hover {
  color: var(--primary);
}

.emr-tab.active {
  color: var(--primary);
  font-weight: 700;
}

.emr-tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2.5px;
  border-radius: 99px;
  background: var(--primary);
}

/* Allergy & Balance Chips */
.allergy-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #FEF2F2;
  color: #B91C1C;
  border: 1px solid #FECACA;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.4;
}

.allergy-chip.is-chronic {
  background: #FEF6DC;
  color: #9A6700;
  border-color: #F6DF9B;
}

.balance-chip {
  display: inline-flex;
  align-items: center;
  background: #EAF4FD;
  border: 1px solid #CBE4FA;
  color: #135170;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}

.balance-chip.has-due {
  background: #FEF6DC;
  border-color: #F6DF9B;
  color: #9A6700;
}

/* Chart Card Bar & Segmented Dentition Switch */
.chart-box {
  padding: 16px 18px 18px;
}

.chart-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid #F1F5F9;
}

.seg-group {
  display: inline-flex;
  background: #F1F5FA;
  padding: 3px;
  border-radius: 999px;
  gap: 3px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 5.5px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.14s ease;
}

.seg-btn:hover {
  color: var(--primary);
}

.seg-btn.active {
  background: var(--primary);
  color: #FFFFFF;
}

/* LinkHMS 2x2 EMR Summary Grid */
.emr-2x2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.mini-card {
  padding: 16px 18px;
}

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

.mini-card-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}

.mini-link {
  border: none;
  background: transparent;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.14s ease;
}

.mini-link:hover {
  background: var(--primary-soft);
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.mini-table th {
  text-align: right;
  font-size: 11.5px;
  color: var(--text-subtle);
  font-weight: 600;
  padding: 6px 8px;
  border-bottom: 1px solid #EDF1F7;
}

.mini-table td {
  padding: 9px 8px;
  border-bottom: 1px solid #F4F7FB;
  color: var(--text);
  vertical-align: middle;
}

.mini-table tr:last-child td {
  border-bottom: none;
}

.tag-chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.tag-blue  { background: #E8F4FD; color: #155B96; }
.tag-amber { background: #FEF6DC; color: #9A6700; }
.tag-coral { background: #FEECEC; color: #B91C1C; }
.tag-slate { background: #EEF2F7; color: #334155; }

/* Floating LinkHMS Appointment Context Menu */
.apt-context-menu {
  position: fixed;
  width: 236px;
  background: #FFFFFF;
  border: 1px solid #E6ECF4;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(15, 35, 60, 0.16);
  padding: 6px;
  z-index: 90;
}

.acm-header {
  padding: 7px 10px 8px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 4px;
}

.acm-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.acm-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 5px 4px;
}

.acm-item {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: right;
  text-decoration: none;
  transition: background 0.12s;
}

.acm-item:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.acm-item.is-current {
  background: var(--bg);
  color: var(--primary);
  font-weight: 700;
}

.acm-item.is-danger {
  color: var(--danger);
}

.acm-item.is-danger:hover {
  background: var(--danger-soft);
}

.acm-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-sky { background: #E3F4FA; color: #0369A1; border: 1px solid #BAE6FD; }
.badge-navy { background: #E6EEF8; color: #135170; border: 1px solid #CBDDF2; }

.patient-alerts-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}

.alerts-strip-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--danger);
}

/* Full-Width Profile Stack (Odontogram spans 100%, Visit Timeline underneath) */
.profile-full-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.timeline-bottom-card {
  padding: 16px 20px;
}

.timeline-grid-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 10px;
}

.timeline-grid-item {
  background: #F8FAFC;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.timeline-dot-inline {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #94A3B8;
  margin-top: 5px;
  flex-shrink: 0;
}

.timeline-dot-inline.op-done { background: var(--primary); }
.timeline-dot-inline.payment { background: var(--teal); }
.timeline-dot-inline.rx { background: #64748B; }
.timeline-dot-inline.consent { background: #94A3B8; }

/* Full-Width Borderless Anatomical Dental Chart (Dentolize-Grade Open Canvas) */
.odonto-card {
  padding: 16px 18px;
}

.odonto-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.odonto-stage {
  direction: ltr;
  background: linear-gradient(180deg, #FFF9FA 0%, #FFFDFD 24%, #FFFFFF 42%, #FFFFFF 58%, #FFFDFD 76%, #FFF9FA 100%);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 14px 12px 12px;
  margin-bottom: 14px;
}

.odonto-arch-caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  font-weight: 600;
  color: #64748B;
  padding: 0 6px 6px;
}

.odonto-arch {
  display: flex;
  align-items: stretch;
  justify-content: center;
  width: 100%;
}

.odonto-quad {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  flex: 1;
  gap: 0;
}

.odonto-stage.is-pedo .odonto-quad {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  max-width: 440px;
}

.odonto-midline {
  width: 1px;
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.12) 0%, rgba(148, 163, 184, 0.45) 50%, rgba(148, 163, 184, 0.12) 100%);
  margin: 4px 2px;
  flex-shrink: 0;
}

.odonto-horizontal-divider {
  height: 1px;
  background: #E8EDF4;
  margin: 2px 4px;
}

.odonto-tooth {
  border: none;
  background: transparent;
  padding: 2px 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.14s ease;
  position: relative;
  min-width: 0;
}

.odonto-tooth:hover {
  background: rgba(11, 116, 184, 0.06);
}

.odonto-tooth.selected {
  background: rgba(11, 116, 184, 0.10);
  box-shadow: inset 0 0 0 1.5px rgba(11, 116, 184, 0.36);
}

.odonto-svg-wrap {
  width: 100%;
  display: block;
  line-height: 0;
}

.tooth-full-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.tooth-full-svg [data-surf] {
  transition: opacity 0.12s ease;
}

.tooth-full-svg [data-surf]:hover {
  opacity: 0.78;
}

/* Floating Clinical Tooth Hover Card (Shows All Procedures, Date, Price & Notes on Hover) */
.tooth-hover-card {
  position: fixed;
  z-index: 185;
  width: 336px;
  max-width: calc(100vw - 24px);
  max-height: 70vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  border-radius: 14px;
  box-shadow: 0 16px 38px rgba(15, 35, 60, 0.20);
  pointer-events: auto;
  direction: rtl;
}

.thc-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: #F0F7FF;
  border-bottom: 1px solid #DCE8F6;
}

.thc-list {
  display: flex;
  flex-direction: column;
}

.thc-item {
  padding: 9px 12px;
  border-bottom: 1px solid #EDF1F7;
}

.thc-item:last-child {
  border-bottom: none;
}

.thc-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.thc-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.35;
}

.thc-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

.thc-note {
  margin-top: 5px;
  padding: 5px 8px;
  border-radius: 6px;
  background: #F8FAFC;
  border-right: 2.5px solid var(--primary);
  font-size: 11.5px;
  color: #334155;
  line-height: 1.5;
  white-space: pre-line;
}

.odonto-tooth-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 2px 6px;
  margin: 3px 0;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  transition: all 0.14s;
}

.odonto-tooth-code.has-ops {
  background: #E0F2FE;
  color: #075985;
  font-weight: 700;
}

.odonto-tooth-code.has-cond {
  background: #FEF2F2;
  color: #B91C1C;
  font-weight: 700;
}

.odonto-tooth-code.selected {
  background: var(--primary) !important;
  color: #FFFFFF !important;
  font-weight: 700;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11.5px;
  padding: 2px 4px;
  background: transparent;
  border: none;
  margin-bottom: 8px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: #5B677A;
}

.legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}

.mobile-tooth-fallback {
  display: none;
}

.under-chart-panel {
  border: 1.5px solid var(--primary-border);
  background: #F8FBFE;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 4px;
}

/* LinkHMS Tooth Quick-Entry Slide-Over Side Drawer (Zero Page Scroll!) */
.tooth-readout {
  margin-top: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  background: #F8FAFD;
  border: 1px solid #E6ECF4;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.tooth-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 35, 60, 0.24);
  z-index: 94;
  display: flex;
  justify-content: flex-end;
  animation: tdFadeIn 0.14s ease;
}

.tooth-drawer {
  width: 440px;
  max-width: 96vw;
  height: 100%;
  max-height: 100%;
  background: #FFFFFF;
  border-right: 1px solid #E6ECF4;
  box-shadow: 8px 0 32px rgba(15, 35, 60, 0.16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: tdSlideIn 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes tdFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes tdSlideIn {
  from { transform: translateX(-28px); opacity: 0.7; }
  to { transform: translateX(0); opacity: 1; }
}

.td-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid #E6ECF4;
  background: #FFFFFF;
  flex-shrink: 0;
}

.td-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.td-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.td-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.td-proc-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 196px;
  overflow-y: auto;
  border: 1px solid #E6ECF4;
  border-radius: 10px;
  padding: 5px;
  background: #FAFBFD;
}

.td-proc-row {
  width: 100%;
  border: 1px solid transparent;
  background: #FFFFFF;
  border-radius: 8px;
  padding: 6px 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: right;
  transition: all 0.12s ease;
}

.td-proc-row:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft);
}

.td-proc-row.active {
  border-color: var(--primary);
  background: #EAF4FD;
  box-shadow: inset 0 0 0 1px rgba(29, 114, 184, 0.25);
}

.td-proc-name {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  direction: ltr;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.td-proc-price {
  font-size: 11.5px;
  color: var(--primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.td-extras-toggle {
  width: 100%;
  border: 1px dashed #CBD5E1;
  background: #F8FAFD;
  color: var(--text-muted);
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: all 0.14s ease;
}

.td-extras-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.td-history-box {
  background: #FAFBFD;
  border: 1px solid #E6ECF4;
  border-radius: 10px;
  padding: 9px 11px;
}

.td-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #EDF1F7;
}

.td-history-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.td-footer {
  padding: 12px 16px;
  border-top: 1px solid #E6ECF4;
  background: #FFFFFF;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.proc-pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 8px;
  max-height: 230px;
  overflow-y: auto;
  padding: 4px 2px;
}

.proc-pick-btn {
  border: 1px solid var(--border);
  background: #FFFFFF;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: all 0.14s;
}

.proc-pick-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.proc-pick-btn.active {
  border: 2px solid var(--primary);
  background: #E0F2FE;
}

.cost-pay-strip {
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Medical History Checkboxes */
.med-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  background: #FFFFFF;
}

.med-check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.med-check-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #F8FAFC;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
}

.med-check-pill:has(input:checked) {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--navy);
  font-weight: 600;
}

/* Rx Quick Chips & Safety Banners */
.rx-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rx-chip {
  border: 1px solid var(--border);
  background: #F8FAFC;
  color: var(--text);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}

.rx-chip:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.safety-banner {
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  margin-bottom: 10px;
  border: 1px solid var(--danger-border);
  background: var(--danger-soft);
  color: #991B1B;
}

.safety-banner.warning {
  border-color: #FDE68A;
  background: var(--warning-soft);
  color: #92400E;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 105;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: #FFFFFF;
  border-radius: var(--radius);
  width: 100%;
  max-width: 650px;
  max-height: 100%;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 18px 20px;
}

.modal-card.wide {
  max-width: 840px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

/* Searchable Patient Combobox Dropdown (Handles 772+ patients effortlessly) */
.patient-combobox {
  position: relative;
}

.pc-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.pc-search-icon {
  position: absolute;
  right: 11px;
  color: var(--text-subtle);
  display: inline-flex;
  pointer-events: none;
}

.pc-search-input {
  padding-right: 34px !important;
  padding-left: 34px !important;
}

.pc-clear-btn {
  position: absolute;
  left: 8px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: none;
  background: #EDF1F7;
  color: var(--text-muted);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.pc-clear-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.pc-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(15, 35, 60, 0.14);
  padding: 5px;
  z-index: 95;
}

.pc-option {
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: right;
  cursor: pointer;
  transition: background 0.12s ease;
}

.pc-option:hover,
.pc-option.active {
  background: var(--primary-soft);
}

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

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

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

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 72px;
  left: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--navy);
  color: #FFFFFF;
  padding: 10px 15px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
  max-width: 390px;
}

.toast.success { background: #0F2D4A; border-right: 4px solid #38BDF8; }
.toast.warning { background: #92400E; }
.toast.danger { background: #991B1B; }

/* Mobile Bottom Nav */
.mobile-bottom-nav {
  display: none;
}

#print-root {
  display: none;
}

/* Doctor-Only Analytics Dashboard */
.analytics-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.analytics-kpi-sub {
  font-size: 12px;
  color: #475569;
  margin-top: 4px;
}

.analytics-bar-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.analytics-bar-track {
  width: 100%;
  height: 9px;
  background: #E2E8F0;
  border-radius: 3px;
  overflow: hidden;
}

.analytics-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.2s ease;
}

.analytics-svg-wrap {
  width: 100%;
  overflow-x: auto;
  padding-top: 4px;
}

/* Visual UI Themes Gallery (Settings) */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.theme-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: #F8FAFC;
  text-align: right;
  transition: all 0.15s;
}

.theme-card:hover {
  border-color: var(--primary);
  background: #FFFFFF;
}

.theme-card.active {
  border: 2px solid var(--primary);
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(11, 116, 184, 0.16);
}

/* Mini Structural Wireframe Previews Inside Settings Theme Gallery */
.theme-wireframe {
  width: 100%;
  height: 58px;
  border-radius: 7px;
  border: 1px solid #CBD5E1;
  background: #F4F7FB;
  padding: 5px;
  display: flex;
  gap: 5px;
  overflow: hidden;
}

.theme-wireframe .wf-side {
  width: 28%;
  background: #FFFFFF;
  border-radius: 4px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border: 1px solid #E2E8F0;
}

.theme-wireframe .wf-nav {
  height: 7px;
  border-radius: 3px;
  background: #E2E8F0;
}

.theme-wireframe .wf-nav.active {
  background: #0B74B8;
}

.theme-wireframe .wf-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theme-wireframe .wf-top {
  height: 8px;
  border-radius: 4px;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
}

.theme-wireframe .wf-cards {
  display: flex;
  gap: 4px;
  height: 13px;
}

.theme-wireframe .wf-cards span {
  flex: 1;
  background: #FFFFFF;
  border-radius: 4px;
  border: 1px solid #E2E8F0;
}

.theme-wireframe .wf-rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.theme-wireframe .wf-rows span {
  height: 6px;
  background: #FFFFFF;
  border-radius: 3px;
  border: 1px solid #E2E8F0;
}

.theme-wireframe.wf-mix .wf-nav.active { background: #D6ECFA; border-right: 2px solid #0B74B8; }

.theme-wireframe.wf-linkhms { background: #F7F8FA; }
.theme-wireframe.wf-linkhms .wf-side { background: #F3F4F6; border-color: #E5E7EB; }
.theme-wireframe.wf-linkhms .wf-nav.active { background: #FFFFFF; border: 1px solid #0B74B8; }

.theme-wireframe.wf-figma { background: #EFF5FB; border-top: 2px solid #0B74B8; }
.theme-wireframe.wf-figma .wf-nav { background: #E8F3FB; border-radius: 5px; }
.theme-wireframe.wf-figma .wf-nav.active { background: #0F2D4A; }
.theme-wireframe.wf-figma .wf-rows span { border-radius: 5px; box-shadow: 0 1px 2px rgba(15, 45, 74, 0.08); }

.theme-wireframe.wf-slate { background: #ECEFF4; padding: 6px; }
.theme-wireframe.wf-slate .wf-side { background: #E5E9F0; border-radius: 6px; border-color: #CBD5E1; }
.theme-wireframe.wf-slate .wf-nav.active { background: #1E293B; }
.theme-wireframe.wf-slate .wf-top { border-radius: 6px; }
.theme-wireframe.wf-slate .wf-cards span { border-right: 2px solid #0B74B8; }

.theme-wireframe.wf-navy { background: #F1F5F9; }
.theme-wireframe.wf-navy .wf-side { background: #0D253F; border-color: #0D253F; }
.theme-wireframe.wf-navy .wf-nav { background: rgba(255, 255, 255, 0.18); }
.theme-wireframe.wf-navy .wf-nav.active { background: #0B74B8; }
.theme-wireframe.wf-navy .wf-cards span { border-top: 2px solid #0D253F; }

/* ==========================================================================
   Structural Theme Layouts (Distinct Navigation, Cards, Tables & Tabs)
   ========================================================================== */

/* 1. Serenity Blue Mix (LinkHMS Crispness + Figma Soft Medical Blue Geometry) */
html[data-theme="serenity_blue_mix"] .btn-primary,
html[data-theme="serenity_blue_mix"] .pill-btn.active {
  border-radius: 9999px;
  padding-left: 16px;
  padding-right: 16px;
}

html[data-theme="serenity_blue_mix"] .tabs-bar {
  background: #ECEFF5;
  padding: 4px;
  border-radius: 10px;
  border-bottom: none;
  gap: 4px;
}

html[data-theme="serenity_blue_mix"] .tab-btn {
  border-radius: 7px;
  border-bottom: none;
  margin-bottom: 0;
  padding: 8px 15px;
}

html[data-theme="serenity_blue_mix"] .tab-btn.active {
  background: #FFFFFF;
  color: #1D72B8;
  box-shadow: 0 1px 3px rgba(15, 45, 74, 0.08);
}

html[data-theme="serenity_blue_mix"] .kpi-icon {
  border-radius: 10px;
  background: #EAF4FD;
  color: #1D72B8;
}

/* 2. LinkHMS Clinical (Cool Gray Sidebar, Crisp 1px Borders, Pill Search & CTAs) */
html[data-theme="linkhms_clinical"] .sidebar {
  width: 236px;
  padding: 14px 10px;
}

html[data-theme="linkhms_clinical"] .nav-item {
  border-radius: 8px;
  border-right: none;
  padding: 9px 11px;
}

html[data-theme="linkhms_clinical"] .nav-item.active {
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  border: 1px solid #E5E7EB;
}

html[data-theme="linkhms_clinical"] .topbar {
  padding: 8px 18px;
  border-bottom: 1px solid #E5E7EB;
}

html[data-theme="linkhms_clinical"] .global-search-btn,
html[data-theme="linkhms_clinical"] .btn-primary {
  border-radius: 9999px;
}

html[data-theme="linkhms_clinical"] .card,
html[data-theme="linkhms_clinical"] .kpi-card {
  box-shadow: none;
  border: 1px solid #E5E7EB;
}

html[data-theme="linkhms_clinical"] .data-table th {
  background: #F9FAFB;
  font-size: 11.5px;
  color: #4B5563;
  border-bottom: 1px solid #E5E7EB;
}

html[data-theme="linkhms_clinical"] .tabs-bar {
  border-bottom: 1.5px solid #E5E7EB;
}

html[data-theme="linkhms_clinical"] .tab-btn.active {
  border-bottom: 2.5px solid #0B74B8;
  background: transparent;
}

/* 3. Figma Airy Cards (Ice-Blue Sidebar Pills, Top Accent Strip, Floating Row Cards) */
html[data-theme="figma_airy_cards"] body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #0EA5C6 0%, #0B74B8 50%, #0F2D4A 100%);
  z-index: 60;
  pointer-events: none;
}

html[data-theme="figma_airy_cards"] .sidebar {
  padding: 18px 14px;
  border-left: none;
  box-shadow: -2px 0 14px rgba(22, 42, 77, 0.05);
}

html[data-theme="figma_airy_cards"] .nav-item {
  background: #EAF0FA;
  color: #1E3A5F;
  border-radius: 10px;
  border-right: none;
  padding: 10px 14px;
  margin-bottom: 2px;
}

html[data-theme="figma_airy_cards"] .nav-item:hover {
  background: #DCE7F8;
  color: #162A4D;
}

html[data-theme="figma_airy_cards"] .nav-item.active {
  background: #162A4D;
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(22, 42, 77, 0.22);
}

html[data-theme="figma_airy_cards"] .kpi-value {
  color: #0B74B8;
  font-size: 23px;
}

html[data-theme="figma_airy_cards"] .kpi-card {
  border: none;
  box-shadow: 0 3px 12px rgba(22, 42, 77, 0.06);
}

html[data-theme="figma_airy_cards"] .card {
  border: 1px solid rgba(219, 230, 245, 0.9);
  box-shadow: 0 4px 14px rgba(22, 42, 77, 0.05);
}

html[data-theme="figma_airy_cards"] .data-table {
  border-collapse: separate;
  border-spacing: 0 7px;
}

html[data-theme="figma_airy_cards"] .data-table th {
  background: transparent;
  border-bottom: none;
  padding: 4px 12px 6px;
  color: #475569;
}

html[data-theme="figma_airy_cards"] .data-table tbody tr {
  background: #FFFFFF;
  box-shadow: 0 1px 5px rgba(22, 42, 77, 0.05);
}

html[data-theme="figma_airy_cards"] .data-table tbody tr:hover td {
  background: #F8FBFF;
}

html[data-theme="figma_airy_cards"] .data-table tbody td {
  border-top: 1px solid #E5EEF9;
  border-bottom: 1px solid #E5EEF9;
  background: #FFFFFF;
}

html[data-theme="figma_airy_cards"] .data-table tbody td:first-child {
  border-right: 1px solid #E5EEF9;
  border-radius: 0 10px 10px 0;
}

html[data-theme="figma_airy_cards"] .data-table tbody td:last-child {
  border-left: 1px solid #E5EEF9;
  border-radius: 10px 0 0 10px;
}

html[data-theme="figma_airy_cards"] .data-table tbody td:only-child {
  border-radius: 10px;
}

html[data-theme="figma_airy_cards"] .data-table tbody tr.op-row-completed td:first-child {
  border-right: 3.5px solid #0B74B8;
}

html[data-theme="figma_airy_cards"] .data-table tbody tr.op-row-planned td:first-child {
  border-right: 3.5px dashed #94A3B8;
}

html[data-theme="figma_airy_cards"] .data-table tbody tr.op-row-condition td:first-child {
  border-right: 3.5px solid #B45309;
}

/* 4. Slate Gray Studio (Floating Detached Sidebar + Topbar + Boxed Tabs) */
@media (min-width: 769px) {
  html[data-theme="slate_gray_studio"] .sidebar {
    width: 240px;
    margin: 12px 10px 12px 0;
    height: calc(100vh - 24px);
    top: 12px;
    border-radius: 14px;
    border: 1px solid #D8DEE9;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  }
  html[data-theme="slate_gray_studio"] .topbar {
    margin: 12px 20px 0;
    border-radius: 12px;
    border: 1px solid #D8DEE9;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
    top: 12px;
  }
}

html[data-theme="slate_gray_studio"] .nav-item {
  border-radius: 8px;
  border-right: none;
}

html[data-theme="slate_gray_studio"] .kpi-card {
  border-right: 3.5px solid #0B74B8;
}

html[data-theme="slate_gray_studio"] .tabs-bar {
  border-bottom: none;
  gap: 6px;
}

html[data-theme="slate_gray_studio"] .tab-btn {
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  background: #FFFFFF;
  margin-bottom: 0;
  padding: 8px 14px;
}

html[data-theme="slate_gray_studio"] .tab-btn.active {
  background: #1E293B;
  color: #FFFFFF;
  border-color: #1E293B;
}

/* 5. Serenity Ocean Navy (White Stage Framing the Real Logo on Dark Navy) */
html[data-theme="serenity_ocean_navy"] .brand-logo-stage {
  background: #FFFFFF;
  padding: 8px 10px;
  border-radius: 8px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
}

html[data-theme="serenity_ocean_navy"] .kpi-card {
  border-top: 3px solid #0D253F;
}

html[data-theme="serenity_ocean_navy"] .data-table th {
  background: #EFF4FA;
  color: #0F294A;
  border-bottom: 2px solid #CBD5E1;
}

@media (max-width: 1120px) {
  .analytics-grid-2 {
    grid-template-columns: 1fr;
  }
  .kpi-grid, .form-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .emr-2x2 {
    grid-template-columns: 1fr;
  }
}

/* Medical Form Builder Alert Level Choices (None / Yellow / Red) */
.mf-alert-choice {
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.mf-alert-choice:hover {
  border-color: var(--primary-border);
  color: var(--navy);
}
.mf-alert-choice.active.is-none {
  background: #F1F5F9;
  border-color: #94A3B8;
  color: #334155;
  font-weight: 700;
}
.mf-alert-choice.active.is-yellow {
  background: #FEF6DC;
  border-color: #EAB308;
  color: #9A6700;
  font-weight: 700;
}
.mf-alert-choice.active.is-red {
  background: #FEF2F2;
  border-color: #DC2626;
  color: #B91C1C;
  font-weight: 700;
}

/* Mobile-only UI helpers (hidden on desktop) */
.mobile-more-backdrop,
.mobile-search-backdrop,
.mob-mode-toggle-btn,
.odonto-mob-pan-hint,
.pat-last-visit-lbl {
  display: none;
}

@media (max-width: 768px) {
  html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
  }
  #app-shell, .shell-frame, .shell-body, .main-content, .lhms-screen, .lhms-card, .card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  /* Block layout on mobile eliminates flex min-content width expansion */
  .shell-body {
    display: block;
    overflow-x: clip;
  }
  .shell-frame, .main-content, .lhms-screen {
    overflow-x: clip;
  }

  /* Mobile View-Only / Edit Mode Icon Button in Topbar */
  .mob-mode-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--primary-border);
    background: #EAF4FD;
    color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
  }
  .mob-mode-toggle-btn.is-edit {
    background: #FEF6DC;
    border-color: #EAB308;
    color: #9A6700;
  }

  /* Hide desktop-only clutter, duplicate CTAs, and A5 print calibration on mobile */
  .cal-subtitle-desktop,
  .cal-legends-bar,
  .cal-today-badge-desktop,
  .desktop-only-hint,
  .desktop-only-card,
  .med-visit-sub-desktop,
  .med-corr-detail-desktop,
  .hide-mobile,
  #prof-back-btn,
  [data-settings-tab="print"] {
    display: none !important;
  }

  /* Mobile View-Only Mode: hide edit/add/delete clutter so data is crystal clear */
  html[data-mob-readonly="1"] .topbar-add-pat,
  html[data-mob-readonly="1"] .patients-header-actions,
  html[data-mob-readonly="1"] #prof-edit-btn,
  html[data-mob-readonly="1"] #prof-quick-apt,
  html[data-mob-readonly="1"] #prof-quick-rx,
  html[data-mob-readonly="1"] .compact-row-actions,
  html[data-mob-readonly="1"] #cal-new-apt-btn,
  html[data-mob-readonly="1"] #cal-schedule-settings,
  html[data-mob-readonly="1"] #btn-day-toggle-off,
  html[data-mob-readonly="1"] .slot-empty-btn,
  html[data-mob-readonly="1"] #mobile-more-new-patient,
  html[data-mob-readonly="1"] .tooth-readout {
    display: none !important;
  }
  html[data-mob-readonly="1"] .slot-row:not(:has(.lh-day-apt-card)) {
    display: none;
  }

  .card, .lhms-card {
    padding: 11px 10px !important;
    border-radius: 12px;
  }
  .card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 8px;
  }
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 10px;
  }
  .page-title-block {
    gap: 8px;
    min-width: 0;
  }
  .entity-badge-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }
  .page-header .controls-row {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 5px;
  }
  .page-h1 {
    font-size: 16.5px;
    line-height: 1.25;
  }
  .page-sub {
    font-size: 11.5px;
    flex-wrap: wrap;
    gap: 3px 5px;
  }

  /* Compact Patient Profile Header on Mobile */
  .patient-open-header {
    gap: 7px;
    margin-bottom: 8px;
  }
  .patient-open-header .page-h1 {
    font-size: 16px;
  }
  .patient-open-header .allergy-chip {
    font-size: 10.5px;
    padding: 1px 7px;
  }
  .balance-chip {
    padding: 4px 10px;
    font-size: 11.5px;
  }
  .btn-pill-primary, .btn-pill-outline {
    padding: 6px 10px;
    font-size: 12px;
    min-height: 34px;
  }
  .seg-group {
    flex-wrap: wrap;
    max-width: 100%;
  }
  .seg-btn {
    font-size: 11.5px;
    padding: 4px 9px;
  }
  .pill-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 100%;
    padding-bottom: 2px;
  }
  .pill-bar::-webkit-scrollbar {
    display: none;
  }
  .pill-btn {
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 32px;
    font-size: 11.5px;
  }
  .table-wrap, .cal-grid-wrap, .cal-week-wrap, .lh-matrix-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Locked Mobile Swipe Tabs (1-row horizontal scroll strictly contained within viewport) */
  .emr-tabs {
    display: flex !important;
    gap: 6px;
    flex-wrap: nowrap;
    width: 100%;
    max-width: calc(100vw - 20px);
    min-width: 0;
    box-sizing: border-box;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    margin-bottom: 10px;
  }
  .emr-tabs::-webkit-scrollbar {
    display: none;
  }
  .emr-tab {
    white-space: nowrap;
    flex: 0 0 auto;
    padding: 7px 10px;
    font-size: 12px;
  }

  /* Calendar Mobile Day View — Compact Fonts & Higher Density */
  .cal-controls-row {
    gap: 5px !important;
  }
  .cal-controls-row .date-picker-btn {
    padding: 4px 8px;
    font-size: 11.5px;
  }
  .cal-controls-row .btn-soft-blue,
  .cal-controls-row .btn-pill-primary {
    padding: 4px 9px;
    font-size: 11.5px;
    min-height: 30px;
  }
  .cal-day-banner {
    padding: 7px 10px !important;
    margin-bottom: 8px !important;
  }
  .cal-day-title {
    font-size: 13px !important;
  }
  .slot-row {
    grid-template-columns: 52px minmax(0, 1fr);
    min-height: 38px;
  }
  .slot-time {
    font-size: 10px;
    padding: 5px 2px;
    text-align: center;
  }
  .slot-body {
    padding: 4px 6px;
    min-width: 0;
  }
  .slot-empty-btn {
    font-size: 11px;
    padding: 5px 8px;
  }
  .lh-day-apt-card {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 7px 9px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .lh-day-apt-card strong {
    font-size: 12.5px !important;
  }
  .cal-day-apt-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 4px;
    border-top: 1px dashed rgba(15, 41, 74, 0.12);
  }
  .cal-day-apt-actions:has(.badge) {
    justify-content: space-between;
  }
  .pat-alert-dot:not(.has-alert) {
    display: none !important;
  }
  .allergy-chip {
    unicode-bidi: plaintext;
    text-align: right;
  }
  .notif-bell-btn {
    width: 34px !important;
    height: 34px !important;
    flex-shrink: 0;
  }
  .sidebar-rail {
    display: none;
  }
  .main-content {
    padding: 10px 10px calc(84px + env(safe-area-inset-bottom, 0px));
  }

  /* Compact Single-Row Mobile Topbar */
  .topbar {
    height: auto;
    min-height: 52px;
    padding: 6px 8px;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    box-sizing: border-box;
  }
  .topbar-brand-btn {
    flex-shrink: 1;
    min-width: 0;
  }
  .topbar-logo-img {
    height: 30px;
    max-width: 124px;
    object-fit: contain;
  }
  /* Search is already a dedicated button in the Mobile Bottom Nav */
  .global-search-btn {
    display: none !important;
  }
  .topbar-actions {
    width: auto;
    flex: 0 0 auto;
    justify-content: flex-end;
    gap: 6px;
    margin-right: 0;
    min-width: 0;
  }
  .topbar-add-pat {
    display: none !important;
  }
  .doc-pill {
    padding: 3px 6px;
    gap: 3px;
    border-radius: 999px;
    height: 34px;
  }
  .doc-pill .account-name {
    display: none;
  }
  .notif-bell-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }
  /* Full-Width Fixed Popovers so they never clip off-screen on phones */
  .notif-popover,
  .account-popover {
    position: fixed !important;
    top: 58px !important;
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    max-width: none !important;
    z-index: 93 !important;
  }

  /* Mobile Bottom Navigation + Safe Area */
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    background: var(--navy);
    border-top: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.16);
    z-index: 90;
    overflow: visible;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .mobile-nav-btn {
    border: none;
    background: transparent;
    color: #CBD5E1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 2px;
    border-radius: var(--radius-sm);
    min-width: 0;
    min-height: 44px;
  }
  .mobile-nav-btn.active {
    color: #FFFFFF;
    background: rgba(11, 116, 184, 0.42);
  }
  /* Option 5: Warm Amber Spotlight Floating Search Button */
  .mobile-nav-search-btn {
    position: relative;
    padding: 0 2px;
    gap: 2px;
    color: #FFFFFF;
    font-size: 10.5px;
    font-weight: 700;
  }
  .mobile-nav-search-btn .mob-search-fab {
    width: 44px;
    height: 44px;
    margin-top: -22px;
    border-radius: 50%;
    background: #FFFFFF;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2.5px solid var(--primary);
    box-shadow: 0 6px 16px rgba(15, 41, 74, 0.28);
  }
  .mobile-nav-search-btn:active .mob-search-fab {
    transform: scale(0.95);
  }

  /* Mobile Search Bottom Sheet (Rises ABOVE bottom nav so bottom tabs stay clickable!) */
  .mobile-search-backdrop {
    display: flex;
    align-items: flex-end;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    background: rgba(15, 23, 42, 0.42);
    z-index: 88;
  }
  .mobile-search-sheet {
    width: 100%;
    max-height: 74vh;
    background: #FFFFFF;
    border-radius: 18px 18px 0 0;
    padding: 10px 12px 14px;
    box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.18);
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
  }
  .mobile-search-handle {
    width: 38px;
    height: 4px;
    border-radius: 999px;
    background: #CBD5E1;
    margin: 0 auto 2px;
  }
  .mobile-search-results {
    display: flex;
    flex-direction: column;
    gap: 7px;
    overflow-y: auto;
    max-height: 52vh;
  }

  /* Mobile "More" Bottom Sheet */
  .mobile-more-backdrop {
    display: flex;
    align-items: flex-end;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 92;
  }
  .mobile-more-sheet {
    width: 100%;
    background: #FFFFFF;
    border-radius: 18px 18px 0 0;
    padding: 14px 14px calc(76px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.18);
  }
  .mobile-more-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--navy);
    font-size: 14.5px;
  }
  .mobile-more-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .mobile-more-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 14px 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #F8FAFD;
    color: var(--navy);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    min-height: 76px;
    cursor: pointer;
  }
  .mobile-more-tile .mmt-icon {
    color: var(--primary);
    display: inline-flex;
  }
  .mobile-more-tile.active {
    background: var(--primary-soft);
    border-color: var(--primary);
  }
  .mobile-more-tile.is-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #FFFFFF;
  }
  .mobile-more-tile.is-primary .mmt-icon {
    color: #FFFFFF;
  }

  /* Touch-Friendly Form Controls (16px prevents iOS Safari auto-zoom) */
  .input, .select, .textarea,
  #camp-msg-inp, #camp-search-inp {
    font-size: 16px !important;
    min-height: 40px;
  }
  .textarea {
    min-height: 78px;
  }

  /* Modals & Drawers on Mobile */
  .modal-backdrop {
    padding: 8px;
    align-items: flex-end;
  }
  .modal-card, .modal-card.wide {
    max-width: 100%;
    max-height: 100%;
    border-radius: 16px 16px 12px 12px;
    padding: 14px 14px calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .modal-header {
    padding-bottom: 8px;
    margin-bottom: 12px;
  }
  .modal-header h3 {
    font-size: 15px;
    line-height: 1.35;
  }
  .tooth-drawer-backdrop {
    z-index: 94;
  }
  .tooth-drawer {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-right: none;
  }
  .td-header {
    padding: 11px 12px;
  }
  .td-body {
    padding: 12px;
  }
  .td-footer {
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .td-filter-row {
    flex-direction: column;
    align-items: stretch !important;
    gap: 8px;
  }
  .td-filter-row > div {
    width: 100% !important;
  }
  .sdp-popover {
    max-width: calc(100vw - 20px) !important;
  }

  /* Medical History Tab — Native Touch Experience */
  .med-section {
    padding: 12px;
    margin-bottom: 12px;
  }
  .med-visit-bar {
    flex-direction: column;
    align-items: stretch !important;
    padding: 11px 12px !important;
  }
  .med-visit-picker {
    width: 100%;
  }
  #med-visit-apt-select {
    width: 100% !important;
    min-width: 0 !important;
    flex: 1 1 100%;
  }
  .med-check-grid {
    gap: 8px;
  }
  .med-check-pill {
    padding: 9px 12px;
    min-height: 40px;
    font-size: 13.5px;
    border-radius: 10px;
  }
  .med-check-pill input[type="checkbox"],
  .med-check-pill input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    flex-shrink: 0;
  }
  .med-yesno-row {
    width: 100%;
    gap: 8px !important;
  }
  .med-yesno-row .med-check-pill {
    flex: 1;
    justify-content: center;
    font-weight: 700;
  }
  .med-sticky-save {
    bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
    z-index: 40 !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 7px 10px !important;
    gap: 8px !important;
    margin-top: 12px;
  }
  .med-sticky-save label {
    font-size: 11px !important;
    line-height: 1.25;
    flex: 1;
    min-width: 0;
  }
  .med-sticky-save button[type="submit"] {
    width: auto !important;
    min-height: 36px;
    padding: 6px 12px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .med-changelog-row {
    flex-direction: column;
    align-items: flex-start !important;
  }

  /* Operations Log Mobile Cards:
     - Clean right-edge date-group stripe on <tr> itself (NEVER overlaps date digits!)
     - Row 1: Date + Tooth badge + Status (left)
     - Row 2: Category pill ABOVE Procedure Name + Description below it (right) | Price + Discount beside Procedure Name (left)
     - Row 3 (Edit mode only): Action buttons */
  .op-title-stack {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 3px !important;
  }
  .op-proc-title-text {
    font-size: 13px;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.35;
  }
  .op-proc-note-text {
    font-size: 11.5px !important;
    line-height: 1.45;
    margin-top: 3px !important;
  }

  .compact-ops-table thead {
    display: none;
  }
  .compact-ops-table,
  .compact-ops-table tbody {
    display: block;
    width: 100%;
  }
  .compact-ops-table tbody tr td:first-child::before {
    display: none !important;
  }
  .compact-ops-table tbody tr {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 6px 8px;
    padding: 10px 14px 10px 10px;
    border-bottom: 1px solid var(--border);
    background: #FFFFFF;
  }
  .compact-ops-table tbody tr::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3.5px;
    pointer-events: none;
  }
  .compact-ops-table tbody tr.op-date-grp-0::before { background: #1D72B8; }
  .compact-ops-table tbody tr.op-date-grp-1::before { background: repeating-linear-gradient(to bottom, #64748B 0 10px, transparent 10px 14px); }
  .compact-ops-table tbody tr.op-date-grp-2::before { background: #B45309; }
  .compact-ops-table tbody tr.op-date-grp-3::before { background: repeating-linear-gradient(to bottom, #0F294A 0 10px, transparent 10px 14px); }

  .compact-ops-table tbody tr td {
    display: inline-flex;
    align-items: center;
    border: none !important;
    padding: 0 !important;
    width: auto !important;
    max-width: 100%;
    text-align: right !important;
  }
  .compact-ops-table tbody tr td:nth-child(1) {
    order: 1;
    font-size: 11.5px;
    color: var(--text-muted);
    align-self: center;
    gap: 6px;
    flex-wrap: wrap;
  }
  .compact-ops-table tbody tr td:nth-child(2) {
    order: 2;
    align-self: center;
  }
  .compact-ops-table tbody tr td:nth-child(2):empty {
    display: none;
  }
  .compact-ops-table tbody tr td:nth-child(3) {
    order: 3;
    align-self: center;
  }
  .compact-ops-table tbody tr td:nth-child(5) {
    order: 4;
    margin-right: auto;
    align-self: center;
  }
  /* Force clean line break between Row 1 (Date/Note/Tooth/Status) and Row 2 (Category+Procedure | Price) */
  .compact-ops-table tbody tr td:nth-child(4) {
    order: 5;
    flex: 1 1 62%;
    min-width: 0;
    display: block;
    font-size: 12.5px;
    line-height: 1.4;
    padding-top: 4px !important;
    border-top: 1px dashed #EDF2F7 !important;
  }
  .compact-ops-table tbody tr td:nth-child(6) {
    order: 6;
    flex: 0 0 auto;
    display: block;
    font-size: 12.5px;
    font-weight: 700;
    text-align: left !important;
    padding-top: 22px !important;
    border-top: 1px dashed #EDF2F7 !important;
  }
  .compact-ops-table tbody tr td:nth-child(7) {
    order: 7;
    flex: 1 1 100%;
    justify-content: flex-end;
    padding-top: 4px !important;
  }
  .compact-ops-table tbody tr.op-complaint-row td:nth-child(4) {
    flex: 1 1 100%;
    font-size: 12px;
  }
  .compact-ops-table tbody tr.op-complaint-row td:nth-child(5) {
    order: 6;
    margin-right: auto;
    border-top: none !important;
    padding-top: 2px !important;
  }
  .compact-ops-table tbody tr[data-op-expand-row] {
    display: none;
    padding-top: 6px;
    padding-bottom: 10px;
  }
  .compact-ops-table tbody tr[data-op-expand-row].is-open {
    display: flex;
  }
  .compact-ops-table tbody tr[data-op-expand-row] td:nth-child(1),
  .compact-ops-table tbody tr[data-op-expand-row] td:nth-child(3) {
    display: none !important;
  }
  .compact-ops-table tbody tr[data-op-expand-row] td:nth-child(2) {
    flex: 1 1 100%;
    display: block !important;
    width: 100% !important;
    border-top: none !important;
    padding: 0 !important;
  }
  .compact-ops-table tbody tr[data-op-expand-row] td:nth-child(2) > div {
    margin-left: 0 !important;
  }

  /* Generic data-table safety in both modes so tables never expand root body */
  .data-table {
    font-size: 12px;
  }
  .data-table th, .data-table td {
    padding: 7px 7px;
  }

  /* Mobile Patients List: Ultra-Clean 3-Row Grid (Name|Balance, LastVisit|Age, Phone|WhatsApp — hides File # on mobile) */
  .pat-last-visit-lbl {
    display: inline;
    font-weight: 600;
    color: var(--text-subtle);
  }
  .patients-list-table thead,
  .patients-list-table tbody tr td:nth-child(1) {
    display: none;
  }
  .patients-list-table,
  .patients-list-table tbody {
    display: block;
    width: 100%;
  }
  .patients-list-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 10px;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: #FFFFFF;
  }
  .patients-list-table tbody tr td {
    display: flex;
    align-items: center;
    border: none !important;
    padding: 0 !important;
    width: auto !important;
    max-width: 100%;
    min-width: 0;
    text-align: right !important;
  }
  /* Row 1: Patient Name (right) | Balance Chip (left) */
  .patients-list-table tbody tr td:nth-child(2) {
    grid-column: 1;
    grid-row: 1;
    font-size: 13.5px;
  }
  .patients-list-table tbody tr td:nth-child(7) {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-end;
  }
  /* Row 2: Last Visit Date (right) | Age & Type (left) */
  .patients-list-table tbody tr td:nth-child(6) {
    grid-column: 1;
    grid-row: 2;
    font-size: 11.5px;
  }
  .patients-list-table tbody tr td:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
    justify-content: flex-end;
    font-size: 11.5px;
    color: var(--text-muted);
    gap: 4px;
    flex-wrap: nowrap;
  }
  /* Row 3: Phone (right) | WhatsApp (left) */
  .patients-list-table tbody tr td:nth-child(4) {
    grid-column: 1;
    grid-row: 3;
    padding-top: 4px !important;
    border-top: 1px dashed #EDF2F7 !important;
  }
  .patients-list-table tbody tr td:nth-child(5) {
    grid-column: 2;
    grid-row: 3;
    justify-content: flex-end;
    padding-top: 4px !important;
    border-top: 1px dashed #EDF2F7 !important;
  }
  .patients-list-table .pat-phone-num {
    font-size: 12.5px;
    letter-spacing: 0.2px;
    white-space: nowrap;
  }

  /* Real Full Anatomical SVG Odontogram on Mobile (Compact, Clean, Smooth Horizontal Pan) */
  .odonto-cap-en {
    display: none;
  }
  .odonto-stage {
    display: block !important;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    padding: 6px 4px 5px;
    margin-bottom: 6px;
    box-sizing: border-box;
  }
  .odonto-arch-caption {
    font-size: 10.5px;
    padding: 0 4px 3px;
  }
  .odonto-arch,
  .odonto-arch-caption,
  .odonto-horizontal-divider {
    min-width: 490px;
  }
  .odonto-stage.is-pedo .odonto-arch,
  .odonto-stage.is-pedo .odonto-arch-caption,
  .odonto-stage.is-pedo .odonto-horizontal-divider {
    min-width: 320px;
  }
  .odonto-tooth-code {
    min-width: 24px;
    padding: 1px 2px;
    margin: 2px 0;
    font-size: 9px;
  }
  .chart-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
  }
  .chart-bar .status-legend {
    display: none;
  }
  html[data-mob-readonly="1"] #btn-print-chart,
  html[data-mob-readonly="1"] #btn-print-quote {
    padding: 4px 8px !important;
    font-size: 11px !important;
    min-height: 28px;
  }
  .tooth-readout {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  /* Grids, Themes & KPIs on Mobile */
  .form-grid-2, .form-grid-3, .form-grid-4, .rx-layout, .theme-grid {
    grid-template-columns: 1fr !important;
  }
  .kpi-grid,
  .lhms-screen [style*="grid-template-columns:repeat(3"],
  .lhms-screen [style*="grid-template-columns: repeat(3"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  .kpi-card {
    padding: 9px 9px !important;
    gap: 7px !important;
  }
  .kpi-icon {
    width: 30px !important;
    height: 30px !important;
    flex-shrink: 0;
  }
  .kpi-value {
    font-size: 15.5px !important;
    white-space: nowrap;
  }
  .kpi-label {
    font-size: 11px !important;
  }

  /* Toast above bottom nav */
  .toast-container {
    bottom: calc(70px + env(safe-area-inset-bottom, 0px)) !important;
    left: 10px !important;
    right: 10px !important;
    max-width: none !important;
  }
}

/* Notification Bell & Popover (After + New Patient, Before Doctor Pill) */
.notif-bell-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--navy);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.notif-bell-btn:hover,
.notif-bell-btn.open {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
}
.notif-bell-btn.has-alerts {
  border-color: #FCA5A5;
  background: #FEF2F2;
  color: #B91C1C;
}
.notif-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #DC2626;
  color: #FFFFFF;
  font-size: 10.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #FFFFFF;
  line-height: 1;
}
.notif-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 340px;
  max-width: min(340px, calc(100vw - 24px));
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 16px 36px rgba(15, 41, 74, 0.16);
  z-index: 85;
  overflow: hidden;
}
.notif-pop-header {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: #FAFBFD;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.notif-pop-list {
  max-height: 360px;
  overflow-y: auto;
}
.notif-pop-item {
  padding: 11px 14px;
  border-bottom: 1px solid #F1F5F9;
}
.notif-pop-item:last-child {
  border-bottom: none;
}
.notif-pop-item:hover {
  background: #FAFBFD;
}

/* Smart Auto-Scaling for Large Desktop Monitors (22" / 24" / 27" / 4K) without affecting print */
@media screen and (min-width: 1480px) {
  html[data-zoom-mode="auto"] {
    zoom: 1.12;
  }
}
@media screen and (min-width: 1750px) {
  html[data-zoom-mode="auto"] {
    zoom: 1.22;
  }
}

/* Continued multi-slot appointment bar & Bidi/Mobile polish */
.tooth-readout-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tooth-readout.is-multi-active {
  background: #F0F7FF;
  border-color: var(--primary-border);
}
.odonto-tooth.is-multi-selected {
  background: #E0F2FE !important;
  border-color: #0B74B8 !important;
  box-shadow: 0 0 0 2px rgba(11, 116, 184, 0.28);
  border-radius: 10px;
}
.aligner-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.aligner-chip {
  min-width: 58px;
  padding: 5px 7px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #F8FAFC;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.aligner-chip.is-delivered {
  background: #EBF4FD;
  border-color: #93C5FD;
  color: var(--navy);
}
.aligner-chip-num {
  font-size: 12px;
  font-weight: 800;
}
.aligner-chip.is-delivered .aligner-chip-num {
  color: var(--primary);
}
.aligner-chip-date {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}
.slot-continued-bar {
  font-size: 11.5px;
  color: var(--text-muted);
  background: #F8FAFD;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 600;
  opacity: 0.85;
}
.allergy-chip {
  unicode-bidi: isolate;
}
@media (max-width: 768px) {
  .main-content {
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .lhms-card .btn,
  .card .btn,
  .lhms-card .btn-pill-outline,
  .lhms-card .btn-pill-primary {
    max-width: 100%;
    white-space: normal;
    line-height: 1.35;
  }
  .account-option {
    flex-direction: row !important;
    align-items: center !important;
    text-align: right !important;
  }
}
@media screen and (min-width: 2150px) {
  html[data-zoom-mode="auto"] {
    zoom: 1.30;
  }
}

/* Supabase Cloud Auth Gate & Sync Pill */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(circle at top right, #EAF4FD 0%, #F5F7FB 55%, #EEF2F7 100%);
  direction: rtl;
  font-family: var(--app-font);
}
.auth-card {
  width: 100%;
  max-width: 430px;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 20px;
  padding: 32px 28px 26px;
  box-shadow: 0 20px 50px rgba(15, 45, 74, 0.09);
}
.auth-brand {
  text-align: center;
  margin-bottom: 24px;
}
.auth-logo {
  max-width: 220px;
  height: auto;
  display: block;
  margin: 0 auto 10px;
}
.auth-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.auth-field label {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
}
.auth-hint {
  font-size: 11.5px;
  color: var(--text-muted);
}
.auth-hint code {
  background: #F1F5F9;
  color: var(--navy);
  padding: 1px 6px;
  border-radius: 5px;
  font-weight: 700;
}
.auth-error {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #B91C1C;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  font-weight: 600;
}
.auth-submit-btn {
  width: 100%;
  justify-content: center;
  padding: 11px 18px !important;
  font-size: 14px !important;
  margin-top: 4px;
}
.auth-footer-note {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid #EEF2F7;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-subtle);
}
.auth-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 10px;
  color: var(--text-muted);
  font-size: 13px;
}
.auth-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #E2E8F0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: serenitySpin 0.8s linear infinite;
}
@keyframes serenitySpin {
  to { transform: rotate(360deg); }
}

.cloud-sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--navy);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.cloud-sync-pill:hover {
  background: #F8FAFD;
  border-color: #CBD5E1;
}
.cloud-sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cloud-sync-pill.is-synced .cloud-sync-dot {
  background: #0EA5E9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18);
}
.cloud-sync-pill.is-syncing .cloud-sync-dot {
  background: #2563EB;
  animation: serenityPulse 1s ease-in-out infinite;
}
.cloud-sync-pill.is-offline {
  background: #FEF9E7;
  border-color: #F6DF9B;
  color: #92400E;
}
.cloud-sync-pill.is-offline .cloud-sync-dot {
  background: #D97706;
}
.cloud-sync-pill.is-error {
  background: #FEF2F2;
  border-color: #FECACA;
  color: #B91C1C;
}
.cloud-sync-pill.is-error .cloud-sync-dot {
  background: #DC2626;
}
@keyframes serenityPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}
.account-pop-signed-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.account-pop-signed-info strong {
  font-size: 13px;
  color: var(--navy);
}
.account-pop-signed-info small {
  font-size: 11.5px;
  color: var(--text-muted);
}
.account-pop-logout {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 8px !important;
}
@media (max-width: 768px) {
  .cloud-sync-pill {
    padding: 0 8px;
    height: 29px;
    font-size: 11px;
  }
}

/* OneDrive New X-Ray Alert Banner */
.od-xray-alert-banner {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: min(580px, calc(100vw - 24px));
  width: max-content;
  padding: 12px 16px;
  border-radius: 14px;
  background: #0B2A45;
  color: #FFFFFF;
  border: 1px solid rgba(56, 189, 248, 0.55);
  box-shadow: 0 14px 36px rgba(11, 34, 57, 0.30);
  font-family: var(--app-font);
  direction: rtl;
}
@media (max-width: 768px) {
  .od-xray-alert-banner {
    top: 64px;
    width: calc(100vw - 20px);
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
}

/* PWA Auto-Update Notification Banner */
.pwa-update-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: min(560px, calc(100vw - 24px));
  width: max-content;
  padding: 12px 16px;
  border-radius: 14px;
  background: #0F2D4A;
  color: #FFFFFF;
  border: 1px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 14px 36px rgba(11, 34, 57, 0.28);
  font-family: var(--app-font);
  direction: rtl;
}
.pwa-update-content {
  display: flex;
  align-items: center;
  gap: 11px;
}
.pwa-update-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #38BDF8;
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.22);
  flex-shrink: 0;
}
.pwa-update-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.35;
}
.pwa-update-text strong {
  font-size: 13.5px;
  font-weight: 700;
  color: #FFFFFF;
}
.pwa-update-text span {
  font-size: 12px;
  color: #CBD5E1;
}
.pwa-update-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.pwa-update-btn-primary {
  border: none;
  border-radius: 9px;
  padding: 7px 14px;
  background: #0EA5E9;
  color: #FFFFFF;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}
.pwa-update-btn-primary:hover {
  background: #0284C7;
}
.pwa-update-btn-primary:disabled {
  opacity: 0.7;
  cursor: wait;
}
.pwa-update-btn-ghost {
  border: 1px solid rgba(203, 213, 225, 0.35);
  border-radius: 9px;
  padding: 6px 11px;
  background: transparent;
  color: #E2E8F0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.pwa-update-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}
@media (max-width: 768px) {
  .pwa-update-banner {
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    width: calc(100vw - 20px);
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .pwa-update-actions {
    justify-content: flex-end;
  }
}

@media print {
  html, body {
    zoom: 1 !important;
  }
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  html, body {
    background: #FFFFFF !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
  }
  body::before,
  body::after,
  body > *:not(#print-root) {
    display: none !important;
  }
  #print-root {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #FFFFFF !important;
  }
}
