/*
 * XCLINIC application stylesheet
 *
 * Component index: search for the [Sxx] marker below.
 * Sections retain their existing cascade order; later sections refine earlier
 * components. Keep declaration order, theme fallbacks and responsive overrides
 * in place when editing. This is the deployed stylesheet: no build step or
 * additional stylesheet request is required on the server.
 *
 * [S01] Foundation tokens, base layout, forms and legacy cards
 * [S02] Medical workspace, patient cards, archive and visit layouts
 * [S03] Shared controls, live sync, settings and responsive refinements
 * [S04] Compact workspace, archive statistics and template cards
 * [S05] Top navigation and toolbar layout
 * [S06] Patient privacy, new-patient states and navigation colors
 * [S07] Compact subscription countdown
 * [S08] Subscription countdown detail and narrow screens
 * [S09] Patient search toolbar actions
 * [S10] Subscription notices in quick buttons and forms
 * [S11] Managed content, compact patient cards and initial themes
 * [S12] Account password settings
 * [S13] Action icon frames and editable text library
 * [S14] Command frames, action palette and theme refinements
 * [S15] Button text, payment status and daily visit states
 * [S16] Patient intake and today-visit form layout
 * [S17] Daily archive numbering
 * [S18] Expired-data cleanup center
 * [S19] Multi-clinic cleanup controls
 * [S20] Patient and visit notes
 * [S21] Unpaid booking fee presentation
 * [S22] Validation guidance dialog
 * [S23] Theme surfaces and automatic-mode fallback
 * [S24] Clinic print settings editor
 * [S25] Clinical completion and autosave indicators
 * [S26] Hidden-patient archive and on-demand statistics
 * [S27] Existing-patient match and intake decision sheet
 * [S28] Patient name search matches
 * [S29] Patient age controls
 * [S30] Secretary daily review states
 * [S31] Secretary queue review action
 * [S32] Secretary waiting queue badges
 * [S33] Secretary patient-card layout
 * [S34] Waiting-state colors and badge geometry
 * [S35] Booking save controls and payment fields
 * [S36] Daily sequence and patient identity
 * [S37] Patient attachments and image viewer
 * [S38] Attachment deletion confirmation
 * [S39] Patient-image and print-template upload progress
 * [S40] Today-visit and clinic confirmation dialogs
 * [S41] Offline guard and connection feedback
 * [S42] Expanded patient search and intake guidance
 * [S43] Application installation dialog
 * [S44] Installation and error-page navigation feedback
 * [S45] Clinical term suggestions
 * [S46] Compact mobile patient cards
 * [S47] Custom-role permissions and visit workflow
 * [S48] Assistant clinic selection
 * [S49] User identity and clinic membership cards
 * [S50] Compact account password reset
 * [S51] Patient-card rendering containment
 * [S52] Print-template geometry
 * [S53] Preview retry visibility
 * [S54] Cleanup progress indicators
 * [S55] Booking source badges
 * [S56] Patient-file save confirmation
 */

/* === [S01] Foundation tokens, base layout, forms and legacy cards === */
:root {
  --bg: #f2f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #122033;
  --muted: #66758a;
  --line: #dce4ee;
  --primary: #1769e0;
  --primary-dark: #0f52b7;
  --primary-soft: #eaf2ff;
  --accent: #0f9f83;
  --accent-soft: #e8f8f4;
  --danger: #b42318;
  --danger-soft: #fff0ef;
  --warn: #b54708;
  --ok: #067647;
  --radius-sm: 11px;
  --radius: 17px;
  --radius-lg: 22px;
  --shadow: 0 12px 34px rgba(26,48,78,.08);
  --shadow-hover: 0 16px 38px rgba(26,48,78,.13);
}

* {
  box-sizing: border-box
}

html {
  font-family: system-ui,-apple-system,"Segoe UI",Tahoma,Arial,sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%
}

body {
  margin: 0;
  direction: rtl;
  min-height: 100vh;
  background: linear-gradient(180deg,#f8fbff 0,#f2f6fb 280px,#f2f6fb 100%)
}

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

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

button {
  touch-action: manipulation
}

.shell {
  max-width: 1180px;
  margin: auto;
  padding: 14px 12px 34px
}

.min-w-0 {
  min-width: 0
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(248,251,255,.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(220,228,238,.9)
}

.topbar-inner {
  max-width: 1180px;
  margin: auto;
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between
}

.brand {
  font-weight: 900;
  letter-spacing: -.2px;
  color: #10253f
}

.nav {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  white-space: nowrap;
  padding: 2px 0;
  scrollbar-width: none
}

.nav::-webkit-scrollbar {
  display: none
}

.nav a {
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  transition: .18s ease
}

.nav a:hover {
  border-color: #b8c8dc;
  background: #fff
}

.nav a.nav-add-patient {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 7px 18px rgba(23,105,224,.18)
}

.card,.search-card,.patient-tile,.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow)
}

.card {
  padding: 15px;
  margin-bottom: 13px
}

.grid {
  display: grid;
  gap: 12px
}

.grid-2,.grid-3 {
  grid-template-columns: 1fr
}

.metric {
  font-size: 29px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -.8px;
  color: #10253f
}

.muted {
  color: var(--muted)
}

h1,h2,h3 {
  margin: 0;
  color: #10253f;
  line-height: 1.25
}

h1 {
  font-size: clamp(24px,6vw,34px);
  letter-spacing: -.7px
}

h2 {
  font-size: 20px
}

h3 {
  font-size: 17px
}

p {
  line-height: 1.7
}

.kicker {
  font-size: 11px;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: .2px;
  margin-bottom: 5px
}

.small {
  font-size: 12px
}

.form-grid {
  display: grid;
  gap: 11px
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 6px;
  color: #33445a
}

.input,.field input,.field textarea,.field select {
  width: 100%;
  border: 1px solid #cbd6e2;
  border-radius: 13px;
  padding: 12px 13px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: .16s ease
}

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

.input:focus,.field input:focus,.field textarea:focus,.field select:focus {
  border-color: #6da5f4;
  box-shadow: 0 0 0 4px rgba(23,105,224,.10)
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 14px;
  min-height: 42px;
  font-weight: 800;
  cursor: pointer;
  background: #edf2f7;
  color: #24364c;
  transition: transform .16s ease,box-shadow .16s ease,background .16s ease,border-color .16s ease
}

.btn:hover {
  transform: translateY(-1px)
}

.btn-primary {
  background: linear-gradient(135deg,var(--primary),#2c7cf0);
  color: #fff;
  box-shadow: 0 8px 20px rgba(23,105,224,.18)
}

.btn-primary:hover {
  background: linear-gradient(135deg,var(--primary-dark),var(--primary))
}

.btn-soft {
  background: #fff;
  border-color: var(--line);
  color: #29415e
}

.btn-soft:hover {
  background: var(--surface-2);
  border-color: #b9c9db
}

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

.btn-ok {
  background: #e7f8ef;
  color: var(--ok)
}

.btn-compact {
  padding: 8px 11px;
  min-height: 36px;
  font-size: 12px;
  background: #f5f8fc;
  border-color: var(--line)
}

.btn-icon {
  font-size: 16px
}

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

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap
}

.paid {
  background: #e3f8ec;
  color: #067647
}

.unpaid {
  background: #fff0ef;
  color: #b42318
}

.flash {
  padding: 12px 14px;
  border-radius: 13px;
  margin-bottom: 11px;
  border: 1px solid transparent;
  font-weight: 700
}

.flash.success {
  background: #ecfdf3;
  color: #067647;
  border-color: #b7ebca
}

.flash.error {
  background: #fef3f2;
  color: #b42318;
  border-color: #ffd0cc
}

.flash.info {
  background: #eff8ff;
  color: #175cd3;
  border-color: #cfe4ff
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 650px
}

.table th,.table td {
  padding: 11px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: top
}

.table th {
  background: #f7f9fc;
  font-size: 12px;
  color: #50627a
}

.quick-buttons {
  display: flex;
  gap: 7px;
  flex-wrap: wrap
}

.quick-buttons button {
  border: 1px solid #b9d1ff;
  background: #eef5ff;
  color: #174d9d;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 700
}

.event-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #12b76a;
  display: inline-block;
  box-shadow: 0 0 0 4px rgba(18,183,106,.12)
}

.thumbs {
  display: flex;
  gap: 8px;
  overflow: auto
}

.thumbs img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line)
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px
}

.login-card {
  width: min(420px,100%)
}

.danger-zone {
  border-color: #f5bdb7;
  background: #fffafa
}

.ltr {
  direction: ltr;
  text-align: left
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between
}

.pagination {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px
}

.pagination a,.page-current {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  font-weight: 800
}

.pagination a.disabled {
  opacity: .45;
  pointer-events: none
}

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

.dashboard-hero,.patients-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 5px 0 14px;
  padding: 4px 2px
}

.dashboard-hero p,.patients-head p {
  margin: 5px 0 0;
  max-width: 660px
}

.stats-toggle {
  white-space: nowrap
}

.stats-panel {
  margin-bottom: 13px
}

.stats-panel[hidden] {
  display: none!important
}

.stats-grid {
  animation: statsIn .18s ease-out
}

@keyframes statsIn {
  from {
    opacity: 0;
    transform: translateY(-4px)
  }

  to {
    opacity: 1;
    transform: none
  }

}

.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px;
  box-shadow: none
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 900;
  font-size: 18px;
  flex: 0 0 auto
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 5px
}

.subscription {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(135deg,#eff7ff,#f1fbf8);
  border-color: #cfe2ee
}

.subscription h2 {
  margin-bottom: 5px
}

.subscription-mark {
  width: 48px;
  height: 48px;
  border-radius: 15px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 900;
  flex: 0 0 auto
}

.dashboard-actions .actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px
}

.dashboard-actions .btn {
  min-height: 49px
}

.live-card {
  overflow: hidden
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border: 1px solid #cfeade;
  border-radius: 999px;
  background: #f3fcf8;
  color: #087a59;
  font-size: 11px;
  font-weight: 900
}

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

.visit-row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px;
  border: 1px solid #e2e8f0;
  border-radius: 13px;
  background: #fbfdff;
  transition: .16s ease
}

.visit-row-card:hover {
  border-color: #b9cbe0;
  background: #fff;
  transform: translateY(-1px)
}

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

.avatar,.patient-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-weight: 900;
  background: linear-gradient(135deg,#dceaff,#edf5ff);
  color: #195fbd;
  border: 1px solid #c8ddfb
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px
}

.visit-patient {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px
}

.patients-head {
  margin-bottom: 11px
}

.add-patient-main {
  white-space: nowrap
}

.search-card {
  padding: 11px;
  margin-bottom: 13px;
  box-shadow: 0 8px 25px rgba(26,48,78,.055)
}

.searchbar {
  display: flex;
  gap: 8px;
  width: 100%
}

.search-input-wrap {
  position: relative;
  min-width: 0;
  flex: 1
}

.search-input-wrap .input {
  padding-right: 40px;
  height: 45px
}

.search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #7a8da5;
  font-size: 18px;
  z-index: 1
}

.searchbar .btn {
  min-width: 82px
}

.patient-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 11px
}

.patient-tile {
  display: block;
  padding: 14px;
  box-shadow: 0 8px 25px rgba(26,48,78,.055);
  overflow: hidden;
  transition: transform .18s ease,box-shadow .18s ease,border-color .18s ease
}

.patient-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: #bdcde0
}

.patient-tile-top {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0
}

.patient-avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  font-size: 20px
}

.patient-title {
  flex: 1
}

.patient-title h3 {
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere
}

.file-code {
  display: inline-flex;
  padding: 3px 7px;
  border-radius: 7px;
  background: #f0f4f8;
  color: #607087;
  font: 700 11px ui-monospace,SFMono-Regular,Menlo,monospace;
  direction: ltr
}

.open-arrow {
  font-size: 25px;
  color: #8b9bb0;
  line-height: 1;
  flex: 0 0 auto
}

.patient-meta {
  display: grid;
  grid-template-columns: 85px minmax(0,1fr);
  gap: 8px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid #edf1f5
}

.meta-item {
  min-width: 0;
  padding: 8px 9px;
  border-radius: 10px;
  background: #f8fafc
}

.meta-wide {
  min-width: 0
}

.meta-label {
  display: block;
  font-size: 10px;
  color: #7b899b;
  font-weight: 800;
  margin-bottom: 4px
}

.meta-item strong {
  display: block;
  font-size: 13px;
  color: #2d3f55;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.patient-tile-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 11px;
  color: #5c6f86;
  font-size: 11px;
  font-weight: 800
}

.tile-action {
  color: var(--primary)
}

.empty-state {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #c8d4e2;
  border-radius: 14px;
  background: #fafcff
}

.patient-empty {
  grid-column: 1/-1;
  display: grid;
  gap: 6px;
  justify-items: center
}

.patient-empty span {
  font-size: 12px
}

.empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 20px;
  margin-bottom: 3px
}

.patient-new-card {
  max-width: 760px;
  margin-inline: auto
}

.patient-save-btn {
  width: 100%;
  min-height: 49px
}

.patient-toolbar-actions {
  margin-inline-start: auto
}

@media(min-width:600px) {
  .patient-grid {
    grid-template-columns: repeat(2,minmax(0,1fr))
  }

  .dashboard-actions .actions {
    grid-template-columns: 1fr 1fr
  }

}

@media(min-width:720px) {
  .shell {
    padding: 20px 18px 40px
  }

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

  .grid-3 {
    grid-template-columns: repeat(3,minmax(0,1fr))
  }

  .form-grid.two {
    grid-template-columns: repeat(2,minmax(0,1fr))
  }

  .card {
    padding: 18px
  }

  .search-card {
    padding: 13px
  }

}

@media(min-width:1020px) {
  .patient-grid {
    grid-template-columns: repeat(3,minmax(0,1fr))
  }

}

@media(max-width:719px) {
  .topbar-inner {
    align-items: flex-start;
    flex-direction: column
  }

  .nav {
    width: 100%
  }

  .nav-add-patient {
    position: sticky;
    right: 0
  }

  .dashboard-hero,.patients-head {
    align-items: stretch;
    flex-direction: column
  }

  .stats-toggle,.add-patient-main {
    width: 100%
  }

  .section-title {
    align-items: flex-start
  }

  .searchbar {
    align-items: stretch
  }

  .searchbar .btn {
    min-width: 76px;
    padding-inline: 12px
  }

  .patient-meta {
    grid-template-columns: 74px minmax(0,1fr)
  }

  .recent-visits .section-title {
    align-items: center
  }

}

@media(max-width:390px) {
  .shell {
    padding-inline: 9px
  }

  .patient-tile {
    padding: 12px
  }

  .patient-avatar {
    width: 42px;
    height: 42px
  }

  .patient-tile-footer {
    font-size: 10px
  }

  .searchbar {
    gap: 6px
  }

  .searchbar .btn {
    min-width: 68px;
    padding-inline: 9px
  }

}

@media print {
  .no-print,.topbar,.stats-toggle {
    display: none!important
  }

  .shell {
    max-width: none;
    padding: 0
  }

  .card {
    box-shadow: none;
    border: 0
  }

  body {
    background: #fff
  }

}

/* === [S02] Medical workspace, patient cards, archive and visit layouts === */
:root {
  --bg: #f4fafb;
  --surface: #ffffff;
  --surface-2: #f7fbfc;
  --surface-med: #eef9f8;
  --text: #16303a;
  --muted: #6b8088;
  --line: #d9e8eb;
  --primary: #0f7f78;
  --primary-dark: #0a645f;
  --primary-soft: #e5f6f4;
  --accent: #1688b8;
  --accent-soft: #e8f5fb;
  --danger: #b42318;
  --danger-soft: #fff1ef;
  --ok: #067647;
  --shadow: 0 10px 28px rgba(23,61,72,.07);
  --shadow-hover: 0 16px 38px rgba(23,61,72,.11);
}

body {
  background: linear-gradient(180deg,#f9fdfd 0,#f4fafb 240px,#f4fafb 100%)
}

.ui-icon {
  width: 19px;
  height: 19px;
  display: inline-block;
  vertical-align: middle;
  flex: 0 0 auto
}

.section-icon {
  width: 34px;
  height: 34px;
  color: var(--primary);
  opacity: .9
}

.topbar {
  background: rgba(250,254,254,.94);
  border-bottom: 1px solid rgba(208,228,231,.88);
  box-shadow: 0 6px 24px rgba(27,67,78,.045)
}

.topbar-inner {
  padding: 9px 12px
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg,#0f7f78,#279bb0);
  color: #fff;
  box-shadow: 0 8px 20px rgba(15,127,120,.18)
}

.brand-mark .ui-icon {
  width: 23px;
  height: 23px
}

.brand-copy {
  min-width: 0
}

.brand {
  font-size: 15px;
  color: #153640
}

.brand-user {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px
}

.nav {
  gap: 6px
}

.nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 11px;
  border-color: #d9e8eb;
  background: rgba(255,255,255,.86);
  color: #36535d
}

.nav a .ui-icon {
  width: 17px;
  height: 17px;
  color: #56808a
}

.nav a:hover {
  background: #fff;
  border-color: #bdd9dc;
  color: #183d47
}

.nav a.nav-add-patient {
  background: linear-gradient(135deg,#0f7f78,#168ca0);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 18px rgba(15,127,120,.18)
}

.nav a.nav-add-patient .ui-icon {
  color: #fff
}

.btn {
  border-radius: 13px;
  min-height: 44px
}

.btn .ui-icon {
  width: 18px;
  height: 18px
}

.btn-primary {
  background: linear-gradient(135deg,#0f7f78,#168ca0);
  box-shadow: 0 8px 20px rgba(15,127,120,.17)
}

.btn-primary:hover {
  background: linear-gradient(135deg,#0b6d67,#0f7f78)
}

.btn-soft {
  border-color: #d7e7e9;
  color: #31535d;
  background: #fff
}

.medical-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 18px;
  padding: 20px;
  margin: 4px 0 14px;
  border: 1px solid #cfe6e7;
  border-radius: 24px;
  background: linear-gradient(145deg,#f0fbfa 0%,#f7fcff 56%,#edf8fb 100%);
  box-shadow: 0 14px 34px rgba(35,89,98,.075)
}

.medical-hero:after {
  content: "";
  position: absolute;
  left: -42px;
  top: -52px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgba(41,164,165,.07);
  pointer-events: none
}

.medical-hero-copy {
  position: relative;
  z-index: 1
}

.hero-kicker {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #0f7f78;
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 7px
}

.hero-kicker .ui-icon {
  width: 18px;
  height: 18px
}

.medical-hero h1 {
  font-size: clamp(25px,6vw,36px);
  color: #123944;
  letter-spacing: -.8px
}

.medical-hero p {
  margin: 7px 0 0;
  color: #5e7a82;
  font-size: 13px
}

.subscription-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  padding: 7px 10px;
  border: 1px solid #cfe8e5;
  border-radius: 999px;
  background: rgba(255,255,255,.78);
  font-size: 11px;
  color: #53727a
}

.subscription-chip .ui-icon {
  width: 15px;
  height: 15px;
  color: #0f7f78
}

.subscription-chip b {
  color: #17444d
}

.hero-actions {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 8px
}

.hero-icon-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 74px;
  padding: 9px 7px;
  border: 1px solid #d4e7e9;
  border-radius: 17px;
  background: rgba(255,255,255,.92);
  color: #31545e;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 5px 18px rgba(31,82,91,.045);
  transition: .18s ease
}

.hero-icon-button:hover {
  transform: translateY(-1px);
  border-color: #a9d3d4;
  box-shadow: 0 9px 22px rgba(31,82,91,.08)
}

.hero-icon-button .ui-icon {
  width: 23px;
  height: 23px;
  color: #0f7f78
}

.hero-icon-primary {
  background: linear-gradient(145deg,#0f7f78,#168ca0);
  border-color: transparent;
  color: #fff
}

.hero-icon-primary .ui-icon {
  color: #fff
}

.stats-panel-modern {
  margin: 0 0 14px;
  padding: 13px;
  border: 1px solid #cfe3e6;
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow);
  animation: statsIn .18s ease
}

.stats-panel-modern[hidden] {
  display: none!important
}

.stats-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 70px;
  color: var(--muted);
  font-size: 12px
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #d8e8e9;
  border-top-color: #0f7f78;
  border-radius: 50%;
  animation: spin .7s linear infinite
}

@keyframes spin {
  to {
    transform: rotate(360deg)
  }

}

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

.today-stat {
  padding: 12px;
  border: 1px solid #dfebed;
  border-radius: 15px;
  background: #f9fcfc
}

.today-stat span {
  display: block;
  font-size: 10px;
  color: #6d838a;
  font-weight: 800;
  margin-bottom: 5px
}

.today-stat b {
  font-size: 24px;
  line-height: 1;
  color: #173d46
}

.today-stat.fees {
  grid-column: 1/-1;
  background: #eef9f7;
  border-color: #cfeae4
}

.today-stat.fees b {
  font-size: 19px;
  color: #0b6e62
}

.stats-date {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
  font-size: 11px;
  color: #70868d
}

.workspace-card {
  padding: 15px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow)
}

.workspace-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px
}

.workspace-heading p {
  margin: 4px 0 0;
  font-size: 12px
}

.patient-search-modern {
  display: flex;
  gap: 8px;
  align-items: stretch
}

.search-input-modern {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  border: 1px solid #c9dfe2;
  border-radius: 14px;
  background: #fafdfe;
  transition: .16s ease
}

.search-input-modern:focus-within {
  border-color: #65b8b3;
  box-shadow: 0 0 0 4px rgba(15,127,120,.09);
  background: #fff
}

.search-input-modern .ui-icon {
  position: absolute;
  right: 13px;
  width: 19px;
  height: 19px;
  color: #6b8a92
}

.search-input-modern input {
  width: 100%;
  height: 48px;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 11px 42px 11px 12px;
  color: #173640;
  font-weight: 700
}

.search-input-modern input::placeholder {
  font-weight: 500;
  color: #9aabb0
}

.inline-hint {
  margin-top: 9px;
  padding: 9px 11px;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 700
}

.error-hint {
  background: #fff3f1;
  color: #a9362c;
  border: 1px solid #ffd8d2
}

.search-results-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 15px 1px 9px;
  color: #637a82;
  font-size: 11px;
  font-weight: 800
}

.search-results-head b {
  display: grid;
  place-items: center;
  min-width: 25px;
  height: 25px;
  padding: 0 7px;
  border-radius: 999px;
  background: #e7f6f4;
  color: #0f766e
}

.search-empty-guide {
  display: flex;
  gap: 11px;
  align-items: center;
  margin-top: 12px;
  padding: 14px;
  border: 1px dashed #c9dfe2;
  border-radius: 15px;
  background: #f9fcfd;
  color: #5e7981
}

.search-empty-guide>.ui-icon {
  width: 27px;
  height: 27px;
  color: #67a5aa
}

.search-empty-guide b,.search-empty-guide span {
  display: block
}

.search-empty-guide b {
  font-size: 13px;
  color: #31535c;
  margin-bottom: 3px
}

.search-empty-guide span {
  font-size: 11px;
  line-height: 1.7
}

.count-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border-radius: 999px;
  background: #eaf7f6;
  color: #0c716a;
  font-size: 12px
}

.count-pill .ui-icon {
  width: 16px;
  height: 16px
}

.patient-grid-modern {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px
}

.patient-card-modern {
  position: relative;
  overflow: hidden;
  border: 1px solid #dbe9eb;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 5px 20px rgba(25,66,76,.045);
  transition: .18s ease
}

.patient-card-modern:hover {
  border-color: #bad7da;
  box-shadow: 0 10px 28px rgba(25,66,76,.085);
  transform: translateY(-1px)
}

.patient-card-open {
  display: block;
  padding: 13px 13px 10px
}

.patient-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0
}

.patient-avatar-modern {
  width: 47px;
  height: 47px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: linear-gradient(145deg,#dff5f2,#e8f6fb);
  border: 1px solid #c9e5e3;
  color: #0c766e;
  font-size: 20px;
  font-weight: 900
}

.patient-card-name {
  flex: 1;
  min-width: 0
}

.patient-card-name h3 {
  font-size: 16px;
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #173b44
}

.patient-card-chevron {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border-radius: 10px;
  background: #f4f9fa;
  color: #83a0a7
}

.patient-card-chevron .ui-icon {
  width: 16px;
  height: 16px
}

.patient-card-info {
  display: grid;
  grid-template-columns: 72px minmax(0,1fr);
  gap: 7px;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid #edf3f4
}

.patient-card-info>div {
  min-width: 0;
  padding: 7px 8px;
  border-radius: 10px;
  background: #f8fbfc
}

.patient-card-info span {
  display: block;
  font-size: 9px;
  color: #84969c;
  font-weight: 800;
  margin-bottom: 3px
}

.patient-card-info strong {
  display: block;
  font-size: 12px;
  color: #38565e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.patient-card-status {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 13px 9px
}

.patient-card-status .muted {
  margin-inline-start: auto
}

.patient-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid #eaf1f2;
  background: #fbfdfd
}

.icon-action {
  appearance: none;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 43px;
  padding: 8px 10px;
  color: #526e76;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer
}

.icon-action+.icon-action {
  border-inline-start: 1px solid #e5eeee
}

.icon-action .ui-icon {
  width: 17px;
  height: 17px;
  color: #5f8b91
}

.icon-action.primary {
  color: #0c766e
}

.icon-action.primary .ui-icon {
  color: #0f7f78
}

.icon-action:hover {
  background: #f1f9f8;
  color: #0d6d67
}

.icon-action.compact {
  min-height: 38px;
  border: 1px solid #dce9eb;
  border-radius: 11px;
  background: #fff;
  padding: 7px 9px
}

.icon-action.compact+.icon-action {
  border-inline-start: 1px solid #dce9eb
}

.icon-action.danger {
  color: #a72e25;
  border-color: #f1d3cf;
  background: #fff8f7
}

.icon-action.danger .ui-icon {
  color: #b42318
}

.patient-inline-stats {
  padding: 11px 13px;
  border-top: 1px solid #e5eeee;
  background: linear-gradient(180deg,#f6fbfb,#fbfdfd)
}

.patient-inline-stats[hidden] {
  display: none!important
}

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

.patient-stat-item {
  padding: 8px;
  border: 1px solid #deeaec;
  border-radius: 11px;
  background: #fff
}

.patient-stat-item span {
  display: block;
  font-size: 9px;
  color: #7d9096;
  margin-bottom: 3px;
  font-weight: 800
}

.patient-stat-item b {
  font-size: 14px;
  color: #254b53
}

.patient-stat-footer {
  margin-top: 7px;
  font-size: 10px;
  color: #74888f
}

.patients-head-modern,.archive-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 5px 0 13px;
  padding: 3px 2px
}

.patients-head-modern p,.archive-hero p {
  margin: 5px 0 0;
  font-size: 12px
}

.archive-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 11px;
  padding: 8px 10px;
  border: 1px solid #dce9eb;
  border-radius: 13px;
  background: #fff;
  font-size: 11px;
  color: #71858c;
  white-space: nowrap;
  scrollbar-width: none
}

.archive-breadcrumbs a {
  color: #0f766e;
  font-weight: 800
}

.archive-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px
}

.archive-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid #d9e8ea;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 7px 22px rgba(26,68,77,.05);
  transition: .18s ease
}

.archive-card:hover {
  transform: translateY(-1px);
  border-color: #b8d8da;
  box-shadow: 0 12px 28px rgba(26,68,77,.085)
}

.archive-icon,.archive-day-number {
  width: 47px;
  height: 47px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: #e8f7f5;
  color: #0f766e;
  font-weight: 900
}

.archive-icon .ui-icon {
  width: 22px;
  height: 22px
}

.archive-day-number {
  font-size: 20px;
  background: linear-gradient(145deg,#e4f6f3,#eaf6fb)
}

.archive-label {
  display: block;
  color: #81949a;
  font-size: 10px;
  font-weight: 800;
  margin-bottom: 3px
}

.archive-card h2 {
  font-size: 18px;
  color: #234950
}

.archive-card p {
  margin: 4px 0 0;
  color: #71868d;
  font-size: 11px
}

.archive-arrow {
  color: #92a7ad
}

.archive-arrow .ui-icon {
  width: 18px;
  height: 18px
}

.patient-profile-hero {
  position: relative;
  padding: 17px;
  margin: 4px 0 14px;
  border: 1px solid #cfe4e6;
  border-radius: 22px;
  background: linear-gradient(145deg,#f0fbfa,#f7fcff);
  box-shadow: 0 12px 30px rgba(29,75,84,.065)
}

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

.profile-avatar {
  width: 59px;
  height: 59px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: linear-gradient(145deg,#d9f2ef,#e1f3fa);
  border: 1px solid #c5e2df;
  color: #0c746c;
  font-size: 25px;
  font-weight: 900
}

.profile-copy {
  min-width: 0
}

.profile-code {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
  color: #68838a;
  font: 800 10px ui-monospace,SFMono-Regular,Menlo,monospace;
  direction: ltr
}

.profile-code .ui-icon {
  width: 14px;
  height: 14px
}

.profile-copy h1 {
  font-size: clamp(23px,6vw,32px);
  white-space: normal;
  overflow-wrap: anywhere
}

.profile-meta {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 8px
}

.profile-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 7px;
  border-radius: 9px;
  background: rgba(255,255,255,.78);
  color: #627d84;
  font-size: 10px
}

.profile-meta .ui-icon {
  width: 13px;
  height: 13px;
  color: #5d9798
}

.profile-actions {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  margin-top: 13px;
  border: 1px solid #d8e8ea;
  border-radius: 14px;
  overflow: hidden;
  background: #fff
}

.profile-actions .icon-action {
  min-height: 46px
}

.profile-inline-stats {
  margin-top: 10px;
  border: 1px solid #d9e8ea;
  border-radius: 14px
}

.patient-edit-details summary,.archive-patient-zone summary {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-weight: 900;
  color: #365960;
  list-style: none
}

.patient-edit-details summary::-webkit-details-marker,.archive-patient-zone summary::-webkit-details-marker {
  display: none
}

.patient-edit-details summary .ui-icon,.archive-patient-zone summary .ui-icon {
  color: #0f7f78
}

.edit-patient-form {
  margin-top: 13px
}

.visit-top-fields {
  grid-template-columns: 1fr
}

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

.money-input>.ui-icon {
  position: absolute;
  right: 12px;
  width: 17px;
  height: 17px;
  color: #679198;
  z-index: 1
}

.money-input input {
  padding-right: 39px!important;
  direction: ltr;
  text-align: right
}

.field small {
  display: block;
  margin-top: 5px;
  color: #7b8d93;
  font-size: 10px;
  line-height: 1.5
}

.clinical-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 11px;
  margin-top: 12px
}

.clinical-box {
  padding: 12px;
  border: 1px solid #dce9ea;
  border-radius: 16px;
  background: #fbfdfd
}

.clinical-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
  color: #2d535b;
  font-size: 13px;
  font-weight: 900
}

.clinical-title .ui-icon {
  width: 19px;
  height: 19px;
  color: #0f7f78
}

.clinical-box textarea {
  width: 100%;
  min-height: 135px;
  border: 1px solid #cbdfe1;
  border-radius: 13px;
  padding: 12px;
  background: #fff;
  color: #173840;
  outline: none;
  resize: vertical;
  line-height: 1.7
}

.clinical-box textarea:focus {
  border-color: #67b8b3;
  box-shadow: 0 0 0 4px rgba(15,127,120,.08)
}

.quick-buttons {
  margin-bottom: 8px
}

.quick-buttons button {
  border-color: #c5dfdf;
  background: #eef9f8;
  color: #176a66;
  border-radius: 999px;
  font-size: 11px;
  padding: 7px 10px
}

.attachment-field label {
  display: flex;
  align-items: center;
  gap: 6px
}

.attachment-field label .ui-icon {
  width: 17px;
  height: 17px;
  color: #1688a1
}

.save-visit-button {
  width: 100%;
  min-height: 49px
}

.visits-section {
  margin-top: 17px
}

.visits-section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 11px
}

.visits-section-title p {
  margin: 4px 0 0;
  font-size: 11px
}

.visit-timeline {
  position: relative;
  display: grid;
  gap: 11px
}

.visit-card-modern {
  position: relative;
  padding: 14px;
  border: 1px solid #d9e7e9;
  border-radius: 19px;
  background: #fff;
  box-shadow: 0 7px 24px rgba(25,68,77,.05)
}

.visit-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 11px;
  border-bottom: 1px solid #edf3f4
}

.visit-date {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #294e56;
  font-size: 12px
}

.visit-date .ui-icon {
  width: 16px;
  height: 16px;
  color: #0f7f78
}

.visit-date span {
  color: #7c9096;
  font-size: 10px
}

.visit-doctor {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  color: #71868d;
  font-size: 10px
}

.visit-doctor .ui-icon {
  width: 14px;
  height: 14px
}

.visit-badges {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  flex-direction: column
}

.fee-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #edf8f6;
  color: #0b6d63;
  font-size: 10px;
  font-weight: 900;
  direction: ltr
}

.fee-badge .ui-icon {
  width: 13px;
  height: 13px
}

.visit-content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  margin-top: 11px
}

.visit-clinical-block {
  padding: 11px;
  border: 1px solid #e0ebec;
  border-radius: 14px;
  background: #f9fcfc
}

.visit-clinical-block.treatment {
  background: #f7fbfd
}

.visit-block-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
  color: #31545c;
  font-size: 11px
}

.visit-block-title .ui-icon {
  width: 16px;
  height: 16px;
  color: #0f7f78
}

.visit-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.8;
  font-size: 13px;
  color: #263f46
}

.visit-note {
  display: flex;
  gap: 8px;
  margin-top: 9px;
  padding: 9px 10px;
  border-radius: 12px;
  background: #fffaf1;
  border: 1px solid #f4e7c8;
  color: #685b3c
}

.visit-note>.ui-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  margin-top: 2px
}

.visit-note b {
  font-size: 10px
}

.visit-note p {
  margin: 2px 0 0;
  font-size: 11px;
  white-space: pre-wrap
}

.visit-thumbs {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid #edf2f3
}

.visit-thumbs img {
  width: 82px;
  height: 82px;
  border-radius: 13px
}

.visit-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid #edf2f3
}

.record-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap
}

.record-actions form {
  margin: 0
}

@media(min-width:600px) {
  .medical-hero {
    grid-template-columns: minmax(0,1fr) auto;
    align-items: center;
    padding: 23px
  }

  .hero-actions {
    width: 300px
  }

  .patient-grid-modern {
    grid-template-columns: repeat(2,minmax(0,1fr))
  }

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

  .visit-top-fields {
    grid-template-columns: repeat(3,minmax(0,1fr))
  }

  .clinical-fields {
    grid-template-columns: repeat(2,minmax(0,1fr))
  }

  .visit-content-grid {
    grid-template-columns: repeat(2,minmax(0,1fr))
  }

}

@media(min-width:980px) {
  .patient-grid-modern {
    grid-template-columns: repeat(3,minmax(0,1fr))
  }

  .archive-grid {
    grid-template-columns: repeat(3,minmax(0,1fr))
  }

}

@media(max-width:719px) {
  .topbar-inner {
    gap: 8px
  }

  .brand-wrap {
    width: 100%
  }

  .nav {
    margin-inline: -2px;
    width: calc(100% + 4px);
    padding-bottom: 2px
  }

  .nav a {
    flex: 0 0 auto;
    padding: 8px 10px
  }

  .nav a span {
    font-size: 11px
  }

  .shell {
    padding: 11px 10px 30px
  }

  .medical-hero {
    padding: 16px
  }

  .patient-search-modern {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto
  }

  .patient-search-modern .btn {
    padding-inline: 14px
  }

  .patients-head-modern,.archive-hero {
    flex-direction: column;
    align-items: stretch
  }

  .patients-head-modern .actions,.archive-hero .btn {
    width: 100%
  }

  .patients-head-modern .actions {
    display: grid;
    grid-template-columns: 1fr 1fr
  }

  .profile-main {
    align-items: flex-start
  }

  .profile-avatar {
    width: 52px;
    height: 52px;
    border-radius: 16px
  }

  .visit-card-header {
    align-items: flex-start
  }

  .visit-actions {
    align-items: stretch
  }

  .record-actions {
    width: 100%
  }

  .record-actions .icon-action,.record-actions form {
    flex: 1
  }

  .record-actions form .icon-action {
    width: 100%
  }

}

@media(max-width:390px) {
  .hero-icon-button {
    min-height: 68px;
    padding-inline: 4px
  }

  .hero-icon-button span {
    font-size: 10px
  }

  .patient-card-info {
    grid-template-columns: 66px minmax(0,1fr)
  }

  .profile-actions .icon-action span {
    font-size: 10px
  }

  .archive-card {
    padding: 12px;
    gap: 9px
  }

  .archive-icon,.archive-day-number {
    width: 42px;
    height: 42px
  }

}

.patient-card-info>div:nth-child(n+3) {
  grid-column: 1/-1
}

/* === [S03] Shared controls, live sync, settings and responsive refinements === */
:root {
  --med-ink: #15363d;
  --med-primary: #0b8079;
  --med-primary-2: #178fa2;
  --med-border: #d7e8e9;
  --med-soft: #edf9f7;
}

.shell {
  max-width: 1120px
}

.topbar {
  background: rgba(249,253,253,.96);
  box-shadow: 0 4px 18px rgba(26,71,78,.045)
}

.topbar-inner {
  max-width: 1120px
}

.nav a {
  border-radius: 13px;
  box-shadow: 0 2px 8px rgba(23,61,72,.025)
}

.medical-hero {
  background: linear-gradient(145deg,#edf9f7 0%,#f8fcfd 58%,#edf7fb 100%);
  border-color: #cce4e4
}

.medical-hero:before {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -85px;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: rgba(23,143,162,.055);
  pointer-events: none
}

.workspace-card {
  box-shadow: 0 8px 25px rgba(22,65,72,.055)
}

.patient-card-modern {
  box-shadow: 0 4px 18px rgba(22,65,72,.045)
}

.patient-card-open:focus-visible,.icon-action:focus-visible,.hero-icon-button:focus-visible,.live-sync-pill:focus-visible,.btn:focus-visible {
  outline: 3px solid rgba(15,127,120,.18);
  outline-offset: 2px
}

.badge.new-patient {
  background: #e8f4ff;
  color: #1769a7;
  border: 1px solid #cce5f7
}

.workspace-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end
}

.live-sync-pill {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid #cfe5df;
  border-radius: 999px;
  background: #f5fbf9;
  color: #416b68;
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
  transition: .18s ease
}

.live-sync-pill:hover {
  background: #edf9f6;
  border-color: #acd7cd
}

.live-sync-pill .event-dot {
  width: 7px;
  height: 7px;
  background: #12a66d;
  box-shadow: 0 0 0 4px rgba(18,166,109,.10)
}

.live-sync-pill.is-syncing .event-dot {
  animation: syncPulse .85s ease-in-out infinite;
  background: #1688b8
}

.live-sync-pill.is-updated {
  background: #eaf8f1;
  color: #087a59;
  border-color: #bfe5d3
}

.live-sync-pill.is-updated .event-dot {
  background: #0c9b67;
  animation: syncPop .42s ease
}

.live-sync-pill.is-error {
  background: #fff4f2;
  color: #a23a30;
  border-color: #f1d0cb
}

.live-sync-pill.is-error .event-dot {
  background: #c04435;
  box-shadow: 0 0 0 4px rgba(192,68,53,.09)
}

@keyframes syncPulse {
  0%,100% {
    transform: scale(.85);
    opacity: .6
  }

  50% {
    transform: scale(1.25);
    opacity: 1
  }

}

@keyframes syncPop {
  0% {
    transform: scale(.6)
  }

  70% {
    transform: scale(1.45)
  }

  100% {
    transform: scale(1)
  }

}

.live-card-enter {
  animation: liveCardIn .22s ease-out both
}

@keyframes liveCardIn {
  from {
    opacity: .45;
    transform: translateY(3px)
  }

  to {
    opacity: 1;
    transform: none
  }

}

.settings-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 5px 0 14px;
  padding: 4px 2px
}

.settings-hero p {
  margin: 5px 0 0
}

.feature-toggle-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px
}

.feature-toggle-card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid #d8e8e8;
  border-radius: 17px;
  background: #fbfdfd;
  cursor: pointer;
  transition: .18s ease
}

.feature-toggle-card:hover {
  border-color: #bddbd8;
  background: #fff
}

.feature-switch-input {
  position: absolute;
  opacity: 0;
  pointer-events: none
}

.feature-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: #e9f7f5;
  color: #0c7a72
}

.feature-icon .ui-icon {
  width: 21px;
  height: 21px
}

.feature-copy {
  min-width: 0
}

.feature-copy b {
  display: block;
  color: #25484f;
  font-size: 13px;
  margin-bottom: 4px
}

.feature-copy small {
  display: block;
  color: #75888e;
  font-size: 10px;
  line-height: 1.6
}

.switch-ui {
  position: relative;
  width: 48px;
  height: 27px;
  border-radius: 999px;
  background: #cad7da;
  box-shadow: inset 0 0 0 1px rgba(55,79,85,.08);
  transition: .2s ease;
  flex: 0 0 auto
}

.switch-ui:after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(26,55,63,.18);
  transition: .2s ease
}

.feature-switch-input:checked~.switch-ui {
  background: linear-gradient(135deg,#0f7f78,#20a096)
}

.feature-switch-input:checked~.switch-ui:after {
  transform: translateX(-21px)
}

.feature-switch-input:focus-visible~.switch-ui {
  outline: 3px solid rgba(15,127,120,.16);
  outline-offset: 2px
}

.settings-save-bar {
  position: sticky;
  bottom: 10px;
  z-index: 8;
  display: flex;
  justify-content: flex-start;
  padding: 10px;
  border: 1px solid rgba(208,228,229,.95);
  border-radius: 17px;
  background: rgba(250,254,254,.94);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(22,65,72,.08)
}

.settings-save-bar .btn {
  min-width: 180px
}

@media(min-width:650px) {
  .feature-toggle-grid {
    grid-template-columns: repeat(2,minmax(0,1fr))
  }

}

@media(max-width:719px) {
  body {
    background: linear-gradient(180deg,#fbfefe 0,#f4fafb 200px,#f4fafb 100%)
  }

  .topbar {
    position: sticky;
    top: 0
  }

  .topbar-inner {
    padding: 8px 10px;
    gap: 7px
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 12px
  }

  .brand-mark .ui-icon {
    width: 21px;
    height: 21px
  }

  .brand {
    font-size: 14px
  }

  .brand-user {
    font-size: 10px
  }

  .nav {
    gap: 6px;
    padding-bottom: 1px;
    scroll-snap-type: x proximity
  }

  .nav a {
    scroll-snap-align: start;
    min-height: 38px;
    padding: 7px 9px;
    font-size: 10px
  }

  .nav a .ui-icon {
    width: 16px;
    height: 16px
  }

  .shell {
    padding-top: 10px
  }

  .medical-hero {
    border-radius: 20px;
    gap: 14px
  }

  .hero-actions {
    gap: 7px
  }

  .hero-icon-button {
    border-radius: 15px;
    min-height: 66px
  }

  .workspace-heading {
    align-items: flex-start
  }

  .workspace-side {
    align-items: flex-end;
    flex-direction: column;
    gap: 6px
  }

  .live-sync-pill {
    min-height: 31px;
    padding: 6px 9px
  }

  .patient-card-modern {
    border-radius: 17px
  }

  .patient-card-open {
    padding: 12px 12px 9px
  }

  .profile-actions {
    grid-template-columns: repeat(3,minmax(0,1fr))
  }

  .feature-toggle-card {
    padding: 12px;
    gap: 10px
  }

  .feature-icon {
    width: 40px;
    height: 40px
  }

  .settings-save-bar {
    bottom: 8px
  }

  .settings-save-bar .btn {
    width: 100%;
    min-width: 0
  }

}

@media(max-width:390px) {
  .workspace-heading {
    gap: 8px
  }

  .workspace-side {
    min-width: 95px
  }

  .live-sync-pill {
    font-size: 9px
  }

  .feature-toggle-card {
    grid-template-columns: auto minmax(0,1fr)
  }

  .feature-toggle-card .switch-ui {
    grid-column: 1/-1;
    justify-self: end
  }

}

/* === [S04] Compact workspace, archive statistics and template cards === */
.topbar-inner {
  min-height: 54px;
  padding: 7px 10px!important;
  flex-direction: row!important;
  align-items: center!important;
  gap: 8px!important
}

.brand-wrap {
  min-width: 0;
  gap: 7px
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px
}

.brand-mark .ui-icon {
  width: 18px;
  height: 18px
}

.brand {
  font-size: 13px!important
}

.brand-user {
  font-size: 9px!important;
  max-width: 110px!important;
  margin-top: 0!important
}

.nav {
  width: auto!important;
  max-width: 70%;
  margin: 0!important;
  gap: 5px!important;
  padding: 0!important;
  align-items: center
}

.nav a.nav-icon-only {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0!important;
  display: inline-grid!important;
  place-items: center;
  border-radius: 12px
}

.nav a.nav-icon-only .ui-icon {
  width: 18px;
  height: 18px
}

.nav a.nav-logout {
  min-height: 38px;
  padding: 7px 10px!important;
  gap: 5px
}

.nav a.nav-logout span {
  font-size: 10px!important
}

.medical-hero.medical-hero-compact {
  padding: 10px 12px!important;
  min-height: 0;
  border-radius: 18px;
  display: flex!important;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px
}

.medical-hero-compact .medical-hero-copy {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap
}

.medical-hero-compact .hero-kicker {
  margin: 0;
  font-size: 11px
}

.medical-hero-compact .subscription-chip {
  margin: 0;
  padding: 6px 8px;
  font-size: 9px;
  min-height: 30px
}

.medical-hero-compact .hero-actions-compact {
  display: flex;
  grid-template-columns: none;
  width: auto!important;
  gap: 6px
}

.medical-hero-compact .hero-icon-button {
  min-width: 42px;
  padding: 7px 9px;
  min-height: 38px
}

.medical-hero-compact .hero-icon-button span {
  font-size: 9px
}

.archive-year-card {
  display: block!important;
  padding: 0!important;
  overflow: hidden
}

.archive-card-main {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px;
  text-decoration: none;
  color: inherit
}

.archive-year-stats-button {
  width: calc(100% - 24px);
  margin: 0 12px 12px;
  border: 1px solid #d9e8ea;
  background: #f6fbfb;
  color: #35646b;
  border-radius: 12px;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 800
}

.archive-year-stats-button .ui-icon {
  width: 16px;
  height: 16px
}

.archive-year-stats-panel {
  border-top: 1px solid #e5efef;
  padding: 10px 12px;
  background: #fbfefe
}

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

.year-stat-item {
  padding: 9px;
  border: 1px solid #e0ecec;
  border-radius: 11px;
  background: #fff
}

.year-stat-item span {
  display: block;
  font-size: 9px;
  color: var(--muted)
}

.year-stat-item b {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  color: #214c55
}

.visit-block-title-actions {
  display: flex!important;
  align-items: center!important;
  justify-content: space-between!important;
  gap: 8px
}

.visit-block-title-actions>span {
  display: inline-flex;
  align-items: center;
  gap: 6px
}

.print-section-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #d3e5e6;
  border-radius: 10px;
  background: #f7fcfc;
  color: #0f817c;
  box-shadow: 0 3px 10px rgba(27,82,87,.05)
}

.print-section-button .ui-icon {
  width: 16px;
  height: 16px
}

.print-section-button:hover {
  background: #eaf8f7;
  border-color: #b8dbdc
}

.quick-library-grid,.template-grid,.clinic-admin-grid {
  display: grid;
  gap: 10px;
  margin: 12px 0
}

.quick-library-card,.template-card,.clinic-admin-card {
  border: 1px solid #d8e7e8;
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 7px 22px rgba(25,68,77,.045)
}

.quick-library-card {
  padding: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px
}

.quick-library-card h3,.template-card h3 {
  margin: 7px 0 4px;
  font-size: 14px
}

.quick-library-card p {
  margin: 0;
  white-space: pre-wrap;
  color: #607981;
  font-size: 11px;
  line-height: 1.7
}

.field-span-two {
  grid-column: 1/-1
}

.template-card {
  overflow: hidden
}

.template-preview {
  height: 150px;
  background: #eef5f5;
  display: grid;
  place-items: center;
  overflow: hidden
}

.template-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff
}

.template-card-body {
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px
}

.template-card-body>div {
  min-width: 0
}

.template-card-body h3 {
  margin: 0 0 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.compact-settings-hero {
  padding: 14px!important;
  margin-bottom: 10px!important
}

.compact-settings-hero h1 {
  font-size: 22px!important
}

.clinic-feature-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin: 11px 0
}

.mini-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid #dce9ea;
  border-radius: 11px;
  background: #f8fcfc;
  font-size: 10px;
  font-weight: 800
}

.clinic-admin-card {
  overflow: hidden
}

.clinic-admin-card summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 13px
}

.clinic-admin-card summary::-webkit-details-marker {
  display: none
}

.clinic-admin-card summary>div {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 2px 7px
}

.clinic-admin-card summary small {
  grid-column: 2;
  color: var(--muted);
  font-size: 9px
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  grid-row: 1/3
}

.status-dot.on {
  background: #27a36a;
  box-shadow: 0 0 0 4px rgba(39,163,106,.09)
}

.status-dot.off {
  background: #c85b5b;
  box-shadow: 0 0 0 4px rgba(200,91,91,.09)
}

.clinic-admin-form {
  border-top: 1px solid #e7eeee;
  padding: 12px
}

.clinic-toggles {
  margin: 10px 0
}

.clinic-toggles .feature-toggle-card {
  margin: 0
}

@media(min-width:720px) {
  .quick-library-grid {
    grid-template-columns: repeat(2,minmax(0,1fr))
  }

  .template-grid {
    grid-template-columns: repeat(3,minmax(0,1fr))
  }

  .clinic-admin-grid {
    grid-template-columns: repeat(2,minmax(0,1fr))
  }

  .year-stat-grid {
    grid-template-columns: repeat(5,minmax(0,1fr))
  }

}

@media(max-width:560px) {
  .topbar-inner {
    padding: 6px 8px!important
  }

  .brand-mark {
    width: 32px;
    height: 32px
  }

  .brand-user {
    display: none
  }

  .nav {
    max-width: 76%!important
  }

  .nav a.nav-icon-only {
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px
  }

  .medical-hero.medical-hero-compact {
    align-items: stretch
  }

  .medical-hero-compact .medical-hero-copy {
    display: grid;
    gap: 5px
  }

  .medical-hero-compact .subscription-chip {
    max-width: 170px
  }

  .medical-hero-compact .hero-icon-button span {
    display: none
  }

  .medical-hero-compact .hero-icon-button {
    width: 38px;
    min-width: 38px;
    padding: 0;
    display: grid;
    place-items: center
  }

  .medical-hero-compact .hero-icon-button .ui-icon {
    width: 17px;
    height: 17px
  }

  .archive-card-main {
    padding: 11px;
    gap: 9px
  }

  .template-preview {
    height: 120px
  }

}

.workspace-heading-actions {
  display: flex;
  align-items: center;
  gap: 7px
}

.section-icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid #cfe4e4;
  background: #eef9f8;
  color: #0f817c
}

.section-icon-button .ui-icon {
  width: 18px;
  height: 18px
}

/* === [S05] Top navigation and toolbar layout === */
.topbar-inner {
  min-height: 50px!important;
  padding: 6px 8px!important;
  justify-content: center!important
}

.topbar .nav.nav-distributed {
  width: 100%!important;
  max-width: 100%!important;
  margin: 0!important;
  padding: 0!important;
  display: flex!important;
  align-items: center!important;
  justify-content: space-evenly!important;
  gap: 6px!important;
  overflow: visible!important
}

.topbar .nav.nav-distributed a.nav-icon-only {
  flex: 0 0 40px;
  width: 40px!important;
  min-width: 40px!important;
  height: 40px!important;
  min-height: 40px!important;
  padding: 0!important;
  display: grid!important;
  place-items: center!important;
  border-radius: 13px;
  background: rgba(255,255,255,.88);
  border: 1px solid #d8e8e9;
  box-shadow: 0 2px 10px rgba(24,73,79,.035)
}

.topbar .nav.nav-distributed a.nav-icon-only .ui-icon {
  width: 18px;
  height: 18px;
  color: #3d7479
}

.topbar .nav.nav-distributed a.nav-icon-only:hover {
  background: #fff;
  border-color: #bcdcdc;
  color: #0f7f78
}

.topbar .nav.nav-distributed a.nav-logout {
  flex: 0 0 40px;
  width: 40px!important;
  min-width: 40px!important;
  height: 40px!important;
  min-height: 40px!important;
  padding: 0!important;
  border-radius: 13px;
  background: #fff;
  border-color: #d8e8e9;
  color: #7b4a46
}

.topbar .nav.nav-distributed a.nav-logout .ui-icon {
  color: #a75b52
}

.medical-hero.medical-hero-compact {
  padding: 8px 10px!important;
  margin-bottom: 8px!important;
  gap: 8px!important;
  border-radius: 16px!important
}

.medical-hero-compact .hero-kicker {
  font-size: 10px!important
}

.medical-hero-compact .subscription-chip {
  min-height: 27px!important;
  padding: 5px 7px!important;
  font-size: 8.5px!important
}

.user-admin-details {
  border: 1px solid #dce9ea;
  border-radius: 14px;
  background: #fbfefe;
  margin-top: 9px;
  overflow: hidden
}

.user-admin-details>summary {
  cursor: pointer;
  padding: 12px 13px;
  font-weight: 850;
  color: #31545b;
  list-style: none
}

.user-admin-details>summary::-webkit-details-marker {
  display: none
}

.user-admin-form {
  padding: 12px;
  border-top: 1px solid #e4eeee
}

@media(max-width:560px) {
  .topbar-inner {
    min-height: 48px!important;
    padding: 5px 6px!important
  }

  .topbar .nav.nav-distributed {
    gap: 4px!important
  }

  .topbar .nav.nav-distributed a.nav-icon-only {
    flex-basis: 38px;
    width: 38px!important;
    min-width: 38px!important;
    height: 38px!important;
    min-height: 38px!important
  }

  .topbar .nav.nav-distributed a.nav-logout {
    flex-basis: 38px;
    width: 38px!important;
    min-width: 38px!important;
    height: 38px!important;
    min-height: 38px!important;
    padding: 0!important
  }

  .medical-hero.medical-hero-compact {
    padding: 7px 9px!important
  }

}

.permissions-subheading {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #e5eeee
}

.permission-check-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid #dce9ea;
  border-radius: 13px;
  background: #fbfefe;
  font-size: 12px;
  font-weight: 800;
  color: #36585f;
  cursor: pointer
}

.permission-check-card input {
  width: 18px;
  height: 18px;
  accent-color: #0f7f78;
  flex: 0 0 auto
}

.permission-check-card:has(input:checked) {
  background: #edf9f7;
  border-color: #bfe0db;
  color: #155f5a
}

/* === [S06] Patient privacy, new-patient states and navigation colors === */
.topbar .nav.nav-distributed a.nav-icon-only {
  border-width: 1px!important;
  box-shadow: 0 4px 12px rgba(24,73,79,.055)!important
}

.topbar .nav.nav-distributed a.nav-home {
  background: #eaf8f6!important;
  border-color: #bfe3de!important
}

.topbar .nav.nav-distributed a.nav-home .ui-icon {
  color: #087d72!important
}

.topbar .nav.nav-distributed a.nav-archive {
  background: #eef6fd!important;
  border-color: #cadeef!important
}

.topbar .nav.nav-distributed a.nav-archive .ui-icon {
  color: #3476a8!important
}

.topbar .nav.nav-distributed a.nav-quick {
  background: #f4f0fd!important;
  border-color: #ddd1f5!important
}

.topbar .nav.nav-distributed a.nav-quick .ui-icon {
  color: #7156ad!important
}

.topbar .nav.nav-distributed a.nav-clinics {
  background: #edf9f2!important;
  border-color: #c8e8d4!important
}

.topbar .nav.nav-distributed a.nav-clinics .ui-icon {
  color: #2a8554!important
}

.topbar .nav.nav-distributed a.nav-admin {
  background: #fff5e9!important;
  border-color: #efd9ba!important
}

.topbar .nav.nav-distributed a.nav-admin .ui-icon {
  color: #a66d25!important
}

.topbar .nav.nav-distributed a.nav-icon-only:active {
  transform: translateY(1px);
  box-shadow: 0 1px 5px rgba(24,73,79,.06)!important
}

.add-patient-visible {
  display: inline-flex!important;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  min-height: 40px;
  padding-inline: 13px!important;
  box-shadow: 0 6px 16px rgba(15,127,120,.13)
}

.add-patient-visible .ui-icon {
  width: 17px;
  height: 17px
}

.patient-card-modern.patient-new-unseen {
  background: linear-gradient(145deg,#fffdf3,#fff9db);
  border-color: #ecd98a;
  box-shadow: 0 7px 24px rgba(181,143,29,.11)
}

.patient-card-modern.patient-new-unseen::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 4px;
  background: #e4b52f
}

.patient-card-modern.patient-new-unseen .patient-avatar-modern {
  background: #fff1b8;
  color: #8c6411
}

.badge.unseen-patient {
  background: #fff0ae;
  color: #77520a;
  border: 1px solid #ead37a
}

.patient-card-modern.patient-hidden-card {
  background: linear-gradient(145deg,#f1f3f3,#e9eded);
  border-color: #c9d1d2;
  box-shadow: none;
  filter: saturate(.62)
}

.patient-card-modern.patient-hidden-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(135deg,rgba(89,107,111,.035) 0 8px,transparent 8px 16px)
}

.patient-hidden-card .patient-card-open,.patient-hidden-card .patient-card-actions,.patient-hidden-card .patient-inline-stats {
  position: relative;
  z-index: 1
}

.badge.hidden-patient,.patient-hidden-banner {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #e2e7e8;
  color: #596b70;
  border: 1px solid #c5ced0;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 900;
  padding: 4px 7px
}

.patient-hidden-banner {
  margin-top: 6px
}

.patient-hidden-banner .ui-icon {
  width: 13px;
  height: 13px
}

.patient-profile-hidden {
  background: linear-gradient(145deg,#f2f4f4,#e8eeee)!important;
  border-color: #c9d3d5!important
}

.patient-visibility-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-inline-start: 4px solid #48a997
}

.patient-visibility-control.is-hidden {
  border-inline-start-color: #7b8b8f;
  background: #f3f5f5
}

.patient-visibility-control h2 {
  font-size: 15px;
  margin: 2px 0 3px
}

.patient-visibility-control p {
  margin: 0;
  max-width: 640px
}

.patient-visibility-control form {
  flex: 0 0 auto
}

.visibility-hide-button {
  border-color: #d8bebe!important;
  background: #fff8f7!important;
  color: #8d4640!important
}

.patient-card-actions .icon-action {
  background: #fbfefe
}

.patient-card-actions .icon-action.primary {
  background: #eef9f7;
  color: #087b72
}

.patient-card-actions .icon-action.primary .ui-icon {
  color: #087b72
}

.patient-card-actions .icon-action:not(.primary) {
  background: #f2f7fb;
  color: #426d89
}

.patient-card-actions .icon-action:not(.primary) .ui-icon {
  color: #4e7f9d
}

.patient-edit-details summary,.delete-patient-zone summary {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-weight: 900;
  color: #365960;
  list-style: none
}

.patient-edit-details summary::-webkit-details-marker,.delete-patient-zone summary::-webkit-details-marker {
  display: none
}

.delete-patient-zone summary {
  color: #a23a32
}

.delete-patient-zone summary .ui-icon {
  color: #b33f36
}

@media(max-width:560px) {
  .workspace-heading-actions {
    width: auto
  }

  .add-patient-visible {
    min-height: 38px;
    padding: 7px 10px!important;
    font-size: 10px
  }

  .patient-visibility-control {
    align-items: stretch;
    flex-direction: column
  }

  .patient-visibility-control form,.patient-visibility-control form .btn {
    width: 100%
  }

  .topbar .nav.nav-distributed a.nav-icon-only {
    box-shadow: 0 2px 8px rgba(24,73,79,.05)!important
  }

}

/* === [S07] Compact subscription countdown === */
.subscription-countdown-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 7px 0 9px;
  padding: 0 8px
}

.subscription-countdown-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 13px;
  border: 1px solid #c9e3e3;
  border-radius: 999px;
  background: linear-gradient(145deg,#f8fefe,#edf8f8);
  color: #126d6d;
  box-shadow: 0 4px 14px rgba(27,82,87,.055);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap
}

.subscription-countdown-pill .ui-icon {
  width: 17px;
  height: 17px;
  color: #0a8c88;
  flex: 0 0 auto
}

.subscription-countdown-pill b {
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0;
  color: #125f61
}

.dashboard-stats-button {
  background: #eef6fd!important;
  border-color: #cadeef!important;
  color: #3476a8!important;
  box-shadow: 0 4px 12px rgba(52,118,168,.07)!important
}

.dashboard-stats-button .ui-icon {
  color: #3476a8!important
}

@media(max-width:560px) {
  .subscription-countdown-bar {
    margin: 6px 0 8px;
    padding: 0 6px
  }

  .subscription-countdown-pill {
    min-height: 31px;
    padding: 6px 11px;
    font-size: 10px
  }

  .subscription-countdown-pill b {
    font-size: 11px
  }

  .workspace-heading-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap
  }

  .dashboard-stats-button {
    width: 38px;
    height: 38px;
    min-width: 38px
  }

}

/* === [S08] Subscription countdown detail and narrow screens === */
.subscription-countdown-pill.is-active {
  padding: 5px 9px;
  gap: 8px;
  max-width: 100%;
  overflow: hidden
}

.subscription-countdown-units {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 3px;
  direction: rtl;
  min-width: 0
}

.subscription-unit {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  justify-content: center;
  gap: 3px;
  min-width: 43px;
  padding: 4px 7px;
  border: 1px solid rgba(157,205,205,.58);
  border-radius: 10px;
  background: rgba(255,255,255,.72);
  line-height: 1
}

.subscription-unit b {
  font-size: 12px!important;
  font-weight: 950!important;
  color: #0d6666!important;
  font-variant-numeric: tabular-nums;
  min-width: 1ch;
  text-align: center
}

.subscription-unit small {
  font-size: 8.5px;
  font-weight: 850;
  color: #668185;
  white-space: nowrap
}

.subscription-countdown-pill.is-state {
  padding-inline: 14px
}

.subscription-countdown-pill.is-expired {
  background: #fff5f4;
  border-color: #e8cdca;
  color: #914f49
}

.subscription-countdown-pill.is-expired .ui-icon,.subscription-countdown-pill.is-expired b {
  color: #914f49
}

@media(max-width:560px) {
  .subscription-countdown-pill.is-active {
    width: min(100%,360px);
    padding: 5px 7px;
    gap: 5px
  }

  .subscription-countdown-pill.is-active>.ui-icon {
    width: 15px;
    height: 15px
  }

  .subscription-countdown-units {
    flex: 1;
    gap: 2px
  }

  .subscription-unit {
    flex: 1;
    min-width: 0;
    padding: 4px 4px;
    border-radius: 9px;
    gap: 2px
  }

  .subscription-unit b {
    font-size: 11px!important
  }

  .subscription-unit small {
    font-size: 7.5px
  }

}

@media(max-width:380px) {
  .subscription-countdown-pill.is-active {
    padding-inline: 5px
  }

  .subscription-unit {
    padding-inline: 3px
  }

  .subscription-unit b {
    font-size: 10px!important
  }

  .subscription-unit small {
    font-size: 7px
  }

}

/* === [S09] Patient search toolbar actions === */
.patient-search-workspace.patient-search-compact {
  padding: 11px 12px 12px
}

.patient-search-toolbar {
  direction: ltr;
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 0
}

.search-toolbar-button {
  direction: rtl;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 35px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 11px;
  text-decoration: none;
  font-size: 10.5px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .16s ease,border-color .16s ease,box-shadow .16s ease,background .16s ease
}

.search-toolbar-button .ui-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto
}

.search-toolbar-button:hover {
  transform: translateY(-1px)
}

.search-toolbar-stats {
  grid-column: 1;
  background: #edf6fd;
  border-color: #cfe2f0;
  color: #2f6f9d;
  box-shadow: 0 3px 10px rgba(47,111,157,.055)
}

.search-toolbar-stats .ui-icon {
  color: #3479aa
}

.search-toolbar-add {
  grid-column: 2;
  background: #eaf8f5;
  border-color: #c9e9e2;
  color: #08776e;
  box-shadow: 0 3px 10px rgba(8,119,110,.055)
}

.search-toolbar-add .ui-icon {
  color: #078178
}

.search-toolbar-spacer {
  grid-column: 2
}

.patient-search-modern.patient-search-modern-compact {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 7px;
  align-items: stretch;
  margin: 0
}

.patient-search-modern-compact .search-input-modern {
  min-height: 0;
  border-radius: 12px
}

.patient-search-modern-compact .search-input-modern input {
  height: 41px;
  padding: 8px 11px;
  font-size: 12px
}

.patient-search-modern-compact .search-input-plain input {
  padding-inline: 11px
}

.search-submit-compact {
  min-width: 64px;
  min-height: 41px;
  padding: 7px 13px!important;
  border-radius: 12px;
  font-size: 11px
}

.patient-search-compact .inline-hint {
  margin-top: 7px
}

.patient-search-compact .search-results-head {
  margin-top: 11px
}

@media(max-width:560px) {
  .patient-search-workspace.patient-search-compact {
    padding: 9px 10px 10px;
    border-radius: 17px
  }

  .patient-search-toolbar {
    gap: 6px;
    margin-bottom: 7px
  }

  .search-toolbar-button {
    min-height: 33px;
    padding: 5px 8px;
    border-radius: 10px;
    font-size: 10px
  }

  .search-toolbar-button .ui-icon {
    width: 15px;
    height: 15px
  }

  .patient-search-modern.patient-search-modern-compact {
    gap: 6px
  }

  .patient-search-modern-compact .search-input-modern input {
    height: 39px;
    font-size: 11.5px
  }

  .search-submit-compact {
    min-width: 59px;
    min-height: 39px;
    padding: 6px 11px!important;
    font-size: 10.5px
  }

}

/* === [S10] Subscription notices in quick buttons and forms === */
.system-validity-card {
  padding: 12px 14px;
  border-color: #cfe5e4;
  background: linear-gradient(145deg,#fbfefe,#f2fbfa)
}

.system-validity-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px
}

.system-validity-heading h2 {
  margin: 1px 0 0;
  font-size: 14px;
  color: #174f54
}

.system-validity-heading .section-icon {
  width: 25px;
  height: 25px;
  color: #0b8a84
}

.system-validity-card .subscription-countdown-contained {
  margin: 0;
  padding: 0;
  justify-content: flex-start
}

.system-validity-card .subscription-countdown-pill {
  box-shadow: none;
  background: #fff;
  border-color: #cde5e4
}

@media(max-width:560px) {
  .system-validity-card {
    padding: 10px 11px
  }

  .system-validity-heading {
    margin-bottom: 7px
  }

  .system-validity-heading h2 {
    font-size: 13px
  }

  .system-validity-card .subscription-countdown-contained {
    justify-content: center
  }

}

/* === [S11] Managed content, compact patient cards and initial themes === */
.login-brand {
  display: flex;
  justify-content: center;
  margin: -2px 0 12px
}

.login-brand img {
  width: 88px;
  height: 88px;
  object-fit: contain;
  border-radius: 24px
}

.login-card h1 {
  text-align: center
}

.login-card>p {
  text-align: center;
  margin-top: 7px
}

.remember-login {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  cursor: pointer
}

.remember-login input {
  width: 17px;
  height: 17px;
  accent-color: var(--primary)
}

.login-help-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted)
}

.login-help-links a {
  color: var(--primary)
}

.login-help-links a:hover {
  text-decoration: underline
}

.login-submit {
  min-height: 46px
}

.admin-home-grid {
  margin-top: 8px
}

.admin-home-card {
  display: block;
  min-height: 118px;
  transition: .17s ease
}

.admin-home-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: color-mix(in srgb,var(--primary) 35%,var(--line))
}

.admin-home-card h2 {
  font-size: 16px
}

.admin-home-card p {
  margin: 7px 0 0;
  font-size: 11px
}

.settings-form {
  display: grid;
  gap: 0
}

.settings-save-bar {
  position: sticky;
  bottom: 10px;
  z-index: 8;
  display: flex;
  justify-content: flex-start;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: color-mix(in srgb,var(--surface) 93%,transparent);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow)
}

.managed-page-editor-form {
  overflow: hidden
}

.editor-color-preview {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 3px var(--surface)
}

.color-input {
  min-height: 44px;
  padding: 5px!important
}

.rich-field {
  grid-column: 1/-1;
  margin-top: 12px
}

.rich-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  padding: 7px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 13px 13px 0 0;
  background: var(--surface-2)
}

.rich-editor-toolbar button,.editor-color-control {
  min-height: 31px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 10px;
  font-weight: 850;
  cursor: pointer
}

.rich-editor-toolbar button:hover {
  border-color: color-mix(in srgb,var(--primary) 45%,var(--line));
  background: var(--primary-soft)
}

.editor-color-control {
  display: inline-flex;
  align-items: center;
  gap: 6px
}

.editor-color-control input {
  width: 27px;
  height: 21px;
  border: 0;
  padding: 0;
  background: transparent
}

.rich-editor {
  min-height: 175px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 0 0 13px 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  line-height: 1.85;
  overflow-wrap: anywhere
}

.rich-editor:focus {
  border-color: color-mix(in srgb,var(--primary) 65%,var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb,var(--primary) 12%,transparent)
}

.rich-editor h2,.rich-editor h3 {
  margin: 10px 0 6px
}

.rich-editor p {
  margin: 6px 0
}

.rich-editor blockquote {
  margin: 8px 0;
  padding: 8px 12px;
  border-inline-start: 3px solid var(--primary);
  background: var(--surface-2);
  border-radius: 8px
}

.managed-page-wrap,.error-page-shell {
  min-height: calc(100vh - 28px);
  display: grid;
  place-items: center;
  padding: 18px
}

.managed-page-card,.error-page-card {
  width: min(760px,100%);
  border: 1px solid var(--line);
  border-top: 4px solid var(--managed-accent,var(--error-accent,var(--primary)));
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: clamp(18px,4vw,28px)
}

.managed-page-mark,.error-page-icon {
  width: 48px;
  height: 48px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  background: color-mix(in srgb,var(--managed-accent,var(--error-accent,var(--primary))) 12%,var(--surface));
  color: var(--managed-accent,var(--error-accent,var(--primary)))
}

.managed-page-mark .ui-icon,.error-page-icon .ui-icon {
  width: 25px;
  height: 25px
}

.managed-page-card h1,.error-page-card h1 {
  font-size: clamp(22px,5vw,30px);
  margin-bottom: 12px
}

.managed-rich-content {
  line-height: 1.9;
  color: var(--text);
  overflow-wrap: anywhere
}

.managed-rich-content p {
  margin: 8px 0
}

.managed-rich-content h2,.managed-rich-content h3 {
  margin: 15px 0 7px
}

.managed-rich-content blockquote {
  padding: 9px 12px;
  margin: 10px 0;
  border-inline-start: 3px solid currentColor;
  background: var(--surface-2);
  border-radius: 9px
}

.managed-back-link {
  display: inline-flex;
  margin-top: 18px;
  font-weight: 850;
  color: var(--primary)
}

.error-page-code {
  font: 900 11px ui-monospace,SFMono-Regular,Menlo,monospace;
  color: var(--muted);
  letter-spacing: 1.5px;
  margin-bottom: 4px
}

.error-page-detail {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px
}

.error-page-action {
  margin-top: 17px
}

.cleanup-single-card {
  display: grid;
  gap: 12px;
  max-width: 480px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-2)
}

/* Patient cards: same information, less vertical space. */
.patient-grid-modern {
  gap: 8px
}

.patient-card-modern {
  border-radius: 15px
}

.patient-card-open {
  padding: 9px 10px 7px
}

.patient-card-head {
  gap: 8px
}

.patient-avatar-modern {
  width: 39px;
  height: 39px;
  border-radius: 12px;
  font-size: 17px
}

.patient-card-name h3 {
  font-size: 14px;
  margin-bottom: 2px
}

.patient-card-chevron {
  width: 26px;
  height: 26px;
  border-radius: 8px
}

.patient-card-info {
  grid-template-columns: 62px minmax(0,1fr);
  gap: 5px;
  margin-top: 7px;
  padding-top: 7px
}

.patient-card-info>div {
  padding: 5px 7px;
  border-radius: 8px
}

.patient-card-info span {
  font-size: 8px;
  margin-bottom: 2px
}

.patient-card-info strong {
  font-size: 11px
}

.patient-card-status {
  gap: 5px;
  padding: 0 10px 6px
}

.patient-card-footer,.patient-card-status {
  font-size: 9px
}

.patient-card-actions .icon-action {
  min-height: 37px;
  padding: 6px 8px;
  font-size: 10px
}

.patient-inline-stats {
  padding: 8px 10px
}

.patient-stat-item {
  padding: 6px
}

.patient-stat-item b {
  font-size: 12px
}

.patient-stat-item span {
  font-size: 8px
}

.badge {
  padding: 4px 7px;
  font-size: 9.5px
}

.file-code {
  padding: 2px 6px;
  font-size: 10px
}

/* Light/dark engine. Forced light uses the default palette. Auto follows the device. */
html[data-theme-effective="dark"] {
  color-scheme: dark;
  --bg: #0b1215;
  --surface: #111b1f;
  --surface-2: #162327;
  --surface-med: #132a2a;
  --text: #e7f0f2;
  --muted: #91a6ad;
  --line: #27383d;
  --primary: #55c7bd;
  --primary-dark: #35a99f;
  --primary-soft: #173533;
  --accent: #65bfe4;
  --accent-soft: #16303c;
  --danger: #ff8c83;
  --danger-soft: #351c1c;
  --warn: #f4b46a;
  --ok: #69d6a3;
  --shadow: 0 12px 34px rgba(0,0,0,.24);
  --shadow-hover: 0 18px 42px rgba(0,0,0,.34)
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] {
    color-scheme: dark;
    --bg: #0b1215;
    --surface: #111b1f;
    --surface-2: #162327;
    --surface-med: #132a2a;
    --text: #e7f0f2;
    --muted: #91a6ad;
    --line: #27383d;
    --primary: #55c7bd;
    --primary-dark: #35a99f;
    --primary-soft: #173533;
    --accent: #65bfe4;
    --accent-soft: #16303c;
    --danger: #ff8c83;
    --danger-soft: #351c1c;
    --warn: #f4b46a;
    --ok: #69d6a3;
    --shadow: 0 12px 34px rgba(0,0,0,.24);
    --shadow-hover: 0 18px 42px rgba(0,0,0,.34)
  }

}

html[data-theme-effective="dark"] body {
  background: linear-gradient(180deg,#0e171a 0,#0b1215 260px,#0b1215 100%)
}

html[data-theme-effective="dark"] h1,html[data-theme-effective="dark"] h2,html[data-theme-effective="dark"] h3,html[data-theme-effective="dark"] .metric {
  color: var(--text)
}

html[data-theme-effective="dark"] .topbar {
  background: rgba(12,20,23,.94);
  border-bottom-color: #24363a;
  box-shadow: 0 6px 24px rgba(0,0,0,.18)
}

html[data-theme-effective="dark"] :is(.card,.search-card,.patient-tile,.stat-card,.workspace-card,.stats-panel-modern,.patient-card-modern,.quick-library-card,.template-card,.clinic-admin-card,.managed-page-card,.error-page-card) {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text)
}

html[data-theme-effective="dark"] :is(.input,.field input,.field textarea,.field select,.search-input-modern,.rich-editor) {
  background: #0e191c;
  border-color: #31454b;
  color: var(--text)
}

html[data-theme-effective="dark"] :is(.input,.field input,.field textarea,.field select)::placeholder,html[data-theme-effective="dark"] .search-input-modern input::placeholder {
  color: #728a91
}

html[data-theme-effective="dark"] .search-input-modern input {
  color: var(--text)
}

html[data-theme-effective="dark"] :is(.btn-soft,.btn-compact,.icon-action.compact,.rich-editor-toolbar button,.editor-color-control) {
  background: #172428;
  border-color: #31454b;
  color: #d5e4e7
}

html[data-theme-effective="dark"] :is(.btn-soft,.btn-compact,.icon-action.compact):hover {
  background: #1c2d31;
  border-color: #436067
}

html[data-theme-effective="dark"] :is(.table-wrap,.pagination a,.page-current) {
  background: var(--surface);
  border-color: var(--line)
}

html[data-theme-effective="dark"] .table th {
  background: #172428;
  color: #b1c2c7
}

html[data-theme-effective="dark"] .table td {
  border-color: #27383d
}

html[data-theme-effective="dark"] :is(.patient-card-info>div,.patient-card-chevron,.patient-stat-item,.today-stat,.search-empty-guide,.empty-state,.cleanup-single-card,.remember-login,.mini-toggle,.permission-check-card,.user-admin-details,.rich-editor-toolbar,.error-page-detail) {
  background: var(--surface-2);
  border-color: var(--line)
}

html[data-theme-effective="dark"] :is(.patient-card-name h3,.patient-card-info strong,.patient-stat-item b,.today-stat b,.search-empty-guide b,.workspace-heading h1,.workspace-heading h2) {
  color: var(--text)
}

html[data-theme-effective="dark"] .patient-card-info {
  border-top-color: #26383d
}

html[data-theme-effective="dark"] .patient-card-actions {
  background: #0f1a1d;
  border-top-color: #27383d
}

html[data-theme-effective="dark"] .icon-action+.icon-action {
  border-inline-start-color: #27383d
}

html[data-theme-effective="dark"] .icon-action:hover {
  background: #17302e
}

html[data-theme-effective="dark"] .patient-card-modern.patient-new-unseen {
  background: linear-gradient(145deg,#2b2918,#242313);
  border-color: #655d2d;
  box-shadow: 0 7px 24px rgba(0,0,0,.18)
}

html[data-theme-effective="dark"] .patient-card-modern.patient-new-unseen .patient-avatar-modern {
  background: #463e18;
  color: #f1cf64;
  border-color: #655d2d
}

html[data-theme-effective="dark"] .badge.unseen-patient {
  background: #463e18;
  color: #f2d675;
  border-color: #695d2b
}

html[data-theme-effective="dark"] .patient-card-modern.patient-hidden-card,html[data-theme-effective="dark"] .patient-profile-hidden {
  background: linear-gradient(145deg,#1a2022,#171d1f)!important;
  border-color: #384448!important;
  filter: saturate(.72)
}

html[data-theme-effective="dark"] .badge.hidden-patient,html[data-theme-effective="dark"] .patient-hidden-banner {
  background: #263135;
  color: #b6c2c5;
  border-color: #3c4b50
}

html[data-theme-effective="dark"] :is(.medical-hero,.subscription,.system-validity-card) {
  background: linear-gradient(145deg,#122426,#111f24);
  border-color: #2b4448
}

html[data-theme-effective="dark"] .medical-hero h1 {
  color: var(--text)
}

html[data-theme-effective="dark"] .medical-hero p {
  color: var(--muted)
}

html[data-theme-effective="dark"] :is(.subscription-chip,.subscription-countdown-pill,.subscription-unit) {
  background: #17282b;
  border-color: #305054;
  color: #b7ced2
}

html[data-theme-effective="dark"] .subscription-unit b {
  color: #7bddcf!important
}

html[data-theme-effective="dark"] .subscription-unit small {
  color: #8ea9ad
}

html[data-theme-effective="dark"] .template-preview {
  background: #172326
}

html[data-theme-effective="dark"] .template-preview img {
  background: #fff
}

html[data-theme-effective="dark"] :is(.flash.info) {
  background: #14283a;
  color: #8dc6ff;
  border-color: #27445f
}

html[data-theme-effective="dark"] :is(.flash.success) {
  background: #153126;
  color: #81ddb0;
  border-color: #28513f
}

html[data-theme-effective="dark"] :is(.flash.error) {
  background: #351d1d;
  color: #ffaaa3;
  border-color: #5d3330
}

html[data-theme-effective="dark"] .danger-zone {
  background: #28191a;
  border-color: #5b3333
}

html[data-theme-effective="dark"] .btn-danger {
  background: #351d1d;
  border-color: #5d3330;
  color: #ffaaa3
}

html[data-theme-effective="dark"] .btn-ok {
  background: #163326;
  color: #77d6a8
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-icon-only {
  box-shadow: 0 4px 12px rgba(0,0,0,.16)!important
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-home {
  background: #15302e!important;
  border-color: #28534e!important
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-home .ui-icon {
  color: #66d1c5!important
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-archive {
  background: #162a38!important;
  border-color: #294758!important
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-archive .ui-icon {
  color: #7ec2ef!important
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-quick {
  background: #251f35!important;
  border-color: #44375d!important
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-quick .ui-icon {
  color: #b39ae6!important
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-clinics {
  background: #182e24!important;
  border-color: #2c503d!important
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-clinics .ui-icon {
  color: #84d3a5!important
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-admin {
  background: #33291c!important;
  border-color: #554329!important
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-admin .ui-icon {
  color: #e5b66e!important
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-logout {
  background: #2b1f1f;
  border-color: #4d3533;
  color: #efb0aa
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-logout .ui-icon {
  color: #ef958b
}

html[data-theme-effective="dark"] :is(.search-toolbar-stats,.dashboard-stats-button) {
  background: #162a38!important;
  border-color: #294758!important;
  color: #8dc9ef!important
}

html[data-theme-effective="dark"] :is(.search-toolbar-stats,.dashboard-stats-button) .ui-icon {
  color: #7ec2ef!important
}

html[data-theme-effective="dark"] .search-toolbar-add {
  background: #15302e;
  border-color: #28534e;
  color: #76d6ca
}

html[data-theme-effective="dark"] .search-toolbar-add .ui-icon {
  color: #66d1c5
}

html[data-theme-effective="dark"] .feature-toggle-card {
  background: #142025;
  border-color: #2b3d42
}

html[data-theme-effective="dark"] .feature-copy b {
  color: var(--text)
}

html[data-theme-effective="dark"] .feature-copy small {
  color: var(--muted)
}

html[data-theme-effective="dark"] .switch-ui {
  background: #34474c;
  border-color: #40565c
}

html[data-theme-effective="dark"] .feature-switch-input:checked~.switch-ui {
  background: #2e9d93;
  border-color: #45bdb2
}

html[data-theme-effective="dark"] .permission-check-card:has(input:checked) {
  background: #17302e;
  border-color: #2f5954;
  color: #9ce3da
}

html[data-theme-effective="dark"] .rich-editor-toolbar {
  background: #142025
}

html[data-theme-effective="dark"] .editor-color-preview {
  box-shadow: inset 0 0 0 3px var(--surface)
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] body {
    background: linear-gradient(180deg,#0e171a 0,#0b1215 260px,#0b1215 100%)
  }

  html[data-theme-mode="auto"] h1,html[data-theme-mode="auto"] h2,html[data-theme-mode="auto"] h3,html[data-theme-mode="auto"] .metric {
    color: var(--text)
  }

  html[data-theme-mode="auto"] .topbar {
    background: rgba(12,20,23,.94);
    border-bottom-color: #24363a;
    box-shadow: 0 6px 24px rgba(0,0,0,.18)
  }

  html[data-theme-mode="auto"] :is(.card,.search-card,.patient-tile,.stat-card,.workspace-card,.stats-panel-modern,.patient-card-modern,.quick-library-card,.template-card,.clinic-admin-card,.managed-page-card,.error-page-card) {
    background: var(--surface);
    border-color: var(--line);
    color: var(--text)
  }

  html[data-theme-mode="auto"] :is(.input,.field input,.field textarea,.field select,.search-input-modern,.rich-editor) {
    background: #0e191c;
    border-color: #31454b;
    color: var(--text)
  }

  html[data-theme-mode="auto"] .search-input-modern input {
    color: var(--text)
  }

  html[data-theme-mode="auto"] :is(.btn-soft,.btn-compact,.icon-action.compact,.rich-editor-toolbar button,.editor-color-control) {
    background: #172428;
    border-color: #31454b;
    color: #d5e4e7
  }

  html[data-theme-mode="auto"] :is(.patient-card-info>div,.patient-card-chevron,.patient-stat-item,.today-stat,.search-empty-guide,.empty-state,.cleanup-single-card,.remember-login,.mini-toggle,.permission-check-card,.user-admin-details,.rich-editor-toolbar,.error-page-detail) {
    background: var(--surface-2);
    border-color: var(--line)
  }

  html[data-theme-mode="auto"] :is(.patient-card-name h3,.patient-card-info strong,.patient-stat-item b,.today-stat b,.search-empty-guide b) {
    color: var(--text)
  }

  html[data-theme-mode="auto"] .patient-card-actions {
    background: #0f1a1d;
    border-top-color: #27383d
  }

  html[data-theme-mode="auto"] .icon-action+.icon-action {
    border-inline-start-color: #27383d
  }

  html[data-theme-mode="auto"] .patient-card-modern.patient-new-unseen {
    background: linear-gradient(145deg,#2b2918,#242313);
    border-color: #655d2d
  }

  html[data-theme-mode="auto"] .badge.unseen-patient {
    background: #463e18;
    color: #f2d675;
    border-color: #695d2b
  }

  html[data-theme-mode="auto"] .patient-card-modern.patient-hidden-card,html[data-theme-mode="auto"] .patient-profile-hidden {
    background: linear-gradient(145deg,#1a2022,#171d1f)!important;
    border-color: #384448!important
  }

  html[data-theme-mode="auto"] :is(.medical-hero,.subscription,.system-validity-card) {
    background: linear-gradient(145deg,#122426,#111f24);
    border-color: #2b4448
  }

  html[data-theme-mode="auto"] .medical-hero h1 {
    color: var(--text)
  }

  html[data-theme-mode="auto"] .medical-hero p {
    color: var(--muted)
  }

  html[data-theme-mode="auto"] :is(.subscription-chip,.subscription-countdown-pill,.subscription-unit) {
    background: #17282b;
    border-color: #305054;
    color: #b7ced2
  }

  html[data-theme-mode="auto"] .subscription-unit b {
    color: #7bddcf!important
  }

  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-home {
    background: #15302e!important;
    border-color: #28534e!important
  }

  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-home .ui-icon {
    color: #66d1c5!important
  }

  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-archive {
    background: #162a38!important;
    border-color: #294758!important
  }

  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-archive .ui-icon {
    color: #7ec2ef!important
  }

  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-quick {
    background: #251f35!important;
    border-color: #44375d!important
  }

  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-quick .ui-icon {
    color: #b39ae6!important
  }

  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-clinics {
    background: #182e24!important;
    border-color: #2c503d!important
  }

  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-clinics .ui-icon {
    color: #84d3a5!important
  }

  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-admin {
    background: #33291c!important;
    border-color: #554329!important
  }

  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-admin .ui-icon {
    color: #e5b66e!important
  }

  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-logout {
    background: #2b1f1f;
    border-color: #4d3533;
    color: #efb0aa
  }

  html[data-theme-mode="auto"] .rich-editor-toolbar {
    background: #142025
  }

}

@media(max-width:560px) {
  .managed-page-wrap,.error-page-shell {
    padding: 11px
  }

  .managed-page-card,.error-page-card {
    padding: 16px;
    border-radius: 18px
  }

  .login-wrap {
    padding: 12px
  }

  .login-card {
    padding: 16px
  }

  .login-brand img {
    width: 76px;
    height: 76px
  }

  .admin-home-card {
    min-height: 98px;
    padding: 13px
  }

  .patient-card-open {
    padding: 8px 9px 6px
  }

  .patient-avatar-modern {
    width: 37px;
    height: 37px
  }

  .patient-card-info {
    margin-top: 6px;
    padding-top: 6px
  }

  .patient-card-actions .icon-action {
    min-height: 35px
  }

  .rich-editor {
    min-height: 150px
  }

  .settings-save-bar {
    bottom: 6px;
    padding: 6px
  }

}

/* === [S12] Account password settings === */
.account-password-card {
  border-color: #d6e8e7;
  background: linear-gradient(145deg,#fff,#f7fcfb)
}

.account-password-card .workspace-heading {
  margin-bottom: 12px
}

.account-password-card .section-icon {
  color: #287f7a
}

.account-password-card .btn {
  margin-top: 12px
}

html[data-theme-effective="dark"] .account-password-card {
  background: linear-gradient(145deg,#132226,#101c20);
  border-color: #294247
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .account-password-card {
    background: linear-gradient(145deg,#132226,#101c20);
    border-color: #294247
  }

}

@media(max-width:560px) {
  .account-password-card {
    padding: 12px
  }

  .account-password-card .workspace-heading {
    margin-bottom: 9px
  }

  .account-password-card .btn {
    width: 100%
  }

}

/* === [S13] Action icon frames and editable text library === */
:root {
  --action-icon-bg: #f2f8fb;
  --action-icon-border: #c9dce6;
  --action-icon-color: #2c7180;
  --action-icon-shadow: 0 2px 7px rgba(32,84,99,.10);
}

.ui-icon {
  stroke-width: 2.08
}

:is(.btn,.icon-action,.search-toolbar-button,.archive-year-stats-button,.nav-logout)>.ui-icon {
  box-sizing: content-box;
  width: 16px;
  height: 16px;
  padding: 3px;
  border: 1px solid var(--action-icon-border);
  border-radius: 8px;
  background: var(--action-icon-bg);
  color: var(--action-icon-color);
  box-shadow: var(--action-icon-shadow);
}

.btn-primary>.ui-icon {
  color: #fff;
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.30);
  box-shadow: 0 2px 7px rgba(0,0,0,.10)
}

.btn-danger>.ui-icon,.icon-action.danger>.ui-icon {
  color: #b42318;
  background: #fff3f1;
  border-color: #f2c8c3;
  box-shadow: 0 2px 7px rgba(180,35,24,.09)
}

.icon-action.primary>.ui-icon,.search-toolbar-add>.ui-icon {
  color: #087b72;
  background: #ecf8f6;
  border-color: #bcded9;
  box-shadow: 0 2px 7px rgba(8,123,114,.10)
}

.search-toolbar-stats>.ui-icon,.archive-year-stats-button>.ui-icon {
  color: #286b96;
  background: #eff7fc;
  border-color: #c7deed;
  box-shadow: 0 2px 7px rgba(40,107,150,.10)
}

.nav a.nav-icon-only .ui-icon {
  stroke-width: 2.2
}

.nav-logout>.ui-icon {
  color: #a23b32;
  background: #fff4f2;
  border-color: #efccc7
}

.app-texts-form {
  padding-bottom: 76px
}

.app-text-group {
  margin-bottom: 10px
}

.app-text-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px
}

.app-text-field {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2)
}

.app-text-field label {
  margin-bottom: 2px
}

.app-text-field .text-key {
  display: block;
  margin-bottom: 7px;
  direction: ltr;
  text-align: left;
  font: 700 9px ui-monospace,SFMono-Regular,Menlo,monospace;
  color: var(--muted);
  opacity: .75
}

.app-text-field input,.app-text-field textarea {
  background: var(--surface)
}

@media(min-width:760px) {
  .app-text-grid {
    grid-template-columns: repeat(2,minmax(0,1fr))
  }

  .app-text-field:has(textarea) {
    grid-column: 1/-1
  }

}

html[data-theme-effective="dark"] {
  --action-icon-bg: #17282d;
  --action-icon-border: #34515a;
  --action-icon-color: #8fd6df;
  --action-icon-shadow: 0 2px 8px rgba(0,0,0,.24);
}

html[data-theme-effective="dark"] .btn-primary>.ui-icon {
  background: rgba(6,29,31,.22);
  border-color: rgba(208,255,249,.28);
  color: #ecfffc
}

html[data-theme-effective="dark"] :is(.btn-danger,.icon-action.danger)>.ui-icon {
  color: #ffaaa3;
  background: #321d1c;
  border-color: #5c3430
}

html[data-theme-effective="dark"] :is(.icon-action.primary,.search-toolbar-add)>.ui-icon {
  color: #7de0d4;
  background: #173330;
  border-color: #2f5954
}

html[data-theme-effective="dark"] :is(.search-toolbar-stats,.archive-year-stats-button)>.ui-icon {
  color: #8dc9ef;
  background: #162b39;
  border-color: #2d4c60
}

html[data-theme-effective="dark"] .nav-logout>.ui-icon {
  color: #f0a39b;
  background: #321e1d;
  border-color: #543532
}

html[data-theme-effective="dark"] .app-text-field input,html[data-theme-effective="dark"] .app-text-field textarea {
  background: #0e191c
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] {
    --action-icon-bg: #17282d;
    --action-icon-border: #34515a;
    --action-icon-color: #8fd6df;
    --action-icon-shadow: 0 2px 8px rgba(0,0,0,.24);
  }

  html[data-theme-mode="auto"] .btn-primary>.ui-icon {
    background: rgba(6,29,31,.22);
    border-color: rgba(208,255,249,.28);
    color: #ecfffc
  }

  html[data-theme-mode="auto"] :is(.btn-danger,.icon-action.danger)>.ui-icon {
    color: #ffaaa3;
    background: #321d1c;
    border-color: #5c3430
  }

  html[data-theme-mode="auto"] :is(.icon-action.primary,.search-toolbar-add)>.ui-icon {
    color: #7de0d4;
    background: #173330;
    border-color: #2f5954
  }

  html[data-theme-mode="auto"] :is(.search-toolbar-stats,.archive-year-stats-button)>.ui-icon {
    color: #8dc9ef;
    background: #162b39;
    border-color: #2d4c60
  }

  html[data-theme-mode="auto"] .nav-logout>.ui-icon {
    color: #f0a39b;
    background: #321e1d;
    border-color: #543532
  }

  html[data-theme-mode="auto"] .app-text-field input,html[data-theme-mode="auto"] .app-text-field textarea {
    background: #0e191c
  }

}

.app-text-filter-card {
  position: sticky;
  top: 60px;
  z-index: 9;
  padding: 9px 11px;
  margin-bottom: 10px;
  background: color-mix(in srgb,var(--surface) 94%,transparent);
  backdrop-filter: blur(12px);
  box-shadow: 0 5px 18px rgba(26,79,89,.07)
}

.app-text-filter-card .field {
  margin: 0
}

.app-text-filter-card label {
  font-size: 10px
}

.app-text-filter-card input {
  min-height: 39px
}

.app-text-field[hidden],.app-text-group[hidden] {
  display: none!important
}

html[data-theme-effective="dark"] .app-text-filter-card {
  background: color-mix(in srgb,var(--surface) 94%,transparent);
  border-color: #2b3d42
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .app-text-filter-card {
    background: color-mix(in srgb,var(--surface) 94%,transparent);
    border-color: #2b3d42
  }

}

/* === [S14] Command frames, action palette and theme refinements === */
:root {
  --action-control-bg: #ffffff;
  --action-control-border: #b9ced8;
  --action-control-shadow: 0 4px 12px rgba(27,74,89,.10),inset 0 0 0 1px rgba(255,255,255,.55);
  --action-control-hover-shadow: 0 7px 16px rgba(27,74,89,.15),inset 0 0 0 1px rgba(255,255,255,.65);
  --action-control-focus: 0 0 0 3px rgba(28,132,139,.15);
}

/* Every visible command gets a real outer frame, not only the glyph inside it. */
:is(
  .btn,
  .icon-action,
  .search-toolbar-button,
  .hero-icon-button,
  .section-icon-button,
  .print-section-button,
  .quick-buttons button,
  .rich-editor-toolbar button,
  .pagination a,
  .topbar .nav.nav-distributed a.nav-icon-only,
  .topbar .nav.nav-distributed a.nav-logout
) {
  border-width: 1.5px!important;
  border-style: solid!important;
  border-color: var(--action-control-border)!important;
  box-shadow: var(--action-control-shadow)!important;
  background-clip: padding-box;
}

:is(
  .btn,
  .icon-action,
  .search-toolbar-button,
  .hero-icon-button,
  .section-icon-button,
  .print-section-button,
  .quick-buttons button,
  .rich-editor-toolbar button,
  .pagination a,
  .topbar .nav.nav-distributed a.nav-icon-only,
  .topbar .nav.nav-distributed a.nav-logout
):hover {
  box-shadow: var(--action-control-hover-shadow)!important;
}

:is(
  .btn,
  .icon-action,
  .search-toolbar-button,
  .hero-icon-button,
  .section-icon-button,
  .print-section-button,
  .quick-buttons button,
  .rich-editor-toolbar button,
  .pagination a,
  .topbar .nav.nav-distributed a.nav-icon-only,
  .topbar .nav.nav-distributed a.nav-logout
):focus-visible {
  outline: none!important;
  box-shadow: var(--action-control-hover-shadow),var(--action-control-focus)!important;
}

:is(
  .btn,
  .icon-action,
  .search-toolbar-button,
  .hero-icon-button,
  .section-icon-button,
  .print-section-button,
  .quick-buttons button,
  .rich-editor-toolbar button,
  .pagination a,
  .topbar .nav.nav-distributed a.nav-icon-only,
  .topbar .nav.nav-distributed a.nav-logout
):active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(27,74,89,.11)!important;
}

/* Core command palette: calm medical colors with enough separation in daylight. */
.btn-soft,.btn-compact {
  background: #fbfdfe!important;
  border-color: #bfd2db!important;
  color: #315867!important
}

.btn-primary {
  border-color: #0a706c!important;
  box-shadow: 0 5px 14px rgba(15,127,120,.18)!important
}

.btn-ok {
  background: #edf9f3!important;
  border-color: #a9d8bd!important;
  color: #137348!important
}

.btn-danger {
  background: #fff5f3!important;
  border-color: #efbeb8!important;
  color: #a9342b!important
}

.search-toolbar-add {
  background: #effaf7!important;
  border-color: #9fd4cb!important;
  color: #087b72!important
}

.search-toolbar-stats,.archive-year-stats-button {
  background: #f0f7fc!important;
  border-color: #abcde2!important;
  color: #286b96!important
}

.section-icon-button,.print-section-button {
  background: #f1faf9!important;
  border-color: #afd7d3!important;
  color: #0c7f79!important
}

.patient-card-actions .icon-action {
  background: #fbfdfe!important;
  border-color: #bfd3dc!important;
  color: #466f82!important
}

.patient-card-actions .icon-action.primary {
  background: #eef9f7!important;
  border-color: #9fd4cb!important;
  color: #087b72!important
}

.patient-card-actions .icon-action.danger {
  background: #fff4f2!important;
  border-color: #eebeb8!important;
  color: #ae372e!important
}

/* Make the small icon capsule itself slightly clearer inside command controls. */
:is(.btn,.icon-action,.search-toolbar-button,.archive-year-stats-button,.nav-logout,.section-icon-button,.print-section-button)>.ui-icon {
  border-width: 1.25px!important;
  box-shadow: 0 2px 6px rgba(31,78,91,.11)!important;
}

/* Banner icons: keep each function distinct while strengthening the frame. */
.topbar .nav.nav-distributed a.nav-home {
  border-color: #91cec5!important;
  box-shadow: 0 4px 12px rgba(8,125,114,.12)!important
}

.topbar .nav.nav-distributed a.nav-archive {
  border-color: #a7c8df!important;
  box-shadow: 0 4px 12px rgba(52,118,168,.12)!important
}

.topbar .nav.nav-distributed a.nav-quick {
  border-color: #c9b9e8!important;
  box-shadow: 0 4px 12px rgba(113,86,173,.12)!important
}

.topbar .nav.nav-distributed a.nav-clinics {
  border-color: #aad7bc!important;
  box-shadow: 0 4px 12px rgba(42,133,84,.12)!important
}

.topbar .nav.nav-distributed a.nav-admin {
  border-color: #dfbf93!important;
  box-shadow: 0 4px 12px rgba(166,109,37,.12)!important
}

.topbar .nav.nav-distributed a.nav-logout {
  border-color: #e6b9b3!important;
  box-shadow: 0 4px 12px rgba(167,91,82,.11)!important
}

/* Dark mode: brighter borders and deeper shadows so controls remain obvious. */
html[data-theme-effective="dark"] {
  --action-control-bg: #162428;
  --action-control-border: #4b6670;
  --action-control-shadow: 0 4px 13px rgba(0,0,0,.28),inset 0 0 0 1px rgba(255,255,255,.025);
  --action-control-hover-shadow: 0 7px 18px rgba(0,0,0,.36),inset 0 0 0 1px rgba(255,255,255,.045);
  --action-control-focus: 0 0 0 3px rgba(87,205,199,.18);
}

html[data-theme-effective="dark"] :is(.btn-soft,.btn-compact) {
  background: #17272b!important;
  border-color: #45616a!important;
  color: #d7e7ea!important
}

html[data-theme-effective="dark"] .btn-primary {
  border-color: #3c9f98!important;
  box-shadow: 0 5px 15px rgba(0,0,0,.30)!important
}

html[data-theme-effective="dark"] .btn-ok {
  background: #162b22!important;
  border-color: #376e52!important;
  color: #9ae0b7!important
}

html[data-theme-effective="dark"] .btn-danger {
  background: #321d1c!important;
  border-color: #6b3b36!important;
  color: #ffaaa3!important
}

html[data-theme-effective="dark"] .search-toolbar-add {
  background: #16302d!important;
  border-color: #3f716b!important;
  color: #7de0d4!important
}

html[data-theme-effective="dark"] :is(.search-toolbar-stats,.archive-year-stats-button) {
  background: #162b39!important;
  border-color: #45677c!important;
  color: #8dc9ef!important
}

html[data-theme-effective="dark"] :is(.section-icon-button,.print-section-button) {
  background: #17302f!important;
  border-color: #3d6f6b!important;
  color: #81ded6!important
}

html[data-theme-effective="dark"] .patient-card-actions .icon-action {
  background: #17272b!important;
  border-color: #48616a!important;
  color: #c8e0e5!important
}

html[data-theme-effective="dark"] .patient-card-actions .icon-action.primary {
  background: #173330!important;
  border-color: #3f716b!important;
  color: #7de0d4!important
}

html[data-theme-effective="dark"] .patient-card-actions .icon-action.danger {
  background: #321e1d!important;
  border-color: #6a3b36!important;
  color: #f4aaa3!important
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-home {
  border-color: #39766f!important;
  box-shadow: 0 4px 13px rgba(0,0,0,.28)!important
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-archive {
  border-color: #416678!important;
  box-shadow: 0 4px 13px rgba(0,0,0,.28)!important
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-quick {
  border-color: #5b4a77!important;
  box-shadow: 0 4px 13px rgba(0,0,0,.28)!important
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-clinics {
  border-color: #406c51!important;
  box-shadow: 0 4px 13px rgba(0,0,0,.28)!important
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-admin {
  border-color: #6b5533!important;
  box-shadow: 0 4px 13px rgba(0,0,0,.28)!important
}

html[data-theme-effective="dark"] .topbar .nav.nav-distributed a.nav-logout {
  border-color: #6a4541!important;
  box-shadow: 0 4px 13px rgba(0,0,0,.28)!important
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] {
    --action-control-bg: #162428;
    --action-control-border: #4b6670;
    --action-control-shadow: 0 4px 13px rgba(0,0,0,.28),inset 0 0 0 1px rgba(255,255,255,.025);
    --action-control-hover-shadow: 0 7px 18px rgba(0,0,0,.36),inset 0 0 0 1px rgba(255,255,255,.045);
    --action-control-focus: 0 0 0 3px rgba(87,205,199,.18);
  }

  html[data-theme-mode="auto"] :is(.btn-soft,.btn-compact) {
    background: #17272b!important;
    border-color: #45616a!important;
    color: #d7e7ea!important
  }

  html[data-theme-mode="auto"] .btn-primary {
    border-color: #3c9f98!important;
    box-shadow: 0 5px 15px rgba(0,0,0,.30)!important
  }

  html[data-theme-mode="auto"] .btn-ok {
    background: #162b22!important;
    border-color: #376e52!important;
    color: #9ae0b7!important
  }

  html[data-theme-mode="auto"] .btn-danger {
    background: #321d1c!important;
    border-color: #6b3b36!important;
    color: #ffaaa3!important
  }

  html[data-theme-mode="auto"] .search-toolbar-add {
    background: #16302d!important;
    border-color: #3f716b!important;
    color: #7de0d4!important
  }

  html[data-theme-mode="auto"] :is(.search-toolbar-stats,.archive-year-stats-button) {
    background: #162b39!important;
    border-color: #45677c!important;
    color: #8dc9ef!important
  }

  html[data-theme-mode="auto"] :is(.section-icon-button,.print-section-button) {
    background: #17302f!important;
    border-color: #3d6f6b!important;
    color: #81ded6!important
  }

  html[data-theme-mode="auto"] .patient-card-actions .icon-action {
    background: #17272b!important;
    border-color: #48616a!important;
    color: #c8e0e5!important
  }

  html[data-theme-mode="auto"] .patient-card-actions .icon-action.primary {
    background: #173330!important;
    border-color: #3f716b!important;
    color: #7de0d4!important
  }

  html[data-theme-mode="auto"] .patient-card-actions .icon-action.danger {
    background: #321e1d!important;
    border-color: #6a3b36!important;
    color: #f4aaa3!important
  }

  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-home {
    border-color: #39766f!important;
    box-shadow: 0 4px 13px rgba(0,0,0,.28)!important
  }

  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-archive {
    border-color: #416678!important;
    box-shadow: 0 4px 13px rgba(0,0,0,.28)!important
  }

  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-quick {
    border-color: #5b4a77!important;
    box-shadow: 0 4px 13px rgba(0,0,0,.28)!important
  }

  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-clinics {
    border-color: #406c51!important;
    box-shadow: 0 4px 13px rgba(0,0,0,.28)!important
  }

  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-admin {
    border-color: #6b5533!important;
    box-shadow: 0 4px 13px rgba(0,0,0,.28)!important
  }

  html[data-theme-mode="auto"] .topbar .nav.nav-distributed a.nav-logout {
    border-color: #6a4541!important;
    box-shadow: 0 4px 13px rgba(0,0,0,.28)!important
  }

}

@media(max-width:560px) {
  :is(.btn,.search-toolbar-button,.icon-action) {
    box-shadow: 0 3px 9px rgba(25,70,82,.10)!important
  }

  html[data-theme-effective="dark"] :is(.btn,.search-toolbar-button,.icon-action) {
    box-shadow: 0 3px 10px rgba(0,0,0,.26)!important
  }

}

/* === [S15] Button text, payment status and daily visit states === */
:is(
  .btn,
  .icon-action,
  .search-toolbar-button,
  .hero-icon-button,
  .section-icon-button,
  .print-section-button,
  .quick-buttons button,
  .rich-editor-toolbar button,
  .pagination a,
  .archive-year-stats-button,
  .topbar .nav.nav-distributed a
) {
  font-weight: 900!important
}

.today-visit-card {
  border: 1.5px solid #a8d9d2!important;
  background: linear-gradient(180deg,#fbfffe 0%,#f6fcfb 100%);
  box-shadow: 0 7px 22px rgba(22,105,101,.08);
}

.today-visit-heading {
  align-items: flex-start
}

.today-visit-state {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end
}

.today-visit-date {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 29px;
  padding: 5px 8px;
  border: 1px solid #c8dfdf;
  border-radius: 10px;
  background: #fff;
  color: #44666c;
  font-size: 10px;
  font-weight: 900;
  direction: ltr
}

.today-visit-date .ui-icon {
  width: 14px;
  height: 14px;
  color: #188279
}

.today-visit-card .clinical-box {
  border-color: #cfe5e2;
  background: #fff
}

.today-visit-card .save-visit-button {
  min-width: 170px
}

.today-visit-thumbs {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #dcebea
}

.previous-visits-section {
  margin-top: 13px
}

html[data-theme-effective="dark"] .today-visit-card {
  background: linear-gradient(180deg,#122225 0%,#101d20 100%);
  border-color: #376c67!important;
  box-shadow: 0 7px 23px rgba(0,0,0,.30)
}

html[data-theme-effective="dark"] .today-visit-date {
  background: #17272b;
  border-color: #3d5960;
  color: #c8dadd
}

html[data-theme-effective="dark"] .today-visit-date .ui-icon {
  color: #7edbd2
}

html[data-theme-effective="dark"] .today-visit-card .clinical-box {
  background: #122024;
  border-color: #2c4649
}

html[data-theme-effective="dark"] .today-visit-thumbs {
  border-top-color: #2c4247
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .today-visit-card {
    background: linear-gradient(180deg,#122225 0%,#101d20 100%);
    border-color: #376c67!important;
    box-shadow: 0 7px 23px rgba(0,0,0,.30)
  }

  html[data-theme-mode="auto"] .today-visit-date {
    background: #17272b;
    border-color: #3d5960;
    color: #c8dadd
  }

  html[data-theme-mode="auto"] .today-visit-date .ui-icon {
    color: #7edbd2
  }

  html[data-theme-mode="auto"] .today-visit-card .clinical-box {
    background: #122024;
    border-color: #2c4649
  }

  html[data-theme-mode="auto"] .today-visit-thumbs {
    border-top-color: #2c4247
  }

}

@media(max-width:560px) {
  .today-visit-heading {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px
  }

  .today-visit-state {
    justify-content: flex-start
  }

  .today-visit-card .save-visit-button {
    width: 100%;
    min-width: 0
  }

}

.visit-patient-type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 29px;
  padding: 5px 9px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap
}

.visit-patient-type.new {
  background: #fff9df;
  border-color: #e6cf71;
  color: #80610a
}

.visit-patient-type.returning {
  background: #edf8f4;
  border-color: #a8d5c0;
  color: #176b4a
}

html[data-theme-effective="dark"] .visit-patient-type.new {
  background: #312b16;
  border-color: #71622d;
  color: #f0d777
}

html[data-theme-effective="dark"] .visit-patient-type.returning {
  background: #162d24;
  border-color: #39644e;
  color: #8dd4ad
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .visit-patient-type.new {
    background: #312b16;
    border-color: #71622d;
    color: #f0d777
  }

  html[data-theme-mode="auto"] .visit-patient-type.returning {
    background: #162d24;
    border-color: #39644e;
    color: #8dd4ad
  }

}

/* === [S16] Patient intake and today-visit form layout === */
.integrated-patient-booking-form {
  display: grid;
  gap: 12px
}

.patient-intake-section {
  padding: 12px;
  border: 1px solid #d8e6eb;
  border-radius: 15px;
  background: #fbfdfe
}

.patient-intake-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px
}

.patient-intake-heading h2 {
  font-size: 17px
}

.patient-intake-heading p {
  margin: 4px 0 0;
  font-size: 11px;
  line-height: 1.6
}

.patient-intake-heading .section-icon {
  width: 38px;
  height: 38px;
  padding: 8px;
  border: 1px solid #bfddd8;
  border-radius: 12px;
  background: #eef9f7;
  color: #0b7c73;
  box-shadow: 0 3px 9px rgba(22,105,101,.08)
}

.booking-intake-section {
  border-color: #b9ddd8;
  background: linear-gradient(180deg,#fbfffe,#f5fbfa)
}

.booking-intake-section .money-input input {
  min-height: 44px
}

.integrated-patient-booking-form .patient-save-btn {
  margin-top: 0!important;
  min-height: 50px
}

html[data-theme-effective="dark"] .patient-intake-section {
  background: #132126;
  border-color: #30464d
}

html[data-theme-effective="dark"] .booking-intake-section {
  background: linear-gradient(180deg,#132525,#111f22);
  border-color: #3b6661
}

html[data-theme-effective="dark"] .patient-intake-heading .section-icon {
  background: #173330;
  border-color: #3f716b;
  color: #7de0d4;
  box-shadow: 0 3px 10px rgba(0,0,0,.25)
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .patient-intake-section {
    background: #132126;
    border-color: #30464d
  }

  html[data-theme-mode="auto"] .booking-intake-section {
    background: linear-gradient(180deg,#132525,#111f22);
    border-color: #3b6661
  }

  html[data-theme-mode="auto"] .patient-intake-heading .section-icon {
    background: #173330;
    border-color: #3f716b;
    color: #7de0d4;
    box-shadow: 0 3px 10px rgba(0,0,0,.25)
  }

}

@media(max-width:560px) {
  .patient-new-card {
    padding: 12px
  }

  .patient-intake-section {
    padding: 10px
  }

  .patient-intake-heading {
    margin-bottom: 9px
  }

  .patient-intake-heading h2 {
    font-size: 16px
  }

  .integrated-patient-booking-form {
    gap: 9px
  }

}

/* === [S17] Daily archive numbering === */
/* v1.7.7 — Daily archive numbering. View-only; no database field required. */
.archive-daily-sequence {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid #9fcbd2;
  border-radius: 8px;
  background: #eef9fa;
  color: #245a64;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  direction: ltr;
  box-shadow: 0 2px 7px rgba(32,92,103,.08)
}

html[data-theme-effective="dark"] .archive-daily-sequence {
  background: #173036;
  border-color: #3e737d;
  color: #d8f3f5;
  box-shadow: 0 2px 8px rgba(0,0,0,.18)
}

@media (prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .archive-daily-sequence {
    background: #173036;
    border-color: #3e737d;
    color: #d8f3f5;
    box-shadow: 0 2px 8px rgba(0,0,0,.18)
  }

}

/* === [S18] Expired-data cleanup center === */
.cleanup-filter-card {
  position: relative;
  overflow: hidden
}

.cleanup-filter-card:before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg,var(--primary),var(--accent))
}

.cleanup-filter-submit {
  display: flex;
  align-items: flex-end
}

.cleanup-filter-submit .btn {
  min-width: 210px
}

.cleanup-summary {
  border-color: #cbdbe9;
  background: linear-gradient(180deg,#fff,#f9fcff)
}

.cleanup-summary-metrics {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 9px;
  margin-top: 14px
}

.cleanup-summary-metrics>div {
  padding: 11px;
  border: 1px solid #d9e5ef;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 3px 10px rgba(28,71,94,.05)
}

.cleanup-summary-metrics span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  margin-bottom: 5px
}

.cleanup-summary-metrics b {
  font-size: 18px;
  direction: ltr;
  display: inline-block
}

.cleanup-review-note {
  margin: 11px 0 0;
  padding: 9px 11px;
  border: 1px solid #ead9a6;
  border-radius: 12px;
  background: #fffaf0;
  color: #74551b;
  font-size: 11px;
  font-weight: 750
}

.cleanup-items-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px
}

.cleanup-item-card {
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1.5px solid #cbd9e5;
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 4px 13px rgba(26,70,89,.055);
  cursor: pointer;
  transition: .16s ease
}

.cleanup-item-card:hover {
  border-color: #8fb2ca;
  box-shadow: 0 7px 18px rgba(26,70,89,.09);
  transform: translateY(-1px)
}

.cleanup-item-card.is-empty {
  opacity: .66
}

.cleanup-check {
  display: grid;
  place-items: center
}

.cleanup-check input {
  width: 19px;
  height: 19px;
  accent-color: var(--primary);
  cursor: pointer
}

.cleanup-item-copy {
  min-width: 0
}

.cleanup-item-copy>b {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
  color: #24384d
}

.cleanup-item-copy small {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.55
}

.cleanup-scope {
  display: inline-flex!important;
  width: max-content;
  margin-top: 6px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef5fb;
  color: #4a657b!important;
  font-size: 9px!important;
  font-weight: 900!important
}

.cleanup-item-metric {
  text-align: left;
  min-width: 72px;
  direction: ltr
}

.cleanup-item-metric strong {
  display: block;
  font-size: 19px;
  color: #1b3850
}

.cleanup-item-metric small {
  display: block;
  margin-top: 3px;
  color: #6c8091;
  font-size: 10px;
  font-weight: 800
}

.cleanup-safety-box {
  margin-top: 14px;
  padding: 14px;
  border: 1.5px solid #e2a29d;
  border-radius: 16px;
  background: linear-gradient(180deg,#fff8f7,#fff3f2)
}

.cleanup-safety-box h3 {
  color: #8e2c25
}

.cleanup-safety-box p {
  margin: 6px 0 11px;
  color: #74504c;
  font-size: 11px
}

.cleanup-safety-box .field {
  max-width: 420px;
  margin-bottom: 10px
}

.cleanup-safety-box .field input {
  border-color: #ddb3af;
  background: #fff
}

.cleanup-safety-box .btn-danger {
  font-weight: 900
}

.cleanup-static-note {
  border-style: dashed
}

.cleanup-static-note p {
  margin-bottom: 0;
  font-size: 11px
}

html[data-theme-effective="dark"] .cleanup-summary {
  background: linear-gradient(180deg,#142226,#111d21);
  border-color: #36515a
}

html[data-theme-effective="dark"] .cleanup-summary-metrics>div {
  background: #17272b;
  border-color: #344c54;
  box-shadow: 0 3px 11px rgba(0,0,0,.20)
}

html[data-theme-effective="dark"] .cleanup-review-note {
  background: #2a2518;
  border-color: #655a31;
  color: #e3cc86
}

html[data-theme-effective="dark"] .cleanup-item-card {
  background: #142327;
  border-color: #3c5861;
  box-shadow: 0 4px 13px rgba(0,0,0,.24)
}

html[data-theme-effective="dark"] .cleanup-item-card:hover {
  border-color: #5c8792;
  box-shadow: 0 7px 18px rgba(0,0,0,.32)
}

html[data-theme-effective="dark"] .cleanup-item-copy>b {
  color: #dcebed
}

html[data-theme-effective="dark"] .cleanup-scope {
  background: #1d3138;
  color: #a9cbd2!important
}

html[data-theme-effective="dark"] .cleanup-item-metric strong {
  color: #d8eff2
}

html[data-theme-effective="dark"] .cleanup-item-metric small {
  color: #9db5ba
}

html[data-theme-effective="dark"] .cleanup-safety-box {
  background: linear-gradient(180deg,#2b1b1b,#241717);
  border-color: #70443f
}

html[data-theme-effective="dark"] .cleanup-safety-box h3 {
  color: #ffb0a9
}

html[data-theme-effective="dark"] .cleanup-safety-box p {
  color: #d8aaa5
}

html[data-theme-effective="dark"] .cleanup-safety-box .field input {
  background: #172327;
  border-color: #6a4946;
  color: #eef5f6
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .cleanup-summary {
    background: linear-gradient(180deg,#142226,#111d21);
    border-color: #36515a
  }

  html[data-theme-mode="auto"] .cleanup-summary-metrics>div {
    background: #17272b;
    border-color: #344c54;
    box-shadow: 0 3px 11px rgba(0,0,0,.20)
  }

  html[data-theme-mode="auto"] .cleanup-review-note {
    background: #2a2518;
    border-color: #655a31;
    color: #e3cc86
  }

  html[data-theme-mode="auto"] .cleanup-item-card {
    background: #142327;
    border-color: #3c5861;
    box-shadow: 0 4px 13px rgba(0,0,0,.24)
  }

  html[data-theme-mode="auto"] .cleanup-item-card:hover {
    border-color: #5c8792;
    box-shadow: 0 7px 18px rgba(0,0,0,.32)
  }

  html[data-theme-mode="auto"] .cleanup-item-copy>b {
    color: #dcebed
  }

  html[data-theme-mode="auto"] .cleanup-scope {
    background: #1d3138;
    color: #a9cbd2!important
  }

  html[data-theme-mode="auto"] .cleanup-item-metric strong {
    color: #d8eff2
  }

  html[data-theme-mode="auto"] .cleanup-item-metric small {
    color: #9db5ba
  }

  html[data-theme-mode="auto"] .cleanup-safety-box {
    background: linear-gradient(180deg,#2b1b1b,#241717);
    border-color: #70443f
  }

  html[data-theme-mode="auto"] .cleanup-safety-box h3 {
    color: #ffb0a9
  }

  html[data-theme-mode="auto"] .cleanup-safety-box p {
    color: #d8aaa5
  }

  html[data-theme-mode="auto"] .cleanup-safety-box .field input {
    background: #172327;
    border-color: #6a4946;
    color: #eef5f6
  }

}

@media(min-width:720px) {
  .cleanup-items-grid {
    grid-template-columns: repeat(2,minmax(0,1fr))
  }

  .cleanup-summary-metrics {
    grid-template-columns: repeat(4,minmax(0,1fr))
  }

}

@media(max-width:560px) {
  .cleanup-filter-submit .btn {
    width: 100%;
    min-width: 0
  }

  .cleanup-item-card {
    grid-template-columns: auto minmax(0,1fr);
    align-items: start
  }

  .cleanup-item-metric {
    grid-column: 2;
    text-align: right;
    display: flex;
    align-items: baseline;
    gap: 7px;
    min-width: 0
  }

  .cleanup-summary-metrics {
    grid-template-columns: 1fr 1fr
  }

}

/* === [S19] Multi-clinic cleanup controls === */
/* v1.7.10.1 multi-clinic cleanup */
.cleanup-clinic-picker {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding: 9px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2)
}

.cleanup-clinic-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid #cfdce6;
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  box-shadow: 0 2px 7px rgba(28,71,94,.04)
}

.cleanup-clinic-option:hover {
  border-color: #8fb2ca
}

.cleanup-clinic-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex: 0 0 auto
}

.cleanup-clinic-option span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  width: 100%
}

.cleanup-clinic-option b {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}

.cleanup-clinic-option small {
  font-size: 9px;
  color: var(--danger);
  font-weight: 900;
  white-space: nowrap
}

.other-sessions-panel {
  border: 1.5px solid #c8dbea;
  box-shadow: 0 7px 20px rgba(28,71,94,.06)
}

.inline-cleanup-summary {
  margin: 12px 0;
  padding: 12px
}

.compact-cleanup-delete {
  margin-top: 12px
}

@media (min-width:760px) {
  .form-grid.three {
    grid-template-columns: repeat(3,minmax(0,1fr))
  }

  .field-span-three {
    grid-column: 1/-1
  }

}

html[data-theme-effective="dark"] .cleanup-clinic-option {
  background: #142327;
  border-color: #3c5861;
  box-shadow: 0 2px 7px rgba(0,0,0,.20)
}

html[data-theme-effective="dark"] .cleanup-clinic-option:hover {
  border-color: #5c8792
}

html[data-theme-effective="dark"] .other-sessions-panel {
  border-color: #36515a;
  box-shadow: 0 7px 20px rgba(0,0,0,.22)
}

@media (prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .cleanup-clinic-option {
    background: #142327;
    border-color: #3c5861;
    box-shadow: 0 2px 7px rgba(0,0,0,.20)
  }

  html[data-theme-mode="auto"] .cleanup-clinic-option:hover {
    border-color: #5c8792
  }

  html[data-theme-mode="auto"] .other-sessions-panel {
    border-color: #36515a;
    box-shadow: 0 7px 20px rgba(0,0,0,.22)
  }

}

@media (max-width:680px) {
  .cleanup-clinic-picker {
    grid-template-columns: 1fr;
    max-height: 260px
  }

  .other-session-filter {
    grid-template-columns: 1fr
  }

  .field-span-three {
    grid-column: auto
  }

}

/* === [S20] Patient and visit notes === */
.patient-file-notes {
  overflow: hidden
}

.patient-page-save-bar {
  margin: 0 0 16px
}

.patient-page-save-button {
  min-height: 50px
}

.patient-notes-heading {
  margin-bottom: 11px
}

.patient-notes-heading p {
  margin: 4px 0 0;
  font-size: 11px
}

.patient-note-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px
}

.patient-note-card {
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
  min-width: 0
}

.patient-note-card-title {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 9px
}

.patient-note-card-title>.ui-icon {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  margin-top: 1px
}

.patient-note-card-title b {
  display: block;
  font-size: 12px
}

.patient-note-card-title small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.5
}

.doctor-patient-note {
  border-color: #b9ddd9;
  background: #f4fbfa
}

.doctor-patient-note .patient-note-card-title>.ui-icon {
  color: #0f7f78
}

.secretary-patient-note {
  border-color: #d9c8ef;
  background: #faf7ff
}

.secretary-patient-note .patient-note-card-title>.ui-icon {
  color: #7851a9
}

.patient-note-form {
  display: grid;
  gap: 8px
}

.patient-note-form textarea,.secretary-intake-note textarea {
  min-height: 108px;
  resize: vertical;
  line-height: 1.75
}

.patient-note-form textarea {
  width: 100%;
  border: 1px solid #cbd6e2;
  border-radius: 13px;
  padding: 12px 13px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: .16s ease
}

.patient-note-form textarea:focus {
  border-color: color-mix(in srgb,var(--primary) 62%,#cbd6e2);
  box-shadow: 0 0 0 3px color-mix(in srgb,var(--primary) 10%,transparent)
}

.patient-note-save {
  width: 100%;
  min-height: 43px
}

.patient-note-value {
  min-height: 54px;
  padding: 10px 11px;
  border: 1px solid color-mix(in srgb,var(--line) 82%,transparent);
  border-radius: 12px;
  background: var(--surface);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.8;
  font-size: 12px;
  color: var(--text)
}

.secretary-intake-note {
  padding-top: 2px
}

.secretary-intake-note small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px
}

.visit-notes-field {
  margin-top: 10px
}

.visit-notes-field textarea {
  min-height: 92px;
  line-height: 1.75
}

.visit-note-readonly {
  margin-top: 10px
}

.note-permissions-heading {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line)
}

.note-permission-card {
  border-color: color-mix(in srgb,var(--primary) 24%,var(--line))
}

html[data-theme-effective="dark"] .doctor-patient-note .patient-note-card-title>.ui-icon {
  color: #7de0d4
}

html[data-theme-effective="dark"] .secretary-patient-note .patient-note-card-title>.ui-icon {
  color: #c9a7ef
}

html[data-theme-effective="dark"] .patient-note-value {
  background: #111d21;
  border-color: #33494f;
  color: #e6f0f2
}

html[data-theme-effective="dark"] .patient-note-form textarea {
  background: #0e191c;
  border-color: #31454b;
  color: var(--text)
}

html[data-theme-effective="dark"] .patient-note-form textarea::placeholder {
  color: #728a91
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .doctor-patient-note .patient-note-card-title>.ui-icon {
    color: #7de0d4
  }

  html[data-theme-mode="auto"] .secretary-patient-note .patient-note-card-title>.ui-icon {
    color: #c9a7ef
  }

  html[data-theme-mode="auto"] .patient-note-value {
    background: #111d21;
    border-color: #33494f;
    color: #e6f0f2
  }

  html[data-theme-mode="auto"] .patient-note-form textarea {
    background: #0e191c;
    border-color: #31454b;
    color: var(--text)
  }

  html[data-theme-mode="auto"] .patient-note-form textarea::placeholder {
    color: #728a91
  }

}

@media(min-width:760px) {
  .patient-note-grid {
    grid-template-columns: repeat(2,minmax(0,1fr))
  }

  .patient-note-save {
    width: max-content;
    min-width: 190px
  }

}

@media(max-width:560px) {
  .patient-file-notes {
    padding: 12px
  }

  .patient-note-card {
    padding: 10px;
    border-radius: 14px
  }

  .patient-note-form textarea,.secretary-intake-note textarea {
    min-height: 96px
  }

  .visit-notes-field textarea {
    min-height: 88px
  }

  .note-permissions-grid {
    grid-template-columns: 1fr
  }

}

/* === [S21] Unpaid booking fee presentation === */
/* New-patient unpaid booking: fee is intentionally fixed to zero. */
.payment-fee-field.is-unpaid .money-input {
  opacity: .78
}

.payment-fee-field.is-unpaid .money-input input:disabled {
  background: #edf2f5;
  border-color: #cbd6dc;
  color: #64767d;
  cursor: not-allowed;
  -webkit-text-fill-color: #64767d;
  opacity: 1
}

.payment-fee-field.is-unpaid>small {
  font-weight: 700;
  color: #65787f
}

html[data-theme-effective="dark"] .payment-fee-field.is-unpaid .money-input input:disabled {
  background: #172327;
  border-color: #334a51;
  color: #91a6ad;
  -webkit-text-fill-color: #91a6ad
}

html[data-theme-effective="dark"] .payment-fee-field.is-unpaid>small {
  color: #91a6ad
}

@media (prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .payment-fee-field.is-unpaid .money-input input:disabled {
    background: #172327;
    border-color: #334a51;
    color: #91a6ad;
    -webkit-text-fill-color: #91a6ad
  }

  html[data-theme-mode="auto"] .payment-fee-field.is-unpaid>small {
    color: #91a6ad
  }

}

/* === [S22] Validation guidance dialog === */
/* Small instructional modal used for client-side validation without navigating away. */
.instruction-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(9,16,24,.62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px)
}

.instruction-modal[hidden] {
  display: none!important
}

.instruction-modal-card {
  width: min(100%,360px);
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 22px 60px rgba(10,28,45,.28);
  opacity: 1
}

.instruction-modal-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: var(--primary-soft);
  border: 1px solid color-mix(in srgb,var(--primary) 28%,var(--line));
  color: var(--primary);
  font-size: 22px;
  font-weight: 900
}

.instruction-modal-card h2 {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.35;
  color: var(--text)
}

.instruction-modal-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8
}

.instruction-modal-ok {
  width: 100%;
  min-height: 46px;
  margin-top: 16px
}

.has-instruction-modal {
  overflow: hidden
}

html[data-theme-effective="dark"] .instruction-modal {
  background: rgba(0,0,0,.76)
}

html[data-theme-effective="dark"] .instruction-modal-card {
  background: #111b1f;
  border-color: #3a5158;
  box-shadow: 0 24px 64px rgba(0,0,0,.56)
}

html[data-theme-effective="dark"] .instruction-modal-icon {
  background: #173533;
  border-color: #355e59;
  color: #7de0d4
}

@media (prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .instruction-modal {
    background: rgba(0,0,0,.76)
  }

  html[data-theme-mode="auto"] .instruction-modal-card {
    background: #111b1f;
    border-color: #3a5158;
    box-shadow: 0 24px 64px rgba(0,0,0,.56)
  }

  html[data-theme-mode="auto"] .instruction-modal-icon {
    background: #173533;
    border-color: #355e59;
    color: #7de0d4
  }

}

@media (max-width:420px) {
  .instruction-modal {
    padding: 14px
  }

  .instruction-modal-card {
    border-radius: 16px;
    padding: 18px 16px
  }

  .instruction-modal-card h2 {
    font-size: 17px
  }

  .instruction-modal-card p {
    font-size: 13px
  }

}

/* === [S23] Theme surfaces and automatic-mode fallback ===
Consolidates late-added UI components so forced dark and auto-dark never fall back
   to light cards. Paper/template white surfaces are intentionally excluded. */
html[data-theme-effective="dark"] {
  --theme-card: #111b1f;
  --theme-card-2: #162327;
  --theme-card-3: #0f1a1d;
  --theme-field: #0e191c;
  --theme-border: #31454b;
  --theme-border-soft: #27383d;
  --theme-text: #e7f0f2;
  --theme-muted: #91a6ad;
}

html[data-theme-effective="dark"] :is(.brand,.field label,.meta-item strong,.archive-card h2,.clinical-title,.visit-date,.visit-block-title,.visit-text,.year-stat-item b,.system-validity-heading h2,.patient-edit-details summary,.archive-patient-zone summary,.delete-patient-zone summary) {
  color: var(--theme-text)
}

html[data-theme-effective="dark"] :is(.meta-label,.patient-tile-footer,.stats-date,.search-results-head,.patient-stat-footer,.archive-card p,.archive-label,.profile-code,.profile-meta span,.visit-date span,.visit-doctor) {
  color: var(--theme-muted)
}

/* Navigation and generic interactive light surfaces. */
html[data-theme-effective="dark"] .nav a:not(.nav-add-patient):not(.nav-icon-only):not(.nav-logout) {
  background: var(--theme-card-2);
  border-color: var(--theme-border);
  color: var(--theme-text)
}

html[data-theme-effective="dark"] .nav a:not(.nav-add-patient):not(.nav-icon-only):not(.nav-logout):hover {
  background: #1b2b30;
  border-color: #46636b;
  color: #eef8fa
}

html[data-theme-effective="dark"] :is(.pagination a,.page-current,.profile-actions,.archive-breadcrumbs,.archive-card,.visit-card-modern,.year-stat-item) {
  background: var(--theme-card);
  border-color: var(--theme-border-soft);
  color: var(--theme-text)
}

html[data-theme-effective="dark"] :is(.archive-card:hover,.visit-row-card:hover) {
  background: #152226;
  border-color: #405960
}

/* Patient cards: legacy + modern + patient profile. */
html[data-theme-effective="dark"] :is(.visit-row-card,.meta-item,.patient-card-info>div,.patient-inline-stats,.archive-year-stats-panel) {
  background: var(--theme-card-2);
  border-color: var(--theme-border-soft)
}

html[data-theme-effective="dark"] :is(.avatar,.patient-avatar,.patient-avatar-modern,.profile-avatar,.archive-icon,.archive-day-number) {
  background: linear-gradient(145deg,#17302f,#172b35);
  border-color: #345258;
  color: #7bd8d0
}

html[data-theme-effective="dark"] .patient-profile-hero {
  background: linear-gradient(145deg,#112528,#101d22);
  border-color: #2e484d;
  box-shadow: 0 12px 30px rgba(0,0,0,.24)
}

html[data-theme-effective="dark"] .profile-meta span {
  background: #17272b;
  border: 1px solid #2f474d
}

html[data-theme-effective="dark"] .profile-actions {
  background: #111d21;
  border-color: #30464c
}

html[data-theme-effective="dark"] .patient-card-chevron {
  background: #18272b;
  color: #9bb0b6
}

html[data-theme-effective="dark"] .file-code {
  background: #18262b;
  color: #a9c0c6
}

html[data-theme-effective="dark"] .patient-visibility-control.is-hidden {
  background: #171f22;
  border-inline-start-color: #68777b
}

html[data-theme-effective="dark"] .visibility-hide-button {
  background: #2b1d1d!important;
  border-color: #65413d!important;
  color: #f1aaa3!important
}

/* Archive years/months/days. */
html[data-theme-effective="dark"] .archive-breadcrumbs a {
  color: #75d6cc
}

html[data-theme-effective="dark"] .archive-arrow {
  color: #71888e
}

html[data-theme-effective="dark"] .archive-year-stats-panel {
  border-top-color: #2b4045
}

html[data-theme-effective="dark"] .archive-year-stats-button {
  background: #17272b!important;
  border-color: #365159!important;
  color: #b8d4d9!important
}

html[data-theme-effective="dark"] .year-stat-item b {
  color: #d8ecef
}

/* Clinical/current-visit and previous-visit content. */
html[data-theme-effective="dark"] :is(.clinical-box,.visit-clinical-block) {
  background: #121f23;
  border-color: #2d444a
}

html[data-theme-effective="dark"] .visit-clinical-block.treatment {
  background: #132026
}

html[data-theme-effective="dark"] .clinical-box textarea {
  background: var(--theme-field);
  border-color: var(--theme-border);
  color: var(--theme-text)
}

html[data-theme-effective="dark"] .clinical-box textarea::placeholder {
  color: #728a91
}

html[data-theme-effective="dark"] :is(.visit-card-header,.visit-thumbs,.visit-actions) {
  border-color: #2a3e43
}

html[data-theme-effective="dark"] .visit-note {
  background: #292416;
  border-color: #625631;
  color: #e3cc8a
}

html[data-theme-effective="dark"] .fee-badge {
  background: #16312b;
  color: #8addba;
  border: 1px solid #315845
}

html[data-theme-effective="dark"] .quick-buttons button {
  background: #17302e!important;
  border-color: #315b56!important;
  color: #9be1d8!important
}

/* Status chips and live sync. */
html[data-theme-effective="dark"] .paid {
  background: #153126;
  color: #81ddb0;
  border: 1px solid #28513f
}

html[data-theme-effective="dark"] .unpaid {
  background: #351d1d;
  color: #ffaaa3;
  border: 1px solid #5d3330
}

html[data-theme-effective="dark"] :is(.live-pill,.live-sync-pill) {
  background: #162823;
  border-color: #315044;
  color: #a8d7c6
}

html[data-theme-effective="dark"] .live-sync-pill:hover {
  background: #1b322c;
  border-color: #45685b
}

html[data-theme-effective="dark"] .live-sync-pill.is-updated {
  background: #163126;
  color: #81ddb0;
  border-color: #315840
}

html[data-theme-effective="dark"] .live-sync-pill.is-error {
  background: #351d1d;
  color: #ffaaa3;
  border-color: #5d3330
}

html[data-theme-effective="dark"] .search-results-head b,html[data-theme-effective="dark"] .count-pill {
  background: #17302e;
  color: #91ddd5
}

html[data-theme-effective="dark"] .error-hint {
  background: #351d1d;
  color: #ffaaa3;
  border-color: #5d3330
}

/* Settings/admin surfaces added after the original theme engine. */
html[data-theme-effective="dark"] .feature-icon {
  background: #173330;
  color: #7de0d4;
  border: 1px solid #315953
}

html[data-theme-effective="dark"] .feature-toggle-card:hover {
  background: #18282c;
  border-color: #405b61
}

html[data-theme-effective="dark"] .mini-toggle {
  background: #142327;
  border-color: #344a50;
  color: var(--theme-text)
}

html[data-theme-effective="dark"] .clinic-admin-form {
  border-top-color: #2b4146
}

html[data-theme-effective="dark"] .user-admin-details {
  background: #121f23;
  border-color: #33494f
}

html[data-theme-effective="dark"] .permission-check-card {
  background: #142327;
  border-color: #344a50;
  color: #cbdde1
}

html[data-theme-effective="dark"] .settings-save-bar {
  background: rgba(17,27,31,.95);
  border-color: #31464c;
  box-shadow: 0 10px 30px rgba(0,0,0,.30)
}

html[data-theme-effective="dark"] .system-validity-card .subscription-countdown-pill {
  background: #17282b;
  border-color: #305054
}

html[data-theme-effective="dark"] .subscription-countdown-pill.is-expired {
  background: #351d1d;
  border-color: #5d3330;
  color: #ffaaa3
}

html[data-theme-effective="dark"] .subscription-countdown-pill.is-expired :is(.ui-icon,b) {
  color: #ffaaa3
}

/* Cleanup + account pages: keep every nested surface dark. */
html[data-theme-effective="dark"] :is(.cleanup-summary-metrics>div,.cleanup-item-card,.cleanup-clinic-option) {
  background: #142327;
  border-color: #3c5861
}

html[data-theme-effective="dark"] .cleanup-safety-box .field input {
  background: var(--theme-field);
  color: var(--theme-text)
}

/* Text library, managed/error/login and modal surfaces. */
html[data-theme-effective="dark"] :is(.managed-page-card,.error-page-card,.login-card,.instruction-modal-card) {
  background: var(--theme-card);
  border-color: var(--theme-border);
  color: var(--theme-text)
}

html[data-theme-effective="dark"] .managed-rich-content {
  color: #c9d9dc
}

html[data-theme-effective="dark"] .managed-rich-content :is(h1,h2,h3,strong,b) {
  color: #eef7f8
}

html[data-theme-effective="dark"] .managed-rich-content :is(blockquote,pre,code) {
  background: #162428;
  border-color: #30464c;
  color: #d4e4e7
}

html[data-theme-effective="dark"] .app-text-field {
  background: #142126;
  border-color: #2b3d42
}

html[data-theme-effective="dark"] .app-text-field :is(input,textarea) {
  background: var(--theme-field);
  border-color: var(--theme-border);
  color: var(--theme-text)
}

/* Semantic note cards remain distinguishable while respecting dark mode. */
html[data-theme-effective="dark"] .doctor-patient-note {
  background: #142927;
  border-color: #35635e
}

html[data-theme-effective="dark"] .secretary-patient-note {
  background: #211b2b;
  border-color: #5f4b79
}

/* Auto mode fallback when the OS is dark, even before/without theme JS. */
@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] {
    --theme-card: #111b1f;
    --theme-card-2: #162327;
    --theme-card-3: #0f1a1d;
    --theme-field: #0e191c;
    --theme-border: #31454b;
    --theme-border-soft: #27383d;
    --theme-text: #e7f0f2;
    --theme-muted: #91a6ad;
  }

  html[data-theme-mode="auto"] :is(.brand,.field label,.meta-item strong,.archive-card h2,.clinical-title,.visit-date,.visit-block-title,.visit-text,.year-stat-item b,.system-validity-heading h2,.patient-edit-details summary,.archive-patient-zone summary,.delete-patient-zone summary) {
    color: var(--theme-text)
  }

  html[data-theme-mode="auto"] :is(.meta-label,.patient-tile-footer,.stats-date,.search-results-head,.patient-stat-footer,.archive-card p,.archive-label,.profile-code,.profile-meta span,.visit-date span,.visit-doctor) {
    color: var(--theme-muted)
  }

  html[data-theme-mode="auto"] .nav a:not(.nav-add-patient):not(.nav-icon-only):not(.nav-logout) {
    background: var(--theme-card-2);
    border-color: var(--theme-border);
    color: var(--theme-text)
  }

  html[data-theme-mode="auto"] .nav a:not(.nav-add-patient):not(.nav-icon-only):not(.nav-logout):hover {
    background: #1b2b30;
    border-color: #46636b;
    color: #eef8fa
  }

  html[data-theme-mode="auto"] :is(.pagination a,.page-current,.profile-actions,.archive-breadcrumbs,.archive-card,.visit-card-modern,.year-stat-item) {
    background: var(--theme-card);
    border-color: var(--theme-border-soft);
    color: var(--theme-text)
  }

  html[data-theme-mode="auto"] :is(.archive-card:hover,.visit-row-card:hover) {
    background: #152226;
    border-color: #405960
  }

  html[data-theme-mode="auto"] :is(.visit-row-card,.meta-item,.patient-card-info>div,.patient-inline-stats,.archive-year-stats-panel) {
    background: var(--theme-card-2);
    border-color: var(--theme-border-soft)
  }

  html[data-theme-mode="auto"] :is(.avatar,.patient-avatar,.patient-avatar-modern,.profile-avatar,.archive-icon,.archive-day-number) {
    background: linear-gradient(145deg,#17302f,#172b35);
    border-color: #345258;
    color: #7bd8d0
  }

  html[data-theme-mode="auto"] .patient-profile-hero {
    background: linear-gradient(145deg,#112528,#101d22);
    border-color: #2e484d;
    box-shadow: 0 12px 30px rgba(0,0,0,.24)
  }

  html[data-theme-mode="auto"] .profile-meta span {
    background: #17272b;
    border: 1px solid #2f474d
  }

  html[data-theme-mode="auto"] .profile-actions {
    background: #111d21;
    border-color: #30464c
  }

  html[data-theme-mode="auto"] .patient-card-chevron {
    background: #18272b;
    color: #9bb0b6
  }

  html[data-theme-mode="auto"] .file-code {
    background: #18262b;
    color: #a9c0c6
  }

  html[data-theme-mode="auto"] .patient-visibility-control.is-hidden {
    background: #171f22;
    border-inline-start-color: #68777b
  }

  html[data-theme-mode="auto"] .visibility-hide-button {
    background: #2b1d1d!important;
    border-color: #65413d!important;
    color: #f1aaa3!important
  }

  html[data-theme-mode="auto"] .archive-breadcrumbs a {
    color: #75d6cc
  }

  html[data-theme-mode="auto"] .archive-arrow {
    color: #71888e
  }

  html[data-theme-mode="auto"] .archive-year-stats-panel {
    border-top-color: #2b4045
  }

  html[data-theme-mode="auto"] .archive-year-stats-button {
    background: #17272b!important;
    border-color: #365159!important;
    color: #b8d4d9!important
  }

  html[data-theme-mode="auto"] .year-stat-item b {
    color: #d8ecef
  }

  html[data-theme-mode="auto"] :is(.clinical-box,.visit-clinical-block) {
    background: #121f23;
    border-color: #2d444a
  }

  html[data-theme-mode="auto"] .visit-clinical-block.treatment {
    background: #132026
  }

  html[data-theme-mode="auto"] .clinical-box textarea {
    background: var(--theme-field);
    border-color: var(--theme-border);
    color: var(--theme-text)
  }

  html[data-theme-mode="auto"] .clinical-box textarea::placeholder {
    color: #728a91
  }

  html[data-theme-mode="auto"] :is(.visit-card-header,.visit-thumbs,.visit-actions) {
    border-color: #2a3e43
  }

  html[data-theme-mode="auto"] .visit-note {
    background: #292416;
    border-color: #625631;
    color: #e3cc8a
  }

  html[data-theme-mode="auto"] .fee-badge {
    background: #16312b;
    color: #8addba;
    border: 1px solid #315845
  }

  html[data-theme-mode="auto"] .quick-buttons button {
    background: #17302e!important;
    border-color: #315b56!important;
    color: #9be1d8!important
  }

  html[data-theme-mode="auto"] .paid {
    background: #153126;
    color: #81ddb0;
    border: 1px solid #28513f
  }

  html[data-theme-mode="auto"] .unpaid {
    background: #351d1d;
    color: #ffaaa3;
    border: 1px solid #5d3330
  }

  html[data-theme-mode="auto"] :is(.live-pill,.live-sync-pill) {
    background: #162823;
    border-color: #315044;
    color: #a8d7c6
  }

  html[data-theme-mode="auto"] .live-sync-pill:hover {
    background: #1b322c;
    border-color: #45685b
  }

  html[data-theme-mode="auto"] .live-sync-pill.is-updated {
    background: #163126;
    color: #81ddb0;
    border-color: #315840
  }

  html[data-theme-mode="auto"] .live-sync-pill.is-error {
    background: #351d1d;
    color: #ffaaa3;
    border-color: #5d3330
  }

  html[data-theme-mode="auto"] .search-results-head b,html[data-theme-mode="auto"] .count-pill {
    background: #17302e;
    color: #91ddd5
  }

  html[data-theme-mode="auto"] .error-hint {
    background: #351d1d;
    color: #ffaaa3;
    border-color: #5d3330
  }

  html[data-theme-mode="auto"] .feature-icon {
    background: #173330;
    color: #7de0d4;
    border: 1px solid #315953
  }

  html[data-theme-mode="auto"] .feature-toggle-card:hover {
    background: #18282c;
    border-color: #405b61
  }

  html[data-theme-mode="auto"] .mini-toggle {
    background: #142327;
    border-color: #344a50;
    color: var(--theme-text)
  }

  html[data-theme-mode="auto"] .clinic-admin-form {
    border-top-color: #2b4146
  }

  html[data-theme-mode="auto"] .user-admin-details {
    background: #121f23;
    border-color: #33494f
  }

  html[data-theme-mode="auto"] .permission-check-card {
    background: #142327;
    border-color: #344a50;
    color: #cbdde1
  }

  html[data-theme-mode="auto"] .settings-save-bar {
    background: rgba(17,27,31,.95);
    border-color: #31464c;
    box-shadow: 0 10px 30px rgba(0,0,0,.30)
  }

  html[data-theme-mode="auto"] .system-validity-card .subscription-countdown-pill {
    background: #17282b;
    border-color: #305054
  }

  html[data-theme-mode="auto"] .subscription-countdown-pill.is-expired {
    background: #351d1d;
    border-color: #5d3330;
    color: #ffaaa3
  }

  html[data-theme-mode="auto"] .subscription-countdown-pill.is-expired :is(.ui-icon,b) {
    color: #ffaaa3
  }

  html[data-theme-mode="auto"] :is(.cleanup-summary-metrics>div,.cleanup-item-card,.cleanup-clinic-option) {
    background: #142327;
    border-color: #3c5861
  }

  html[data-theme-mode="auto"] .cleanup-safety-box .field input {
    background: var(--theme-field);
    color: var(--theme-text)
  }

  html[data-theme-mode="auto"] :is(.managed-page-card,.error-page-card,.login-card,.instruction-modal-card) {
    background: var(--theme-card);
    border-color: var(--theme-border);
    color: var(--theme-text)
  }

  html[data-theme-mode="auto"] .managed-rich-content {
    color: #c9d9dc
  }

  html[data-theme-mode="auto"] .managed-rich-content :is(h1,h2,h3,strong,b) {
    color: #eef7f8
  }

  html[data-theme-mode="auto"] .managed-rich-content :is(blockquote,pre,code) {
    background: #162428;
    border-color: #30464c;
    color: #d4e4e7
  }

  html[data-theme-mode="auto"] .app-text-field {
    background: #142126;
    border-color: #2b3d42
  }

  html[data-theme-mode="auto"] .app-text-field :is(input,textarea) {
    background: var(--theme-field);
    border-color: var(--theme-border);
    color: var(--theme-text)
  }

  html[data-theme-mode="auto"] .doctor-patient-note {
    background: #142927;
    border-color: #35635e
  }

  html[data-theme-mode="auto"] .secretary-patient-note {
    background: #211b2b;
    border-color: #5f4b79
  }

}

/* Remaining semantic/command surfaces found by the final theme audit. */
html[data-theme-effective="dark"] .btn:not(.btn-primary):not(.btn-danger):not(.btn-ok) {
  background: #172428;
  color: #d5e4e7;
  border-color: #31454b
}

html[data-theme-effective="dark"] .btn:not(.btn-primary):not(.btn-danger):not(.btn-ok):hover {
  background: #1c2d31;
  border-color: #436067
}

html[data-theme-effective="dark"] .hero-icon-button:not(.hero-icon-primary) {
  background: #17272b!important;
  border-color: #365159!important;
  color: #d8e7ea!important
}

html[data-theme-effective="dark"] .hero-icon-button:not(.hero-icon-primary) .ui-icon {
  color: #7edbd2
}

html[data-theme-effective="dark"] .hero-kicker {
  color: #7edbd2
}

html[data-theme-effective="dark"] .search-icon {
  color: #8da7ad
}

html[data-theme-effective="dark"] .today-stat.fees {
  background: #142d29;
  border-color: #31564d
}

html[data-theme-effective="dark"] .today-stat.fees b {
  color: #8bddc8
}

html[data-theme-effective="dark"] .badge.new-patient {
  background: #172d3a;
  color: #8dccf2;
  border-color: #31546b
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .btn:not(.btn-primary):not(.btn-danger):not(.btn-ok) {
    background: #172428;
    color: #d5e4e7;
    border-color: #31454b
  }

  html[data-theme-mode="auto"] .btn:not(.btn-primary):not(.btn-danger):not(.btn-ok):hover {
    background: #1c2d31;
    border-color: #436067
  }

  html[data-theme-mode="auto"] .hero-icon-button:not(.hero-icon-primary) {
    background: #17272b!important;
    border-color: #365159!important;
    color: #d8e7ea!important
  }

  html[data-theme-mode="auto"] .hero-icon-button:not(.hero-icon-primary) .ui-icon {
    color: #7edbd2
  }

  html[data-theme-mode="auto"] .hero-kicker {
    color: #7edbd2
  }

  html[data-theme-mode="auto"] .search-icon {
    color: #8da7ad
  }

  html[data-theme-mode="auto"] .today-stat.fees {
    background: #142d29;
    border-color: #31564d
  }

  html[data-theme-mode="auto"] .today-stat.fees b {
    color: #8bddc8
  }

  html[data-theme-mode="auto"] .badge.new-patient {
    background: #172d3a;
    color: #8dccf2;
    border-color: #31546b
  }

}

html[data-theme-effective="dark"] .user-admin-details>summary {
  color: var(--theme-text)
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .user-admin-details>summary {
    color: var(--theme-text)
  }

}

/* === [S24] Clinic print settings editor === */
/* Clinic print settings editor */
.print-settings-page {
  display: grid;
  gap: 16px
}

.print-settings-entry-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  text-decoration: none;
  color: inherit
}

.print-settings-entry-card>div {
  min-width: 0
}

.clinic-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 14px
}

.print-settings-layout {
  display: grid;
  gap: 16px
}

.print-settings-controls {
  min-width: 0
}

.print-settings-preview-wrap {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-2);
  overflow: hidden
}

.print-settings-paper-scaler {
  position: relative;
  margin: 0 auto
}

.print-settings-paper {
  position: absolute;
  inset: 0 auto auto 0;
  background: #fff;
  box-shadow: 0 14px 42px rgba(28,67,74,.16);
  transform-origin: top left;
  overflow: hidden
}

.print-settings-template-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  z-index: 1;
  pointer-events: none
}

.print-settings-preview-empty {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  place-items: center;
  color: #a7b6ba;
  background: linear-gradient(135deg,#fff,#fbfefe);
  font-size: 12px
}

.print-settings-box {
  position: absolute;
  z-index: 3;
  border: 1px dashed rgba(15,131,124,.75);
  background: rgba(255,255,255,.82);
  color: #111;
  padding: 1.4mm 2mm;
  border-radius: 2mm;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  line-height: 1.35;
  overflow: visible
}

.print-settings-box.is-dragging {
  cursor: grabbing;
  border-style: solid;
  background: rgba(255,255,255,.96)
}

.print-settings-box>span {
  position: absolute;
  top: -18px;
  right: 0;
  border-radius: 6px;
  background: #0f837c;
  color: #fff;
  padding: 2px 5px;
  font-size: 9px;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none
}

.print-settings-box>b {
  font: inherit;
  font-weight: 700;
  color: #111
}

.print-settings-box.patient-box {
  direction: rtl;
  text-align: right;
  white-space: nowrap;
  min-width: 42mm
}

.print-settings-box.date-box {
  direction: ltr;
  text-align: left;
  white-space: nowrap;
  min-width: 30mm;
  font-variant-numeric: tabular-nums
}

.print-settings-box.age-box {
  direction: rtl;
  text-align: right;
  white-space: nowrap;
  min-width: 24mm
}

.print-settings-box.text-box {
  min-height: 12mm;
  white-space: pre-wrap;
  min-width: 20mm
}

.print-settings-box.rights-box {
  direction: rtl;
  text-align: center;
  white-space: nowrap;
  min-width: 35mm;
  font-size: 7pt;
  font-weight: 500;
  padding: .8mm 1.2mm
}

.print-settings-box.rights-box.is-readonly {
  cursor: default;
  border-style: dotted
}

.print-settings-box.rights-box.is-readonly>span {
  display: none
}

.print-rights-admin {
  order: 90
}

.print-age-toggle {
  align-items: center
}

@media(min-width:900px) {
  .print-settings-layout {
    grid-template-columns: minmax(300px,.86fr) minmax(360px,1.14fr);
    align-items: start
  }

  .print-settings-preview-wrap {
    position: sticky;
    top: 90px
  }

}

html[data-theme-effective="dark"] .print-settings-preview-wrap {
  background: #101c20;
  border-color: #31484f
}

html[data-theme-effective="dark"] .print-settings-paper {
  box-shadow: 0 18px 54px rgba(0,0,0,.5);
  outline: 1px solid #3b4d52
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .print-settings-preview-wrap {
    background: #101c20;
    border-color: #31484f
  }

  html[data-theme-mode="auto"] .print-settings-paper {
    box-shadow: 0 18px 54px rgba(0,0,0,.5);
    outline: 1px solid #3b4d52
  }

}

/* === [S25] Clinical completion and autosave indicators === */
/* Clinical completion + autosave */
.badge.clinical-done {
  font-weight: 800;
  letter-spacing: .01em
}

.autosave-status {
  display: block;
  min-height: 1.3em;
  margin-top: 6px;
  font-size: .78rem;
  opacity: .82
}

.autosave-status.is-saving {
  opacity: .8
}

.autosave-status.is-saved {
  font-weight: 700
}

.autosave-status.is-error {
  font-weight: 700
}

.tests-followup-box {
  grid-column: 1/-1
}

/* === [S26] Hidden-patient archive and on-demand statistics === */
/* V6: isolated hidden-patient archive + on-demand archive statistics */
.hidden-archive-entry {
  border-style: dashed
}

.hidden-patient-archive-grid .patient-card-actions {
  grid-template-columns: repeat(3,minmax(0,1fr))
}

.patient-card-inline-form {
  display: contents
}

.archive-pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap
}

.archive-day-heading-stats {
  width: auto;
  min-width: 132px;
  margin: 0
}

.workspace-side>.archive-year-stats-panel {
  flex-basis: 100%;
  min-width: min(360px,90vw)
}

@media(max-width:560px) {
  .hidden-patient-archive-grid .patient-card-actions {
    grid-template-columns: 1fr
  }

  .archive-day-heading-stats {
    min-width: 110px
  }

}

/* Keep the archive day's stats button and expanded panel inside the card on phones.
   Scope to the archive day view: today's patients and other archive levels are unchanged. */
@media(max-width:719px) {
  .archive-day-workspace .workspace-heading {
    flex-direction: column;
    align-items: stretch
  }

  .archive-day-workspace .workspace-side {
    width: 100%;
    min-width: 0;
    align-items: stretch;
    flex-direction: column
  }

  .archive-day-workspace .archive-day-heading-stats {
    width: 100%;
    min-width: 0;
    margin: 0;
    min-height: 44px
  }

  .archive-day-workspace .workspace-side>.archive-year-stats-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-basis: auto
  }

}

/* === [S27] Existing-patient match and intake decision sheet === */
/* Existing-patient name match: clinic-scoped, mobile-first intake decision sheet. */
.duplicate-name-inline-hint:not([hidden]) {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--text);
  font-size: 12px;
  line-height: 1.8
}

.duplicate-patient-overlay {
  position: fixed;
  inset: 0;
  z-index: 1250;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(14px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(14px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));
  background: rgba(9,18,25,.69);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px)
}

.integrated-patient-booking-form [data-note-row][hidden],
.duplicate-patient-overlay[hidden] {
  display: none!important
}

.has-duplicate-modal {
  overflow: hidden
}

.duplicate-patient-dialog {
  box-sizing: border-box;
  width: min(100%,480px);
  max-height: 88vh;
  max-height: min(88dvh,800px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(17px,3vw,24px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 22px 70px rgba(0,0,0,.3);
  direction: rtl;
  text-align: right
}

.duplicate-patient-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 23px;
  font-weight: 900;
  margin-bottom: 12px
}

.duplicate-patient-dialog h2 {
  font-size: clamp(19px,5vw,23px);
  margin: 0 0 8px;
  color: var(--text)
}

.duplicate-patient-dialog>p {
  margin: 0 0 15px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.9
}

.duplicate-patient-list {
  display: grid;
  gap: 9px;
  max-height: 37dvh;
  overflow: auto;
  overscroll-behavior: contain
}

.duplicate-patient-entry {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2)
}

.duplicate-patient-info {
  display: grid;
  gap: 3px;
  min-width: 0;
  overflow-wrap: anywhere
}

.duplicate-patient-info strong {
  font-size: 15px;
  color: var(--text)
}

.duplicate-patient-info small {
  font-size: 12px;
  color: var(--muted);
  direction: rtl
}

.duplicate-patient-last-visit {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  padding-block-start: 7px;
  border-block-start: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px
}

.duplicate-patient-last-visit time {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums
}

.duplicate-patient-visit {
  width: 100%;
  min-height: 44px;
  font-size: 12px;
  white-space: normal;
  line-height: 1.65
}

.duplicate-patient-note {
  margin: 13px 0 0;
  padding: 11px 12px;
  background: var(--primary-soft);
  border: 1px solid var(--line);
  border-radius: 12px
}

.duplicate-patient-note p {
  font-size: 12px;
  line-height: 1.8;
  color: var(--text);
  margin: 0
}

.duplicate-patient-note p+p {
  margin-top: 7px
}

.duplicate-patient-actions {
  display: grid;
  gap: 9px;
  margin-top: 14px
}

.duplicate-patient-actions .btn {
  width: 100%;
  min-height: 46px;
  text-align: center;
  white-space: normal;
  line-height: 1.5
}

.duplicate-patient-continue {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line)
}

.duplicate-patient-cancel {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line)
}

.duplicate-patient-overlay button:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px
}

@media(max-width:500px) {
  .duplicate-patient-overlay {
    align-items: flex-end;
    padding-bottom: max(8px,env(safe-area-inset-bottom))
  }

  .duplicate-patient-dialog {
    width: 100%;
    border-radius: 22px 22px 15px 15px;
    max-height: 90vh;
    max-height: 90dvh;
    padding: 18px 15px
  }

  .duplicate-patient-list {
    max-height: 42dvh
  }

}

/* === [S28] Patient name search matches === */
/* Smart patient name matches: existing theme tokens support night/day/auto. */
.patient-card-name .badge.patient-name-near {
  display: inline-flex;
  max-width: 100%;
  white-space: normal;
  text-align: right;
  line-height: 1.45;
  vertical-align: top;
  margin-block-start: 4px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--line);
  font-size: 10px;
  font-weight: 800
}

/* === [S29] Patient age controls === */
/* XCLINIC age controls: safe native dropdown (sنة/شهر/يوم) to prevent mistaken taps.
 * Explicit color-scheme AND option colors avoid pale-on-pale OS menus on dark devices.
 * No changes to layout/print/patient cards or any database structures. */
.patient-age-control {
  --age-bg: #f3f8fb;
  --age-border: #b5d0d6;
  --age-text: #173a43;
  display: flex;
  align-items: stretch;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--age-border);
  border-radius: 13px;
  background: var(--age-bg);
  color: var(--age-text);
  overflow: hidden;
  transition: border-color .15s,box-shadow .15s
}

.patient-age-control:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft)
}

.field .patient-age-control>input[type=number] {
  flex: 1 1 auto;
  width: 0;
  min-width: 68px;
  min-height: 48px;
  margin: 0;
  padding: 8px 10px!important;
  border: 0!important;
  border-radius: 0!important;
  background: transparent!important;
  color: var(--text)!important;
  box-shadow: none!important;
  outline: 0!important;
  appearance: textfield;
  -moz-appearance: textfield;
  direction: ltr;
  text-align: center;
  font-weight: 850;
  font-variant-numeric: tabular-nums
}

.patient-age-control>input[type=number]::-webkit-inner-spin-button,.patient-age-control>input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0
}

.field .patient-age-control>select.patient-age-unit-select {
  flex: 0 0 112px;
  width: 112px;
  min-width: 0;
  min-height: 48px;
  margin: 0;
  padding: 9px 12px!important;
  border: 0!important;
  border-inline-start: 1px solid var(--age-border)!important;
  border-radius: 0!important;
  background-color: #e7f2f5!important;
  color: #173a43!important;
  box-shadow: none!important;
  outline: 0!important;
  font-weight: 800;
  cursor: pointer;
  color-scheme: light;
  direction: rtl;
  text-align: center;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M3 6l5 5 5-5' fill='none' stroke='%23173a43' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 15px 15px;
  background-position: left 10px center;
  padding-left: 30px!important
}

.field .patient-age-control>select.patient-age-unit-select:focus-visible {
  outline: 2px solid var(--primary)!important;
  outline-offset: -3px!important
}

.field select.clinic-default-age-select {
  display: block;
  width: 100%;
  max-width: 390px;
  min-height: 48px;
  padding: 10px 13px;
  border: 1px solid #b5d0d6;
  border-radius: 12px;
  background: #f3f8fb;
  color: #173a43;
  font-weight: 800;
  cursor: pointer;
  color-scheme: light;
  direction: rtl;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M3 6l5 5 5-5' fill='none' stroke='%23173a43' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat!important;
  background-size: 15px 15px!important;
  background-position: left 12px center!important;
  padding-left: 35px
}

.field select.clinic-default-age-select:focus-visible {
  border-color: var(--primary);
  outline: 2px solid var(--primary);
  outline-offset: 1px
}

/* Option styling is respected by desktop browsers; color-scheme governs native mobile popups. */
.field :is(select.patient-age-unit-select,select.clinic-default-age-select) option {
  background-color: #ffffff!important;
  color: #173a43!important
}

html[data-theme-effective="dark"] .patient-age-control {
  --age-bg: #112429;
  --age-border: #45656d;
  --age-text: #f0fcfc
}

html[data-theme-effective="dark"] .field .patient-age-control>select.patient-age-unit-select {
  background-color: #172f36!important;
  color: #f0fcfc!important;
  color-scheme: dark;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M3 6l5 5 5-5' fill='none' stroke='%23f0fcfc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
}

html[data-theme-effective="dark"] .field select.clinic-default-age-select {
  background-color: #172f36;
  color: #f0fcfc;
  border-color: #45656d;
  color-scheme: dark;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M3 6l5 5 5-5' fill='none' stroke='%23f0fcfc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
}

html[data-theme-effective="dark"] .field :is(select.patient-age-unit-select,select.clinic-default-age-select) option {
  background-color: #172f36!important;
  color: #f0fcfc!important
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .patient-age-control {
    --age-bg: #112429;
    --age-border: #45656d;
    --age-text: #f0fcfc
  }

  html[data-theme-mode="auto"] .field .patient-age-control>select.patient-age-unit-select {
    background-color: #172f36!important;
    color: #f0fcfc!important;
    color-scheme: dark;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M3 6l5 5 5-5' fill='none' stroke='%23f0fcfc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
  }

  html[data-theme-mode="auto"] .field select.clinic-default-age-select {
    background-color: #172f36;
    color: #f0fcfc;
    border-color: #45656d;
    color-scheme: dark;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M3 6l5 5 5-5' fill='none' stroke='%23f0fcfc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
  }

  html[data-theme-mode="auto"] .field :is(select.patient-age-unit-select,select.clinic-default-age-select) option {
    background-color: #172f36!important;
    color: #f0fcfc!important
  }

}

@media(max-width:380px) {
  .field .patient-age-control>select.patient-age-unit-select {
    flex-basis: 100px;
    width: 100px;
    padding-inline: 6px!important
  }

  .field .patient-age-control>input[type=number] {
    min-width: 55px;
    padding-inline: 5px!important
  }

}

/* === [S30] Secretary daily review states === */
.patient-review-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 7px 11px;
  border: 1px solid #c9d8dc;
  border-radius: 11px;
  background: #f5f9fa;
  color: #395660;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: background .16s,border-color .16s,color .16s
}

.patient-review-toggle input[type="checkbox"] {
  appearance: auto;
  -webkit-appearance: checkbox;
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  margin: 0;
  accent-color: #087d67;
  cursor: pointer;
  flex-shrink: 0
}

.patient-review-toggle.is-reviewed {
  background: #e8f8ee;
  border-color: #8bceb0;
  color: #156040
}

.patient-review-toggle:focus-within {
  outline: 2px solid var(--primary);
  outline-offset: 2px
}

.patient-review-toggle.is-saving {
  opacity: .67;
  cursor: progress
}

.patient-review-toggle input:disabled {
  cursor: wait
}

.patient-review-feedback {
  color: var(--danger);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5
}

.patient-card-status:has(.patient-review-toggle) {
  gap: 8px
}

html[data-theme-effective="dark"] .patient-review-toggle {
  background: #1c2b31;
  border-color: #405b64;
  color: #d4e7eb
}

html[data-theme-effective="dark"] .patient-review-toggle.is-reviewed {
  background: #163a31;
  border-color: #448977;
  color: #a8e6cc
}

@media (prefers-color-scheme: dark) {
  html[data-theme-mode="auto"] .patient-review-toggle {
    background: #1c2b31;
    border-color: #405b64;
    color: #d4e7eb
  }

  html[data-theme-mode="auto"] .patient-review-toggle.is-reviewed {
    background: #163a31;
    border-color: #448977;
    color: #a8e6cc
  }

}

/* === [S31] Secretary queue review action === */
/* Secretary daily queue: review action next to the name, never inside the file link. */
.secretary-review-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 12px 13px 0
}

.secretary-review-head-link {
  display: block;
  flex: 1 1 120px;
  min-width: 0;
  outline-offset: 3px
}

.secretary-review-head-link:focus-visible {
  outline: 3px solid var(--primary);
  border-radius: 10px
}

.secretary-review-head .patient-card-head {
  min-width: 0
}

.secretary-review-head .patient-card-name h3 {
  white-space: normal;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  line-height: 1.4
}

.secretary-review-head .patient-review-toggle {
  flex: 0 0 auto;
  gap: 5px;
  min-height: 42px;
  padding: 7px 8px;
  font-size: 11px;
  white-space: nowrap
}

.secretary-review-head .patient-review-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px
}

.secretary-review-card .secretary-review-info-open {
  padding-top: 0
}

.secretary-review-card .patient-review-feedback:empty {
  display: none
}

.secretary-review-card .patient-review-feedback:not(:empty) {
  flex-basis: 100%
}

@media(max-width:520px) {
  .secretary-review-head {
    gap: 6px;
    padding: 9px 10px 0
  }

  .secretary-review-head .patient-card-head {
    gap: 7px
  }

  .secretary-review-head .patient-card-chevron {
    display: none
  }

  .secretary-review-head .patient-review-toggle {
    font-size: 10px;
    padding: 7px 6px
  }

  .secretary-review-card .secretary-review-info-open {
    padding: 0 10px 7px
  }

}

/* === [S32] Secretary waiting queue badges === */
/* XCLINIC: secretary daily waiting queue; no change to doctor cards. */
/* Use the same badge typography and box metrics as the paid/unpaid status.
   Only background color and internal gap differ; scales equally on phones. */
.badge.secretary-queue-ahead {
  gap: 4px;
  background: #e7f6fb;
  color: #17566f;
  font-variant-numeric: tabular-nums
}

.badge.secretary-queue-ahead b {
  font-size: inherit;
  line-height: inherit;
  font-weight: inherit
}

.badge.secretary-queue-ahead[hidden] {
  display: none!important
}

.today-stat.secretary-reviewed-stat {
  background: #eaf8f2;
  border-color: #a1d8bd
}

.today-stat.secretary-waiting-stat {
  background: #edf7fb;
  border-color: #b6d8e5
}

.today-stat.secretary-reviewed-stat :is(span,b) {
  color: #175b48
}

.today-stat.secretary-waiting-stat :is(span,b) {
  color: #1b5d78
}

.secretary-review-card .patient-card-name h3 {
  font-size: clamp(16px,2.8vw,18px);
  line-height: 1.5
}

.secretary-review-card .patient-card-info span {
  font-size: 11px;
  line-height: 1.45
}

.secretary-review-card .patient-card-info strong {
  font-size: 13px;
  line-height: 1.5
}

.secretary-review-card .patient-card-status {
  font-size: 11px;
  gap: 7px
}

.secretary-review-card .secretary-review-head .patient-review-toggle {
  font-size: 11px
}

.secretary-review-card .patient-card-info>div {
  min-width: 0;
  padding: 7px 8px
}

.secretary-review-card .patient-card-info strong {
  white-space: normal;
  overflow-wrap: anywhere
}

html[data-theme-effective="dark"] .today-stat.secretary-reviewed-stat {
  background: #16392f;
  border-color: #397962;
  color: #b9ebd4
}

html[data-theme-effective="dark"] .today-stat.secretary-waiting-stat {
  background: #18333f;
  border-color: #37657b;
  color: #b7dcee
}

html[data-theme-effective="dark"] .badge.secretary-queue-ahead {
  background: #1a3844;
  border: 1px solid #396d7f;
  color: #c0ebf6
}

html[data-theme-effective="dark"] .today-stat.secretary-reviewed-stat :is(span,b) {
  color: #b9ebd4
}

html[data-theme-effective="dark"] .today-stat.secretary-waiting-stat :is(span,b) {
  color: #b7dcee
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .today-stat.secretary-reviewed-stat {
    background: #16392f;
    border-color: #397962;
    color: #b9ebd4
  }

  html[data-theme-mode="auto"] .today-stat.secretary-waiting-stat {
    background: #18333f;
    border-color: #37657b;
    color: #b7dcee
  }

  html[data-theme-mode="auto"] .badge.secretary-queue-ahead {
    background: #1a3844;
    border: 1px solid #396d7f;
    color: #c0ebf6
  }

  html[data-theme-mode="auto"] .today-stat.secretary-reviewed-stat :is(span,b) {
    color: #b9ebd4
  }

  html[data-theme-mode="auto"] .today-stat.secretary-waiting-stat :is(span,b) {
    color: #b7dcee
  }

}

@media(max-width:380px) {
  .secretary-review-head-link {
    flex-basis: 95px
  }

  .secretary-review-head {
    gap: 5px
  }

  .secretary-review-head .patient-review-toggle {
    font-size: 10px;
    padding: 7px 6px
  }

  .secretary-review-card .patient-card-info span {
    font-size: 10px
  }

  .secretary-review-card .patient-card-info strong {
    font-size: 12.5px
  }

}

/* === [S33] Secretary patient-card layout === */
/* Secretary's daily-card polish: full-width names, checkbox beside gender.
   No new request, stored field, or queue computation; doctor cards untouched. */
.secretary-review-card .secretary-review-head {
  display: block;
  min-width: 0;
  padding: 11px 13px 0
}

.secretary-review-card .secretary-review-head-link {
  display: block;
  width: 100%;
  min-width: 0
}

.secretary-review-card .secretary-review-head .patient-card-name h3 {
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: unset;
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.5;
}

.secretary-review-card .secretary-review-primary-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center;
  gap: 7px;
  min-width: 0;
  margin: 9px 13px 0;
  padding-top: 9px;
  border-top: 1px solid var(--line,#dce9ec);
}

.secretary-review-card .secretary-review-primary-row .secretary-review-info-open {
  display: block;
  min-width: 0;
  padding: 0!important;
}

.secretary-review-card .secretary-review-primary-row .patient-card-info {
  display: grid;
  grid-template-columns: minmax(56px,72px) minmax(60px,1fr);
  min-width: 0;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

.secretary-review-card .secretary-review-primary-row .patient-card-info>div {
  min-width: 0;
  padding: 7px 7px;
}

.secretary-review-card .secretary-review-primary-row .patient-card-info strong {
  overflow-wrap: anywhere;
  white-space: normal;
}

.secretary-review-card .secretary-review-primary-row .patient-review-toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 7px;
  min-height: 45px;
  margin: 0;
  max-width: 100%;
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
}

.secretary-review-card .secretary-review-primary-row .patient-review-toggle input[type="checkbox"] {
  width: 19px;
  height: 19px;
  min-width: 19px;
  min-height: 19px;
}

.secretary-review-card .secretary-review-extra-open {
  display: block;
  min-width: 0;
  padding: 7px 13px 10px!important;
}

.secretary-review-card .secretary-review-extra-fields {
  display: grid;
  grid-template-columns: minmax(0,1fr);
  margin: 0;
  padding: 0;
  border: 0;
  gap: 6px;
}

.secretary-review-card .secretary-review-extra-fields>div {
  grid-column: 1/-1;
}

@media(max-width:520px) {
  .secretary-review-card .secretary-review-head {
    padding: 9px 10px 0
  }

  .secretary-review-card .secretary-review-primary-row {
    margin: 8px 10px 0;
    padding-top: 8px;
    gap: 5px
  }

  .secretary-review-card .secretary-review-extra-open {
    padding: 6px 10px 8px!important
  }

  .secretary-review-card .secretary-review-primary-row .patient-review-toggle {
    padding: 7px 6px;
    font-size: 10px;
    min-height: 43px
  }

  .secretary-review-card .secretary-review-primary-row .patient-card-info {
    grid-template-columns: minmax(48px,62px) minmax(52px,1fr);
    gap: 5px
  }

  .secretary-review-card .secretary-review-primary-row .patient-card-info>div {
    padding: 6px 5px
  }

}

@media(max-width:285px) {
  .secretary-review-card .secretary-review-primary-row {
    grid-template-columns: minmax(0,1fr)
  }

  .secretary-review-card .secretary-review-primary-row .patient-review-toggle {
    justify-self: start
  }

}

/* === [S34] Waiting-state colors and badge geometry === */
/* Clear, calm amber queue indicator — same physical badge sizing as 'دافع'.
   Fixed dark text on light amber in either theme preserves readability. */
.secretary-review-card .badge.secretary-queue-ahead,
html[data-theme-effective="dark"] .secretary-review-card .badge.secretary-queue-ahead,
html[data-theme-mode="auto"] .secretary-review-card .badge.secretary-queue-ahead {
  background: #ffecad;
  color: #211a0c;
  border: 0;
  outline: 1px solid #e8c365;
  outline-offset: -1px;
  box-shadow: 0 0 0 0 rgba(231,182,56,.08);
  animation: secretary-queue-soft-glow 3.6s ease-in-out infinite;
}

.secretary-review-card .badge.secretary-queue-ahead>span {
  color: #211a0c;
  animation: secretary-queue-text-glow 3.6s ease-in-out infinite;
}

.secretary-review-card .badge.secretary-queue-ahead b {
  color: #211a0c
}

@keyframes secretary-queue-soft-glow {
  0%,100% {
    box-shadow: 0 0 0 0 rgba(225,176,53,.07)
  }

  50% {
    box-shadow: 0 0 0 2px rgba(240,195,75,.20),0 0 8px rgba(230,185,55,.20)
  }

}

@keyframes secretary-queue-text-glow {
  0%,100% {
    text-shadow: none
  }

  50% {
    text-shadow: 0 0 3px rgba(131,91,12,.32)
  }

}

@media(prefers-reduced-motion:reduce) {
  .secretary-review-card .badge.secretary-queue-ahead,
  .secretary-review-card .badge.secretary-queue-ahead>span {
    animation: none!important;
  }

}

/* === [S35] Booking save controls and payment fields === */
/* Long booking save label remains touch-friendly at 320px without horizontal overflow. */
.patient-page-save-button {
  max-width: 100%;
  white-space: normal;
  text-align: center;
  line-height: 1.45;
  overflow-wrap: anywhere
}

/* Payment on existing patient and edit-visit forms. Unpaid fees are visibly locked at 0. */
.payment-fee-field.is-unpaid .money-input input[readonly] {
  background: #edf2f5;
  border-color: #cbd6dc;
  color: #526970;
  -webkit-text-fill-color: #526970;
  opacity: 1;
  cursor: default
}

html[data-theme-effective="dark"] .payment-fee-field.is-unpaid .money-input input[readonly] {
  background: #172327;
  border-color: #334a51;
  color: #a6bcc2;
  -webkit-text-fill-color: #a6bcc2
}

@media (prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .payment-fee-field.is-unpaid .money-input input[readonly] {
    background: #172327;
    border-color: #334a51;
    color: #a6bcc2;
    -webkit-text-fill-color: #a6bcc2
  }

}

/* === [S36] Daily sequence and patient identity === */
/* Today's daily sequence is shown INSTEAD of the initial, not by the name.
   Font size tracks the existing patient-name typography for each role;
   4+ digit outliers are reduced just enough to fit the existing avatar box.
   No extra animation, network request, database field or stored counter. */
.patient-card-modern .patient-avatar-modern.patient-daily-number {
  direction: ltr;
  unicode-bidi: isolate;
  white-space: nowrap;
  min-width: 0;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.secretary-review-card .patient-avatar-modern.patient-daily-number {
  font-size: clamp(16px,2.8vw,18px);
}

.patient-card-modern .patient-avatar-modern.patient-daily-number.is-multi-digit {
  font-size: 12px;
  letter-spacing: -.04em;
}

.patient-card-modern .patient-avatar-modern.patient-daily-number.is-very-long {
  font-size: 9px;
  letter-spacing: -.05em;
}

/* === [S37] Patient attachments and image viewer === */
/* Patient visit attachments: zoom in-page and delete only when authorized. */
.patient-attachment-tile {
  position: relative;
  flex: 0 0 auto;
  width: 88px;
  min-width: 88px
}

.patient-attachment-preview {
  position: relative;
  display: block;
  width: 88px;
  height: 88px;
  border-radius: 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-2)
}

.patient-attachment-preview img {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  object-fit: cover
}

.patient-attachment-eye {
  position: absolute;
  inset: auto auto 5px 5px;
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 10px;
  background: rgba(7,24,32,.82);
  color: #fff;
  box-shadow: 0 2px 9px rgba(0,0,0,.15)
}

.patient-attachment-eye .ui-icon,.patient-attachment-trash .ui-icon {
  width: 18px;
  height: 18px
}

.patient-attachment-trash {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.35);
  background: #b42318;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 9px rgba(0,0,0,.16);
  touch-action: manipulation
}

.patient-attachment-preview:focus-visible,.patient-attachment-trash:focus-visible,.patient-attachment-lightbox-close:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px
}

.patient-attachment-trash:hover {
  background: #8d1a14
}

.patient-attachment-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1350;
  background: rgba(4,13,19,.88);
  padding: max(10px,env(safe-area-inset-top)) max(10px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left));
  display: grid;
  place-items: center;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px)
}

.patient-attachment-lightbox[hidden] {
  display: none!important
}

.has-attachment-lightbox {
  overflow: hidden
}

.patient-attachment-lightbox-panel {
  width: min(100%,1050px);
  height: min(90vh,850px);
  height: min(90dvh,850px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 25px 70px rgba(0,0,0,.4)
}

.patient-attachment-lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 15px;
  flex: 0 0 auto
}

.patient-attachment-lightbox-close {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  min-height: 44px;
  touch-action: manipulation
}

.patient-attachment-lightbox-close span {
  font-size: 23px;
  vertical-align: middle;
  margin-inline-start: 5px;
  line-height: 0
}

.patient-attachment-lightbox-content {
  min-height: 0;
  flex: 1;
  display: grid;
  place-items: center;
  overflow: auto;
  border-radius: 12px;
  background: color-mix(in srgb,var(--surface-2) 85%,#101820)
}

.patient-attachment-lightbox-content img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain
}

html[data-theme-effective="dark"] .patient-attachment-lightbox-panel {
  background: #142126;
  border-color: #40565b;
  color: #edf6f6
}

html[data-theme-effective="dark"] .patient-attachment-lightbox-close {
  background: #20343a;
  color: #fff;
  border-color: #435c61
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .patient-attachment-lightbox-panel {
    background: #142126;
    border-color: #40565b;
    color: #edf6f6
  }

  html[data-theme-mode="auto"] .patient-attachment-lightbox-close {
    background: #20343a;
    color: #fff;
    border-color: #435c61
  }

}

@media(max-width:480px) {
  .patient-attachment-lightbox-panel {
    height: calc(100dvh - 20px);
    width: 100%;
    padding: 10px;
    border-radius: 14px
  }

  .patient-attachment-lightbox-content {
    min-height: 0
  }

  .patient-attachment-lightbox-bar {
    font-size: 14px
  }

}

/* === [S38] Attachment deletion confirmation === */
/* Destructive attachment confirmation only; no effect on other site dialogs. */
.patient-attachment-delete-overlay {
  position: fixed;
  inset: 0;
  z-index: 1450;
  display: grid;
  place-items: center;
  padding: max(16px,env(safe-area-inset-top)) max(14px,env(safe-area-inset-right))
    max(16px,env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left));
  background: rgba(8,19,28,.68);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.patient-attachment-delete-overlay[hidden] {
  display: none!important
}

.has-attachment-delete-dialog {
  overflow: hidden
}

.patient-attachment-delete-panel {
  position: relative;
  width: min(100%,410px);
  max-height: min(90vh,90dvh);
  overflow-y: auto;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 25px 75px rgba(7,24,35,.29);
  color: var(--text);
  padding: 28px 22px 22px;
  text-align: center;
  overscroll-behavior: contain;
}

.patient-attachment-delete-close {
  position: absolute;
  inset-block-start: 12px;
  inset-inline-end: 12px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 23px;
  line-height: 1;
  touch-action: manipulation;
}

.patient-attachment-delete-symbol {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 4px auto 15px;
  border-radius: 19px;
  background: #fff0ef;
  color: #b42318;
  border: 1px solid #ffd7d2;
}

.patient-attachment-delete-symbol svg {
  width: 29px;
  height: 29px
}

.patient-attachment-delete-panel h2 {
  margin: 0 0 10px;
  font-size: clamp(19px,5vw,22px);
  font-weight: 900;
  color: var(--text)
}

.patient-attachment-delete-panel #patient-attachment-delete-message {
  margin: 0 auto 14px;
  max-width: 340px;
  font-size: 14px;
  line-height: 1.9;
  color: var(--muted);
}

.patient-attachment-delete-panel #patient-attachment-delete-note {
  margin: 0 0 20px;
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid #f5dcb3;
  background: #fff9ed;
  color: #785014;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.8;
  text-align: right;
}

.patient-attachment-delete-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px
}

.patient-attachment-delete-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
  border: 1px solid var(--line);
  touch-action: manipulation;
  transition: background .15s ease,box-shadow .15s ease;
}

.patient-attachment-delete-cancel {
  background: var(--surface-2);
  color: var(--text)
}

.patient-attachment-delete-cancel:hover {
  background: var(--primary-soft)
}

.patient-attachment-delete-approve {
  background: #b42318!important;
  border-color: #b42318!important;
  color: #fff!important
}

.patient-attachment-delete-approve:hover {
  background: #912018!important;
  border-color: #912018!important
}

.patient-attachment-delete-overlay button:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px
}

html[data-theme-effective="dark"] .patient-attachment-delete-panel {
  background: #142126;
  border-color: #42575d;
  color: #edf6f6;
  box-shadow: 0 28px 76px rgba(0,0,0,.55)
}

html[data-theme-effective="dark"] .patient-attachment-delete-panel h2 {
  color: #f1f7f8
}

html[data-theme-effective="dark"] .patient-attachment-delete-panel #patient-attachment-delete-message {
  color: #bdd0d3
}

html[data-theme-effective="dark"] .patient-attachment-delete-close,
html[data-theme-effective="dark"] .patient-attachment-delete-cancel {
  background: #20343a;
  color: #f1f7f8;
  border-color: #476168
}

html[data-theme-effective="dark"] .patient-attachment-delete-symbol {
  background: #482622;
  border-color: #77433a;
  color: #ffc0b8
}

html[data-theme-effective="dark"] .patient-attachment-delete-panel #patient-attachment-delete-note {
  background: #302a1d;
  border-color: #6b5327;
  color: #f5d38c
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .patient-attachment-delete-panel {
    background: #142126;
    border-color: #42575d;
    color: #edf6f6;
    box-shadow: 0 28px 76px rgba(0,0,0,.55)
  }

  html[data-theme-mode="auto"] .patient-attachment-delete-panel h2 {
    color: #f1f7f8
  }

  html[data-theme-mode="auto"] .patient-attachment-delete-panel #patient-attachment-delete-message {
    color: #bdd0d3
  }

  html[data-theme-mode="auto"] .patient-attachment-delete-close,
  html[data-theme-mode="auto"] .patient-attachment-delete-cancel {
    background: #20343a;
    color: #f1f7f8;
    border-color: #476168
  }

  html[data-theme-mode="auto"] .patient-attachment-delete-symbol {
    background: #482622;
    border-color: #77433a;
    color: #ffc0b8
  }

  html[data-theme-mode="auto"] .patient-attachment-delete-panel #patient-attachment-delete-note {
    background: #302a1d;
    border-color: #6b5327;
    color: #f5d38c
  }

}

/* === [S39] Patient-image and print-template upload progress === */
/* One progress panel for patient images and print-template uploads. */
.visit-image-upload-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483001;
  display: grid;
  place-items: center;
  padding: max(16px,env(safe-area-inset-top)) max(14px,env(safe-area-inset-right))
    max(16px,env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left));
  overflow: auto;
  overscroll-behavior: contain;
  background: rgba(5,23,29,.48);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.visit-image-upload-overlay[hidden] {
  display: none!important
}

.has-visit-image-upload {
  overflow: hidden!important
}

.visit-image-upload-panel {
  display: grid;
  gap: 16px;
  width: min(100%,380px);
  min-width: 0;
  padding: 24px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 22px 70px rgba(5,23,29,.24);
  text-align: center;
}

.visit-image-upload-panel h2 {
  margin: 0;
  color: var(--text);
  font-size: 19px;
  line-height: 1.5;
  font-weight: 800;
  overflow-wrap: anywhere
}

.visit-image-upload-message {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
  overflow-wrap: anywhere
}

.visit-image-upload-track {
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  direction: ltr
}

.visit-image-upload-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg,var(--primary),var(--accent));
  transition: width .12s linear
}

.visit-image-upload-fill.is-indeterminate {
  width: 38%;
  animation: visit-image-upload-moving 1.2s ease-in-out infinite alternate
}

.visit-image-upload-percent {
  margin: 0;
  color: var(--text);
  font-size: 28px;
  line-height: 1.2;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  direction: ltr
}

.visit-image-upload-overlay[data-phase="processing"] .visit-image-upload-panel h2::before {
  content: "";
  display: inline-block;
  width: 17px;
  height: 17px;
  margin-inline-end: 9px;
  vertical-align: -2px;
  border: 2px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: visit-image-upload-processing 1s linear infinite
}

.visit-image-upload-cancel {
  min-height: 48px;
  margin-top: 2px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 750;
  line-height: 1.5;
  cursor: pointer;
  touch-action: manipulation
}

.visit-image-upload-cancel:hover {
  border-color: var(--primary);
  background: var(--primary-soft)
}

.visit-image-upload-cancel:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px
}

.visit-image-upload-panel [hidden] {
  display: none!important
}

html[data-theme-effective="dark"] .visit-image-upload-overlay {
  background: rgba(0,0,0,.56)
}

@keyframes visit-image-upload-moving {
  from {
    transform: translateX(0)
  }

  to {
    transform: translateX(163%)
  }

}

@keyframes visit-image-upload-processing {
  to {
    transform: rotate(360deg)
  }

}

@media(max-width:360px) {
  .visit-image-upload-panel {
    padding: 20px;
    gap: 14px
  }

}

@media(prefers-reduced-motion:reduce) {
  .visit-image-upload-fill {
    transition: none
  }

  .visit-image-upload-fill.is-indeterminate,.visit-image-upload-overlay[data-phase="processing"] .visit-image-upload-panel h2::before {
    animation: none
  }

}

@media(max-width:360px) {
  .patient-attachment-delete-panel {
    padding: 26px 15px 16px;
    border-radius: 19px
  }

  .patient-attachment-delete-actions {
    gap: 8px
  }

  .patient-attachment-delete-actions button {
    font-size: 13px;
    padding: 9px 6px
  }

}

@media(prefers-reduced-motion:reduce) {
  .patient-attachment-delete-actions button {
    transition: none
  }

}

/* === [S40] Today-visit and clinic confirmation dialogs === */
.today-visit-card[hidden],.today-visit-launcher[hidden],.today-visit-confirm-overlay[hidden],.patient-page-save-bar[hidden] {
  display: none!important
}

.today-visit-fields {
  padding: 0;
  margin: 0;
  border: 0;
  min-inline-size: 0;
  display: block
}

.today-visit-launcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  border: 1.5px solid color-mix(in srgb,var(--primary) 24%,var(--line));
  background: var(--surface)
}

.today-visit-launcher>div {
  flex: 1 1 240px;
  min-width: 0
}

.today-visit-launcher h2 {
  color: var(--text);
  font-size: clamp(16px,3vw,21px)
}

.today-visit-launcher p {
  margin: 7px 0 0;
  font-size: 13px
}

.today-visit-launcher-button {
  min-height: 46px;
  justify-content: center;
  gap: 8px;
  flex: 0 1 auto;
  white-space: normal;
  text-align: center
}

.today-visit-launcher-button .ui-icon {
  width: 19px;
  height: 19px
}

.today-visit-card {
  scroll-margin-top: 90px
}

.today-visit-confirmation-settings {
  margin-top: 15px
}

.today-visit-confirmation-settings .feature-toggle-grid {
  margin-top: 12px
}

.today-visit-confirmation-settings .clinic-card-actions {
  margin-top: 15px
}

.today-visit-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10,21,29,.66);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px)
}

.today-visit-confirm-panel {
  width: min(100%,440px);
  padding: 25px 22px;
  border: 1.5px solid var(--line);
  border-radius: 21px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
  box-shadow: 0 25px 75px rgba(12,29,44,.30)
}

.today-visit-confirm-symbol {
  width: 56px;
  height: 56px;
  margin: 0 auto 15px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid color-mix(in srgb,var(--primary) 22%,var(--line))
}

.today-visit-confirm-symbol .ui-icon {
  height: 27px;
  width: 27px
}

.today-visit-confirm-panel h2 {
  font-size: 21px;
  color: var(--text);
  margin-bottom: 12px
}

.today-visit-confirm-panel p {
  font-size: 15px;
  line-height: 2;
  color: var(--muted);
  margin: 0
}

.today-visit-confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 23px
}

.today-visit-confirm-actions button {
  min-height: 48px;
  justify-content: center
}

html.has-today-visit-dialog {
  overflow: hidden
}

html[data-theme-effective="dark"] .today-visit-launcher {
  background: #132125;
  border-color: #355657
}

html[data-theme-effective="dark"] .today-visit-confirm-overlay {
  background: rgba(0,0,0,.77)
}

html[data-theme-effective="dark"] .today-visit-confirm-panel {
  background: #122024;
  border-color: #365458;
  box-shadow: 0 28px 85px rgba(0,0,0,.58)
}

html[data-theme-effective="dark"] .today-visit-confirm-symbol {
  background: #173734;
  border-color: #34665d;
  color: #8be1d7
}

@media(max-width:560px) {
  .today-visit-launcher {
    align-items: stretch;
    flex-direction: column
  }

  .today-visit-launcher-button {
    width: 100%
  }

  .today-visit-confirm-overlay {
    padding: 14px
  }

  .today-visit-confirm-panel {
    padding: 22px 16px;
    border-radius: 17px
  }

  .today-visit-confirm-panel h2 {
    font-size: 18px
  }

  .today-visit-confirm-panel p {
    font-size: 14px
  }

}

/* === [S41] Offline guard and connection feedback === */
/* XCLINIC offline error: page-sized guard, mobile-first, no navigation/data loss. */
.xclinic-offline-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  overflow-y: auto;
  display: grid;
  place-items: center;
  overscroll-behavior: contain;
  padding: calc(16px + env(safe-area-inset-top)) max(13px,env(safe-area-inset-right))
          calc(16px + env(safe-area-inset-bottom)) max(13px,env(safe-area-inset-left));
  background: var(--bg);
  color: var(--text);
}

.xclinic-offline-overlay[hidden] {
  display: none!important
}

.xclinic-is-offline,.xclinic-is-offline body {
  overflow: hidden!important
}

.xclinic-offline-card {
  width: min(100%,490px);
  padding: clamp(18px,5vw,32px);
  border: 1px solid var(--line);
  border-top: 4px solid var(--offline-accent,#c47b13);
  border-radius: 23px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  text-align: center;
}

.xclinic-offline-symbol {
  width: 65px;
  height: 65px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--surface-2);
  color: var(--offline-accent,#c47b13);
}

.xclinic-offline-symbol .ui-icon {
  width: 36px;
  height: 36px
}

.xclinic-offline-kicker {
  display: block;
  font-weight: 850;
  font-size: 12px;
  color: var(--offline-accent,#c47b13)
}

.xclinic-offline-card h2 {
  font-size: clamp(22px,5.5vw,29px);
  margin: 9px 0 13px;
  color: var(--text);
  line-height: 1.4
}

.xclinic-offline-card .managed-rich-content {
  font-size: clamp(14px,3.8vw,16px);
  line-height: 1.95
}

.xclinic-offline-card .managed-rich-content p {
  margin: 9px 0
}

.xclinic-offline-card .managed-rich-content p + p {
  margin-top: 15px;
  padding: 11px 12px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
}

.xclinic-offline-status {
  min-height: 25px;
  font-size: 13px;
  font-weight: 750;
  color: var(--muted);
  margin: 14px 0 8px
}

.xclinic-offline-retry {
  width: 100%;
  min-height: 54px;
  font-size: 16px;
  touch-action: manipulation
}

.xclinic-offline-retry:disabled {
  opacity: .65;
  cursor: wait
}

.xclinic-offline-retry:focus-visible {
  outline: 3px solid var(--offline-accent,#c47b13);
  outline-offset: 3px
}

html[data-theme-effective="dark"] .xclinic-offline-overlay {
  background: var(--bg);
  color: var(--text)
}

html[data-theme-effective="dark"] .xclinic-offline-card {
  background: var(--surface);
  border-color: var(--line);
  border-top-color: var(--offline-accent,#c47b13);
  color: var(--text)
}

@media(max-width:360px) {
  .xclinic-offline-card {
    padding: 18px 15px
  }

  .xclinic-offline-card h2 {
    font-size: 21px
  }

}

/* === [S42] Expanded patient search and intake guidance === */
/* Patient search: an optional, low-frequency expansion capped at nine rows. */
.patient-search-more {
  display: flex;
  width: fit-content;
  max-width: 100%;
  margin: 13px auto 2px;
  justify-content: center;
  text-align: center;
  min-height: 42px;
  align-items: center
}

/* Intake save: guide a user who confirmed a duplicate triple name but forgot the fourth. */
.integrated-patient-booking-form .field input.duplicate-name-fourth-missing,
.integrated-patient-booking-form .field input.duplicate-name-fourth-missing:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb,var(--danger) 18%,transparent)
}

.duplicate-name-inline-hint.duplicate-fourth-save-warning:not([hidden]) {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in srgb,var(--danger) 40%,var(--line));
  font-weight: 750
}

/* === [S43] Application installation dialog === */
/* XCLINIC PWA install invitation — isolated modal; light/dark + mobile-first. */
.xclinic-install-overlay[hidden],
.xclinic-install-help[hidden],
.xclinic-install-status[hidden],
.xclinic-install-spinner[hidden],
.xclinic-install-complete[hidden],
.xclinic-install-go[hidden] {
  display: none!important
}

.xclinic-install-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: grid;
  place-items: center;
  padding: calc(15px + env(safe-area-inset-top)) calc(13px + env(safe-area-inset-right))
          calc(15px + env(safe-area-inset-bottom)) calc(13px + env(safe-area-inset-left));
  background: rgba(7,20,27,.67);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  overflow-y: auto;
  color: var(--text)
}

html.has-xclinic-install-dialog {
  overflow: hidden
}

.xclinic-install-card {
  width: min(100%,450px);
  padding: clamp(21px,5vw,30px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 23px;
  box-shadow: 0 28px 78px rgba(6,20,30,.26);
  text-align: center;
  color: var(--text)
}

.xclinic-install-brand {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  margin: 0 auto 17px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 24px rgba(6,20,30,.12)
}

.xclinic-install-brand-icon {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: contain
}

.xclinic-install-card h2 {
  color: var(--text);
  font-size: clamp(20px,5vw,25px);
  line-height: 1.5
}

.xclinic-install-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.85
}

.xclinic-install-card .xclinic-install-status {
  padding: 10px 12px;
  margin-top: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  line-height: 1.8;
  text-align: center
}

.xclinic-install-card .xclinic-install-status-alert {
  border-color: var(--line)
}

.xclinic-install-card .xclinic-install-help {
  padding: 12px;
  margin-top: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  line-height: 1.9;
  text-align: right
}

.xclinic-install-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 23px
}

.xclinic-install-actions .btn {
  min-height: 49px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 800
}

.xclinic-install-later {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text)
}

.xclinic-install-actions .btn:disabled,
.xclinic-install-complete:disabled {
  opacity: .47;
  filter: grayscale(.28);
  cursor: wait;
  pointer-events: none
}

.xclinic-install-spinner {
  display: inline-block;
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
  animation: xclinic-install-spin .75s linear infinite
}

.xclinic-install-go {
  gap: 8px
}

@keyframes xclinic-install-spin {
  to {
    transform: rotate(360deg)
  }

}

.xclinic-install-complete {
  display: block;
  width: 100%;
  margin-top: 15px;
  padding: 12px;
  background: transparent;
  border: 0;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 750;
  font-size: 13px
}

.xclinic-install-card button:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px
}

.pwa-install-admin-grid {
  margin-top: 15px
}

html[data-theme-effective="dark"] .xclinic-install-overlay {
  background: rgba(0,0,0,.76)
}

html[data-theme-effective="dark"] .xclinic-install-card {
  box-shadow: 0 28px 85px rgba(0,0,0,.6)
}

@media(max-width:360px) {
  .xclinic-install-card {
    padding: 21px 15px;
    border-radius: 18px
  }

  .xclinic-install-actions {
    gap: 8px
  }

  .xclinic-install-actions .btn {
    padding: 9px 6px;
    font-size: 13px
  }

}

@media(prefers-reduced-motion:reduce) {
  .xclinic-install-actions .btn {
    transition: none
  }

  .xclinic-install-spinner {
    animation-duration: 2s
  }

}

/* === [S44] Installation and error-page navigation feedback === */
/* XCLINIC installation polish and error-page navigation feedback (V3). */
.xclinic-install-card {
  max-height: calc(100dvh - 28px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch
}

.xclinic-install-card .xclinic-install-status[hidden] {
  display: none!important
}

.xclinic-install-card .xclinic-install-help[hidden] {
  display: none!important
}

.xclinic-install-actions .btn {
  touch-action: manipulation
}

.xclinic-install-card button {
  scroll-margin: 14px
}

.xclinic-install-card .xclinic-install-status-alert {
  border-color: var(--danger,var(--line))
}

.error-page-action.is-loading {
  opacity: .78;
  cursor: progress;
  gap: 8px
}

.error-page-action.is-loading .ui-icon {
  animation: xclinic-install-spin .9s linear infinite
}

@media (prefers-reduced-motion:reduce) {
  .xclinic-install-spinner,.error-page-action.is-loading .ui-icon {
    animation: none
  }

}

@media (max-height:520px) {
  .xclinic-install-card {
    padding: 14px 16px
  }

  .xclinic-install-brand {
    margin-bottom: 9px;
    width: 56px;
    height: 56px
  }

  .xclinic-install-actions {
    margin-top: 13px
  }

}

/* === [S45] Clinical term suggestions === */
/* In-place clinical term suggestions, scoped to clinic-enabled fields. */
.clinical-suggest-host {
  position: relative
}

.clinical-suggest-popup {
  position: absolute;
  z-index: 12;
  right: 10px;
  bottom: 8px;
  max-width: calc(100% - 20px);
  pointer-events: none
}

.clinical-suggest-popup[hidden] {
  display: none
}

.clinical-suggest-choice {
  pointer-events: auto;
  border: 1px solid #e8c84b;
  border-radius: 9px;
  padding: 5px 10px;
  background: #fff2a8;
  color: #473800;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 3px 10px rgba(0,0,0,.12);
  cursor: pointer
}

.clinical-suggest-choice.clinical-suggest-touch {
  min-height: 42px;
  padding: 8px 14px;
  font-size: 14px;
  touch-action: manipulation
}

html[data-theme-effective="dark"] .clinical-suggest-choice {
  background: #514316;
  border-color: #9a812b;
  color: #fff0a2
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .clinical-suggest-choice {
    background: #514316;
    border-color: #9a812b;
    color: #fff0a2
  }

}

/* === [S46] Compact mobile patient cards === */
/* Compact mobile cards while preserving every field and action. */
@media(max-width:560px) {
  .patient-card-modern .patient-card-open {
    padding: 9px 10px 7px
  }

  .patient-card-modern .patient-card-head {
    gap: 7px
  }

  .patient-card-modern .patient-avatar-modern {
    width: 39px;
    height: 39px;
    border-radius: 12px
  }

  .patient-card-modern .patient-card-info {
    margin-top: 7px;
    padding-top: 7px;
    gap: 5px
  }

  .patient-card-modern .patient-card-info>div {
    padding: 5px 6px
  }

  .patient-card-modern .patient-card-status {
    padding: 0 10px 7px
  }

  .card,.workspace-card,.search-card {
    padding: 13px;
    margin-bottom: 11px
  }

  .patient-card-modern {
    padding: 0
  }

}

.today-visit-launcher {
  margin: 0 0 8px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  display: flex;
  justify-content: flex-start
}

.today-visit-launcher-button {
  min-height: 40px;
  padding: 8px 12px
}

.account-logout-action {
  display: flex;
  justify-content: flex-start;
  margin: 12px 0 24px
}

.subscription-expiring-row {
  background: #fff6c9!important;
  color: #543f00
}

.subscription-expiring-row td {
  background: #fff6c9!important;
  border-color: #eddda0!important
}

.subscription-expiring-badge {
  display: inline-flex;
  margin-inline-start: 5px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #f4d85f;
  color: #503d00;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap
}

.subscription-notice-banner {
  display: grid;
  gap: 10px;
  margin: 0 0 13px;
  padding: 13px 15px;
  border: 1px solid #e7d589;
  border-inline-start: 4px solid #d5aa22;
  border-radius: 15px;
  background: linear-gradient(135deg,#fff9dc,#fffdf3);
  color: #594915;
  box-shadow: 0 5px 16px rgba(81,65,12,.06)
}

.subscription-notice-message {
  display: flex;
  align-items: flex-start;
  gap: 10px
}

.subscription-notice-icon {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #f5e7a9;
  color: #78600e
}

.subscription-notice-message b {
  display: block;
  margin: 0 0 3px;
  font-size: 13px;
  font-weight: 950
}

.subscription-notice-message p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  font-weight: 750
}

.subscription-notice-validity {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 7px 12px;
  padding-top: 9px;
  border-top: 1px solid rgba(173,143,44,.25)
}

.subscription-notice-validity-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap
}

.subscription-notice-expiry-date {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  color: #776a42
}

.subscription-notice-expiry-date b {
  color: #594915;
  font-size: 11px;
  font-variant-numeric: tabular-nums
}

.subscription-notice-validity .subscription-countdown-bar {
  grid-column: 1/-1;
  justify-content: flex-start;
  margin: 0;
  padding: 0
}

.subscription-notice-validity .subscription-countdown-pill {
  box-shadow: none
}

.subscription-notice-admin-card {
  border-color: #eadb9e;
  background: linear-gradient(145deg,#fffefa,#fff9e7)
}

.subscription-notice-clinic-picker {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  margin: 0 0 12px
}

.subscription-notice-clinic-picker .field {
  flex: 1;
  margin: 0
}

.subscription-notice-admin-form {
  display: grid;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line)
}

.subscription-notice-selected-clinic {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--primary);
  font-size: 13px
}

.subscription-notice-toggle {
  width: fit-content;
  max-width: 100%
}

html[data-theme-effective="dark"] .subscription-notice-banner {
  background: linear-gradient(135deg,#302b19,#252419);
  border-color: #675b31;
  color: #f4e6a2
}

html[data-theme-effective="dark"] .subscription-notice-icon {
  background: #51451f;
  color: #ffe890
}

html[data-theme-effective="dark"] .subscription-notice-validity {
  border-color: rgba(202,177,91,.25)
}

html[data-theme-effective="dark"] .subscription-notice-expiry-date {
  color: #c5b980
}

html[data-theme-effective="dark"] .subscription-notice-expiry-date b {
  color: #ffed9c
}

html[data-theme-effective="dark"] .subscription-notice-admin-card {
  background: linear-gradient(145deg,#202625,#28271d);
  border-color: #615833
}

html[data-theme-effective="dark"] .subscription-expiring-row,
html[data-theme-effective="dark"] .subscription-expiring-row td {
  background: #3b341b!important;
  color: #ffed9c;
  border-color: #65582a!important
}

html[data-theme-effective="dark"] .subscription-expiring-badge {
  background: #67591e;
  color: #fff1a6
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .subscription-expiring-row,
  html[data-theme-mode="auto"] .subscription-expiring-row td {
    background: #3b341b!important;
    color: #ffed9c;
    border-color: #65582a!important
  }

  html[data-theme-mode="auto"] .subscription-expiring-badge {
    background: #67591e;
    color: #fff1a6
  }

}

.education-account-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary);
  font-weight: 850
}

.education-account-link .ui-icon:last-child {
  margin-inline-start: auto;
  transform: rotate(90deg)
}

@media(max-width:560px) {
  .subscription-notice-banner {
    gap: 8px;
    padding: 10px 11px;
    border-radius: 12px
  }

  .subscription-notice-message p {
    font-size: 12px
  }

  .subscription-notice-validity {
    grid-template-columns: 1fr;
    gap: 6px
  }

  .subscription-notice-expiry-date {
    justify-content: flex-start
  }

  .subscription-notice-validity .subscription-countdown-bar {
    justify-content: center
  }

  .subscription-notice-clinic-picker {
    align-items: stretch;
    flex-direction: column
  }

  .subscription-notice-clinic-picker .btn,.subscription-notice-toggle {
    width: 100%
  }

}

/* === [S47] Custom-role permissions and visit workflow === */
/* Custom clinic roles: compact, touch friendly permissions and visit workflow. */
.role-permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(min(100%,220px),1fr));
  gap: 10px;
  margin: 14px 0
}

.role-field-permission {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 12px
}

.role-field-permission legend {
  padding: 0 5px;
  font-weight: 800
}

.role-field-permission label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  font-size: 13px
}

.role-definition-form {
  display: grid;
  gap: 10px
}

.role-workflow-card,.role-visit-fields {
  border-color: color-mix(in srgb,var(--primary) 24%,var(--line))
}

.role-workflow-item {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px
}

.role-workflow-item h3 {
  margin: 0 0 8px;
  font-size: 15px
}

.role-workflow-form {
  display: grid;
  gap: 10px
}

.role-workflow-form textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical
}

.role-workflow-text {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  margin: 8px 0;
  line-height: 1.75;
  overflow-wrap: anywhere
}

.role-workflow-text p {
  margin: 5px 0 0;
  white-space: pre-wrap
}

.role-visit-fields .field {
  margin: 10px 0
}

.role-visit-fields .btn,.role-workflow-form .btn {
  justify-self: start
}

@media(max-width:520px) {
  .role-permission-grid {
    grid-template-columns: 1fr
  }

  .role-field-permission {
    justify-content: space-between
  }

  .role-workflow-card,.role-visit-fields {
    padding: 14px
  }

}

.role-permission-section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin: 12px 0
}

.role-permission-section>legend {
  padding: 0 7px;
  font-weight: 850;
  color: var(--primary)
}

.role-permission-section .role-permission-grid {
  margin: 6px 0 0
}

.attachment-permissions-section {
  min-width: 0
}

.attachment-permission-layout {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 12px;
  align-items: stretch;
  margin-top: 6px
}

.attachment-permission-layout:has(>.attachment-permission-card:only-child) {
  grid-template-columns: minmax(0,1fr)
}

.attachment-permission-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text)
}

.attachment-permission-card>.permission-check-card {
  display: flex;
  align-items: center;
  min-height: 72px;
  width: 100%;
  min-width: 0;
  padding: 14px
}

.attachment-permission-card>.permission-check-card span {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.55
}

.attachment-permission-card .attachment-view-roles-field,.attachment-permission-card .attachment-upload-limit-field {
  width: 100%;
  min-width: 0;
  margin: 0
}

.attachment-permission-card .attachment-view-roles-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface)
}

.attachment-permission-card .attachment-view-roles-title {
  margin: 0;
  line-height: 1.6;
  overflow-wrap: anywhere
}

.attachment-permission-card .attachment-view-roles-field>.role-permission-grid {
  grid-template-columns: repeat(auto-fit,minmax(min(100%,150px),1fr));
  gap: 8px;
  margin: 0
}

.attachment-permission-card .attachment-view-roles-field>small {
  display: block;
  margin-top: auto;
  line-height: 1.7;
  overflow-wrap: anywhere
}

.attachment-permission-card .attachment-upload-limit-field {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1
}

.attachment-permission-card .attachment-upload-limit-field input {
  width: 100%;
  max-width: 100%
}

.attachment-permission-card .attachment-upload-limit-field small {
  line-height: 1.7;
  overflow-wrap: anywhere
}

@media(max-width:700px) {
  .attachment-permission-layout {
    grid-template-columns: minmax(0,1fr)
  }

  .attachment-permission-card {
    padding: 10px
  }

  .attachment-permission-card>.permission-check-card {
    min-height: 60px
  }

}

.role-delete-panel {
  margin-top: 16px;
  border: 1px solid color-mix(in srgb,#d74747 35%,var(--line));
  border-radius: 14px;
  overflow: hidden
}

.role-delete-panel>summary {
  min-height: 44px;
  padding: 11px 13px;
  cursor: pointer;
  color: #a72d2d;
  font-weight: 900;
  display: flex;
  align-items: center
}

.role-delete-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line)
}

.role-delete-form .field,.role-purge-form .field {
  margin: 0
}

.role-delete-form .btn,.role-purge-form .btn {
  justify-self: start
}

.archived-roles-card {
  border-style: dashed
}

.archived-role-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,2fr);
  gap: 12px;
  align-items: start;
  padding: 13px 0;
  border-top: 1px solid var(--line)
}

.archived-role-row>div:first-child {
  display: grid;
  gap: 4px;
  overflow-wrap: anywhere
}

.archived-role-row small {
  color: var(--muted);
  font-size: 11px
}

.archived-role-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px
}

.archived-role-actions form {
  margin: 0
}

.role-purge-form {
  display: grid;
  grid-template-columns: minmax(180px,1fr) auto;
  align-items: end;
  gap: 8px;
  flex: 1 1 100%
}

html[data-theme-effective="dark"] .role-delete-panel>summary {
  color: #ff9b93
}

@media(max-width:620px) {
  .archived-role-row {
    grid-template-columns: 1fr
  }

  .archived-role-actions {
    display: grid;
    grid-template-columns: 1fr
  }

  .archived-role-actions form,.archived-role-actions .btn {
    width: 100%
  }

  .role-purge-form {
    grid-template-columns: 1fr
  }

  .role-delete-form .btn,.role-purge-form .btn {
    width: 100%
  }

}

/* === [S48] Assistant clinic selection === */
/* Scoped assistant-clinic multi-select: thumb-friendly, RTL, light/dark ready. */
.delegate-clinic-fieldset {
  min-width: 0;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface)
}

.delegate-clinic-fieldset>legend {
  padding: 0 8px;
  font-weight: 850;
  color: var(--text)
}

.delegate-clinic-fieldset>.small {
  margin: 4px 0 12px;
  line-height: 1.8
}

.delegate-clinic-picker {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  min-width: 0
}

.delegate-clinic-picker>summary {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  padding: 13px;
  min-height: 52px;
  list-style: none;
  font-weight: 800;
  color: var(--text);
  user-select: none
}

.delegate-clinic-picker>summary::-webkit-details-marker {
  display: none
}

.delegate-clinic-picker>summary>span {
  flex: 1;
  min-width: 0;
  white-space: normal
}

.delegate-clinic-picker>summary>strong {
  font-size: 12px;
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--primary-soft);
  color: var(--primary);
  white-space: nowrap
}

.delegate-clinic-picker>summary .ui-icon {
  width: 19px;
  height: 19px;
  flex-shrink: 0
}

.delegate-clinic-picker[open]>summary {
  border-bottom: 1px solid var(--line)
}

.delegate-clinic-picker>summary:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px
}

.delegate-clinic-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  max-height: 300px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px
}

.delegate-clinic-options .permission-check-card {
  margin: 0;
  min-height: 50px;
  align-items: center
}

.delegate-clinic-options input[type=checkbox] {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  accent-color: var(--primary)
}

@media(min-width:680px) {
  .delegate-clinic-options {
    grid-template-columns: repeat(2,minmax(0,1fr))
  }

}

@media(prefers-reduced-motion:reduce) {
  .delegate-clinic-picker * {
    scroll-behavior: auto
  }

}

/* === [S49] User identity and clinic membership cards === */
/* A single user card owns identity, memberships and every permitted action. */
.admin-user-list {
  display: grid;
  gap: 14px
}

.admin-user-list>.admin-user-card {
  margin: 0;
  min-width: 0
}

.admin-user-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px
}

.admin-user-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--primary);
  font-size: 23px;
  font-weight: 900;
  border: 1px solid var(--line)
}

.admin-user-identity {
  flex: 1;
  min-width: 0
}

.admin-user-identity h2 {
  margin: 0 0 4px;
  font-size: 18px;
  overflow-wrap: anywhere;
  line-height: 1.6
}

.admin-user-login {
  display: inline-block;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
  max-width: 100%
}

.admin-user-memberships {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 14px
}

.admin-user-clinic {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 9px;
  font-size: 12px;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere
}

.admin-user-clinic .ui-icon {
  flex: 0 0 16px;
  width: 16px;
  height: 16px
}

.admin-user-actions {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 8px
}

.admin-user-actions>.btn {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 44px;
  padding: 10px 8px;
  white-space: normal;
  text-align: center;
  font-size: 13px;
  line-height: 1.5
}

.admin-user-actions>.btn .ui-icon {
  flex: 0 0 18px;
  width: 18px;
  height: 18px
}

.admin-user-actions>[aria-expanded="true"] {
  outline: 2px solid var(--primary);
  outline-offset: 2px
}

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

.admin-user-panel[hidden] {
  display: none!important
}

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

.admin-user-panel-heading h3 {
  font-size: 16px;
  margin: 0
}

.admin-user-panel form {
  min-width: 0
}

.admin-user-panel .form-grid {
  margin-bottom: 12px
}

.admin-user-panel .field {
  min-width: 0
}

.admin-user-panel .field input,.admin-user-panel .field select {
  width: 100%;
  max-width: 100%;
  min-width: 0
}

.admin-user-link-form {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 16px
}

.admin-user-link-form h4 {
  margin: 0 0 12px;
  font-size: 14px
}

.admin-user-permission-links {
  display: grid;
  gap: 10px
}

.admin-user-permission-links .btn {
  justify-content: flex-start;
  white-space: normal;
  text-align: start
}

.admin-user-create>summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 800;
  min-height: 44px
}

.admin-user-create[open]>summary {
  margin-bottom: 14px
}

.admin-user-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0
}

.admin-user-deleted-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px
}

.admin-user-deleted-link>span {
  font-size: 13px;
  color: var(--muted)
}

.admin-user-deleted-link .btn {
  white-space: normal
}

.admin-user-restore-form {
  display: grid;
  gap: 12px
}

.admin-user-restore-clinics {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 0;
  padding: 12px;
  min-width: 0
}

.admin-user-restore-clinic {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 0;
  overflow-wrap: anywhere
}

.admin-user-restore-clinic input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin-top: 3px
}

.admin-user-restore-clinic small {
  display: block;
  color: var(--muted)
}

@media(max-width:560px) {
  .admin-user-actions {
    grid-template-columns: repeat(2,minmax(0,1fr))
  }

  .admin-user-card-header {
    gap: 9px;
    align-items: flex-start
  }

  .admin-user-identity h2 {
    font-size: 16px
  }

  .admin-user-card-header>.badge {
    flex: 0 0 auto;
    font-size: 11px
  }

  .admin-user-deleted-link {
    align-items: stretch;
    flex-direction: column
  }

  .admin-user-deleted-link .btn {
    width: 100%
  }

}

/* === [S50] Compact account password reset === */
/* Compact password reset under the owner account: works on narrow mobile tables. */
.owner-user-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px
}

.owner-reset-details {
  min-width: 190px;
  max-width: 300px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text)
}

.owner-reset-details>summary {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  padding: 9px 10px;
  font-weight: 800;
  font-size: 12px;
  list-style: none;
  min-height: 40px
}

.owner-reset-details>summary::-webkit-details-marker {
  display: none
}

.owner-reset-details>summary .ui-icon {
  width: 17px;
  height: 17px
}

.owner-reset-details[open]>summary {
  border-bottom: 1px solid var(--line)
}

.owner-password-reset-form {
  padding: 11px;
  display: grid;
  gap: 8px
}

.owner-password-label {
  font-size: 12px;
  font-weight: 800;
  white-space: normal
}

.owner-password-controls {
  display: flex;
  gap: 5px
}

.owner-password-controls input {
  width: 100%;
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  direction: ltr;
  text-align: left
}

.owner-password-controls .btn {
  flex: 0 0 auto
}

.owner-password-reset-form .btn-primary {
  white-space: normal
}

.owner-password-reset-form small {
  font-size: 11px;
  white-space: normal;
  line-height: 1.6
}

.owner-reset-details>summary:focus-visible {
  outline: 3px solid var(--primary)
}

@media(max-width:480px) {
  .delegate-clinic-fieldset {
    padding: 10px
  }

  .delegate-clinic-picker>summary {
    padding: 12px 9px;
    gap: 6px
  }

  .delegate-clinic-picker>summary>strong {
    font-size: 11px;
    padding: 5px 7px
  }

  .owner-password-controls .btn {
    min-width: 44px;
    min-height: 44px
  }

  .owner-reset-details {
    min-width: 178px
  }

}

/* === [S51] Patient-card rendering containment === */
/* Rendering containment only: every card remains in the document and accessible. */
@supports(content-visibility:auto) {
  .patient-grid-modern>.patient-card-modern {
    content-visibility: auto;
    contain-intrinsic-size: auto 210px
  }

}

@media print {
  .patient-grid-modern>.patient-card-modern {
    content-visibility: visible;
    contain-intrinsic-size: none
  }

}

/* === [S52] Print-template geometry === */
/* Same physical geometry in settings and the actual print sheet. */
.print-settings-paper {
  font-family: Tahoma,Arial,sans-serif
}

.print-settings-box {
  max-width: 100%;
  padding: 1.2mm 1.8mm
}

.print-settings-box.patient-box,.print-settings-box.date-box,.print-settings-box.age-box {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  font-weight: 700
}

.print-settings-box.text-box {
  padding: 1.5mm;
  line-height: 1.65;
  font-weight: 400;
  overflow-wrap: anywhere
}

.print-settings-box.text-box>b {
  font-weight: 400
}

.print-settings-box.rights-box {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
  font-weight: 500;
  text-align: right
}

.print-settings-box.rights-box>b {
  font-weight: 500
}

.print-settings-fields {
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0
}

.print-output-tools {
  display: flex;
  justify-content: center
}

.print-output-tools button {
  margin-bottom: 10px
}

.print-output-status {
  margin: 0;
  padding: 8px 12px;
  text-align: center
}

.print-output-check .print-settings-box>span {
  display: none
}

@media print {
  html.print-settings-document,
  html.print-settings-document .print-settings-sheet-path {
    display: block!important;
    position: static!important;
    width: auto!important;
    height: auto!important;
    min-height: 0!important;
    max-width: none!important;
    margin: 0!important;
    padding: 0!important;
    overflow: visible!important;
    border: 0!important;
    border-radius: 0!important;
    box-shadow: none!important;
    background: white!important;
    color-scheme: light!important
  }

  .print-settings-sheet-path>:not(.print-settings-sheet-path):not([data-print-settings-paper]) {
    display: none!important
  }

  html.print-settings-document .print-settings-paper {
    position: relative!important;
    inset: auto!important;
    transform: none!important;
    box-shadow: none!important;
    outline: 0!important;
    background: white!important;
    color: #111!important;
    overflow: hidden
  }

  html.print-settings-document .print-settings-box {
    border-color: transparent!important;
    background: transparent!important
  }

  html.print-settings-document .text-box {
    z-index: 2
  }

  html.print-settings-document .print-settings-preview-empty,
  html.print-settings-document .print-settings-box>span,
  html.print-settings-blocked .print-settings-paper {
    display: none!important
  }

  html.print-settings-blocked .print-settings-sheet-path>[data-print-output-inline-status] {
    display: block!important;
    color: #111;
    padding: 10mm
  }

  html.print-settings-document .print-settings-template-image {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact
  }
}

.today-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 14px;
  font-size: 12px
}

.today-pagination[hidden],.today-pagination [hidden] {
  display: none!important
}

/* === [S53] Preview retry visibility === */
/* Keep the preview retry control hidden while its read requests are active. */
[data-cleanup-retry][hidden], [data-cleanup-refresh][hidden] {
  display: none!important
}

/* === [S54] Cleanup progress indicators === */
/* Durable cleanup progress: native progress supports assistive technology and RTL. */
.delete-job-panel progress {
  display: block;
  width: 100%;
  height: 18px;
  accent-color: var(--primary,#168c8b);
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--border,#d8e4e5)
}

.delete-job-panel progress::-webkit-progress-bar {
  background: var(--border,#d8e4e5)
}

.delete-job-panel progress::-webkit-progress-value {
  background: var(--primary,#168c8b);
  border-radius: 10px
}

.delete-job-panel progress::-moz-progress-bar {
  background: var(--primary,#168c8b);
  border-radius: 10px
}

.delete-job-panel [hidden] {
  display: none!important
}

.delete-job-panel [data-job-detail],.delete-job-panel [data-job-status] {
  overflow-wrap: anywhere;
  line-height: 1.8
}

.delete-job-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px
}

.delete-job-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(min(100%,150px),1fr));
  gap: 10px
}

.delete-job-totals>div {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border,#d8e4e5);
  border-radius: 10px
}

.delete-job-totals b {
  font-variant-numeric: tabular-nums
}

@media(max-width:480px) {
  .delete-job-actions .btn {
    flex: 1 1 130px;
    min-height: 44px
  }

}

/* === [S55] Booking source badges === */
/* The booking source stays readable beside a patient name on narrow phones. */
.patient-card-name .badge.patient-online-booking {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  min-height: 26px;
  padding: 4px 9px;
  margin-block-start: 5px;
  border: 1px solid #93bce1;
  background: #e8f4ff;
  color: #134f82;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.5;
  white-space: normal;
  text-align: start;
  vertical-align: top
}

.patient-online-booking>span[aria-hidden] {
  flex: 0 0 auto;
  font-size: 14px;
  line-height: 1
}

html[data-theme-effective="dark"] .badge.patient-online-booking,
html[data-theme-mode="dark"] .badge.patient-online-booking {
  background: #193b4d;
  color: #d6efff;
  border-color: #6198b3
}

@media(prefers-color-scheme:dark) {
  html[data-theme-mode="auto"] .badge.patient-online-booking {
    background: #193b4d;
    color: #d6efff;
    border-color: #6198b3
  }

}

.clinic-public-links {
  border-top: 1px solid var(--border,#dbe6e7);
  margin-top: 1.5rem;
  padding-top: 1rem
}

.public-link-setting {
  border: 1px solid var(--border,#dbe6e7);
  border-radius: 14px;
  padding: 16px;
  min-width: 0
}

.public-link-setting .field {
  margin-top: 14px
}

.tv-link-number-row {
  display: grid;
  grid-template-columns: minmax(0, max-content) auto minmax(5rem, 9rem);
  align-items: center;
  justify-content: end;
  gap: .4rem;
}

.tv-link-number-row bdi {
  overflow-wrap: anywhere;
}

.tv-link-number-row input {
  min-width: 0;
  width: 100%;
}

.public-link-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap
}

.public-link-row input {
  flex: 1 1 180px;
  min-width: 0
}

.public-link-setting p {
  line-height: 1.8
}

/* === [S56] Patient-file save confirmation === */
/* One-use confirmation after a completed manual patient-file save. */
dialog.patient-save-success {
  width: min(380px,calc(100% - 32px));
  max-width: calc(100% - 32px);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  margin: auto;
  padding: 26px 24px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 76px rgba(5,23,29,.26);
  direction: rtl;
  text-align: center;
}

dialog.patient-save-success[open] {
  display: grid;
  justify-items: center;
  gap: 12px
}

dialog.patient-save-success:not([open]),
dialog.patient-save-success[hidden],
.patient-save-success [hidden] {
  display: none!important
}

.patient-save-success::backdrop {
  background: rgba(5,23,29,.48)
}

.patient-save-success__icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin-bottom: 4px;
  border: 1px solid var(--line);
  border-radius: 21px;
  background: var(--primary-soft);
  color: var(--ok);
}

.patient-save-success__icon svg {
  display: block;
  width: 34px;
  height: 34px;
  color: currentColor
}

.patient-save-success .patient-save-success__title {
  margin: 0;
  color: var(--text);
  font-size: 21px;
  font-weight: 800;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.patient-save-success__message {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.85;
  overflow-wrap: anywhere;
  max-width: 100%;
}

body.has-patient-save-success {
  overflow: hidden
}

html[data-theme-effective="dark"] .patient-save-success::backdrop {
  background: rgba(0,0,0,.58)
}

@media(max-width:360px) {
  dialog.patient-save-success {
    padding: 22px 20px;
    border-radius: 21px
  }

  .patient-save-success .patient-save-success__title {
    font-size: 20px
  }

}

@media(prefers-reduced-motion:reduce) {
  .patient-save-success,.patient-save-success * {
    animation: none!important;
    transition: none!important;
    scroll-behavior: auto!important
  }

}

@media print {
  dialog.patient-save-success {
    display: none!important
  }

  body.has-patient-save-success {
    overflow: visible
  }

}
.rt-policy-row{display:grid;grid-template-columns:minmax(12em,2fr) minmax(9em,1fr) auto;gap:.6rem;align-items:center;padding:.6rem 0;border-bottom:1px solid currentColor}
.rt-policy-row input[type=number]{width:5.5em}.rt-policy-row small{display:block}.rt-toggle{display:inline-flex;gap:.35em;align-items:center;cursor:pointer}.rt-toggle input[type=checkbox]:not(:checked)~.rt-on,.rt-toggle input[type=checkbox]:checked~.rt-off{display:none}
.rt-required{min-block-size:100vh;min-block-size:100svh;display:grid;place-items:center;padding:1rem}
.rt-required .workspace-card{inline-size:100%;max-inline-size:30rem}
.rt-required progress{inline-size:100%;block-size:1rem}
.rt-required a{display:inline-block;padding-block:.5rem}
@media(max-width:600px){.rt-policy-row{grid-template-columns:1fr auto}.rt-policy-row>label:first-child{grid-column:1/-1}}

