:root {
  --soft: #f1f5f9;
  --bg: #eaf3f3; --card: #fff; --ink: #25343d; --muted: #6b7f89; --line: #dbe6e7;
  --brand: #3b8f94; --brand-d: #2c6f74; --brand-l: #e2f1f1;
  --danger: #c9605f; --warn: #cc8a3c; --ok: #4a9d6f;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5;
}
a { color: var(--brand-d); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted, small { color: var(--muted); }

/* layout */
#app { display: flex; min-height: 100vh; }
#sidebar {
  width: 230px; flex: none; background: #2f5f64; color: #e4f1f1; padding: 18px 12px;
  display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh;
}
.brand { font-size: 19px; font-weight: 700; padding: 4px 10px 12px; border-bottom: 1px solid #467a7f; }
#sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
#sidebar nav a {
  color: #d3e8e9; padding: 10px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center;
}
#sidebar nav a:hover { background: #3b7177; text-decoration: none; }
#sidebar nav a.active { background: #4a9ca1; color: #fff; }
.lang { background: transparent; border: 1px solid #5b8e93; color: #d3e8e9; padding: 8px; border-radius: 8px; cursor: pointer; font: inherit; }
.lang:hover { background: #3b7177; }
#content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#main { flex: 1; padding: 22px 30px 60px; min-width: 0; width: 100%; max-width: 1400px; }

/* cards, headings */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head h1 { margin: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 { margin-bottom: 16px; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; margin: 0; }
.error { color: var(--danger); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat small { display: block; margin-bottom: 4px; }
.stat b { font-size: 22px; }
.stat.warn b { color: var(--warn); }
.stat.due b { color: var(--danger); }

/* buttons & inputs */
.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 16px; border-radius: 8px;
  cursor: pointer; font: inherit;
}
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); }
.btn.danger { color: var(--danger); border-color: #f1c4c4; }
.btn.danger:hover { background: #fdf0f0; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: default; }
.icon { border: 0; background: transparent; cursor: pointer; color: var(--danger); font-size: 15px; padding: 2px 6px; border-radius: 6px; }
.icon:hover { background: #fdf0f0; }
input, select, textarea {
  font: inherit; color: inherit; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; background: var(--card); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-l); border-color: var(--brand); }
.search { max-width: 420px; margin-bottom: 14px; }
.inline-input { width: auto; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: start; font-size: 13px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid #eef2f6; vertical-align: middle; }
.tbl tbody tr:hover { background: var(--soft); }
.tbl tr.click { cursor: pointer; }
.tbl td.num, .tbl th.num { text-align: end; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; }
.due { color: var(--danger); font-weight: 600; }
.ok { color: var(--ok); }
.warn { color: var(--warn); font-weight: 600; }

/* badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--c, #e2e8f0); color: #fff; white-space: nowrap; }
.st-scheduled { --c: #6b9bd6; } .st-confirmed { --c: #4f6fb0; } .st-checked_in { --c: #4aa59b; }
.st-in_progress { --c: #9272c4; } .st-completed { --c: #4f9a6c; } .st-delayed { --c: #d29a4c; }
.st-cancelled { --c: #d1707f; } .st-no_show { --c: #a45b5b; } .st-waiting_list { --c: #9a9f4a; }
.badge.low { --c: var(--warn); } .badge.out { --c: var(--danger); }

/* patient header & tabs */
.back { display: inline-block; margin-bottom: 10px; }
.phead { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.phead > div:first-child { flex: 1; min-width: 220px; }
.pbal { text-align: center; padding: 6px 18px; border-radius: 10px; background: var(--brand-l); }
.pbal b { display: block; font-size: 20px; }
.pbal.due { background: #fdecec; }
.pbal.due b { color: var(--danger); }
.alert-warn { margin-top: 8px; background: #fff4e0; color: #8a4b00; border: 1px solid #f5d9a6; padding: 6px 12px; border-radius: 8px; display: inline-block; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 10px 18px; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { color: var(--brand-d); border-bottom-color: var(--brand); font-weight: 600; }
.dl { display: grid; grid-template-columns: 170px 1fr; gap: 10px 16px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; white-space: pre-wrap; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(15, 30, 40, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal { background: var(--card); border-radius: 14px; padding: 22px; width: 100%; max-width: 620px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 13px; color: var(--muted); }
.field.wide, .actions.wide { grid-column: 1 / -1; }
.field small { margin-top: 2px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; }
.hist { margin-bottom: 14px; border: 1px solid var(--line); border-radius: 10px; max-height: 190px; overflow-y: auto; }
.hrow { display: flex; gap: 12px; align-items: center; padding: 8px 12px; border-bottom: 1px solid #eef2f6; }
.hrow:last-child { border-bottom: 0; }
.hrow span:nth-child(3) { flex: 1; }

/* toast */
#toast { position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translateX(-50%) translateY(20px); background: #2f5f64; color: #fff; padding: 10px 20px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .25s; z-index: 100; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--danger); }

/* dental chart */
.chart { direction: ltr; display: flex; flex-direction: column; gap: 0; align-items: center; padding: 8px 0 4px; overflow-x: auto; background: linear-gradient(#fff, #fff); }
.jaw-label { color: var(--muted); font-size: 13px; margin: 4px 0; }
.arch { display: flex; align-items: stretch; width: 100%; max-width: 1060px; box-sizing: border-box; background: linear-gradient(to bottom, rgba(253,236,238,.0), rgba(250,228,232,.5) 55%, rgba(253,236,238,.0)); padding: 0 6px; }
.arch.lower { margin-top: 0; }
.quad { display: flex; flex: 1 1 0; min-width: 0; }
.midline { width: 1px; background: #cfd6de; margin: 0 4px; }
.tooth { flex: 1 1 0; min-width: 0; max-width: 66px; border: 0; background: transparent; cursor: pointer; display: flex; flex-direction: column; align-items: center; padding: 0; font: inherit; color: var(--ink); position: relative; }
.tooth:hover { background: rgba(139, 92, 246, .10); }
.tooth svg { display: block; }
.tooth svg.side { width: 100%; height: auto; aspect-ratio: 60/136; filter: drop-shadow(0 1px 1.5px rgba(90,70,40,.25)); }
.tooth svg.occ { width: 90%; height: auto; aspect-ratio: 60/52; margin: 2px 0; filter: drop-shadow(0 1px 1px rgba(90,70,40,.22)); }
.tooth svg .shine { fill: url(#tg-shine); stroke: none; pointer-events: none; }
.tooth .tn { font-size: 12px; color: #6b7280; padding: 3px 0; min-width: 100%; text-align: center; }
.tooth svg .gum2 { fill: url(#tg-gum); stroke: none; }
.tooth svg .cshade, .tooth svg .rshade { fill: url(#tg-side); stroke: none; pointer-events: none; }
.tooth svg .neck { fill: url(#tg-neck); stroke: none; pointer-events: none; }
.tooth svg .oshade { fill: url(#tg-occ); stroke: none; pointer-events: none; }
.tooth svg .cusp { fill: #fff; opacity: .4; stroke: none; }
.tooth svg path { stroke: #9aa5ad; stroke-width: .8; stroke-linejoin: round; }
.tooth svg .root { fill: var(--rc, #f4edc2); stroke: #cfc48e; }
.tooth svg .pulp { fill: none; stroke: #dcc9a0; stroke-width: .9; }
.tooth svg .crown { fill: var(--cc, #fdf8ee); }
.tooth svg .fis { fill: none; stroke: rgba(80, 105, 130, .6); stroke-width: .9; stroke-linecap: round; }
.t-none { --c: #fdf8ee; } .t-planned { --c: #e89a9a; } .t-incomplete { --c: #efcb7d; } .t-completed { --c: #8fd0a6; } .t-existing { --c: #c1b8e8; }
.tooth.cs-none { --cc: #fffefa; } .tooth.cs-planned { --cc: #e89a9a; } .tooth.cs-incomplete { --cc: #efcb7d; } .tooth.cs-completed { --cc: #8fd0a6; } .tooth.cs-existing { --cc: #c1b8e8; }
.tooth.rs-none { --rc: #f4edc2; } .tooth.rs-planned { --rc: #e89a9a; } .tooth.rs-incomplete { --rc: #efcb7d; } .tooth.rs-completed { --rc: #8fd0a6; } .tooth.rs-existing { --rc: #c1b8e8; }
.tooth:not(.t-none) .tn { background: var(--c); color: #1b2733; font-weight: 700; border-radius: 4px; }
.tooth.c-extracted svg { opacity: .35; }
.tooth.c-extracted svg path { stroke-dasharray: 3 2; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: center; margin-top: 12px; font-size: 13px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--c); border: 1px solid #5b6b7c55; margin-inline-end: 5px; vertical-align: -1px; }
.c-healthy { --c: #86efac; } .c-caries { --c: #ef4444; } .c-filling { --c: #3b82f6; } .c-root_canal { --c: #a855f7; }
.c-crown { --c: #eab308; } .c-bridge { --c: #ec4899; } .c-implant { --c: #06b6d4; } .c-extracted { --c: #9ca3af; }
.c-fracture { --c: #b45309; } .c-other { --c: #f97316; } .c-none { --c: #fff; }
.badge.c-healthy, .badge.c-crown { color: #1b2733; }

.print-only { display: none; }

#menuBtn { display: none; }
@media (max-width: 860px) {
  #app { flex-direction: column; }
  /* phone: the side menu slides in from the start edge behind the ☰ button */
  #menuBtn { display: inline-flex; }
  #sidebar { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: 250px; max-width: 80vw; height: 100vh; z-index: 60; overflow-y: auto; transform: translateX(var(--nav-x, -105%)); transition: transform .2s; flex-direction: column; flex-wrap: nowrap; align-items: stretch; box-shadow: 0 0 30px rgba(0,0,0,.35); }
  html[dir=rtl] #sidebar { --nav-x: 105%; }
  body.nav-open #sidebar { transform: none; }
  #sidebar nav { flex-direction: column; flex-wrap: nowrap; }
  #topbar { gap: 8px; padding: 8px 10px; flex-wrap: wrap; }
  .brand { border: 0; padding: 14px 16px; }
  #main { padding: 18px 14px 50px; }
  .grid2, .form-grid { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
}
@media print {
  body { background: var(--card); }
  #sidebar, #topbar, .no-print, .tabs, .back, #toast { display: none !important; }
  .print-only { display: block; }
  #main { padding: 0; max-width: none; }
  .card, .stat { border-color: #bbb; break-inside: avoid; }
}

/* top bar */
#topbar { display: flex; align-items: center; gap: 16px; padding: 10px 30px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.gsearch { position: relative; width: 320px; max-width: 40%; }
.gsearch input { background: var(--soft); border-color: transparent; }
.gres { position: absolute; top: 100%; inset-inline: 0; margin-top: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); overflow: hidden; z-index: 30; }
.gres[hidden] { display: none; }
.gres a { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; color: var(--ink); }
.gres a:hover { background: var(--brand-l); text-decoration: none; }
.tb-title { flex: 1; font-weight: 700; font-size: 17px; color: var(--brand-d); }

/* dashboard */
.dfilters { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.dfilters label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.dnav { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--brand); border-radius: 10px; padding: 4px 8px; }
.dnav input { border: 0; width: auto; padding: 4px; }
.dnav .btn { border: 0; padding: 6px 10px; }
.clock { margin-inline-start: auto; font-size: 22px; font-weight: 700; color: var(--brand-d); background: var(--brand-l); padding: 8px 18px; border-radius: 10px; direction: ltr; }
.dgrid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; margin-bottom: 16px; align-items: start; }
.dgrid > .card { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { border: 0; background: var(--c); color: #fff; padding: 5px 12px; border-radius: 6px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; opacity: .95; }
.chip.dim { opacity: .35; }
.chip.on { outline: 3px solid var(--c); outline-offset: 2px; }
.acard { display: flex; justify-content: space-between; gap: 12px; background: var(--c); color: #fff; border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; }
.acard a { color: #fff; font-size: 17px; font-weight: 700; }
.a-body { min-width: 0; }
.a-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag { display: inline-block; background: rgba(255,255,255,.22); padding: 2px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; margin-inline-start: 8px; }
.a-tags .tag { margin: 0; }
.tag.b { background: rgba(255,255,255,.9); color: var(--c); margin: 0; }
.a-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; text-align: end; }
.a-top { display: flex; gap: 8px; align-items: center; }
.ib { border: 0; background: rgba(255,255,255,.2); color: #fff; width: 28px; height: 28px; border-radius: 6px; cursor: pointer; font-size: 15px; }
.ib:hover { background: rgba(255,255,255,.35); }
.a-time { font-weight: 700; font-size: 15px; }
.a-status { width: auto; padding: 3px 8px; font-size: 13px; background: rgba(255,255,255,.92); color: var(--ink); border-color: transparent; }
.chk { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }
.chk input { width: auto; }
.inv { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid #eef2f6; }
.inv:last-child { border-bottom: 0; }
.ring { --p: 0; width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center; background: conic-gradient(var(--ok) calc(var(--p) * 1%), #e5e7eb 0); }
.ring span { background: var(--card); width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.inv-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.inv-info a { font-weight: 700; }
.inv-amt { text-align: end; font-size: 14px; line-height: 1.7; white-space: nowrap; }
@media (max-width: 1000px) { .dgrid { grid-template-columns: 1fr; } .gsearch { max-width: none; flex: 1; } .tb-title { display: none; } }

/* logo */
.brand { display: flex; align-items: center; gap: 10px; }
.logo { background: var(--brand); color: #fff; font-weight: 800; letter-spacing: 1px; font-size: 15px; padding: 6px 9px; border-radius: 8px; direction: ltr; flex: none; }

/* segmented buttons */
.seg { display: inline-flex; border: 1px solid #cbd5e1; border-radius: 8px; overflow: hidden; background: var(--card); }
.seg button { border: 0; background: transparent; padding: 6px 16px; font: inherit; cursor: pointer; color: var(--ink); }
.seg button + button { border-inline-start: 1px solid #cbd5e1; }
.seg button.on { background: var(--brand); color: #fff; }
.seg button.on-yes { background: var(--danger); color: #fff; }
.seg button.on-no { background: var(--ok); color: #fff; }

/* medical history */
.qgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 36px; margin-bottom: 22px; }
.q { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid #eef2f6; }
.mchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mchip { background: #fde8e8; color: #9b1c1c; border: 1px solid #f5bcbc; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.mchip.al { background: #fff4e0; color: #8a4b00; border-color: #f5d9a6; }

/* chart category bar */
.catbar { display: flex; flex-wrap: wrap; gap: 6px; }
.catbtn { border: 1px solid var(--line); background: var(--card); padding: 6px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px; display: flex; gap: 6px; align-items: center; }
.catbtn:hover { background: var(--brand-l); }
.catbtn.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* calendar */
.calwrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: auto; max-height: calc(100vh - 250px); }
.calhead, .calbody { display: grid; min-width: max-content; }
.calhead { position: sticky; top: 0; background: var(--card); z-index: 3; border-bottom: 1px solid var(--line); }
.colhead { padding: 10px 8px; text-align: center; font-weight: 600; border-inline-start: 1px solid var(--line); }
.today-h { color: var(--brand-d); background: var(--brand-l); }
.gutter { position: relative; color: var(--muted); font-size: 11px; }
.gutter span { position: absolute; inset-inline-end: 6px; transform: translateY(-50%); white-space: nowrap; direction: ltr; }
.gutter span:first-child { transform: none; }
.col { position: relative; border-inline-start: 1px solid var(--line); cursor: pointer;
  background-image: repeating-linear-gradient(to bottom, #dfe5ec 0, #dfe5ec 1px, transparent 1px, transparent calc(var(--hr) / 2), #f0f3f7 calc(var(--hr) / 2), #f0f3f7 calc(var(--hr) / 2 + 1px), transparent calc(var(--hr) / 2 + 1px), transparent var(--hr)); }
.col:hover { background-color: #fafcff; }
.ev { position: absolute; background: var(--c); color: #fff; border-radius: 6px; padding: 3px 7px; font-size: 12px; overflow: hidden; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.3); line-height: 1.3; z-index: 1; }
.ev b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev span { display: block; opacity: .95; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.dim { opacity: .45; }
.nowline { position: absolute; inset-inline: 0; height: 2px; background: #e11d48; z-index: 2; pointer-events: none; }
.legend i.st-scheduled, .legend i[class^="st-"] { background: var(--c); }

/* lab */
.sm-chip { font-size: 11px; padding: 1px 8px; margin-top: 4px; }
.chip.lab-chip.on { outline-offset: 2px; }
@media (max-width: 860px) { .qgrid { grid-template-columns: 1fr; } }

.ev .evt span { display: inline; }

/* settings hub */
.set-layout{display:grid;grid-template-columns:230px 1fr;gap:18px;align-items:start}
.set-nav{display:flex;flex-direction:column;gap:4px;background:var(--card,#fff);border:1px solid var(--line,#e3e8ee);border-radius:12px;padding:8px;position:sticky;top:12px}
.set-nav a{padding:10px 12px;border-radius:8px;color:inherit;text-decoration:none;font-weight:600}
.set-nav a:hover{background:rgba(0,0,0,.04)}
.set-nav a.active{background:#3b8f94;color:#fff}
.set-body{min-width:0}
.acts{white-space:nowrap;text-align:end}
.btn.danger{color:#c0392b;border-color:#e6b0aa}
@media(max-width:800px){.set-layout{grid-template-columns:1fr}.set-nav{flex-direction:row;flex-wrap:wrap;position:static}}
#sidebar .sub{display:none;margin:2px 14px 6px;padding-inline-start:12px;border-inline-start:2px solid rgba(255,255,255,.18)}
#sidebar .sub.open{display:block}
#sidebar .sub a{padding:6px 10px;font-size:13px;opacity:.8}
#sidebar .sub a.active{opacity:1;font-weight:700;background:rgba(255,255,255,.1)}
.tbl .ib{color:#475569;background: var(--soft);border:1px solid var(--line);border-radius:6px;cursor:pointer;padding:2px 7px;margin-inline-start:4px}
.tbl .ib:hover{background:#e2e8f0}
.fin-layout{display:block}.fin-layout .set-nav{display:none}
.chip-s{display:inline-flex;align-items:center;gap:6px;background: var(--soft);border:1px solid var(--line);border-radius:999px;padding:2px 4px 2px 10px;margin:2px;font-size:13px}
.chip-s.best{background:#e6f6f0;border-color:#9bd5bf}
.chip-s .x{border:0;background:none;cursor:pointer;color:#94a3b8;font-size:15px;line-height:1}
.invimg{max-width:420px;max-height:340px;border:1px solid var(--line);border-radius:10px;display:block}
.badge.st-scheduled{background:#3b82f6;color:#fff}.badge.st-completed{background:#16a34a;color:#fff}
.acts2{white-space:nowrap}

/* printable lab work order — A5 */
#printSheet{position:fixed;inset:0;background:rgba(15,30,40,.55);z-index:200;overflow:auto;padding:20px}
.ps-bar{display:flex;gap:10px;justify-content:center;margin-bottom:14px}
.ps-page{background: var(--card);color:#111;width:148mm;min-height:210mm;margin:0 auto;padding:10mm;border-radius:4px;box-shadow:0 8px 30px rgba(0,0,0,.3);box-sizing:border-box}
.ps-head{display:flex;justify-content:space-between;align-items:flex-start;border-bottom:2px solid #0e7c86;padding-bottom:8px;margin-bottom:14px}
.ps-clinic{font-size:17px;font-weight:800;color:#2c6f74}
.ps-title{font-size:22px;font-weight:800;margin-top:2px}
.ps-meta{font-size:12px;line-height:1.8;text-align:end}
.ps-tbl{width:100%;border-collapse:collapse}
.ps-tbl th{width:30%;text-align:start;background: var(--soft);padding:9px 10px;border:1px solid #cbd5e1;font-size:12px;color:#334155}
.ps-tbl td{padding:9px 10px;border:1px solid #cbd5e1;font-size:14px}
.ps-tbl td.big{font-size:18px;font-weight:800}
.ps-qty{font-size:13px;font-weight:600;color:#475569}
.ps-notes{border:1px solid #cbd5e1;margin-top:12px;padding:8px 10px;min-height:60mm;font-size:13px}
.ps-notes b{display:block;margin-bottom:4px;color:#334155;font-size:12px}
@media print{
  body.printing-sheet #app,body.printing-sheet #toast{display:none!important}
  body.printing-sheet #printSheet{position:static;background:none;padding:0;overflow:visible}
  body.printing-sheet .ps-page{box-shadow:none;width:auto;min-height:0;padding:0;border-radius:0}
  body.printing-sheet .ps-tbl th{-webkit-print-color-adjust:exact;print-color-adjust:exact}
}

/* prescriptions: only the typed fields are printed, on the clinic's own pre-printed A5 pad */
.rx-page{position:relative;width:148mm;height:209mm;background: var(--card);overflow:hidden;direction:ltr}
.rx-f{position:absolute;font-size:13pt;line-height:1.25;color:#111;white-space:nowrap;overflow:hidden;transform:translateY(-100%);padding-bottom:.6mm}
.rx-body{transform:none;white-space:pre-wrap;overflow:hidden;font-size:13pt;line-height:1.7;padding:0}
.rx-guide{position:absolute;height:0;border-top:.3mm dashed #e11}
.rx-guide-box{position:absolute;border:.3mm dashed #e11}
#printSheet.rx-print .rx-wrap{display:flex;justify-content:center}
#printSheet.rx-print .rx-page{box-shadow:0 8px 30px rgba(0,0,0,.3)}
@media print{
  body.printing-sheet #printSheet.rx-print{position:static;background:none;padding:0}
  body.printing-sheet .rx-print .rx-page{box-shadow:none;margin:0}
  body.printing-sheet .rx-guide,body.printing-sheet .rx-guide-box{-webkit-print-color-adjust:exact;print-color-adjust:exact}
}

/* ---- login screen, user menu, audit lines ---- */
#authScreen { position: fixed; inset: 0; z-index: 100; background: linear-gradient(135deg, var(--brand-d), var(--brand)); display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-box { background: var(--card); border-radius: 16px; padding: 28px 30px; width: min(400px, 100%); display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth-box h1 { font-size: 22px; margin: 0; text-align: center; }
.auth-box .btn.primary { padding: 10px; font-size: 16px; }
.auth-box .lang-sw { align-self: center; border: 0; background: none; color: var(--muted); }
.auth-box input { padding: 10px; font-size: 15px; }
.logo.big { width: 64px; height: 64px; font-size: 22px; align-self: center; display: flex; align-items: center; justify-content: center; border-radius: 16px; background: var(--brand); color: #fff; font-weight: 700; }
.auth-err { background: #fde8e8; color: var(--danger); padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.usr { position: relative; }
.usr-menu { position: absolute; inset-inline-end: 0; top: 36px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.15); min-width: 190px; z-index: 50; padding: 6px; display: flex; flex-direction: column; }
.usr-menu small { padding: 6px 10px; }
.usr-menu button { border: 0; background: none; text-align: start; padding: 8px 10px; border-radius: 6px; cursor: pointer; font: inherit; }
.usr-menu button:hover { background: var(--brand-l); }
.acc-line { display: flex; gap: 28px; flex-wrap: wrap; }
.acc-line span { display: flex; flex-direction: column; }
.acc-line .ok { color: var(--ok); } .acc-line .due { color: var(--danger); }
.aud { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; font-weight: 400; white-space: nowrap; }
.aud:empty { display: none; }
.usr-menu[hidden], .auth-err[hidden] { display: none; }
.tag.ins { background: #fff3cd; color: #7a5b00; font-size: 12px; vertical-align: middle; }

/* ---- session timer ---- */
.sess { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; justify-content: flex-end; }
.sess .live { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; color: var(--ok); }
.sess.run { background: #e8f7ee; border-radius: 8px; padding: 6px 8px; }
.sess.done small { color: var(--muted); }
.sess-banner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: #e8f7ee; border: 1px solid #b7e4c7; color: #14532d; border-radius: 12px; padding: 10px 16px; margin-bottom: 14px; }
.sess-banner .live.big { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sess-banner b { color: var(--ok); }
.sess-banner .btn { margin-inline-start: auto; }
@media print { .sess-banner, .sess { display: none; } }
.sess-banner { background: var(--soft); border-color: var(--line); color: var(--ink); padding: 6px 14px; font-size: 14px; }
.sess-card { margin-bottom: 12px; }
.sc-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.sc-time { text-align: end; display: flex; flex-direction: column; }
.sc-time b { font-size: 22px; color: var(--brand-d); }
.sc-body h4 { margin: 12px 0 6px; font-size: 14px; color: var(--muted); }
.sc-body ul { margin: 0 0 8px; padding-inline-start: 20px; }
.sc-notes { background: var(--soft); border-inline-start: 3px solid var(--brand); padding: 8px 12px; border-radius: 6px; margin: 8px 0; }
.tag.ok { background: #e8f7ee; color: var(--ok); }

/* ---- procedure menus on the chart ---- */
.catwrap { position: relative; display: inline-block; }
.catbtn.picked { box-shadow: inset 0 0 0 2px var(--ok); }
.catmenu { position: absolute; top: calc(100% + 4px); inset-inline-start: 0; z-index: 30; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); min-width: 250px; max-height: 320px; overflow: auto; padding: 4px; direction: rtl; }
html[dir=ltr] .catmenu { direction: ltr; }
.catmenu .mi { display: flex; justify-content: space-between; gap: 14px; width: 100%; border: 0; background: none; text-align: start; padding: 9px 10px; border-radius: 7px; cursor: pointer; font: inherit; }
.catmenu .mi:hover, .catmenu .mi.on { background: var(--brand-l); }
.catmenu .mi b { color: var(--brand-d); white-space: nowrap; }
.activeproc { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: #e8f7ee; border: 1px solid #b7e4c7; border-radius: 10px; padding: 8px 14px; margin-top: 10px; }

.mirow { display: flex; align-items: center; }
.mirow .mi { flex: 1; }
.mie { border: 0; background: none; cursor: pointer; padding: 6px 8px; border-radius: 6px; color: var(--muted); }
.mie:hover { background: var(--brand-l); color: var(--brand-d); }
.catmenu .mi .pr { visibility: hidden; }
.catmenu .mi:hover .pr, .catmenu .mi:focus-visible .pr { visibility: visible; }
.catmenu .mi.add { color: var(--brand-d); border-top: 1px solid var(--line); border-radius: 0 0 7px 7px; margin-top: 4px; font-weight: 600; }

/* ---- procedure status ---- */
.pstatus { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.pst { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 20px; padding: 4px 12px; cursor: pointer; font: inherit; font-size: 13px; }
.pst.on { border-color: var(--brand); background: var(--brand-l); font-weight: 600; }
.sdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #999; vertical-align: middle; }
.sdot.p-planned { background: #e07a7a; }
.sdot.p-incomplete { background: #e0a93f; }
.sdot.p-completed { background: #5fb87f; }
.sdot.p-existing { background: #a597dc; }
.tooth { position: relative; }
.badge.p-planned { background: #e8ecfb; color: #3b4fb0; } .badge.p-incomplete { background: #fff3d6; color: #9a5b00; }
.badge.p-completed { background: #e8f7ee; color: var(--ok); } .badge.p-existing { background: #efe7fd; color: #6d3fd1; }
.pst-sel { min-width: 120px; }

/* ---- accounts: statement, sub tabs, permissions ---- */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.subtabs a { padding: 6px 14px; border-radius: 20px; background: var(--card); border: 1px solid var(--line); color: var(--ink); }
.subtabs a.active { background: var(--brand); border-color: var(--brand); color: #fff; text-decoration: none; }
.stmt td { padding: 7px 10px; }
.stmt tr.sub td { border-top: 1px solid var(--line); font-weight: 700; background: var(--soft); }
.stmt tr.neg td:last-child { color: var(--danger); }
.stmt tr.final td { font-size: 20px; background: #e8f7ee; border-top: 2px solid var(--ok); }
.stmt tr.final.loss td { background: #fde8e8; border-top-color: var(--danger); }
tr.tot td { border-top: 2px solid var(--line); background: var(--soft); }
.perm-h { margin: 16px 0 4px; font-size: 15px; }
.perms { display: flex; flex-direction: column; gap: 6px; }

/* analytics */
.an-filters { align-items: end; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.an-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.an-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 120px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; transition: transform .12s, box-shadow .12s, border-color .12s; }
.an-tile:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.an-tile .an-ic { font-size: 30px; }
.an-tile b { font-size: 15px; }
.an-chart { margin-bottom: 16px; }
.an-bars { display: flex; align-items: flex-end; gap: 6px; height: 190px; overflow-x: auto; padding-bottom: 4px; }
.an-bar { flex: 1 0 34px; max-width: 90px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.an-bar .col { width: 100%; flex: 1; display: flex; align-items: flex-end; }
.an-bar i { display: block; width: 100%; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 3px; flex: none; }
.an-bar span { font-size: 10px; color: var(--muted); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.an-sub td, tr.an-final td { font-weight: 700; background: rgba(0,0,0,.035); }
tr.an-final td { font-size: 1.05em; border-top: 2px solid var(--line); }
tr.an-minus td.num { color: var(--danger); }

.an-sum { padding: 0; overflow: hidden; }
.an-row { display: grid; grid-template-columns: 200px 1fr; border-bottom: 1px solid var(--line); }
.an-row:last-child { border-bottom: 0; }
.an-k { padding: 18px; background: rgba(0,0,0,.025); color: var(--muted); font-weight: 600; }
.an-v { padding: 14px 18px; }
.an-big { font-size: 22px; font-weight: 700; color: #0a7bb0; }
.an-big.ok { color: var(--ok); } .an-big.bad { color: var(--danger); }
.an-subv { font-size: 15px; color: var(--warn); } .an-subv small { color: var(--muted); }
.an-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 10px; }
.an-mini { background: #eef1f9; border-radius: 6px; padding: 8px 10px; text-align: center; }
.an-mini small { display: block; color: var(--muted); font-size: 12px; }
.an-mini b { font-size: 17px; }
.an-mini i { display: block; font-style: normal; font-size: 11px; color: var(--muted); }
.an-mini.ok { background: #edfcf2; } .an-mini.ok b { color: var(--ok); }
.an-mini.bad b { color: var(--danger); } .an-mini.warn b { color: var(--warn); }
@media (max-width: 700px) { .an-row { grid-template-columns: 1fr; } }
.att-link { display: block; margin-top: 16px; padding: 12px; background: var(--brand-l); border-radius: 10px; }
.att-link b, .att-link code, .att-link small { display: block; margin-bottom: 6px; }
.att-link code { font-size: 16px; user-select: all; }

.tlegend i.tl { width: 16px; height: 16px; border-radius: 50%; background: var(--c); border: 1px solid #6b7b8c; }
.badge.p-planned { background: #fde8e8; color: #b42323; }

.no-del [data-del], .no-del [data-delc], .no-del [data-delp], .no-del [data-delr], .no-del [data-delrec] { display: none !important; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.perm-grp { margin-bottom: 10px; } .perm-grp h4 { margin: 8px 0 6px; font-size: 14px; color: var(--muted); }

/* appointment details popup */
.acard[data-aid] { cursor: pointer; }
.modal.modal-wide { max-width: 760px; }
.ad { border-top: 6px solid var(--c, #999); margin: -22px -22px 0; padding: 18px 22px 20px; border-radius: 14px; }
.ad-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.ad-head h2 { margin: 0; font-size: 20px; }
.ad-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ad-lbl { min-width: 96px; font-size: 13px; color: var(--muted); font-weight: 600; }
.ad-grid { display: grid; grid-template-columns: 110px 1fr 110px 1fr; border: 1px solid var(--line); border-radius: 10px; margin: 12px 0; overflow: hidden; }
.ad-k { background: color-mix(in srgb, var(--c, #999) 14%, white); padding: 8px 12px; font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--line); }
.ad-v { padding: 8px 12px; border-bottom: 1px solid var(--line); min-height: 38px; }
.ad-link { padding: 4px 10px; border: 1px solid var(--line); border-radius: 16px; font-size: 13px; background: var(--card); }
.ad-links { border-bottom: 0; }
.ad-status { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding-top: 8px; border-top: 1px solid var(--line); }
.ad-status .chip { cursor: pointer; }
@media (max-width: 700px) { .ad-grid { grid-template-columns: 100px 1fr; } }

/* weekly working hours */
.wk { display: grid; gap: 6px; max-width: 520px; }
.wk-row { display: grid; grid-template-columns: 130px 110px 20px 110px 1fr; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line, #e3e8ef); border-radius: 8px; }
.wk-row .wk-off { display: none; }
.wk-row.off { background: #f4f5f7; }
.wk-row.off input[type=time] { opacity: .35; pointer-events: none; }
.wk-row.off .wk-off { display: inline; }
.wk-on { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.dayoff { background: #fff4e0; color: #8a5a00; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; font-weight: 600; }
.colhead.off-h { background: #f0f1f3; color: #8a8f98; }
.colhead small { font-weight: 400; }

/* attendance pay + notices */
.pr-rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.pr-rules.off { opacity: .45; }
.pr-net { margin: 12px 0; padding: 10px 14px; background: #eef6ff; border-radius: 8px; font-size: 15px; }
.pr-net b { font-size: 18px; }
tr.pr-abs td { background: #fff1f1; }
tr.pr-late td { background: #fff8e6; }
.tag.bad { background: #ffd9d9; color: #a11; } .tag.warn { background: #ffecb5; color: #8a5a00; } .tag.ok { background: #d8f3dc; color: #176b2c; }
.bell { position: relative; } .bell .bdg { position: absolute; top: -6px; inset-inline-end: -6px; background: #e53935; color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 6px; }
.notices { display: grid; gap: 8px; max-height: 60vh; overflow: auto; margin: 10px 0; }
.notice { border: 1px solid #e3e8ef; border-radius: 8px; padding: 10px 12px; display: grid; gap: 3px; }
.notice.new { border-color: #f1b44c; background: #fdf8ee; }
.notice.deduction .amt { color: #c62828; font-weight: 700; } .notice.bonus .amt { color: #2e7d32; font-weight: 700; }

.hol-row { display: flex; gap: 8px; margin-bottom: 6px; max-width: 460px; } .hol-row .hol-n { flex: 1; }

/* new patient form (reference layout) */
.modal.pf-modal { max-width: 980px; width: 96vw; max-height: 94vh; overflow: auto; padding: 0; }
.pf-head { padding: 16px 24px; border-bottom: 1px solid #e3e8ef; position: sticky; top: 0; background: var(--card); z-index: 3; } .pf-head h2 { margin: 0; font-size: 18px; }
.pf { padding: 16px 24px 0; }
.pf-band { background: #e6f6f5; border-radius: 8px; padding: 10px 16px; font-weight: 700; margin-bottom: 14px; }
.pf-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px 18px; }
.pf .f { display: flex; flex-direction: column; gap: 6px; position: relative; font-size: 13px; }
.pf .s2 { grid-column: span 2; } .pf .s3 { grid-column: span 3; } .pf .s6 { grid-column: span 6; }
.pf input, .pf select, .pf textarea { border: 1px solid #d5dbe4; border-radius: 8px; padding: 9px 11px; font: inherit; background: var(--card); width: 100%; min-width: 0; }
.pf input:focus, .pf select:focus, .pf textarea:focus { outline: none; border-color: #2a9fc9; box-shadow: 0 0 0 2px rgba(42,159,201,.15); }
.pf .rq { color: #d32f2f; font-style: normal; }
.pf .pair { display: flex; gap: 0; align-items: stretch; } .pf .pair > * + * { margin-inline-start: -1px; }
.pf .pair input { border-radius: 0; } .pf .pair input:first-child { border-start-start-radius: 8px; border-end-start-radius: 8px; } .pf .pair input:last-child, .pf .pair select:last-child { border-start-end-radius: 8px; border-end-end-radius: 8px; }
.pf .ccb { width: 64px; flex: none; text-align: center; background: var(--soft); }
.pf .ro { background: #eef1f5; color: #8a93a0; text-align: center; width: 90px; flex: none; }
.pf .pair.pct .u { border: 1px solid #d5dbe4; padding: 9px 12px; background: var(--soft); border-start-start-radius: 8px; border-end-start-radius: 8px; }
.pf .sw { display: inline-flex; align-items: center; margin-inline-start: 8px; cursor: pointer; } .pf .sw input { display: none; }
.pf .sw i { width: 36px; height: 20px; background: #c9d6e3; border-radius: 10px; position: relative; transition: .2s; } .pf .sw i::after { content: ''; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; background: var(--card); border-radius: 50%; transition: .2s; }
.pf .sw input:checked + i { background: #2a9fc9; } .pf .sw input:checked + i::after { inset-inline-start: 18px; }
.pf .cnt { color: #8a93a0; } .pf .chk { flex-direction: row; align-items: center; gap: 8px; } .pf .chk input { width: auto; }
.tagbox { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid #d5dbe4; border-radius: 8px; padding: 6px 8px; min-height: 42px; }
.tagbox input { border: 0 !important; box-shadow: none !important; flex: 1; min-width: 120px; padding: 4px !important; }
.tagp { color: #fff; border-radius: 6px; padding: 3px 10px; font-size: 12px; font-weight: 600; display: inline-block; } .tagp.sm { padding: 1px 7px; font-size: 11px; } .tagp b { cursor: pointer; margin-inline-start: 4px; }
.tagpanel { position: absolute; top: 100%; inset-inline: 0; background: var(--card); border: 1px solid #d5dbe4; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.15); z-index: 5; margin-top: 4px; }
.tp-list { max-height: 220px; overflow: auto; padding: 6px; } .tp-row { padding: 6px 10px; border-radius: 6px; cursor: pointer; } .tp-row:hover, .tp-row.on { background: var(--soft); } .tp-none { padding: 10px; }
.tp-add { border-top: 1px solid #e3e8ef; padding: 10px; text-align: center; cursor: pointer; color: #1565c0; font-weight: 600; }
.pf-foot { display: flex; gap: 10px; padding: 14px 0 18px; position: sticky; bottom: 0; background: var(--card); border-top: 1px solid #e3e8ef; margin-top: 16px; }
@media (max-width: 720px) { .pf-grid { grid-template-columns: 1fr 1fr; } .pf .s2, .pf .s3 { grid-column: span 2; } .pf .s6 { grid-column: span 2; } }

/* quick "new" menu */
.qa { position: relative; }
.qa-menu { position: absolute; top: calc(100% + 8px); inset-inline-end: 0; min-width: 260px; background: #0b3157; border-radius: 12px; padding: 8px 0; box-shadow: 0 18px 40px rgba(0,0,0,.3); z-index: 50; max-height: 80vh; overflow: auto; }
.qa-item { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 14px; background: none; border: 0; color: #dbe7f3; padding: 11px 18px; font: inherit; font-size: 14px; cursor: pointer; text-align: start; }
.qa-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.qa-item i { font-style: normal; width: 24px; text-align: center; opacity: .9; }
.qa-sep { height: 1px; background: rgba(255,255,255,.14); margin: 6px 0; }

/* patient picker */
.pp-panel { position: absolute; top: 100%; inset-inline: 0; background: var(--card); border: 1px solid #d5dbe4; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.16); z-index: 30; max-height: 240px; overflow: auto; margin-top: 3px; }
.pp-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; cursor: pointer; }
.pp-row:hover, .pp-row.on { background: #eaf3fb; } .pp-row small { color: #8a93a0; } .pp-none { padding: 10px 12px; color: #8a93a0; }

@media (max-width: 860px) {
  #main { overflow-x: hidden; }
  .dfilters, .row { flex-wrap: wrap; }
  .dfilters input[type=date] { min-width: 0; max-width: 100%; }
  .card { overflow-x: auto; }
  .modal { max-width: 96vw; padding: 16px; }
  .calwrap { overflow-x: auto; }
  .tbl th, .tbl td { padding: 8px 8px; }
}
@media (max-width: 860px) { .gsearch { flex: 1 1 110px; min-width: 110px; } #topbar .row { flex: none; } }

/* phones settings */
.ph-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 14px 0; }
.ph-mode { border: 2px solid #d5dbe4; border-radius: 12px; padding: 14px; display: grid; gap: 4px; cursor: pointer; position: relative; }
.ph-mode.on { border-color: #3b8f94; background: #eaf5f5; } .ph-mode input { position: absolute; opacity: 0; } .ph-ic { font-size: 26px; } .ph-mode small { color: #6b7684; }
.ph-open { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; margin-top: 10px; padding-top: 18px; border-top: 1px solid #e3e8ef; }
.ph-qr { text-align: center; display: grid; gap: 6px; } .ph-qr svg { border: 1px solid #d5dbe4; border-radius: 10px; padding: 6px; }
.ph-info { flex: 1; min-width: 260px; display: grid; gap: 10px; } .ph-label { font-weight: 700; }
.ph-url { font-size: 18px; font-weight: 700; background: var(--soft); border-radius: 8px; padding: 10px 14px; word-break: break-all; }
.ph-steps { margin: 4px 0; padding-inline-start: 20px; line-height: 1.9; }

.ckin{position:fixed;inset:0;z-index:9999;background:linear-gradient(135deg,#3a7479,#5aa3a7);display:flex;align-items:center;justify-content:center;padding:16px}
.ck-card{background:var(--card,#fff);color:var(--text,#1c2b33);border-radius:18px;padding:28px 24px;max-width:380px;width:100%;text-align:center;display:flex;flex-direction:column;gap:12px;box-shadow:0 20px 60px #0006}
.ck-card h2{margin:0}.ck-ic{font-size:44px}.ck-big{font-size:20px;padding:16px}

.exp-banner{margin-bottom:12px}
tr.row-exp td{background:#fdecea}tr.row-soon td{background:#fff6e5}
.bf{font-size:13px;margin-bottom:4px}.lnk{font-weight:600;text-decoration:none}
.nav-bdg{margin-inline-start:auto;background:#d9822b;color:#fff;border-radius:10px;padding:0 7px;font-size:12px;line-height:18px}
.exp-banner{display:block;width:100%;box-sizing:border-box}
td.dt{white-space:nowrap}
.usr-menu .usr-item{display:block;padding:8px 12px;color:inherit;text-decoration:none;border-radius:8px}.usr-menu .usr-item:hover{background:#0001}
.pf-head{display:flex;gap:16px;align-items:center}.pf-avatar{width:56px;height:56px;border-radius:50%;background:#0e7c86;color:#fff;display:flex;align-items:center;justify-content:center;font-size:24px;font-weight:700;flex:none}

/* photo teeth */
.tooth .tbox { position: relative; display: block; width: 100%; aspect-ratio: 84/180; }
.tbox .timg { position: absolute; left: 50%; transform: translateX(-50%); display: block; }
.tbox .timg.u { bottom: 0; } .tbox .timg.l { top: 0; }
.tbox img { width: 100%; height: 100%; display: block; filter: drop-shadow(0 1px 2px rgba(60,40,20,.3)); user-select: none; }
.tbox .ov { position: absolute; inset: 0; -webkit-mask: var(--m) center/100% 100% no-repeat; mask: var(--m) center/100% 100% no-repeat; mix-blend-mode: multiply; pointer-events: none; }
.tbox .ovc { background: var(--cc); } .tbox .ovr { background: var(--rc); }
.tooth.cs-none .ovc, .tooth.rs-none .ovr { display: none; }
.tbox .gm { position: absolute; left: -4%; right: -4%; height: 20%; pointer-events: none; border-radius: 40% 40% 0 0 / 30% 30% 0 0; }
.tooth.c-extracted .tbox { opacity: .3; filter: grayscale(1); }

/* flat textbook style (matches the reference chart) */
.tooth svg path { stroke: #c9b27c; stroke-width: .9; }
.tooth svg .root { fill: var(--rc, #f0e6cd); stroke: #c9b27c; }
.tooth svg .pulp { stroke: #c9b27c; stroke-width: .8; opacity: .9; }
.tooth svg .crown { fill: var(--cc, #fffdf8); }
.tooth svg .fos { fill: rgba(190, 160, 100, .22); stroke: #d3bf92; stroke-width: .6; }
.tooth svg .fis { stroke: #cdb98c; stroke-width: .8; }
.tooth svg .gum2 { opacity: .35; }
.tooth svg.side, .tooth svg.occ { filter: none; }

/* picture chart */
.pchart { position: relative; width: 100%; max-width: 1180px; margin: 0 auto; aspect-ratio: 1577/826; direction: ltr; }
.pchart > img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; }
.pchart .ptooth, .pchart .ptooth .ov { position: absolute; inset: 0; pointer-events: none; }
.pchart .ptooth .ov { -webkit-mask-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; mix-blend-mode: multiply; }
.pchart .ovc { background: var(--cc); -webkit-mask-image: url(/static/chart-crown.png); mask-image: url(/static/chart-crown.png); }
.pchart .ovr { background: var(--rc); -webkit-mask-image: url(/static/chart-canal.png); mask-image: url(/static/chart-canal.png); }
.pchart .ptooth.cs-none .ovc, .pchart .ptooth.rs-none .ovr { display: none; }
.pchart .ptooth.c-extracted { opacity: .35; }
.pchart .phit { position: absolute; border: 0; background: transparent; cursor: pointer; padding: 0; }
.pchart .phit:hover { background: rgba(59, 143, 148, .14); }
.ptooth.cs-planned { --cc: #ee8f8f; } .ptooth.cs-incomplete { --cc: #f2c35e; } .ptooth.cs-completed { --cc: #6fcb92; } .ptooth.cs-existing { --cc: #b7a9ee; }
.ptooth.rs-planned { --rc: #ee8f8f; } .ptooth.rs-incomplete { --rc: #f2c35e; } .ptooth.rs-completed { --rc: #6fcb92; } .ptooth.rs-existing { --rc: #b7a9ee; }

.pchart .ptooth.c-extracted { opacity: 1; }
.pchart .xcover { position: absolute; inset: 0; background: rgba(255, 250, 250, .8); }
.pchart .xmark { position: absolute; inset: 0; width: 100%; height: 100%; }
.pchart .xmark path { fill: none; stroke: #c0392b; stroke-width: 5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.pchart .ptooth.rs-planned { --rc: #e5484d; } .pchart .ptooth.rs-incomplete { --rc: #f0a020; } .pchart .ptooth.rs-completed { --rc: #2eae6b; } .pchart .ptooth.rs-existing { --rc: #8b6fe0; }
.pchart .ptooth.c-extracted .ov { display: none; }
.pchart .xcover { background: rgba(255, 250, 250, .88); }
.pchart .xmark path { stroke-width: 3.5; }
.pchart .xcover { background: #fffafa; }

/* exam findings shown on the treatment chart */
.pchart .exov { opacity: .85; }
.pchart .exl { position: absolute; z-index: 2; text-align: center; font-size: clamp(8px, 1.05vw, 12px); line-height: 1.5; padding: 0 2px; background: var(--xc, #f2c35e); color: #3a2f12; border-radius: 6px; box-sizing: border-box; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.tooth .exl.sv { position: absolute; left: 50%; transform: translateX(-50%); z-index: 2; font-size: 10px; padding: 0 4px; border-radius: 6px; background: var(--xc); color: #3a2f12; white-space: nowrap; font-weight: 600; }
.tooth .exl.sv.up { bottom: 24px; } .tooth .exl.sv.low { top: 24px; }
.exnote { background: color-mix(in srgb, var(--xc, #f2c35e) 28%, #fff); border-inline-start: 4px solid var(--xc, #f2c35e); padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; font-size: 14px; }
.pchart .ptooth .exov { display: block !important; }

/* dark appearance (user menu -> المظهر) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --soft: #2d4144; --bg: #1b2a2d; --card: #243538; --ink: #e4eeee; --muted: #9db3b5; --line: #3a4e51;
  --brand: #4aa0a6; --brand-d: #7cc6cb; --brand-l: #2c4a4d;
}
:root[data-theme="dark"] #sidebar { background: #16292c; }
:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea { background: #1f3033; color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] .btn { background: #2b4144; color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] .btn.primary { background: var(--brand); color: #fff; }
:root[data-theme="dark"] .tbl tr:hover td { background: #2a3f42; }
:root[data-theme="dark"] .alert-warn, :root[data-theme="dark"] .exp-banner { background: #3b3220; color: #f1d9a3; border-color: #5a4a26; }
:root[data-theme="dark"] .pchart { background: #fffafa; border-radius: 10px; }
.usr-theme { display: flex; gap: 4px; padding: 6px 10px; align-items: center; }
.usr-theme span { font-size: 13px; color: var(--muted); margin-inline-end: 6px; }
.usr-theme button { flex: 1; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; padding: 4px 6px; font-size: 12px; cursor: pointer; }
.usr-theme button.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* note dot on examined teeth: hover the tooth to read what was written */
.pchart .exdot { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--xc); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); pointer-events: none; z-index: 3; }
.pchart .exdot::after { content: attr(data-tip); display: none; position: absolute; left: 50%; transform: translateX(-50%); min-width: 150px; max-width: 260px; white-space: pre-line; text-align: start; background: #25373a; color: #fff; font-size: 12px; line-height: 1.6; padding: 6px 10px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.3); z-index: 9; }
.pchart .exdot.up::after { top: 18px; } .pchart .exdot.lo::after { bottom: 18px; }
.pchart .phit:hover + .exdot::after, .pchart .phit:focus + .exdot::after { display: block; }
.tooth .exdot.sv { position: absolute; left: 50%; margin-left: -6px; width: 12px; height: 12px; border-radius: 50%; background: var(--xc); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); z-index: 3; }
.tooth .exdot.sv.up { top: 0; } .tooth .exdot.sv.low { bottom: 0; }
.tooth:hover .exdot.sv::after { content: attr(data-tip); position: absolute; top: 16px; left: 50%; transform: translateX(-50%); min-width: 140px; white-space: pre-line; background: #25373a; color: #fff; font-size: 12px; padding: 6px 10px; border-radius: 8px; z-index: 9; }
.pchart .exdot::after, .tooth .exdot.sv::after { font-style: normal; font-weight: 400; }
.rc-act { white-space: nowrap; }
.rc-act .rc-snooze { width: 92px; padding: 3px 6px; font-size: 13px; display: inline-block; }

/* appointment cards on the dashboard: medium size, one under the other */
.alist { display: flex; flex-direction: column; gap: 8px; }
.alist .acard { gap: 10px; padding: 10px 14px; margin: 0; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.1); align-items: flex-start; }
.alist .acard a { font-size: 15.5px; }
.alist .a-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.alist .a-name .tag, .alist .a-tags .tag { margin: 0; font-size: 11.5px; padding: 1px 8px; }
.alist .a-tags { margin-top: 5px; gap: 5px; }
.alist .a-side { gap: 6px; }
.alist .a-top { gap: 5px; }
.alist .a-top .tag.b { font-size: 11.5px; padding: 1px 8px; }
.alist .ib { width: 25px; height: 25px; font-size: 13px; border-radius: 6px; }
.alist .a-time { font-size: 13.5px; }
.alist .a-status { font-size: 12.5px; padding: 2px 7px; }
.alist .sess { padding: 4px 8px; gap: 6px; }
.alist .sess .btn.sm { padding: 3px 9px; font-size: 12px; }
.alist .sess small { font-size: 11.5px; }
.medflag { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: #fff; color: #c0392b; font-size: 13px; font-weight: 700; cursor: help; flex: none; }
.medflag::after { content: attr(data-tip); display: none; position: absolute; top: 24px; inset-inline-start: 0; min-width: 160px; max-width: 280px; white-space: pre-line; text-align: start; background: #25373a; color: #fff; font-size: 12.5px; font-weight: 400; line-height: 1.6; padding: 7px 11px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.3); z-index: 20; }
.medflag:hover::after { display: block; }
.alist .acard { align-items: stretch; }
.alist .a-body { display: flex; flex-direction: column; }
.alist .a-time { margin-top: auto; padding-top: 6px; }
.alist .ib { width: 22px; height: 22px; font-size: 11.5px; border-radius: 5px; }
.alist .a-top { gap: 4px; }
.alist .a-room { margin-top: auto; padding-top: 6px; font-size: 13px; font-weight: 700; }
.alist .a-room + .a-time { margin-top: 0; padding-top: 1px; }
.alist .acard { flex-wrap: wrap; }
.alist .a-stats { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 2px 10px; padding-top: 6px; margin-top: 2px; border-top: 1px solid rgba(255,255,255,.25); }
.alist .ast { background: none; border: 0; color: rgba(255,255,255,.72); font: inherit; font-size: 11px; padding: 1px 6px; border-radius: 10px; cursor: pointer; }
.alist .ast:hover { color: #fff; background: rgba(255,255,255,.18); }
.alist .ast.on { background: rgba(255,255,255,.92); color: var(--c); font-weight: 700; cursor: default; }
@media (min-width: 1001px) { .dgrid { grid-template-columns: minmax(0, 450px) minmax(0, 1fr); } }
.alist .a-stats { gap: 2px 1px; justify-content: space-between; } .alist .ast { font-size: 10.5px; padding: 1px 4px; }
.sbtn { width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer; font-size: 15px; line-height: 1; display: inline-grid; place-items: center; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.sbtn.play { background: #fff; color: #2f8a6a; padding-inline-start: 3px; } .sbtn.stop { background: #fff; color: #c0392b; font-size: 14px; }
.sbtn:hover { transform: scale(1.08); }
.alist .acard { position: relative; }
.alist .a-side { min-width: 112px; }
.alist .sess, .alist .sess.run { position: absolute; left: 36px; top: calc((100% - 30px) / 2); transform: translateY(-50%); padding: 0; background: none; }
.sbtn { width: 30px; height: 30px; font-size: 12px; } .sbtn.stop { font-size: 11px; }
.alist .sess, .alist .sess.run { left: 14px; }

.trays { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tray { font-size: 11.5px; padding: 1px 8px; border-radius: 10px; background: #fdecd2; color: #8a5a12; } .tray.ok { background: #d9f0e0; color: #1f6b3d; } .tray.out { background: #fbdcdc; color: #9b2c2c; }
.btn.warnb { border-color: #d29a4c; color: #8a5a12; background: #fdf3e2; }
.tray-row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 8px; } .tray-row .tn { flex: 1; } .tray-row label { display: flex; flex-direction: column; font-size: 12px; gap: 2px; } .tray-row label input { width: 64px; }
.lab-act { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; min-width: 200px; max-width: 300px; }
.tray { white-space: nowrap; }
