/* MaxMED Pro — design system, aligned with MedScribe: deep-teal top bar, white module tabs,
   gradient page headers, tinted KPI cards, teal-headed tables. Self-contained (Inter and Chart.js
   are served locally, no CDNs). */

@font-face { font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("../fonts/inter-latin-wght-normal.8e433c0592f7.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("../fonts/inter-latin-ext-wght-normal.ad4eb06671be.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("../fonts/inter-cyrillic-wght-normal.06ab411342ac.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }

:root {
  color-scheme: light;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --teal-50: #f0fdfa; --teal-100: #ccfbf1; --teal-200: #99f6e4; --teal-300: #5eead4; --teal-400: #2dd4bf;
  --teal-500: #14b8a6; --teal-600: #0d9488; --teal-700: #0f766e; --teal-800: #115e59; --teal-900: #134e4a;
  --bar: #0c3a36;            /* top bar */
  --ink: #0f2e2b;            /* headings */

  --bg: #f7faf9;
  --surface: #ffffff;
  --surface-2: #f8fbfa;
  --surface-3: #f1f5f4;
  --border: #e8edec;
  --border-strong: #cdd9d7;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #5b6b78;
  --faint: #94a3b8;

  --accent: var(--teal-600);
  --accent-hover: var(--teal-700);
  --accent-soft: var(--teal-50);
  --accent-text: var(--teal-700);
  --ring: 0 0 0 3px rgba(20, 184, 166, .25);

  --red: #e11d48;   --red-soft: #fff1f2;   --red-text: #be123c;   --red-line: #fecdd3;
  --amber: #d97706; --amber-soft: #fffbeb; --amber-text: #b45309; --amber-line: #fde68a;
  --blue: #2563eb;  --blue-soft: #eff6ff;  --blue-text: #1d4ed8;  --blue-line: #bfdbfe;
  --green: #059669; --green-soft: #ecfdf5; --green-text: #047857; --green-line: #a7f3d0;
  --violet: #7c3aed; --violet-soft: #f5f3ff; --violet-text: #6d28d9; --violet-line: #ddd6fe;
  --cyan-soft: #cffafe; --cyan-text: #0e7490;

  --radius-sm: .5rem;
  --radius: .7rem;
  --radius-lg: 1rem;
  --shadow-xs: 0 1px 2px rgba(15, 46, 43, .05);
  --shadow-sm: 0 1px 2px rgba(15, 46, 43, .06), 0 1px 3px rgba(15, 46, 43, .05);
  --shadow: 0 4px 14px -4px rgba(15, 46, 43, .12), 0 2px 6px -2px rgba(15, 46, 43, .07);
  --shadow-lg: 0 20px 44px -12px rgba(15, 46, 43, .45);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--text-2);
  background-color: var(--bg);
  background-image: radial-gradient(60rem 26rem at 50% -16rem, rgba(13, 148, 136, .07), transparent 70%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; font-feature-settings: "cv11", "ss01";
}
img { max-width: 100%; display: block; }
h1, h2, h3, p, ul, ol, dl, figure { margin: 0; }
[hidden] { display: none !important; }
.icon { flex-shrink: 0; }
a { color: var(--teal-700); text-decoration: none; font-weight: 500; }
a:hover { color: var(--teal-800); text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }
::selection { background: var(--teal-200); color: var(--teal-900); }
* { scrollbar-width: thin; scrollbar-color: var(--teal-300) transparent; }

/* ---------- Type ---------- */
.eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--teal-600); }
.caption { color: var(--muted); font-size: .9rem; font-weight: 600; margin-bottom: .2rem; }
.h1, h1.h1 { font-size: clamp(1.55rem, 2.6vw, 1.95rem); line-height: 1.2; font-weight: 800; letter-spacing: -.02em; color: var(--ink); }
.h2 { font-size: 1.05rem; line-height: 1.4; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.h3 { font-size: .98rem; line-height: 1.4; font-weight: 700; color: var(--ink); }
.lead { font-size: 1rem; color: var(--muted); max-width: 66ch; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.prose { color: var(--text-2); font-size: 1rem; }
.prose p + p { margin-top: 8px; }
.text-danger { color: var(--red-text) !important; }

/* ---------- App bar (top) + module tabs ---------- */
.appbar { position: sticky; top: 0; z-index: 40; }
.appbar-top { background: var(--bar); border-bottom: 1px solid rgba(255, 255, 255, .07); }
.appbar-inner { max-width: 1440px; margin: 0 auto; display: flex; align-items: center; gap: .85rem; padding: 0 clamp(1rem, 2.4vw, 2rem); }
.appbar-top .appbar-inner { height: 3.9rem; }
.appbar-brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 700; font-size: 1.02rem; flex: none; }
.appbar-brand:hover { color: #fff; text-decoration: none; }
.appbar-brand span span { color: rgba(236, 253, 245, .65); font-weight: 600; }
.brand-badge { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: .7rem; background: rgba(255, 255, 255, .12); color: #fff; flex: none; }
.clinic-chip {
  display: inline-flex; align-items: center; gap: .45rem; height: 2.5rem; padding: 0 .9rem; min-width: 0;
  border-radius: 99rem; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .15);
  color: rgba(236, 253, 245, .95); font-size: .92rem; font-weight: 600; white-space: nowrap;
}
.clinic-chip .icon { color: var(--teal-300); }
.clinic-chip .chip-text { overflow: hidden; text-overflow: ellipsis; }
.clinic-chip .chip-short { display: none; }
.appbar-right { margin-left: auto; display: flex; align-items: center; gap: .35rem; flex: none; }
.appbar-ib {
  display: inline-flex; align-items: center; gap: .35rem; height: 2.5rem; padding: 0 .75rem; border-radius: .8rem;
  color: rgba(236, 253, 245, .92); background: transparent; border: 0; font: inherit; font-size: .88rem; font-weight: 700; cursor: pointer;
}
.appbar-ib:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.me-menu { position: relative; }
.me-menu > summary { list-style: none; }
.me-menu > summary::-webkit-details-marker { display: none; }
.appbar-me { display: flex; align-items: center; gap: .55rem; padding: .25rem .5rem .25rem .25rem; border-radius: 99rem; color: #fff; cursor: pointer; }
.appbar-me:hover { background: rgba(255, 255, 255, .08); }
.appbar-me .av {
  width: 2.3rem; height: 2.3rem; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: rgba(255, 255, 255, .16); font-weight: 700; font-size: .85rem; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}
.appbar-me .nm { line-height: 1.2; max-width: 13rem; }
.appbar-me .nm b { display: block; font-size: .9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar-me .nm span { display: block; font-size: .8rem; color: rgba(236, 253, 245, .72); }
.appbar-me .icon { opacity: .75; transition: transform .15s; }
.me-menu[open] .appbar-me .icon { transform: rotate(180deg); }
.pop {
  position: absolute; right: 0; top: calc(100% + .55rem); z-index: 60; width: 17.5rem; background: #fff; color: var(--text);
  border-radius: 1rem; border: 1px solid #e2e8f0; padding: .5rem; box-shadow: var(--shadow-lg);
}
.pop-head { padding: .45rem .7rem .7rem; border-bottom: 1px solid #f1f5f9; margin-bottom: .3rem; }
.pop-head b { display: block; color: var(--text); }
.pop-head span { font-size: .85rem; color: var(--muted); }
.menu-item {
  display: flex; align-items: center; gap: .6rem; width: 100%; padding: .6rem .7rem; border-radius: .6rem; border: 0; background: none;
  font: inherit; font-size: .93rem; font-weight: 500; color: var(--text-2); text-align: left; cursor: pointer; text-decoration: none !important;
}
.menu-item .icon { color: #64748b; }
.menu-item:hover { background: var(--teal-50); color: var(--teal-900); }
.menu-item.is-danger { color: var(--red-text); }
.menu-item.is-danger .icon { color: var(--red-text); }
.menu-item.is-danger:hover { background: var(--red-soft); }
.pop-sep { border-top: 1px solid #f1f5f9; margin: .3rem 0; }

.subnav { background: #fff; border-bottom: 1px solid #e6eceb; box-shadow: 0 1px 0 rgba(15, 46, 43, .02); }
.subnav .appbar-inner { height: 3.3rem; gap: .15rem; overflow-x: auto; scrollbar-width: none; }
.subnav .appbar-inner::-webkit-scrollbar { display: none; }
.sub-link {
  display: flex; align-items: center; gap: .5rem; height: 100%; padding: 0 .9rem; flex: none;
  font-weight: 600; font-size: .95rem; color: #475569; white-space: nowrap; text-decoration: none !important;
  border-bottom: 3px solid transparent; border-top: 3px solid transparent;
}
.sub-link .icon { color: var(--faint); }
.sub-link:hover { color: var(--text); }
.sub-link[aria-current="page"] { color: var(--text); border-bottom-color: var(--teal-600); }
.sub-link[aria-current="page"] .icon { color: var(--teal-600); }
.sub-count { min-width: 1.4rem; padding: 0 .45rem; border-radius: 99rem; font-size: .75rem; font-weight: 700; line-height: 1.35rem; text-align: center; background: var(--teal-100); color: var(--teal-700); }
.sub-count.alert { background: #ffe4e6; color: var(--red-text); }

.content { width: 100%; max-width: 1440px; margin: 0 auto; padding: 1.75rem clamp(1rem, 2.4vw, 2rem) 3rem; }
.wrap-narrow { max-width: 900px; }
.app-footer { max-width: 1440px; margin: 0 auto; padding: 0 clamp(1rem, 2.4vw, 2rem) 2rem; text-align: center; font-size: .85rem; color: var(--muted); }
.app-footer .icon { color: var(--teal-500); vertical-align: -3px; }

@media (max-width: 1100px) { .appbar-me .nm { display: none; } }
@media (max-width: 760px) {
  .appbar-brand > span:last-child { display: none; }
  .clinic-chip .chip-text { display: none; }
  .clinic-chip .chip-short { display: inline; }
  .appbar-top .appbar-inner { gap: .5rem; }
  .content { padding-top: 1.1rem; }
}

/* ---------- Auth (split: brand hero + form) ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 46%) 1fr; background: #fff; }
.auth-aside {
  position: relative; overflow: hidden; color: #ecfeff; padding: 2.2rem 3rem; display: flex; flex-direction: column; gap: 2rem;
  background: linear-gradient(150deg, #0b3b37 0%, #0f766e 55%, #0d9488 100%);
}
.auth-aside::before, .auth-aside::after { content: ""; position: absolute; border-radius: 50%; filter: blur(64px); pointer-events: none; }
.auth-aside::before { width: 22rem; height: 22rem; right: -6rem; top: -6rem; background: rgba(45, 212, 191, .35); }
.auth-aside::after { width: 18rem; height: 18rem; left: -5rem; bottom: -6rem; background: rgba(37, 99, 235, .28); }
.auth-aside > * { position: relative; z-index: 1; }
.auth-brand { display: flex; align-items: center; gap: .65rem; color: #fff; font-weight: 700; font-size: 1.05rem; }
.auth-brand:hover { color: #fff; text-decoration: none; }
.auth-brand .brand-badge { background: rgba(255, 255, 255, .14); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); }
.auth-pitch { margin-top: auto; margin-bottom: auto; }
.auth-pitch .eyebrow { color: var(--teal-200); }
.auth-pitch h2 { margin-top: .5rem; color: #fff; font-size: clamp(1.7rem, 2.6vw, 2.3rem); line-height: 1.18; font-weight: 800; letter-spacing: -.02em; max-width: 17ch; }
.auth-pitch > p { margin-top: .9rem; color: rgba(236, 254, 255, .82); max-width: 44ch; }
.auth-pitch ul { list-style: none; padding: 0; margin-top: 1.8rem; display: flex; flex-direction: column; gap: 1rem; }
.auth-pitch li { display: flex; gap: .85rem; align-items: flex-start; }
.auth-pitch li b { display: block; color: #fff; font-weight: 600; }
.auth-pitch li div span { display: block; font-size: .9rem; color: rgba(236, 254, 255, .75); }
.auth-pitch .feat-ic { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: .75rem; flex: none; background: rgba(255, 255, 255, .12); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); }
.auth-foot { font-size: .82rem; color: rgba(236, 254, 255, .65); display: flex; gap: 1rem; flex-wrap: wrap; }
.auth-foot a { color: rgba(236, 254, 255, .9); font-weight: 500; }
.auth-main { display: flex; flex-direction: column; padding: 1.4rem 2rem; background: #fff; }
.auth-tools { display: flex; justify-content: flex-end; align-items: center; gap: .6rem; }
.auth-box { width: 100%; max-width: 30rem; margin: auto; padding: 2rem 0; }
.auth-mobile-brand { display: none; color: var(--ink); }
.auth-mobile-brand .brand-badge { background: linear-gradient(140deg, var(--teal-400), var(--teal-700)); }
.auth-box .page-head { margin-bottom: 1.4rem; }
.auth-box .btn[type="submit"]:not(.btn-secondary):not(.btn-ghost), .btn-auth {
  background: linear-gradient(135deg, var(--teal-600), #2563eb); border-color: transparent;
  box-shadow: 0 12px 26px -14px rgba(13, 148, 136, .8);
}
.auth-box .btn[type="submit"]:not(.btn-secondary):not(.btn-ghost):hover, .btn-auth:hover { filter: brightness(1.06); background: linear-gradient(135deg, var(--teal-600), #2563eb); }
@media (max-width: 960px) {
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-main { padding: 1rem; background: transparent; }
  .auth-tools { justify-content: space-between; }
  .auth-mobile-brand { display: flex; }
  .auth-box { padding: 1.2rem 0 2rem; margin-top: .5rem; }
}

/* ---------- Page structure ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem 1.5rem; margin-bottom: 1.4rem; }
.page-head .lead { margin-top: .35rem; }
.page-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: .35rem; color: var(--teal-700); font-weight: 600; margin-bottom: .9rem; font-size: .92rem; }
.back:hover { text-decoration: none; color: var(--teal-900); }

/* Gradient page header (dashboards). */
.hero {
  position: relative; border-radius: 1.1rem; padding: 1.5rem 1.7rem; margin-bottom: 1.4rem; color: #ecfeff;
  background: linear-gradient(105deg, #0f9d8f 0%, #0e6e72 48%, #134e63 100%);
  box-shadow: 0 16px 34px -18px rgba(13, 78, 99, .55);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 1.5rem;
}
.hero::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle 8rem at calc(100% - 6rem) 3rem, rgba(94, 234, 212, .22), transparent 65%); }
.hero > * { position: relative; z-index: 1; min-width: 0; }
.hero .eyebrow { color: var(--teal-200); }
.hero h1 { margin-top: .2rem; font-size: clamp(1.45rem, 2.4vw, 1.8rem); font-weight: 800; letter-spacing: -.02em; color: #fff; line-height: 1.2; }
.hero p.sub { margin-top: .35rem; color: rgba(236, 254, 255, .8); font-size: .95rem; max-width: 70ch; }
.hero .btn-secondary { background: #fff; color: var(--teal-800); border-color: #fff; }
.hero .btn-secondary:hover { background: var(--teal-50); color: var(--teal-900); }
.hero .btn-glass { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .28); box-shadow: none; }
.hero .btn-glass:hover { background: rgba(255, 255, 255, .2); color: #fff; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .75rem; border-radius: 99rem; font-size: .8rem; font-weight: 600;
  background: rgba(255, 255, 255, .14); color: #ecfeff; border: 1px solid rgba(255, 255, 255, .25); }
@media (max-width: 640px) { .hero { padding: 1.2rem 1.15rem; border-radius: 1rem; } }

.section { margin-top: 1.8rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .8rem; }
.sec-head { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.sec-bar { width: .35rem; height: 1.5rem; border-radius: 99rem; flex: none; background: var(--teal-600); }
.sec-note { font-size: .85rem; color: var(--muted); }
.stack > * + * { margin-top: 1.1rem; }
.row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.4rem; align-items: start; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .cols { grid-template-columns: 1fr; } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .cols-2, .grid-3 { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-body { padding: 1.35rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: 1rem 1.35rem; border-bottom: 1px solid #f1f5f4; }
.card-title { font-size: .98rem; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: .5rem; }
.card-title .icon { color: var(--teal-600); }
.card-sub { font-size: .85rem; color: var(--muted); margin-top: .1rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 1.2rem 1.35rem; }
.panel + .panel { margin-top: 1rem; }
.panel-title { font-size: .98rem; font-weight: 700; color: var(--ink); margin-bottom: .8rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; height: 2.65rem; padding: 0 1.1rem; border-radius: var(--radius);
  font: inherit; font-size: .93rem; font-weight: 600; line-height: 1; white-space: nowrap; cursor: pointer; text-decoration: none !important;
  border: 1px solid var(--teal-600); background: var(--teal-600); color: #fff; box-shadow: var(--shadow-xs);
  transition: background .15s, border-color .15s, box-shadow .2s, transform .12s, color .15s;
}
.btn:hover { background: var(--teal-700); border-color: var(--teal-700); color: #fff; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:focus-visible { box-shadow: var(--ring); }
.btn:disabled { opacity: .55; cursor: progress; transform: none; }
.btn-secondary { background: #fff; color: var(--teal-800); border-color: #d6e4e2; box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--teal-50); color: var(--teal-900); border-color: var(--teal-300); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: transparent; }
.btn-warning { background: var(--red); border-color: var(--red); }
.btn-warning:hover { background: #be123c; border-color: #be123c; }
.btn-small { height: 2.2rem; padding: 0 .85rem; font-size: .86rem; border-radius: .6rem; }
.btn-lg { height: 3rem; padding: 0 1.35rem; font-size: 1rem; border-radius: .85rem; }
.btn-block { width: 100%; }
.btn-icon { width: 2.4rem; padding: 0; }
.btn-group { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; }
.linklike { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--teal-700); cursor: pointer; }
.linklike:hover { text-decoration: underline; text-underline-offset: 2px; }
.danger-link { color: var(--red-text) !important; }

/* ---------- Forms ---------- */
.field + .field { margin-top: 1.1rem; }
.field-label { display: block; font-size: .875rem; font-weight: 600; color: var(--text-2); margin-bottom: .35rem; }
.field-hint { display: block; color: var(--muted); font-size: .84rem; margin: -.1rem 0 .45rem; }
.field-error { display: block; color: var(--red-text); font-size: .86rem; font-weight: 500; margin: .1rem 0 .4rem; }
.optional { font-weight: 400; color: var(--faint); }
.input {
  display: block; width: 100%; height: 2.75rem; padding: 0 .85rem; font: inherit; font-size: .95rem; color: var(--ink);
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: none;
  transition: border-color .15s, box-shadow .15s; appearance: none;
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: var(--teal-300); }
.input:focus { outline: none; border-color: var(--teal-500); box-shadow: var(--ring); }
.has-error .input { border-color: #fda4af; }
.has-error .input:focus { box-shadow: 0 0 0 3px rgba(225, 29, 72, .15); border-color: var(--red); }
textarea.input { height: auto; min-height: 7rem; padding: .7rem .85rem; line-height: 1.55; resize: vertical; }
select.input {
  padding-right: 2.4rem; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2364748b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; background-size: 1.15rem;
}
select.input[multiple] { height: auto; background-image: none; padding: .4rem; }
.input-w-5 { max-width: 7.5rem; }
.input-suffix { display: flex; align-items: stretch; }
.input-suffix .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-suffix .suffix {
  display: flex; align-items: center; padding: 0 .85rem; border: 1px solid var(--border-strong); border-left: 0; white-space: nowrap;
  border-radius: 0 var(--radius) var(--radius) 0; background: var(--teal-50); color: var(--teal-800); font-weight: 600;
}
/* Phone: the group is drawn as one input, with the fixed country code inside it. */
.input-prefix {
  display: flex; align-items: stretch; height: 2.75rem; background: #fff; border: 1px solid var(--border-strong);
  border-radius: var(--radius); transition: border-color .15s, box-shadow .15s;
}
.input-prefix:hover { border-color: var(--teal-300); }
.input-prefix:focus-within { border-color: var(--teal-500); box-shadow: var(--ring); }
.input-prefix .prefix {
  display: flex; align-items: center; padding: 0 .7rem 0 .85rem; border-right: 1px solid var(--border); white-space: nowrap;
  border-radius: var(--radius) 0 0 var(--radius); background: var(--teal-50); color: var(--teal-800); font-size: .95rem; font-weight: 600;
}
.input-prefix .input, .input-prefix .input:focus, .has-error .input-prefix .input:focus {
  height: 100%; border: 0; border-radius: 0 var(--radius) var(--radius) 0; box-shadow: none; background: transparent;
}
.input-prefix .prefix, .input-prefix .input { font-variant-numeric: tabular-nums; }
.has-error .input-prefix { border-color: #fda4af; }
.has-error .input-prefix:focus-within { box-shadow: 0 0 0 3px rgba(225, 29, 72, .15); border-color: var(--red); }
.checkbox { display: flex; gap: .7rem; align-items: flex-start; cursor: pointer; font-size: .95rem; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--teal-600); }
.checkbox input { width: 1.1rem; height: 1.1rem; margin: .15rem 0 0; flex-shrink: 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .5rem .9rem; }
.check-grid label { display: flex; gap: .5rem; align-items: center; padding: .45rem .65rem; border: 1px solid var(--border); border-radius: .6rem; background: #fff; cursor: pointer; }
.check-grid label:hover { border-color: var(--teal-300); background: var(--teal-50); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { padding: 0; }
.file-field input[type=file] { font: inherit; font-size: .9rem; color: var(--text-2); }
.file-field input[type=file]::file-selector-button {
  font: inherit; font-weight: 600; margin-right: .8rem; height: 2.4rem; padding: 0 1rem; border-radius: var(--radius);
  border: 1px solid #d6e4e2; background: #fff; color: var(--teal-800); cursor: pointer;
}
.file-field input[type=file]::file-selector-button:hover { background: var(--teal-50); }
.image-preview { display: flex; align-items: flex-end; gap: .8rem; margin-top: .8rem; }
.image-preview img { width: 6rem; height: 6rem; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }

/* ---------- Notices ---------- */
.messages { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.3rem; }
.notice {
  display: flex; gap: .6rem; align-items: flex-start; padding: .8rem 1rem; border-radius: .9rem; font-size: .92rem; font-weight: 500;
  border: 1px solid var(--blue-line); background: var(--blue-soft); color: #1e3a8a; box-shadow: var(--shadow-xs);
}
.notice-info { border-color: var(--teal-200); background: var(--teal-50); color: var(--teal-800); }
.notice-success { background: var(--green-soft); border-color: var(--green-line); color: #065f46; }
.notice-error { background: var(--red-soft); border-color: var(--red-line); color: #9f1239; }
.notice-warning { background: var(--amber-soft); border-color: var(--amber-line); color: #92400e; }
.notice .linklike { color: inherit; text-decoration: underline; }
.error-summary { padding: .9rem 1rem; border-radius: .9rem; border: 1px solid var(--red-line); background: var(--red-soft); color: #9f1239; }
.error-summary h2 { font-size: .95rem; font-weight: 700; margin-bottom: .2rem; }
.error-summary ul { padding-left: 1.1rem; font-size: .9rem; }
.error-summary a { color: #9f1239; }
.inset { border-left: 3px solid var(--teal-200); padding: .25rem 0 .25rem .9rem; }
.inset-green { border-left-color: var(--green); }

/* ---------- Status pills ---------- */
.tag {
  display: inline-flex; align-items: center; gap: .45rem; height: 1.75rem; padding: 0 .75rem; border-radius: 99rem;
  font-size: .82rem; font-weight: 600; white-space: nowrap; background: #f1f5f9; color: #475569;
}
.tag::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; flex: none; }
.tag-new, .tag-warn, .tag-high { background: #fef3c7; color: var(--amber-text); }
.tag-in_progress { background: var(--cyan-soft); color: var(--cyan-text); }
.tag-in_progress::before { animation: pulse-dot 1.6s ease-in-out infinite; }
.tag-done { background: #d1fae5; color: var(--green-text); }
.tag-rejected, .tag-grey, .tag-withdrawn, .tag-routine { background: #f1f5f9; color: #475569; }
.tag-urgent, .tag-overdue { background: #ffe4e6; color: var(--red-text); }
.tag-lg { height: 2rem; font-size: .88rem; padding: 0 .9rem; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.cat { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; white-space: nowrap; color: var(--text-2); }
.cat::before { content: ""; width: .6rem; height: .6rem; border-radius: .2rem; }
.cat-health::before { background: var(--teal-500); }
.cat-suggestion::before { background: #f59e0b; }
.cat-complaint::before { background: #f43f5e; }
.unassigned { color: var(--amber-text); font-weight: 600; }

/* ---------- Segmented tabs ---------- */
.tabs {
  display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 1rem; background: #eef3f2; border-radius: .8rem;
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  display: inline-flex; align-items: center; gap: .45rem; height: 2.25rem; padding: 0 .9rem; border-radius: .6rem; white-space: nowrap;
  color: #64748b; font-weight: 600; font-size: .9rem; text-decoration: none !important; transition: background .12s, color .12s;
}
.tabs a:hover { color: var(--teal-700); }
.tabs a[aria-current="page"] { background: #fff; color: var(--teal-700); box-shadow: 0 1px 2px rgba(15, 46, 43, .1); }
.tabs .count { min-width: 1.35rem; padding: 0 .4rem; border-radius: 99rem; font-size: .72rem; font-weight: 700; line-height: 1.3rem; text-align: center; background: rgba(15, 46, 43, .06); color: #64748b; font-variant-numeric: tabular-nums; }
.tabs a[aria-current="page"] .count { background: var(--teal-100); color: var(--teal-700); }
.tabs-block { display: flex; width: 100%; }
.tabs-block a { flex: 1; justify-content: center; }
.hero .tabs { margin: 0; background: rgba(255, 255, 255, .14); }
.hero .tabs a { color: rgba(236, 253, 245, .85); }
.hero .tabs a:hover { color: #fff; }
.hero .tabs a[aria-current="page"] { background: #fff; color: var(--teal-700); }

/* ---------- Option cards (role choice, new appeal) ---------- */
.options { list-style: none; padding: 0; display: grid; gap: .75rem; }
.options-grid { grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
.option {
  display: grid; grid-template-columns: auto 1fr auto; gap: .15rem .95rem; align-items: center; padding: 1rem 1.1rem; height: 100%;
  background: #fff; border: 1px solid var(--border); border-radius: 1rem; box-shadow: var(--shadow-sm);
  color: var(--text); text-decoration: none !important; transition: transform .15s, box-shadow .2s, border-color .2s;
}
.option:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--teal-200); color: var(--text); }
.option-icon { grid-row: 1 / span 2; width: 2.9rem; height: 2.9rem; border-radius: .85rem; display: grid; place-items: center; color: #fff; box-shadow: 0 8px 18px -8px rgba(15, 46, 43, .35); background: linear-gradient(140deg, #64748b, #334155); }
.option-title { font-size: 1.02rem; font-weight: 700; color: var(--ink); }
.option-text { grid-column: 2; color: var(--muted); font-size: .9rem; line-height: 1.45; }
.option > .icon:last-child { grid-row: 1 / span 2; grid-column: 3; color: var(--faint); transition: transform .15s, color .15s; }
.option:hover > .icon:last-child { color: var(--teal-600); transform: translateX(2px); }
.options-grid .option { grid-template-columns: 1fr auto; grid-template-rows: auto auto 1fr; gap: .2rem .8rem; padding: 1.3rem; align-items: start; }
.options-grid .option-icon { grid-row: 1; grid-column: 1; margin-bottom: .8rem; }
.options-grid .option-title { grid-column: 1 / span 2; }
.options-grid .option-text { grid-column: 1 / span 2; }
.options-grid .option > .icon:last-child { grid-row: 1; grid-column: 2; }
/* Gradient tiles, as MedScribe's module icons. */
.tone-health, .grad-teal { background: linear-gradient(140deg, #2dd4bf, #0d9488); color: #fff; }
.tone-suggestion, .grad-amber { background: linear-gradient(140deg, #fbbf24, #f97316); color: #fff; }
.tone-complaint, .grad-rose { background: linear-gradient(140deg, #fb7185, #e11d48); color: #fff; }
.tone-accent, .grad-emerald { background: linear-gradient(140deg, #34d399, #059669); color: #fff; }
.tone-blue, .grad-sky { background: linear-gradient(140deg, #38bdf8, #2563eb); color: #fff; }
.grad-violet { background: linear-gradient(140deg, #a78bfa, #7c3aed); color: #fff; }
.grad-slate { background: linear-gradient(140deg, #64748b, #334155); color: #fff; }
.icon-tile { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: .8rem; flex: none; box-shadow: 0 8px 18px -8px rgba(15, 46, 43, .35); }

.poly-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); gap: .6rem; }
.poly-list a {
  display: flex; align-items: center; gap: .65rem; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: .85rem;
  background: #fff; color: var(--text); text-decoration: none !important; box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.poly-list a:hover { border-color: var(--teal-300); box-shadow: var(--shadow); transform: translateY(-1px); }
.poly-list strong { display: grid; place-items: center; min-width: 2.3rem; height: 2.3rem; border-radius: .65rem; font-size: .92rem; font-weight: 800; color: var(--teal-700); background: linear-gradient(140deg, #ccfbf1, #99f6e4); font-variant-numeric: tabular-nums; }
.poly-list span { font-size: .86rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Summary list ---------- */
.summary { display: grid; grid-template-columns: minmax(8.5rem, 34%) 1fr; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: .3rem 1.35rem; }
.summary dt, .summary dd { margin: 0; padding: .75rem 0; border-bottom: 1px solid #f1f5f4; }
.summary dt { color: var(--muted); font-size: .9rem; padding-right: 1rem; }
.summary dd { font-weight: 600; color: var(--text); word-break: break-word; }
.summary dt:nth-last-of-type(1), .summary dd:last-of-type { border-bottom: 0; }
@media (max-width: 560px) {
  .summary { grid-template-columns: 1fr; }
  .summary dt { border-bottom: 0; padding-bottom: 0; }
  .summary dd { padding-top: .1rem; }
}

/* ---------- Tables ---------- */
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .93rem; }
.table th {
  text-align: left; padding: .75rem 1rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--teal-700); background: var(--teal-50); border-bottom: 1px solid var(--teal-100); white-space: nowrap;
}
.table td { padding: .85rem 1rem; border-bottom: 1px solid #eef3f2; vertical-align: top; color: var(--text-2); }
.table tbody tr { transition: background .12s; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--teal-50); }
.table tr[data-href] { cursor: pointer; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .row-muted td { color: var(--faint); }
.table-plain { box-shadow: none; }
.cell-title { font-weight: 700; color: var(--text); }
a.cell-title:hover { color: var(--teal-700); }
.cell-sub { display: block; color: var(--muted); font-size: .84rem; margin-top: .15rem; }
.cell-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; align-items: center; }
.person { display: inline-flex; align-items: center; gap: .55rem; font-weight: 600; color: var(--text); }
.avatar {
  width: 2rem; height: 2rem; border-radius: .65rem; flex-shrink: 0; display: inline-grid; place-items: center;
  color: var(--teal-700); background: linear-gradient(140deg, #ccfbf1, #99f6e4); font-weight: 700; font-size: .78rem;
}
.person .avatar { width: 1.75rem; height: 1.75rem; font-size: .7rem; border-radius: .55rem; }
.urg-bar { box-shadow: inset 3px 0 0 transparent; }
tr.is-urgent td:first-child { box-shadow: inset 3px 0 0 #f43f5e; }
tr.is-high td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }

@media (max-width: 760px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: .8rem 1rem; border-bottom: 1px solid #eef3f2; }
  .table-stack tbody tr:last-child { border-bottom: 0; }
  .table-stack td { border: 0 !important; padding: .15rem 0; background: none !important; box-shadow: none !important; }
  .table-stack td[data-label]::before { content: attr(data-label) " · "; color: var(--faint); font-size: .82rem; }
  .table-stack td.td-primary { padding-bottom: .4rem; }
  .table-stack tr.is-urgent { box-shadow: inset 3px 0 0 #f43f5e; }
  .table-stack tr.is-high { box-shadow: inset 3px 0 0 #f59e0b; }
}

/* ---------- Appeal list (patient) ---------- */
.items { list-style: none; padding: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.item { padding: 1rem 1.25rem; position: relative; transition: background .12s; }
.item + .item { border-top: 1px solid #f1f5f4; }
.item:hover { background: #f8fbfa; }
.item-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; }
.item-title { font-size: 1rem; font-weight: 700; color: var(--text); }
a.item-title::after { content: ""; position: absolute; inset: 0; }
a.item-title:hover { color: var(--teal-800); text-decoration: none; }
.item-meta { color: var(--muted); font-size: .84rem; margin-top: .15rem; }
.item-text { margin-top: .4rem; color: var(--text-2); word-break: break-word; }
.empty { padding: 2rem 1rem; color: var(--muted); text-align: center; }
p.empty { border: 1.5px dashed #c8d8d5; border-radius: 1rem; background: rgba(240, 253, 250, .5); }
.items .empty, .table .empty { background: #fff; }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filters .field { margin: 0; }
.filters .field + .field { margin: 0; }
.filters .field-label { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.filters .input { height: 2.6rem; font-size: .92rem; }
.filters .f-search { flex: 1 1 16rem; position: relative; }
.filters .f-search .input { padding-left: 2.4rem; }
.filters .f-search .icon { position: absolute; left: .8rem; top: .75rem; color: var(--faint); pointer-events: none; }
.filters .f-select { flex: 0 1 13rem; }
.filters .btn { height: 2.6rem; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 1.15rem 1.9rem; }
.timeline li::before { content: ""; position: absolute; left: .5rem; top: 1.3rem; bottom: 0; width: 2px; background: #e6eceb; border-radius: 2px; }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; left: .1rem; top: .3rem; width: .85rem; height: .85rem; border-radius: 50%; background: #fff; border: 2.5px solid var(--border-strong); }
.timeline .k-created .dot { border-color: var(--blue); }
.timeline .k-auto_assigned .dot, .timeline .k-assigned .dot { border-color: #f59e0b; }
.timeline .k-status .dot { border-color: var(--teal-600); background: var(--teal-600); }
.timeline .k-comment .dot { border-color: var(--violet); }
.timeline .k-rated .dot { border-color: #f59e0b; background: #fef3c7; }
.timeline .k-triage .dot { border-color: var(--red); }
.timeline .t-head { display: flex; flex-wrap: wrap; gap: .2rem .5rem; align-items: baseline; }
.timeline .t-title { font-weight: 600; color: var(--text); }
.timeline .t-meta { color: var(--muted); font-size: .84rem; }
.timeline .msg { margin-top: .4rem; padding: .7rem .85rem; border-radius: .8rem; background: var(--surface-2); border: 1px solid var(--border); white-space: pre-line; word-break: break-word; color: var(--text-2); }
.timeline .internal .msg { background: var(--amber-soft); border-color: var(--amber-line); }

.photo { display: inline-block; margin-top: .9rem; }
.photo img { max-width: 17rem; max-height: 17rem; object-fit: cover; border-radius: .8rem; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }

/* ---------- KPI cards (tinted, MedScribe style) ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: .8rem; margin-bottom: 1.3rem; }
.kpi {
  position: relative; display: flex; flex-direction: column; gap: .1rem; padding: 1rem 1.1rem; border-radius: .9rem; border: 1px solid #99f6e4;
  background: linear-gradient(160deg, #f0fdfa, #fff); color: var(--text); text-decoration: none !important;
  transition: transform .15s, box-shadow .2s, border-color .2s;
}
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); color: var(--text); }
.kpi-label { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #64748b; display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.kpi-label .icon { color: var(--kpi-accent, var(--teal-600)); }
.kpi-value, .kpi b { display: block; margin-top: .15rem; font-size: 1.85rem; font-weight: 800; letter-spacing: -.02em; color: var(--text); line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .82rem; color: #64748b; margin-top: .25rem; display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.kpi > span:not([class]) { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #64748b; }
.kpi-teal { --kpi-accent: #0d9488; background: linear-gradient(160deg, #f0fdfa, #fff); border-color: #99f6e4; }
.kpi-sky { --kpi-accent: #2563eb; background: linear-gradient(160deg, #eff6ff, #fff); border-color: #bfdbfe; }
.kpi-violet { --kpi-accent: #7c3aed; background: linear-gradient(160deg, #f5f3ff, #fff); border-color: #ddd6fe; }
.kpi-amber, .kpi-warn { --kpi-accent: #d97706; background: linear-gradient(160deg, #fffbeb, #fff); border-color: #fde68a; }
.kpi-emerald { --kpi-accent: #059669; background: linear-gradient(160deg, #ecfdf5, #fff); border-color: #a7f3d0; }
.kpi-rose, .kpi-danger { --kpi-accent: #e11d48; background: linear-gradient(160deg, #fff1f2, #fff); border-color: #fecdd3; }
.kpi-slate { --kpi-accent: #475569; background: linear-gradient(160deg, #f8fafc, #fff); border-color: #e2e8f0; }
.kpi-danger:not(.kpi-zero) b { color: var(--red-text); }
.kpi-warn:not(.kpi-zero) b { color: var(--amber-text); }
.kpi.kpi-zero { --kpi-accent: #94a3b8; background: linear-gradient(160deg, #f8fafc, #fff); border-color: #e2e8f0; }
.kpi.active { box-shadow: 0 0 0 2px var(--kpi-accent, var(--teal-600)), var(--shadow); }
.delta { display: inline-flex; align-items: center; gap: .15rem; padding: .1rem .45rem; border-radius: 99rem; font-size: .72rem; font-weight: 700; }
.delta-up { background: #d1fae5; color: #047857; }
.delta-down { background: #ffe4e6; color: #be123c; }
.delta-flat { background: #f1f5f9; color: #475569; }

/* Legacy key figures (kept for small summaries). */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: .8rem; }
.figure { background: #fff; border: 1px solid var(--border); border-radius: .9rem; box-shadow: var(--shadow-sm); padding: 1rem 1.1rem; }
.figure span { display: block; color: var(--muted); font-size: .85rem; }
.figure b { display: block; margin-top: .2rem; font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Analytics ---------- */
.metric-pills { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.2rem; }
.metric-pill {
  display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .85rem; border-radius: 99rem; font-size: .82rem; font-weight: 600;
  background: #fff; color: var(--text-2); border: 1px solid #e2e8f0; text-decoration: none !important; transition: background .12s, color .12s, border-color .12s;
}
.metric-pill:hover { background: var(--teal-50); color: var(--teal-700); border-color: var(--teal-200); }
.insights { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); }
.insight { display: flex; gap: .7rem; border-radius: .85rem; padding: .8rem .9rem; }
.insight-ic { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; flex: none; border-radius: .65rem; background: #fff; }
.insight b { display: block; font-size: .9rem; color: var(--text); }
.insight p { margin-top: .1rem; font-size: .84rem; line-height: 1.45; color: var(--muted); }
.insight-teal { background: #f0fdfa; box-shadow: inset 0 0 0 1px #ccfbf1; } .insight-teal .insight-ic { color: #0f766e; }
.insight-sky { background: #eff6ff; box-shadow: inset 0 0 0 1px #bfdbfe; } .insight-sky .insight-ic { color: #1d4ed8; }
.insight-violet { background: #f5f3ff; box-shadow: inset 0 0 0 1px #ddd6fe; } .insight-violet .insight-ic { color: #6d28d9; }
.insight-amber { background: #fffbeb; box-shadow: inset 0 0 0 1px #fde68a; } .insight-amber .insight-ic { color: #b45309; }
.insight-rose { background: #fff1f2; box-shadow: inset 0 0 0 1px #fecdd3; } .insight-rose .insight-ic { color: #be123c; }
.chart-card { padding: 1.2rem 1.3rem; }
.chart-card h3 { font-size: .95rem; font-weight: 700; color: var(--ink); }
.chart-card .chart-sub { font-size: .84rem; color: var(--muted); margin: .1rem 0 .8rem; }
.chart-wrap { position: relative; height: 260px; }
.chart-wrap.tall { height: 300px; }
.chart-wrap.short { height: 220px; }
.chart-wrap canvas { position: absolute; inset: 0; }
.chart-empty { display: grid; place-items: center; height: 100%; color: var(--faint); font-size: .9rem; }
.heatmap { display: flex; flex-direction: column; gap: .3rem; }
.heat-row { display: flex; align-items: center; gap: .5rem; }
.heat-row > span { width: 2.2rem; flex: none; font-size: .75rem; font-weight: 600; color: var(--muted); }
.heat-cells { display: flex; flex: 1; gap: 3px; }
.heat-cells i { flex: 1; height: 1.75rem; border-radius: .35rem; background: linear-gradient(rgba(13, 148, 136, var(--a, 0)), rgba(13, 148, 136, var(--a, 0))), #f1f6f5; }
.heat-hours { display: flex; flex: 1; gap: 3px; }
.heat-hours span { flex: 1; text-align: center; font-size: .68rem; color: var(--faint); }
.bar-cell { display: flex; align-items: center; gap: .55rem; min-width: 7rem; }
.bar-track { flex: 1; height: .45rem; border-radius: 99rem; background: #f1f5f9; overflow: hidden; min-width: 4rem; }
.bar-fill { display: block; height: 100%; border-radius: 99rem; background: var(--teal-500); }
.gauge { display: grid; place-items: center; position: relative; }
.gauge-value { position: absolute; text-align: center; }
.gauge-value b { display: block; font-size: 1.9rem; font-weight: 800; color: var(--ink); letter-spacing: -.02em; }
.gauge-value span { font-size: .8rem; color: var(--muted); }

/* ---------- Details ---------- */
details.reveal summary { cursor: pointer; color: var(--teal-700); font-weight: 600; list-style: none; display: inline-flex; align-items: center; gap: .4rem; }
details.reveal summary::-webkit-details-marker { display: none; }
details.reveal summary::after { content: "▾"; font-size: .7rem; color: var(--muted); transition: transform .15s; }
details.reveal[open] summary::after { transform: rotate(180deg); }
details.reveal[open] > div { margin-top: .9rem; }

/* ---------- Pagination ---------- */
.pagination { display: flex; justify-content: space-between; align-items: center; gap: .8rem; margin-top: 1rem; font-size: .9rem; }

/* ---------- Toasts & lightbox ---------- */
.toast-root { position: fixed; right: 1.25rem; bottom: 1.25rem; left: auto; z-index: 100; display: flex; flex-direction: column; gap: .5rem; max-width: calc(100% - 2.5rem); }
.toast { min-width: 18rem; max-width: 27rem; background: var(--ink); color: #f0fdfa; padding: .8rem .95rem; border-radius: .9rem; display: flex; align-items: center; gap: .8rem; box-shadow: var(--shadow-lg); font-size: .9rem; animation: toast-in .18s ease-out; }
.toast .btn { margin-left: auto; height: 2rem; padding: 0 .8rem; font-size: .85rem; background: #fff; color: var(--teal-800); border-color: #fff; box-shadow: none; }
@keyframes toast-in { from { transform: translateY(6px); opacity: 0; } }
@media (max-width: 640px) { .toast-root { left: .75rem; right: .75rem; bottom: .75rem; } .toast { max-width: none; } }
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(15, 23, 42, .78); display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.lightbox img { max-width: 100%; max-height: 88vh; border-radius: 1rem; box-shadow: var(--shadow-lg); }
.lightbox-close { position: absolute; top: 1rem; right: 1rem; width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .14); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* ---------- QR poster ---------- */
.poster { background: #fff; border: 1px solid var(--border); border-radius: 1.2rem; box-shadow: var(--shadow-sm); padding: 2rem; text-align: center; }
.poster-title { font-size: 1.4rem; font-weight: 800; letter-spacing: -.01em; color: var(--ink); }
.poster .qr { width: min(280px, 100%); margin: 1.25rem auto 1rem; padding: .8rem; border-radius: 1rem; background: #fff; box-shadow: inset 0 0 0 1px var(--border); }
.poster .qr svg { width: 100%; height: auto; display: block; }
.poster-link { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85rem; color: var(--muted); word-break: break-all; }

/* ---------- Urgency, triage, ratings ---------- */
.notice-danger { flex-direction: column; gap: .15rem; background: var(--red-soft); border-color: var(--red-line); color: #881337; }
.notice-danger strong { font-weight: 700; }
.triage { margin-bottom: 1rem; padding: 1rem 1.1rem; border-radius: 1rem; border: 1px solid var(--border); background: #fff; box-shadow: var(--shadow-sm); }
.triage-urgent { border-color: var(--red-line); background: linear-gradient(160deg, #fff1f2, #fff); }
.triage-high { border-color: var(--amber-line); background: linear-gradient(160deg, #fffbeb, #fff); }
.triage-head { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .4rem; }
.triage-flags { display: flex; flex-wrap: wrap; gap: .4rem; margin: .25rem 0 .4rem; }
.triage-flags span { font-size: .82rem; font-weight: 600; padding: .15rem .55rem; border-radius: .45rem; background: #fff; color: var(--text-2); box-shadow: inset 0 0 0 1px var(--border); }
.triage p + p { margin-top: .25rem; }
.mini-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.mini-list .tag { margin-left: .4rem; }
.stars { display: inline-flex; flex-direction: row-reverse; gap: .25rem; }
.stars input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.stars label { font-size: 2rem; line-height: 1; color: #d6e4e2; cursor: pointer; transition: color .1s, transform .1s; }
.stars label:hover { transform: scale(1.08); }
.stars label:hover, .stars label:hover ~ label, .stars input:checked ~ label { color: #f59e0b; }
.stars input:focus-visible + label { outline: 2px solid var(--teal-600); border-radius: 4px; }
.rating-view span { font-size: 1.4rem; color: #d6e4e2; }
.rating-view span.on { color: #f59e0b; }

/* ---------- Accessibility helpers ---------- */
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 300; background: var(--ink); color: #fff; padding: .6rem .9rem; border-radius: var(--radius); }
.skip-link:focus { left: .75rem; top: .75rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; white-space: nowrap; }

@media print {
  body { background: #fff; }
  .appbar, .no-print, .messages, .toast-root, .app-footer { display: none !important; }
  .content { padding: 0; }
  .hero { color: var(--ink); background: none; box-shadow: none; padding: 0; }
  .hero h1 { color: var(--ink); }
  .poster { border: 0; box-shadow: none; }
  .poster-title { font-size: 2.1rem; }
  .poster .qr { width: 70%; }
}

/* Language segmented control (sign-in pages). */
.lang-seg { display: inline-flex; gap: .15rem; padding: .2rem; border-radius: .7rem; background: rgba(15, 46, 43, .06); }
.lang-seg button { border: 0; background: none; cursor: pointer; padding: .3rem .7rem; border-radius: .5rem; font: inherit; font-size: .78rem; font-weight: 700; color: #64748b; }
.lang-seg button:hover { color: var(--teal-700); }
.lang-seg button.is-active { background: #fff; color: var(--teal-700); box-shadow: var(--shadow-sm); }
.kpis-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1280px) { .kpis-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .kpis-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpis-6 .kpi b { font-size: 1.5rem; } }
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .kpi { padding: .8rem .85rem; }
  .kpi b, .kpi-value { font-size: 1.5rem; }
  .kpi-label { font-size: .66rem; letter-spacing: .07em; }
  .kpi-sub { font-size: .76rem; }
  .metric-pills { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: .1rem; }
  .metric-pill { flex: none; }
}
@media (max-width: 640px) {
  .options-grid .option { grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; padding: 1rem 1.1rem; align-items: center; }
  .options-grid .option-icon { grid-row: 1 / span 2; grid-column: 1; margin: 0; }
  .options-grid .option-title, .options-grid .option-text { grid-column: 2; }
  .options-grid .option > .icon:last-child { grid-row: 1 / span 2; grid-column: 3; }
}
