:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --ink: #14221f;
  --muted: #5c6e6a;
  --line: #e4ebe8;
  --accent: #0d8a7a;
  --accent-2: #0b5f56;
  --accent-soft: #e7f6f3;
  --danger: #c23b3b;
  --danger-soft: #fdecec;
  --ok: #1f8a4c;
  --ok-soft: #e8f7ee;
  --warn: #b7791f;
  --sidebar: #0c2e2c;
  --sidebar-2: #13403d;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(12, 46, 44, 0.06);
  --header-h: 64px;
  --sidebar-w: 260px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

html { direction: rtl; }

body {
  font-family: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  font-size: 15px;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--accent); }
img { max-width: 100%; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--header-h) 1fr;
  transition: grid-template-columns .22s ease;
}
html.sidebar-closed .app {
  grid-template-columns: 0 minmax(0, 1fr);
}

.app-sidebar {
  grid-row: 1 / -1;
  background: linear-gradient(180deg, var(--sidebar) 0%, #081f1e 100%);
  color: #e8f4f2;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  min-width: 0;
  width: var(--sidebar-w);
}
html.sidebar-closed .app-sidebar {
  overflow: hidden;
  padding: 0;
  width: 0;
  opacity: 0;
  pointer-events: none;
}
.sidebar-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  margin-top: 6px;
  border: 0;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  color: #d5ece8;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.sidebar-close:hover { background: rgba(255,255,255,.16); color: #fff; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0 22px;
  color: #fff;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: -1px;
}

.brand strong { display: block; font-size: 16px; }
.brand span { display: block; font-size: 12px; color: #9ec9c3; }

.nav-group {
  margin: 8px 0 18px;
}

.nav-group h4 {
  margin: 0 10px 8px;
  font-size: 11px;
  color: #8fb8b3;
  font-weight: 600;
  letter-spacing: .4px;
}

.nav-group-collapsible .nav-group-items {
  display: none;
}
.nav-group-collapsible.is-open .nav-group-items,
html.settings-nav-open [data-nav-collapsible="settings"] .nav-group-items {
  display: block;
}
.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: calc(100% - 20px);
  margin: 0 10px 8px;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: #8fb8b3;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .4px;
  cursor: pointer;
}
.nav-group-toggle:hover {
  background: rgba(255,255,255,.06);
  color: #c5e5df;
}
.nav-group-chevron {
  font-size: 11px;
  transition: transform .2s ease;
}
.nav-group-collapsible.is-open .nav-group-chevron,
html.settings-nav-open [data-nav-collapsible="settings"] .nav-group-chevron {
  transform: rotate(180deg);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: #d5ece8;
  font-size: 13.5px;
}

.nav-link:hover,
.nav-link.is-active {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.nav-link.is-active {
  background: var(--accent);
}

.app-header {
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-search {
  flex: 1;
  max-width: 420px;
}

.header-search input {
  width: 100%;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-2);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.user-meta small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.app-main {
  padding: 22px;
  min-width: 0;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-head h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.page-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.list-filters label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.list-filters select {
  min-width: 170px;
  margin: 0;
}

.card,
.card-flush {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.card-title,
.card-title h5,
.card-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.card-body,
.card-toolbar { padding: 16px 18px; }
.card-toolbar { padding-top: 0; }

.table-responsive { overflow-x: auto; }

table.table,
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table th,
.table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
}

.table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  background: #f8fafa;
}

.table tbody tr:hover { background: #f7fbfa; }

.tooth-display {
  position: relative;
  width: 44px;
  height: 44px;
  margin: 0 auto;
}
.tooth-number {
  position: absolute;
  width: 50%;
  height: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  padding: 0;
  background: transparent;
}
.tooth-display::before,
.tooth-display::after {
  content: "";
  position: absolute;
  background: #000;
  pointer-events: none;
}
.tooth-display::before {
  width: 2px;
  height: 78%;
  top: 11%;
  right: 50%;
  transform: translateX(50%);
}
.tooth-display::after {
  height: 2px;
  width: 78%;
  top: 50%;
  right: 11%;
  transform: translateY(-50%);
}
.tooth-number.top-right { top: 0; right: 0; }
.tooth-number.top-left { top: 0; left: 0; }
.tooth-number.bottom-right { bottom: 0; right: 0; }
.tooth-number.bottom-left { bottom: 0; left: 0; }

.btn,
button.btn,
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 10px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.4;
  background: var(--accent-soft);
  color: var(--accent-2);
}

.btn:hover { filter: brightness(.97); color: var(--accent-2); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); color: #fff; }
.btn-light,
.btn-light-primary,
.btn-light-success,
.btn-sm.btn-light { background: #eef3f2; color: var(--ink); }
.btn-danger,
.btn-light-danger { background: var(--danger-soft); color: var(--danger); }
.btn-success { background: #d7efe4; color: #176b40; }
.btn-secondary { background: #dce8e5; color: #1c3d39; }
.app-toolbar .btn {
  border: 1px solid #c4d8d3;
  background: #dff1ed;
  color: var(--accent-2);
}
.app-toolbar .btn-primary {
  background: var(--accent);
  border-color: #0b7467;
  color: #fff;
}
.app-toolbar .btn-success {
  background: #d4eee3;
  border-color: #b3d7c4;
  color: #176b40;
}
.app-toolbar .btn-secondary {
  background: #dde7e4;
  border-color: #c0d0cc;
  color: #1c3d39;
}
.app-toolbar .btn-primary:hover { color: #fff; }
.app-toolbar .btn-success:hover { color: #176b40; }
.app-toolbar .btn-secondary:hover { color: #1c3d39; }
.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
  filter: none;
}
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 10px; }

input, select, textarea,
.form-control,
.form-control-solid,
.form-select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fbfdfc;
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
}

input:focus, select:focus, textarea:focus,
.form-control:focus {
  outline: 2px solid rgba(13,138,122,.25);
  border-color: var(--accent);
  background: #fff;
}

label, .fw-semibold { font-weight: 600; }
.required::after { content: " *"; color: var(--danger); }

.fv-row, .mb-7, .mb-3, .mb-2 { margin-bottom: 12px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.visit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.visit-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.visit-card h3 { margin: 0 0 10px; font-size: 16px; }
.visit-card li { list-style: none; color: var(--muted); font-size: 13px; margin: 6px 0; }
.visit-card ul { margin: 0; padding: 0; }
.date-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 10px;
  grid-column: 1 / -1;
  color: var(--muted);
  font-weight: 700;
}
.date-sep::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.visit-board-hint {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-2);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 6px 12px;
}

.visit-page-head {
  flex-wrap: wrap;
  gap: 12px 16px;
}

.visit-view-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.visit-view-tabs {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.visit-view-tab {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
}

.visit-view-tab:hover { color: var(--accent-2); }
.visit-view-tab.is-active {
  background: linear-gradient(135deg, #0d8a7a, #14b8a6);
  color: #fff;
}

.visit-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.visit-period {
  min-width: 140px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-2);
  padding: 0 8px;
}

.visit-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 2px 18px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.visit-week {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.visit-week-scroll {
  max-height: calc(100vh - 190px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.visit-week-grid {
  display: grid;
  grid-template-columns: 56px repeat(var(--day-count, 7), minmax(120px, 1fr));
  min-width: calc(56px + (var(--day-count, 7) * 120px));
}

.visit-week.is-day .visit-week-grid {
  grid-template-columns: 64px minmax(280px, 1fr);
  min-width: 0;
}

.visit-week-corner,
.visit-week-dayhead,
.visit-week-time {
  position: sticky;
  z-index: 2;
  background: #e8f6f3;
}

.visit-week-corner {
  top: 0;
  inset-inline-start: 0;
  z-index: 4;
  border-bottom: 1px solid #c5e5de;
  border-inline-end: 1px solid #c5e5de;
  min-height: 64px;
}

.visit-week-dayhead {
  top: 0;
  z-index: 3;
  padding: 10px 8px;
  border-bottom: 1px solid #c5e5de;
  border-inline-end: 1px solid #c5e5de;
  text-align: center;
  background: linear-gradient(180deg, #0d8a7a, #0f9a88);
  color: #fff;
  min-height: 64px;
}

.visit-week-dayhead strong {
  display: block;
  font-size: 13px;
}

.visit-week-dayhead span {
  display: block;
  font-size: 11px;
  opacity: .9;
  margin-top: 2px;
}

.visit-week-dayhead em {
  display: block;
  font-style: normal;
  font-size: 10px;
  opacity: .85;
  margin-top: 4px;
}

.visit-week-dayhead.is-today {
  background: linear-gradient(180deg, #0b5f56, #0d8a7a);
  box-shadow: inset 0 -3px 0 #fbbf24;
}

.visit-week-time {
  inset-inline-start: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  border-inline-end: 1px solid #c5e5de;
  background: #f3faf8;
  min-height: 64px;
  font-variant-numeric: tabular-nums;
}

.visit-week-cell {
  min-height: 64px;
  border-bottom: 1px solid var(--line);
  border-inline-end: 1px solid var(--line);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fff;
  transition: background .12s, box-shadow .12s;
  position: relative;
  overflow: visible;
  z-index: 1;
}

.visit-week-cell:has(.visit-week-card) {
  z-index: 2;
}

.visit-week-cell.is-today {
  background: #f7fffc;
}

.visit-week-cell.is-over {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
  z-index: 4;
}

.visit-week-cell .visit-slot-empty {
  flex: 1;
  min-height: 40px;
  border: 1px dashed transparent;
  border-radius: 8px;
  color: transparent;
  font-size: 14px;
  display: grid;
  place-items: center;
  background: transparent;
}

.visit-week.is-dragging-active .visit-week-cell .visit-slot-empty {
  border-color: #b7d0ca;
  color: #9bb5ae;
}

.visit-week-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: linear-gradient(135deg, #fff 0%, #eef9f6 100%);
  border: 1px solid #c5e5de;
  border-inline-start: 3px solid var(--accent);
  border-radius: 8px;
  padding: 6px 8px;
  cursor: grab;
  font-size: 12px;
  line-height: 1.35;
  --span: 1;
  height: calc(var(--span) * 64px - 8px);
  min-height: calc(var(--span) * 64px - 8px);
  box-shadow: 0 4px 14px rgba(12, 46, 44, .08);
  z-index: 3;
}

.visit-week-card b {
  font-size: 10px;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
}

.visit-week-card a {
  color: var(--ink);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visit-week-card small {
  color: var(--muted);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visit-week-card.is-dragging {
  opacity: .4;
}

html[data-theme="dark"] .visit-week {
  background: #152523;
  border-color: #2a403d;
}
html[data-theme="dark"] .visit-week-corner,
html[data-theme="dark"] .visit-week-time {
  background: #1a2b28;
  border-color: #2a403d;
  color: var(--muted);
}
html[data-theme="dark"] .visit-week-cell {
  background: #1a2b28;
  border-color: #2a403d;
}
html[data-theme="dark"] .visit-week-cell.is-today {
  background: #1e3330;
}
html[data-theme="dark"] .visit-week-card {
  background: #243532;
  border-color: #2a403d;
}

@media (max-width: 900px) {
  .visit-week-grid {
    grid-template-columns: 48px repeat(var(--day-count, 7), minmax(110px, 1fr));
    min-width: calc(48px + (var(--day-count, 7) * 110px));
  }
}

.visit-board.is-day .visit-day {
  flex: 1 1 100%;
  max-width: 720px;
  margin: 0 auto;
}

.visit-day {
  flex: 0 0 min(280px, 82vw);
  scroll-snap-align: start;
  background: linear-gradient(180deg, #f3faf8 0%, #fff 40%);
  border: 1px solid #c5e5de;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
  min-height: 420px;
  box-shadow: 0 6px 20px rgba(13, 138, 122, 0.06);
  transition: border-color .15s, box-shadow .15s;
}

.visit-day.is-today {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(13, 138, 122, 0.2);
}

.visit-day.is-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 138, 122, 0.18);
}

.visit-day-head {
  flex: 0 0 auto;
  padding: 12px 14px;
  border-bottom: 1px solid #c5e5de;
  background: linear-gradient(135deg, #0d8a7a, #14b8a6);
  color: #fff;
  border-radius: 15px 15px 0 0;
  display: grid;
  gap: 2px;
}

.visit-day-head strong { font-size: 15px; }
.visit-day-head span { font-size: 12px; opacity: .92; }
.visit-day-head em {
  font-style: normal;
  font-size: 11px;
  opacity: .85;
  margin-top: 2px;
}

.visit-day-slots {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.visit-slot {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 6px;
  min-height: 44px;
  border: 1px dashed transparent;
  border-radius: 10px;
  padding: 4px;
  transition: background .15s, border-color .15s;
}

.visit-slot.is-over {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.visit-slot-time {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding-top: 10px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.visit-slot-body {
  min-height: 40px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.visit-slot-empty {
  min-height: 36px;
  border: 1px dashed #c5e5de;
  border-radius: 8px;
  color: #9bb5ae;
  font-size: 11px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.6);
}

.visit-board.is-dragging-active .visit-slot-empty,
.visit-month.is-dragging-active .visit-slot-empty {
  border-color: #7ecfc0;
  color: var(--accent-2);
}

.visit-card-dnd {
  position: relative;
  cursor: grab;
  padding: 10px 10px 10px 28px;
  margin: 0;
  user-select: none;
  border-right: 3px solid var(--accent);
  transition: transform .12s, box-shadow .12s, opacity .12s;
}

.visit-card-dnd:active { cursor: grabbing; }
.visit-card-dnd.is-dragging {
  opacity: .45;
  transform: scale(0.98);
}

.visit-card-drag {
  position: absolute;
  right: 6px;
  top: 10px;
  color: #9bb5ae;
  font-size: 14px;
  letter-spacing: -2px;
  line-height: 1;
}

.visit-card-dnd h3 { font-size: 13px; margin-bottom: 6px; }
.visit-card-dnd li { margin: 3px 0; font-size: 12px; }

.visit-month {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.visit-month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}

.visit-month-weekdays span {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 6px 0;
}

.visit-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.visit-month-cell {
  min-height: 110px;
  border: 1px solid #c5e5de;
  border-radius: 12px;
  background: #f7fbfa;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.visit-month-cell.is-empty {
  background: transparent;
  border-color: transparent;
}

.visit-month-cell.is-today {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.visit-month-cell.is-over {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.visit-month-cell header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.visit-month-cell header strong {
  font-size: 14px;
  color: var(--accent-2);
}

.visit-month-cell header em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}

.visit-month-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 40px;
}

.visit-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid #c5e5de;
  border-right: 3px solid var(--accent);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 11px;
  cursor: grab;
}

.visit-chip b {
  font-variant-numeric: tabular-nums;
  color: var(--accent-2);
  flex-shrink: 0;
}

.visit-chip a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.visit-toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-right: 4px solid var(--ok);
  border-radius: 12px;
  padding: 10px 16px;
  box-shadow: 0 12px 32px rgba(12, 46, 44, 0.16);
  z-index: 130;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: min(420px, calc(100vw - 32px));
  font-size: 13px;
  font-weight: 600;
}

.visit-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.visit-toast.is-error { border-right-color: var(--danger); }

html[data-theme="dark"] .visit-day {
  background: linear-gradient(180deg, #152523 0%, #1a2b28 40%);
  border-color: #2a403d;
}
html[data-theme="dark"] .visit-slot-empty {
  background: rgba(0, 0, 0, 0.15);
  border-color: #2a403d;
  color: var(--muted);
}
html[data-theme="dark"] .visit-slot.is-over {
  background: #1e3330;
}
html[data-theme="dark"] .visit-month-cell {
  background: #1a2b28;
  border-color: #2a403d;
}
html[data-theme="dark"] .visit-chip {
  background: #243532;
  border-color: #2a403d;
  color: var(--ink);
}
html[data-theme="dark"] .visit-view-tabs {
  background: #1a2b28;
  border-color: #2a403d;
}

@media (max-width: 900px) {
  .visit-month-weekdays,
  .visit-month-grid { grid-template-columns: repeat(7, minmax(72px, 1fr)); }
  .visit-month { overflow-x: auto; }
  .visit-month-weekdays,
  .visit-month-grid { min-width: 560px; }
}

.tx-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.tx-action { position: relative; }
.tx-act-view { color: #0d8a7a; font-weight: 800; }
.tx-act-dl { color: #1d6fd8; font-weight: 800; }
.menu-link.is-off { color: var(--muted); cursor: default; opacity: .7; }
.badge {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 11px;
  font-weight: 700;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(12, 46, 44, .42);
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal.show,
.modal.fade.show { display: flex; }

.modal-dialog,
.modal-dialog-centered,
.mw-650px,
.modal-xl,
.custom-modal {
  width: min(720px, 100%);
  max-height: 90vh;
}

.modal-xl, .custom-modal, .custom-modal-width, .procedure-modal { width: min(980px, 100%); }

.modal-content {
  background: #fff;
  border-radius: 18px;
  overflow: auto;
  max-height: 90vh;
  box-shadow: 0 20px 50px rgba(0,0,0,.18);
}

.modal-header, .modal-footer {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.modal-header { border-bottom: 1px solid var(--line); }
.modal-footer { border-top: 1px solid var(--line); justify-content: flex-start; }
.modal-body { padding: 18px 20px; }
.modal-title, .modal-header h2 { margin: 0; font-size: 16px; }

.menu-sub,
.menu-sub-dropdown {
  display: none;
  position: absolute;
  left: 0;
  top: 110%;
  min-width: 140px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 30;
  padding: 6px;
}

.menu-sub.show { display: block; }
.menu-sub.menu-sub-floating {
  position: fixed;
  z-index: 100;
}
.menu-item, .menu-link { display: block; }
.menu-link {
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 13px;
}
.menu-link:hover { background: var(--accent-soft); color: var(--accent-2); }
td { position: relative; }

.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.justify-content-end { justify-content: flex-end; }
.gap-2 { gap: 8px; }
.gap-6, .gap-lg-8 { gap: 16px; }
.h-100 { height: 100%; }
.w-100 { width: 100%; }
.text-center { text-align: center; }
.text-muted, .text-gray-500, .text-gray-600 { color: var(--muted); }
.fw-bold { font-weight: 700; }
.text-danger { color: var(--danger); }
.text-primary { color: var(--accent-2); }
.d-none { display: none !important; }
.container, .container-xxl, .app-container { width: 100%; max-width: 1280px; margin-inline: auto; }
.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.col-12, .col-md-6, .col-lg-4, .col-sm-12 { padding: 0 8px; }
.col-12, .col-sm-12 { width: 100%; }
.col-md-6 { width: 50%; }
.col-lg-4 { width: 33.333%; }
.mt-3 { margin-top: 12px; }
.mt-4, .mt-5, .mt-9, .mt-12, .mt-custom { margin-top: 16px; }
.mb-4, .mb-5 { margin-bottom: 16px; }
.pt-0 { padding-top: 0; }
.py-3 { padding-block: 12px; }
.px-4 { padding-inline: 16px; }
.list-unstyled { list-style: none; padding: 0; margin: 0; }
.separator { display: none; }
.indicator-progress { display: none !important; }
.ki-duotone, .ki-outline, .ki-down, .path1, .path2 { display: none; }
.list-group { list-style: none; margin: 0; padding: 0; }
.list-group-item { padding: 8px 0; border-bottom: 1px solid var(--line); }
.captcha, .captcha-box img { height: 46px; border-radius: 8px; }
.captcha-box input { max-width: 160px; }
input[type="file"] { padding: 8px; }
.soha-timepicker {
  position: fixed;
  z-index: 120;
  width: 220px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0,0,0,.16);
  padding: 14px;
}
.soha-timepicker[hidden] { display: none !important; }
.soha-tp-title {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.soha-tp-row {
  display: grid;
  grid-template-columns: 1fr 16px 1fr;
  align-items: center;
  justify-items: center;
  gap: 6px;
}
.soha-tp-values {
  margin: 6px 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 1px;
}
.soha-tp-spin {
  width: 42px;
  height: 32px;
  border: 1px solid var(--line);
  background: #f7fbfa;
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink);
}
.soha-tp-spin:hover { border-color: var(--accent); background: var(--accent-soft); }
.soha-tp-ok { width: 100%; margin-top: 12px; }
.file-uploaded { border-color: var(--ok) !important; background: var(--ok-soft); }
.page-heading { font-size: 16px; margin: 0 0 16px; }
.app-main .app-main { padding: 0; }
.card.container { max-width: none; padding: 0; }
.app-main > form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  max-width: 560px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.stat b { display: block; font-size: 22px; margin-top: 4px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.stat-ok b { color: var(--ok); }

.dash-sec { margin-bottom: 28px; }
.dash-sec > h2 {
  margin: 0 0 14px;
  font-size: 18px;
  color: var(--ink);
  padding-right: 10px;
  border-right: 3px solid var(--accent);
}
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.dash-grid-3 { grid-template-columns: repeat(3, 1fr); }
.dash-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.dash-hero h1 { margin: 0 0 4px; font-size: 28px; }
.dash-hero p { margin: 0; color: var(--muted); }
.dash-filter {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
}
.dash-filter input { min-width: 150px; margin: 0; }
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 18px 16px;
  border-top: 5px solid var(--accent);
}
.kpi-a { border-top-color: #0d8a7a; }
.kpi-b { border-top-color: #c23b3b; }
.kpi-c { border-top-color: #1f8a4c; }
.kpi-d { border-top-color: #1d6fd8; }
.kpi span { display: block; color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi b {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.kpi small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.kpi-rate { margin-top: 8px; }
.kpi-meter {
  height: 8px;
  background: #e7efed;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 8px;
}
.kpi-meter i { display: block; height: 100%; background: #1d6fd8; }
.dash-mini {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}
.dash-mini div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: center;
}
.dash-mini span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.dash-mini b { font-size: 18px; }
.dash-highlights {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.dash-highlights article {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  border-right: 4px solid var(--accent);
}
.dash-highlights span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.dash-highlights b {
  display: block;
  margin-top: 8px;
  font-size: 22px;
  line-height: 1.3;
}
.dash-highlights small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.chart-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 16px 12px;
  min-width: 0;
  box-shadow: 0 8px 24px rgba(12, 46, 44, 0.04);
}
.chart-wide { grid-column: 1 / -1; }
.chart-card header {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
}
.chart-card header em {
  flex: 0 0 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-2);
  border-radius: 8px;
  font-style: normal;
  font-weight: 800;
  font-size: 12px;
}
.chart-card header h3 {
  margin: 0;
  font-size: 15px;
  color: var(--ink);
}
.chart-card header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }
.dash-table-card { overflow: hidden; }
.dash-table th { white-space: nowrap; }
.dash-table td { font-variant-numeric: tabular-nums; }
.num-ok { color: #176b40; font-weight: 700; }
.num-warn { color: #c23b3b; font-weight: 700; }
@media (max-width: 1100px) {
  .dash-kpis, .dash-highlights { grid-template-columns: 1fr 1fr; }
  .dash-mini { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .chart-grid, .dash-grid-3, .dash-grid { grid-template-columns: 1fr; }
  .chart-wide { grid-column: auto; }
  .dash-mini { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .dash-highlights { grid-template-columns: 1fr; }
}

.toast-wrap {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  left: 16px;
  z-index: 120;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.soha-toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 12px 12px 14px;
  box-shadow: 0 12px 32px rgba(12, 46, 44, 0.14);
  opacity: 0;
  transform: translateY(-10px) scale(0.98);
  transition: opacity .28s ease, transform .28s ease;
}
.soha-toast.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.soha-toast.is-leaving {
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
}
.soha-toast-icon {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}
.soha-toast-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  padding-top: 2px;
}
.soha-toast-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.soha-toast-close:hover { color: var(--ink); }
.toast-success { border-right: 4px solid var(--ok); }
.toast-success .soha-toast-icon { background: var(--ok-soft); color: var(--ok); }
.toast-error { border-right: 4px solid var(--danger); }
.toast-error .soha-toast-icon { background: var(--danger-soft); color: var(--danger); }
.toast-warning { border-right: 4px solid var(--warn); }
.toast-warning .soha-toast-icon { background: #fff4df; color: var(--warn); }
.toast-info { border-right: 4px solid var(--accent); }
.toast-info .soha-toast-icon { background: var(--accent-soft); color: var(--accent-2); }

.toast-undo {
  align-items: stretch;
}

.soha-undo-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.soha-undo-message {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--ink);
}

.soha-undo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  align-self: flex-start;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent-2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.soha-undo-btn:hover {
  background: var(--accent);
  color: #fff;
}

.soha-undo-btn:hover .soha-undo-countdown {
  background: #fff;
  color: var(--accent-2);
}

.soha-undo-label {
  white-space: nowrap;
}

.soha-undo-countdown {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-2);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.soha-undo-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.soha-undo-progress-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--ok), var(--accent));
  border-radius: inherit;
  transition: width 1s linear;
}

#sohaDeleteModal .modal-body {
  color: var(--muted);
  line-height: 1.7;
}

.soha-call-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 700;
}
.soha-call-link:hover { background: var(--accent); color: #fff; }

.audit-card .card-header h5 { margin: 0; font-size: 15px; }
.audit-list { display: grid; gap: 12px; }
.audit-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2, var(--surface));
}
.audit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.audit-user { font-weight: 600; color: var(--accent-2); }
.audit-changes {
  margin: 6px 0 0;
  padding: 0 16px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.audit-changes li { margin: 2px 0; }
.audit-changes span { color: var(--ink); font-weight: 600; }

.dash-compare {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.dash-compare .kpi small.cmp-up { color: var(--ok); }
.dash-compare .kpi small.cmp-down { color: var(--danger); }
@media (max-width: 700px) {
  .dash-compare { grid-template-columns: 1fr; }
}

.dash-income-sec {
  margin: 8px 0 20px;
}
.dash-income-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 14px;
}
.dash-income-head h2 { margin: 0 0 4px; font-size: 18px; }
.dash-income-head p { margin: 0; color: var(--muted); font-size: 13px; }
.dash-income-totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 8px;
}
.dash-income-totals > div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  border-right: 3px solid var(--accent);
}
.dash-income-totals span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}
.dash-income-totals b {
  display: block;
  margin-top: 4px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.dash-income-chart { margin: 0; }
.income-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}
.income-bar i {
  display: block;
  height: 8px;
  min-width: 0;
  flex: 1;
  max-width: 120px;
  border-radius: 999px;
  background: linear-gradient(90deg, #0d8a7a, #14b8a6);
}
.income-bar span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  min-width: 36px;
}
.dash-table .cmp-up { color: var(--ok); font-weight: 700; }
.dash-table .cmp-down { color: var(--danger); font-weight: 700; }
.dash-table tr.is-muted td { opacity: .45; }
.dash-split {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr);
  gap: 14px;
  align-items: start;
}
.dash-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.doc-share {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.dash-income-totals small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
@media (max-width: 900px) {
  .dash-income-totals { grid-template-columns: 1fr 1fr; }
  .dash-split { grid-template-columns: 1fr; }
}

.visit-status-select {
  display: block;
  width: 100%;
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.2;
  padding: 2px 4px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.visit-card-dnd.status-attended { border-right: 3px solid var(--ok); }
.visit-card-dnd.status-cancelled { border-right: 3px solid #94a3b8; opacity: .75; }
.visit-card-dnd.status-no_show { border-right: 3px solid var(--danger); }
.visit-card-dnd.status-scheduled { border-right: 3px solid var(--accent); }

.theme-toggle {
  display: grid;
  place-items: center;
  border: 0;
  background: var(--accent-soft);
  color: var(--accent-2);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  flex: 0 0 auto;
}
.theme-toggle:hover { filter: brightness(.97); }

.custom-alert {
  background: #fff;
  border: 1px solid var(--line);
  border-right: 4px solid var(--accent);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}

.alert-error, .alert-danger { border-right-color: var(--danger); }
.alert-success { border-right-color: var(--ok); }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(13,138,122,.18), transparent 28%),
    radial-gradient(circle at 80% 80%, rgba(12,46,44,.16), transparent 30%),
    var(--bg);
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 22px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.login-card h1 { margin: 0 0 6px; font-size: 24px; }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.captcha-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 16px;
}

.menu-btn {
  display: grid;
  place-items: center;
  border: 0;
  background: var(--accent-soft);
  color: var(--accent-2);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 20px;
  cursor: pointer;
  flex: 0 0 auto;
}

.empty {
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 992px) {
  .app,
  html.sidebar-closed .app { grid-template-columns: 1fr; }
  html.sidebar-closed .app-sidebar {
    width: min(280px, 86vw);
    opacity: 1;
    pointer-events: auto;
    padding: 22px 16px;
    overflow: auto;
  }
  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(110%);
    transition: transform .22s ease;
    z-index: 40;
    width: min(280px, 86vw);
    right: 0;
    left: auto;
  }
  .app-sidebar.open { transform: translateX(0); }
  .col-md-6, .col-lg-4 { width: 100%; }
  .grid-2 { grid-template-columns: 1fr; }
  .app-main { padding: 16px; }
}

body.sidebar-open::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.28);
  z-index: 30;
}

.flex-xl-row { flex-direction: column; }
@media (min-width: 1200px) {
  .flex-xl-row { flex-direction: row; }
}

.treatment-modal { width: min(980px, 100%); }
.tp-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}
.tp-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.tp-card {
  background: #f7fbfa;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.tp-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--accent-2);
}
.tp-chart {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  position: relative;
}
.tp-chart::before,
.tp-chart::after {
  content: "";
  position: absolute;
  background: #c9ddd8;
  z-index: 0;
  pointer-events: none;
}
.tp-chart::before {
  width: 1px;
  height: 72%;
  top: 14%;
  right: 50%;
}
.tp-chart::after {
  height: 1px;
  width: 72%;
  top: 50%;
  right: 14%;
}
.tp-chart label,
.tp-quad {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
}
.tp-quad > span { font-weight: 600; }
.tp-teeth {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.tp-tooth-all { grid-column: 1 / -1; font-size: 11px; }
.tp-tooth {
  border: 1px solid var(--line);
  background: #eef4f2;
  border-radius: 8px;
  height: 28px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  color: var(--ink);
}
.tp-tooth.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.tp-chart input {
  margin: 0;
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  padding: 8px 6px;
  background: #fff;
}
.tp-flags {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tp-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}
.tp-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.tp-check:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
}
@media (max-width: 900px) {
  .tp-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .tp-grid { grid-template-columns: 1fr; }
}

.modal-dialog.patient-modal {
  width: min(760px, 100%);
  max-width: 760px;
}
.patient-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.patient-form-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.patient-form-body {
  display: grid;
  gap: 18px;
}
.patient-form-section {
  background: #f7fbfa;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}
.patient-form-section h3 {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--accent-2);
}
.patient-field {
  display: grid;
  gap: 6px;
}
.patient-field label {
  font-size: 13px;
  color: var(--muted);
}
.patient-field-wide {
  grid-column: 1 / -1;
}
.patient-form textarea {
  resize: vertical;
  min-height: 72px;
}
.patient-modal .modal-footer {
  justify-content: flex-end;
}
.expense-modal {
  width: min(560px, 100%);
  max-width: 560px;
}
.expense-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.expense-form-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.expense-form-body {
  display: grid;
  gap: 14px;
}
.expense-field {
  display: grid;
  gap: 6px;
}
.expense-field label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.expense-field label small {
  font-weight: 500;
  opacity: .85;
}
.expense-modal .modal-footer {
  justify-content: flex-end;
}
@media (max-width: 640px) {
  .expense-form-body .grid-2 { grid-template-columns: 1fr; }
}

.modal-dialog.procedure-modal {
  width: min(860px, 100%);
  max-width: 860px;
  max-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
}
.procedure-modal .modal-content,
.procedure-modal #dynamicForm {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 36px);
  width: 100%;
}
.procedure-modal .modal-content {
  overflow: hidden;
  border: 0;
  box-shadow: 0 24px 64px rgba(13, 138, 122, 0.2);
}
.procedure-modal .tx-modal-header,
.procedure-modal .modal-header {
  flex: 0 0 auto;
  background: linear-gradient(135deg, #0a7568 0%, #0d8a7a 42%, #14b8a6 100%);
  border-bottom: 0;
  color: #fff;
  padding: 18px 20px;
}
.procedure-modal .modal-header h2 {
  margin: 0;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}
.procedure-modal .modal-header .tp-sub {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
}
.procedure-modal .modal-header .btn-light {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
}
.procedure-modal .modal-header .btn-light:hover {
  background: rgba(255, 255, 255, 0.26);
  color: #fff;
}
.procedure-modal .modal-footer {
  flex: 0 0 auto;
  justify-content: flex-end;
  background: linear-gradient(180deg, #eef9f6 0%, #fff 100%);
  border-top: 1px solid #c5e5de;
}
.procedure-modal .modal-footer .btn-primary {
  background: linear-gradient(135deg, #0d8a7a 0%, #14b8a6 100%);
  border: 0;
  box-shadow: 0 4px 16px rgba(13, 138, 122, 0.35);
  font-weight: 700;
}
.procedure-modal .modal-footer .btn-primary:hover {
  filter: brightness(1.05);
  box-shadow: 0 6px 20px rgba(13, 138, 122, 0.42);
}
.procedure-modal .tx-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: linear-gradient(180deg, #ecf8f5 0%, #f6fbfb 35%, #fff 100%);
}
.tx-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.tx-item-head,
.tx-main { grid-column: 1 / -1; }
.row.tx-item,
.tx-item {
  display: grid;
  grid-template-columns: 1.35fr .65fr;
  align-items: start;
  gap: 10px;
  width: 100%;
  margin: 0 0 14px;
  background: linear-gradient(145deg, #ffffff 0%, #f3fbf9 100%);
  border: 1px solid #c5e5de;
  border-right: 4px solid var(--accent);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 4px 18px rgba(13, 138, 122, 0.08);
}
.tx-item > * { width: 100%; min-width: 0; }
.tx-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
}
.tx-item-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: #0b5f56;
}
.tx-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tx-item-remove {
  border: 0;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 8px;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.tx-item-remove:hover { filter: brightness(.97); }
.tx-item-tag {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #0d8a7a, #14b8a6);
  border-radius: 999px;
  padding: 3px 10px;
  box-shadow: 0 2px 8px rgba(13, 138, 122, 0.25);
}
.tx-main {
  display: grid;
  grid-template-columns: 1.4fr .9fr;
  gap: 10px;
}
.tx-field-wide { grid-column: 1 / -1; }
.tx-field label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #3d5c56;
}
.procedure-modal .tx-field input,
.procedure-modal .tx-field select {
  border-color: #b8ddd5;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.procedure-modal .tx-field input:focus,
.procedure-modal .tx-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 138, 122, 0.14);
  outline: 0;
}
.tx-field label small {
  font-weight: 500;
  color: #8aa09b;
}
.tx-money {
  position: relative;
}
.tx-money input { font-variant-numeric: tabular-nums; }
.tx-money:has(.tx-suffix) input { padding-left: 36px; }
.tx-suffix {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
}
.tx-chart-wrap {
  background: linear-gradient(145deg, #fff 0%, #eef9f6 100%);
  border: 1px solid #b8ddd5;
  border-radius: 12px;
  padding: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.tx-chart-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.tx-chart-title h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  color: #0b5f56;
}
.tx-chart-title span {
  font-size: 10px;
  color: var(--muted);
}
.tx-chart {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  position: relative;
}
.tx-chart::before,
.tx-chart::after {
  content: "";
  position: absolute;
  background: linear-gradient(180deg, #7ecfc0, #b8e8df);
  z-index: 0;
  pointer-events: none;
}
.tx-chart::before {
  width: 1px;
  height: 70%;
  top: 15%;
  right: 50%;
}
.tx-chart::after {
  height: 1px;
  width: 70%;
  top: 50%;
  right: 15%;
}
.tx-quad {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #c5e5de;
  border-radius: 8px;
  padding: 5px 6px;
}
.tx-quad > span {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
}
.tx-teeth {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}
.tx-tooth {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 5px;
  height: 22px;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  color: var(--ink);
  padding: 0;
}
.tx-tooth.is-on {
  background: linear-gradient(135deg, #0d8a7a, #14b8a6);
  border-color: #0d8a7a;
  color: #fff;
  box-shadow: 0 2px 10px rgba(13, 138, 122, 0.35);
  transform: scale(1.04);
}
.tx-files {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
}
.tx-upload {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-height: 0;
  padding: 8px 10px;
  border: 1px dashed #9fd4c8;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  overflow: hidden;
  flex: 1;
  transition: border-color .15s, background .15s, transform .15s, box-shadow .15s;
}
.tx-upload--before {
  border-color: #f5c56b;
  background: linear-gradient(135deg, #fffbf3 0%, #fff7e6 100%);
}
.tx-upload--before:hover,
.tx-upload--before.has-file {
  border-color: #f59e0b;
  background: linear-gradient(135deg, #fff7e6 0%, #ffedd5 100%);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
}
.tx-upload--before strong { color: #b45309; }
.tx-upload--after {
  border-color: #6ee7b7;
  background: linear-gradient(135deg, #f0fdf9 0%, #ecfdf5 100%);
}
.tx-upload--after:hover,
.tx-upload--after.has-file {
  border-color: #10b981;
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}
.tx-upload--after strong { color: #047857; }
.tx-upload:not(.tx-upload--before):not(.tx-upload--after):hover,
.tx-upload:not(.tx-upload--before):not(.tx-upload--after).has-file {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.tx-upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: 0;
  font-size: 0;
  z-index: 2;
}
.tx-upload input[type="file"]::-webkit-file-upload-button,
.tx-upload input[type="file"]::file-selector-button {
  display: none;
}
.tx-upload strong {
  font-size: 12px;
  color: var(--accent-2);
  white-space: nowrap;
}
.tx-file-name {
  font-size: 11px;
  font-style: normal;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tx-add {
  width: 100%;
  margin: 0;
  padding: 12px;
  border: 2px dashed #5ecfb8;
  border-radius: 12px;
  background: linear-gradient(135deg, #fff 0%, #e7f6f3 100%);
  color: #0b5f56;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s, box-shadow .15s;
}
.tx-add:hover {
  background: linear-gradient(135deg, #e7f6f3 0%, #d0f0ea 100%);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(13, 138, 122, 0.14);
}
.tx-add.is-nudge {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(13, 138, 122, .18);
}
.tx-add-hint {
  margin: 6px 0 16px;
  font-size: 12px;
  color: var(--accent-2);
  font-weight: 600;
}
.tx-add-hint[hidden] { display: none; }
.tx-settle {
  background: linear-gradient(135deg, #faf5ff 0%, #f0faf8 45%, #fff9f0 100%);
  border: 1px solid #c5e5de;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 4px 20px rgba(13, 138, 122, 0.06);
}
.tx-settle h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 800;
  color: #0b5f56;
}
.tx-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.tx-stat {
  background: #fff;
  border: 1px solid #d4ebe5;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 2px 10px rgba(13, 138, 122, 0.06);
}
.tx-stat--cost {
  border-right: 4px solid #0d8a7a;
  background: linear-gradient(135deg, #fff 0%, #f0faf8 100%);
}
.tx-stat--cost b { color: #0b5f56; }
.tx-stat--insurance {
  border-right: 4px solid #3b82f6;
  background: linear-gradient(135deg, #fff 0%, #eff6ff 100%);
}
.tx-stat--insurance b { color: #1d4ed8; }
.tx-stat-patient {
  border-right: 4px solid #10b981;
  background: linear-gradient(135deg, #fff 0%, #ecfdf5 100%);
}
.tx-stat-patient b { color: #047857; }
.tx-stat > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.tx-stat b {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--ink);
}
.tx-stat b span {
  font-size: 22px;
  font-weight: 800;
  color: inherit;
}
.tx-stat b small {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.tx-pay {
  display: grid;
  grid-template-columns: .7fr 1fr 1fr 1fr;
  gap: 10px;
}
.btn-info { background: #e7f1ee; color: var(--accent-2); }
@media (max-width: 800px) {
  .row.tx-item, .tx-item { grid-template-columns: 1fr; }
  .tx-files { flex-direction: row; }
  .tx-main, .tx-stats, .tx-pay { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .tx-main, .tx-chart, .tx-stats, .tx-pay { grid-template-columns: 1fr; }
  .tx-files { flex-direction: column; }
  .tx-chart::before, .tx-chart::after { display: none; }
}

/* ── Mobile-first responsive (primary use: phones) ── */
@media (max-width: 768px) {
  body { font-size: 14px; }
  .app-main { padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .app-header {
    padding: 0 12px;
    gap: 8px;
    min-height: var(--header-h);
  }
  .header-search { max-width: none; min-width: 0; flex: 1; }
  .header-user .user-meta { display: none; }
  .menu-btn, .avatar { width: 42px; height: 42px; }

  input, select, textarea,
  .form-control, .form-control-solid, .form-select {
    font-size: 16px;
    min-height: 44px;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
  }
  .page-head h1 { font-size: 20px; }
  .page-head .btn,
  .page-head > .toolbar,
  .page-head > form,
  .page-head .list-filters {
    width: 100%;
  }
  .list-filters {
    flex-direction: column;
    align-items: stretch;
  }
  .list-filters label { width: 100%; }
  .list-filters select {
    width: 100%;
    min-width: 0;
  }

  .btn, button.btn, a.btn {
    min-height: 44px;
    padding: 10px 14px;
  }
  .btn-sm { min-height: 38px; padding: 8px 12px; }

  .card-header, .card-body, .card-toolbar { padding: 12px 14px; }
  .container, .container-xxl, .app-container { padding-left: 0; padding-right: 0; }

  .app-toolbar { padding: 0 0 12px; margin-bottom: 8px; }
  .app-toolbar .d-flex.align-items-center,
  .app-toolbar .d-flex {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }
  .app-toolbar .btn { width: 100%; justify-content: center; text-align: center; }

  .dash-hero {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .dash-filter {
    flex-direction: column;
    width: 100%;
  }
  .dash-filter input,
  .dash-filter button { width: 100%; min-width: 0; }
  .dash-kpis,
  .dash-highlights,
  .dash-mini,
  .dash-grid,
  .dash-grid-3,
  .chart-grid { grid-template-columns: 1fr !important; }
  .kpi b { font-size: 22px; }
  .chart-box { height: 240px; }
  .chart-box.tall { height: 280px; }

  .modal {
    padding: 0;
    align-items: flex-end;
  }
  .modal-dialog,
  .modal-dialog-centered,
  .mw-650px,
  .modal-xl,
  .custom-modal,
  .procedure-modal,
  .patient-modal,
  .expense-modal,
  .treatment-modal {
    width: 100%;
    max-width: 100%;
    max-height: 94vh;
    margin: 0;
  }
  .modal-content {
    border-radius: 18px 18px 0 0;
    max-height: 94vh;
  }
  .modal-header, .modal-footer, .modal-body { padding: 14px 16px; }

  .table-responsive.is-mobile-cards,
  .dash-table-card .table-responsive.is-mobile-cards {
    overflow: visible;
  }
  .table-mobile-cards thead { display: none; }
  .table-mobile-cards tbody tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 12px;
    background: #fff;
    box-shadow: var(--shadow);
  }
  .table-mobile-cards tbody tr:hover { background: #fff; }
  .table-mobile-cards tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border: 0;
    border-bottom: 1px solid #eef3f1;
    text-align: left;
  }
  .table-mobile-cards tbody td:last-child { border-bottom: 0; }
  .table-mobile-cards tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    font-size: 12px;
    flex: 0 0 38%;
    text-align: right;
  }
  .table-mobile-cards tbody td[data-label=""]::before,
  .table-mobile-cards tbody td:not([data-label])::before { display: none; }
  .table-mobile-cards tbody td:has(.tx-actions),
  .table-mobile-cards tbody td:has(.menu-sub),
  .table-mobile-cards tbody td:has(form),
  .table-mobile-cards tbody td:has(.btn) {
    flex-direction: column;
    align-items: stretch;
  }
  .table-mobile-cards .tx-actions {
    flex-wrap: wrap;
    width: 100%;
  }
  .table-mobile-cards .tx-action,
  .table-mobile-cards .btn { width: 100%; }

  .visit-grid { grid-template-columns: 1fr; }
  .container.mt-4, .container.mb-4 { margin-top: 0 !important; margin-bottom: 0 !important; }
  .flex-xl-row { gap: 12px !important; }
}

@media (max-width: 480px) {
  .app-toolbar .d-flex.align-items-center,
  .app-toolbar .d-flex { grid-template-columns: 1fr; }
  .nav-link { padding: 11px 12px; font-size: 14px; }
  .dash-highlights b { font-size: 18px; }
}

@media (min-width: 993px) {
  body.sidebar-open::after { display: none; }
}

/* ── Dark mode ── */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1514;
  --surface: #172422;
  --ink: #e8f4f2;
  --muted: #8aa8a3;
  --line: #2a3f3c;
  --accent-soft: #163632;
  --danger-soft: #3a2020;
  --ok-soft: #163528;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
html[data-theme="dark"] body { background: var(--bg); color: var(--ink); }
html[data-theme="dark"] .app-header {
  background: rgba(23, 36, 34, 0.92);
  border-bottom-color: var(--line);
}
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-control-solid,
html[data-theme="dark"] .form-select {
  background: #101918;
  border-color: var(--line);
  color: var(--ink);
}
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] .form-control:focus {
  background: #121f1d;
  border-color: var(--accent);
}
html[data-theme="dark"] .card,
html[data-theme="dark"] .card-flush,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .kpi,
html[data-theme="dark"] .chart-card,
html[data-theme="dark"] .dash-filter,
html[data-theme="dark"] .patient-form-section,
html[data-theme="dark"] .expense-form-body,
html[data-theme="dark"] .visit-card,
html[data-theme="dark"] .stat,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .soha-toast,
html[data-theme="dark"] .menu-sub,
html[data-theme="dark"] .soha-timepicker {
  background: var(--surface);
  border-color: var(--line);
}
html[data-theme="dark"] .table thead th,
html[data-theme="dark"] .dash-table thead th {
  background: #101918;
  color: var(--muted);
}
html[data-theme="dark"] .table tbody tr:hover,
html[data-theme="dark"] .dash-table tbody tr:hover {
  background: #1a2b28;
}
html[data-theme="dark"] .table-mobile-cards tbody tr,
html[data-theme="dark"] .tx-item,
html[data-theme="dark"] .tp-card,
html[data-theme="dark"] .dash-highlights article,
html[data-theme="dark"] .dash-mini > div {
  background: #1a2b28;
  border-color: var(--line);
}
html[data-theme="dark"] .procedure-modal .modal-header {
  background: linear-gradient(135deg, #0a4f48 0%, #0d6b60 50%, #0f8578 100%);
}
html[data-theme="dark"] .procedure-modal .tx-body {
  background: linear-gradient(180deg, #152523 0%, #1a2b28 100%);
}
html[data-theme="dark"] .procedure-modal .modal-footer {
  background: linear-gradient(180deg, #1a2b28, #152523);
  border-top-color: var(--line);
}
html[data-theme="dark"] .tx-item {
  background: linear-gradient(145deg, #1a2b28 0%, #1e3330 100%);
  border-color: #2a403d;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2);
}
html[data-theme="dark"] .tx-chart-wrap,
html[data-theme="dark"] .tx-quad {
  background: #243532;
  border-color: #2a403d;
}
html[data-theme="dark"] .tx-stat {
  background: #243532;
  border-color: #2a403d;
}
html[data-theme="dark"] .tx-stat--cost { background: linear-gradient(135deg, #243532, #1e3330); }
html[data-theme="dark"] .tx-stat--insurance { background: linear-gradient(135deg, #243532, #1a2740); }
html[data-theme="dark"] .tx-stat-patient { background: linear-gradient(135deg, #243532, #1a3328); }
html[data-theme="dark"] .tx-settle {
  background: linear-gradient(135deg, #1e2830 0%, #1a2b28 50%, #1f2a24 100%);
  border-color: #2a403d;
}
html[data-theme="dark"] .tx-upload--before {
  background: linear-gradient(135deg, #2a2418 0%, #332a1a 100%);
  border-color: #8a6520;
}
html[data-theme="dark"] .tx-upload--after {
  background: linear-gradient(135deg, #1a2e28 0%, #1a3328 100%);
  border-color: #2a6b52;
}
html[data-theme="dark"] .tx-add {
  background: linear-gradient(135deg, #243532, #1a2b28);
  border-color: #3a6b60;
  color: #8fd6c8;
}
html[data-theme="dark"] .btn-light,
html[data-theme="dark"] .btn-light-primary,
html[data-theme="dark"] .btn-sm.btn-light {
  background: #243532;
  color: var(--ink);
}
html[data-theme="dark"] .btn-secondary { background: #243532; color: var(--ink); }
html[data-theme="dark"] .btn-success { background: #1d3b2f; color: #8fd6ad; }
html[data-theme="dark"] .app-toolbar .btn {
  background: #1a2b28;
  border-color: var(--line);
  color: var(--ink);
}
html[data-theme="dark"] .menu-link:hover { background: #243532; color: #fff; }
html[data-theme="dark"] .login-page {
  background:
    radial-gradient(circle at 20% 20%, rgba(13,138,122,.12), transparent 28%),
    radial-gradient(circle at 80% 80%, rgba(0,0,0,.25), transparent 30%),
    var(--bg);
}
html[data-theme="dark"] .toast-warning .soha-toast-icon { background: #3a2f18; }

.pwa-install {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-right: 4px solid var(--accent);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}
.pwa-install[hidden] { display: none !important; }
.pwa-install strong { display: block; font-size: 14px; }
.pwa-install p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.pwa-install-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
@media (min-width: 769px) {
  .pwa-install {
    left: auto;
    right: 16px;
    width: min(420px, calc(100vw - 32px));
  }
}
.login-theme-toggle {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  left: 16px;
  z-index: 20;
}
.login-page .toast-wrap {
  position: fixed;
  top: calc(68px + env(safe-area-inset-top));
  left: 16px;
  width: min(360px, calc(100vw - 32px));
}
