/* Colours, type and radii follow the CureBay Figma design (light). */
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("/static/fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f9f9f9;          /* Black/2 */
  --panel: #ffffff;       /* Black/1 */
  --panel-2: #f9f9f9;
  --line: #e5e5e5;        /* Black/3 */
  --line-soft: #ebebeb;
  --text: #000000;        /* Black/12 */
  --text-2: #4d4d4d;      /* Black/9 */
  --muted: #808080;       /* Black/7 */
  --placeholder: #cccccc; /* Black/4 */
  --accent: #004172;      /* Blue Primary/Brand */
  --Gradient-special-CTA: linear-gradient(90deg, #3CBA84 0%, #004172 100%);  /* green to brand blue */
  --ok: #00b82e;          /* Success/Dark */
  --ok-bg: #e8fff1;       /* Success/light */
  --warn: #d29300;        /* Warning/Dark */
  --warn-bg: #fff3d7;
  --bad: #d82525;         /* Error/Dark */
  --bad-bg: #ffdbdb;
  /* darker inks for small status text on the light status backgrounds (>= 4.5:1) */
  --ok-ink: #00701c;
  --warn-ink: #7a5600;
  --bad-ink: #b01c1c;
  --shadow-card: 0 2px 20px rgb(0 65 114 / .08), inset 0 0 2px rgb(0 65 114 / .12);  /* Outer/6 */
  --shadow-btn: 0 2px 4px rgb(0 65 114 / .08), inset 0 0 2px rgb(0 65 114 / .08);    /* Outer/2 */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-ui: "Geist", var(--font);
  --topbar: 64px;
  --pager: 52px;
  --side: 290px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 500 14px/1.4 var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; font: 600 15px var(--font-ui); white-space: nowrap; }
.brand-logo { display: block; height: 24px; width: auto; }
.stats { display: flex; gap: 8px; margin-left: 12px; }
.pill {
  padding: 6px 12px; border-radius: 8px;
  background: var(--panel-2); color: var(--muted);
  font-size: 12px; letter-spacing: .03em; white-space: nowrap;
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.spacer { flex: 1; }
.search {
  width: 280px; height: 40px; padding: 0 14px;
  background: var(--panel); border: 1.5px solid var(--accent); border-radius: 12px; outline: none;
  letter-spacing: .02em;
}
.search::placeholder { color: var(--muted); }
.search:focus { box-shadow: 0 0 0 3px rgb(0 65 114 / .18); }
.toggle { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; white-space: nowrap; cursor: pointer; }
.toggle input { accent-color: var(--accent); }
.seg {
  display: flex; gap: 2px; padding: 3px;
  background: rgb(255 255 255 / .48); border-radius: 12px;
  box-shadow: inset 0 0 5px rgb(0 65 114 / .2);   /* Inner/5 */
}
.seg button { background: none; border: 0; border-radius: 9px; padding: 5px 11px; color: var(--text-2); }
.seg button.active { background: var(--accent); color: #fff; }
.icon-btn {
  display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 8px;
  background: var(--panel); border: 0; border-radius: 12px; box-shadow: var(--shadow-btn);
  color: var(--accent); text-decoration: none; font-size: 15px;
}
.icon-btn:hover { background: var(--panel-2); }
.seg button:hover:not(.active) { color: var(--accent); }
.icon-btn.active { background: var(--accent); color: #fff; }
#menuBtn { display: inline-grid; }

/* ---------- layout ---------- */
.layout { display: flex; height: calc(100% - var(--topbar)); }
.sidebar {
  width: var(--side); flex: none; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--line);
  font-family: var(--font-ui);
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px 8px 24px; color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
}
.tree-actions { display: flex; gap: 2px; }
.tree-actions button {
  padding: 3px 6px; border: 0; border-radius: 6px; background: none;
  color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase;
}
.tree-actions button:hover { background: var(--panel-2); color: var(--accent); }

/* sidebar tree: state folder > site > camera */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree { padding: 0 12px 16px; }
.tree-row {
  display: flex; align-items: center; gap: 2px;
  padding-left: calc(var(--depth, 0) * 12px);
  border: 1px solid transparent; border-radius: 6px;
}
.tree-row:hover { background: var(--panel-2); }
.tree-row.active { background: var(--panel-2); border-color: var(--line); }
.caret {
  flex: none; width: 20px; height: 28px; padding: 0; border: 0; background: none;
  color: var(--text-2); font-size: 13px; line-height: 1;
}
.caret::before { content: "\25B8"; display: inline-block; transition: transform .15s; }
.caret.open::before { transform: rotate(90deg); }
.caret:hover { color: var(--accent); }
.tree-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 2px;
  background: none; border: 0; text-align: left;
  color: var(--text-2); font-size: 13px; font-weight: 400;
}
.tree-row.root .tree-main { color: var(--text); font-weight: 600; }
.tree-row.org .tree-main { color: var(--text); font-weight: 600; text-transform: capitalize; }
.tree-row.cam .tree-main { color: var(--muted); font-size: 12px; padding-top: 4px; padding-bottom: 4px; }
.tree-row.cam:hover .tree-main { color: var(--accent); }
.tree-row.active .tree-main { color: var(--text); font-weight: 600; }
.tree-row.active .count { color: var(--text); font-weight: 600; }
.tree-row.offline .site-name { color: var(--muted); }
.tree-empty { padding: 12px 16px; color: var(--muted); font-size: 13px; }
.site-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.banner {
  margin: 12px 12px 0; padding: 12px 16px;
  background: var(--warn-bg); color: #7a5600;
  border: 1px solid rgb(210 147 0 / .3); border-radius: 12px; font-size: 13px;
}

/* ---------- camera grid ---------- */
.grid {
  flex: 1; min-height: 0; padding: 12px; gap: 10px;
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 4), minmax(0, 1fr));
}
.tile {
  position: relative; overflow: hidden; min-height: 0;
  background: #000; border: 1px solid var(--line); border-radius: 16px; cursor: pointer;
  box-shadow: 0 4px 6px rgb(0 65 114 / .08);
}
.tile:hover, .tile:focus-visible { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px rgb(0 65 114 / .25); }
.tile cam-player, .tile video { display: block; width: 100%; height: 100%; }
.tile video { object-fit: contain; background: #000; }
.label {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  background: linear-gradient(rgb(0 0 0 / .65), transparent);
  color: #fff; font-size: 12px; pointer-events: none;
}
.label .dot { width: 7px; height: 7px; }
.cam-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-site { color: #d9d9d9; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #999; font-size: 13px; pointer-events: none; text-align: center; padding: 0 10px;
}
.tile[data-state="live"] .status { display: none; }
.tile[data-state="error"] .status { color: #ff9a9a; }
.tile.is-offline {
  cursor: default; box-shadow: none;
  background: repeating-linear-gradient(45deg, #f2f2f2, #f2f2f2 10px, #ededed 10px, #ededed 20px);
}
.tile.is-offline .label { background: none; color: var(--text-2); }
.tile.is-offline .cam-site { color: var(--muted); }
.tile.is-offline .status { color: var(--bad); }
.tile.is-offline:hover { border-color: var(--line); box-shadow: none; }
.empty { grid-column: 1 / -1; grid-row: 1 / -1; display: grid; place-items: center; color: var(--muted); }

.pager {
  height: var(--pager); flex: none; display: flex; align-items: center; justify-content: center; gap: 16px;
  border-top: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 12px;
}
.pager button {
  background: var(--panel); border: 0; border-radius: 12px; box-shadow: var(--shadow-btn);
  padding: 7px 14px; color: var(--accent); font-weight: 600; font-size: 13px;
}
.pager button:hover:not(:disabled) { background: var(--panel-2); }
.pager button:disabled { opacity: .35; cursor: default; }
.pager.single button { visibility: hidden; }

/* ---------- HD modal ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgb(0 0 0 / .6); }
.modal-inner {
  width: min(1400px, 100%); display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border-radius: 24px; box-shadow: var(--shadow-card);
}
.modal-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 20px; font-weight: 700; font-size: 16px; }
.badge { font-size: 12px; font-weight: 500; padding: 5px 10px; border-radius: 8px; background: var(--accent); color: #fff; }
.modal-video { aspect-ratio: 16 / 9; max-height: calc(100vh - 110px); }
.modal-video .tile { height: 100%; border: 0; border-radius: 0; box-shadow: none; cursor: default; }
.modal-video .tile:hover { box-shadow: none; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; padding: 16px; overflow: auto; }
.login-card {
  width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; padding: 32px;
  background: var(--panel); border-radius: 24px; box-shadow: var(--shadow-card);
}
.login-card .brand-logo { height: 32px; align-self: flex-start; }
.login-title { margin: 8px 0 0; font-size: 24px; font-weight: 700; letter-spacing: .01em; }
.login-sub { margin: -8px 0 4px; color: var(--muted); font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--text-2); font-size: 13px; }
.login-card input {
  height: 44px; padding: 0 14px; background: var(--panel);
  border: 1px solid var(--line-soft); border-radius: 12px; outline: none; font-size: 15px;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  height: 48px; margin-top: 6px; background: var(--accent); border: 0; border-radius: 16px;
  color: #fff; font-weight: 500; font-size: 16px; box-shadow: 0 2px 2px rgb(0 65 114 / .08);
}
.login-card button:hover { background: #00355d; }
.login-error { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--bad-bg); color: var(--bad); font-size: 13px; }

/* ---------- page nav (Live / AI Monitor) ---------- */
.seg a { padding: 5px 11px; border-radius: 9px; color: var(--text-2); text-decoration: none; white-space: nowrap; }
.seg a.active { background: var(--accent); color: #fff; }
.seg a:hover:not(.active) { color: var(--accent); }

/* ---------- AI monitor ---------- */
body.page-monitor { overflow: auto; }
.updated { color: var(--muted); font-size: 12px; white-space: nowrap; }
.mon { display: flex; flex-direction: column; gap: 16px; max-width: 1800px; margin: 0 auto; padding: 16px 20px 32px; }
.mon .banner { margin: 0; }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.kpis-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi {
  min-width: 0; padding: 14px 16px; background: var(--panel); border-radius: 16px;
  border-top: 3px solid transparent; box-shadow: var(--shadow-card);
}
.kpi.bad { border-top-color: var(--bad); }
.kpi.warn { border-top-color: var(--warn); }
.kpi-link { color: inherit; text-decoration: none; }
button.kpi { width: 100%; font: inherit; text-align: left; cursor: pointer; border: 0; border-top: 3px solid transparent; }
button.kpi.bad { border-top-color: var(--bad); }
button.kpi.warn { border-top-color: var(--warn); }
.kpi-link:hover, .kpi-link:focus-visible { outline: none; box-shadow: 0 0 0 2px rgb(0 65 114 / .3), var(--shadow-card); }
.kpi.kpi-active { box-shadow: 0 0 0 2px var(--accent), var(--shadow-card); }  /* the card whose clinics are shown */
.band-note { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.band-note .link-btn { height: auto; padding: 0; }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.kpi-value { margin: 4px 0 2px; color: var(--text); font: 700 28px/1.2 var(--font-ui); font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--text-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.report-total { margin: 0 0 6px; font-size: 15px; font-weight: 700; color: var(--text); }
.kpi-sub .kpi-line { overflow: hidden; text-overflow: ellipsis; }  /* a sub line of its own, cut on its own */

.mon-panel { min-width: 0; padding: 16px; background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-card); }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font: 600 16px var(--font-ui); }
.seg-small button { padding: 3px 9px; font-size: 12px; }
.empty-note { padding: 12px 4px; color: var(--muted); font-size: 13px; list-style: none; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-2); color: var(--text-2); font-size: 11px; font-weight: 600; white-space: nowrap;
}
.chip-icon { font-size: 10px; }
.chip.ok { background: var(--ok-bg); color: var(--ok-ink); }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.chip.bad { background: var(--bad-bg); color: var(--bad-ink); }
/* a chip that filters (the status chips on the cluster and state pages) */
.chip-btn { border: 0; font-family: inherit; cursor: pointer; }
.chip-btn:hover { box-shadow: inset 0 0 0 1px currentColor; }
.chip-btn[aria-pressed="true"] { box-shadow: inset 0 0 0 2px currentColor; }
.chip-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.clinics { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.clinic { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.clinic-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.clinic-title { min-width: 0; }
.clinic-title h3 { margin: 0; font: 600 15px var(--font-ui); }
.clinic-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.clinic-state { color: var(--muted); font-size: 12px; }
.clinic-meta { color: var(--text-2); font-size: 12px; }
.clinic-hours { margin-top: -4px; color: var(--muted); font-size: 12px; }
.mon-cams { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.mon-cam {
  position: relative; aspect-ratio: 11 / 9; padding: 0; overflow: hidden;
  background: #111; border: 1px solid var(--line); border-radius: 10px;
}
.mon-cam:hover, .mon-cam:focus-visible { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px rgb(0 65 114 / .25); }
.mon-cam.bad { border-color: var(--bad); }
.mon-cam img { display: block; width: 100%; height: 100%; object-fit: cover; }
img.missing { visibility: hidden; }
.mon-cam-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #999; font-size: 12px; }
.mon-cam-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 6px; padding: 14px 6px 6px;
  background: linear-gradient(transparent, rgb(0 0 0 / .72));
}
.mon-cam-label {
  flex: 1; min-width: 0; color: #fff; font-size: 11px; font-weight: 600; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mon-cam-people { color: #fff; font-size: 11px; white-space: nowrap; }

.modal-photo { width: min(1000px, 100%); }
.modal-photo img { display: block; width: 100%; max-height: calc(100vh - 200px); object-fit: contain; background: #000; }
.modal-text { margin: 0; padding: 12px 20px 16px; color: var(--text-2); font-size: 14px; }

.panel-note { margin: -4px 0 12px; color: var(--muted); font-size: 12px; font-weight: 400; }
.panel-note b { color: var(--text-2); font-weight: 600; }

/* ---------- clinic scores ---------- */
.score-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.score-period { color: var(--muted); font-size: 12px; }
.score-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.table-wrap { overflow-x: auto; }
.score-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.score-table th, .score-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.score-table thead th { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.score-table .num { min-width: 120px; }
.row-state th { padding-top: 16px; font: 700 15px var(--font-ui); }
.row-state td, .row-state th { background: var(--panel-2); }
.row-cluster th { padding-left: 22px; font-weight: 600; }
.row-com { margin-left: 10px; color: var(--muted); font-size: 12px; font-weight: 500; }
.row-clinic .clinic-name { padding-left: 36px; color: var(--text-2); }
.row-clinic:hover td { background: var(--panel-2); }
.score-cell { display: inline-flex; align-items: center; gap: 8px; }
.score-bar { width: 70px; height: 6px; overflow: hidden; background: var(--line); border-radius: 3px; }
.score-bar i { display: block; height: 100%; border-radius: 3px; background: var(--muted); }
.score-cell.ok .score-bar i { background: var(--ok); }
.score-cell.warn .score-bar i { background: var(--warn); }
.score-cell.bad .score-bar i { background: var(--bad); }
.score-num { min-width: 22px; font-variant-numeric: tabular-nums; }
.score-none, .muted-cell { color: var(--muted); }
.score-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }

/* ---------- distribution pies (Scores page): the Clinic Monitoring System's design ---------- */
.dist-section h2 { margin: 0; font: 600 16px var(--font-ui); }
.dist-hint { margin: 4px 0 12px; color: var(--muted); font-size: 12px; font-weight: 400; }
.pie-row { display: flex; flex-wrap: wrap; gap: 14px; }
.pie-card, .category-pie-card {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-card);
}
.pie-card { min-width: 150px; padding: 14px 16px; }
.pie, .pie-empty { flex: 0 0 auto; width: 72px; height: 72px; border-radius: 50%; }
.pie-empty, .category-pie-empty {
  display: flex; align-items: center; justify-content: center; padding: 6px;
  background: var(--bg); color: var(--muted); font-size: 11px; text-align: center;
}
.pie-window, .category-pie-window { font: 600 12px var(--font-ui); }
.pie-legend { display: flex; flex-direction: column; gap: 3px; width: 100%; color: var(--muted); font-size: 11px; }
.pie-legend .row { display: flex; align-items: center; gap: 6px; }
.pie-dot, .category-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; }
.pie-dot.high { background: var(--bad); }
.pie-dot.medium { background: var(--warn); }
.pie-dot.low { background: var(--ok); }
.category-pie-row { display: flex; flex-wrap: nowrap; gap: 10px; }
.category-pie-card { min-width: 0; padding: 14px 10px; }
.category-pie, .category-pie-empty { flex: 0 0 auto; width: 96px; height: 96px; border-radius: 50%; }
.category-legend { display: flex; flex-direction: column; gap: 3px; width: 100%; max-height: 170px; overflow-y: auto; font-size: 11px; }
.category-legend-row { display: flex; align-items: center; gap: 6px; }
.category-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-pct { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* a pie and its legend rows open the problems they count, on the Incidents page */
a.pie-link { color: inherit; text-decoration: none; cursor: pointer; }
a.pie-link:hover .category-name, a.pie-link.row:hover { color: var(--accent); text-decoration: underline; }
a.pie-link.pie:hover, a.pie-link.category-pie:hover, a.pie-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.category-legend-row.pie-link { color: var(--text); }

/* ---------- report pop-ups (AI Monitor tiles) ---------- */
.report-sheet { width: min(1100px, 100%); max-height: calc(100vh - 32px); }
.report-sheet .modal-bar { flex-wrap: wrap; gap: 10px; border-bottom: 1px solid var(--line); }
.report-day select {
  height: 36px; padding: 0 10px; background: var(--panel); color: var(--text);
  border: 1.5px solid var(--accent); border-radius: 10px; font: 500 13px var(--font);
}
.report-body { overflow-y: auto; padding: 16px 20px 24px; }
.report-downloads { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.report-download { display: inline-flex; align-items: center; text-decoration: none; }
.report-note { color: var(--muted); font-size: 12px; }
.report-sub { margin: 18px 0 8px; font: 600 14px var(--font-ui); }
/* the clinic status report's four parts, each in a box with the brand gradient as its border */
.report-box {
  margin-top: 14px; padding: 14px 16px; border: 1.5px solid transparent; border-radius: 16px;
  background: linear-gradient(var(--panel), var(--panel)) padding-box,
              var(--Gradient-special-CTA, linear-gradient(90deg, #3CBA84 0%, #004172 100%)) border-box;
}
/* the status pop-up's parts: opened, did not open, no video, offline - each on its status's light colour */
.report-box-ok { --box-bg: #effff5; }
.report-box-bad { --box-bg: #fff1f1; }
.report-box-warn { --box-bg: #fff8e6; }
.report-box-off { --box-bg: #f2f2f2; }
.report-box[class*="report-box-"] {
  background: linear-gradient(var(--box-bg), var(--box-bg)) padding-box,
              var(--Gradient-special-CTA, linear-gradient(90deg, #3CBA84 0%, #004172 100%)) border-box;
}
.report-box > .report-sub:first-child { margin-top: 0; font-size: 15px; font-weight: 700; }
.report-group { margin-bottom: 10px; }
.report-group-state { margin-top: 12px; padding: 6px 0; font: 700 15px var(--font-ui); border-bottom: 2px solid var(--line); }
.report-group-cluster { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin: 10px 0 4px; font-weight: 600; }
.cluster-contact { color: var(--muted); font-size: 12px; font-weight: 500; }
.report-table td { vertical-align: middle; }

/* ---------- incidents ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.filters label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.filters select {
  min-width: 150px; height: 38px; padding: 0 10px; background: var(--panel); color: var(--text);
  border: 1px solid var(--line-soft); border-radius: 10px; font: 500 13px var(--font); text-transform: none; letter-spacing: 0;
}
.filters select:focus { border-color: var(--accent); outline: none; }
.filters select:disabled { background: var(--panel-2); color: var(--muted); cursor: not-allowed; }
/* filters that take several values: a button that opens a list of tick boxes */
.filters .flt { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 600;
                letter-spacing: .03em; text-transform: uppercase; }
.ms { position: relative; }
.ms-btn {
  position: relative; min-width: 150px; max-width: 230px; height: 38px; padding: 0 28px 0 10px; text-align: left;
  background: var(--panel); color: var(--text); border: 1px solid var(--line-soft); border-radius: 10px;
  font: 500 13px var(--font); text-transform: none; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ms-btn::after { content: '▾'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.ms-btn:focus { border-color: var(--accent); outline: none; }
.ms-on .ms-btn { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.ms-panel {
  position: absolute; z-index: 30; top: 42px; left: 0; min-width: 220px; max-height: 340px; overflow-y: auto; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgb(0 0 0 / .16);
}
.filters .ms-opt {
  display: flex; flex-direction: row; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer;
  color: var(--text); font: 500 13px var(--font); text-transform: none; letter-spacing: 0; width: auto;
}
.filters .ms-opt:hover { background: var(--panel-2); }
.filters .ms-opt input { accent-color: var(--accent); width: 16px; height: 16px; }
.ms-all { height: auto; padding: 4px 8px 6px; text-transform: none; letter-spacing: 0; }
.filters input[type="datetime-local"] {
  height: 38px; padding: 0 10px; background: var(--panel); color: var(--text); border: 1px solid var(--line-soft);
  border-radius: 10px; font: 500 13px var(--font); text-transform: none; letter-spacing: 0;
}
.filters input[type="datetime-local"]:focus { border-color: var(--accent); outline: none; }
.link-btn { height: 38px; padding: 0 6px; background: none; border: 0; color: var(--accent); font-size: 13px; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }

.inc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.inc-table th, .inc-table td { padding: 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
.inc-table thead th { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
.inc-table th[data-sort] { cursor: pointer; user-select: none; }
.inc-table th[data-sort]:hover, .inc-table th.sorted { color: var(--accent); }
.inc-table th[data-sort]::after { content: attr(data-arrow); margin-left: 4px; font-size: 9px; }
.inc-table th[data-sort]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.inc-row { cursor: pointer; }
.inc-row:hover td { background: var(--panel-2); }
.inc-row.resolved td { color: var(--text-2); }
.inc-evidence { display: flex; gap: 6px; min-width: 196px; }
.inc-thumb { position: relative; display: block; width: 92px; aspect-ratio: 11 / 9; overflow: hidden; background: #111; border-radius: 8px; }
.inc-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.inc-thumb-none { position: absolute; inset: 0; display: grid; place-items: center; color: #999; font-size: 11px; }
.inc-thumb-label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 6px 3px; color: #fff; font-size: 10px; font-weight: 600;
  background: linear-gradient(transparent, rgb(0 0 0 / .7));
}
.inc-link { color: var(--text); font-weight: 600; text-decoration: none; }
.inc-link:hover { color: var(--accent); text-decoration: underline; }
.inc-title { display: block; font-weight: 600; }
.inc-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.inc-desc {
  display: -webkit-box; max-width: 340px; margin-top: 4px; overflow: hidden; color: var(--text-2); font-size: 12px; font-weight: 400;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.nowrap { white-space: nowrap; }
.num-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }

.inc-detail { max-width: 1400px; }
.back-link { align-self: flex-start; color: var(--accent); font-size: 13px; font-weight: 600; text-decoration: none; }
.back-link:hover { text-decoration: underline; }
#content { display: flex; flex-direction: column; gap: 16px; }
#content[hidden] { display: none; }
.inc-header h1 { margin: 0 0 8px; font: 700 22px/1.3 var(--font-ui); }
.inc-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inc-group { color: var(--text-2); font-size: 13px; }
.inc-where { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.kpi-value-sm { font-size: 20px; }
.evidence { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.evidence-photo { margin: 0; }
.evidence-btn { display: block; width: 100%; padding: 0; overflow: hidden; background: #111; border: 1px solid var(--line); border-radius: 12px; aspect-ratio: 11 / 9; }
.evidence-btn:hover, .evidence-btn:focus-visible { border-color: var(--accent); outline: none; }
.evidence-btn img { display: block; width: 100%; height: 100%; object-fit: contain; }
.evidence-none { display: grid; place-items: center; aspect-ratio: 11 / 9; background: var(--panel-2); border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: 13px; }
.evidence-photo figcaption { margin-top: 6px; color: var(--text-2); font-size: 12px; }
.inc-latest { margin: 0; font-size: 15px; }
/* what to do about the incident, in the brand gradient (the text itself is coloured, not a box behind it) */
.inc-reason {
  width: fit-content; max-width: 100%; margin: 6px 0 0; font-size: 14px; font-weight: 600;
  background: var(--Gradient-special-CTA, linear-gradient(90deg, #3CBA84 0%, #004172 100%));
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
}
.timeline { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.timeline { max-height: 560px; overflow-y: auto; }
.tl-item { padding: 0 0 10px 14px; border-left: 2px solid var(--line); }
.tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tl-time { min-width: 64px; color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.tl-label { font-size: 13px; font-weight: 600; }
.tl-desc { margin: 4px 0 0; color: var(--muted); font-size: 12px; font-weight: 400; }
.tl-staff { color: var(--text); }
.tl-staff .link-btn { height: auto; padding: 0; font-size: 12px; }
/* Ask AI's error line */
.comment-error { color: var(--bad-ink); font-size: 12px; }
.primary-btn { height: 38px; padding: 0 16px; background: var(--accent); border: 0; border-radius: 12px; color: #fff; font-weight: 600; }
.primary-btn:hover { background: #00355d; }
.primary-btn:disabled { opacity: .5; cursor: default; }
.secondary-btn {
  height: 38px; padding: 0 14px; background: var(--panel); color: var(--accent);
  border: 1.5px solid var(--accent); border-radius: 12px; font-weight: 600; white-space: nowrap;
}
.secondary-btn:hover { background: var(--panel-2); }
.secondary-btn:focus-visible, .primary-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- clinic overview ---------- */
.clinic-page { max-width: 1500px; }
.clinic-page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.clinic-page-head h1 { margin: 0; font: 700 26px/1.2 var(--font-ui); }
.clinic-reason { margin: 6px 0 0; color: var(--text-2); font-size: 13px; }
.clinic-live { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.clinic-live.single { grid-template-columns: minmax(0, 1fr); max-width: 900px; }
.clinic-live .tile { aspect-ratio: 16 / 9; }  /* the HD pop-up sizes itself, as on the Live page */
.tile > img { display: block; width: 100%; height: 100%; object-fit: contain; }
.tile.is-still { cursor: default; }
.tile.is-still .status { align-items: end; padding-bottom: 14px; color: #ffb3b3; }
.tile.can-play { cursor: pointer; }
.still-time {
  position: absolute; left: 10px; top: 38px; padding: 3px 8px; border-radius: 999px;
  background: rgb(0 0 0 / .6); color: #fff; font-size: 11px; pointer-events: none;
}
.live-note { margin: 10px 0 0; }
.clinic-inc-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.clinic-inc-head .inc-sub { display: inline; margin: 0; }
.concern-period select {
  height: 34px; padding: 0 10px; background: var(--panel); color: var(--text);
  border: 1px solid var(--line-soft); border-radius: 10px; font: 500 13px var(--font);
}
.concern-period select:focus { border-color: var(--accent); outline: none; }
.concern-table td { vertical-align: middle; }
.concern-thumb { width: 72px; }
.chips-cell .chip + .chip { margin-left: 4px; }
.bad-text { color: var(--bad-ink); font-weight: 600; }
.group-clinics td { vertical-align: middle; }
.worst-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.worst-card { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-left: 4px solid var(--bad); border-radius: 12px; }
.worst-photo { position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden; background: #111; }
.worst-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.worst-photo:hover img, .worst-photo:focus-visible img { opacity: .9; }
.worst-rank {
  position: absolute; top: 8px; left: 8px; padding: 3px 9px; border-radius: 999px;
  background: rgb(0 0 0 / .65); color: #fff; font: 700 13px var(--font-ui);
}
.worst-body { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px 14px; }
.worst-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.worst-name { font: 700 16px var(--font-ui); }
.worst-com { color: var(--text-2); font-size: 12px; }
.worst-what { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.worst-what .inc-sub { display: inline; margin: 0; }
.worst-desc { margin: 0; font-size: 13px; line-height: 1.45; }
.worst-time { margin: 0; color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.worst-sum { margin: 2px 0 0; padding-top: 8px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 12px; }
.concern-more { margin: -4px 0 0; text-align: right; }
.alert-when { margin: 4px 0 0; color: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.alert-more { display: inline-block; color: var(--accent); font-size: 12px; font-weight: 600; text-decoration: none; }
.alert-more:hover { text-decoration: underline; }

.day-bar { position: relative; height: 44px; margin: 6px 0 26px; background: var(--panel-2); border-radius: 8px; }
.day-hours { position: absolute; top: -3px; bottom: -3px; border: 2px dashed var(--accent); border-radius: 8px; opacity: .45; pointer-events: none; }
.day-seg { position: absolute; top: 8px; bottom: 8px; border-radius: 3px; }
.day-open { background: var(--ok); }
.day-closed { background: #9a9a9a; }
.day-unclear { background: var(--warn); opacity: .55; }
/* offline: nothing could be streamed. Striped, so it does not read as a red problem mark */
.day-offline, .lg-offline { background: repeating-linear-gradient(135deg, var(--bad) 0 4px, color-mix(in srgb, var(--bad) 35%, transparent) 4px 8px); }
.day-offline { z-index: 1; }
.day-issue { position: absolute; top: -14px; transform: translateX(-50%); color: var(--warn); font-size: 11px; line-height: 1; }
.day-issue.high { color: var(--bad); }
.day-now { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); }
.day-tick { position: absolute; top: 48px; transform: translateX(-50%); color: var(--muted); font-size: 11px; white-space: nowrap; }
.day-legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--text-2); font-size: 12px; }
.day-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { display: inline-block; width: 14px; height: 10px; border-radius: 2px; font-style: normal; }
.lg-open { background: var(--ok); }
.lg-closed { background: #9a9a9a; }
.lg-unclear { background: var(--warn); opacity: .55; }
.lg-issue { width: auto; height: auto; color: var(--warn); font-size: 11px; }
.lg-hours { border: 2px dashed var(--accent); opacity: .6; }
.days-table .row-empty td { color: var(--muted); }
/* Last 14 days: the column names in the brand gradient, as on an incident's reason line */
.grad-text {
  background: var(--Gradient-special-CTA, linear-gradient(90deg, #3CBA84 0%, #004172 100%));
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
}
.days-table thead th { font-size: 12px; font-weight: 700; }

.cam-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 12px; }
.cam-check { display: flex; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.cam-check-pic { flex: none; width: 140px; }
.cam-check-body { min-width: 0; }
.cam-check .inc-desc { max-width: none; -webkit-line-clamp: 3; }

.clinic-link { color: inherit; text-decoration: none; }
.clinic-link:hover, .clinic-link:focus-visible { color: var(--accent); text-decoration: underline; outline: none; }

/* ---------- ask the AI ---------- */
.suggest {
  position: fixed; z-index: 30; margin: 0; padding: 6px; list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-card);
}
.suggest-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); font-size: 13px; cursor: pointer; }
.suggest-item:hover, .suggest-item.active { background: var(--panel-2); color: var(--accent); }
.suggest-icon { width: 16px; color: var(--accent); text-align: center; }
.ask-form { display: flex; flex-direction: column; gap: 10px; }
.ask-form .seg { align-self: flex-start; flex-wrap: wrap; }
.ask-custom { display: flex; flex-wrap: wrap; gap: 12px; }
.ask-custom label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.ask-custom input, .ask-row input {
  height: 40px; padding: 0 12px; background: var(--panel); color: var(--text);
  border: 1px solid var(--line-soft); border-radius: 10px; font: 500 13px var(--font);
}
.ask-custom input:focus, .ask-row input:focus { border-color: var(--accent); outline: none; }
.ask-row { display: flex; gap: 10px; }
.ask-row input { flex: 1; min-width: 0; font-size: 14px; border: 1.5px solid var(--accent); }  /* blue, like the search boxes */
.ask-row input::placeholder { color: var(--muted); }
.ask-row input:focus { box-shadow: 0 0 0 3px rgb(0 65 114 / .18); }
.ask-row .primary-btn { height: 40px; }
.ask-result { margin-top: 14px; padding: 14px 16px; background: var(--panel-2); border-radius: 12px; }
.ask-understood { margin: 0 0 8px; color: var(--muted); font-size: 12px; }
.ask-para { margin: 0 0 8px; font-size: 14px; line-height: 1.5; }
.ask-para:first-child { font-weight: 600; }
.ask-list { margin: 0 0 8px; padding-left: 20px; font-size: 13px; line-height: 1.55; }
.ask-thinking { margin: 0; color: var(--text-2); font-size: 13px; }
.ask-proof { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.proof-title { margin: 0 0 10px; font: 600 14px var(--font-ui); }
.proof-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.proof-card { margin: 0; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.proof-photo { display: block; width: 100%; padding: 0; aspect-ratio: 11 / 9; overflow: hidden; background: #111; border: 0; }
.proof-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.proof-photo:hover img, .proof-photo:focus-visible img { opacity: .9; }
.proof-photo:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.proof-card figcaption { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px 12px; }
.proof-when { color: var(--text-2); font-size: 12px; }
.proof-when b { color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; }
.proof-verdict { display: flex; flex-wrap: wrap; gap: 6px; }
.proof-desc { margin: 0; color: var(--text-2); font-size: 12px; line-height: 1.45; }
.ask-modal { width: min(760px, 100%); }
.ask-modal-body { max-height: calc(100vh - 140px); overflow-y: auto; padding: 4px 20px 20px; }
.ask-links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; }
.look-status { flex: 1; color: var(--text-2); font-size: 12px; text-align: right; }

/* the Live page's sites list, hidden on a computer to give the cameras the whole width */
.hide-side { font-size: 15px !important; line-height: 1; }
@media (min-width: 761px) {
  body.side-collapsed .sidebar { display: none; }
}

/* the top bar always fits, so the sign-out button never leaves the screen */
.topbar > * { flex-shrink: 0; }
.topbar .search { flex: 0 1 280px; min-width: 140px; width: auto; }
@media (max-width: 1600px) {
  #title { display: none; }
}
@media (max-width: 1400px) {
  .stats { display: none; }
}
@media (max-width: 1100px) {
  .topbar { gap: 8px; padding: 0 14px; }
}
@media (min-width: 761px) and (max-width: 960px) {
  body { overflow: auto; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; row-gap: 10px; }
  .topbar .search { order: 10; flex: 1 1 100%; }
  .layout { height: auto; min-height: calc(100vh - 120px); }
}
@media (max-width: 760px) {
  .topbar .search { order: 10; flex: 1 1 100%; }
}

@media (max-width: 1300px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- small screens ---------- */
@media (max-width: 1100px) {
  .stats, .toggle, #title { display: none; }
  .search { width: 180px; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; row-gap: 10px; }
  .search { order: 10; flex: 1 1 100%; width: auto; }
  #menuBtn { display: inline-grid; }
  .seg button[data-n="16"], .seg button[data-n="25"], #fsBtn { display: none; }
  .layout { height: auto; min-height: calc(100% - var(--topbar)); }
  .sidebar {
    position: fixed; z-index: 10; top: 0; bottom: 0; left: 0; width: min(80vw, 300px);
    transform: translateX(-100%); transition: transform .2s;
  }
  body.side-open .sidebar { transform: none; box-shadow: 0 0 40px rgb(0 65 114 / .2); }
  .grid { display: flex; flex-direction: column; padding: 12px 16px; gap: 10px; }
  .tile { aspect-ratio: 16 / 9; flex: none; }
  .pager { position: sticky; bottom: 0; }
  .mon { padding: 12px 16px 24px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .clinics { grid-template-columns: minmax(0, 1fr); }
  .updated { display: none; }
  .evidence { grid-template-columns: minmax(0, 1fr); }
  .ask-row { flex-direction: column; }
  .look-status { flex-basis: 100%; text-align: left; }
  .clinic-live { grid-template-columns: minmax(0, 1fr); }
  .worst-grid { grid-template-columns: minmax(0, 1fr); }
  .cam-checks { grid-template-columns: minmax(0, 1fr); }
  .category-pie-row { flex-wrap: wrap; }
  .category-pie-card { min-width: 150px; }
  .cam-check-pic { width: 100px; }
  .filters label, .filters .flt { width: calc(50% - 6px); }
  .filters select, .filters .ms-btn { width: 100%; min-width: 0; max-width: none; }
  .filters .ms-opt { width: auto; }
}

/* Timelines x Metrics: numbers right-aligned, cells past the clinic system's thresholds marked */
.metrics-table th.num, .metrics-table td.num { text-align: right; min-width: 0; font-variant-numeric: tabular-nums; }
.metrics-table td.problem { background: var(--bad-bg); color: var(--bad-ink); font-weight: 600; }
.metrics-table td.watch { background: var(--warn-bg); color: var(--warn-ink); font-weight: 600; }
.metrics-table td.metric-overall { font-weight: 700; }
.metrics-table .row-empty td { color: var(--muted); }
.table-wrap + .panel-note { margin: 10px 0 0; }

/* Top areas of concern: the clinic system's cards */
.concern-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.concern-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px 16px;
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-card);
}
.concern-count { font: 600 22px var(--font-ui); font-variant-numeric: tabular-nums; }
.concern-count small { color: var(--muted); font-size: 12px; font-weight: 400; }
.concern-cat { color: var(--muted); font-size: 12px; }

/* Top 3: the worst clinics, live */
.top3-intro { margin: 0 0 12px; }
.top3-row { margin-bottom: 16px; }
.top3-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 12px; }
.top3-rank {
  padding: 2px 9px; border-radius: 999px; background: var(--bad-bg); color: var(--bad-ink);
  font: 700 13px var(--font-ui);
}
.top3-name { font: 700 18px var(--font-ui); }
.top3-where, .top3-count { color: var(--muted); font-size: 12px; }
.top3-problem {
  display: flex; align-items: center; gap: 8px; flex-basis: 100%; min-width: 0;
  color: var(--text); text-decoration: none; font-size: 13px;
}
.top3-problem:hover .top3-desc { text-decoration: underline; }
.top3-desc { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.top3-empty { padding: 24px; }
/* all three clinics on one screen, as a video wall: the two cameras on the left, as tall as a third of
   the space below the top bar, and the clinic's details beside them */
.top3-row { display: grid; grid-template-columns: auto minmax(240px, 1fr); gap: 16px; align-items: start; margin-bottom: 12px; padding: 12px; }
.top3-row .clinic-live { order: -1; width: min(calc((100vh - 250px) / 3 * 32 / 9 + 12px), calc(100vw - 340px)); }
.top3-row .top3-head { flex-direction: column; align-items: flex-start; margin: 0; }
.top3-row .top3-problem { flex-wrap: wrap; }
.top3-row .top3-desc { white-space: normal; }
@media (max-width: 900px) {
  .top3-row { grid-template-columns: minmax(0, 1fr); }
  .top3-row .clinic-live { order: 0; width: auto; }
}

/* Today timeline: readings open their picture, problem marks open their incident */
.day-click { cursor: pointer; }
.day-seg.day-click:hover, .day-seg.day-click:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; z-index: 1; }
.day-issue { padding: 2px 3px; font-size: 13px; z-index: 2; }
.day-issue.day-click:hover, .day-issue.day-click:focus-visible { transform: translateX(-50%) scale(1.4); outline: none; }
.reading-photo { margin: 0; }
.reading-photo img { display: block; width: 100%; max-height: 75vh; object-fit: contain; background: #000; }
.reading-photo figcaption { padding: 10px 12px; color: var(--text-2); font-size: 13px; }

/* a card that opens another page */
a.kpi-link { display: block; color: inherit; text-decoration: none; cursor: pointer; }
a.kpi-link:hover, a.kpi-link:focus-visible { box-shadow: 0 0 0 2px var(--accent); outline: none; }

/* Timelines x Metrics: High % / Medium % carry their case count, quieter than the share */
.metric-cases { color: var(--muted); font-weight: 400; }
/* Timelines x Metrics: a Timeliness number leads to the days it comes from */
.metrics-table td.metric-link { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.metrics-table td.metric-link:hover, .metrics-table td.metric-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.days-table tr.row-flash td { background: #e3f0ff; transition: background .3s; }

/* AI Monitor: the parts of a card's line that open their incidents */
.kpi-sublink { color: var(--accent); font-weight: 600; text-decoration: none; }
.kpi-sublink:hover, .kpi-sublink:focus-visible { text-decoration: underline; }

/* Live page: clinics with an open clinic issue - a thin red (High) or amber (Medium) frame with a glow that
   fades in and out over the video's edges, and a small label */
.tile.issue-high::after, .tile.issue-medium::after {
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none; border-radius: inherit;
}
.tile.issue-high::after { border: 3px solid var(--bad); animation: issue-pulse-high 1.1s ease-in-out infinite; }
.tile.issue-medium::after { border: 3px solid var(--warn); animation: issue-pulse-medium 2.2s ease-in-out infinite; }
@keyframes issue-pulse-high {
  0%, 100% { box-shadow: inset 0 0 6px 2px rgb(216 37 37 / .45); }
  50% { box-shadow: inset 0 0 36px 12px rgb(216 37 37 / .85); }
}
@keyframes issue-pulse-medium {
  0%, 100% { box-shadow: inset 0 0 6px 2px rgb(210 147 0 / .4); }
  50% { box-shadow: inset 0 0 30px 10px rgb(210 147 0 / .75); }
}
@media (prefers-reduced-motion: reduce) {
  .tile.issue-high::after, .tile.issue-medium::after { animation: none; box-shadow: inset 0 0 24px 8px rgb(0 0 0 / .25); }
}
.tile.issue-high .label, .tile.issue-medium .label { z-index: 3; }
.tile-issue {
  position: absolute; left: 8px; bottom: 8px; z-index: 3; max-width: calc(100% - 16px);
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile-issue.high { background: var(--bad); color: #fff; }
.tile-issue.medium { background: var(--warn); color: #1f1600; }
.tile-issue:hover, .tile-issue:focus-visible { text-decoration: underline; outline: 2px solid #fff; }
.issue-dot { width: 9px; height: 9px; margin-left: 6px; border-radius: 50%; flex: none; }
.issue-dot.high { background: var(--bad); }
.issue-dot.medium { background: var(--warn); }
/* AI Monitor: the online clinics' heading, then the offline ones', across the whole grid */
.clinics-group { grid-column: 1 / -1; margin: 6px 2px -4px; font: 600 14px var(--font-ui); color: var(--text-2); }
.clinics-group:first-child { margin-top: 0; }
