/* Trust Dental — design tokens & components (05_DESIGN_SYSTEM/DESIGN_SYSTEM.md) */
:root {
  --bg: #F5F7FB; --surface: #FFFFFF; --surface-2: #F0F3F9; --border: #E1E6EF; --border-strong: #CBD3E1;
  --text: #101A2C; --text-2: #4A5570; --text-3: #8790A6;
  --nav: #0C1524; --nav-text: #C9D3E6; --nav-active: #1B2B4A;
  --accent: #2457DC; --accent-soft: #E8EEFC; --accent-text: #FFFFFF;
  --success: #0F8A56; --success-soft: #E3F4EC; --warning: #B26A12; --warning-soft: #FBF0E1;
  --danger: #C93535; --danger-soft: #FBE7E7; --info: #0A77AA; --info-soft: #E2F1F8; --neutral: #5C6680; --neutral-soft: #ECEFF5;
  --shadow: 0 1px 2px rgba(16,26,44,.06), 0 4px 16px rgba(16,26,44,.06);
  --shadow-lg: 0 12px 40px rgba(16,26,44,.18);
  --r1: 6px; --r2: 8px; --r3: 12px;
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
  --t: 180ms cubic-bezier(.2,.7,.2,1);
  --rail: 252px; --top: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0A101B; --surface: #111927; --surface-2: #172133; --border: #243049; --border-strong: #31405F;
  --text: #E6EBF4; --text-2: #AAB4C8; --text-3: #75809A; --nav: #070B13; --nav-text: #B7C2D8; --nav-active: #18233A;
  --accent: #5A86FF; --accent-soft: #1B2A4F; --accent-text: #0A101B;
  --success: #34C38A; --success-soft: #11291F; --warning: #E5A54B; --warning-soft: #2B2112; --danger: #F07272; --danger-soft: #301616;
  --info: #4DB3E3; --info-soft: #102633; --neutral: #9AA4BC; --neutral-soft: #1C2538; --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 40px rgba(0,0,0,.5); color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0A101B; --surface: #111927; --surface-2: #172133; --border: #243049; --border-strong: #31405F;
  --text: #E6EBF4; --text-2: #AAB4C8; --text-3: #75809A; --nav: #070B13; --nav-text: #B7C2D8; --nav-active: #18233A;
  --accent: #5A86FF; --accent-soft: #1B2A4F; --accent-text: #0A101B;
  --success: #34C38A; --success-soft: #11291F; --warning: #E5A54B; --warning-soft: #2B2112; --danger: #F07272; --danger-soft: #301616;
  --info: #4DB3E3; --info-soft: #102633; --neutral: #9AA4BC; --neutral-soft: #1C2538; --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 40px rgba(0,0,0,.5); color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 13.5px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
html.large-text body { font-size: 15.5px; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--text-2); } .faint { color: var(--text-3); } .small { font-size: 12.5px; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ------------------------------------------------ shell */
.app { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.app.collapsed { --rail: 64px; }
.rail { position: sticky; top: 0; height: 100vh; background: var(--nav); color: var(--nav-text); display: flex; flex-direction: column; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; height: var(--top); color: #fff; font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #2457DC, #0FA3A3); display: grid; place-items: center; flex: none; }
.nav-group { padding: 6px 10px; }
.nav-title { font-size: 11.5px; color: #6F7C96; padding: 10px 8px 4px; white-space: nowrap; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r2); color: var(--nav-text); cursor: pointer; white-space: nowrap; min-height: 38px; }
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: var(--nav-active); color: #fff; box-shadow: inset -3px 0 0 #5A86FF; }
.nav-item .badge { margin-inline-start: auto; }
.app.collapsed .nav-title, .app.collapsed .nav-item span, .app.collapsed .brand span, .app.collapsed .nav-item .badge { display: none; }
.rail-foot { margin-top: auto; padding: 10px; border-top: 1px solid rgba(255,255,255,.06); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--top); display: flex; align-items: center; gap: 10px; padding: 0 16px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.searchbox > span:not(.kbd) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.searchbox { flex: 1; min-width: 0; max-width: 520px; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--r2); background: var(--surface-2); color: var(--text-3); cursor: text; }
.kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--text-2); background: var(--surface); }
#page:focus { outline: none; }
.content { padding: 20px; max-width: 1400px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 22px; margin: 0; line-height: 1.3; }
.page-head .sub { color: var(--text-2); margin-top: 2px; }
.page-head .actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bottombar { display: none; }
.env-banner { background: var(--warning-soft); color: var(--warning); text-align: center; font-size: 12.5px; padding: 3px 8px; }

/* ------------------------------------------------ controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r2); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; font-weight: 500; transition: background var(--t), border-color var(--t); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 36px; padding: 0; }
.btn[disabled], .btn.busy { opacity: .55; pointer-events: none; }
.btn.busy::after { content: ''; width: 12px; height: 12px; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; }
.field label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--text-3); }
.field .err { font-size: 12px; color: var(--danger); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); }
input[type=text], input[type=tel], input[type=email], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=search], select, textarea {
  height: 38px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r2); background: var(--surface); width: 100%; min-width: 0; }
textarea { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.money, input[type=tel] { direction: ltr; text-align: right; font-family: var(--mono); }
.row { display: flex; gap: 12px; flex-wrap: wrap; } .row > * { flex: 1 1 180px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 32px; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r2); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 0 12px; height: 34px; cursor: pointer; color: var(--text-2); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ------------------------------------------------ cards, kpis, chips */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r3); box-shadow: var(--shadow); }
.card.pad { padding: 16px; }
.card h2, .card h3 { margin: 0 0 10px; font-size: 15px; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-head h3 { margin: 0; font-size: 15px; } .card-head .actions { margin-inline-start: auto; display: flex; gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r3); padding: 14px; cursor: pointer; text-align: start; transition: border-color var(--t), transform var(--t); }
.kpi:hover { border-color: var(--accent); }
.kpi .label { color: var(--text-2); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 4px; font-family: var(--mono); font-variant-numeric: tabular-nums; direction: ltr; text-align: right; }
.kpi .meaning { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--neutral-soft); color: var(--neutral); }
.chip svg { width: 12px; height: 12px; }
.chip.info { background: var(--info-soft); color: var(--info); } .chip.success { background: var(--success-soft); color: var(--success); }
.chip.warning { background: var(--warning-soft); color: var(--warning); } .chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.accent { background: var(--accent-soft); color: var(--accent); } .chip.strike { text-decoration: line-through; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11.5px; display: inline-grid; place-items: center; font-family: var(--mono); }
.alert-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.action { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r2); border: 1px solid var(--border); background: var(--surface); cursor: pointer; min-height: 44px; }
.action .n { font: 700 18px var(--mono); }
.action.danger { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); } .action.danger .n { color: var(--danger); }
.action.warning .n { color: var(--warning); } .action.info .n { color: var(--info); }
.notice { padding: 10px 14px; border-radius: var(--r2); background: var(--info-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--info) 25%, transparent); }
.notice.warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.notice.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.notice.success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 30%, transparent); }

/* ------------------------------------------------ tables / lists */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: start; font-weight: 600; font-size: 12.5px; color: var(--text-2); padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: var(--surface-2); }
.tbl th.money { text-align: left; }
.tbl td.money { text-align: left; direction: ltr; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tfoot td { font-weight: 700; background: var(--surface-2); }
.list-cards { display: none; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.toolbar input[type=search] { max-width: 320px; }
.empty { text-align: center; padding: 36px 16px; color: var(--text-2); }
.empty .ic { width: 44px; height: 44px; margin: 0 auto 8px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); }
.empty h4 { margin: 0 0 4px; color: var(--text); font-size: 15px; }
.skel { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; margin: 10px 0; }
@keyframes sk { to { background-position: -200% 0; } }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv dt { color: var(--text-2); } .kv dd { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px dashed var(--border); display: flex; gap: 10px; }

/* ------------------------------------------------ overlays */
.overlay { position: fixed; inset: 0; background: rgba(10,16,27,.42); z-index: 60; display: grid; place-items: center; padding: 16px; animation: fade var(--t); }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: var(--r3); box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal.wide { width: min(860px, 100%); }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-start; flex-direction: row-reverse; }
.drawer-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(10,16,27,.25); animation: fade var(--t); }
.drawer { position: absolute; top: 0; bottom: 0; inset-inline-start: auto; inset-inline-end: 0; left: 0; width: min(520px, 100%); background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide var(--t); }
[dir=rtl] .drawer { left: 0; right: auto; }
@keyframes slide { from { transform: translateX(-24px); opacity: .4; } }
.drawer-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 10px; }
.drawer-head h3 { margin: 0; font-size: 17px; } .drawer-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 18px; left: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast button { pointer-events: auto; }
.toast { background: #101A2C; color: #fff; padding: 10px 14px; border-radius: var(--r2); box-shadow: var(--shadow-lg); display: flex; gap: 12px; align-items: center; max-width: 420px; animation: fade var(--t); }
.toast.danger { background: #8E2020; } .toast.success { background: #0B6B43; }
.toast button { background: none; border: 0; color: #9DB8FF; cursor: pointer; font-weight: 600; }
.menu { position: fixed; z-index: 70; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r2); box-shadow: var(--shadow-lg); padding: 4px; min-width: 180px; }
.menu button { display: flex; width: 100%; gap: 8px; align-items: center; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; text-align: start; }
.menu button:hover { background: var(--surface-2); } .menu button.danger { color: var(--danger); }
.palette { width: min(640px, 100%); align-self: start; margin-top: 10vh; }
.palette input { height: 52px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; font-size: 16px; padding: 0 18px; }
.palette input:focus { box-shadow: none; }
.palette-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.palette-item { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: var(--r2); cursor: pointer; }
.palette-item.on, .palette-item:hover { background: var(--accent-soft); }
.palette-item .type { font-size: 11.5px; color: var(--text-3); margin-inline-start: auto; }
.picker-results { border: 1px solid var(--border); border-radius: var(--r2); margin-top: 4px; max-height: 240px; overflow-y: auto; background: var(--surface); }
.picker-results div { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--border); } .picker-results div:hover, .picker-results div.on { background: var(--accent-soft); }

/* ------------------------------------------------ calendar */
.cal-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.cal-date { font-weight: 700; font-size: 16px; min-width: 190px; text-align: center; }
.cal { display: grid; position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r3); overflow: auto; max-height: calc(100vh - 190px); }
.cal-col-head { position: sticky; top: 0; z-index: 3; background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 8px; text-align: center; font-weight: 600; }
.cal-times { position: sticky; inset-inline-start: 0; z-index: 2; background: var(--surface); border-inline-end: 1px solid var(--border); }
.cal-time { height: 40px; font: 11.5px var(--mono); color: var(--text-3); padding: 0 6px; text-align: center; border-bottom: 1px solid var(--border); }
.cal-col { position: relative; border-inline-end: 1px solid var(--border); }
.cal-slot { height: 26px; border-bottom: 1px dashed color-mix(in srgb, var(--border) 70%, transparent); cursor: copy; }
.cal-slot:nth-child(2n) { border-bottom-style: solid; border-bottom-color: var(--border); }
.cal-slot:hover { background: var(--accent-soft); }
.cal-slot.drop { background: var(--accent-soft); outline: 2px dashed var(--accent); }
.appt { position: absolute; inset-inline: 3px; border-radius: 6px; padding: 3px 7px; font-size: 12px; overflow: hidden; cursor: pointer; background: var(--surface); border: 1px solid var(--border-strong); border-inline-start: 4px solid var(--neutral); box-shadow: var(--shadow); line-height: 1.35; }
.appt:hover { z-index: 5; box-shadow: var(--shadow-lg); }
.appt .t { font: 11px var(--mono); color: var(--text-2); }
.appt .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt.s-confirmed { border-inline-start-color: var(--info); } .appt.s-arrived { border-inline-start-color: var(--warning); background: var(--warning-soft); }
.appt.s-in_chair { border-inline-start-color: var(--accent); background: var(--accent-soft); } .appt.s-completed { border-inline-start-color: var(--success); opacity: .8; }
.appt.s-no_show { border-inline-start-color: var(--danger); opacity: .7; } .appt.late { box-shadow: 0 0 0 2px var(--danger); }
.now-line { position: absolute; inset-inline: 0; height: 2px; background: var(--danger); z-index: 4; pointer-events: none; }
.day-list .appt-card { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.day-list .appt-card .time { font: 600 13px var(--mono); width: 54px; text-align: center; }

/* ------------------------------------------------ patient & visit */
.phead { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 16px; }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 18px; flex: none; }
.phead h2 { margin: 0; font-size: 19px; } .phead .meta { color: var(--text-2); display: flex; gap: 10px; flex-wrap: wrap; font-size: 12.5px; }
.phead .money-box { margin-inline-start: auto; text-align: end; }
.alert-chip { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: 12.5px; display: inline-flex; gap: 6px; align-items: center; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.thumb { border: 1px solid var(--border); border-radius: var(--r2); overflow: hidden; background: var(--surface-2); cursor: pointer; }
.thumb img { width: 100%; height: 100px; object-fit: cover; display: block; background: #000; }
.thumb .cap { padding: 4px 8px; font-size: 11.5px; color: var(--text-2); }
.viewer { max-width: 96vw; max-height: 86vh; object-fit: contain; background: #000; border-radius: 8px; }

/* odontogram — always LTR (patient's right on screen left) */
.odonto { direction: ltr; overflow-x: auto; padding: 8px 0; }
.odonto svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.tooth { cursor: pointer; }
.tooth rect.body { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.2; transition: fill var(--t); }
.tooth:hover rect.body { fill: var(--accent-soft); }
.tooth.sel rect.body { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2.2; }
.tooth.existing rect.body { fill: color-mix(in srgb, var(--info) 30%, var(--surface)); }
.tooth.planned rect.body { stroke: var(--danger); stroke-width: 2; stroke-dasharray: 3 2; }
.tooth.done rect.body { fill: color-mix(in srgb, var(--success) 30%, var(--surface)); stroke: var(--success); }
.tooth text { font: 600 11px var(--mono); fill: var(--text); pointer-events: none; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); justify-content: center; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 4px; vertical-align: -2px; border: 1px solid var(--border-strong); }

/* ------------------------------------------------ responsive */
@media (max-width: 1100px) { .cols { grid-template-columns: 1fr; } }
@media (max-width: 899px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .app.nav-open .rail { display: flex; position: fixed; inset: 0; width: 100%; z-index: 80; height: 100%; }
  .content { padding: 14px 14px 90px; }
  .topbar { padding: 0 12px; }
  .bottombar { display: flex; position: fixed; bottom: 0; inset-inline: 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .bottombar button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11.5px; color: var(--text-2); min-height: 52px; justify-content: center; cursor: pointer; }
  .bottombar button.on { color: var(--accent); font-weight: 600; }
  .bottombar svg { width: 22px; height: 22px; }
  input, select, textarea { font-size: 16px !important; }
  .btn { min-height: 44px; } .btn.sm { min-height: 36px; }
  .tbl-wrap.cardify table { display: none; }
  .tbl-wrap.cardify .list-cards { display: block; }
  .day-list .appt-card { flex-wrap: wrap; }
  .day-list .appt-card > div:nth-child(2) { flex: 1 1 60% !important; }
  .list-card { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; cursor: pointer; }
  .list-card .main-l { flex: 1; min-width: 0; } .list-card .t1 { font-weight: 600; } .list-card .t2 { font-size: 12.5px; color: var(--text-2); }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .drawer { width: 100%; }
  .modal { max-height: 100%; } .overlay { padding: 0; align-items: end; } .modal { border-radius: 14px 14px 0 0; width: 100%; }
  .palette { margin-top: 0; align-self: stretch; border-radius: 0; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .value { font-size: 18px; }
  .searchbox .kbd, .hide-m { display: none; }
  .page-head h1 { font-size: 19px; }
  .toasts { left: 12px; right: 12px; bottom: 76px; }
}
@media print { .rail, .topbar, .bottombar, .no-print { display: none !important; } .app { display: block; } .card { box-shadow: none; } }

/* ------------------------------------------------ care & communication (Sprint 2) */
.bell { position: relative; } .bell .badge { position: absolute; top: 2px; inset-inline-end: 0; min-width: 17px; height: 17px; font-size: 10px; padding: 0 4px; }
.notif-panel { width: min(380px, calc(100vw - 16px)); max-height: 70vh; overflow-y: auto; padding: 0; }
.notif-panel .notif-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.notif-panel > button { border-bottom: 1px solid var(--border); border-radius: 0; flex-wrap: wrap; padding: 10px 12px; }
.notif-panel > button.unread { background: var(--accent-soft); } .notif-panel > button.unread span:first-child { font-weight: 600; }
.row-actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; flex: 1; } .progress > span { display: block; height: 100%; background: var(--success); border-radius: inherit; transition: width var(--t); }
.qbar { display: grid; grid-template-columns: 150px 1fr 40px; gap: 10px; align-items: center; margin: 8px 0; } .qbar b { text-align: end; }
.insight { margin: 4px 0 12px; padding: 8px 12px; border-inline-start: 3px solid var(--accent); background: var(--accent-soft); border-radius: 6px; font-weight: 500; }
.section-title { font-size: 14px; color: var(--text-2); margin: 18px 0 8px; }
.tpl-card { margin-bottom: 10px; } .tpl-head { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; } .tpl-head > div:first-child { flex: 1; min-width: 200px; }
.tpl-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; padding: 12px 16px; } .tpl-grid textarea { width: 100%; }
@media (max-width: 900px) { .tpl-grid { grid-template-columns: 1fr; } .qbar { grid-template-columns: 110px 1fr 34px; } }
.wa-bubble { white-space: pre-wrap; background: #DCF8C6; color: #111B21; border-radius: 10px 0 10px 10px; padding: 8px 12px; font-size: 13.5px; line-height: 1.55; box-shadow: 0 1px 1px rgba(0,0,0,.08); margin-top: 4px; }
:root[data-theme="dark"] .wa-bubble { background: #005C4B; color: #E9EDEF; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wa-bubble { background: #005C4B; color: #E9EDEF; } }
.var-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; } .var-chips .chip { border: 0; cursor: pointer; font-family: var(--mono); direction: ltr; } .var-chips .chip:disabled { cursor: default; }
details.rule { margin-bottom: 8px; } details.rule summary { display: flex; gap: 8px; align-items: center; padding: 12px 16px; cursor: pointer; list-style: none; flex-wrap: wrap; } details.rule summary::-webkit-details-marker { display: none; }
details.rule summary::before { content: '‹'; color: var(--text-3); transition: transform var(--t); } details.rule[open] summary::before { transform: rotate(-90deg); }
.rule-body { padding: 4px 16px 16px; border-top: 1px solid var(--border); display: grid; gap: 10px; } .rule-body textarea { width: 100%; }
.fu-row, .rx-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; } .fu-row input[name=title] { flex: 1 1 160px; } .fu-row input[name=text] { flex: 2 1 220px; }
.rx-row input { flex: 1 1 110px; } .rx-row input[name=drug] { flex: 2 1 180px; }
.rx-list { margin: 0; padding: 10px 16px 12px 16px; padding-inline-start: 34px; } .rx-list li { margin-bottom: 4px; }
.rx-tpls { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; } .suggest-btn { border-color: var(--accent); color: var(--accent); }
.rx-edit-row { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px dashed var(--border); }
.card.suggest { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.consent-text { white-space: pre-wrap; max-height: 260px; overflow-y: auto; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r2); font-size: 13.5px; line-height: 1.75; margin: 6px 0; }
.sigpad { width: 100%; height: 180px; background: #fff; border: 1.5px dashed var(--border-strong); border-radius: var(--r2); touch-action: none; cursor: crosshair; display: block; }
.sig-img { max-width: 320px; background: #fff; border: 1px solid var(--border); border-radius: var(--r2); padding: 4px; }
.field.req > label::after { content: ' *'; color: var(--danger); }
.auto-row { padding: 6px 0; border-bottom: 1px solid var(--border); }

/* ------------------------------------------------ analytics (Sprint 2 WP2) */
.report-bar { border: 1px solid var(--border); border-radius: var(--r3); background: var(--surface); margin-bottom: 12px; }
.compare-note { display: flex; gap: 6px; align-items: center; color: var(--text-2); font-size: 13px; }
.kpis12 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.kpi2 .kpi-foot { display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.delta { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 7px; font-family: var(--mono); direction: ltr; }
.delta.up { background: var(--success-soft); color: var(--success); } .delta.down { background: var(--danger-soft); color: var(--danger); } .delta.flat { color: var(--text-3); font-family: var(--font); font-weight: 500; padding: 0; }
.cols-even { grid-template-columns: 1fr 1fr; } @media (max-width: 1100px) { .cols-even { grid-template-columns: 1fr; } }
.chart-box { width: 100%; } .chart { width: 100%; height: 220px; display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; } .chart .axis { fill: var(--text-3); font: 11px var(--mono); }
.chart .bar.c1 { fill: var(--accent); opacity: .85; } .chart .bar.c2 { fill: var(--success); } .chart .bar:hover { opacity: 1; }
.chart .line { fill: none; stroke-width: 2.4; stroke-linejoin: round; } .chart .line.c2, .chart .dot.c2 { stroke: #0FA3A3; } .chart .dot { fill: var(--surface); stroke-width: 2; }
.legend-row { display: flex; gap: 14px; justify-content: flex-start; font-size: 12.5px; color: var(--text-2); margin-top: 4px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; background: var(--accent); vertical-align: -1px; } .sw.c2 { background: #0FA3A3; }
.chart-tip { position: fixed; z-index: 95; display: none; background: #101A2C; color: #fff; padding: 8px 10px; border-radius: 8px; font-size: 12.5px; pointer-events: none; box-shadow: var(--shadow-lg); direction: rtl; min-width: 140px; } .chart-tip b { font-family: var(--mono); }
.hbars { display: grid; gap: 8px; } .hbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 4px 10px; align-items: center; }
.hbar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; } .hbar-track { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; } .hbar-track span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.hbar-val { font-size: 12.5px; white-space: nowrap; } .hbar-sub { grid-column: 2 / -1; margin-top: -4px; }
.income { display: grid; gap: 2px; max-width: 560px; } .is-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 4px; border-bottom: 1px dashed var(--border); }
.is-row.neg .num { color: var(--danger); } .is-row.sum { font-weight: 600; } .is-row.total { font-weight: 700; font-size: 15px; border-bottom: 2px solid var(--text); } .is-row.muted { color: var(--text-2); } .is-sep { height: 10px; }
.heat { display: grid; gap: 3px; min-width: 560px; } .heat-h, .heat-d { font-size: 11px; color: var(--text-3); text-align: center; align-self: center; } .heat-d { text-align: start; font-size: 12.5px; color: var(--text-2); }
.heat-c { height: 28px; border-radius: 5px; font: 10.5px var(--mono); display: grid; place-items: center; border: 1px solid var(--border); }
details.defs summary { cursor: pointer; }
@media (max-width: 600px) { .hbar { grid-template-columns: 90px 1fr auto; } .chart { height: 180px; } }
@media (max-width: 600px) {
  .kpis12, .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 10px; } .kpi .value { font-size: 18px; } .kpi .meaning { display: none; } .kpi2 .kpi-foot .faint { display: none; }
  .report-bar .seg, .toolbar .seg { overflow-x: auto; max-width: 100%; flex-wrap: nowrap; } .seg button { white-space: nowrap; }
}

/* ------------------------------------------------ English (LTR) */
[dir=ltr] .nav-item.active { box-shadow: inset 3px 0 0 #5A86FF; }
.tbl th.money, .tbl td.money { text-align: end; }
[dir=ltr] .kpi .value { text-align: left; }
[dir=ltr] .drawer { left: auto; right: 0; }
[dir=ltr] .toasts { left: auto; right: 18px; }
[dir=ltr] details.rule summary::before { content: '›'; } [dir=ltr] details.rule[open] summary::before { transform: rotate(90deg); }
[dir=ltr] input.money, [dir=ltr] input[type=tel] { text-align: left; }
[dir=ltr] body { font-family: 'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif; }
[dir=ltr] .chart-tip { direction: ltr; }
@media (max-width: 899px) { [dir=ltr] .toasts { left: 12px; right: 12px; } }

/* ------------------------------------------------ tables v2 (Sprint 2 WP3) */
.tbl th.sortable { cursor: pointer; user-select: none; white-space: nowrap; } .tbl th.sortable:hover { color: var(--text); }
.sort-ic { font-size: 10px; color: var(--text-3); margin-inline-start: 4px; } th[aria-sort] .sort-ic { color: var(--accent); }
.tbl tr.selected td { background: var(--accent-soft); }
.tools-end { margin-inline-start: auto; display: flex; gap: 6px; }
.chips-row { display: flex; gap: 6px; flex-wrap: wrap; }
.fchip { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); border-radius: 999px; height: 30px; padding: 0 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
.fchip .n { font-family: var(--mono); font-size: 11px; background: var(--surface-2); border-radius: 999px; padding: 0 6px; } .fchip.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; } .fchip.on .n { background: var(--surface); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px; flex-wrap: wrap; } .pager:empty { display: none; }
.pager-btns { display: flex; align-items: center; gap: 6px; }
.bulk-bar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: var(--accent-soft); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.cols-menu { padding: 8px 12px; display: grid; gap: 4px; max-height: 60vh; overflow-y: auto; }
.list-card.total { background: var(--surface-2); font-weight: 600; }
@media (max-width: 600px) { .chips-row { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; padding-bottom: 2px; } .fchip { flex: none; } }

/* ------------------------------------------------ front desk (Sprint 2 WP4) */
.badges { display: inline-flex; gap: 3px; vertical-align: middle; }
.badge-i { width: 20px; height: 20px; border-radius: 6px; display: inline-grid; place-items: center; background: var(--neutral-soft); color: var(--neutral); }
.badge-i.danger { background: var(--danger-soft); color: var(--danger); } .badge-i.warning { background: var(--warning-soft); color: var(--warning); } .badge-i.success { background: var(--success-soft); color: var(--success); }
.badge-i.info { background: var(--info-soft); color: var(--info); } .badge-i.accent { background: var(--accent-soft); color: var(--accent); }
.appt .badges { margin-inline-start: 2px; } .appt .badge-i { width: 16px; height: 16px; border-radius: 4px; } .appt .badge-i svg { width: 10px; height: 10px; }
.timer { display: inline-flex; align-items: center; gap: 3px; border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.timer.success { background: var(--success-soft); color: var(--success); } .timer.warning { background: var(--warning-soft); color: var(--warning); } .timer.danger { background: var(--danger-soft); color: var(--danger); animation: pulse 2s infinite; } .timer.info { background: var(--info-soft); color: var(--info); }
@keyframes pulse { 50% { opacity: .65; } }
.wait-kpis { margin-bottom: 12px; }
.quick-svc { display: flex; flex-wrap: wrap; gap: 6px; } .qbtn { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 12.5px; color: var(--text); }
.qbtn:hover { border-color: var(--accent); } .qbtn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.surfaces { display: inline-flex; gap: 4px; direction: ltr; } .surf { width: 38px; height: 34px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 8px; font: 600 13px var(--mono); cursor: pointer; color: var(--text-2); }
.surf[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.surf-tag { font: 600 11px var(--mono); background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 0 4px; margin-inline-start: 4px; direction: ltr; display: inline-block; }
.reg-kpi { cursor: default; } .diff-box { margin: 10px 0; padding: 10px 14px; border-radius: var(--r2); background: var(--surface-2); font-size: 15px; } .diff-box.ok { background: var(--success-soft); color: var(--success); } .diff-box.bad { background: var(--danger-soft); color: var(--danger); }
.preview-banner { display: flex; align-items: center; gap: 10px; justify-content: center; background: #4A2B8C; color: #fff; padding: 6px 12px; font-size: 13px; position: sticky; top: 0; z-index: 40; }
.preview-banner .btn { background: #fff; color: #4A2B8C; border-color: #fff; }
body.privacy .pii, body.privacy .phead h2, body.privacy a[href^="tel:"], body.privacy .list-card .t1, body.privacy .appt .n, body.privacy .picker-results b { filter: blur(6px); transition: filter var(--t); }
body.privacy .pii:hover, body.privacy .appt:hover .n { filter: none; }
.privacy-chip { color: var(--warning); }
/* reception (tablet) mode: no side menu, bigger targets */
.app.reception { --rail: 0px; } .app.reception .rail { display: none; } .app.reception .content { font-size: 16px; }
.app.reception .appt-card { padding: 14px 16px; } .app.reception .appt-card b { font-size: 17px; } .app.reception .btn.sm { height: 40px; padding: 0 16px; font-size: 15px; } .app.reception .timer { font-size: 14px; padding: 3px 10px; }
/* timeline */
.tline { list-style: none; margin: 0; padding: 8px 16px 14px; } .tline li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); align-items: flex-start; }
.tl-ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; } .tl-body { flex: 1; min-width: 0; }
.tl-visit .tl-ic { background: var(--accent-soft); color: var(--accent); } .tl-payment .tl-ic { background: var(--success-soft); color: var(--success); } .tl-refund .tl-ic { background: var(--danger-soft); color: var(--danger); } .tl-consent .tl-ic { background: var(--info-soft); color: var(--info); }

/* open trial: «who are you?» */
.trial-pick { max-width: 720px; margin: 8vh auto; padding: 24px 16px; display: grid; gap: 14px; }
.brand-big { display: flex; gap: 14px; align-items: center; } .brand-big .logo { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg, #2457DC, #0FA3A3); display: grid; place-items: center; color: #fff; } .brand-big h1 { margin: 0; }
.trial-users { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.trial-user { display: grid; gap: 2px; text-align: start; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r3); background: var(--surface); cursor: pointer; color: var(--text); font: inherit; }
.trial-user:hover { border-color: var(--accent); box-shadow: var(--shadow); }
