/* Sparsh Assist — "reading room" layout: dark navigation rail like a PACS workstation,
   bright, calm workspace for reports and billing. Teal accent; semantic colours separate. */
@font-face { font-family: "Inter"; src: url("/fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Jakarta"; src: url("/fonts/jakarta.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Jakarta", "Inter", system-ui, sans-serif;

  --bg: #e7edf1;          /* workspace: a soft cool grey, so white cards stand out and the screen doesn't glare */
  --surface: #ffffff;     /* cards */
  --surface-2: #f1f5f8;   /* inputs, table heads */
  --ink: #0f1d26;
  --ink-2: #34444f;
  --muted: #566874;
  --line: #d6dfe5;
  --line-strong: #bfccd4;

  --accent: #0b7f8c;      /* teal */
  --accent-ink: #ffffff;
  --accent-soft: #e2f3f4;
  --accent-strong: #08656f;

  --rail: #0e1a21;        /* navigation rail */
  --rail-2: #16252e;
  --rail-ink: #c3d1d9;
  --rail-muted: #7f939f;

  --ok: #13804f;  --ok-soft: #e1f4ea;
  --warn: #a35f00; --warn-soft: #fcefd9;
  --bad: #c2352f;  --bad-soft: #fbe6e5;
  --info: #3159c8; --info-soft: #e7edfc;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 29, 38, .06), 0 2px 6px rgba(15, 29, 38, .04);
  --shadow-lg: 0 18px 50px rgba(15, 29, 38, .18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d161c; --surface: #1b2a33; --surface-2: #15222a;
    --ink: #eaf0f3; --ink-2: #ccd8de; --muted: #a5b5be; --line: #314450; --line-strong: #3e535f;
    --accent: #2fb5c2; --accent-ink: #04181b; --accent-soft: #14424a; --accent-strong: #63cfd9;
    --rail: #0a1217; --rail-2: #17252e; --rail-ink: #cfdbe2; --rail-muted: #93a6b1;
    --ok: #4cc98c; --ok-soft: #143826; --warn: #e6a63e; --warn-soft: #3b2d12; --bad: #f2776f; --bad-soft: #40201d;
    --info: #7f9ff3; --info-soft: #1e2d58;
    --shadow: inset 0 1px 0 rgba(255, 255, 255, .045), 0 1px 3px rgba(0, 0, 0, .35); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d161c; --surface: #1b2a33; --surface-2: #15222a;
  --ink: #eaf0f3; --ink-2: #ccd8de; --muted: #a5b5be; --line: #314450; --line-strong: #3e535f;
  --accent: #2fb5c2; --accent-ink: #04181b; --accent-soft: #14424a; --accent-strong: #63cfd9;
  --rail: #0a1217; --rail-2: #17252e; --rail-ink: #cfdbe2; --rail-muted: #93a6b1;
  --ok: #4cc98c; --ok-soft: #143826; --warn: #e6a63e; --warn-soft: #3b2d12; --bad: #f2776f; --bad-soft: #40201d;
  --info: #7f9ff3; --info-soft: #1e2d58;
  --shadow: inset 0 1px 0 rgba(255, 255, 255, .045), 0 1px 3px rgba(0, 0, 0, .35); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* hidden always hides, whatever layout style the element has */
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 15px; font-weight: 700; margin: 0 0 12px; }
h3 { font-family: var(--font); font-size: 11px; font-weight: 600; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num, .mono { font-variant-numeric: tabular-nums; }

/* ---------- Top progress bar (shown while any request is in flight) ---------- */
#progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100; pointer-events: none; opacity: 0; transition: opacity .2s; }
#progress.on { opacity: 1; }
#progress::before { content: ""; position: absolute; inset: 0; width: 40%; background: linear-gradient(90deg, transparent, var(--accent), transparent); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* ---------- Shell ---------- */
.layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--rail); color: var(--rail-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: #fff; font: 700 17px var(--font-display); letter-spacing: -.01em; }
.brand-link { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; text-decoration: none; border-radius: 10px; }
.brand-link:hover, .brand-link:hover * { text-decoration: none; }
.brand-link:hover .brand-mark { filter: brightness(1.12); }
.brand-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(140deg, #19a7b5, #0b6f7b); display: grid; place-items: center; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.brand-mark svg { width: 18px; height: 18px; color: #fff; }
.brand small { display: block; font: 500 11px var(--font); color: var(--rail-muted); letter-spacing: 0; }
/* Sparsh wordmark (js/core/brand.js): "Sparsh" shows once in Hindi, Kannada, Tamil, Telugu, then "Sparsh Assist" settles */
.sp-mark { position: relative; display: inline-flex; align-items: baseline; gap: .26em; white-space: nowrap; line-height: 1.2; }
.sp-in { position: absolute; left: 0; fill: currentColor; opacity: 0; pointer-events: none; overflow: visible; }
.sp-center .sp-in { left: 50%; margin-left: calc(var(--w) / -2); }
.sp-anim .sp-in { animation: sp-flash .72s cubic-bezier(.3,.7,.3,1) both; animation-delay: calc(var(--i) * .72s + .25s); }
.sp-anim .sp-en, .sp-anim .sp-assist { animation: sp-settle .55s cubic-bezier(.3,.7,.3,1) both; animation-delay: 3.15s; }
.sp-anim .sp-assist { animation-delay: 3.3s; }
@keyframes sp-flash { 0% { opacity: 0; transform: translateY(.3em); } 22%, 74% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-.3em); } }
@keyframes sp-settle { from { opacity: 0; transform: translateY(.3em); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .sp-anim .sp-in { display: none; } .sp-anim .sp-en, .sp-anim .sp-assist { animation: none; } }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--rail-muted); padding: 14px 12px 6px; }
.side a.nav { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: var(--rail-ink); font-weight: 500; transition: background .15s, color .15s; }
.side a.nav svg { width: 18px; height: 18px; opacity: .9; flex: none; }
.side a.nav:hover { background: var(--rail-2); text-decoration: none; color: #fff; }
.side a.nav.active { background: rgba(47, 181, 194, .14); color: #fff; box-shadow: inset 2px 0 0 #2fb5c2; }
.side a.nav.active svg { opacity: 1; color: #5fcbd5; }
.side .foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--rail-2); font-size: 12px; color: var(--rail-muted); display: grid; gap: 10px; }
.me { display: flex; gap: 10px; align-items: center; }
.me b { color: #fff; font-weight: 600; display: block; font-size: 13px; }
.me span { font-size: 11.5px; text-transform: capitalize; }
.side .foot .row button { background: var(--rail-2); color: var(--rail-ink); border-color: transparent; }
.side .foot .row button:hover { color: #fff; border-color: var(--rail-muted); }
.side { transition: padding .18s ease; }
.layout { transition: grid-template-columns .18s ease; }
.side-toggle { margin-left: auto; background: transparent; border-color: transparent; color: var(--rail-muted); padding: 6px; }
.side-toggle:hover { background: var(--rail-2); color: #fff; border-color: transparent; }
.side-toggle svg { width: 18px; height: 18px; }
.side a.nav { position: relative; }
.nav-tip { opacity: 0; transition: opacity .25s ease; } .nav-tip.on { opacity: 1; }
.nav-tip { position: fixed; z-index: 140; transform: translateY(-50%); background: var(--ink); color: var(--surface); font: 600 12.5px var(--font); padding: 6px 10px; border-radius: 8px; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow-lg); }
.nav-tip::before { content: ""; position: absolute; left: -4px; top: 50%; width: 8px; height: 8px; background: inherit; transform: translateY(-50%) rotate(45deg); }
/* Slim menu (desktop only) */
@media (min-width: 861px) {
  .nav-mini .layout { grid-template-columns: 68px minmax(0, 1fr); }
  .nav-mini .side { padding: 14px 8px; overflow-x: hidden; }
  .nav-mini .side .lbl, .nav-mini .me > div, .nav-mini .theme-switch span { display: none; }
  .nav-mini .brand { flex-direction: column; gap: 10px; padding: 4px 0 14px; }
  .nav-mini .side-toggle { margin: 0; }
  .nav-mini .side-toggle svg { transform: scaleX(-1); }
  .nav-mini .nav-label { font-size: 0; padding: 0; height: 1px; margin: 10px 8px; background: var(--rail-2); }
  .nav-mini .side a.nav { justify-content: center; padding: 10px 0; }
  .nav-mini .side a.nav.active { box-shadow: inset 2px 0 0 #2fb5c2; }
  .nav-mini .nav-badge { position: absolute; top: 3px; right: 7px; min-width: 16px; height: 16px; line-height: 16px; font-size: 10px; padding: 0 4px; margin: 0; }
  .nav-mini .side .foot { padding: 12px 0 4px; justify-items: center; }
  .nav-mini .me { justify-content: center; }
  .nav-mini .ai-chip { justify-content: center; }
  .nav-mini .theme-switch { flex-direction: column; width: 40px; }
  .nav-mini .theme-switch button { padding: 6px 0; }
  .nav-mini .side .foot .row { flex-direction: column; gap: 6px; }
  .nav-mini .side .foot .row button { padding: 7px 9px; }
}
@media (max-width: 860px) { .side-toggle { display: none; } }
.theme-switch { display: flex; background: var(--rail-2); border-radius: 9px; padding: 3px; gap: 2px; }
.theme-switch button { flex: 1; justify-content: center; gap: 5px; padding: 5px 4px; font-size: 11.5px; background: transparent; border: 0; color: var(--rail-muted); border-radius: 7px; }
.theme-switch button svg { width: 14px; height: 14px; }
.theme-switch button:hover { color: #fff; background: transparent; }
.theme-switch button.on { background: var(--rail); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.ai-chip { display: inline-flex; gap: 6px; align-items: center; font-size: 11.5px; }
.ai-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--rail-muted); }
.ai-chip.on i { background: #45c486; box-shadow: 0 0 0 3px rgba(69,196,134,.2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 12px 28px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); min-height: 60px; }
.topbar .crumb { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
main#app { padding: 24px 28px 48px; width: 100%; max-width: 2200px; margin-inline: auto; } /* use the whole screen; only very large monitors are capped */

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); margin-top: 4px; font-size: 13px; }

/* ---------- Building blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; }
/* Dashboard cards: the button stays at the top right, beside the title, even on a phone */
.card-head.dash-head { flex-wrap: nowrap; align-items: flex-start; }
.card-head.dash-head > div:first-child { flex: 1; min-width: 0; }
.card-head.dash-head > .btn, .card-head.dash-head > button { flex: none; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mt { margin-top: 16px; }
.stack { display: grid; gap: 16px; }

/* stat tiles */
.stat { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center; color: inherit; text-decoration: none !important; transition: border-color .15s, transform .15s; }
a.stat:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.stat .ico { grid-row: span 2; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.stat .ico svg { width: 19px; height: 19px; }
.stat .ico.warn { background: var(--warn-soft); color: var(--warn); }
.stat .ico.bad { background: var(--bad-soft); color: var(--bad); }
.stat .ico.ok { background: var(--ok-soft); color: var(--ok); }
.stat .ico.info { background: var(--info-soft); color: var(--info); }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { font: 700 22px/1.15 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td, table tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; transition: background .12s; }
tr.click:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who b { font-weight: 600; display: block; }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; font: 600 12px var(--font); color: var(--accent-strong); background: var(--accent-soft); }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }

/* buttons */
button, .btn { font: 500 13.5px var(--font); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; display: inline-flex; gap: 7px; align-items: center; justify-content: center; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, box-shadow .15s; }
button svg, .btn svg { width: 16px; height: 16px; }
button:hover, .btn:hover { border-color: var(--accent); color: var(--accent-strong); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); box-shadow: 0 1px 2px rgba(11, 127, 140, .25); }
button.primary:hover, .btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
button.ghost { background: transparent; border-color: transparent; }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); color: var(--bad); }
button.ai { justify-content: flex-start; background: var(--surface-2); border-color: var(--line); color: var(--ink-2); }
button.ai svg { color: var(--accent); }
button.ai:hover { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-soft); }
button:disabled { opacity: .55; cursor: progress; }
button.sm, .btn.sm { padding: 5px 10px; font-size: 12.5px; }

/* forms */
input, select, textarea { font: 14px var(--font); color: var(--ink); background-color: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; width: 100%; transition: border-color .15s, box-shadow .15s, background .15s; }
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background-color: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
/* Dropdowns: same look as text boxes, with a clean chevron instead of the operating system's arrow. */
select { --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23566874' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); -webkit-appearance: none; appearance: none; background-image: var(--chev); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 34px; cursor: pointer; text-overflow: ellipsis; line-height: 1.3; min-height: 40px; }
select:hover { --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233c4d59' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
select:focus { --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230b7f8c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-image: var(--chev); }
select:disabled { opacity: .55; cursor: not-allowed; }
select[multiple] { background-image: none; padding-right: 11px; }
select option, select optgroup { background: var(--surface); color: var(--ink); }
select optgroup { font-weight: 600; color: var(--muted); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) select { --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a5b5be' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
  :root:not([data-theme="light"]) select:hover { --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ccd8de' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
  :root:not([data-theme="light"]) select:focus { --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232fb5c2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
}
:root[data-theme="dark"] select { --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a5b5be' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
:root[data-theme="dark"] select:hover { --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ccd8de' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
:root[data-theme="dark"] select:focus { --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232fb5c2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
.toolbar select, .row > select { min-height: 38px; }
button.sm ~ select, select.sm { min-height: 32px; padding-top: 5px; padding-bottom: 5px; font-size: 13px; }
input[readonly], textarea[readonly] { background: var(--surface); border-style: dashed; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); padding: 0; flex: none; }
/* Drawn by us so a ticked box is obvious on every phone and in dark mode (some browsers ignore accent-color). */
input[type="checkbox"], input[type="radio"] { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; margin: 0; border: 1.5px solid var(--muted, #8a9aa4); border-radius: 5px; background: var(--surface, #fff) no-repeat center / 12px; cursor: pointer; display: inline-grid; place-content: center; transition: background-color .12s, border-color .12s; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:checked { background-color: var(--accent); border-color: var(--accent); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E"); }
input[type="radio"]:checked { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 4.5px, transparent 5px); }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: .5; cursor: default; }
.u-blist { display: grid; gap: 2px; border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; }
.u-brow { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.u-brow + .u-brow { border-top: 1px solid var(--line); }
.u-main { color: var(--muted); }
.u-main[hidden] { display: none; }
.u-bnote { margin-top: 6px; }
textarea { resize: vertical; min-height: 72px; line-height: 1.55; }
textarea.report { min-height: 220px; font-size: 14.5px; line-height: 1.65; }
label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 13.5px; margin: 0; }
.field { margin-bottom: 14px; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 34px; }

/* status pills */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-Pending { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.b-Draft { background: var(--info-soft); color: var(--info); border-color: transparent; }
.b-Signed, .b-Paid, .b-Active { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.b-Unpaid, .b-STAT, .b-crit, .b-Disabled { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.b-Partial, .b-Urgent { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.b-Cancelled { text-decoration: line-through; }
.mod { font: 600 11px var(--font); letter-spacing: .04em; padding: 3px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-strong); }

/* reporting workspace */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) clamp(360px, 25vw, 480px); gap: 18px; align-items: start; }
.assist { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 92px); overflow: auto; }
.assist .ai-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.assist .ai-head .ico { width: 32px; height: 32px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.assist .ai-head .ico svg { width: 17px; height: 17px; }
.issue { border: 1px solid var(--line); border-left: 3px solid var(--line-strong); padding: 9px 12px; margin: 8px 0; background: var(--surface-2); border-radius: 0 8px 8px 0; }
.issue.high { border-left-color: var(--bad); }
.issue.medium { border-left-color: var(--warn); }
.issue.low { border-left-color: var(--accent); }
.critical-banner { display: flex; gap: 10px; align-items: center; background: var(--bad-soft); color: var(--bad); padding: 11px 14px; border-radius: 10px; font-weight: 600; margin-bottom: 16px; }
.critical-banner svg { width: 18px; height: 18px; flex: none; }
.pt-strip { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.pt-strip .kv { display: grid; gap: 1px; }
.pt-strip .kv > span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.pt-strip .kv b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 10px; color: var(--muted); font-size: 13px; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { border-bottom-color: var(--accent); color: var(--accent-strong); font-weight: 600; }
pre.addendum { white-space: pre-wrap; font: inherit; background: var(--warn-soft); padding: 12px; border-radius: 10px; margin: 0; }
details summary { cursor: pointer; }

/* filter toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.toolbar .search { flex: 1 1 260px; max-width: 380px; }
.toolbar select, .toolbar input[type="date"] { width: auto; }
.toolbar input[type="date"] { min-height: 38px; }
.chips { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; }
.chips button { border: 0; background: transparent; padding: 5px 11px; font-size: 12.5px; color: var(--muted); border-radius: 7px; }
.chips button.on { background: var(--accent-soft); color: var(--accent-strong, var(--accent)); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }

/* modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(6, 14, 19, .5); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 120; padding: 16px; animation: fade .15s ease-out; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; width: min(660px, 100%); max-height: 90vh; overflow: auto; padding: 24px; box-shadow: var(--shadow-lg); animation: rise .18s ease-out; }
.modal h2 { font-size: 18px; margin-bottom: 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.toast-wrap { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 130; }
.toast { display: flex; gap: 10px; align-items: center; background: var(--ink); color: var(--surface); padding: 11px 16px; border-radius: 10px; max-width: 420px; box-shadow: var(--shadow-lg); animation: rise .2s ease-out; font-weight: 500; }
.toast.err { background: var(--bad); color: #fff; }

/* chart */
.bars { display: flex; align-items: flex-end; gap: 5px; height: 140px; padding-top: 8px; border-bottom: 1px solid var(--line); }
.bars div { flex: 1; background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 55%, transparent)); border-radius: 5px 5px 0 0; min-height: 3px; position: relative; transition: opacity .15s; }
.bars div:hover { opacity: .8; }
.bars div:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--surface); font-size: 11px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; z-index: 2; }

/* loading: spinner, skeleton shimmer, busy lists */
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.sk { display: block; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--line) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-line { height: 12px; margin: 10px 0; }
.is-loading { position: relative; pointer-events: none; }
.is-loading > * { opacity: .45; transition: opacity .15s; }
.is-loading::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: slide2 1s linear infinite; }
@keyframes slide2 { from { background-position: -50% 0; } to { background-position: 150% 0; } }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 34px; height: 34px; color: var(--line-strong); display: block; margin: 0 auto 10px; }
.error-card { border-color: var(--bad-soft); }

/* "new version available" bar */
.update-bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 125; display: flex; align-items: center; gap: 10px; background: var(--ink); color: var(--surface); padding: 8px 10px 8px 14px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: calc(100% - 24px); }
.update-bar svg { width: 16px; height: 16px; flex: none; }
.update-bar .ghost { color: var(--surface); }
.update-bar .ghost:hover { color: var(--surface); background: rgba(255,255,255,.1); }

/* Scanner page: numbered steps, app-install card */
.card-title { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.card-title > svg { width: 36px; height: 36px; padding: 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); flex: none; }
.card-title h2 { margin: 0 0 2px; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: grid; gap: 0; }
.steps li { counter-increment: step; position: relative; display: grid; gap: 4px; padding: 0 0 16px 42px; justify-items: start; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font: 700 13px var(--font); background: var(--accent-soft); color: var(--accent-strong); }
.steps li::after { content: ""; position: absolute; left: 13.5px; top: 30px; bottom: 2px; width: 1px; background: var(--line); }
.steps li:last-child { padding-bottom: 0; } .steps li:last-child::after { display: none; }
.steps li > b { font-size: 14px; }
.steps li > span { color: var(--ink-2); font-size: 13px; line-height: 1.55; }
.steps li .primary { margin-top: 6px; }
.path { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; }
.path i { font: 600 12px var(--font); font-style: normal; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; color: var(--ink); white-space: normal; max-width: 100%; overflow-wrap: anywhere; }
.steps li, .steps li > span { min-width: 0; max-width: 100%; }
.path { gap: 4px 16px; }
.path i { position: relative; }
.path i + i::before { content: "›"; position: absolute; left: -11px; top: 50%; transform: translateY(-52%); color: var(--muted); font-weight: 400; font-size: 14px; }
.app-hero { display: flex; gap: 14px; align-items: center; }
.app-hero img { border-radius: 14px; box-shadow: 0 6px 18px rgba(11,127,140,.28); flex: none; }
.app-hero h2 { margin: 0 0 3px; }
.perks { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 14px 0 16px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.perks span { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.perks svg { width: 15px; height: 15px; color: var(--ok); }
.installed { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); margin-bottom: 16px; }
.installed > svg { width: 20px; height: 20px; flex: none; }

/* report page: sticky header, toolbar, side column */
.study-head { position: sticky; top: 60px; z-index: 15; display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap;
  margin: -24px -28px 16px; padding: 14px 28px 12px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid transparent; }
.study-head.stuck { border-bottom-color: var(--line); box-shadow: 0 6px 16px -12px rgba(15,29,38,.35); }
.sh-left { min-width: 0; }
.sh-back { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; }
.sh-back svg { width: 14px; height: 14px; }
.sh-title { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: 2px; }
.sh-title h1 { margin: 0; line-height: 1.25; }
.sh-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.sh-tools { display: flex; align-items: center; gap: 2px; padding-right: 8px; margin-right: 2px; border-right: 1px solid var(--line); }
.sh-primary { display: flex; align-items: center; gap: 8px; }
.ib-btn { background: transparent; border-color: transparent; color: var(--ink-2); padding: 7px 10px; }
a.ib-btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid transparent; border-radius: var(--radius-sm); font: 500 13.5px var(--font); text-decoration: none; white-space: nowrap; }
.ib-btn svg { width: 16px; height: 16px; flex: none; }
.ib-btn:hover { background: var(--surface); border-color: var(--line); }
.ib-btn.icon-only { padding: 7px 8px; }
.show-sm { display: none; }
.pt-strip .pt-name { color: inherit; text-decoration: none !important; padding-right: 6px; }
.pt-strip .pt-name:hover b { color: var(--accent-strong); }
.badge .x { padding: 0 2px; margin-left: 2px; font-size: 11px; line-height: 1; border: 0; min-height: 0; }
.rep-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px; margin: 2px 0 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.rep-tools select { width: auto; max-width: 260px; min-height: 34px; padding-top: 6px; padding-bottom: 6px; background-color: var(--surface); }
.rep-tools .ai-mini { color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.rep-tools .ai-mini svg { color: var(--accent); }
.rep-manage { margin-left: auto; padding: 0 6px; }
.rep-hint { margin: 0 2px 14px; line-height: 1.5; }
.rep-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 4px; }
.study-details { border-top: 1px solid var(--line); padding-top: 12px; }
.side-card .card-head { padding: 12px 16px; }
.side-pad { padding: 12px 16px; }
.side-pad:empty { display: none; }
.side-pad .empty { padding: 14px 8px; font-size: 13px; }
.side-pad .empty svg { width: 26px; height: 26px; margin-bottom: 6px; }
.side-sub { padding: 6px 16px 0; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.side-sub .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.ai-grid { grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.ai-out { margin-top: 12px; }
/* Side column scrolls with the page: an inner scroll area hid the lower cards (its scrollbar is invisible on Macs). */
.assist { position: static; max-height: none; overflow: visible; }
.assist > * { flex-shrink: 0; }
.pt-strip .kv b .note { font-style: normal; font-weight: 400; color: var(--muted); font-size: 12.5px; text-transform: none; letter-spacing: 0; }
@media (max-width: 1150px) { .assist { top: auto; } }
@media (max-width: 860px) {
  .study-head { top: 56px; margin: -18px -16px 14px; padding: 10px 16px; }
  .sh-actions { width: 100%; justify-content: space-between; }
  .sh-tools { border-right: 0; padding-right: 0; }
  .ib-btn span { display: none; }
  .hide-sm { display: none; } .show-sm { display: inline; }
}
@media (max-width: 420px) { .sh-primary button { padding: 8px 10px; } .rep-manage { margin-left: 0; } }
@media (max-width: 640px) { .sh-primary { flex-wrap: wrap; justify-content: flex-end; min-width: 0; } .sh-actions > * { min-width: 0; } }

/* invoice page */
.inv-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; }
.inv-patient { display: flex; flex-direction: column; gap: 14px; }
.inv-kvs { display: flex; flex-wrap: wrap; gap: 12px 28px; }
.inv-kvs .kv span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; display: block; }
.inv-kvs .kv b { font-weight: 600; font-variant-numeric: tabular-nums; }
.inv-money { display: grid; gap: 10px; align-content: center; }
.inv-amounts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.inv-amounts span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.inv-amounts b { font: 700 22px/1.2 var(--font-display); font-variant-numeric: tabular-nums; }
.inv-bar { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.inv-bar i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.inv-items { display: grid; }
.inv-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.inv-desc { min-width: 0; }
.inv-amt { font-weight: 600; white-space: nowrap; }
.chip-link { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-strong); margin-left: 4px; vertical-align: 1px; }
.chip-link svg { width: 12px; height: 12px; }
.inv-again { margin-top: 4px; color: var(--ink-2); display: flex; align-items: center; gap: 5px; } .inv-again svg { width: 13px; height: 13px; color: var(--muted); flex: none; }
.inv-totals { display: grid; gap: 6px; padding: 14px 18px; margin-left: auto; width: min(340px, 100%); }
.inv-totals > div { display: flex; justify-content: space-between; color: var(--ink-2); }
.inv-totals .grand { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; color: var(--ink); font: 700 17px var(--font-display); }
.inv-notes { padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.amt-row { display: flex; gap: 8px; }
.amt-row input { font: 700 18px var(--font); font-variant-numeric: tabular-nums; }
.amt-row button { white-space: nowrap; }
.method-chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.mchip { display: flex; align-items: center; gap: 6px; margin: 0; padding: 8px 9px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: var(--surface); }
.mchip input { position: absolute; opacity: 0; pointer-events: none; }
.mchip svg { width: 15px; height: 15px; flex: none; color: var(--muted); }
.mchip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); box-shadow: 0 0 0 1px var(--accent) inset; }
.mchip:has(input:checked) svg { color: var(--accent); }
.mchip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.pay-list { display: grid; }
.pay-row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.pay-row:last-child { border-bottom: 0; }
.pay-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); flex: none; }
.pay-ico svg { width: 16px; height: 16px; }
.pay-main { flex: 1; min-width: 0; }
.ib-btn.danger { color: var(--bad); }
.ib-btn.ib-doc { border-color: var(--accent); color: var(--accent); background: var(--accent-soft, transparent); font-weight: 600; }
.ib-btn.ib-doc:hover { background: var(--accent); color: #fff; }
@media (max-width: 860px) { .ib-btn.ib-doc span.show-sm { display: inline; } }
@media (max-width: 860px) { .inv-top { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .inv-amounts b { font-size: 18px; } .method-chips { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Settings → Machines */
.seen-box { margin: 0; padding: 12px 18px; background: var(--info-soft); border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.seen-box > b { color: var(--info); }
.seen-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.machine-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 0; }
.machine { padding: 14px 18px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
.machine.off { opacity: .6; }
.machine-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.decisions { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 5px; font-size: 12.5px; color: var(--ink-2); }
.decisions li { position: relative; padding-left: 16px; line-height: 1.45; }
.decisions li::before { content: ""; position: absolute; left: 2px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.decisions li.ok::before { background: var(--ok); } .decisions li.warn::before { background: var(--warn); } .decisions li.info::before { background: var(--info); }

/* image status tag (awaiting scan / in scan / receiving / uploading / images) */
.itag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font: 600 11.5px var(--font); white-space: nowrap; border: 1px solid transparent; }
.itag svg { width: 12px; height: 12px; }
.itag.ok { background: var(--ok-soft); color: var(--ok); }
.itag.img { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); padding: 3px 8px; font-variant-numeric: tabular-nums; }
.itag.img svg { width: 13px; height: 13px; color: var(--muted); }
/* Status cell: badges on one line, the ⓘ at the right edge (same spot on every row) */
.st-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.st-tags { display: inline-flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.st-cell > .info-tip { margin-left: auto; flex: none; }
.st-tags .wl-tags { margin: 0; gap: 6px; flex-wrap: nowrap; }
@media (max-width: 1199px) { .st-tags, .st-tags .wl-tags { flex-wrap: wrap; } } /* small laptops / tablets: badges may take two lines rather than push the table off screen */
.itag.wait { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.itag.busy { background: var(--info-soft); color: var(--info); }
.itag.busy::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.2s ease-in-out infinite; }
h1 .itag { font-size: 12px; vertical-align: 1px; }

/* one-click copy of a patient ID */
button.copy-id { display: inline-flex; align-items: center; gap: 4px; font: inherit; font-variant-numeric: tabular-nums; color: inherit; background: transparent; border: 1px dashed transparent; border-radius: 6px; padding: 0 5px; margin: 0 -5px; cursor: copy; white-space: nowrap; box-shadow: none; }
button.copy-id svg { width: 13px; height: 13px; opacity: .7; }
button.copy-id:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--accent-strong); }
button.copy-id:hover svg { opacity: 1; }
button.copy-id.copied { border-color: var(--ok); color: var(--ok); }
h1 + .sub button.copy-id, .kv b button.copy-id { font-weight: 600; }
h1 button.copy-id { font-weight: inherit; }
h1 button.copy-id svg { width: 16px; height: 16px; }

/* dashboard: studies-per-day column chart */
.tchart[hidden], .ttable[hidden], main#app table.ttable[hidden] { display: none; }
.tchart { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; padding: 18px 18px 6px; }
.ty { display: flex; flex-direction: column; justify-content: space-between; height: 150px; padding-top: 22px; font-size: 11px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.ty span { line-height: 0; }
.tplot { position: relative; }
.tgrid { position: absolute; inset: 22px 0 auto 0; height: 128px; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.tgrid i { height: 1px; background: var(--line); }
.tcols { position: relative; display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); }
.tc { position: relative; display: flex; flex-direction: column; align-items: center; outline: none; cursor: default; }
.tc-bar { height: 150px; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-top: 22px; }
.tc-bar i { position: relative; display: block; flex: none; width: min(24px, 70%); min-height: 0; background: color-mix(in srgb, var(--accent) 38%, var(--surface)); border-radius: 4px 4px 0 0; transition: background .12s; }
.tc.today .tc-bar i { background: var(--accent); }
.tc:hover .tc-bar i, .tc:focus-visible .tc-bar i { background: var(--accent-strong); }
.tc-val { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding-bottom: 3px; font: 700 12px var(--font); color: var(--ink); font-variant-numeric: tabular-nums; }
.tc-x { display: grid; justify-items: center; gap: 0; padding-top: 6px; border-top: 1px solid var(--line-strong); width: 100%; font-size: 10.5px; color: var(--muted); line-height: 1.3; }
.tc-x b { font-weight: 600; color: var(--ink-2); }
.tc.today .tc-x b { color: var(--accent-strong); }
.tc[data-tip]:hover::after, .tc[data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; bottom: calc(100% - 14px); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--surface); font-size: 11.5px; font-weight: 600; padding: 5px 9px; border-radius: 7px; white-space: nowrap; z-index: 3; pointer-events: none; }
.tcols .tc:first-child[data-tip]:hover::after, .tcols .tc:nth-child(2)[data-tip]:hover::after { left: 0; transform: none; }
.tcols .tc:last-child[data-tip]:hover::after, .tcols .tc:nth-last-child(2)[data-tip]:hover::after { left: auto; right: 0; transform: none; }
.ttable { margin: 8px 0; }
.tmods { padding: 6px 18px 16px; border-top: 1px solid var(--line); margin-top: 8px; display: grid; gap: 7px; }
.tmods-h { display: flex; justify-content: space-between; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 0 2px; }
.tmods-h span:last-child { text-transform: none; letter-spacing: 0; font-weight: 500; }
.tmod { display: grid; grid-template-columns: 110px minmax(0, 1fr) 36px; align-items: center; gap: 10px; font-size: 13px; }
.tmod-n { color: var(--ink-2); }
.tmod-bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.tmod-bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.tmod-v { text-align: right; font-weight: 600; }
@media (max-width: 640px) { .tc-x span { display: none; } .tc:nth-child(odd):not(.today) .tc-x b { visibility: hidden; } .tc-x b { font-size: 9.5px; } .ty { height: 130px; } .tc-bar { height: 130px; } .tgrid { height: 108px; } }

/* scanner watch chip (top bar) and menu badge */
.sw-chip[hidden] { display: none; }
.sw-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; padding: 6px 11px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); max-width: 46vw; }
.sw-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-chip i { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.sw-chip.ok i { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.sw-chip.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); color: var(--warn); } .sw-chip.warn i { background: var(--warn); }
.sw-chip.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); color: var(--bad); } .sw-chip.bad i { background: var(--bad); }
.sw-chip:hover { border-color: var(--accent); color: var(--accent-strong); }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--warn); color: #fff; font: 700 11px/20px var(--font); text-align: center; }
@media (max-width: 640px) { .sw-chip { max-width: 40vw; font-size: 11.5px; padding: 5px 9px; } }

/* dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 12px; }
.kpi { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto; gap: 2px 12px; align-items: center; padding: 14px 16px; color: inherit; text-decoration: none !important; transition: border-color .15s, transform .15s; border-top: 3px solid transparent; }
a.kpi:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.kpi.warn { border-top-color: var(--warn); } .kpi.bad { border-top-color: var(--bad); } .kpi.ok { border-top-color: var(--ok); } .kpi.info { border-top-color: var(--info); }
.kpi .ico { grid-row: span 2; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.kpi .ico svg { width: 17px; height: 17px; }
.kpi .ico.warn { background: var(--warn-soft); color: var(--warn); } .kpi .ico.bad { background: var(--bad-soft); color: var(--bad); }
.kpi .ico.ok { background: var(--ok-soft); color: var(--ok); } .kpi .ico.info { background: var(--info-soft); color: var(--info); }
.kpi .label { color: var(--ink-2); font-size: 12px; font-weight: 500; }
.kpi .value { font: 700 22px/1.15 var(--font-display); font-variant-numeric: tabular-nums; }
.kpi .value.kpi-date { font-size: 20px; white-space: nowrap; }
.kpi .sub { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.kpi { position: relative; }
.kpi-eye { position: absolute; top: 6px; right: 6px; }
.kpi:has(.kpi-eye) .label { padding-right: 26px; }
.eye-btn { padding: 4px 6px; border-color: transparent; background: transparent; color: var(--muted); }
.eye-btn svg { width: 16px; height: 16px; }
.eye-btn:hover { color: var(--accent-strong); background: var(--surface-2); }
.masked { letter-spacing: .08em; color: var(--muted); }
button.masked { all: unset; letter-spacing: .08em; color: var(--muted); cursor: pointer; border-radius: 4px; }
button.masked:hover { color: var(--ink); }
button.masked:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kpi .sub a { color: var(--accent); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 16px; align-items: start; }
.dash-card .empty { padding: 26px 16px; }
.live-chip { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); }
.live-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dlist { display: grid; }
.drow { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none !important; }
.drow:last-child { border-bottom: 0; }
a.drow:hover { background: var(--surface-2); }
.dnum { flex: none; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font: 700 12px var(--font); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.dmain { flex: 1; min-width: 0; }
.d-block { display: block; margin-top: 2px; }
.dtags { flex: none; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.qnow { padding: 10px 18px 14px; display: grid; gap: 4px; }
.qrow { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center; padding: 7px 0; color: inherit; text-decoration: none !important; }
.qname { font-weight: 600; }
.qbar { display: flex; height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.qbar i, .qlegend i { display: block; height: 100%; }
.qbar .done, .qlegend .done { background: var(--ok); } .qbar .scan, .qlegend .scan { background: var(--info); } .qbar .wait, .qlegend .wait { background: var(--warn); }
.qnum { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.qlegend { display: flex; gap: 14px; margin-top: 6px; }
.qlegend span { display: inline-flex; align-items: center; gap: 5px; }
.qlegend i { width: 9px; height: 9px; border-radius: 3px; }
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; } .kpi .value { font-size: 19px; } .kpi .value.kpi-date { font-size: 16px; }
  main#app .m-facts a:not(.btn) { padding-block: 6px; }
  .kpi .sub a { display: inline-block; padding-block: 6px; } .kpi .sub a + br + a { margin-top: -6px; }
  button.masked { display: inline-block; padding-block: 4px; margin-block: -4px; min-height: 28px; line-height: 20px; }
  .qrow { grid-template-columns: 80px 1fr; } .qnum { grid-column: 1 / -1; }
  .drow { padding: 10px 14px; flex-wrap: wrap; } .dtags { width: 100%; justify-content: flex-start; }
}

/* report page: dictation, quick phrases, previous studies, shortcuts */
.dict-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 10px; background: var(--surface-2); }
.dict-bar #dict-status { flex: 1; min-width: 200px; line-height: 1.5; }
button.rec { background: var(--bad); border-color: var(--bad); color: #fff; }
button.rec:hover { color: #fff; background: var(--bad); }
.rec-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); margin-right: 4px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.dict-live { margin: -6px 0 12px; padding: 6px 10px; border-radius: 8px; background: var(--info-soft); color: var(--info); font-style: italic; }
.prior { padding: 10px 0; border-top: 1px solid var(--line); }
.prior:first-child { border-top: 0; padding-top: 0; }
.prior.locked { opacity: .7; }
.prior-imp { margin-top: 6px; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; color: var(--ink-2); }
#priors-list { max-height: 420px; overflow: auto; }
kbd { font: 600 12px var(--font); background: var(--surface-2); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
.kbd-table td { padding: 7px 10px; }

/* calculators */
.calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; align-items: start; }
.calc { display: flex; flex-direction: column; gap: 14px; }
.calc-head { display: flex; gap: 12px; align-items: flex-start; }
.calc-head h2 { margin: 0 0 2px; }
.calc-head .ico { width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.calc-head .ico svg { width: 18px; height: 18px; }
.calc-form .field:last-child { margin-bottom: 0; }
.calc-tight { gap: 10px; }
.calc-checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 14px; }
.calc-out { background: var(--accent-soft); border-radius: 10px; padding: 14px 16px; display: grid; gap: 6px; justify-items: start; }
.calc-out.empty { background: var(--surface-2); }
.calc-out.empty .calc-val { color: var(--muted); }
.calc-val { font: 700 20px/1.3 var(--font-display); }
.calc-note { color: var(--ink-2); line-height: 1.55; }
.calc-copy { margin-top: 4px; }
.calc-ref { margin: 0; padding-top: 10px; border-top: 1px dashed var(--line); }
.calc-tag { display: inline-block; font: 700 13px var(--font); padding: 3px 9px; border-radius: 7px; vertical-align: 3px; margin-right: 4px; background: var(--surface); }
.calc-tag.ok { background: var(--ok-soft); color: var(--ok); }
.calc-tag.warn { background: var(--warn-soft); color: var(--warn); }
.calc-tag.bad { background: var(--bad-soft); color: var(--bad); }
.calc-psa[hidden] { display: none; }

/* sign-in */
body.signed-out .side, body.signed-out .topbar { display: none; }
body.signed-out .layout { grid-template-columns: 1fr; }
body.signed-out main#app { max-width: none; }
.auth-wrap { min-height: calc(100vh - 80px); display: grid; place-items: center; }
.auth-card { width: min(420px, 100%); padding: 28px; }
.auth-card .brand { color: var(--ink); padding: 0 0 18px; }
.auth-card .brand small { color: var(--muted); }

@media (max-width: 1150px) { .workspace { grid-template-columns: minmax(0, 1fr); } .assist { position: static; max-height: none; } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 70; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .side { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(6,14,19,.45); z-index: 65; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); }
  main#app { padding: 18px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); }
  .g2, .g3 { grid-template-columns: 1fr; }
  .topbar .hide-sm { display: none; }
  th, td { white-space: nowrap; }
  .page-head > .row { width: 100%; }
}
.linkrow { flex-wrap: nowrap; }
.linkrow input { flex: 1; min-width: 0; }
.ci-row { flex-wrap: wrap; margin-bottom: 12px; gap: 6px 8px; }
.ci-row select { min-width: 0; }
.ci-row [data-proc] { flex: 1 1 0; }
.ci-row [data-doc] { flex: 1 1 100%; } /* doctor on its own line, procedure + remove below */

/* Phones: tables become stacked cards (each cell shows its column name), nothing is cut off at the edge. */
@media (max-width: 640px) {
  main#app table, .modal table, main#app tbody, .modal tbody { display: block; width: 100%; }
  main#app tr, .modal tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  main#app tr:last-child, .modal tr:last-child { border-bottom: 0; }
  main#app tr:has(> th), .modal tr:has(> th) { display: none; }
  main#app td, .modal td { display: block; padding: 0; border: 0; white-space: normal !important; width: auto !important; max-width: 100%; min-width: 0; text-align: left !important; }
  main#app td:first-child, .modal td:first-child { flex: 1 1 100%; }
  main#app td:empty, .modal td:empty { display: none; }
  main#app td[data-label]:not(:first-child)::before, .modal td[data-label]:not(:first-child)::before { content: attr(data-label); display: block; font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 1px; }
  main#app td:last-child > .row, .modal td:last-child > .row { justify-content: flex-start !important; flex-wrap: wrap !important; }
  main#app td:has(button, .btn, input, select), .modal td:has(button, .btn, input, select) { flex-basis: auto; }
  main#app td:last-child:has(button, .btn), .modal td:last-child:has(button, .btn) { flex: 1 1 100%; }
  main#app td input:not([type="checkbox"]):not([type="radio"]), .modal td input:not([type="checkbox"]):not([type="radio"]) { width: 100%; }
  tr.click:hover td { background: none; }
  tr.click:active { background: var(--surface-2); }
  .table-wrap { overflow: visible; }
  /* queue board: token on the left; patient, then waiting time + bill/Form F, then the actions in one line */
  main#app table.qt tr { display: grid !important; grid-template-columns: 62px minmax(0, 1fr); gap: 6px 12px; align-items: start; }
  main#app table.qt td:nth-child(1) { grid-column: 1; grid-row: 1 / span 3; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
  main#app table.qt td:nth-child(1) .num { font-size: 22px !important; }
  main#app table.qt td:nth-child(1) .tk-re { padding: 2px 4px; font-size: 11.5px; margin-left: -4px; }
  main#app table.qt td:nth-child(2) { grid-column: 2; }
  main#app table.qt td:nth-child(3) { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12.5px; }
  main#app table.qt td:nth-child(3) > div { margin: 0 !important; }
  main#app table.qt td:nth-child(4) { grid-column: 2; }
  main#app table.qt td:nth-child(4) > .row { flex-wrap: nowrap !important; gap: 2px !important; justify-content: flex-start !important; }
  main#app table.qt td:nth-child(4) .sm { padding: 5px 8px; }
  .linkrow { flex-wrap: wrap; }
  .linkrow input { flex: 1 1 100%; }
  .modal-bg { padding: 10px; }
  .modal { padding: 18px; max-height: calc(100dvh - 20px); }
  .card-head { flex-wrap: wrap; gap: 8px; }
}
/* Phones: lists (worklist, patients, invoices, to bill) as two-line rows —
   name + status on top, the rest as one quiet line underneath. Column roles come from <table data-m>. */
@media (max-width: 640px) {
  main#app table[data-m] tr { gap: 4px 14px; padding: 12px 16px; align-items: center; }
  main#app table[data-m] tr::after { content: ""; order: 2; flex: 0 0 100%; height: 0; }
  main#app table[data-m] tr[data-av] { position: relative; padding-left: 58px; }
  main#app table[data-m] tr[data-av] td[data-m="main"] .who > .avatar { position: absolute; left: 16px; top: 13px; }
  main#app table[data-m] td { flex: 0 0 auto; }
  main#app table[data-m] td::before { content: none !important; }
  main#app table[data-m] td[data-m="main"] { order: 0; flex: 1 1 50%; min-width: 0; }
  main#app table[data-m] td[data-m="main"] .who > div { min-width: 0; }
  main#app table[data-m] td[data-m="main"] .who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  main#app table[data-m] td[data-m="end"] { order: 1; flex: 0 0 auto; margin-left: auto; }
  main#app table[data-m] td[data-m="end"] + td[data-m="end"] { margin-left: 0; }
  main#app table[data-m] td[data-m="end"] > .row { flex-direction: column; align-items: flex-end; gap: 4px !important; }
  main#app table[data-m] .m-quiet { display: none; }
  main#app table[data-m] td[data-m="main"] > .row { flex-wrap: nowrap !important; }
  main#app table[data-m] td[data-m="end"] > .row { flex-wrap: nowrap !important; justify-content: flex-end !important; }
  main#app table[data-m] td[data-m="end"] b.num { font-size: 13px; color: var(--muted); }
  main#app table[data-m] td[data-m="metaw"] { order: 4 !important; flex: 0 0 100% !important; color: var(--text); }
  main#app table[data-m] td[data-m="metaw"] > .small { color: var(--muted); }
  main#app table[data-m] td[data-m="metaw"] .small { font-size: 12.5px; }
  main#app table[data-m] td[data-m^="meta"] { order: 5; flex: 0 1 auto; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; min-width: 0; }
  main#app table[data-m] td[data-m^="meta"] > * { margin: 0 !important; }
  main#app table[data-m] td[data-m^="meta"] .row { flex-wrap: nowrap !important; gap: 6px !important; }
  main#app table[data-m] td[data-m^="meta"] > .row > span:not(.mod):not(.badge) { color: var(--text); font-weight: 500; }
  main#app table[data-m] td[data-m^="meta"] .small { font-size: 12.5px; }
  main#app table[data-m] td[data-m="metal"]::before { content: attr(data-label) !important; display: inline; font: 400 12.5px var(--font); letter-spacing: 0; text-transform: none; margin: 0; color: var(--muted); }
  main#app table[data-m] td[data-m="metal"] { gap: 4px; color: var(--text); }
  main#app table[data-m] td[data-m="hide"], main#app table[data-m] td[data-empty] { display: none; }
  main#app table[data-m] td.num { text-align: left !important; }
}
@media (max-width: 520px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .g4 .stat { grid-template-columns: 1fr; padding: 14px; }
  .g4 .stat .ico { grid-row: auto; width: 32px; height: 32px; }
  .g4 .stat .value { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* List paging + search-first patients */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); }
.pager button[disabled] { opacity: .45; cursor: default; }
button.link { background: none; border: 0; box-shadow: none; padding: 0; color: var(--accent-strong); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.pt-more { padding: 10px 16px 14px; border-top: 1px solid var(--line); }
.pt-idle, .pt-none { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 34px 20px; }
.pt-idle > svg, .pt-none > svg { width: 30px; height: 30px; opacity: .45; }
.pt-idle p, .pt-none p { margin: 0; line-height: 1.5; }
.pt-idle b, .pt-none b { color: var(--text); font-size: 15px; }
.empty button svg { width: 16px; height: 16px; display: inline-block; margin: 0; color: currentColor; }
.nowrap { white-space: nowrap; }
.tk-re { display: flex; margin: 4px 0 0 -8px; padding: 2px 8px; font-size: 12px; color: var(--muted); } .tk-re svg { width: 13px; height: 13px; }
/* Billing: day collection by payment method */
.coll-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.coll-head input[type=date] { width: auto; }
.coll-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.coll-grid > div { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.coll-grid b { font: 700 18px var(--font-display); font-variant-numeric: tabular-nums; }
.coll-total { background: var(--accent-soft) !important; border-color: transparent !important; }
.coll-total b { color: var(--accent-strong); }
.coll-list { margin-top: 12px; }
.coll-list summary { cursor: pointer; color: var(--accent-strong); font-weight: 600; padding: 4px 0; }
.coll-list table { margin-top: 8px; }
.ss-bar { height: 6px; border-radius: 99px; background: var(--surface-2); margin-top: 12px; overflow: hidden; } .ss-bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
/* Settings → System health & backup */
.sys-card .card-title { display: flex; align-items: center; gap: 12px; }
.sys-warn { display: grid; gap: 8px; margin: 14px 0 4px; }
.sys-warn > div, .sys-ok { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; font-size: 13.5px; line-height: 1.45; }
.sys-warn svg, .sys-ok svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.sw-bad { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.sw-warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: color-mix(in srgb, var(--warn) 80%, var(--text)); }
.sw-info { background: var(--surface-2); color: var(--text); }
.sw-info svg { color: var(--muted); }
.sys-ok { margin: 14px 0 4px; background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
/* Tiles flow in columns (masonry): each keeps its own height and the next one sits right under it, so opening
   "Biggest parts" pushes down only the tiles below it, with no gaps */
.sys-grid { display: flex; align-items: flex-start; column-gap: 10px; margin-top: 14px; }
.mz-col { flex: 1 1 0; min-width: 0; display: grid; gap: 10px; align-content: start; }
.sys-tile { display: grid; gap: 4px; align-content: start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); min-width: 0; }
.sys-tile b { font: 700 18px var(--font-display); overflow-wrap: anywhere; }
.sys-tile details summary { cursor: pointer; color: var(--accent-strong); margin-top: 4px; }
.sys-tile details .row { padding: 2px 0; }
.sys-tile svg { width: 15px; height: 15px; }
.ss-bar.warn i { background: var(--warn); } .ss-bar.bad i { background: var(--bad); }
.sys-tile .ss-bar { margin-top: 4px; }
.sys-tile .ss-bar { background: var(--line); }
/* Share dialog: WhatsApp message preview */
.wa-preview { margin: 8px 0 0; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, #25d366 10%, var(--surface)); border: 1px solid color-mix(in srgb, #25d366 25%, var(--line)); font: 13px/1.5 var(--font); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); max-height: 240px; overflow: auto; }
.wa-preview { max-width: 100%; min-width: 0; } #sh-kind { flex-wrap: wrap; }
.modal { min-width: 0; max-width: 100%; } .modal input, .modal select, .modal textarea { min-width: 0; max-width: 100%; }

/* "Showing …" banner when a list was opened from a dashboard number */
.view-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 18px; background: var(--info-soft); color: var(--info); border-bottom: 1px solid var(--line); font-size: 13.5px; }
.view-banner svg { width: 16px; height: 16px; flex: none; }
.view-banner span { flex: 1; min-width: 0; }
.view-banner button { color: var(--info); }

.share-chip { gap: 6px; }
.share-chip .perm { padding: 1px 7px; font-size: 11.5px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-2); background: var(--surface); }
.share-chip .perm:hover { border-color: var(--accent); color: var(--accent); }
.share-chip .perm-tag { font-style: normal; font-size: 11.5px; color: var(--muted); }
#rev-note { border: 0; border-radius: var(--radius-sm); margin-bottom: 12px; }

/* PC&PNDT Form F */
.ff-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 18px; }
.ff-grid .span2 { grid-column: 1 / -1; }
@media (max-width: 700px) { .ff-grid { grid-template-columns: minmax(0, 1fr); } }
.ff-todo { background: var(--warn-soft, #fff6e5); border-color: transparent; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ff-decl { margin: 12px 0 6px; padding: 12px 16px; border-left: 3px solid var(--accent); background: var(--surface-2, var(--bg)); font-size: 15.5px; line-height: 1.6; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.ff-pad { width: 100%; max-width: 560px; height: 170px; display: block; border: 1.5px dashed var(--line-strong, var(--line)); border-radius: var(--radius-sm); background: #fff; touch-action: none; cursor: crosshair; }
.ff-done { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--ok-soft, #e6f6ee); }
.ff-done > svg { width: 20px; height: 20px; color: var(--ok, #1a7f4b); flex: none; }
.ff-done > div { flex: 1; min-width: 200px; }
.ff-sign-img { height: 60px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.ff-ind { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; margin-bottom: 8px; }
.ff-ind label.check { align-items: flex-start; line-height: 1.4; }
.ff-ind label.check input { margin-top: 3px; }
@media (max-width: 700px) { .ff-ind { grid-template-columns: minmax(0, 1fr); } }
.ff-card { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.ff-card .ff-ico svg { width: 26px; height: 26px; color: var(--accent); }
.ff-card .ff-txt { flex: 1; min-width: 220px; }
.btn.ff-need { border-color: var(--warn); color: var(--warn); }
.ff-reg { font-size: 13.5px; }
.ff-reg td, .ff-reg th { vertical-align: top; }
.ff-reg td .small { margin-top: 2px; }
tr.ff-warnrow td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.ff-alert.bad { background: var(--bad-soft); color: var(--bad); }
.ff-alert.bad .btn { color: var(--bad); }
.badge.ff-tag { background: var(--accent-soft); color: var(--accent-strong, var(--accent)); }
.ff-note { margin-top: 6px; }
.ff-note.bad { color: var(--bad); display: flex; gap: 6px; align-items: flex-start; }
.ff-note.bad svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }

/* Phones: 16px text in boxes, so iPhone Safari does not zoom the page in when a box is tapped (and stay zoomed). */
@media (max-width: 760px), (pointer: coarse) { input, select, textarea { font-size: 16px; } }
@media (max-width: 640px) {
  /* Same spacing between every field, whether or not it sits in a grid. */
  .grid:has(> .field) { row-gap: 0; }
  /* Price list: procedure name on top, then labelled Code · Type · Price · On in one fixed row (any phone width). */
  main#app table.pl-table tr:not(:first-child) { display: grid !important; grid-template-columns: minmax(0, 1.2fr) 58px minmax(0, 1.2fr) 34px; gap: 4px 8px; padding: 12px 14px; align-items: end; }
  main#app table.pl-table tr::after { display: none !important; }
  main#app table.pl-table td { padding: 0 !important; margin: 0 !important; min-width: 0; width: auto !important; }
  main#app table.pl-table td[data-m="main"] { grid-column: 1 / -1; grid-row: 1; }
  main#app table.pl-table td { order: 0 !important; display: block !important; flex: none !important; }
  main#app table.pl-table td:nth-child(1) { grid-row: 2; grid-column: 1; }
  main#app table.pl-table td:nth-child(3) { grid-row: 2; grid-column: 2; }
  main#app table.pl-table td:nth-child(4) { grid-row: 2; grid-column: 3; }
  main#app table.pl-table td:nth-child(5) { grid-row: 2; grid-column: 4; }
  main#app table.pl-table td input:not([type="checkbox"]) { width: 100% !important; min-width: 0; }
  main#app table.pl-table td::before { display: none !important; }
  main#app table.pl-table td:not([data-m="main"])::before { content: attr(data-label) !important; display: block !important; font: 600 10.5px var(--font); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 4px 0 3px; }
  main#app table.pl-table td[data-m="end"] { text-align: center; }
  /* the tick sits in a box as tall as the inputs beside it, so labels and controls line up */
  main#app table.pl-table td.pl-on input[type="checkbox"] { display: block; width: 22px; height: 22px; margin: 12px auto 9px; } /* 12px: merges with the label's 3px bottom margin */
  main#app table.pl-table td:not([data-m="main"])::before { line-height: 14px !important; }
  main#app table.pl-table td input { display: block; }
  form#np { display: grid !important; grid-template-columns: minmax(0, 1.2fr) 58px minmax(0, 1.2fr) auto; gap: 8px; padding: 12px 14px; }
  form#np > * { width: 100% !important; min-width: 0 !important; margin: 0 !important; }
  form#np input[name="name"] { grid-column: 1 / -1; grid-row: 1; }
  form#np input[name="code"] { grid-row: 2; grid-column: 1; } form#np input[name="modality"] { grid-row: 2; grid-column: 2; }
  form#np input[name="price"] { grid-row: 2; grid-column: 3; } form#np button { grid-row: 2; grid-column: 4; }
}
.users-roles summary { cursor: pointer; color: var(--accent-strong, var(--accent)); width: fit-content; }
.users-roles[open] { max-width: 640px; }

/* ---------- Phone polish ---------- */
@media (max-width: 640px) {
  /* Study page header: labelled tools in one scrollable row, actions as an even grid. */
  .sh-actions { flex-direction: column; align-items: stretch; gap: 8px; min-width: 0; max-width: 100%; }
  .study-head > * { min-width: 0; max-width: 100%; }

  /* Cards with an icon, text and a button (Form F, choose procedure): icon beside the text, button full width below. */
  .ff-card { display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: start; gap: 4px 12px; }
  .ff-card .ff-ico { padding-top: 2px; }
  .ff-card > .btn, .ff-card > button { grid-column: 1 / -1; justify-content: center; }
  /* Notice banners: text first, button below. */
  .view-banner.card { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px 10px; align-items: start; }
  .view-banner.card > svg { margin-top: 2px; }
  .view-banner.card > .btn, .view-banner.card > button { grid-column: 2; justify-self: start; }
  /* Worklist: filters fold away; each study is one clean block. */
  #filters .wl-more { display: none; }
  #filters.open .wl-more { display: contents; }
  #filters .wl-toggle { display: inline-flex; }
  main#app table[data-m] td[data-m="metaw"] { display: block !important; }
  main#app table[data-m] td[data-m="metaw"] > .row { display: flex; flex-wrap: nowrap !important; align-items: flex-start; }
  main#app table[data-m] td[data-m="metaw"] > .row > span:last-child { min-width: 0; }
}
#filters .wl-toggle { display: none; }
@media (max-width: 640px) { #filters .wl-toggle { display: inline-flex; } }
.wl-date { position: relative; display: inline-flex; align-items: center; }
.wl-date > span { position: absolute; left: 11px; font-size: 12px; color: var(--muted); pointer-events: none; }
.wl-date > input:not(.has-val) { color: transparent; }
.wl-date > input:not(.has-val)::-webkit-datetime-edit { color: transparent; }
.wl-date > input.has-val + span, .wl-date > input:focus + span { display: none; }
.wl-ref-in { display: none; margin-top: 3px; }
/* Tablets and small laptops: the referrer moves under the study, so the worklist fits without sideways scrolling */
@media (min-width: 861px) and (max-width: 1099px) { main#app th.wl-ref, main#app td.wl-ref { display: none; } .wl-ref-in { display: block; } }
.wl-queue { display: flex; align-items: center; gap: 6px; margin: 6px 0 0 42px; }
.wl-tags { display: inline-flex; gap: 4px; flex-wrap: wrap; vertical-align: middle; margin-left: 4px; }
@media (min-width: 641px) { #filters .wl-more { display: contents; } }

/* ---------- Phones: lists become separate cards ----------
   A box that holds a list (table or .dlist) loses its own frame; its title row stays on the page background,
   and every row becomes its own rounded card with space between. Computers keep the tables. */
@media (max-width: 640px) {
  main#app .card.flush:has(table[data-m], table.qt, > .dlist, > div > .dlist) { background: transparent; border: 0; box-shadow: none; overflow: visible; border-radius: 0; }
  main#app .card.flush:has(table[data-m], table.qt, > .dlist, > div > .dlist) > .card-head { padding: 4px 2px 10px; border-bottom: 0; background: transparent; }
  main#app .card.flush:has(table[data-m], table.qt, > .dlist, > div > .dlist) > .toolbar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; box-shadow: var(--shadow); }
  main#app .card.flush:has(table[data-m], table.qt, > .dlist, > div > .dlist) .table-wrap { padding: 0; }
  main#app table[data-m] tr:not(:has(> th)), main#app table.qt tr {
    background: var(--surface); border: 1px solid var(--line) !important; border-radius: 14px; margin: 0 0 10px; box-shadow: var(--shadow);
  }
  main#app table[data-m] tr.click:active, main#app table.qt tr:active { background: var(--surface-2); }
  main#app .card.flush .dlist { display: flex; flex-direction: column; gap: 10px; }
  main#app .card.flush:has(> .dlist, > div > .dlist) .drow { background: var(--surface); border: 1px solid var(--line) !important; border-radius: 14px; box-shadow: var(--shadow); }
  main#app .card.flush .pager { background: transparent; border-top: 0; padding: 4px 0 0; }
  main#app .card.flush:has(table[data-m], table.qt, > .dlist, > div > .dlist) .empty { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
  main#app .card.flush .view-banner:not(.card) { border-radius: 12px; margin-bottom: 10px; border: 0; }
}
@media (max-width: 640px) { main#app table[data-m] td[data-m="end"] > .row:has(> button + button) { flex-direction: row !important; align-items: center; } }

/* ---------- Phone cards: refined look ---------- */
@media (max-width: 640px) {
  main#app table[data-m] tr:not(:has(> th)), main#app table.qt tr, main#app .card.flush:has(> .dlist, > div > .dlist) .drow {
    border-radius: 16px; border-color: color-mix(in srgb, var(--line) 80%, transparent) !important;
    box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 6px 16px -10px rgba(0,0,0,.25); padding: 14px 16px !important; position: relative; overflow: hidden;
  }
  /* status stripe on the left edge: amber pending · blue draft / in scan · red STAT/urgent · green signed */
  main#app tr[data-accent]:not([data-accent=""])::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
  main#app tr[data-accent="warn"]::before { background: var(--warn); }
  main#app tr[data-accent="info"]::before { background: var(--info); }
  main#app tr[data-accent="bad"]::before { background: var(--bad); }
  main#app tr[data-accent="ok"]::before { background: var(--ok); }
  main#app table[data-m] td[data-m="main"] .who b { font-size: 15.5px; }
  main#app table[data-m] td[data-m="main"] .who .small { font-size: 12.5px; }
  /* section titles above a group of cards */
  main#app .card.flush:has(table[data-m], table.qt, > .dlist, > div > .dlist) > .card-head h2 { font-size: 16.5px; }
  /* page title buttons (Register patient, Waiting-room display…): full width, centred */
  .page-head > button, .page-head > .btn, .page-head > a.btn { width: 100%; justify-content: center; white-space: nowrap; }
  /* filter tabs: the selected one clearly marked */
  .chips button.on { background: var(--accent); color: var(--accent-ink, #fff); box-shadow: none; }
}
@media (max-width: 640px) {
  main#app table[data-m] tr[data-av]:not(:has(> th)) { padding-left: 62px !important; }
  main#app table[data-m] tr[data-av] td[data-m="main"] .who > .avatar { left: 16px; top: 14px; }
  .page-head > button, .page-head > .btn, .page-head > a.btn { justify-content: center !important; gap: 8px; }
}

@media (max-width: 640px) {
  /* "New version" bar and messages: full width at the bottom, above the phone's home bar */
  .update-bar { left: 10px; right: 10px; transform: none; max-width: none; bottom: calc(10px + env(safe-area-inset-bottom)); flex-wrap: wrap; gap: 8px 10px; padding: 12px 14px; border-radius: 14px; font-size: 14px; }
  .update-bar > span { flex: 1 1 calc(100% - 30px); }
  .update-bar > button { flex: 1 1 0; justify-content: center; padding: 9px 12px; }
  .toast-wrap { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; border-radius: 12px; }
}
body:has(.update-bar) .toast-wrap { bottom: 76px; }

/* Phone-only and computer-only bits for cards (breakpoint 640px, same as the card layout) */
.m-only { display: none !important; }
@media (max-width: 640px) {
  .m-only { display: revert !important; }
  .m-facts.m-only { display: flex !important; flex-direction: column; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
  .d-only { display: none !important; }
  .m-fact { display: flex; align-items: center; gap: 6px; font-size: 13px; line-height: 1.3; min-width: 0; }
  .m-fact > svg { width: 15px; height: 15px; flex: none; color: var(--muted); }
  .m-fact .m-l { color: var(--muted); flex: none; }
  .m-fact .m-l::after { content: ":"; }
  .m-fact .m-v { color: var(--ink); font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
  .m-fact .m-v a { color: var(--accent-strong, var(--accent)); }
  span.m-only.m-l { margin-right: 4px; color: var(--muted); font-weight: 400; }
}

/* Phone cards with labelled facts: status badge / main button pinned top-right, facts use the full width */
@media (max-width: 640px) {
  main#app table[data-m] tr:has(.m-facts) { position: relative; align-items: flex-start; }
  main#app table[data-m] tr:has(.m-facts) td[data-m="main"] { flex: 1 1 100% !important; }
  main#app table[data-m] tr:has(.m-facts) td[data-m="main"] .who { padding-right: 92px; }
  main#app table[data-m] tr:has(.m-facts) td[data-m="end"] { position: absolute; top: 14px; right: 14px; margin: 0 !important; }
  main#app table[data-m] tr:has(.m-facts) td[data-m="end"] + td[data-m="end"] { top: 46px; }
  .m-fact .m-sub { font-weight: 400; color: var(--muted); }
  /* To bill: first three, then "Show all" */
  main#app .card:not(.tb-open) table.tb-list tr.tb-more { display: none !important; }
  .tb-showall { width: 100%; justify-content: center; margin-top: 2px; }
}
@media (max-width: 640px) {
  main#app table[data-m] tr:has(.m-facts) td[data-m="end"] + td[data-m="end"] { position: static; order: 9 !important; flex: 1 1 100% !important; margin-top: 10px !important; }
  main#app table[data-m] tr:has(.m-facts) td[data-m="end"] + td[data-m="end"] button { width: 100%; justify-content: center; }
  main#app table[data-m] tr:has(.m-facts) td[data-m="end"] + td[data-m="end"]:empty { display: none; }
}

/* ---------- Phone bottom menu bar ---------- */
#bnav { display: none; }
@media (max-width: 640px) {
  #bnav { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); transition: transform .22s ease; }
  #bnav a, #bnav button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px 2px; border: 0; background: none; box-shadow: none;
    color: var(--muted); font: 600 11px var(--font); text-decoration: none; border-radius: 12px; min-width: 0; }
  #bnav svg { width: 22px; height: 22px; }
  #bnav span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  #bnav .on { color: var(--accent-strong, var(--accent)); }
  #bnav .on svg { background: var(--accent-soft); border-radius: 999px; padding: 3px 14px; width: 50px; height: 28px; box-sizing: border-box; }
  #bnav .bn-badge { position: absolute; top: 2px; left: calc(50% + 8px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: var(--warn); color: #111; font: 700 10.5px/17px var(--font); font-style: normal; text-align: center; }
  body.bn-hide #bnav, body.bn-typing #bnav, body.signed-out #bnav { transform: translateY(110%); }
  main#app { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  /* messages and the update bar sit above the menu */
  .toast-wrap { bottom: calc(78px + env(safe-area-inset-bottom)); }
  .update-bar { bottom: calc(78px + env(safe-area-inset-bottom)); }
  body:has(.update-bar) .toast-wrap { bottom: calc(190px + env(safe-area-inset-bottom)); }
  body.bn-hide .toast-wrap, body.bn-hide .update-bar { bottom: calc(10px + env(safe-area-inset-bottom)); }
  body.bn-hide:has(.update-bar) .toast-wrap { bottom: calc(122px + env(safe-area-inset-bottom)); }
}

.q-sec { display: contents; }
@media (max-width: 640px) {
  /* Reception card: one big Call / Done button; the rest behind ⋯ */
  main#app table.qt td:nth-child(4) > .q-acts { display: flex; flex-wrap: wrap !important; gap: 6px !important; width: 100%; }
  main#app table.qt .q-main { flex: 1 1 auto; justify-content: center; padding: 11px 14px !important; font-size: 15px; font-weight: 600; border-radius: 12px; }
  main#app table.qt .q-main:not(.primary) { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
  main#app table.qt .q-more { flex: none; width: 46px; justify-content: center; font-size: 18px; padding: 8px 0 !important; border-radius: 12px; }
  main#app table.qt .q-sec { display: none; }
  main#app table.qt tr.q-open .q-sec { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; width: 100%; order: 3; }
  main#app table.qt tr.q-open .q-sec button { width: 100%; justify-content: center; border: 1px solid var(--line); padding: 9px 8px !important; }
  main#app table.qt tr:has(.q-acts) td:nth-child(4) { grid-column: 1 / -1 !important; margin-top: 4px; }
}

@media (max-width: 640px) {
  .m-fact.m-tags { gap: 6px; flex-wrap: wrap; }
  .m-fact .m-v .mod { margin-right: 4px; }
  /* dashboard list cards: badges / buttons pinned top-right, facts below a dashed line */
  main#app .drow:has(.m-facts) { position: relative; align-items: flex-start; }
  main#app .drow:has(.m-facts) .dmain { flex: 1 1 100%; padding-right: 96px; }
  main#app .drow:has(.m-facts) .dmain .m-facts { margin-right: -96px; }
  main#app .drow:has(.m-facts) .dtags { position: absolute; top: 14px; right: 14px; flex-direction: column; align-items: flex-end; gap: 4px; }
  main#app .drow:has(.m-facts) .dnum + .dmain { padding-right: 96px; }
}
@media (max-width: 640px) {
  main#app .drow:has(.m-facts) { flex-wrap: nowrap !important; gap: 12px; }
  main#app .drow:has(.m-facts) .dmain { flex: 1 1 0 !important; min-width: 0; }
  main#app .drow:has(.m-facts) .dnum { flex: none; }
}

/* ---------- Phones: study page action bar at the top (menu-bar style); slides away on scroll down ---------- */
#sbar { display: none; }
@media (max-width: 640px) {
  body.has-sbar .study-head { position: static; margin-bottom: 0; }
  body.has-sbar .sh-actions { display: none !important; }
  #sbar { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); align-items: center; gap: 4px; position: sticky; top: 56px; z-index: 18;
    margin: 0 -16px 14px; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
    padding: 6px 8px; transition: transform .22s ease, opacity .22s; }
  #sbar > button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px 2px; border: 0; background: none; box-shadow: none;
    color: var(--muted); font: 600 11px var(--font); border-radius: 12px; min-width: 0; }
  #sbar > button svg { width: 22px; height: 22px; }
  #sbar > button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  #sbar > button.sb-primary { background: var(--accent); color: var(--accent-ink); padding: 8px 4px; }
  #sbar > button:disabled { opacity: .5; }
  #sbar .sb-sheet { position: absolute; right: 8px; top: calc(100% + 6px); min-width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; display: grid; gap: 2px; }
  #sbar .sb-sheet[hidden] { display: none; }
  #sbar .sb-sheet button { justify-content: flex-start; border: 0; background: none; box-shadow: none; padding: 11px 12px; font-size: 14.5px; border-radius: 10px; }
  #sbar .sb-sheet button:active { background: var(--surface-2); }
  body.bn-hide #sbar { transform: translateY(calc(-100% - 60px)); opacity: 0; pointer-events: none; }
}

/* Filter bars on tablets and computers: every control the same height (38px), search box shrinks first so the row fits */
@media (min-width: 641px) {
  .toolbar { gap: 8px; }
  .toolbar .search { flex: 1 1 180px; min-width: 160px; max-width: 380px; }
  .toolbar input:not([type="checkbox"]):not([type="radio"]), .toolbar select { height: 38px; min-height: 38px; padding-top: 0; padding-bottom: 0; box-sizing: border-box; }
  .toolbar .chips { height: 38px; box-sizing: border-box; align-items: stretch; }
  .toolbar .chips button { display: inline-flex; align-items: center; padding-top: 0; padding-bottom: 0; }
  .toolbar > button, .toolbar > .btn, .toolbar .wl-more > button { height: 38px; box-sizing: border-box; }
  .toolbar .wl-date input { width: 150px; }
}
@media (min-width: 641px) { .toolbar .wl-date { height: 38px; align-items: center; } .toolbar .wl-date input { margin: 0; } }
@media (min-width: 641px) { .toolbar label.wl-date { margin: 0; } }

/* Controls side by side: same height (reception procedure row, Form F register month picker and "Mark as sent" row) */
.ci-row > button { height: 38px; min-width: 38px; justify-content: center; }
#m-prev, #m-next { height: 38px; min-width: 38px; justify-content: center; }
#m-pick, #sub-on, #sub-note { height: 38px; box-sizing: border-box; padding-top: 0; padding-bottom: 0; }
#sub-ok { height: 38px; }

/* Phones: filter bars as one clean block — search full width, tabs stretch across, Filters at the right edge */
@media (max-width: 640px) {
  .toolbar { gap: 8px; }
  .toolbar .search { flex: 1 1 100% !important; max-width: none !important; width: 100%; }
  .toolbar .chips { flex: 1 1 auto; min-width: 0; height: 40px; box-sizing: border-box; align-items: stretch; }
  .toolbar .chips button { flex: 1 1 auto; justify-content: center; display: inline-flex; align-items: center; padding: 0 6px; }
  .toolbar > .wl-toggle { flex: none; height: 40px; }
  /* opened "Filters": a 2-column grid, every control 40px tall —
     row 1: modality | study date; row 2: Mine / Shared with me | Clear */
  #filters.open .wl-more { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; flex: 1 1 100%; align-items: stretch; }
  #filters.open .wl-more > * { margin: 0; min-width: 0; height: 40px; box-sizing: border-box; }
  #filters.open .wl-more > select { grid-column: 1 / 3; width: 100%; }
  #filters.open .wl-more > .wl-date { grid-column: 3 / 5; display: flex; }
  #filters.open .wl-more > .chips { grid-column: 1 / 4; }
  #filters.open .wl-more > #clear { grid-column: 4; padding: 0; justify-content: center; }
  #filters.open .wl-more > select + .wl-date + #clear { grid-column: 1 / -1; } /* no Mine / Shared (front desk): Clear spans the row */
  /* iPhone draws an empty date box taller than other boxes: make it a plain 40px box */
  #filters .wl-date input { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 40px; min-height: 0; margin: 0; padding: 0 12px; line-height: 40px; box-sizing: border-box; }
}
.wl-toggle .wl-n { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 11px; line-height: 18px; text-align: center; }
@media (max-width: 380px) { .wl-toggle .wl-tl { display: none; } .toolbar .chips button { padding: 0 4px; font-size: 12px; } }
@media (max-width: 640px) {
  #filters .wl-date > span { font-size: 15px; color: var(--muted); }
  #filters.open .wl-more > #clear { border: 1px solid var(--line); padding: 0 16px; }
}
.install-now { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.install-now .primary { padding: 11px 18px; font-size: 15px; }

/* Branches: picker in the top bar, tag on lists */
.br-pick[hidden] { display: none; }
.br-pick { position: relative; display: inline-flex; align-items: center; }
.br-pick > svg { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--accent); pointer-events: none; }
.br-pick select { min-height: 36px; padding: 6px 32px 6px 32px; border-radius: 99px; font-size: 13px; font-weight: 600; max-width: 220px; }
.br-one { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 6px 11px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); }
.br-one svg { width: 15px; height: 15px; color: var(--accent); }
.br-tag { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--ink-2); background: var(--surface-2, rgba(127,127,127,.1)); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.br-tag svg { width: 12px; height: 12px; }
@media (max-width: 640px) {
  .br-pick select { max-width: 132px; font-size: 12.5px; padding-left: 28px; }
  .br-one .lbl { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Measurements from the scanner (report page side panel) */
.ms-list { display: grid; gap: 2px; font-size: 13px; }
.ms-sec { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 8px 0 2px; }
.ms-sec:first-child { margin-top: 0; }
.ms-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.ms-row:last-child { border-bottom: 0; }
.ms-row b { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Report page: images always in view.
   Desktop: the Images card stays pinned under the sticky study header while the report scrolls.
   Narrower screens and phones: the Images card comes before the report instead of after it. */
@media (min-width: 1151px) {
  .workspace > .assist { align-self: stretch; }
  /* (Images card first in the column; not pinned: a pinned card covered the cards scrolling beneath it.
     "View images" in the pinned study header keeps the images one click away.) */
}
@media (max-width: 1150px) {
  .workspace { display: flex; flex-direction: column; align-items: stretch; } /* every card full width when stacked */
  .workspace > .assist { display: contents; }
  .workspace > .assist > * { order: 2; }
  .workspace > .assist > #img-card { order: -1; }
  .workspace > .report-card { order: 1; }
}
.lr-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--surface); color: var(--accent); flex-shrink: 0; }
.lr-ico svg { width: 18px; height: 18px; }

/* Report form: slim indication on top, optional sections behind "+" buttons */
textarea.autogrow { min-height: 40px; resize: none; overflow: hidden; }
.hx-field textarea { background: var(--accent-soft); border-color: transparent; }
.hx-field textarea:focus { background: var(--surface-2); }
.opt-sec[hidden], .opt-add[hidden], [data-add-opt][hidden] { display: none !important; }
.opt-add { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 12px; }
.opt-add button { color: var(--muted); border-style: dashed; }
.opt-add button:hover { color: var(--accent); }
.tpl-note { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }
.tpl-note:empty { display: none; }
.tpl-note svg { width: 14px; height: 14px; color: var(--ok, #1a7f4b); flex-shrink: 0; }
.linklike { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.scan-live { display: flex; align-items: center; gap: 10px; margin-top: 14px; background: var(--info-soft); border-color: transparent; color: var(--ink); }
.scan-live[hidden] { display: none; }
.scan-live > .spinner, .view-banner.scan-live > .spinner { flex: none; width: 16px; height: 16px; color: var(--info); grid-column: auto; }
.scan-live > .sl-text { flex: 1; text-align: left; }

/* In the image viewer, messages sit at the top centre (clear of the key-image panel and the tools) and never block clicks. */
body:has(.dv) .toast-wrap { top: 72px; bottom: auto; left: 50%; right: auto; transform: translateX(-50%); pointer-events: none; justify-items: center; }
body:has(.dv) .toast { max-width: min(560px, calc(100vw - 32px)); }
.scan-match { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; margin-bottom: 8px; border-radius: 10px; background: var(--info-soft); color: var(--ink); }
.scan-match svg { width: 15px; height: 15px; flex: none; margin-top: 2px; color: var(--info); }

/* Report page: today's queue (Start scan / Scan done) */
.queue-bar { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px 16px; }
.queue-bar[hidden] { display: none; }
.queue-bar .qb-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); color: var(--muted); flex: none; }
.queue-bar .qb-ico.on { background: var(--accent-soft); color: var(--accent); }
.queue-bar .qb-ico svg { width: 19px; height: 19px; }
.queue-bar .qb-text { flex: 1; min-width: 0; }
@media (max-width: 640px) { .queue-bar { flex-wrap: wrap; } .queue-bar button { width: 100%; justify-content: center; } }
/* buttons on a message */
.toast.has-act { flex-wrap: wrap; }
.toast-act { display: flex; gap: 6px; width: 100%; justify-content: flex-end; }
.toast-act button { min-height: 32px; }
.toast-act button:not(.primary) { background: transparent; color: inherit; border-color: rgba(255,255,255,.35); }

/* Patient search results (Reception check-in): name and details on the left, "Select" on the right, never on top of each other */
.pick-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; height: auto; min-height: 56px; padding: 8px 12px; border-radius: 0; border-bottom: 1px solid var(--line); text-align: left; white-space: normal; }
.pick-row .who, .pick-line .who { flex: 1; min-width: 0; }
.pick-row .who > div, .pick-line .who > div { min-width: 0; }
.pick-row .who .small, .pick-line .who .small { overflow-wrap: anywhere; }
.pick-row .pick-sel { flex: none; color: var(--accent); font-weight: 600; }

/* Settings → Price list (desktop/tablet): the procedure name gets the spare width, headers sit over their boxes */
@media (min-width: 641px) {
  .pl-table { width: 100%; table-layout: auto; }
  .pl-table th, .pl-table td { padding: 8px 6px; }
  .pl-table th:first-child, .pl-table td:first-child { padding-left: 14px; }
  .pl-table th:last-child, .pl-table td:last-child { padding-right: 14px; }
  .pl-table .pl-code { width: 70px; }
  .pl-table td:nth-child(2) { width: 100%; }
  .pl-table .pl-name { width: 100%; min-width: 140px; text-overflow: ellipsis; }
  .pl-table .pl-type { width: 52px; text-transform: uppercase; }
  .pl-table .pl-price { width: 88px; text-align: right; }
  .pl-table th.num, .pl-table td.num { text-align: right; }
  .pl-table th.pl-on, .pl-table td.pl-on { text-align: center; width: 44px; }
}
@media (min-width: 641px) {
  /* header text starts where the text inside each box starts (box padding ~12px) */
  .pl-table th { padding-left: 18px; }
  .pl-table th:first-child { padding-left: 26px; }
  .pl-table th.num { padding-right: 18px; }
  .pl-table th.pl-on { padding-left: 6px; }
  /* the "add procedure" row: same columns as the table, Add on the same line */
  form#np.toolbar { display: grid; grid-template-columns: 70px minmax(0, 1fr) 52px 88px auto; gap: 6px 12px; align-items: center; padding: 10px 14px; }
  form#np.toolbar > input { width: 100% !important; min-width: 0 !important; flex: none !important; }
}

/* Settings → Centre: print style choice and letterhead upload */
.print-styles { display: grid; gap: 8px; margin-bottom: 12px; }
.ps-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.ps-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.ps-opt input { margin-top: 3px; width: 18px; }
.ps-opt > span { display: grid; gap: 2px; }
.lh-box { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 12px; }
.lh-box[hidden], #lh-margins[hidden] { display: none; }
.lh-thumb { width: 110px; aspect-ratio: 210 / 297; object-fit: cover; border: 1px solid var(--line); border-radius: 6px; background: #fff; flex: none; }
.lh-thumb.empty { display: grid; place-items: center; align-content: center; gap: 6px; color: var(--muted); background: var(--surface-2); }
.lh-thumb.empty svg { width: 22px; height: 22px; }
input.bad-input, input[data-phone]:invalid:not(:placeholder-shown):not(:focus) { border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent); }

/* AI assistant card (report page) */
.ai-card .ai-group { margin-top: 12px; }
.ai-card .ai-gl, .ai-ba .ai-gl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.ai-card .ai-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ai-card .ai-btns button { min-height: 36px; font-size: 13px; padding: 6px 10px; text-align: left; line-height: 1.25; white-space: normal; height: auto; min-width: 0; }
.ai-card .ai-btns button[hidden] { display: none; }
.ai-res { margin-top: 12px; border: 1px solid var(--accent); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.ai-res ol, .ai-res ul { margin: 6px 0; padding-left: 20px; }
.ai-acts { gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.ai-ba { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 8px 0; }
.ai-ba .ai-txt { white-space: pre-wrap; font-size: 13px; line-height: 1.5; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; max-height: 240px; overflow: auto; }
.ai-ba > div:last-child .ai-txt { border-color: var(--accent); background: var(--accent-soft); }
.ai-src { margin: 6px 0 0; }
@media (max-width: 1150px) { .ai-card .ai-btns { grid-template-columns: 1fr 1fr 1fr; } }
@media (max-width: 640px) { .ai-card .ai-btns { grid-template-columns: 1fr 1fr; } }
/* Day summary / Ask your data */
.day-sum { white-space: pre-wrap; font: 13px/1.6 var(--font, system-ui); background: var(--bg-soft, rgba(127,127,127,.08)); border-radius: 10px; padding: 12px 14px; max-height: 55vh; overflow: auto; margin: 8px 0 0; }
.ask-big { font-size: 32px; font-weight: 700; margin: 4px 0 8px; }
.bad-text { color: var(--bad); }
.pick-list { display: grid; gap: 4px; max-height: 50vh; overflow: auto; margin-top: 8px; }
.pick-list .pick-row { display: flex; gap: 8px; align-items: center; }
.pick-list .pick-row b { margin-left: auto; }
/* Phone top bar: everything fits in the width; the page name is in the bottom menu already. */
.topbar > * { min-width: 0; }
.topbar #top-new, .topbar .menu-btn { flex: none; }
@media (max-width: 640px) {
  .topbar { gap: 8px; }
  .topbar .crumb { display: none; }
  .br-pick { flex: 0 1 auto; min-width: 0; }
  .br-pick select { max-width: 100%; min-width: 96px; text-overflow: ellipsis; }
  .sw-chip { flex: 0 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
}
/* New centre: setup checklist on the admin dashboard */
.get-ready { margin-bottom: 14px; }
.gr-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin-top: 12px; }
.gr-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); text-decoration: none; }
.gr-item:hover { border-color: var(--accent); }
.gr-item.done { opacity: .72; }
.gr-item.done b { text-decoration: line-through; }
.gr-dot { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--muted); display: grid; place-items: center; margin-top: 1px; }
.gr-item.done .gr-dot { background: var(--ok, #1a9e6a); border-color: transparent; color: #fff; }
.gr-dot svg { width: 13px; height: 13px; }
/* A text-style button inside a label (e.g. "Full amount") */
.link-btn { background: none; border: 0; padding: 0 0 0 6px; color: var(--accent-strong, var(--accent)); font-weight: 600; cursor: pointer; min-height: 0; box-shadow: none; }
.link-btn:hover { text-decoration: underline; background: none; }
/* Invoice header on phones: the few tools and the main button share one row (the study page stacks its many actions). */
@media (max-width: 640px) { .sh-actions.sh-one-row { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: nowrap; } }
/* Admin: who is signed in now (bottom of the menu) */
.online { padding: 8px 12px 10px; border-top: 1px solid rgba(255,255,255,.08); display: grid; gap: 6px; max-height: 32vh; overflow: auto; }
.online-h { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8aa0ab; text-decoration: none; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.online-h:hover { color: #fff; }
.online-row { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: #d5e1e7; }
.online-row i { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #5b6b73; margin-top: 5px; }
.online-row i.on { background: #2fca7f; box-shadow: 0 0 0 3px rgba(47,202,127,.18); }
.online-row span { display: grid; min-width: 0; }
.online-row b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-row small { color: #8aa0ab; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wait-ico { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin: 0 auto; background: var(--accent-soft); color: var(--accent); }
.wait-ico svg { width: 28px; height: 28px; }
.dev-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dev-row > span:first-child { display: grid; min-width: 0; }
.dev-row small { color: var(--muted); font-size: 12px; }
.online-h .badge { background: rgba(245,166,35,.18); color: #f5b955; border: 0; font-size: 10.5px; padding: 1px 7px; letter-spacing: .02em; }
.nav-mini .online { display: none; }
.st-on { color: var(--ok, #1a9e6a); display: inline-flex; align-items: center; gap: 6px; }
.st-on i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 20%, transparent); }
/* Who created / last changed a record */
.stamp { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; line-height: 1.5; }
.stamp .info-tip { display: inline-flex; align-items: center; } .stamp .info-btn { width: 22px; height: 22px; }
.stamp .dot { opacity: .5; }
/* A button with a short note: side by side when there is room, the note under the button when there is not. */
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.action-row > .small { flex: 1 1 220px; min-width: 0; }
/* Card header with a button (e.g. System health · Check again): the button drops under the title when narrow */
.card-title { flex-wrap: wrap; }
.card-title > div:not(:last-child) { flex: 1 1 200px; min-width: 0; }
@media (max-width: 640px) {
  /* dashboard rows with action buttons (Print / Share): buttons in a row under the facts, not stacked top-right */
  main#app .drow:has(.dtags.actions) { flex-wrap: wrap !important; }
  main#app .drow:has(.dtags.actions) .dmain { padding-right: 0 !important; flex-basis: 100% !important; }
  main#app .drow:has(.dtags.actions) .dmain .m-facts { margin-right: 0 !important; }
  main#app .drow .dtags.actions { position: static; flex-direction: row; width: 100%; justify-content: flex-start; gap: 8px; }
  /* machines seen in scans: name left, Add right, on every row */
  .seen-row { flex-wrap: nowrap; } .seen-row > span:first-child { min-width: 0; }
}
@media (max-width: 640px) {
}
/* Form F register on phones: card header (number · name · age, Form F no. · date, state) */
@media (max-width: 640px) { .ffr-head.m-only { display: flex !important; } }
.ffr-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ffr-head b { font-size: 15px; }
@media (max-width: 640px) { main#app table.ff-reg tr.ff-warnrow { border-left: 3px solid var(--warn) !important; } main#app table.ff-reg tr.ff-warnrow td:first-child { box-shadow: none; } }
/* Form F "Send": date, note and button line up; full width on phones */
.ff-send { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.ff-send input { flex: 1 1 170px; min-width: 0; }
.ff-send input[type="date"] { flex: 0 1 170px; }
@media (max-width: 640px) { .ff-send input, .ff-send input[type="date"], .ff-send button { flex: 1 1 100%; } }
/* Date boxes: text starts at the left like every other box (iPhone centres it by default) */
input[type="date"], input[type="month"] { text-align: left; }
input[type="date"]::-webkit-date-and-time-value, input[type="month"]::-webkit-date-and-time-value { text-align: left; }
/* ⓘ info pop-ups (format.js infoTip, core/ui.js) */
.info-tip { display: inline-flex; vertical-align: middle; }
.info-btn { all: unset; box-sizing: border-box; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: var(--muted); cursor: pointer; flex: none; }
.info-btn svg { width: 15px; height: 15px; }
.info-btn:hover, .info-btn[aria-expanded="true"] { color: var(--accent); background: var(--accent-soft); }
.info-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.info-pop { position: fixed; z-index: 1000; max-width: min(300px, calc(100vw - 16px)); width: max-content; padding: 10px 12px; border-radius: 10px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
  font: 400 12.5px/1.5 var(--font); white-space: normal; text-align: left; text-transform: none; letter-spacing: 0; }
.info-pop .d-block { display: block; }
/* a warning that needs a short tag, with the reason behind ⓘ (e.g. a doctor without a registration no.) */
.warn-tag { display: inline-flex; align-items: center; gap: 4px; color: var(--warn); font-size: 12.5px; font-weight: 500; }
.warn-tag svg { width: 13px; height: 13px; }
@media (max-width: 640px) {
  /* a main action with its note: the button spans the card, the note sits under it */
  .action-row > button { flex: 1 1 100%; justify-content: center; }
  /* phone cards: long names wrap instead of ending in "…" */
  main#app table[data-m] tr:has(.m-facts) .who b { white-space: normal; overflow: visible; text-overflow: clip; }
}
@media (max-width: 640px) {
  /* status corner of phone cards: the ⓘ sits beside the badge ("Signed ⓘ"), not on a line of its own */
  main#app table[data-m] td[data-m="end"] > .row:has(> .info-tip) { flex-direction: row !important; align-items: center; gap: 2px !important; }
}
@media (max-width: 640px) {
  /* report page: the template picker fills its row; Dictate and the links go under it */
  .rep-tools select { flex: 1 1 100%; max-width: none; }
}
/* Computer lists (tables with data-grow, see core/ui.js): the named columns take the spare width; the others
   (dates, amounts, badges, buttons, short codes) fit their content on one line. Amounts stay right-aligned. */
@media (min-width: 641px) {
  main#app table[data-grow] th, main#app table[data-grow] td { white-space: nowrap; }
  main#app table[data-grow] [data-g] { white-space: normal; min-width: 110px; }
  main#app table[data-grow] th.num, main#app table[data-grow] td.num { text-align: right; }
  main#app table[data-grow] td:not([data-g]) .row { flex-wrap: nowrap; } /* status badges stay on one line */
}
/* Small laptops and tablets: slightly tighter cells so lists fit without sideways scrolling */
@media (min-width: 861px) and (max-width: 1279px) {
  main#app table[data-grow] th, main#app table[data-grow] td { padding-left: 9px; padding-right: 9px; }
}
/* Two-column layouts switch to one column when the space beside the menu is too narrow for their lists:
   the open menu takes ~240px, the folded one ~70px, so the switch depends on which one is showing. */
@media (min-width: 861px) and (max-width: 1259px) { html:not(.nav-mini) .cols2 { display: flex; flex-direction: column; align-items: stretch; } html:not(.nav-mini) .cols2 > .col { display: contents; } html:not(.nav-mini) .cols2 .col-item { width: 100%; min-width: 0; } }
@media (min-width: 861px) and (max-width: 1099px) { html.nav-mini .cols2 { display: flex; flex-direction: column; align-items: stretch; } html.nav-mini .cols2 > .col { display: contents; } html.nav-mini .cols2 .col-item { width: 100%; min-width: 0; } }
@media (min-width: 861px) and (max-width: 1379px) { html:not(.nav-mini) .set-split { grid-template-columns: 1fr; } html:not(.nav-mini) .set-side { position: static; } }
@media (min-width: 861px) and (max-width: 1199px) { html.nav-mini .set-split { grid-template-columns: 1fr; } html.nav-mini .set-side { position: static; } }
/* System health header: the refresh button stays in the top-right corner; on phones it is just the ↻ icon */
.card-title .sys-re { margin-left: auto; flex: none; }
@media (max-width: 640px) {
  .card-title:has(.sys-re) { flex-wrap: nowrap; }
  .card-title:has(.sys-re) > div { flex: 1 1 auto; }
  .card-title .sys-re { width: 36px; height: 36px; padding: 0; justify-content: center; border-radius: 50%; }
  .card-title .sys-re span { display: none; }
}
/* ✕ in search boxes (core/ui.js) */
.search input[data-x] { padding-right: 36px; }
.search-x { all: unset; box-sizing: border-box; position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px;
  display: grid; place-items: center; border-radius: 50%; color: var(--muted); cursor: pointer; }
.search-x[hidden] { display: none; }
.search-x:hover { color: var(--ink); background: var(--surface-2); }
.search-x svg { position: static; transform: none; width: 15px; height: 15px; pointer-events: none; }
/* Report page: "Scores for this scan" (calculators inside one side card) */
.calc.calc-compact { box-shadow: none; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 14px 16px; margin: 0; gap: 12px; }
.calc-compact .calc-head .ico { width: 30px; height: 30px; }
.calc-compact .calc-head h2 { font-size: 15px; display: flex; align-items: center; gap: 4px; }
.calc-compact .calc-out { padding: 12px 14px; }
.calc-compact .calc-val { font-size: 17px; }
.calc-compact .grid.g2, .calc-compact .grid.g3 { gap: 8px; }
.calc-acts { gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.calc-acts .calc-copy { margin-top: 0; }
/* Two columns of cards that fill downwards (format.js columns); one column, in reading order, when narrow */
.cols2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.cols2 > .col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.cols2 .col-item > .card, .cols2 .col-item > section, .cols2 .col-item > .stack { margin: 0; }
@media (max-width: 1000px) {
  .cols2 { display: flex; flex-direction: column; align-items: stretch; }
  .cols2 > .col { display: contents; }
  .cols2 .col-item { width: 100%; min-width: 0; } /* every card full width, however little it holds */
}
/* Menu foot: avatar + name + ⚙; the ⚙ opens theme / password / sign out (core/shell.js renderMe) */
#ai-status { position: relative; }
.me-btn { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border-radius: 10px; cursor: pointer; }
.me-btn > div { flex: 1; min-width: 0; }
.me-btn b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-btn:hover, .me-btn[aria-expanded="true"] { background: var(--rail-2); }
.me-btn:focus-visible { outline: 2px solid var(--accent); }
.me-gear { display: grid; place-items: center; color: var(--rail-muted); }
.me-gear svg { width: 18px; height: 18px; }
.me-btn:hover .me-gear, .me-btn[aria-expanded="true"] .me-gear { color: #fff; }
.me-menu { position: absolute; left: 8px; right: 8px; bottom: calc(100% - 4px); z-index: 50; display: grid; gap: 6px; padding: 10px;
  background: var(--rail-2); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.me-menu[hidden] { display: none; }
.me-menu .ai-chip { padding: 4px 6px; color: var(--rail-muted); }
.me-item { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #e6edf0; font-size: 13px; cursor: pointer; }
.me-item svg { width: 16px; height: 16px; color: var(--rail-muted); }
.me-item:hover { background: var(--rail); }
.me-item:focus-visible { outline: 2px solid var(--accent); }
.me-menu .theme-switch { background: var(--rail); }
.me-menu .theme-switch button.on { background: var(--rail-2); }
/* folded (icon-only) menu: just the avatar; the pop-up opens beside it */
.nav-mini .me-btn { justify-content: center; padding: 6px 0; }
.nav-mini .me-gear { display: none; }
.nav-mini .me-menu { position: fixed; right: auto; width: 230px; z-index: 90; }
.nav-mini .me-menu .theme-switch { flex-direction: row; width: auto; }
.nav-mini .me-menu .theme-switch span { display: inline; }
/* Menu: staff waiting for sign-in approval (the only thing the admin needs to act on there) */
.online-h.warn { text-transform: none; letter-spacing: 0; font-size: 12.5px; color: #f5b955; background: rgba(245,166,35,.12); padding: 8px 10px; border-radius: 9px; }
.online-h.warn svg { width: 15px; height: 15px; flex: none; }
.online-h.warn:hover { color: #ffd48a; }
/* Settings: groups as tabs */
.set-tabs { display: flex; gap: 4px; padding: 4px; margin: 0 0 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; scrollbar-width: none; }
.set-tabs::-webkit-scrollbar { display: none; }
.set-tabs button { flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 500; white-space: nowrap; }
.set-tabs button svg { width: 16px; height: 16px; }
.set-tabs button:hover { color: var(--ink); background: var(--surface-2); }
.set-tabs button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-strong, var(--accent)); font-weight: 600; }
.set-panel { display: grid; gap: 16px; }
.set-panel[hidden] { display: none; }
.set-panel > .card, .set-panel > div > .card, .set-panel > form { margin-top: 0 !important; }
.set-panel > .mt { margin-top: 0; }
.sf-save { display: flex; justify-content: flex-end; margin-top: 6px; }
.sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sec-head h2 { margin: 0 0 2px; }
/* Machines as cards */
.mc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; align-items: start; }
.mc { display: grid; gap: 6px; padding: 16px; margin: 0; }
.mc.off { opacity: .6; }
.mc-top { display: flex; align-items: center; gap: 8px; }
.mc-top .mc-edit { margin-left: auto; }
.mc b { font-size: 15px; }
.mc-sends { color: var(--ink-2); }
.mc .decisions { margin-top: 6px; padding-top: 10px; border-top: 1px dashed var(--line); }
.mc-seen { border-style: dashed; background: var(--info-soft); }
.mc-seen .mc-top .badge { margin-left: auto; }
.mc-seen > button { justify-self: start; margin-top: 4px; }
@media (max-width: 640px) { .set-tabs { margin-left: -4px; margin-right: -4px; } .set-tabs button { flex: 0 0 auto; padding: 8px 12px; } }
/* Settings: a list on the left, a related card on the right; one column when narrow */
.set-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 340px); gap: 16px; align-items: start; }
.set-side { position: sticky; top: 76px; display: grid; gap: 16px; }
.set-side > .card, .set-side > form { margin: 0; }
.side-help h3 { margin: 0 0 8px; }
.side-help p { margin: 0 0 10px; line-height: 1.6; }
.side-help p:last-child { margin-bottom: 0; }
@media (max-width: 1000px) {
  .set-split { grid-template-columns: 1fr; }
  .set-side { position: static; }
}
.set-split .stack > .card, .set-split > div > .card:first-child { margin-top: 0 !important; }
/* Settings: search in card heads (price list, users); audit filters */
.card-head .card-search { flex: 0 1 260px; min-width: 160px; margin-left: auto; }
.card-head .card-search input { height: 34px; }
.card-head:has(.card-search) { gap: 10px; flex-wrap: wrap; }
.audit-filters { flex-wrap: wrap; }
.audit-filters .search { flex: 1 1 220px; }
.audit-filters select, .audit-filters input[type="date"] { width: auto; flex: 0 1 auto; }
.audit-table td b { font-weight: 600; }
@media (max-width: 640px) { .card-head .card-search { flex: 1 1 100%; order: 3; } .audit-filters select, .audit-filters input[type="date"] { flex: 1 1 calc(50% - 4px); } }
/* Menu foot: a long name never pushes the ⚙ out (the column may not grow wider than the menu) */
.side .foot#ai-status { grid-template-columns: minmax(0, 1fr); }
.me-btn { min-width: 0; }
.me-btn .me-gear { flex: none; }
.me-btn b { display: block; max-width: 100%; }
.me-btn b { white-space: normal; overflow: visible; text-overflow: clip; display: block; line-height: 1.3; overflow-wrap: anywhere; } /* the full name, as printed on reports */
#users-role { flex: none; }
@media (max-width: 640px) { #users-role { flex: 1 1 100%; order: 3; } }
@media (max-width: 640px) {
  /* users: role filter as an even segmented control across the width */
  #users-role { display: flex; }
  #users-role button { flex: 1 1 0; justify-content: center; }
}

/* Follow-up card (report page) */
.fu-of { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; margin-bottom: 10px; background: var(--info-soft); color: var(--ink-2); border-radius: 8px; }
.fu-of svg { width: 15px; height: 15px; flex: none; margin-top: 2px; color: var(--info); }
.ci-fu-row { flex-wrap: wrap; } .ci-fu-row > span:first-of-type { flex: 1 1 200px; }
.fu-sug { display: flex; gap: 8px; align-items: center; padding: 8px 10px; margin-bottom: 10px; background: var(--accent-soft); border-radius: 8px; color: var(--ink-2); }
.fu-sug svg { width: 15px; height: 15px; color: var(--accent); flex: none; }
.fu-sug span { flex: 1; min-width: 0; }
.fu-presets { flex-wrap: wrap; margin-bottom: 8px; }
.fu-form { display: grid; gap: 8px; }
.fu-set { display: grid; gap: 4px; }
.fu-set .badge { margin-left: 4px; }
.fu-late { color: var(--bad); font-weight: 600; }
.fu-acts { gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.fu-n { font-weight: 600; }
@media (max-width: 860px) { main#app table[data-m] td[data-m="metaw"] .fu-acts { justify-content: flex-start; flex-wrap: wrap; padding-top: 4px; } }
.fu-head { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
#rc-fu .fu-head { border-radius: var(--radius) var(--radius) 0 0; }
#filters.fu-mode .search, #filters.fu-mode #wl-more, #filters.fu-mode .wl-more { display: none !important; } /* Follow-ups: the study filters do not apply */
#rc-tabs button svg, #st-chips #wl-fu svg { width: 14px; height: 14px; margin-right: 4px; vertical-align: -2px; }

/* Billing */
.bill-kpis { margin-bottom: 16px; }
.bill-kpis a.kpi:hover { border-color: var(--accent); }
.kpi .sub .up { color: var(--ok); font-weight: 600; } .kpi .sub .down { color: var(--bad); font-weight: 600; }
#bill-insights { margin-bottom: 16px; }
#bill-insights .up { color: var(--ok); font-weight: 600; } #bill-insights .down { color: var(--bad); font-weight: 600; }
.coll-none { align-self: center; padding: 12px 14px; }
.bill-days { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; align-items: end; height: 54px; margin-top: 16px; }
.bill-days i { display: block; min-height: 2px; border-radius: 3px 3px 0 0; background: color-mix(in srgb, var(--accent) 40%, var(--surface)); }
.bill-days i.today { background: var(--accent); }
.bill-sub { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 8px; }
.bill-refs { display: grid; gap: 6px; }
.bill-refs > div { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: baseline; font-size: 13px; }
.bill-refs > div > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bill-sum { display: flex; flex-wrap: wrap; gap: 6px 20px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); font-size: 13px; color: var(--ink-2); }
.bill-sum b { color: var(--ink); font-variant-numeric: tabular-nums; }
.bill-sum .bill-due b { color: var(--bad); }
.inv-due { color: var(--bad); } .inv-due b { font-weight: 700; }
.inv-for { max-width: 280px; }
.inv-acts { gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
tr.inv-x td { opacity: .75; }
.bill-more > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--accent-strong); margin-bottom: 10px; }
.bill-more > summary::-webkit-details-marker { display: none; }
.bill-more > summary svg { width: 15px; height: 15px; }
.bill-more[open] > summary { color: var(--muted); }
/* Billing: cash tally, 14 days, this month */
.bill-card { margin: 0; }
.bill-card h2 { display: flex; align-items: center; gap: 8px; margin: 0; }
.bill-card h2 svg { width: 17px; height: 17px; color: var(--accent); }
.bc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.bc-head input[type=date] { width: auto; flex: none; }
.tally-total { display: grid; gap: 2px; margin-bottom: 14px; }
.tally-total b { font: 700 30px/1.1 var(--font-display); font-variant-numeric: tabular-nums; color: var(--ink); }
.mbar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; gap: 2px; background: var(--surface-2); }
.mbar i { display: block; min-width: 6px; }
.mlegend { display: grid; gap: 8px; margin-top: 14px; }
.mlegend > div { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; font-size: 13.5px; }
.mlegend b { min-width: 90px; text-align: right; }
.mdot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.m-cash { background: #2fa36b; } .m-upi { background: #7b61d9; } .m-card { background: #d98e1f; } .m-bank { background: #2f7fd1; } .m-ins { background: #c4497a; } .m-chq { background: #6b8796; } .m-other { background: var(--muted); }
.tally-empty { display: flex; align-items: center; gap: 10px; padding: 16px; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--muted); font-size: 13.5px; }
.tally-empty svg { width: 20px; height: 20px; flex: none; }
.bill-card .coll-list { margin-top: 12px; }
.dchart { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 6px; height: 150px; align-items: end; }
.dcol { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 16px minmax(0, 1fr) 16px; height: 100%; justify-items: center; align-items: end; }
.dcol i { display: block; width: 100%; max-width: 26px; border-radius: 5px 5px 2px 2px; background: color-mix(in srgb, var(--accent) 35%, var(--surface-2)); align-self: end; transition: background .15s; }
.dcol:hover i { background: var(--accent-strong); }
.dcol.today i { background: var(--accent); }
.dcol .dv { font: 700 10.5px var(--font); color: var(--ink-2); white-space: nowrap; }
.dcol .dl { font-size: 10.5px; color: var(--muted); }
.dcol.today .dl { color: var(--accent-strong); font-weight: 700; }
.mods { display: grid; gap: 9px; }
.mod-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 38px 84px; gap: 10px; align-items: center; font-size: 13.5px; }
.mod-row b { text-align: right; }
.mod-p { text-align: right; }
.mod-bar, .ref-bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.mod-bar i, .ref-bar i { display: block; height: 100%; border-radius: 99px; }
.ref-bar i { background: color-mix(in srgb, var(--accent) 60%, var(--surface-2)); }
.mod-bar i.c0 { background: var(--accent); } .mod-bar i.c1 { background: #7b61d9; } .mod-bar i.c2 { background: #d98e1f; } .mod-bar i.c3 { background: #2f7fd1; } .mod-bar i.c4 { background: #2fa36b; } .mod-bar i.c5 { background: #c4497a; }
.refs { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; counter-reset: ref; }
.refs li { display: grid; grid-template-columns: 22px minmax(0, 1fr) 70px auto 84px; gap: 10px; align-items: center; font-size: 13.5px; counter-increment: ref; }
.refs li::before { content: counter(ref); width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font: 700 11px/22px var(--font); text-align: center; }
.refs .ref-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.refs b { text-align: right; }
/* Three cards side by side on wide screens; the month card takes the full width below two on medium ones */
.bill-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
@media (max-width: 1399px) { .bill-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .bill-grid > .bill-card:last-child { grid-column: 1 / -1; } }
@media (max-width: 860px) { .bill-grid { grid-template-columns: 1fr; } }
/* To bill: the first four, "Show all" for the rest */
.tb-n { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; margin-left: 6px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); font: 700 12px var(--font); vertical-align: 2px; }
.tb-card:not(.tb-open) table.tb-list tr.tb-more { display: none; }
.tb-card .tb-showall { width: 100%; justify-content: center; border-radius: 0 0 var(--radius) var(--radius); border-top: 1px solid var(--line); }
.tb-card .tb-showall svg { transform: rotate(90deg); }
/* Invoice rows: a coloured edge by status (green paid, amber part paid, red unpaid) */
@media (min-width: 641px) {
  .inv-table tr[data-accent="ok"] td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
  .inv-table tr[data-accent="warn"] td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
  .inv-table tr[data-accent="bad"] td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
}
@media (max-width: 640px) {
  .mod-row { grid-template-columns: 80px minmax(0, 1fr) 34px 70px; }
  .refs li { grid-template-columns: 22px minmax(0, 1fr) auto 70px; } .refs li .ref-bar { display: none; }
  .dchart { gap: 3px; height: 120px; } .dcol .dv { visibility: hidden; }
}

/* Report page: follow-up as one line under the report */
.fu-line { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.fu-row { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; min-height: 34px; }
.fu-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.fu-label svg { width: 15px; height: 15px; color: var(--accent); }
.fu-main { flex: 1 1 auto; min-width: 0; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fu-acts { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.fu-line .fu-sug { margin: 0; padding: 4px 6px 4px 10px; gap: 6px; }
.fu-line .fu-of { margin: 0 0 8px; }
.fu-edit { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1 1 100%; }
.fu-edit .fu-presets { margin: 0; flex-wrap: wrap; }
.fu-edit input[type=date] { width: auto; flex: 0 0 auto; }
.fu-edit #fu-reason { flex: 1 1 220px; width: auto; }
/* Report page: the right column as tabs */
.rail-tabs { position: sticky; top: var(--rail-top, 0); z-index: 2; display: flex; gap: 2px; flex-wrap: nowrap; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.rail-tabs[hidden] { display: none; }
.rail-tabs button { position: relative; flex: 1 1 0; min-width: 0; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 2px 5px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: 600 12.5px var(--font); box-shadow: none; min-height: 32px; }
.rail-tabs button svg { width: 17px; height: 17px; }
.rail-tabs button span { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.rail-tabs button b { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; font-size: 10px !important; line-height: 16px !important; background: var(--line); color: var(--ink-2); font: 700 10.5px/18px var(--font); }
.rail-tabs button:hover { color: var(--ink); }
.rail-tabs button.on { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow); }
.rail-tabs button.on b { background: var(--accent-soft); color: var(--accent-strong); }
.assist > .rail-off { display: none !important; }

/* Report page: who signed, quietly reassuring: a thin green edge and a small tick */
.signed-seal { display: grid; grid-template-columns: 17px minmax(0, 1fr) auto; align-items: center; gap: 4px 10px; margin-top: 14px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); border-left: 3px solid var(--ok); font-size: 13px; color: var(--ink-2); }
.signed-seal > svg { width: 17px; height: 17px; color: var(--ok); stroke-width: 2; flex: none; }
.signed-seal b { color: var(--ink); }
.signed-seal .seal-when { font-size: 12px; color: var(--muted); }
@media (max-width: 640px) { .signed-seal { grid-template-columns: 17px minmax(0, 1fr); align-items: start; } .signed-seal > svg { margin-top: 1px; } .signed-seal .seal-when { grid-column: 2; } }

/* Report page: "Study details" form: title wide, referrer and priority beside it, buttons at the right */
.meta-form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.5fr) minmax(120px, 1fr); gap: 12px 14px; margin-top: 12px; align-items: end; }
.meta-form .field { margin: 0; }
.meta-form .mf-hx { grid-column: 1 / -1; }
.meta-form .mf-acts { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; padding-top: 2px; }
.meta-form .mf-acts .danger { margin-right: auto; }
@media (max-width: 760px) { .meta-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .meta-form .mf-title { grid-column: 1 / -1; } }
/* Text boxes in pop-ups stand out clearly from the pop-up (dark mode especially) */
.modal input:not([type=checkbox]):not([type=radio]), .modal textarea, .modal select { background-color: var(--bg); border-color: var(--line-strong); }
.modal input:focus, .modal textarea:focus, .modal select:focus { background-color: var(--surface); }

/* Report page: the addendum box under a signed report */
/* Follow-up actions: "Check in" keeps its label; Call · WhatsApp · Close become icon buttons where space is tight */
#fu-today .fu-c .lbl, .dash-card .fu-c .lbl { display: none; }
@media (max-width: 860px) { .fu-c .lbl { display: none; } }
.fu-c:has(.lbl) { min-width: 34px; justify-content: center; }
/* Follow-up details: the scan to repeat, the last call, "is this the follow-up?" */
.fu-tgt { margin-left: 4px; gap: 4px; font-weight: 500; }
.fu-tgt svg { width: 12px; height: 12px; }
.fu-contact { margin-top: 4px; color: var(--ink-2); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.fu-contact svg { width: 13px; height: 13px; color: var(--accent); flex: none; }
.fu-ask { flex-wrap: wrap; align-items: center; background: var(--warn-soft, var(--info-soft)); }
.fu-ask > span { flex: 1 1 240px; }
.fu-ask > button { flex: none; margin-left: auto; }
.fu-edit #fu-scan { width: auto; min-width: 0; max-width: 240px; }
.dup-list { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
/* Reception: patients not finished on an earlier day */
#rc-left { border-left: 4px solid var(--warn); }
#rc-left .lo-img { color: var(--ok); font-weight: 600; }
/* Bills of visits that didn't happen */
.inv-nd { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--bad-soft); color: var(--ink); font-size: 13px; }
.inv-nd > svg { width: 15px; height: 15px; color: var(--bad); flex: none; }
.inv-nd > span:first-of-type { flex: 1 1 220px; }
.inv-nd-acts { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.nd-card { border-left: 4px solid var(--bad); }
.pay-neg { color: var(--bad); }
.kpi .kpi-late { color: var(--bad); font-weight: 700; }
.ci-fu-acts { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-left: auto; align-self: center; }
/* "Has a follow-up due" at check-in: four big choices */
.fu-q { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.fu-q button { display: flex; align-items: flex-start; gap: 10px; text-align: left; padding: 12px; height: auto; white-space: normal; justify-content: flex-start; }
.fu-q button svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--accent); }
.fu-q button span { display: grid; gap: 2px; }
.fu-q button small { color: var(--muted); font-weight: 400; }
@media (max-width: 520px) { .fu-q { grid-template-columns: 1fr; } }
/* Follow-up line on a phone: "Follow-up" and the icon actions on top, the date · state · reason below at full width;
   the wider "not set" actions and the edit form take their own full row */
@media (max-width: 640px) {
  .fu-line .fu-row { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "label acts" "main main"; align-items: center; gap: 6px 10px; }
  .fu-line .fu-label { grid-area: label; }
  .fu-line .fu-main { grid-area: main; }
  .fu-line .fu-acts { grid-area: acts; justify-self: end; margin-left: 0; flex-wrap: nowrap; gap: 2px; }
  .fu-line .fu-acts .lbl { display: none; }
  .fu-line .fu-acts > button.ghost { padding: 6px 8px; }
  .fu-line .fu-row:has(.fu-acts .fu-sug, #fu-add) { grid-template-areas: "label main" "acts acts"; }
  .fu-line .fu-row:has(.fu-acts .fu-sug, #fu-add) .fu-acts { justify-self: start; flex-wrap: wrap; gap: 6px; }
  .fu-line .fu-edit { grid-column: 1 / -1; }
  .fu-line .fu-edit #fu-scan { max-width: 100%; flex: 1 1 100%; }
}
/* Choice chips inside a pop-up wrap, so the pop-up never grows wider than a phone */
.modal .chips { flex-wrap: wrap; }
/* Phone cards: several status tags stack at the top right instead of squeezing the patient's name */
@media (max-width: 640px) { main#app table[data-m] td[data-m="end"] .st-tags { flex-direction: column; align-items: flex-end; gap: 4px; } }
/* Reports (front desk) */
.rp-acts { gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.rp-handed { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 12.5px; color: var(--ok); }
.rp-handed svg { width: 13px; height: 13px; }
.rp-wait { display: flex; gap: 12px; align-items: flex-start; margin: 12px 16px; padding: 14px; border-radius: 12px; background: var(--warn-soft); }
.rp-wait > svg { width: 20px; height: 20px; color: var(--warn); flex: none; margin-top: 2px; }
#rp-one .view-banner { margin: 12px 16px 0; }
@media (max-width: 860px) { .rp-acts { justify-content: flex-start; flex-wrap: wrap; } .rp-acts .lbl { display: inline; } }
#rp-views { flex-wrap: wrap; }
/* Reports on a phone: Print · WhatsApp · Handed over as a row at the bottom of the card, not pinned over the name */
@media (max-width: 640px) {
  main#app #rp-list table[data-m] tr:has(.m-facts) td[data-m="end"] { position: static; order: 9 !important; flex: 1 1 100% !important; margin-top: 10px !important; }
  main#app #rp-list table[data-m] tr:has(.m-facts) td[data-m="main"] .who { padding-right: 0; }
  main#app #rp-list .rp-acts { justify-content: flex-start; flex-wrap: wrap; }
  main#app #rp-list .rp-acts button:not(.ghost) { flex: 1 1 0; justify-content: center; }
}
/* Patient page, front desk: what to hand over and collect, then every report and bill */
.pd-sum { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.pd-sum-t { display: flex; align-items: center; gap: 10px; }
.pd-sum-t > svg { width: 20px; height: 20px; color: var(--accent); flex: none; }
.pd-sum-a { gap: 8px; flex-wrap: wrap; }
.pd-due { color: var(--bad); }
@media (max-width: 640px) {
  .pd-sum-a { width: 100%; } .pd-sum-a > * { flex: 1 1 auto; justify-content: center; }
  main#app .card table[data-m] tr:has(.rp-acts):has(.m-facts) td[data-m="end"] { position: static; order: 9 !important; flex: 1 1 100% !important; margin-top: 10px !important; }
  main#app .card table[data-m] tr:has(.rp-acts) td[data-m="main"] .who { padding-right: 0; }
  main#app .rp-acts { justify-content: flex-start; flex-wrap: wrap; flex-direction: row !important; align-items: center !important; }
}
.rp-many { display: grid; gap: 2px; }
.pd-show { width: 100%; justify-content: center; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); padding: 12px; }
/* Option cards (settings): a short title and a line of explanation, one tap to choose */
.opt-cards { display: grid; gap: 8px; }
.opt-card { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--surface-2); }
.opt-card:hover { border-color: var(--line-strong); }
.opt-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.opt-card { position: relative; padding-right: 36px; }
.opt-card input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; padding: 0; pointer-events: none; }
.opt-card:has(input:checked)::after { content: ""; position: absolute; right: 12px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E") center / 11px no-repeat; }
.opt-card span { display: grid; gap: 1px; min-width: 0; }
.opt-card b { font-weight: 600; font-size: 14px; }
.opt-card small { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.opt-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Price list: add row at the top; matches show below while typing */
.pl-add { flex-wrap: wrap; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.pl-hint { flex: 1 1 100%; display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.pl-hint svg { width: 15px; height: 15px; flex: none; color: var(--accent); }
.pl-hint.bad { color: var(--bad); } .pl-hint.bad svg { color: var(--bad); }
.pl-table tr.pl-dup td { background: var(--bad-soft); }
form#np .pl-hint { grid-column: 1 / -1; grid-row: auto; width: 100% !important; }
form#np input[name="modality"] { min-width: 64px; }
@media (min-width: 861px) { form#np.toolbar { grid-template-columns: 80px minmax(0, 1fr) 72px 96px auto; } }
/* Phone cards force rows visible; a row hidden by the price-list filter must stay hidden */
main#app #price-card table tr[hidden], main#app #price-card table[data-m] tr[hidden] { display: none !important; }
form#np input[name="modality"] { padding-left: 8px; padding-right: 6px; min-width: 70px; }
/* Centre computers, per branch */
.dev-branch { border-top: 1px solid var(--line); padding: 10px 16px 6px; }
.dev-bh { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.dev-bh svg { width: 15px; height: 15px; color: var(--accent); flex: none; }
.dev-bh .small { margin-left: auto; }
.dev-note { margin: 2px 0 6px 23px; font-size: 12.5px; }
.dev-warn { color: var(--warn); }
.dev-branch .dev-row { padding-left: 23px; padding-right: 0; }
.dev-c small + small { display: block; margin-top: 1px; }
.dev-live { color: var(--ok); font-weight: 600; }
.dev-this { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; background: var(--ok-soft); color: var(--ink); font-size: 13.5px; }
.dev-this svg { width: 16px; height: 16px; color: var(--ok); flex: none; }
.dev-saved { display: grid; gap: 1px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 4px 0 12px; }
.dev-saved > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; background: var(--surface-2); }
.dev-saved span { color: var(--muted); font-size: 13px; } .dev-saved b { text-align: right; font-weight: 600; }
/* "Who made or changed this" pop-up: label column + who / when, aligned */
.info-pop .sp-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; align-items: baseline; }
.info-pop .sp-row { display: contents; }
.info-pop .sp-l { color: var(--muted); font-size: 12px; white-space: nowrap; }
.info-pop .sp-v { display: grid; gap: 1px; min-width: 0; }
.info-pop .sp-by { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.info-pop .sp-at { color: var(--ink-2); }
.wa-why { text-align: left; margin-top: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.wa-why summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
.wa-why ul { margin: 6px 0; padding-left: 18px; display: grid; gap: 4px; }
.wa-relay { display: flex; gap: 8px; text-align: left; margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--ink); }
.wa-relay svg { width: 16px; height: 16px; color: var(--warn); flex: none; margin-top: 2px; }
/* Messages with buttons (approve a sign-in, open…): tick beside the first line, buttons in a row under the text */
.toast.has-act { display: grid; grid-template-columns: 16px minmax(0, 1fr); column-gap: 10px; row-gap: 10px; align-items: start; }
.toast.has-act > svg { margin-top: 3px; }
.toast.has-act > span { line-height: 1.45; }
.toast.has-act .toast-act { grid-column: 2; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-start; margin: 0; }
.login-notice { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--ink); }
.login-notice svg { width: 16px; height: 16px; color: var(--warn); flex: none; margin-top: 2px; }

/* Phones: the side panel's tabs scroll with the page (a sticky row under the sticky header would leave little room) */
@media (max-width: 860px) { .rail-tabs { position: static; } }
/* A scanner upload with no news for 30 minutes */
.itag.warn { background: var(--warn-soft); color: var(--warn); }
.scan-live.stalled { background: var(--warn-soft); color: var(--ink); }
.scan-live.stalled > svg { width: 18px; height: 18px; color: var(--warn); flex: none; }
/* Phone cards: whatever opens the card (a patient's name, a scan's title) keeps clear of the tag pinned top-right */
@media (max-width: 640px) {
  main#app table[data-m] tr:has(.m-facts):has(td[data-m="end"] .badge, td[data-m="end"] .st-cell) td[data-m="main"] > :first-child:not(.m-facts) { padding-right: 112px; }
  main#app table[data-m] tr:has(.m-facts):has(td[data-m="end"] .badge, td[data-m="end"] .st-cell) td[data-m="main"] > :first-child.who { padding-right: 112px; }
}
/* Phones: small stand-alone links get a finger-sized tap area (at least 32 px tall); links inside sentences stay inline */
@media (max-width: 640px) {
  .sh-back, .rep-manage, #ff-mark, #paid-full, .chip-link, #go-branches, .field > div > a[href^="#/patient/"] { display: inline-flex; align-items: center; min-height: 32px; padding-top: 4px; padding-bottom: 4px; }
  .sh-back { padding-right: 10px; }
}
/* A cancelled bill and the bill that replaced it point at each other */
.inv-repl { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; background: var(--warn-soft, #fdf3e1); border-color: transparent; }
.inv-repl > div:first-child svg { width: 18px; height: 18px; color: var(--warn); margin-top: 2px; }
.inv-repl.ok { background: var(--accent-soft); }
.inv-repl.ok > div:first-child svg { color: var(--accent); }
.inv-repl .small { margin-top: 3px; color: var(--ink-2); }
.pay-moved a { color: var(--accent); }
/* Sideways scrolling shows itself (core/hscroll.js): the edge with more to see fades; strips of buttons get an arrow */
.hs-l, .hs-r { --hs-l: 0px; --hs-r: 0px; -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--hs-l), #000 calc(100% - var(--hs-r)), transparent 100%); mask-image: linear-gradient(to right, transparent 0, #000 var(--hs-l), #000 calc(100% - var(--hs-r)), transparent 100%); }
.hs-l { --hs-l: 36px; } .hs-r { --hs-r: 36px; }
.hs-box { position: relative; min-width: 0; max-width: 100%; }
.hs-box.hs-l, .hs-box.hs-r, .hs-box > .hs-l, .hs-box > .hs-r { -webkit-mask-image: none; mask-image: none; } /* strips: the arrow says it */
.hs-btn { position: absolute; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; min-height: 0; padding: 0; border-radius: 99px; display: none; align-items: center; justify-content: center;
  background: var(--surface); color: var(--accent); border: 1px solid var(--line); box-shadow: var(--shadow, 0 2px 6px rgba(0,0,0,.15)); z-index: 2; }
.hs-btn svg { width: 16px; height: 16px; }
.hs-btn-l { left: 2px; } .hs-btn-l svg { transform: scaleX(-1); }
.hs-btn-r { right: 2px; }
.hs-box.hs-l > .hs-btn-l, .hs-box.hs-r > .hs-btn-r { display: inline-flex; }
.hs-box > .set-tabs { margin-bottom: 0; } .hs-box:has(> .set-tabs) { margin-bottom: 18px; }
/* Connection banner (core/offline.js): a pill at the bottom, above the phone menu bar */
#net-bar { display: none; }
#net-bar.off, #net-bar.sync, #net-bar.warn, #net-bar.ok { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 60; display: flex; align-items: center; gap: 8px;
  max-width: min(680px, calc(100vw - 24px)); padding: 9px 14px; border-radius: 12px; font-size: 13px; line-height: 1.35; box-shadow: var(--shadow-lg, 0 6px 24px rgba(0,0,0,.2)); border: 1px solid transparent; }
#net-bar svg { width: 16px; height: 16px; flex: none; }
#net-bar.off { background: var(--warn-soft); color: var(--ink); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
#net-bar.off svg { color: var(--warn); }
#net-bar.sync { background: var(--surface); color: var(--ink); border-color: var(--line); }
#net-bar.warn { background: var(--bad-soft); color: var(--ink); } #net-bar.warn svg { color: var(--bad); } #net-bar.warn a { color: var(--accent); font-weight: 600; }
#net-bar.ok { background: var(--ok-soft); color: var(--ink); } #net-bar.ok svg { color: var(--ok); }
@media (max-width: 860px) { #net-bar.off, #net-bar.sync, #net-bar.warn, #net-bar.ok { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); } }
.off-list { margin: 4px 0 14px; padding-left: 18px; line-height: 1.6; }
.draft-note { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.draft-note > span:nth-child(2) { flex: 1 1 260px; }
/* Installed app: a double-click on a label or button doesn't select the word (no highlight, no dictionary pop-ups
   from browser extensions). Text people work with stays selectable: boxes, report text, IDs, AI and summary text. */
@media (display-mode: standalone), (display-mode: window-controls-overlay), (display-mode: minimal-ui) {
  body { -webkit-user-select: none; user-select: none; }
  input, textarea, select, [contenteditable], pre, code, .mono, .ai-txt, .day-sum, .wa-preview, .rep-view, .error-card, .toast span { -webkit-user-select: text; user-select: text; }
}

.sw-stuck { display: flex; align-items: center; gap: 5px; margin-top: 3px; color: var(--warn); }
.sw-stuck svg { width: 13px; height: 13px; flex: none; }

/* Scanner → Recent scans: a matched scan opens its report */
.drow-open { cursor: pointer; }
.drow-open:hover { background: var(--surface-2); }
.drow-go svg { width: 16px; height: 16px; color: var(--muted); margin-left: 4px; vertical-align: middle; }
/* Scanner → This computer: its settings and folder buttons in one box above the scans */
.sw-settings { margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); display: grid; gap: 12px; }
.sw-set-h { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.sw-set-h svg { width: 16px; height: 16px; color: var(--accent); }
.sw-set-acts { gap: 8px; flex-wrap: wrap; }
.sw-set-acts .danger { margin-left: auto; }
@media (max-width: 640px) { .sw-set-acts .danger { margin-left: 0; } }
@media (max-width: 640px) { #sw-card .pt-strip { display: grid; grid-template-columns: 1fr 1fr; } }

/* Billing → Cash tally: the day's payments as a compact list that fits the card at any width (a 5-column table spilled out) */
.coll-rows { margin-top: 8px; display: grid; max-height: 60vh; overflow-y: auto; border-top: 1px solid var(--line); }
.coll-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.coll-row:hover { background: var(--surface-2); }
.coll-who { display: grid; min-width: 0; }
.coll-who > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coll-show { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; font-weight: 600; }
.coll-show svg { width: 15px; height: 15px; }
/* Last 14 days: the amount over the first / last bar stays inside the card */
.dcol:last-child .dv { justify-self: end; } .dcol:first-child .dv { justify-self: start; }
/* Filter chips never wider than their box: they scroll sideways instead (with the arrows of core/hscroll.js) */
.chips { max-width: 100%; overflow-x: auto; scrollbar-width: none; } .chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; white-space: nowrap; }
.coll-show { min-height: 32px; padding: 4px 0; }

/* ============ AI assistant (report page) ============ */
.ai-card .ai-head { display: flex; align-items: center; gap: 10px; }
.ai-card .ai-head > div { flex: 1; min-width: 0; }
.ai-card .ai-head .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-kbd { font: 600 10.5px var(--font); color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; white-space: nowrap; }
/* ask box */
.ai-ask { display: flex; align-items: flex-end; gap: 6px; margin-top: 12px; padding: 6px 6px 6px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); transition: border-color .15s, box-shadow .15s; }
.ai-ask:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.ai-ask textarea { flex: 1; border: 0; background: transparent; resize: none; padding: 7px 0; min-height: 22px; max-height: 140px; font-size: 13.5px; line-height: 1.45; box-shadow: none; outline: none; }
.ai-send { flex: none; width: 34px; height: 34px; min-height: 0; padding: 0; border-radius: 10px; border: 0; background: var(--accent); color: var(--on-accent, #fff); display: inline-flex; align-items: center; justify-content: center; }
.ai-send svg { width: 17px; height: 17px; }
.ai-send:hover { filter: brightness(1.08); }
.ai-q-exs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ai-q-ex { min-height: 0; padding: 4px 10px; font-size: 12px; border-radius: 99px; border: 1px dashed var(--line-strong, var(--line)); background: transparent; color: var(--ink-2); }
.ai-q-ex:hover { border-color: var(--accent); color: var(--accent-strong); }
/* suggested + more */
.ai-sugg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ai-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 6px 12px; border-radius: 99px; border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--accent-soft); color: var(--accent-strong); font-size: 13px; font-weight: 600; }
.ai-chip svg { width: 15px; height: 15px; }
.ai-chip:hover { border-color: var(--accent); }
.ai-more { margin-top: 10px; }
.ai-more > summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 6px 0; }
.ai-more > summary:hover { color: var(--accent-strong); }
.ai-more .ai-group:first-of-type { margin-top: 4px; }
/* result cards */
.ai-feed { display: grid; gap: 10px; margin-top: 12px; }
.ai-feed:empty { display: none; }
.ai-c { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 10px 12px 12px; animation: ai-in .18s ease-out; }
.ai-feed .ai-c:first-child { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
@keyframes ai-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.ai-c header { display: flex; align-items: center; gap: 8px; }
.ai-c header b { font-size: 13.5px; flex: 1; min-width: 0; }
.ai-c-ic { width: 24px; height: 24px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ai-c-ic svg { width: 14px; height: 14px; }
.ai-c-src { font-size: 11px; color: var(--muted); white-space: nowrap; }
.ai-ib { min-height: 0; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ai-ib:hover { background: var(--surface-2); color: var(--ink); }
.ai-ib svg { width: 15px; height: 15px; }
.ai-c-b { margin-top: 8px; font-size: 13.5px; line-height: 1.5; }
.ai-c-b p { margin: 0 0 6px; }
.ai-c-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ai-wait { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.ai-ok { display: flex; align-items: center; gap: 6px; color: var(--ok); margin: 0; }
.ai-ok svg { width: 15px; height: 15px; }
.ai-sec { margin-top: 8px; }
.ai-sec .ai-gl { margin-bottom: 4px; }
/* lines you can add one by one */
.ai-lines { margin: 0; padding: 0; list-style: none; counter-reset: ai; display: grid; gap: 2px; }
.ai-lines li { counter-increment: ai; display: flex; align-items: flex-start; gap: 6px; padding: 5px 4px 5px 6px; border-radius: 8px; }
.ai-lines li::before { content: counter(ai) "."; color: var(--muted); font-size: 12px; min-width: 16px; padding-top: 2px; }
.ai-lines li > span:first-of-type { flex: 1; min-width: 0; }
.ai-lines li:hover { background: var(--surface-2); }
.ai-line-acts { display: inline-flex; gap: 2px; opacity: .55; }
.ai-lines li:hover .ai-line-acts, .ai-line-acts:focus-within { opacity: 1; }
@media (hover: none) { .ai-line-acts { opacity: 1; } }
/* what a suggestion changes */
.ai-diff { white-space: pre-wrap; font-size: 13px; line-height: 1.55; padding: 8px 10px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); max-height: 320px; overflow: auto; }
.ai-diff ins { text-decoration: none; background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ink); border-radius: 3px; padding: 0 1px; }
.ai-diff del { color: var(--bad); opacity: .75; }
.ai-why { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); }
.ai-codes { display: grid; gap: 4px; }
.ai-code { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 6px 4px; border-radius: 8px; }
.ai-code:hover { background: var(--surface-2); }
.ai-privacy { display: flex; gap: 6px; align-items: flex-start; margin: 12px 0 0; }
.ai-privacy svg { width: 14px; height: 14px; flex: none; margin-top: 2px; }
/* ✨ on a report section, its menu, and its answer under the box */
.fld-head { display: flex; align-items: center; gap: 8px; position: relative; margin-bottom: 6px; }
.fld-head > label { margin: 0; }
.ai-fld { min-height: 0; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); background: transparent; color: var(--accent-strong); font-size: 11.5px; font-weight: 600; text-transform: none; letter-spacing: 0; }
.ai-fld svg { width: 12px; height: 12px; }
.ai-fld:hover { background: var(--accent-soft); }
.ai-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; min-width: 220px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-lg, 0 8px 28px rgba(0,0,0,.25)); display: grid; }
.ai-menu button { display: flex; align-items: center; gap: 8px; justify-content: flex-start; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; font-size: 13px; color: var(--ink); min-height: 0; text-transform: none; letter-spacing: 0; font-weight: 500; }
.ai-menu button svg { width: 15px; height: 15px; color: var(--accent); }
.ai-menu button:hover, .ai-menu button:focus { background: var(--accent-soft); outline: none; }
.ai-inline { margin-top: 8px; border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
@media (max-width: 640px) { .rep-tools select { max-width: 100%; min-width: 0; } }
@media (hover: none) { .ai-kbd { display: none; } }
.ai-locked { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); }
.ai-locked svg { width: 15px; height: 15px; flex: none; margin-top: 1px; color: var(--muted); }
/* AI answers: their own scrolling area under a small header (count · Clear) */
.ai-feed-h { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ai-feed-h[hidden] { display: none; }
.ai-feed-h button { min-height: 0; padding: 2px 8px; font-size: 12px; text-transform: none; letter-spacing: 0; }
.ai-feed { max-height: min(62vh, 680px); overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; margin-top: 6px; }
.ai-q-line { color: var(--ink-2); font-style: italic; }
.ai-more .ai-group[hidden], .ai-more [data-ai][hidden] { display: none; }
