: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; gap: 1rem; align-items: center; padding: .5rem 1rem; background: var(--card); border-bottom: 1px solid #e5e7eb; }
.topbar nav { display: flex; gap: .75rem; margin-inline-start: 1rem; }
.topbar .who { margin-inline-start: auto; color: var(--muted); }
.topbar form { margin: 0; }
.brand { font-weight: 700; text-decoration: none; color: var(--accent); }
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; }
.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.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; }
.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 { background: #ffedd5; color: #9a3412; }
.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 */
.pf { max-width: 52rem; display: flex; flex-direction: column; gap: .6rem; }
.pf-group { font-size: 1rem; margin: 1.2rem 0 .2rem; color: var(--muted); font-weight: 600; }
.pf-row { border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.pf-row > summary { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; cursor: pointer; list-style: none; }
.pf-row > summary::-webkit-details-marker { display: none; }
.pf-row > summary > .icon { width: 1.3rem; height: 1.3rem; color: var(--accent); flex: none; }
.pf-row[open] > summary { border-block-end: 1px solid var(--line); }
.pf-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pf-title small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-badge { flex: none; font-size: .8em; padding: .15rem .6rem; border-radius: 999px; background: #e8efff; color: var(--accent); white-space: nowrap; }
.pf-badge.clinic { background: #fff1e6; color: #b45309; }
.pf-form { display: flex; flex-direction: column; gap: .8rem; padding: 1rem; }
.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; }
.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: .9em; }
@media (max-width: 600px) {
  .pf-row > summary { flex-wrap: wrap; }
  .pf-badge { margin-inline-start: 2.1rem; }
}

/* 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; }
