/* ITP performance dashboard. The OTP dashboard's design (v2, Oct 2026): a cool quiet ground, white cards, dark text
   that holds on a phone in sunlight, teal only for links and controls, orange for figures that need attention, red only
   for the most serious, grey chips for plain labels. The font is IBM Plex Sans, served by the app itself. */
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 100 700; font-display: swap;
  src: url("/static/fonts/plex-sans.woff2?v=1") format("woff2"); }

:root {
  --ground: #F1F4F3;
  --surface: #FFFFFF;
  --inset: #F6F8F7;
  --line: #CDD5D2;
  --line-soft: #DFE5E2;
  --line-strong: #8C9893;
  --ink: #111816;
  --ink-2: #2F3A37;
  --muted: #46534E;
  --faint: #66716C;
  --teal: #0A6767;
  --teal-dark: #064545;
  --teal-bg: #E2F0EF;
  --hot: #B03F05;
  --hot-bg: #FFF3E9;
  --hot-line: #F5C9A6;
  --red: #B42318;
  --red-bg: #FDECEA;
  --red-line: #E0857A;
  --good: #11643B;
  --good-bg: #DBF2E4;
  --chip: #EDF0EF;
  --s-itp: #064545;            /* chart: the ITP's own line */
  --s-itp-2: #64A6A0;
  --ref-prog: #B0559A;         /* chart: the programme reference line, used for nothing else */
  --c-alive: #2B8063; --c-fth: #2F7BD8; --c-left: #D9A030; --c-dead: #A3220F; --c-other: #9AA4A0;
  --shadow-up: 0 8px 24px rgba(17, 24, 22, .12);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Roboto Mono", monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--sans); color: var(--ink); background: var(--ground); }
a { color: var(--teal); }
a:hover { color: var(--teal-dark); }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 30px; line-height: 1.15; font-weight: 650; }
h2 { font-size: 19px; font-weight: 650; }
h3 { font-size: 16px; font-weight: 650; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.lbl, .muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.sec { font-size: 12px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.hot { color: var(--hot); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.pid { font-family: var(--mono); font-size: .93em; }

/* ---- top bar ---------------------------------------------------------------------------------------------------- */
.topbar { display: flex; align-items: center; gap: 22px; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 0 24px; height: 58px; white-space: nowrap; position: sticky; top: 0; z-index: 30; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand small { font-weight: 500; color: var(--muted); font-size: 13px; }
.nav { display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; align-self: stretch; }
.nav::-webkit-scrollbar { display: none; }
.nav a { display: flex; align-items: center; padding: 0 12px; color: var(--ink-2); text-decoration: none; font-size: 14px;
  border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { font-weight: 650; color: var(--ink); border-bottom-color: var(--teal); }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }
.asof { background: var(--chip); border-radius: 999px; padding: 5px 11px; font-variant-numeric: tabular-nums; }
.acct { position: relative; }
.acct summary { list-style: none; cursor: pointer; width: 34px; height: 34px; border-radius: 50%; display: grid;
  place-items: center; background: var(--teal-bg); color: var(--teal); font-size: 12px; font-weight: 700; }
.acct summary::-webkit-details-marker { display: none; }
.acct-menu { position: absolute; right: 0; top: 42px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow-up); display: flex; flex-direction: column; gap: 8px;
  min-width: 220px; z-index: 40; }

/* ---- page frame ------------------------------------------------------------------------------------------------- */
main { max-width: 1240px; margin: 0 auto; padding: 28px 24px 80px; display: flex; flex-direction: column; gap: 22px; }
.crumbs { display: flex; gap: 8px; color: var(--muted); font-size: 14px; margin-bottom: -10px; }
.crumbs a { text-decoration: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 6px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px; }
.card-head .lbl { font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* buttons and controls */
.btn { font: inherit; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 9px;
  text-decoration: none; cursor: pointer; min-height: 36px; }
.btn:hover { border-color: var(--ink-2); color: var(--ink); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); }
.btn.tint { background: var(--teal-bg); border-color: transparent; color: var(--teal-dark); font-weight: 600; }
.btn.small { padding: 5px 10px; min-height: 30px; font-size: 13px; }
.linkbtn { background: none; border: 0; color: var(--teal); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
select, input[type=text], input[type=email] { font: inherit; font-size: 14px; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); }
.seg { display: inline-flex; background: var(--chip); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg a { padding: 6px 12px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-size: 14px; }
.seg a[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 650;
  box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.period { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.period form { display: flex; gap: 6px; align-items: center; }

/* chips: grey for a plain label, orange for attention, red for the most serious; green only for "better than the
   standard" where a standard exists */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; line-height: 1.3;
  padding: 3px 9px; border-radius: 999px; background: var(--chip); color: var(--ink-2); white-space: nowrap; }
.chip.warn { background: var(--hot-bg); color: var(--hot); }
.chip.alert { background: var(--red); color: #fff; }
.chip.good { background: var(--good-bg); color: var(--good); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--faint); flex: none; }
.dot.warn { background: var(--hot); } .dot.alert { background: var(--red); }

/* ---- the programme readout (overview tiles) --------------------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile .t-lbl { font-size: 13px; color: var(--muted); }
.tile .t-val { font-size: 28px; font-weight: 550; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile .t-aux { font-size: 13px; color: var(--muted); }
.tile.warn { background: var(--hot-bg); border-color: var(--hot-line); }
.tile.warn .t-val, .tile.warn .t-lbl { color: var(--hot); }
.tile.alert { background: var(--red-bg); border-color: var(--red-line); }
.tile.alert .t-val, .tile.alert .t-lbl { color: var(--red); }
a.tile { color: inherit; text-decoration: none; }
a.tile:hover { border-color: var(--line-strong); }

/* ---- ITP cards -------------------------------------------------------------------------------------------------- */
.itp-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }
.itp-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px;
  display: flex; flex-direction: column; gap: 14px; border-left: 4px solid var(--line); }
.itp-card.warn { border-left-color: var(--hot); }
.itp-card.alert { border-left-color: var(--red); }
.itp-card .head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.itp-card h3 { font-size: 20px; }
.itp-card h3 a { color: var(--ink); text-decoration: none; }
.itp-card h3 a:hover { color: var(--teal); }
.itp-card .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.itp-card .concern { font-size: 14px; background: var(--inset); border-radius: 9px; padding: 9px 12px; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
.kv > div { display: flex; flex-direction: column; min-width: 0; }
.kv .k { font-size: 13px; color: var(--muted); }
.kv .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 6px; }
.kv .o { font-size: 12px; color: var(--faint); line-height: 1.3; }
.kv .v.warn { color: var(--hot); } .kv .v.alert { color: var(--red); }
.itp-card .foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: auto; }

/* ---- tables ----------------------------------------------------------------------------------------------------- */
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
th { font-size: 12px; font-weight: 650; color: var(--muted); letter-spacing: .02em; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.grp td { background: var(--inset); font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase;
  letter-spacing: .05em; }
td .warn { color: var(--hot); font-weight: 650; } td .alert { color: var(--red); font-weight: 700; }
td .sub { display: block; font-size: 12px; color: var(--faint); }
.compare th.itp { text-align: right; }
.compare td:first-child { min-width: 230px; }
.compare tr.prog td { font-weight: 600; }

/* ---- ITP page: side panel and sections -------------------------------------------------------------------------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
.side { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 14px; }
.side .card { padding: 18px 20px; }
.facts { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.facts > div { display: flex; justify-content: space-between; gap: 12px; }
.facts .k { color: var(--muted); }
.facts .v { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.jump { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.jump a { text-decoration: none; padding: 3px 0; }
.concerns { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.concerns li { display: flex; gap: 10px; align-items: baseline; font-size: 14px; }
.concerns li .dot { margin-top: 6px; }
.section { scroll-margin-top: 78px; }
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.metric { border: 1px solid var(--line-soft); border-radius: 11px; padding: 13px 15px; display: flex; flex-direction: column;
  gap: 4px; background: var(--surface); }
.metric .m-lbl { font-size: 13px; color: var(--muted); line-height: 1.35; }
.metric .m-val { font-size: 24px; font-weight: 550; font-variant-numeric: tabular-nums; line-height: 1.2; }
.metric .m-of { font-size: 13px; color: var(--muted); }
.metric .m-cmp { font-size: 12.5px; color: var(--faint); }
.metric.warn { border-color: var(--hot-line); background: var(--hot-bg); }
.metric.warn .m-val { color: var(--hot); }
.metric.alert { border-color: var(--red-line); background: var(--red-bg); }
.metric.alert .m-val { color: var(--red); }
.metric.thin .m-val { color: var(--faint); }
details.how { margin-top: 14px; font-size: 13.5px; color: var(--ink-2); }
details.how summary { cursor: pointer; color: var(--teal); font-size: 13.5px; }
details.how dl { margin: 10px 0 0; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 6px 16px; }
details.how dt { font-weight: 600; }
details.how dd { margin: 0; color: var(--muted); }
details.list { margin-top: 14px; }
details.list > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--teal); }
details.list[open] > summary { margin-bottom: 8px; }
.note { font-size: 13.5px; color: var(--muted); background: var(--inset); border-radius: 9px; padding: 9px 12px; }
.note.warn { color: var(--hot); background: var(--hot-bg); }

/* bars: discharge outcomes as one stacked bar (2px gaps between segments) */
.stackbar { display: flex; height: 12px; gap: 2px; border-radius: 6px; overflow: hidden; margin: 6px 0 10px; }
.stackbar > span { display: block; min-width: 2px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* charts (server-drawn SVG) */
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.chart { border: 1px solid var(--line-soft); border-radius: 11px; padding: 12px 14px 8px; }
.chart h4 { font-size: 14px; font-weight: 600; }
.chart .c-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart svg text { font-family: var(--sans); font-size: 11px; fill: var(--muted); }
.chart svg .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart svg .axis { stroke: var(--line); stroke-width: 1; }
.chart svg .l-itp { fill: none; stroke: var(--s-itp); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart svg .l-prog { fill: none; stroke: var(--ref-prog); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; opacity: .85; }
.chart svg .p-itp { fill: var(--s-itp); stroke: var(--surface); stroke-width: 2; }
.chart svg .thr { stroke: var(--hot); stroke-width: 1; stroke-dasharray: 3 3; }
.chart svg .hit { fill: transparent; }
.chart svg .hit:hover + .p-itp, .chart svg g.pt:hover .p-itp { r: 5.5; }
.chart .c-key { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 2px; flex-wrap: wrap; }
.chart .c-key i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 5px; }
.spark svg { width: 100%; height: 44px; display: block; }
.spark .l-itp { fill: none; stroke: var(--s-itp); stroke-width: 2; }
.spark .l-prog { fill: none; stroke: var(--ref-prog); stroke-width: 1.5; opacity: .7; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: #fff; font-size: 12.5px;
  border-radius: 7px; padding: 6px 9px; max-width: 260px; line-height: 1.4; }

/* LOS histogram */
.hist { display: flex; align-items: flex-end; gap: 2px; height: 90px; margin-top: 8px; }
.hist > div { flex: 1; background: var(--s-itp-2); border-radius: 3px 3px 0 0; min-height: 1px; position: relative; }
.hist > div.fast { background: var(--hot); opacity: .75; }
.hist-x { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* ---- reports ---------------------------------------------------------------------------------------------------- */
.rv { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 22px; align-items: start; }
.rv-side { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 12px; }
.rv-box { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.rv-box nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.rv-box nav a { font-size: 14px; text-decoration: none; padding: 5px 8px; border-radius: 7px; color: var(--ink-2); }
.rv-box nav a[aria-current="page"], .rv-box nav a:hover { background: var(--teal-bg); color: var(--teal-dark); }
.report { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 30px 34px; }
.report .r-kicker { font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.report h1 { font-size: 28px; margin: 6px 0 10px; }
.report .r-meta { font-size: 13px; color: var(--muted); padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.report .r-lead { font-size: 16px; line-height: 1.6; margin: 18px 0 6px; max-width: 76ch; }
.report h2 { font-size: 19px; margin: 30px 0 10px; scroll-margin-top: 78px; }
.report .md { max-width: 78ch; line-height: 1.65; }
.report .md p { margin: 0 0 10px; }
.report .md ul, .report .md ol { margin: 0 0 10px; padding-left: 22px; }
.report .md li { margin: 3px 0; }
.report .md table { margin: 8px 0 14px; }
.report .md strong { font-weight: 650; }
.report .actions { display: grid; gap: 10px; margin-top: 6px; }
.report .action { border: 1px solid var(--line-soft); border-radius: 11px; padding: 12px 14px; background: var(--inset); }
.report .action .a-what { font-weight: 650; }
.report .action .a-meta { font-size: 13px; color: var(--muted); margin-top: 3px; }
.report .r-foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.banner { background: var(--hot-bg); color: var(--hot); border-radius: 10px; padding: 10px 14px; font-size: 14px; }

/* ---- empty and error -------------------------------------------------------------------------------------------- */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.login { max-width: 420px; margin: 12vh auto; text-align: center; display: flex; flex-direction: column; gap: 16px; }

/* ---- phones ----------------------------------------------------------------------------------------------------- */
@media (max-width: 1000px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; order: -1; }
  .side .jump-card, .side .feed-card { display: none; }
  .rv { grid-template-columns: minmax(0, 1fr); }
  .rv-side { position: static; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .topbar { padding: 0 14px; gap: 10px; }
  .brand small, .asof { display: none; }
  main { padding: 20px 14px 60px; }
  h1 { font-size: 25px; }
  .card { padding: 18px 16px; }
  .report { padding: 22px 18px; }
  .itp-cards { grid-template-columns: minmax(0, 1fr); }
  details.how dl { grid-template-columns: minmax(0, 1fr); }
  .nav a { padding: 0 9px; }
}
@media print {
  .topbar, .rv-side, .period, .no-print { display: none !important; }
  body { background: #fff; }
  .card, .report { border: 0; padding: 0; }
  main { padding: 0; }
}
