:root { --fg: #1f2933; --muted: #6b7280; --accent: #2563eb; --bg: #f7f8fa; --card: #fff; --warn: #b45309; --err: #b91c1c; }
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, sans-serif; color: var(--fg); background: var(--bg); }
.topbar { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; min-height: 3.5rem; padding: .5rem 1.25rem; background: var(--card); border-bottom: 1px solid #e5e7eb; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.topbar nav { display: flex; gap: .25rem; margin-inline-start: .75rem; }
.top-nav a { padding: .4rem .75rem; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: .93rem; text-decoration: none; transition: background .12s, color .12s; }
.top-nav a:hover { background: #f1f3f6; color: var(--fg); }
.top-nav a.on { background: #eff4ff; color: var(--accent); }
.topbar .who { display: inline-flex; align-items: center; gap: .4rem; margin-inline-start: auto; color: var(--muted); font-size: .9rem; }
.topbar .who .icon { width: 1.05em; height: 1.05em; }
.topbar form { margin: 0; }
.topbar button.ghost { border-color: #e5e7eb; border-radius: 8px; padding: .35rem .75rem; color: var(--fg); }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.05rem; text-decoration: none; color: var(--accent); }
@media (max-width: 640px) { .topbar .who > span { display: none; } .topbar nav { order: 3; width: 100%; margin: 0; overflow-x: auto; } }
main { padding: 1rem; max-width: 1100px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid #e5e7eb; border-radius: 8px; padding: 1.25rem; }
.narrow { max-width: 420px; margin: 2rem auto; }
.error { color: var(--err); }
.alert { color: var(--err); font-weight: 600; }
.badge.warning { color: var(--warn); font-size: .8em; }
.muted { color: var(--muted); }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: start; padding: .4rem .5rem; border-bottom: 1px solid #eee; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }

/* htmx indicators (htmx.config.includeIndicatorStyles is off: CSP style-src self) */
.htmx-indicator { opacity: 0; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; transition: opacity 200ms ease-in; }
/* console */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
a.button { display: inline-block; padding: .35rem .8rem; border-radius: 6px; background: var(--accent); color: #fff; text-decoration: none; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin: 0 0 1rem; }
.filters input { flex: 1 1 220px; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.stack input:not([type=checkbox]), .stack select { width: 100%; box-sizing: border-box; padding: .35rem; }
.stack .check { display: flex; gap: .4rem; align-items: center; }
.helptext { color: var(--muted); font-size: .85em; }
.errorlist { color: var(--err); margin: .25rem 0; padding-inline-start: 1rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin-top: 1.5rem; align-items: start; }
.narrow-wide { max-width: 560px; }
.badge { display: inline-block; font-size: .8em; padding: 0 .4rem; border-radius: 4px; background: #eef2ff; }
.badge.ok { background: #ecfdf5; color: #047857; }
.badge.off { background: #f3f4f6; color: var(--muted); }
.tag { display: inline-block; font-size: .85em; padding: 0 .35rem; margin: 1px 0; border: 1px solid #e5e7eb; border-radius: 4px; }
.tag.off { text-decoration: line-through; color: var(--muted); }
td.actions form { display: flex; gap: .35rem; flex-wrap: wrap; margin: 0; }
.pager { display: flex; gap: 1rem; justify-content: center; }
.messages { list-style: none; padding: 0; }
.messages li { padding: .5rem .75rem; border-radius: 6px; background: #ecfdf5; margin-bottom: .5rem; }
.messages li.error { background: #fef2f2; color: var(--err); }
.hx-error { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 100; display: flex; align-items: center; gap: .6rem; max-width: min(640px, calc(100vw - 2rem)); padding: .6rem .8rem; border-radius: 8px; background: #fef2f2; color: var(--err); border: 1px solid #fecaca; box-shadow: 0 8px 24px rgb(15 23 42 / .18); }
.hx-error button { flex: none; }
.hx-error .hx-error-x { background: none; color: inherit; border: 0; font-size: 1.2em; padding: 0 .2rem; }
/* patient intake */
form.intake { display: flex; flex-direction: column; gap: 1rem; }
form.intake fieldset { margin: 0; }
form.intake legend { font-weight: 600; padding: 0 .35rem; }
form.intake .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem 1rem; }
form.intake .checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: .4rem 1rem; }
form.intake .stack { gap: .6rem; }
form.intake .field { display: flex; flex-direction: column; gap: .15rem; }
form.intake .field.wide, form.intake .checks .field { grid-column: 1 / -1; }
form.intake .field input, form.intake .field select, form.intake .field textarea { width: 100%; padding: .35rem; font: inherit; }
form.intake .check { display: flex; gap: .45rem; align-items: flex-start; flex-wrap: wrap; }
form.intake .check input { margin-top: .3rem; flex: none; }
form.intake .check label { flex: 1 1 0; min-width: 0; }
form.intake .grid .check { align-self: end; padding-bottom: .4rem; }
form.intake .check .errorlist { flex-basis: 100%; }
form.intake .invalid input, form.intake .invalid select, form.intake .invalid textarea { border-color: var(--err); }
.alert-mark { color: var(--err); }
button.primary { align-self: flex-start; padding: .5rem 1.2rem; background: var(--accent); color: #fff; border: 0; border-radius: 6px; font: inherit; cursor: pointer; }
.warn-box { border-color: #f59e0b; background: #fffbeb; margin-bottom: 1rem; }
.new-person { margin-top: 1rem; display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.new-person p { margin: 0; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
.grid2.facts { margin-top: 1rem; }

/* ---- clinic shell: sidebar + breadcrumb strip (matches the original Apexo layout) ---- */
:root { --line: #e5e7eb; --side: #fff; --hover: #f1f3f6; --appts: #7c5cdb; --newp: #3b82f6; --pay: #14a39a; }
.shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100vh; }
.shell .crumbs { grid-column: 1 / -1; display: flex; align-items: center; gap: .75rem; padding: .5rem 1rem; background: var(--side); border-bottom: 1px solid var(--line); }
.crumb-back { display: inline-flex; color: var(--muted); padding: .25rem; border-radius: 6px; }
.crumb-back:hover { background: var(--hover); color: var(--fg); }
.crumb { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .8rem; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); font-size: .92em; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }
[dir=rtl] .crumb-back .icon { transform: scaleX(-1); }

.sidebar { background: var(--side); border-inline-end: 1px solid var(--line); padding: 1.25rem 0 1rem; display: flex; flex-direction: column; gap: .75rem; }
.logo { display: flex; align-items: center; gap: .9rem; padding: 0 1.25rem; text-decoration: none; color: var(--fg); font-size: 1.6rem; font-weight: 500; }
.logo img { border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.ver { font-size: .9rem; color: var(--muted); font-weight: 400; }
.me { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem 1.25rem; border-block: 1px solid var(--line); }
.me-name { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me form, .sidebar form.switch { margin: 0; }
.sidebar form.switch { padding: 0 1.25rem; }
button.ghost { display: inline-flex; align-items: center; gap: .35rem; background: none; border: 1px solid var(--line); border-radius: 6px; padding: .3rem .7rem; font: inherit; font-size: .9em; color: var(--fg); cursor: pointer; }
button.ghost:hover { background: var(--hover); }
button.ghost.wide { width: 100%; justify-content: center; }
.side-nav { display: flex; flex-direction: column; }
.side-nav a, .side-nav .soon { display: flex; align-items: center; gap: .85rem; padding: .7rem 1.5rem; color: var(--fg); text-decoration: none; border-inline-start: 4px solid transparent; }
.side-nav .icon { width: 1.35em; height: 1.35em; color: #4b5563; }
.side-nav a:hover { background: var(--hover); }
.side-nav a.on { background: #eceef2; border-inline-start-color: var(--accent); font-weight: 600; }
.side-nav .soon { color: #9ca3af; cursor: default; }
.side-nav .soon .icon { color: #c0c5cc; }

.page { min-width: 0; display: flex; flex-direction: column; }
.page main { max-width: none; width: 100%; margin: 0; padding: 0 1.5rem 1.5rem; }
header.hello { display: flex; align-items: baseline; gap: .6rem; padding: 1.25rem 1.5rem .75rem; font-size: 1.5rem; }
header.hello .icon { align-self: center; color: #4b5563; }
.hello-clinic { font-size: .95rem; color: var(--accent); }

/* ---- dashboard ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.stat { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.4rem; border-radius: 6px; color: #fff; text-decoration: none; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.stat .stat-icon { width: 2.6rem; height: 2.6rem; flex: none; opacity: .9; }
.stat span { display: flex; flex-direction: column; }
.stat b { font-size: 1.9rem; font-weight: 500; line-height: 1.15; }
.stat b small { font-size: .55em; font-weight: 400; }
.stat i { font-style: normal; opacity: .92; }
.s-appts { background: var(--appts); } .s-new { background: var(--newp); } .s-pay { background: var(--pay); }
a.stat:hover { filter: brightness(1.06); }
.now { display: flex; gap: 1.25rem; margin: 1.25rem 0 .5rem; font-size: 1.05rem; color: #374151; }

.columns { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(190px, 1fr); overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 6px; }
.col { border-inline-start: 1px solid var(--line); padding: .25rem 0 .75rem; min-width: 0; }
.col:first-child { border-inline-start: 0; }
.col h2 { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: 0; padding: .8rem 1rem; font-size: 1.02rem; font-weight: 500; border-bottom: 1px solid var(--line); }
.col h2 .icon { color: #6b7280; width: 1.3em; height: 1.3em; }
ul.people { list-style: none; margin: 0; padding: 0; }
ul.people li { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; padding: .65rem 1rem; border-bottom: 1px solid #f0f1f3; }
ul.people li.none { justify-content: center; padding: 1.5rem 1rem; color: var(--muted); border: 0; }
.who { min-width: 0; }
.who .sub, .who p.sub { margin: .15rem 0 0; color: var(--muted); font-size: .88em; overflow-wrap: anywhere; }
.who.folder { display: flex; gap: .7rem; align-items: center; }
.who.folder > .icon { width: 2rem; height: 2rem; color: #9ca3af; }
.who.folder > span { display: flex; flex-direction: column; }
.lab { font-weight: 500; }
.person { display: inline-flex; align-items: center; gap: .45rem; text-decoration: none; color: inherit; }
.dot { width: 1.6rem; height: 1.6rem; border-radius: 50%; flex: none; }
.nm { padding: .05rem .45rem; border-radius: 4px; font-weight: 500; }
.done .icon { color: #16a34a; margin-inline-end: .25rem; }
.time { display: inline-flex; align-items: center; gap: .25rem; white-space: nowrap; font-size: .85em; color: #374151; }
/* eight name tones: dot is solid, name gets a pale wash of the same hue */
.dot.t0 { background: #ef4444; } .nm.t0 { background: #fee2e2; }
.dot.t1 { background: #f59e0b; } .nm.t1 { background: #fef3c7; }
.dot.t2 { background: #10b981; } .nm.t2 { background: #d1fae5; }
.dot.t3 { background: #3b82f6; } .nm.t3 { background: #dbeafe; }
.dot.t4 { background: #8b5cf6; } .nm.t4 { background: #ede9fe; }
.dot.t5 { background: #ec4899; } .nm.t5 { background: #fce7f3; }
.dot.t6 { background: #14b8a6; } .nm.t6 { background: #ccfbf1; }
.dot.t7 { background: #84cc16; } .nm.t7 { background: #ecfccb; }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-inline-end: 0; border-bottom: 1px solid var(--line); padding-block: .75rem; }
  .side-nav { flex-direction: row; flex-wrap: wrap; padding: 0 .5rem; }
  .side-nav a, .side-nav .soon { padding: .45rem .7rem; border-inline-start: 0; border-bottom: 3px solid transparent; }
  .side-nav a.on { border-bottom-color: var(--accent); }
  .side-nav .soon { display: none; }
  .page main, header.hello { padding-inline: 16px; }
  .columns { grid-auto-flow: row; grid-auto-columns: auto; }
  .col { border-inline-start: 0; border-top: 1px solid var(--line); }
  .col:first-child { border-top: 0; }
}

/* --- Patients list (§9) ------------------------------------------------------------------ */
:root { --tool: #2563eb; --unset: #ea7a1a; --pill: #eef2f7; }
.plist { padding-block: 1rem 2rem; }
.ptools { display: flex; gap: 1.25rem; align-items: center; margin-block-end: 1rem; }
.tool { display: inline-flex; align-items: center; gap: .4rem; color: var(--fg); text-decoration: none; font-weight: 500; padding: .35rem .2rem; }
.tool .icon { width: 1.2rem; height: 1.2rem; color: var(--tool); }
a.tool:hover { color: var(--tool); }
.tool.off { color: var(--muted); cursor: not-allowed; }
.tool.off .icon { color: var(--muted); }
.pfind { display: flex; flex-direction: column; gap: .75rem; margin: 0 0 .75rem; }
.psearch { display: flex; align-items: center; gap: .6rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .2rem 1rem; }
.psearch .icon { width: 1.25rem; height: 1.25rem; color: var(--muted); flex: none; }
.psearch input { border: 0; outline: 0; background: none; flex: 1; min-width: 0; font: inherit; font-size: 1.05rem; padding: .75rem 0; color: var(--fg); }
.psearch:focus-within { border-color: var(--tool); box-shadow: 0 0 0 3px #2563eb22; }
.ptreat { font: inherit; font-size: .9em; padding: .4rem .7rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); }
.psort { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-block-end: 1rem; }
.pills { display: flex; flex-wrap: wrap; gap: .4rem; }
.pill { padding: .35rem .85rem; border-radius: 6px; background: var(--pill); color: var(--fg); text-decoration: none; font-size: .9em; border: 1px solid transparent; }
.pill:hover { border-color: var(--line); background: var(--hover); }
.pill.on { background: var(--tool); color: #fff; }
.pcards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.pcard { display: flex; align-items: center; gap: 1rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; }
.pcard:hover { box-shadow: 0 2px 8px #0000000d; }
.pmain { flex: 1; min-width: 0; }
.pmain .person { margin-block-end: .55rem; }
.pfacts { display: flex; flex-wrap: wrap; gap: .4rem 1.75rem; margin: 0; }
.pfacts > div { min-width: 0; }
.pfacts dt { display: flex; align-items: center; gap: .3rem; font-size: .75em; color: var(--muted); }
.pfacts dt .icon { width: .95rem; height: .95rem; }
.pfacts dd { margin: .1rem 0 0; font-size: .9em; white-space: nowrap; }
.pfacts dd small { font-size: .78em; color: var(--muted); }
.pfacts .unset dt .icon, .pfacts .unset dd { color: var(--unset); }
.pfacts .hot dt .icon { color: var(--tool); }
.ptag { display: inline-block; padding: 0 .45rem; margin-inline-end: .25rem; border-radius: 4px; background: var(--pill); font-size: .9em; }
.teeth { list-style: none; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .3rem; margin: 0; padding: 0; max-width: 12rem; }
.tb { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 1.9rem; height: 1.9rem; border-radius: 6px; }
.tb .icon { width: 1.25rem; height: 1.25rem; }
.tb span { position: absolute; inset-block-end: -.3rem; inset-inline-end: -.3rem; min-width: 1rem; padding: 0 .2rem; border-radius: 999px; background: var(--card); border: 1px solid currentColor; font-size: .65rem; line-height: 1rem; text-align: center; }
.c-filled { background: #e0ecff; color: #2563eb; }
.c-endo { background: #efe7ff; color: #7c3aed; }
.c-compromised { background: #fde2ec; color: #db2777; }
.c-missing { background: #eceff3; color: #6b7280; }
.c-rotated, .c-displaced { background: #fff1e0; color: #c2620c; }
.c-gum-recessed { background: #fce7f3; color: #be185d; }
.c-caries, .c-abscess, .c-fractured { background: #fef2f2; color: #b91c1c; }
.c-crown, .c-bridge, .c-implant, .c-veneer, .c-inlay, .c-denture { background: #eef2f7; color: #334155; }
.c-pulpotomy { background: #efe7ff; color: #7c3aed; }
.c-attrition, .c-abrasion, .c-erosion { background: #fef3c7; color: #92400e; }
.c-impacted, .c-root { background: #f5f5f4; color: #57534e; }
.pcards .none { padding: 2rem; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: 8px; }
.pmore { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-block-start: 1rem; color: var(--muted); font-size: .9em; }
@media (max-width: 800px) {
  .pcard { flex-direction: column; align-items: stretch; }
  .teeth { justify-content: flex-start; max-width: none; }
  .pfacts { gap: .4rem 1.1rem; }
}

/* --- Patient workspace (§9): treatments + chart in the middle, patient panel on the side --- */
:root { --invisit: #fce7f3; --invisit-line: #ec4899; --sel: #2563eb; }
.pw { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.treat, .ppanel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; min-width: 0; }
.treat-head { display: flex; align-items: center; gap: .75rem; }
.treat-head h1 { margin: 0; font-size: 1.15rem; }
.treat-head p { margin: .1rem 0 0; color: var(--muted); }
.treat-head .chip { margin-inline-start: auto; }
.icon.big { width: 1.8em; height: 1.8em; color: var(--accent); }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .75rem; border: 1px solid var(--line); border-radius: 999px; color: var(--fg); text-decoration: none; font-size: .9em; background: var(--card); }
.chip:hover { background: var(--hover); }
.chip.on { background: #e8efff; border-color: #c7d6fb; color: var(--accent); }
.treat .alert { background: #fef2f2; padding: .4rem .7rem; border-radius: 6px; margin: .75rem 0 0; }
.st { font-weight: 600; font-size: .85em; padding: 0 .45rem; border-radius: 4px; }
.st-done { color: #15803d; background: #dcfce7; }
.st-missed { color: var(--err); background: #fee2e2; }
.st-upcoming { color: #1d4ed8; background: #dbeafe; }

/* timeline */
.tl-row { display: flex; align-items: center; gap: .75rem; margin: 1rem 0 .5rem; }
.tl-row form { flex: none; }
.timeline { flex: 1; display: flex; list-style: none; margin: 0; padding: 1.4rem .25rem .25rem; overflow-x: auto; scrollbar-width: thin; }
.tl { position: relative; flex: none; min-width: 5.2rem; text-align: center; }
.tl::before { content: ""; position: absolute; top: .55rem; inset-inline: 0; border-top: 2px solid var(--line); }
.tl:first-child::before { inset-inline-start: 50%; }
.tl:last-child::before { inset-inline-end: 50%; }
.tl a { position: relative; display: flex; flex-direction: column; align-items: center; gap: .3rem; color: var(--muted); text-decoration: none; font-size: .8em; }
.tl .dotx { width: 1.1rem; height: 1.1rem; border-radius: 50%; background: #9ca3af; border: 3px solid var(--card); box-shadow: 0 0 0 1px #d1d5db; box-sizing: border-box; }
.tl.done .dotx { background: #22c55e; }
.tl.missed .dotx { background: #ef4444; }
.tl.upcoming .dotx { background: #3b82f6; }
.tl.on .dotx { box-shadow: 0 0 0 3px var(--sel); }
.tl.on .when { color: var(--fg); font-weight: 600; }
.tl .gap { position: absolute; top: -1.3rem; inset-inline-start: -.9rem; font-size: .72em; color: var(--muted); background: var(--pill); padding: 0 .3rem; border-radius: 4px; }
.tl-none { color: var(--muted); }

/* chart */
.chart-bar { display: flex; justify-content: space-between; align-items: center; margin: .5rem 0; color: var(--muted); font-size: .9em; }
.chart-bar b { color: var(--fg); }
.chart { display: grid; grid-template-columns: 1fr 1fr; padding: .5rem 0; }
.half { display: flex; }
.half.r { justify-content: flex-end; border-inline-end: 2px solid #374151; }
.half.up { border-bottom: 2px solid #374151; padding-bottom: .2rem; }
.half.down { padding-top: .2rem; }
.tt { position: relative; flex: 1 1 0; max-width: 3.4rem; min-width: 0; display: flex; flex-direction: column; align-items: center; padding: .2rem .1rem; border-radius: 6px; color: var(--fg); text-decoration: none; }
.tt:hover { background: var(--hover); }
.tt .tooth { width: 100%; height: 5.4rem; }
.chart.primary .tt .tooth { height: 4.4rem; }
.tt .num { font-size: .8em; font-weight: 600; color: #4b5563; line-height: 1.4; }
.tooth .root { fill: #f5f1e8; stroke: #a8a29e; stroke-width: 1; }
.tooth .crown { fill: #fff; stroke: #78716c; stroke-width: 1.2; }
.tooth .canal { fill: none; stroke: none; }
.tooth .fill { fill: none; }
.tt.c-filled .fill { fill: #FFE082; stroke: #d4a20a; }
.tt.c-endo .root { fill: #D1C4E9; }
.tt.c-endo .canal { stroke: #6d28d9; stroke-width: 2; }
.tt.c-compromised .crown { fill: #FFCDD2; }
.tt.c-rotated .crown { fill: #B2EBF2; }
.tt.c-displaced .crown { fill: #b2dfdb; }
.tt.c-gum-recessed .root { fill: #F48FB1; }
.tt.c-missing .tooth { opacity: .22; }
.tt.c-caries .fill { fill: #7c4a1e; stroke: #4a2c11; }
.tt.c-fractured .crown { fill: #fee2e2; stroke: #dc2626; stroke-dasharray: 3 2; }
.tt.c-abscess .root { fill: #fca5a5; stroke: #dc2626; }
.tt.c-impacted .tooth { opacity: .5; }
.tt.c-impacted .crown, .tt.c-impacted .root { stroke-dasharray: 3 2; }
.tt.c-root .crown { fill: none; stroke: #d6d3d1; stroke-dasharray: 2 2; }
.tt.c-crown .crown { fill: #cbd5e1; stroke: #475569; stroke-width: 1.6; }
.tt.c-veneer .crown { fill: #e0f2fe; stroke: #0284c7; stroke-width: 2; }
.tt.c-bridge .crown { fill: #e2e8f0; stroke: #334155; stroke-width: 1.6; }
.tt.c-bridge .root { opacity: .35; }
.tt.c-implant .root { fill: #9ca3af; stroke: #4b5563; }
.tt.c-implant .crown { fill: #e5e7eb; stroke: #4b5563; }
.tt.c-inlay .fill { fill: #FFE082; stroke: #d4a20a; stroke-width: 1.4; }
.tt.c-attrition .crown { fill: #fef3c7; stroke: #b45309; stroke-width: 1.6; }
.tt.c-abrasion .root { fill: #fde68a; stroke: #b45309; }
.tt.c-erosion .crown { fill: #fefce8; stroke: #ca8a04; stroke-dasharray: 3 2; }
.tt.c-pulpotomy .root { fill: #ede9fe; }
.tt.c-pulpotomy .canal { stroke: #7c3aed; stroke-width: 2; stroke-dasharray: 3 3; }
.tt.c-denture .root { opacity: .15; }
.tt.c-denture .crown { fill: #fce7f3; stroke: #db2777; stroke-width: 1.4; }
/* restoration material: amalgam and metals draw grey, tooth-coloured materials pale */
.tt.m-amalgam .fill, .tt.m-metal .fill { fill: #9ca3af; stroke: #4b5563; }
.tt.m-gold .fill, .tt.m-gold .crown { fill: #fcd34d; stroke: #a16207; }
.tt.m-composite .fill, .tt.m-ceramic .fill, .tt.m-gic .fill { fill: #fef9ef; stroke: #d4a20a; }
.tt.m-temporary .fill { fill: #fff; stroke: #d4a20a; stroke-dasharray: 2 2; }
.tt.in-visit { background: var(--invisit); box-shadow: inset 0 0 0 1px var(--invisit-line); }
.tt.sel { box-shadow: inset 0 0 0 2px var(--sel); }
.tt .lbl { position: absolute; top: .4rem; inset-inline-start: 50%; transform: translateX(-50%); writing-mode: vertical-rl; font-size: .68em; font-weight: 600; padding: .2rem .05rem; border-radius: 3px; background: rgba(255, 255, 255, .85); color: #374151; pointer-events: none; }
.half.down .tt .lbl { top: auto; bottom: .4rem; }
.tt .nt { position: absolute; top: .1rem; inset-inline-end: .1rem; font-size: .62em; background: var(--accent); color: #fff; border-radius: 999px; min-width: 1.1em; text-align: center; }
.half.down .tt .nt { top: auto; bottom: .1rem; }

/* tooth panel */
.tooth-panel { border: 1px solid #c7d6fb; background: #f8faff; border-radius: 8px; padding: .75rem 1rem; margin: .75rem 0; }
.tooth-panel header { display: flex; justify-content: space-between; align-items: center; }
.tooth-panel h2 { font-size: 1rem; margin: 0; }
.tooth-panel h3 { font-size: .9rem; margin: .75rem 0 .3rem; }
.tooth-panel .x { color: var(--muted); text-decoration: none; padding: .1rem .4rem; border-radius: 4px; }
.tooth-panel .x:hover { background: var(--hover); }
.conds { display: flex; flex-wrap: wrap; gap: .35rem; margin: .6rem 0; }
.cond { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: .2rem .7rem; font: inherit; font-size: .85em; cursor: pointer; }
.cond.on { border-color: #374151; font-weight: 700; }
.cond.c-filled { background: #FFE082; } .cond.c-endo { background: #D1C4E9; } .cond.c-compromised { background: #FFCDD2; }
.cond.c-missing { background: #BDBDBD; } .cond.c-rotated { background: #B2EBF2; } .cond.c-displaced { background: #b2dfdb; } .cond.c-gum-recessed { background: #F48FB1; }
.cond.c-caries { background: #e7c9a9; } .cond.c-fractured { background: #fee2e2; } .cond.c-abscess { background: #fca5a5; }
.cond.c-impacted { background: #e5e7eb; } .cond.c-root { background: #f5f1e8; } .cond.c-crown { background: #cbd5e1; }
.cond.c-inlay { background: #FFE082; } .cond.c-pulpotomy { background: #ede9fe; } .cond.c-denture { background: #fce7f3; }
.cond.c-attrition, .cond.c-abrasion, .cond.c-erosion { background: #fef3c7; }
.cond.c-veneer { background: #bae6fd; } .cond.c-bridge { background: #e2e8f0; } .cond.c-implant { background: #d1d5db; }
.conds { flex-direction: column; align-items: stretch; gap: .45rem; }
.cgroup { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.cgroup-name { flex: 0 0 9.5rem; font-size: .78em; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.tp-now { margin: .5rem 0 0; font-size: .92em; }
.tp-cond { padding: .05rem .5rem; border-radius: 999px; }
.surfs { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem; margin: .2rem 0 .6rem; }
.surfs fieldset { display: flex; flex-wrap: wrap; gap: .3rem; border: 0; margin: 0; padding: 0; }
.tp-material { display: flex; flex-direction: column; gap: .2rem; font-size: .78em; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.tp-material select { font-size: 1.25em; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--fg); }
.surfs legend { padding: 0; margin-bottom: .3rem; font-size: .78em; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.surf { position: relative; cursor: pointer; }
.surf input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.surf span { display: inline-flex; align-items: baseline; gap: .3rem; padding: .2rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); font-size: .85em; }
.surf input:checked + span { background: #dbeafe; border-color: var(--accent); color: #1e3a8a; }
.surf input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.tp-hist { margin: .5rem 0 0; font-size: .88em; }
.tp-hist summary { cursor: pointer; color: var(--muted); }
.tp-hist ul { list-style: none; margin: .3rem 0 0; padding: 0; }
.tp-hist li { padding: .15rem 0; }
.tp-hist small { color: var(--muted); }
@media (max-width: 640px) { .cgroup-name { flex-basis: 100%; } }
.tnotes { list-style: none; margin: 0; padding: 0; }
.tnotes li { display: flex; flex-direction: column; padding: .3rem 0; border-bottom: 1px dashed var(--line); }
.tnotes small { color: var(--muted); }
.addnote { display: flex; gap: .4rem; margin-top: .5rem; }
.addnote input { flex: 1; min-width: 0; font: inherit; padding: .35rem .5rem; border: 1px solid #d1d5db; border-radius: 6px; }
.small { font-size: .85em; }

/* visit editor */
.op { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .75rem; }
.op fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .7rem; min-width: 0; }
.op label { display: flex; flex-direction: column; gap: .25rem; font-size: .9em; color: #374151; }
.op input[type=text], .op input[type=number], .op input[type=datetime-local], .op select, .op textarea { font: inherit; padding: .4rem .55rem; border: 1px solid #d1d5db; border-radius: 6px; background: var(--card); width: 100%; box-sizing: border-box; }
.op-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.op-head h2 { margin: 0; font-size: 1rem; display: flex; align-items: center; gap: .4rem; }
.op label.isdone { flex-direction: row; align-items: center; font-weight: 600; color: #15803d; }
.op-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.op-grid.money { grid-template-columns: repeat(2, minmax(0, 12rem)); }
.op .pre span { font-weight: 600; }
.docs { display: flex; flex-wrap: wrap; gap: .4rem .9rem; align-items: center; font-size: .9em; }
.docs > span { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); }
.op label.pick { flex-direction: row; align-items: center; gap: .3rem; padding: .15rem .6rem; border: 1px solid var(--line); border-radius: 999px; }
.vteeth { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; font-size: .9em; }
.vteeth .ptag { background: var(--invisit); color: #9d174d; text-decoration: none; }
.op-actions { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-top: 1rem; }
.op-actions button.primary { align-self: auto; display: inline-flex; align-items: center; gap: .35rem; }
details.danger summary { cursor: pointer; color: var(--err); display: inline-flex; align-items: center; gap: .3rem; padding: .35rem .2rem; list-style: none; }
details.danger summary::-webkit-details-marker { display: none; }
button.danger { margin-top: .4rem; background: var(--err); color: #fff; border: 0; border-radius: 6px; padding: .4rem .9rem; font: inherit; cursor: pointer; }
.empty { color: var(--muted); text-align: center; padding: 1.5rem 0; }

/* patient panel */
.ppanel { position: sticky; top: 1rem; }
.pp-head { display: flex; align-items: center; gap: .6rem; }
.pp-head .person { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; min-width: 0; }
.pp-head .dot { width: 1.1rem; height: 1.1rem; }
.pp-tabs { display: flex; gap: .25rem; margin: .8rem 0; border-bottom: 1px solid var(--line); }
.pp-tabs a { display: inline-flex; align-items: center; gap: .3rem; padding: .4rem .6rem; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: .9em; }
.pp-tabs a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.vcards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; max-height: 70vh; overflow-y: auto; }
.vcard { display: flex; flex-direction: column; gap: .2rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; color: var(--fg); text-decoration: none; }
.vcard:hover { background: var(--hover); }
.vcard.on { border-color: var(--sel); box-shadow: 0 0 0 1px var(--sel); background: #f8faff; }
.vc-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .9em; }
.vc-meta { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); font-size: .82em; }
.vc-notes { font-size: .85em; color: #374151; }
.ppanel h2 { font-size: .95rem; margin: 1rem 0 .3rem; }
.ppanel .hist { margin: 0; padding-inline-start: 1.1rem; font-size: .88em; }
dl.pfields { display: grid; grid-template-columns: max-content 1fr; gap: .35rem .8rem; margin: .5rem 0 0; font-size: .9em; }
dl.pfields dt { color: var(--muted); }
dl.pfields dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .pw { grid-template-columns: minmax(0, 1fr); }
  .ppanel { position: static; }
}
@media (max-width: 600px) {
  .treat, .ppanel { padding: .75rem; }
  .tt .tooth { height: 3.6rem; }
  .tt .lbl { font-size: .58em; }
  .tt .num { font-size: .7em; }
  .op-grid, .op-grid.money { grid-template-columns: minmax(0, 1fr); }
  .treat-head .chip { display: none; }
}

/* Patient details: edit form in the side panel */
.pdetails-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .4rem; }
.pdetails-head p { margin: 0; }
a.button.ghost { display: inline-flex; align-items: center; gap: .35rem; background: none; color: var(--fg); border: 1px solid var(--line); padding: .3rem .7rem; font-size: .9em; }
a.button.ghost:hover { background: var(--hover); }
form.pedit fieldset { border: 0; border-top: 1px solid var(--line); margin: 0 0 .6rem; padding: .5rem 0 0; min-width: 0; }
form.pedit legend { font-weight: 600; padding: 0 .3rem 0 0; }
form.pedit .helptext { display: block; }
form.pedit .field { display: flex; flex-direction: column; gap: .15rem; margin-bottom: .5rem; }
form.pedit .field input, form.pedit .field select, form.pedit .field textarea { width: 100%; box-sizing: border-box; padding: .35rem; font: inherit; }
form.pedit .check { display: flex; gap: .45rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: .5rem; }
form.pedit .check input { margin-top: .25rem; flex: none; }
form.pedit .check label { flex: 1 1 0; min-width: 0; }
form.pedit .check .errorlist { flex-basis: 100%; }
form.pedit .invalid input, form.pedit .invalid select, form.pedit .invalid textarea { border-color: var(--err); }
.pedit-actions { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: .5rem; padding: .6rem 0; background: var(--card, var(--bg)); border-top: 1px solid var(--line); }

/* Appointments: toolbar, week strip, day list */
.cal { background: var(--card); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.cal-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem .9rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.cal-new summary { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; padding: .3rem .5rem; border-radius: 6px; list-style: none; }
.cal-new summary::-webkit-details-marker { display: none; }
.cal-new summary:hover { background: var(--hover); }
.cal-new[open] summary { background: var(--hover); }
.cal-newform { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.6fr) minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: .6rem; align-items: end; padding: .6rem .2rem .2rem; }
.cal-newform label { display: flex; flex-direction: column; gap: .2rem; font-size: .9em; min-width: 0; }
.cal-newform select, .cal-newform input { width: 100%; box-sizing: border-box; padding: .35rem; font: inherit; }
.cal-new[open] { flex-basis: 100%; }
.cal-doc select { padding: .4rem .6rem; min-width: 12rem; font: inherit; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); }
.cal-week { padding: .6rem .9rem .3rem; border-bottom: 1px solid var(--line); }
.cal-month { display: flex; align-items: center; gap: .75rem; }
.cal-month b { flex: 1; font-weight: 500; }
.cal-arrow { text-decoration: none; color: var(--fg); font-size: 1.4em; line-height: 1; padding: 0 .5rem; border-radius: 6px; }
.cal-arrow:hover { background: var(--hover); }
.cal-w { background: #525252; color: #fff; font-weight: 600; font-size: .85em; border-radius: 4px; padding: .2rem .5rem; }
.cal-days { list-style: none; margin: .4rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-day { display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: .25rem 0; text-decoration: none; color: var(--fg); border-radius: 8px; }
.cal-day:hover { background: var(--hover); }
.cal-day .dn { font-weight: 600; font-size: .85em; }
.cal-day .dd { width: 2.3rem; height: 2.3rem; display: grid; place-items: center; border-radius: 50%; background: #e5e7eb; }
.cal-day.today .dd { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day.on .dd { background: var(--accent); color: #fff; box-shadow: none; }
.cal-day .dc { font-size: .7em; font-style: italic; color: #db2777; margin-top: -.5rem; background: var(--card); border-radius: 999px; padding: 0 .3rem; }
.cal-day.on .dc { color: var(--accent); }
.cal-day .dc.zero { visibility: hidden; }
.cal-dayhead { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .9rem; border-bottom: 1px solid var(--line); }
.cal-dayhead > span { display: inline-flex; align-items: center; gap: .35rem; }
.cal-list { list-style: none; margin: 0; padding: 0; }
.cal-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: .75rem; padding: .55rem .9rem; border-bottom: 1px solid var(--line); background: #f3f6fa; }
.cal-row.open { background: #e8efff; box-shadow: inset 3px 0 0 var(--accent); }
.cal-tick { margin: 0; }
.tick { width: 1.8rem; height: 1.8rem; display: grid; place-items: center; border: 1.5px solid #9ca3af; border-radius: 6px; background: var(--card); color: #9ca3af; cursor: pointer; padding: 0; }
.tick .icon { width: 1rem; height: 1rem; }
.tick.on { background: var(--accent); border-color: var(--accent); color: #fff; }
button.tick:hover { border-color: var(--accent); }
.cal-main { display: flex; flex-direction: column; gap: .3rem; text-decoration: none; color: inherit; min-width: 0; }
.cal-main .dot { width: 1.7rem; height: 1.7rem; }
.cal-main:hover .nm { text-decoration: underline; }
.cal-note { font-size: .85em; color: var(--muted); padding-inline-start: 2.2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-row.done .cal-note { color: var(--fg); }
.cal-tags { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; }
.ctag { display: inline-flex; align-items: center; gap: .25rem; font-size: .78em; border-radius: 999px; padding: .1rem .55rem; border: 1px solid #93c5fd; background: #dbeafe; color: #1d4ed8; white-space: nowrap; }
.ctag .icon { width: .95rem; height: .95rem; }
.ctag.tooth { border-radius: 6px; background: #f9a8d4; border-color: #f472b6; color: #831843; padding: .2rem .3rem; }
.ctag.tooth .icon { width: 1.15rem; height: 1.15rem; }
.ctag sup { font-size: .75em; }
.cal-side { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; min-width: 6.5rem; }
.cal-time { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.cal-money { font-size: .85em; white-space: nowrap; }
.cal-empty { padding: 1.5rem .9rem; text-align: center; }
.cal-total { margin: 0; padding: .6rem .9rem; text-align: end; }

/* The patient workspace opened over the calendar */
.calwin-shade { position: fixed; inset: 0; background: rgb(15 23 42 / .18); z-index: 30; }
.calwin { position: fixed; top: .75rem; right: .75rem; bottom: .75rem; width: min(1320px, calc(100vw - 520px)); overflow: auto; z-index: 40; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 50px rgb(15 23 42 / .25); padding: .75rem; }
.calwin .ppanel { position: static; }
a.button.calwin-x { display: inline-flex; align-items: center; gap: .3rem; background: #1f2937; color: #fff; font-size: .9em; padding: .3rem .75rem; }
@media (max-width: 1100px) {
  .calwin { left: .5rem; right: .5rem; top: .5rem; bottom: .5rem; width: auto; }
}
@media (max-width: 760px) {
  .cal-newform { grid-template-columns: minmax(0, 1fr); }
  .cal-doc select { min-width: 0; max-width: 100%; }
  .cal-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .cal-tags { grid-column: 2; flex-direction: row; justify-content: flex-start; }
  .cal-side { grid-column: 3; grid-row: 1; min-width: 0; }
  .cal-note { padding-inline-start: 0; }
  .cal-day .dd { width: 2rem; height: 2rem; }
  .calwin { left: 0; right: 0; top: 0; bottom: 0; border-radius: 0; padding: .4rem; }
}

/* New patient dialog, over the patients list */
.nd-shade { position: fixed; inset: 0; z-index: 40; background: rgba(17, 24, 39, .45); cursor: default; }
.nd { position: fixed; z-index: 41; top: 14vh; left: 50%; transform: translateX(-50%); width: min(400px, calc(100vw - 2rem));
      max-height: 80vh; display: flex; flex-direction: column; background: #f3f3f3; border-radius: 6px;
      box-shadow: 0 18px 40px rgba(0, 0, 0, .25), 0 2px 6px rgba(0, 0, 0, .12); overflow: hidden; }
.nd-body { padding: 1.1rem 1.25rem 1.25rem; overflow-y: auto; }
.nd h2 { display: flex; align-items: center; gap: .45rem; margin: 0 0 1rem; font-size: 1.15rem; font-weight: 500; }
.nd h2 .icon { width: 1.3rem; height: 1.3rem; }
.nd-form { display: flex; flex-direction: column; gap: .9rem; }
.nd-f { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; color: #374151; }
.nd-f input { box-sizing: border-box; width: 100%; padding: .5rem .6rem; font: inherit; font-size: 1rem; color: var(--fg);
              background: #fff; border: 1px solid #cfd2d6; border-radius: 4px; }
.nd-f input::placeholder { color: #a3a8b0; }
.nd-f input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37, 99, 235, .18); }
.nd-more { font-size: .85rem; }
.nd-more summary { cursor: pointer; color: var(--muted); list-style: none; }
.nd-more summary::-webkit-details-marker { display: none; }
.nd-more summary::before { content: "+ "; }
.nd-more[open] summary::before { content: "− "; }
.nd-more[open] { display: flex; flex-direction: column; gap: .75rem; }
.nd-error { display: flex; align-items: center; gap: .4rem; margin: .9rem 0 0; padding: .5rem .65rem; border-radius: 4px;
            background: #fef2f2; border: 1px solid #fecaca; color: var(--err); font-size: .88rem; }
.nd-found { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid #dfe1e4; }
.nd-found h3 { margin: 0 0 .5rem; font-size: .9rem; font-weight: 600; color: var(--warn); }
.nd-found ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.nd-found li { display: grid; grid-template-columns: 1fr auto; gap: .2rem .6rem; align-items: center; padding: .55rem .65rem;
               background: #fff; border: 1px solid #e3e5e8; border-radius: 4px; }
.nd-found li form { margin: 0; grid-row: 1 / span 2; grid-column: 2; }
.nd-who { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; min-width: 0; }
.nd-meta { grid-column: 1; font-size: .8rem; color: var(--muted); }
a.nd-act, button.nd-act { grid-row: 1 / span 2; grid-column: 2; display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .65rem;
          font: inherit; font-size: .85rem; border-radius: 4px; border: 1px solid var(--line); background: #fff; color: var(--fg); text-decoration: none; cursor: pointer; }
a.nd-act:hover, button.nd-act:hover { background: var(--hover); }
.nd-match { font-size: .72rem; font-weight: 600; padding: .05rem .45rem; border-radius: 999px; background: #fef3c7; color: var(--warn); }
.nd-other { display: inline-block; margin-top: .7rem; font-size: .88rem; color: var(--accent); text-decoration: none; }
.nd-other:hover { text-decoration: underline; }
.nd-foot { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; padding: 1.25rem; background: #fff; }
.nd-save, .nd-cancel { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .55rem .9rem;
                       font: inherit; font-size: .95rem; font-weight: 500; border: 0; border-radius: 4px; text-decoration: none; cursor: pointer; }
.nd-save { background: var(--accent); color: #fff; }
.nd-save:hover { background: #1d4ed8; }
.nd-save:disabled { background: #c4c6c9; color: #f4f4f5; cursor: not-allowed; }
.nd-save .icon { width: 1.05rem; height: 1.05rem; }
.nd-cancel { background: #2b2b2b; color: #fff; }
.nd-cancel:hover { background: #111; }
.nd-pair { display: grid; grid-template-columns: minmax(7.5rem, 2fr) 3fr; gap: .5rem; }
.nd-f select { box-sizing: border-box; width: 100%; padding: .5rem .5rem; font: inherit; font-size: 1rem; color: var(--fg);
               background: #fff; border: 1px solid #cfd2d6; border-radius: 4px; }
.nd-f select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37, 99, 235, .18); }

/* Import patients dialog (wider: the preview is a table) */
.nd-wide { width: min(760px, calc(100vw - 2rem)); top: 8vh; }
.nd-wide .nd-body { max-height: 70vh; }
.nd-f input[type=file] { padding: .4rem; background: #fff; }
.ni-note { margin: 0; font-size: .85rem; color: var(--muted); line-height: 1.45; }
.ni-file { display: flex; align-items: center; gap: .4rem; margin: 0 0 .6rem; font-size: .9rem; color: #374151; overflow-wrap: anywhere; }
.ni-sum { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 .75rem; }
.ni-sum span { font-size: .82rem; font-weight: 600; padding: .15rem .6rem; border-radius: 999px; }
.ni-ok { background: #dcfce7; color: #166534; }
.ni-warn { background: #fef3c7; color: var(--warn); }
.ni-bad { background: #fee2e2; color: #991b1b; }
.ni-cols { margin: .2rem 0 0; padding-left: 1.1rem; font-size: .82rem; line-height: 1.6; color: #374151; }
.ni-cols code { font-size: .8rem; background: #e5e7eb; padding: 0 .3rem; border-radius: 3px; }
.ni-scroll { overflow-x: auto; border: 1px solid #dfe1e4; border-radius: 6px; background: #fff; }
.ni-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.ni-table th { position: sticky; top: 0; text-align: left; font-weight: 600; color: var(--muted); background: #f9fafb; padding: .45rem .6rem; border-bottom: 1px solid #dfe1e4; white-space: nowrap; }
.ni-table td { padding: .45rem .6rem; border-bottom: 1px solid #eef0f2; vertical-align: top; }
.ni-table tr:last-child td { border-bottom: 0; }
.ni-table td:first-child { color: var(--muted); }
.ni-table tr.bad { background: #fef2f2; }
.ni-table tr.warn { background: #fffbeb; }
.ni-why { margin: 0; padding: 0; list-style: none; font-size: .8rem; color: #991b1b; }
tr.warn .ni-why { color: var(--warn); }
.ni-okay { display: inline-flex; align-items: center; gap: .25rem; color: #166534; font-weight: 500; }
.ni-okay .icon { width: .95rem; height: .95rem; }
.ni-done, .ni-issues { margin: 0 0 .75rem; padding-left: 1.1rem; font-size: .88rem; line-height: 1.7; }
.ni-done a { color: var(--accent); text-decoration: none; }
.ni-issues { color: #991b1b; }
.nd-other .icon { width: 1rem; height: 1rem; vertical-align: -3px; }
a.nd-save { text-decoration: none; }
.ni-table .nw { white-space: nowrap; }
@media (max-width: 560px) { .ni-table .opt { display: none; } }

/* --- Labworks page --------------------------------------------------------------------- */
.lw { display: flex; flex-direction: column; gap: .9rem; }
.lw.with-panel { margin-inline-end: min(380px, 40vw); }
.lw-find { display: flex; gap: .6rem; align-items: center; }
.lw-find .psearch { flex: 1; min-width: 0; }
.lw-done { display: inline-flex; align-items: center; gap: .35rem; flex: none; padding: .45rem .8rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); text-decoration: none; font-size: .9em; }
.lw-done .icon { width: 1rem; height: 1rem; color: var(--muted); }
.lw-done.on { border-color: var(--accent); color: var(--accent); }
.lw-done small { font-size: .78em; color: var(--muted); background: var(--hover); padding: 0 .4rem; border-radius: 999px; }
.lw-table { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lw-row { display: grid; grid-template-columns: minmax(10rem, 1.4fr) 9.5rem minmax(6rem, 1fr) minmax(8rem, 1.2fr) minmax(8rem, 1.3fr) 10rem; gap: .75rem; align-items: center; padding: .7rem 1rem; border-top: 1px solid var(--line); color: var(--fg); text-decoration: none; font-size: .93rem; }
a.lw-row:hover { background: var(--hover); }
.lw-row.open { background: #eef4ff; box-shadow: inset 3px 0 0 var(--accent); }
.lw-head { border-top: 0; background: #f9fafb; padding-block: .6rem; font-size: .88rem; }
.lw-head > * { color: var(--muted); text-decoration: none; font-weight: 500; }
.lw-head a:hover, .lw-head a.on { color: var(--fg); }
.lw-pt { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.lw-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lw-ico { flex: none; display: inline-flex; padding: .2rem; border: 1.5px solid currentColor; border-radius: 5px; }
.lw-ico .icon { width: .85rem; height: .85rem; }
.lw-ico.s-waiting { color: #374151; }
.lw-ico.s-received { color: #15803d; }
.lw-ico.s-not_sent { color: var(--muted); }
.lw-date { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lw-date .icon { width: .95rem; height: .95rem; color: #dc2626; }
.lw-dim { color: var(--muted); font-size: .88em; }
.lw-cut { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lw-teeth { color: var(--muted); }
.lw-st { display: flex; flex-wrap: wrap; align-items: center; gap: .1rem .4rem; }
.lw-st.s-received { color: #15803d; }
.lw-st.s-not_sent { color: var(--muted); }
.lw-unpaid { font-size: .72rem; font-weight: 600; padding: 0 .4rem; border-radius: 999px; background: #fef3c7; color: var(--warn); }
.lw-none { margin: 0; padding: 2rem 1rem; text-align: center; color: var(--muted); border-top: 1px solid var(--line); }
.lw.with-panel .lw-row { grid-template-columns: minmax(8rem, 1.4fr) 8.5rem minmax(7rem, 1fr) 9rem; }
.lw.with-panel .lw-opt { display: none; }
@media (max-width: 1100px) {
  .lw-row { grid-template-columns: minmax(8rem, 1.4fr) 8.5rem minmax(7rem, 1fr) 9rem; }
  .lw-opt { display: none; }
}
@media (max-width: 700px) {
  .lw.with-panel { margin-inline-end: 0; }
  .lw-row, .lw.with-panel .lw-row { grid-template-columns: 1fr auto; gap: .25rem .75rem; }
  .lw-row > .lw-cut { grid-column: 1; color: var(--muted); font-size: .85em; }
  .lw-head > :nth-child(n+3) { display: none; }
  .lw-st { grid-column: 2; grid-row: 2; justify-content: flex-end; font-size: .85em; }
}

/* the side panel (New labwork / a case) */
.lwp { position: fixed; z-index: 30; top: .75rem; right: .75rem; bottom: .75rem; width: min(370px, calc(100vw - 1.5rem)); display: flex; flex-direction: column; background: #f3f3f3; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 12px 32px rgba(0, 0, 0, .18); overflow: hidden; }
.lwp-head { display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; background: #fff; border-bottom: 1px solid var(--line); }
.lwp-tag { display: inline-flex; align-items: center; gap: .25rem; font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 4px; background: #fde68a; color: #92400e; }
.lwp-tag .icon { width: .85rem; height: .85rem; }
.lwp-head h2 { flex: 1; margin: 0; font-size: .95rem; font-weight: 500; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lwp-x { display: inline-flex; padding: .2rem; color: var(--fg); border-radius: 4px; }
.lwp-x:hover { background: var(--hover); }
.lwp-x .icon { width: 1.1rem; height: 1.1rem; }
.lwp-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .8rem; padding: .9rem; margin: 0; }
.lwp-f select, .lwp-f textarea { box-sizing: border-box; width: 100%; padding: .5rem .6rem; font: inherit; font-size: .95rem; color: var(--fg); background: #fff; border: 1px solid #d4d6da; border-radius: 4px; }
.lwp-f input { font-size: .95rem; }
.lwp-f textarea { resize: vertical; }
.lwp-f select:focus, .lwp-f textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37, 99, 235, .18); }
.lwp-f.bad input, .lwp-f.bad select { border-color: var(--err); }
.lwp-err { font-size: .8rem; color: var(--err); }
.lwp-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; align-items: end; }
.lwp-docs { margin: 0; padding: .55rem .7rem; border: 1px solid #d4d6da; border-radius: 4px; background: #fff; display: flex; flex-wrap: wrap; gap: .3rem 1rem; }
.lwp-docs legend { padding: 0 .3rem; font-size: .9rem; color: #374151; }
.lwp-check { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; color: #374151; cursor: pointer; }
.lwp-check input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--accent); }
.lwp-steps { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; padding: .7rem; background: #fff; border: 1px solid #d4d6da; border-radius: 4px; }
.lwp-step { display: flex; flex-direction: column; gap: .45rem; }
.lwp-step .nd-f { font-size: .82rem; }
.lwp-paid { padding-bottom: .55rem; }
.lwp-foot { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; padding: .8rem .9rem; background: #fff; border-top: 1px solid var(--line); }
.lwp-del { margin: 0; display: grid; }
.lwp-delete { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem .9rem; font: inherit; font-weight: 500; color: var(--err); background: #fff; border: 1px solid #fecaca; border-radius: 4px; cursor: pointer; }
.lwp-delete:hover { background: #fef2f2; }
.lwp-delete .icon { width: 1rem; height: 1rem; }
.lwp-read { display: grid; grid-template-columns: auto 1fr; gap: .5rem 1rem; align-content: start; font-size: .92rem; }
.lwp-read dt { color: var(--muted); }
.lwp-read dd { margin: 0; }

/* --- Notes board ------------------------------------------------------------------------ */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nb { display: flex; flex-direction: column; gap: .8rem; min-width: 0; }
.nb.with-panel { margin-inline-end: min(380px, 40vw); }
.nb-bar { display: flex; flex-direction: column; gap: .6rem; }
.nb-top { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.nb-who select { padding: .45rem 2rem .45rem .7rem; font: inherit; font-size: .92rem; color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: 6px; min-width: 11rem; }
.nb-search { min-width: 0; }
.nb-toggles { display: flex; flex-wrap: wrap; gap: .4rem; }
.nb-tg { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .75rem; font: inherit; font-size: .88rem; color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.nb-tg .icon { width: 1rem; height: 1rem; color: var(--muted); }
.nb-tg:hover { background: var(--hover); }
.nb-tg.on { border-color: var(--accent); color: var(--accent); background: #eef4ff; }
.nb-tg.on .icon { color: var(--accent); }
.nb-board { display: grid; grid-template-columns: repeat(4, minmax(15rem, 1fr)); gap: .75rem; overflow-x: auto; padding-bottom: .4rem; align-items: start; }
.nb-col { display: flex; flex-direction: column; min-width: 0; background: #f3f4f6; border: 1px solid var(--line); border-radius: 8px; transition: box-shadow .12s, background .12s; }
.nb-col.drop { background: #eef4ff; box-shadow: inset 0 0 0 2px var(--accent); }
.nb-colh { display: flex; align-items: center; gap: .55rem; padding: .65rem .75rem; border-bottom: 1px solid var(--line); }
.nb-colh h2 { flex: 1; margin: 0; font-size: 1rem; font-weight: 600; }
.nb-count { display: inline-grid; place-items: center; min-width: 1.45rem; height: 1.45rem; padding: 0 .3rem; box-sizing: border-box; border-radius: 999px; font-size: .75rem; font-weight: 700; color: #fff; background: #111827; }
.c-todo .nb-count { background: #3b82f6; }
.c-doing .nb-count { background: #f59e0b; }
.c-done .nb-count { background: #22c55e; }
.nb-add { display: inline-flex; padding: .25rem; color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: 5px; }
.nb-add:hover { background: var(--hover); }
.nb-add .icon { width: 1.05rem; height: 1.05rem; }
.nb-cards { display: flex; flex-direction: column; gap: .6rem; padding: .65rem; max-height: calc(100vh - 17rem); min-height: 6rem; overflow-y: auto; }
.nb-empty { margin: auto; padding: 2.5rem 0; display: flex; flex-direction: column; align-items: center; gap: .4rem; color: var(--muted); font-style: italic; font-size: .92rem; }
.nb-empty .icon { width: 2.2rem; height: 2.2rem; }

.nc { display: flex; flex-direction: column; gap: .5rem; padding: .7rem .75rem .6rem; background: var(--card); border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 1px 2px rgba(0, 0, 0, .05); cursor: grab; }
.nc.open { box-shadow: 0 0 0 2px var(--accent); }
.nc.dragging { opacity: .45; }
.nc-top { display: flex; align-items: flex-start; gap: .5rem; }
.nc-title { flex: 1; min-width: 0; margin: 0; padding-bottom: .45rem; border-bottom: 1px solid var(--line); font-size: .98rem; font-weight: 600; overflow-wrap: anywhere; }
.nc.checked .nc-title { color: var(--muted); text-decoration: line-through; }
.nc-acts { display: flex; flex-direction: column; gap: .35rem; }
.nc-check, .nc-del { display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; padding: 0; border-radius: 7px; cursor: pointer; }
.nc-check { color: transparent; background: #fff; border: 2px solid #374151; }
.nc-check:hover { color: #9ca3af; }
.nc-check[aria-pressed="true"] { color: #fff; background: #15803d; border-color: #15803d; border-radius: 999px; }
.nc-del { color: #fff; background: #b91c1c; border: 0; }
.nc-del:hover { background: #991b1b; }
.nc-check .icon, .nc-del .icon { width: 1.05rem; height: 1.05rem; stroke-width: 2.2; }
.nc-body { margin: 0; font-size: .9rem; color: #374151; overflow-wrap: anywhere; }
.nc-tags { display: flex; flex-wrap: wrap; gap: .3rem .5rem; align-items: center; }
.nc-tag { display: inline-flex; align-items: center; gap: .25rem; font-size: .76rem; color: var(--muted); }
.nc-tag .icon { width: .85rem; height: .85rem; }
.nc-tag.over { padding: .05rem .4rem; border-radius: 4px; background: #fee2e2; color: #991b1b; }
.nc-tag.rep { font-style: italic; }
.nc-tag.pt { color: var(--accent); }
.nc-foot { display: flex; align-items: center; gap: .5rem; padding: .3rem .4rem; background: #f3f4f6; border-radius: 6px; }
.nc-open { display: inline-flex; align-items: center; gap: .35rem; flex: 1; color: var(--fg); text-decoration: none; font-size: .9rem; }
.nc-open:hover { color: var(--accent); }
.nc-open .icon { width: 1.05rem; height: 1.05rem; padding: 1px; border: 1.4px solid currentColor; border-radius: 4px; }
.nc-com { display: inline-flex; align-items: center; gap: .2rem; font-size: .78rem; color: var(--muted); }
.nc-com .icon { width: 1rem; height: 1rem; }
.nc-who { display: inline-flex; align-items: center; gap: .25rem; max-width: 50%; padding: .1rem .45rem; border-radius: 5px; background: #e5e7eb; font-size: .76rem; color: #374151; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nc-who .icon { width: .85rem; height: .85rem; flex: none; }
.nc-who.none { color: var(--muted); }

/* the note panel reuses the labwork panel (.lwp) */
.nbp-tag { background: #dbeafe; color: #1e40af; }
.nbp .lwp-body { padding-bottom: 1.2rem; }
.nbp-form { display: flex; flex-direction: column; gap: .8rem; }
.nbp-pt { display: inline-flex; align-items: center; gap: .35rem; font-size: .88rem; color: var(--accent); text-decoration: none; }
.nbp-pt .icon { width: 1rem; height: 1rem; }
.nbp-meta { margin: 0; font-size: .8rem; color: var(--muted); }
.nbp-coms { display: flex; flex-direction: column; gap: .5rem; padding-top: .6rem; border-top: 1px solid var(--line); }
.nbp-coms h3 { display: flex; align-items: center; gap: .35rem; margin: 0; font-size: .92rem; font-weight: 600; }
.nbp-coms h3 .icon { width: 1rem; height: 1rem; color: var(--muted); }
.nbp-coms h3 small { font-weight: 500; color: var(--muted); }
.nbp-com { padding: .5rem .6rem; background: #fff; border: 1px solid var(--line); border-radius: 6px; font-size: .88rem; overflow-wrap: anywhere; }
.nbp-cwho { display: flex; justify-content: space-between; gap: .5rem; margin-bottom: .2rem; font-size: .8rem; }
.nbp-cwho time { color: var(--muted); }
.nbp-cform { display: flex; flex-direction: column; gap: .4rem; }
.nbp-send { align-self: flex-end; display: inline-flex; align-items: center; gap: .35rem; padding: .4rem .8rem; font: inherit; font-size: .88rem; color: var(--fg); background: #fff; border: 1px solid #d4d6da; border-radius: 4px; cursor: pointer; }
.nbp-send:hover { background: var(--hover); }
.nbp-send .icon { width: 1rem; height: 1rem; }

@media (max-width: 1100px) {
  .nb-board { grid-template-columns: repeat(4, minmax(16rem, 1fr)); }
}
@media (max-width: 700px) {
  .nb.with-panel { margin-inline-end: 0; }
  .nb-board { grid-template-columns: repeat(4, 82vw); scroll-snap-type: x mandatory; }
  .nb-col { scroll-snap-align: start; }
  .nb-cards { max-height: none; }
}

/* Expenses: suppliers and their orders (the panel reuses .lwp, the dialog .nd) */
.ex { display: flex; flex-direction: column; gap: .9rem; }
.ex.with-panel { margin-inline-end: min(380px, 40vw); }
.ex-bar { display: flex; align-items: center; justify-content: space-between; gap: .6rem 1rem; flex-wrap: wrap; }
.ex-total { display: inline-flex; align-items: center; gap: .4rem; flex-wrap: wrap; font-size: .9em; color: var(--muted); }
.ex-due, .ex-paid { display: inline-block; padding: .2rem .55rem; border-radius: 5px; font-size: .95rem; color: #7c2d12; background: #fbd9c9; text-decoration: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ex-paid { color: #166534; background: #dcfce7; }
.ex-due small, .ex-paid small { font-size: .7em; }
.ex-list { background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.ex-row { position: relative; display: flex; align-items: center; gap: .5rem; padding: .55rem 1rem .55rem .5rem; border-top: 1px solid var(--line); }
.ex-row:first-child { border-top: 0; }
.ex-row:hover { background: var(--hover); }
.ex-row.open { background: #eef4ff; box-shadow: inset 3px 0 0 var(--accent); }
.ex-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: .6rem; padding: .35rem 0; color: var(--fg); text-decoration: none; }
.ex-open > .icon { flex: none; width: 1.3rem; height: 1.3rem; }
.ex-name { display: flex; flex-direction: column; min-width: 0; }
.ex-name b { font-weight: 500; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-name small { color: var(--muted); font-size: .8rem; }
.ex-menu { flex: none; }
.ex-menu summary { list-style: none; cursor: pointer; padding: .2rem .55rem; border-radius: 5px; font-weight: 700; color: var(--muted); }
.ex-menu summary::-webkit-details-marker { display: none; }
.ex-menu summary:hover, .ex-menu[open] summary { background: var(--line); color: var(--fg); }
.ex-pop { position: absolute; z-index: 5; top: 2.6rem; left: .5rem; min-width: 9rem; display: flex; flex-direction: column; padding: .3rem; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 20px rgba(0, 0, 0, .12); }
.ex-pop form { margin: 0; display: flex; }
.ex-pop a, .ex-pop button { flex: 1; display: flex; align-items: center; gap: .45rem; padding: .45rem .6rem; border: 0; border-radius: 4px; background: none; font: inherit; font-size: .9rem; color: var(--fg); text-decoration: none; text-align: start; cursor: pointer; }
.ex-pop button { color: var(--err); }
.ex-pop a:hover, .ex-pop button:hover { background: var(--hover); }
.ex-pop .icon { width: 1rem; height: 1rem; }
.exp-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.exp-tabs a { display: flex; align-items: center; gap: .45rem; padding: .5rem .8rem; background: #fff; color: var(--fg); text-decoration: none; font-size: .88rem; font-weight: 600; }
.exp-tabs a span { flex: 1; text-align: center; }
.exp-tabs a:hover { background: var(--hover); }
.exp-tabs .icon { width: 1rem; height: 1rem; color: var(--muted); }
.exp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; }
.exp-head h3 { margin: 0; font-size: 1.25rem; font-weight: 500; }
.exp-head small { color: var(--muted); font-size: .8rem; }
.exp-rename { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .6rem; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--fg); text-decoration: none; font-size: .85rem; white-space: nowrap; }
.exp-rename:hover { background: var(--hover); }
.exp-rename .icon { width: .9rem; height: .9rem; }
.exp-card { display: flex; flex-direction: column; gap: .15rem; padding: .7rem .85rem; background: #fff; border: 1px solid var(--line); border-radius: 4px; color: var(--fg); text-decoration: none; }
.exp-card:hover { border-color: #c7cbd1; }
.exp-card span { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; }
.exp-card span .icon { width: 1rem; height: 1rem; color: var(--accent); }
.exp-card.due span .icon { color: #ea580c; }
.exp-card.paid span .icon { color: #16a34a; }
.exp-card b { font-weight: 400; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.exp-card b small { font-size: .7em; }
.exp .lwp-foot .nd-save, .exp .lwp-foot .nd-cancel { font-size: .9rem; }
.exo-find .exo-sup select { padding: .7rem .6rem; font: inherit; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--fg); max-width: 14rem; }
.exo-show { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--card); }
.exo-show a { padding: .35rem .9rem; color: var(--fg); text-decoration: none; font-size: .9em; border-inline-start: 1px solid var(--line); }
.exo-show a:first-child { border-inline-start: 0; }
.exo-show a.on { background: var(--accent); color: #fff; }
.exo-row { display: grid; grid-template-columns: 9.5rem minmax(8rem, 1fr) minmax(8rem, 1.5fr) 9rem 6.5rem; gap: .75rem; align-items: center; padding: .55rem 1rem; border-top: 1px solid var(--line); font-size: .93rem; }
.exo-row.lw-head { border-top: 0; }
.exo-row:not(.lw-head):hover { background: var(--hover); }
.exo-row.open { background: #eef4ff; box-shadow: inset 3px 0 0 var(--accent); }
.exo-row a { color: var(--fg); text-decoration: none; }
.exo-row form { margin: 0; }
.exo-amt { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.exo-amt small { font-size: .72em; color: var(--muted); }
.exo-st { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border: 1px solid transparent; border-radius: 999px; font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }
.exo-st .icon { width: .85rem; height: .85rem; }
.exo-st.due { color: #9a3412; background: #ffedd5; }
.exo-st.paid { color: #166534; background: #dcfce7; }
.exo-st:hover { border-color: currentColor; }
.ex.with-panel .exo-row { grid-template-columns: 8.5rem minmax(7rem, 1fr) 8rem 6.5rem; }
.ex.with-panel .lw-opt { display: none; }
@media (max-width: 1100px) {
  .exo-row { grid-template-columns: 8.5rem minmax(7rem, 1fr) 8rem 6.5rem; }
  .exo .lw-opt { display: none; }
}
@media (max-width: 700px) {
  .ex.with-panel { margin-inline-end: 0; }
  .exo-find { flex-wrap: wrap; }
  .exo-find .exo-sup, .exo-find .exo-sup select { flex: 1 1 100%; max-width: none; width: 100%; }
  .exo-row, .ex.with-panel .exo-row { grid-template-columns: 1fr auto; gap: .2rem .75rem; }
  .exo-row.lw-head { display: none; }
  .exo-row > .lw-date { grid-column: 1; grid-row: 2; color: var(--muted); font-size: .85em; }
  .exo-row > .exo-link:not(.lw-opt):not(.exo-amt) { grid-column: 1; grid-row: 1; font-weight: 500; }
  .exo-row > .exo-amt { grid-column: 2; grid-row: 1; }
  .exo-row > :last-child { grid-column: 2; grid-row: 2; justify-self: end; }
}

/* Insights */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.in { display: flex; flex-direction: column; gap: .75rem; margin-block-end: 1rem; }
.in-tools { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.in-pick { position: relative; }
.in-pick summary { list-style: none; cursor: pointer; }
.in-pick summary::-webkit-details-marker { display: none; }
.in-menu { position: absolute; z-index: 20; inset-inline-start: 0; top: calc(100% + .25rem); display: flex; flex-direction: column; min-width: 12rem; padding: .3rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px #0002; }
.in-menu a { padding: .45rem .7rem; border-radius: 6px; color: var(--fg); text-decoration: none; }
.in-menu a:hover { background: var(--hover); }
.in-doc select { padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); font: inherit; min-width: 12rem; }
.in-range { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .75rem; padding: .75rem 1rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.in-date { display: inline-flex; align-items: center; gap: .5rem; color: var(--muted); }
.in-date .icon { width: 1.3rem; height: 1.3rem; flex: none; }
.in-date span { display: flex; flex-direction: column; }
.in-date small { font-size: .78rem; }
.in-date input { border: 0; background: none; font: inherit; font-size: .9rem; color: var(--fg); padding: 0; }
.in-date.end { justify-self: end; text-align: end; }
.in-date.end span { align-items: flex-end; }
.in-period { display: flex; flex-direction: column; align-items: center; gap: .35rem; color: var(--muted); font-size: .85rem; }
.in-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.in-card { background: var(--card); padding: 1rem 1.1rem 1.1rem; display: flex; flex-direction: column; gap: .75rem; min-width: 0; }
.in-card header { display: flex; gap: .6rem; align-items: flex-start; }
.in-card header > .icon { width: 1.3rem; height: 1.3rem; margin-top: .25rem; color: var(--muted); flex: none; }
.in-card h2 { margin: 0; font-size: 1.1rem; font-weight: 500; }
.in-card p { margin: 0; font-size: .8rem; color: var(--muted); }
.in-card p small { font-size: .85em; }
.in-chart { position: relative; height: 290px; }
.in-none { display: flex; height: 100%; align-items: center; justify-content: center; color: var(--muted); font-size: .95rem !important; }
@media (max-width: 1100px) { .in-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  .in-grid { grid-template-columns: minmax(0, 1fr); }
  .in-range { grid-template-columns: 1fr 1fr; }
  .in-period { grid-column: 1 / -1; grid-row: 2; }
  .in-period .exo-show { flex-wrap: wrap; justify-content: center; }
  .in-doc, .in-doc select { flex: 1; min-width: 0; }
  .in-chart { height: 240px; }
}

/* Deleted Items */
.tr { display: flex; flex-direction: column; gap: .9rem; }
.tr .ptools { margin: 0; }
button.tool { background: none; border: 0; font: inherit; cursor: pointer; }
button.tool:disabled { color: var(--muted); cursor: not-allowed; }
button.tool:disabled .icon { color: var(--muted); }
.tr-find { display: flex; flex-direction: column; gap: .6rem; }
.tr-filters { display: flex; gap: .6rem; align-items: center; }
.tr-filters select { padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); font: inherit; font-size: .9em; min-width: 10rem; }
.tr-head { padding: 0 .9rem; color: var(--muted); font-size: .85em; }
.tr-all { display: inline-flex; gap: .5rem; align-items: center; cursor: pointer; }
.tr-rows { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tr-row + .tr-row { border-top: 1px solid var(--line); }
.tr-row label { display: grid; grid-template-columns: auto 8.5rem minmax(0, 1fr) auto; gap: .9rem; align-items: center; padding: .7rem .9rem; cursor: pointer; }
.tr-row label:hover { background: var(--hover); }
.tr-row:has(input:checked) label { background: #eef4ff; }
.tr-kind { justify-self: start; font-size: .75rem; font-weight: 600; padding: .1rem .55rem; border-radius: 999px; background: var(--hover); color: var(--muted); }
.tr-kind.k-appointment { background: #ede9fe; color: #5b21b6; }
.tr-kind.k-labwork { background: #e0f2fe; color: #075985; }
.tr-kind.k-note { background: #fef9c3; color: #854d0e; }
.tr-kind.k-supplier, .tr-kind.k-order, .tr-kind.k-supply_item { background: #ffedd5; color: #9a3412; }
.tr-kind.k-treatment, .tr-kind.k-prescription { background: #dcfce7; color: #166534; }
.tr-main { display: flex; flex-direction: column; min-width: 0; }
.tr-main b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-main small, .tr-when small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-when { display: flex; flex-direction: column; align-items: flex-end; color: var(--muted); font-size: .82em; text-align: end; max-width: 16rem; }
.tr-when .icon { display: none; }
.tr-none { text-align: center; color: var(--muted); padding: 4rem 0; }
@media (max-width: 700px) {
  .tr-row label { grid-template-columns: auto minmax(0, 1fr); gap: .25rem .75rem; }
  .tr-row label > input { grid-row: 1 / span 3; }
  .tr-when { align-items: flex-start; text-align: start; max-width: none; }
  .tr-filters select { flex: 1; min-width: 0; }
  .tr-filters label { flex: 1; display: flex; }
}

/* Settings: three sections (your preferences, clinic settings, manage the clinic) */
.pf { max-width: 52rem; display: flex; flex-direction: column; gap: 1.75rem; margin-top: .5rem; }
.pf-sec { display: flex; flex-direction: column; gap: .7rem; }
.pf-head h2 { margin: 0; font-size: 1.05rem; font-weight: 600; color: var(--fg); }
.pf-head p { margin: .2rem 0 0; color: var(--muted); font-size: .88rem; line-height: 1.4; }
.pf-list { background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 1px 2px rgba(16,24,40,.05); overflow: hidden; }
.pf-row { border: 0; border-radius: 0; background: none; }
.pf-row + .pf-row { border-block-start: 1px solid var(--line); }
.pf-row > summary { display: flex; align-items: center; gap: .85rem; padding: .8rem 1.1rem; cursor: pointer; list-style: none; transition: background .12s; }
.pf-row > summary:hover { background: var(--hover); }
.pf-row > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pf-row > summary::-webkit-details-marker { display: none; }
.pf-row > summary > .icon:first-child { flex: none; width: 2.1rem; height: 2.1rem; padding: .45rem; box-sizing: border-box; border-radius: 8px; background: #eff6ff; color: var(--accent); }
.pf-row[open] > summary { background: #fafbfc; border-block-end: 1px solid var(--line); }
.pf-title { display: flex; flex-direction: column; gap: .1rem; min-width: 0; flex: 1; }
.pf-title b { font-weight: 600; font-size: .95rem; }
.pf-title small { color: var(--muted); font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-badge { flex: none; font-size: .74rem; font-weight: 500; padding: .15rem .55rem; border-radius: 999px; background: #eff6ff; color: var(--accent); border: 1px solid #dbeafe; white-space: nowrap; }
.pf-badge.clinic { background: #fff7ed; color: #b45309; border-color: #fed7aa; }
.pf-chev { flex: none; width: 1rem; height: 1rem; color: #9ca3af; transform-origin: 50% 50%; transition: transform .15s; }
.pf-row[open] .pf-chev { transform: rotate(90deg); }
.pf-form { display: flex; flex-direction: column; align-items: flex-start; gap: .8rem; padding: 1rem 1.1rem 1.1rem 4.05rem; }
.pf-options { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.pf-options label { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .92rem; }
.pf-options:disabled label { cursor: default; color: var(--muted); }
.pf-num input { width: 10rem; max-width: 100%; }
.pf-help { margin: 0; color: var(--muted); font-size: .86rem; }
.pf-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: .75rem; }
a.pf-tool { display: flex; align-items: center; gap: .85rem; padding: .9rem 1rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 1px 2px rgba(16,24,40,.05); color: var(--fg); text-decoration: none; transition: border-color .12s, box-shadow .12s; }
a.pf-tool:hover { border-color: #bfdbfe; box-shadow: 0 2px 6px rgba(16,24,40,.08); }
a.pf-tool:hover .pf-go { color: var(--accent); transform: translateX(2px); }
a.pf-tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pf-tool-ic { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 2.4rem; height: 2.4rem; border-radius: 8px; background: #eff6ff; color: var(--accent); }
.pf-tool-ic .icon { width: 1.2rem; height: 1.2rem; }
.pf-tool-ic.pf-tool-muted { background: #f3f4f6; color: #6b7280; }
.pf-tool-txt { display: flex; flex-direction: column; gap: .15rem; min-width: 0; flex: 1; }
.pf-tool-txt b { font-weight: 600; font-size: .95rem; }
.pf-tool-txt small { color: var(--muted); font-size: .84rem; line-height: 1.35; }
.pf-go { flex: none; width: 1rem; height: 1rem; color: #9ca3af; transition: transform .12s, color .12s; }
@media (max-width: 600px) {
  .pf-row > summary { flex-wrap: wrap; padding: .75rem .9rem; }
  .pf-badge { display: none; }
  .pf-form { padding: .9rem; }
  .pf-tools { grid-template-columns: 1fr; }
}

/* Visit editor: field errors and the "someone else saved" notice (patients/views.py visit_save) */
.ferr { display: block; color: var(--err); font-size: .85em; font-weight: 500; margin-top: .2rem; }
form.op [aria-invalid="true"] { border-color: var(--err); outline-color: var(--err); }
.vconflict { border: 1px solid var(--warn); border-radius: 8px; padding: .6rem .8rem; margin: 0 0 .8rem; background: rgb(180 83 9 / .06); }
.vconflict p { margin: .2rem 0; }
.vconflict dl { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .8rem; margin: .4rem 0 0; }
.vconflict dt { font-weight: 600; }
.vconflict dd { margin: 0; overflow-wrap: anywhere; }

/* Settings → Staff */
.st-page { max-width: 64rem; }
.st-list.off a { color: var(--muted); }
.st-form { max-width: 52rem; }
.st-days { border: 0; margin: .6rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem 1rem; }
.st-days legend { font-weight: 500; padding: 0; margin-block-end: .3rem; }
.st-days label { display: inline-flex; align-items: center; gap: .3rem; }
.st-perms { max-width: 28rem; margin-block-end: .8rem; }
.st-perms th[scope=row] { font-weight: 400; }
.st-perms td { width: 5rem; }
.st-box { display: inline-flex; padding: .2rem; cursor: pointer; }
.st-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

/* Settings -> Treatments / Prescriptions, Console -> Catalogue */
/* Settings → Treatments / Prescriptions catalogue */
.ct-intro { max-width: 60rem; line-height: 1.5; }
.ct-card { max-width: 64rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 1px 2px rgba(16,24,40,.05); overflow-x: auto; margin: 1rem 0 2rem; }
.ct-list { width: 100%; max-width: none; border-collapse: collapse; margin: 0; }
.ct-list thead th { position: sticky; top: 0; background: #f9fafb; color: var(--muted); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: .65rem .9rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.ct-list td { padding: .55rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ct-list tbody tr:not(.ct-cat):not(.ct-add):hover td { background: #fafbfc; }
.ct-list th.ct-n, .ct-list td.ct-n { text-align: right; }
.ct-list th.ct-c, .ct-list td.ct-c { text-align: center; }
.ct-list th.ct-a { width: 1%; }
.ct-cat th { background: #f3f4f6; color: #374151; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; text-align: left; padding: .5rem .9rem; border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); }
.ct-list tbody:first-of-type .ct-cat th { border-top: 0; }
.ct-off td:first-child { color: var(--muted); }
.ct-own { display: inline-block; margin-left: .4rem; padding: .05rem .5rem; font-size: .72rem; font-weight: 600; line-height: 1.5; color: var(--accent); background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 999px; vertical-align: middle; white-space: nowrap; }
.ct-code { margin-left: .4rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .75rem; color: #9ca3af; }
.ct-yes { color: #047857; font-weight: 500; }
.ct-list input[type=number], .ct-addform input, .ct-addform select, .ct-editform input, .ct-editform select { font: inherit; font-size: .92rem; color: var(--fg); background: #fff; border: 1px solid #d1d5db; border-radius: 6px; padding: .4rem .55rem; transition: border-color .15s, box-shadow .15s; }
.ct-list input[type=number], .ct-addform input[type=number] { width: 7.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.ct-list input:focus, .ct-addform input:focus, .ct-addform select:focus, .ct-editform input:focus, .ct-editform select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.ct-list input[type=checkbox] { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); cursor: pointer; }
.ct-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: nowrap; justify-content: flex-end; }
.ct-actions form { margin: 0; }
.ct-actions button.ghost, .ct-actions a.button.ghost { min-width: 4.6rem; justify-content: center; height: 2rem; padding: 0 .75rem; border-radius: 6px; font-size: .85rem; font-weight: 500; text-decoration: none; background: #fff; border-color: #d1d5db; }
.ct-actions button.ghost:hover, .ct-actions a.button.ghost:hover { background: var(--hover); border-color: #9ca3af; }
.ct-actions button.ct-save { color: var(--accent); border-color: #bfdbfe; }
.ct-actions button.ct-save:hover { background: #eff6ff; border-color: var(--accent); }
.ct-actions button.ct-danger { color: #b91c1c; border-color: #fecaca; }
.ct-actions button.ct-danger:hover { background: #fef2f2; border-color: #f87171; }
button.ghost:disabled, .ct-actions button.ghost:disabled { color: #b6bcc6; background: #f9fafb; border-color: #e5e7eb; border-style: solid; cursor: not-allowed; }
.ct-actions button.ghost:disabled:hover { background: #f9fafb; border-color: #e5e7eb; }
.ct-add td { padding: .45rem .9rem .6rem; background: #fcfcfd; }
.ct-add summary, .ct-add-item summary { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; color: var(--accent); font-size: .88rem; font-weight: 500; list-style: none; padding: .2rem .1rem; border-radius: 4px; }
.ct-add summary::-webkit-details-marker, .ct-add-item summary::-webkit-details-marker { display: none; }
.ct-add summary::before, .ct-add-item summary::before { content: "+"; display: inline-flex; align-items: center; justify-content: center; width: 1.1rem; height: 1.1rem; border: 1px solid currentColor; border-radius: 50%; font-size: .85rem; line-height: 1; }
.ct-add details[open] > summary::before, .ct-add-item[open] > summary::before { content: "2"; }
.ct-add summary:hover, .ct-add-item summary:hover { text-decoration: underline; }
.ct-add-item { max-width: 64rem; margin: .75rem 0 0; }
.ct-addform { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; margin: .6rem 0 .3rem; padding: .9rem 1rem; background: var(--bg); border: 1px dashed #cbd5e1; border-radius: 8px; }
.ct-addform label, .ct-editform label { display: flex; flex-direction: column; gap: .3rem; font-size: .78rem; font-weight: 600; color: #4b5563; }
.ct-addform label.ct-grow { flex: 1 1 14rem; }
.ct-addform label.ct-grow input { width: 100%; box-sizing: border-box; }
.ct-addform button.primary, .ct-editform button.primary { align-self: flex-end; height: 2.15rem; padding: 0 1.1rem; font-weight: 500; }
.ct-addform button.primary:hover, .ct-editform button.primary:hover { filter: brightness(.93); }
.ct-editform { display: flex; flex-direction: column; gap: .9rem; margin-top: .75rem; }
.ct-editform input, .ct-editform select { width: 100%; box-sizing: border-box; }
.ct-editform .ct-actions { justify-content: flex-start; margin-top: .4rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.ct-editform .ct-actions button.primary { align-self: auto; }
.ct-editform .errorlist { margin: -.5rem 0 0; color: var(--err); font-size: .85rem; }
a.ct-new { display: inline-flex; align-items: center; gap: .35rem; color: var(--accent); font-size: .88rem; font-weight: 500; text-decoration: none; padding: .2rem .1rem; }
a.ct-new::before { content: "+"; display: inline-flex; align-items: center; justify-content: center; width: 1.1rem; height: 1.1rem; border: 1px solid currentColor; border-radius: 50%; font-size: .85rem; line-height: 1; }
a.ct-new:hover { text-decoration: underline; }
.ct-subhead { margin: 1.5rem 0 .25rem; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ct-note { margin: .5rem 0 0; padding: .65rem .8rem; font-size: .88rem; line-height: 1.45; color: #1e3a8a; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; }
.ct-removed { max-width: 64rem; margin: -1rem 0 2rem; }
.ct-removed > summary { cursor: pointer; color: var(--muted); font-size: .88rem; padding: .3rem 0; width: max-content; }
.ct-removed > summary:hover { color: var(--fg); }
.ct-removed .ct-card { margin: .5rem 0 .5rem; }
.st-name { color: var(--fg); font-weight: 500; text-decoration: none; }
.st-name:hover { color: var(--accent); text-decoration: underline; }
.st-pill { display: inline-block; padding: .05rem .55rem; font-size: .72rem; font-weight: 600; line-height: 1.5; border-radius: 999px; color: #6b7280; background: #f3f4f6; border: 1px solid #e5e7eb; }
.st-pill.ok { color: #047857; background: #ecfdf5; border-color: #a7f3d0; }
.st-list.off td { color: var(--muted); }
@media (max-width: 800px) {
  .ct-list thead th, .ct-list td, .ct-cat th { padding-left: .6rem; padding-right: .6rem; }
  .ct-actions { flex-wrap: wrap; justify-content: flex-start; }
  .ct-list input[type=number] { width: 6rem; }
}

/* Console -> Audit */
.au-list td { vertical-align: top; }
.au-list pre { max-width: 32rem; margin: .3rem 0 0; white-space: pre-wrap; word-break: break-word; font-size: .8rem; }

/* Invitations */
form.inline { display: inline; }
.notice { border: 1px solid var(--line); border-radius: 6px; padding: .5rem .8rem; margin: .5rem 0; }
.notice input.wide { width: 100%; font: inherit; padding: .3rem; }

/* ---- expenses: sub-navigation, overview, items, order lines ---- */
.exn { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--line); }
.exn a { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .9rem; margin-bottom: -1px; color: var(--muted); text-decoration: none; font-size: .92rem; font-weight: 500; border-bottom: 2px solid transparent; }
.exn a .icon { width: 1rem; height: 1rem; }
.exn a:hover { color: var(--fg); }
.exn a.on { color: var(--accent); border-bottom-color: var(--accent); }
.exh { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; max-width: 64rem; }
.exh-card { display: flex; flex-direction: column; gap: .75rem; padding: 1.1rem 1.2rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 1px 2px rgba(16,24,40,.05); }
.exh-card header { display: flex; align-items: center; gap: .75rem; }
.exh-card h2 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.exh-card small { color: var(--muted); font-size: .82rem; }
.exh-card p { margin: 0; flex: 1; color: #4b5563; font-size: .9rem; line-height: 1.45; }
.exh-ic { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 2.4rem; height: 2.4rem; border-radius: 8px; background: #eff6ff; color: var(--accent); }
.exh-ic .icon { width: 1.25rem; height: 1.25rem; }
.exh-sums { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.exh-sums > span { display: inline-flex; align-items: center; gap: .4rem; }
.exh-acts { display: flex; flex-wrap: wrap; gap: .5rem; }
a.exh-main, a.exh-alt { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; height: 2.15rem; padding: 0 .95rem; border-radius: 6px; font-size: .88rem; font-weight: 500; text-decoration: none; white-space: nowrap; box-sizing: border-box; }
a.exh-main { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
a.exh-main:hover { filter: brightness(.93); }
a.exh-main .icon { width: 1rem; height: 1rem; }
a.exh-alt { background: #fff; color: var(--fg); border: 1px solid #d1d5db; }
a.exh-alt:hover { background: var(--hover); border-color: #9ca3af; }
.exh-nowrap { white-space: nowrap; }
.exh-cut { max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #4b5563; }
.exh-recent a { color: var(--fg); }
.exi-top { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; max-width: 64rem; }
.exi-find { flex: 1 1 16rem; margin: 0; }
.ex .ct-card, .ex .ct-add-item { margin: 0; }
.ex .ct-subhead { margin: .75rem 0 0; }
.exi-name { font-weight: 500; }
.ct-actions a.button.ghost.ct-order { color: var(--accent); border-color: #bfdbfe; }
.ct-actions a.button.ghost.ct-order:hover { background: #eff6ff; border-color: var(--accent); }
.exl { margin: 0; padding: .6rem .7rem .7rem; border: 1px solid #d4d6da; border-radius: 4px; background: #fff; display: flex; flex-direction: column; gap: .45rem; min-width: 0; }
.exl legend { padding: 0 .3rem; font-size: .9rem; color: #374151; }
.exl-head, .exl-row { display: grid; grid-template-columns: minmax(0, 1fr) 3.8rem 5.6rem; gap: .4rem; align-items: center; }
.exl-head span { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.exl-rows { display: flex; flex-direction: column; gap: .35rem; }
.exl-row select, .exl-row input { box-sizing: border-box; width: 100%; min-width: 0; padding: .4rem .45rem; font: inherit; font-size: .88rem; color: var(--fg); background: #fff; border: 1px solid #d4d6da; border-radius: 4px; }
.exl-row input { text-align: right; font-variant-numeric: tabular-nums; }
.exl-row select:focus, .exl-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37, 99, 235, .18); }
.exl-row.bad select, .exl-row.bad input { border-color: var(--err); }
.exl-row .lwp-err { grid-column: 1 / -1; }
.exl-more { align-self: flex-start; display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .1rem; border: 0; background: none; color: var(--accent); font: inherit; font-size: .85rem; font-weight: 500; cursor: pointer; }
.exl-more .icon { width: .9rem; height: .9rem; }
.exl-more:hover { text-decoration: underline; }
.exl-hint { color: var(--muted); font-size: .76rem; line-height: 1.35; }
@media (max-width: 640px) {
  .exn a { padding: .5rem .6rem; }
  .exh-cut { max-width: 10rem; }
}
.exi-add > summary { display: none; }
.exi-add:not([open]) { display: none; }
@media (max-width: 640px) {
  .exh-wide { display: none; }
}

/* Sign-in page */
.auth { min-height: calc(100vh - 4rem); display: flex; align-items: center; justify-content: center; padding: 2rem 16px; box-sizing: border-box; }
.auth-card { width: 100%; max-width: 400px; box-sizing: border-box; background: var(--card); border: 1px solid #e5e7eb; border-radius: 14px; box-shadow: 0 1px 2px rgba(16,24,40,.05), 0 12px 32px rgba(16,24,40,.08); padding: 2.25rem 2rem 1.75rem; }
.auth-brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: var(--accent); text-decoration: none; }
.auth-card h1 { margin: 1.5rem 0 .25rem; font-size: 1.5rem; font-weight: 650; letter-spacing: -.01em; }
.auth-sub { margin: 0 0 1.5rem; color: var(--muted); }
.auth-sub b { color: var(--fg); font-weight: 600; }
.auth-error { margin: 0 0 1.1rem; padding: .65rem .85rem; border: 1px solid #fecaca; border-radius: 8px; background: #fef2f2; color: var(--err); font-size: .92rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-field { display: flex; flex-direction: column; gap: .35rem; }
.auth-field label { font-size: .88rem; font-weight: 600; }
.auth-field input { width: 100%; box-sizing: border-box; padding: .6rem .75rem; font: inherit; color: var(--fg); background: #fff; border: 1px solid #d1d5db; border-radius: 8px; transition: border-color .12s, box-shadow .12s; }
.auth-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
.auth-field input[aria-invalid="true"] { border-color: var(--err); }
.auth-field .errorlist { margin: 0; padding: 0; list-style: none; font-size: .85rem; }
.auth-submit { margin-top: .4rem; width: 100%; padding: .65rem 1rem; font: inherit; font-weight: 600; color: #fff; background: var(--accent); border: 0; border-radius: 8px; cursor: pointer; transition: background .12s; }
.auth-submit:hover { background: #1d4ed8; }
.auth-submit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.auth-foot { margin: 1.5rem 0 0; padding-top: 1.1rem; border-top: 1px solid #e5e7eb; text-align: center; color: var(--muted); font-size: .9rem; }
.auth-foot a { color: var(--accent); font-weight: 500; text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }
@media (max-width: 480px) { .auth { padding: 1rem 16px; align-items: flex-start; } .auth-card { padding: 1.75rem 1.25rem 1.5rem; } }

/* Treatment plan: chart marker, summary under the chart, tooth panel section */
.tt .pl { position: absolute; top: .1rem; inset-inline-end: .1rem; font-size: .62em; background: #ea580c; color: #fff; border-radius: 999px; min-width: 1.1em; text-align: center; }
.tt.planned { box-shadow: inset 0 0 0 1px #fdba74; }
.tt.planned.sel { box-shadow: inset 0 0 0 2px var(--sel); }
.tplan { margin: .5rem 0 .75rem; padding: .7rem 1rem; border: 1px solid #fed7aa; border-radius: 8px; background: #fffaf5; }
.tplan header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .3rem 1rem; }
.tplan h2 { display: inline-flex; align-items: center; gap: .4rem; margin: 0; font-size: 1rem; }
.tplan h2 .icon { width: 1.1rem; height: 1.1rem; color: #ea580c; }
.tplan-total { color: var(--muted); font-size: .9em; }
.tplan-total b { color: var(--fg); }
.tplan ul { list-style: none; margin: .5rem 0 0; padding: 0; }
.tplan li { display: flex; align-items: baseline; gap: .5rem; padding: .25rem 0; border-top: 1px dashed #fde3c8; }
.tplan-name { flex: 1; min-width: 0; }
.tplan-name small, .tp-plan-name small { color: var(--muted); font-weight: 600; }
.tplan-price, .tp-plan-price { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tp-plans { list-style: none; margin: 0; padding: 0; }
.tp-plans li { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; padding: .3rem 0; border-bottom: 1px dashed var(--line); }
.tp-plans li form { margin: 0; }
.tp-plans li.done { color: var(--muted); }
.tp-plans li.done .tp-plan-name { text-decoration: line-through; text-decoration-color: #cbd5e1; }
.tp-plan-name { flex: 1; min-width: 8rem; }
.tp-add { margin-top: .5rem; }
.tp-add summary { cursor: pointer; color: var(--accent); font-size: .9em; font-weight: 500; }
.tp-addform { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem .8rem; margin-top: .5rem; padding: .7rem .8rem; background: var(--card); border: 1px dashed #cbd5e1; border-radius: 8px; }
.tp-addform label { display: flex; flex-direction: column; gap: .2rem; font-size: .85em; font-weight: 600; }
.tp-addform select, .tp-addform input[type=number] { font: inherit; font-weight: 400; padding: .3rem .45rem; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; }
.tp-addform input[type=number] { width: 7rem; }
.tp-addform .tp-surfs { display: flex; gap: .25rem; border: 0; margin: 0; padding: 0; }
.tp-addform .tp-surfs legend { padding: 0; margin-bottom: .2rem; font-size: .85em; font-weight: 600; }
.tp-addform .surf { font-weight: 400; }
.tp-addform button.primary { align-self: flex-end; }

/* ASA class and X-rays (Details tab and tooth panel) */
.asa { display: inline-block; white-space: nowrap; padding: .05rem .45rem; border-radius: 4px; background: #f1f5f9; font-size: .9em; }
.asa.high { background: #fef2f2; color: #b91c1c; font-weight: 600; }
.asa-what { color: var(--muted); font-size: .88em; }
.xrays { margin-top: 1.25rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.xrays h3 { display: inline-flex; align-items: center; gap: .35rem; margin: 0; font-size: .95rem; }
.xrays h3 .icon { width: 1rem; height: 1rem; color: var(--accent); }
.xr-due { margin: .5rem 0; padding: .4rem .7rem; border-radius: 6px; background: #fffbeb; border: 1px solid #fde68a; color: #92400e; font-size: .88rem; }
.xr-list { list-style: none; margin: .4rem 0; padding: 0; }
.xr-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem; padding: .35rem 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.xr-kind { font-weight: 600; }
.xr-when { color: var(--muted); font-variant-numeric: tabular-nums; }
.xr-img { display: inline-flex; align-items: center; gap: .2rem; font-size: .85em; }
.xr-img .icon { width: .85rem; height: .85rem; }
.xr-list small.muted, .xr-del { margin-inline-start: auto; }
.xr-del { margin-block: 0; }
.xr-del button { padding: .15rem .35rem; }
.xr-del .icon { width: .9rem; height: .9rem; }
.xr-find { flex-basis: 100%; margin: 0; color: var(--fg); white-space: pre-line; font-size: .88rem; }
.xr-add { margin-top: .4rem; }
.xr-add summary { cursor: pointer; color: var(--accent); font-size: .9em; font-weight: 500; }
.xr-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .6rem; margin-top: .5rem; padding: .7rem .8rem; background: var(--card); border: 1px dashed #cbd5e1; border-radius: 8px; }
.xr-form > label { display: flex; flex-direction: column; gap: .2rem; font-size: .85em; font-weight: 600; }
.xr-form > label.check { flex-direction: row; align-items: center; font-weight: 400; grid-column: 1 / -1; }
.xr-form .xr-wide { grid-column: 1 / -1; }
.xr-form select, .xr-form input[type=date], .xr-form input[type=url], .xr-form textarea { font: inherit; font-weight: 400; padding: .3rem .45rem; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; width: 100%; box-sizing: border-box; }
.xr-form button.primary { justify-self: start; }

/* Diagnosis and ICD-10 codes on a visit */
.op-grid.dx { align-items: start; }
.icd { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; }
.icd-h { color: var(--muted); }
.icd-codes { display: flex; flex-wrap: wrap; gap: .3rem; }
.icd-code { font-size: .85rem; }
.icd-code b { font-variant-numeric: tabular-nums; }
.vc-dx { font-size: .82em; color: #374151; }
.vc-dx abbr, .icd-c { display: inline-block; margin-inline-end: .25rem; padding: 0 .3rem; border-radius: 4px; background: #eef2ff; color: #3730a3; font-size: .9em; text-decoration: none; font-variant-numeric: tabular-nums; }

/* Periodontal chart */
.perio-page { display: flex; flex-direction: column; gap: 1rem; }
.perio-page, .perio-form { min-width: 0; max-width: 100%; }
.perio-form { display: flex; flex-direction: column; gap: 1rem; }
.perio-form input[type=date], .perio-notes textarea { font: inherit; padding: .4rem .55rem; border: 1px solid #d1d5db; border-radius: 6px; background: var(--card); box-sizing: border-box; }
.perio-notes textarea { width: 100%; resize: vertical; }
.perio-bar label { display: inline-flex; align-items: center; gap: .5rem; }
.perio-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; }
.perio-bar p { margin: 0; max-width: 46rem; }
.perio-exams { display: flex; flex-wrap: wrap; gap: .35rem; }
.perio-exams .chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.perio-sum { display: flex; flex-direction: column; gap: .5rem; }
.perio-stats { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; }
.perio-stats div { padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 8px; min-width: 8rem; }
.perio-stats dt { font-size: .78rem; color: var(--muted); }
.perio-stats dd { margin: 0; font-size: 1.1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.perio-stats dd.pd-w { color: #b45309; }
.perio-stats dd.pd-d { color: #b91c1c; }
.perio-change { margin: 0; padding: .4rem .7rem; border-radius: 6px; background: #f8fafc; border: 1px solid var(--line); font-size: .9rem; }
.perio-note { margin: 0; font-size: .9rem; }
.perio-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.perio-actions form { margin: 0; }
.perio-notes { display: flex; flex-direction: column; gap: .3rem; max-width: 46rem; }
.perio-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.perio { border-collapse: collapse; font-size: .78rem; font-variant-numeric: tabular-nums; }
.perio caption { text-align: start; padding: .4rem .6rem; font-weight: 600; }
.perio th, .perio td { padding: 1px 2px; border-top: 1px solid #eef0f3; text-align: center; white-space: nowrap; }
.perio th[scope=row] { position: sticky; inset-inline-start: 0; z-index: 1; background: var(--card); text-align: start; font-weight: 500; color: var(--muted); padding-inline: .5rem; }
.perio .perio-teeth th { font-weight: 700; padding: .25rem 2px; background: #f8fafc; color: inherit; }
.perio .mid { border-inline-start: 2px solid #94a3b8; }
.perio .gone { background: repeating-linear-gradient(45deg, #f1f5f9 0 4px, #e2e8f0 4px 8px); color: #94a3b8; }
.perio .trio { display: inline-flex; gap: 1px; }
.perio .pc { display: inline-block; width: 1.25rem; text-align: center; color: #334155; }
.perio input.pc { width: 1.4rem; height: 1.5rem; padding: 0; border: 1px solid #d5dae1; border-radius: 3px; font: inherit; text-align: center; background: #fff; }
.perio input.pc:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.perio .pc.pd-w { color: #b45309; font-weight: 700; }
.perio .pc.pd-d { color: #fff; background: #dc2626; border-radius: 3px; font-weight: 700; }
.perio input.pc.pd-w { background: #fffbeb; border-color: #f59e0b; }
.perio input.pc[aria-invalid=true] { border-color: #dc2626; outline: 2px solid #fecaca; }
.perio .bop { display: inline-flex; width: 1.25rem; justify-content: center; }
.perio span.bop::before, .perio .bop span { content: ""; display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; border: 1px solid #cbd5e1; background: #fff; }
.perio span.bop.on::before { background: #dc2626; border-color: #dc2626; }
.perio label.bop { position: relative; width: 1.4rem; cursor: pointer; }
.perio label.bop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.perio label.bop input:checked + span { background: #dc2626; border-color: #dc2626; }
.perio span.bop.mk-plq.on::before, .perio label.bop.mk-plq input:checked + span { background: #2563eb; border-color: #2563eb; }
.perio span.bop.mk-sup.on::before, .perio label.bop.mk-sup input:checked + span { background: #d97706; border-color: #d97706; }
.perio label.bop input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.perio-sec .perio-line { margin: .4rem 0; font-size: .9rem; }
.tp-perio { font-size: .88rem; font-variant-numeric: tabular-nums; }
.tp-perio .pd-w { color: #b45309; font-weight: 700; }
.tp-perio .pd-d { color: #b91c1c; font-weight: 700; }

/* Medical risks */
.alert.risk b { font-weight: 600; }
.risk-pill { display: inline-block; margin: 0 .25rem .25rem 0; padding: .05rem .45rem; border-radius: 999px; background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; font-size: .82rem; }
form.pedit #id_risk_flags { display: flex; flex-direction: column; gap: .5rem; }
form.pedit #id_risk_flags > div { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .15rem 1rem; }
form.pedit #id_risk_flags > div > label:not([for]) { grid-column: 1 / -1; font-weight: 600; font-size: .85rem; color: var(--muted); }
form.pedit #id_risk_flags label[for] { display: flex; align-items: flex-start; gap: .35rem; font-weight: 400; }
form.pedit #id_risk_flags input { width: auto; margin-top: .2rem; }

/* Clinic picker (base domain) */
.picker { display: flex; justify-content: center; padding: 3rem 16px 2rem; }
.picker-card { width: 100%; max-width: 480px; background: var(--card); border: 1px solid #e5e7eb; border-radius: 14px; box-shadow: 0 1px 2px rgba(16,24,40,.05), 0 12px 32px rgba(16,24,40,.08); padding: 2rem 1.75rem 1.5rem; }
.picker-head h1 { margin: 0 0 .25rem; font-size: 1.5rem; font-weight: 650; letter-spacing: -.01em; }
.picker-sub { margin: 0 0 1.5rem; color: var(--muted); overflow-wrap: anywhere; }
.picker-sub b { color: var(--fg); font-weight: 600; }
.picker-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.picker-list form { margin: 0; }
.picker-item { display: flex; align-items: center; gap: .9rem; width: 100%; padding: .8rem .9rem; font: inherit; color: var(--fg); text-align: start; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; cursor: pointer; transition: border-color .12s, box-shadow .12s, background .12s; }
.picker-item:hover { border-color: #bfd0fb; background: #f8faff; box-shadow: 0 2px 8px rgba(37,99,235,.08); }
.picker-item:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
.picker-avatar { flex: none; display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 10px; background: #eff4ff; color: var(--accent); font-weight: 700; font-size: .95rem; letter-spacing: .02em; }
.picker-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.picker-name { font-weight: 600; overflow-wrap: anywhere; }
.picker-host { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-badge { display: inline-block; margin-inline-start: .35rem; padding: .05rem .45rem; border-radius: 999px; background: #ecfdf5; color: #047857; font-size: .72rem; font-weight: 600; vertical-align: .1em; }
.picker-go { flex: none; display: inline-flex; color: #9ca3af; transition: color .12s, transform .12s; }
.picker-item:hover .picker-go { color: var(--accent); transform: translateX(2px); }
[dir="rtl"] .picker-go { transform: scaleX(-1); }
[dir="rtl"] .picker-item:hover .picker-go { transform: scaleX(-1) translateX(2px); }
.picker-empty { text-align: center; padding: 1rem .5rem .5rem; color: var(--muted); }
.picker-empty p { margin: .35rem 0; }
.picker-empty b { color: var(--fg); }
.picker-empty-icon { display: inline-grid; place-items: center; width: 3rem; height: 3rem; margin-bottom: .5rem; border-radius: 50%; background: #f1f3f6; }
.picker-foot { margin: 1.5rem 0 0; padding-top: 1.1rem; border-top: 1px solid #e5e7eb; text-align: center; color: var(--muted); font-size: .88rem; }
@media (max-width: 480px) { .picker { padding: 1.25rem 16px; } .picker-card { padding: 1.5rem 1.1rem 1.25rem; } }
