/*
 * Colour.
 *
 * The ramp is VFCi EMR's, taken as it stands there rather than approximated:
 *
 *   slate  #16202A   #234A57   #2A6E73   #319C8C   #55C99B   #8EF79B  mint
 *
 * with #F1F8F5, #DDF0E8, #4C6B66 and #CFE5DC derived, because the ramp has no near-white and a
 * page needs one. Two systems the same people use all day should not be two different colours,
 * and matching by eye produces neighbours that are almost the same, which reads as a mistake
 * rather than a family.
 *
 * Teal carries the light theme and mint the dark one, for the reason the EMR gives: teal on a
 * dark ground disappears, and white on the sea green above it is 3.35:1, which fails body text.
 *
 * Every colour below is a variable, including the sidebar, which used to be six hardcoded values.
 * A theme that reaches most of a page and not the rest is worse than no theme at all.
 */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --raised: #F1F8F5;
  --border: #CFE5DC;
  --border-soft: #E4F0EA;
  --text: #16202A;
  --muted: #4C6B66;
  --accent: #2A6E73;
  --accent-hover: #235A5E;
  --accent-soft: #DDF0E8;
  --accent-line: #A9D9C6;
  --on-accent: #ffffff;

  --good: #1a7f4b;
  --good-soft: #e6f4ec;
  --warn: #9a6700;
  --warn-soft: #fff4e0;
  --warn-line: #f0d9a8;
  --warn-text: #7a5200;
  --bad: #b3261e;
  --bad-soft: #fdeceb;
  --bad-line: #f5c6c3;
  --bad-text: #8c1d18;
  --info-line: #A9D9C6;
  --info-text: #1F5B52;

  --sidebar-bg: #16202A;
  --sidebar-text: #B9D6CA;
  --sidebar-strong: #ffffff;
  --sidebar-muted: #7E9E93;
  --sidebar-line: rgba(255, 255, 255, 0.08);
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active: rgba(85, 201, 155, 0.16);
  --sidebar-link: #9CC4B7;
  --sidebar-link-hover: #DCEFE6;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
}

/*
 * Dark.
 *
 * Declared twice on purpose. The media query is what somebody gets before they have ever touched
 * the switch, guarded so an explicit choice of light is not overridden by the machine's setting;
 * the attribute is what the switch sets, and must win in both directions.
 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16202A;
    --surface: #1C2E38;
    --raised: #234A57;
    --border: #234A57;
    --border-soft: #1F3D48;
    --text: #DCEFE6;
    --muted: #9CC4B7;
    --accent: #55C99B;
    --accent-hover: #8EF79B;
    --accent-soft: #234A57;
    --accent-line: #319C8C;
    --on-accent: #16202A;

    --good: #8EF79B;
    --good-soft: #1E3D35;
    --warn: #F0C475;
    --warn-soft: #3A3122;
    --warn-line: #5C4C2E;
    --warn-text: #F0C475;
    --bad: #FF9A93;
    --bad-soft: #3D2523;
    --bad-line: #5E332F;
    --bad-text: #FF9A93;
    --info-line: #319C8C;
    --info-text: #9CC4B7;

    --sidebar-bg: #101A22;
    --sidebar-text: #B9D6CA;
    --sidebar-strong: #DCEFE6;
    --sidebar-muted: #7E9E93;
    --sidebar-line: rgba(255, 255, 255, 0.07);
    --sidebar-hover: rgba(255, 255, 255, 0.05);
    --sidebar-active: rgba(85, 201, 155, 0.18);
    --sidebar-link: #9CC4B7;
    --sidebar-link-hover: #DCEFE6;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  --bg: #16202A;
  --surface: #1C2E38;
  --raised: #234A57;
  --border: #234A57;
  --border-soft: #1F3D48;
  --text: #DCEFE6;
  --muted: #9CC4B7;
  --accent: #55C99B;
  --accent-hover: #8EF79B;
  --accent-soft: #234A57;
  --accent-line: #319C8C;
  --on-accent: #16202A;

  --good: #8EF79B;
  --good-soft: #1E3D35;
  --warn: #F0C475;
  --warn-soft: #3A3122;
  --warn-line: #5C4C2E;
  --warn-text: #F0C475;
  --bad: #FF9A93;
  --bad-soft: #3D2523;
  --bad-line: #5E332F;
  --bad-text: #FF9A93;
  --info-line: #319C8C;
  --info-text: #9CC4B7;

  --sidebar-bg: #101A22;
  --sidebar-text: #B9D6CA;
  --sidebar-strong: #DCEFE6;
  --sidebar-muted: #7E9E93;
  --sidebar-line: rgba(255, 255, 255, 0.07);
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active: rgba(85, 201, 155, 0.18);
  --sidebar-link: #9CC4B7;
  --sidebar-link-hover: #DCEFE6;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Tells the browser to paint its own furniture - scrollbars, form controls - to match. */
:root { color-scheme: light; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ------------------------------- layout ------------------------------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 12px;
}
.brand h1 { font-size: 16px; margin: 0; color: var(--sidebar-strong); letter-spacing: 0.2px; }
.brand span { font-size: 11px; color: var(--sidebar-muted); text-transform: uppercase; letter-spacing: 0.8px; }

.nav-group { margin-bottom: 14px; }

/*
 * The group heading. Small, spaced and dim on purpose: it is a signpost you read once on the way
 * past, not a thing to click, so it must not compete with the rows underneath it.
 */
.nav-group-label {
  padding: 0 20px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--sidebar-muted);
}

/*
 * Sized in ems so the icon tracks the label if the row's font size is ever changed, and
 * flex-shrink: 0 so a long label cannot squash it into an ellipse.
 */
.nav-icon {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  opacity: 0.75;
}
.nav button:hover .nav-icon,
.nav button.active .nav-icon { opacity: 1; }

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--sidebar-text);
  padding: 9px 20px;
  font-size: 13.5px;
  cursor: pointer;
  font-family: inherit;
  border-left: 3px solid transparent;
}
.nav button:hover { background: var(--sidebar-hover); color: var(--sidebar-strong); }
.nav button.active {
  background: var(--sidebar-active);
  color: var(--sidebar-strong);
  border-left-color: var(--accent);
  font-weight: 600;
}

.sidebar-foot {
  margin-top: auto;
  padding: 16px 20px 0;
  font-size: 11px;
  color: #64748b;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/*
 * The content side of the shell, as a column: trail on top, page under it. .app is a flex row, so
 * without this the trail would sit beside the page rather than above it.
 *
 * min-width: 0 because a flex child defaults to min-content width, and one wide table would then
 * push the whole column past the viewport instead of scrolling inside its own container.
 */
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.main { flex: 1; padding: 8px 32px 60px; max-width: 1500px; overflow-x: hidden; }

/* Matches VFCi EMR: muted link, chevron, current page bold and not a link. */
.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 20px 32px 0;
  font-size: 13px;
  min-height: 20px;
}
.crumbs:empty { padding: 0; min-height: 0; }
.crumb-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}
.crumb-link:hover { color: var(--text); text-decoration: underline; }
.crumb-sep { width: 13px; height: 13px; color: var(--muted); flex-shrink: 0; }
.crumb-current { font-weight: 600; color: var(--text); }

/* The toggle is pinned top-right; keep the trail clear of it. */
@media (max-width: 720px) {
  .crumbs { padding: 12px 16px 0; }
}

.page-head { margin-bottom: 20px; }
.page-head h2 { margin: 0 0 3px; font-size: 21px; font-weight: 650; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }

/* ------------------------------- pieces ------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}
.card > h3 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card > h3 .sub { font-weight: 400; color: var(--muted); font-size: 12px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow);
}
.stat .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat .value { font-size: 25px; font-weight: 650; margin-top: 5px; letter-spacing: -0.5px; }
.stat .note { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.alert .value { color: var(--warn); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: 7px 10px;
  font-weight: 600;
  white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--raised); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-scroll { overflow-x: auto; }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad  { background: var(--bad-soft);  color: var(--bad); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.pill.grey { background: var(--raised); color: var(--muted); }

button.btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
button.btn:hover { background: var(--accent-hover); }
button.btn:disabled { opacity: 0.5; cursor: not-allowed; }
button.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
button.btn.secondary:hover { background: var(--raised); }

.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
input, select {
  font-family: inherit;
  font-size: 13px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  min-width: 150px;
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { padding: 26px; text-align: center; color: var(--muted); font-size: 13px; }

.banner {
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 12.5px;
  margin-bottom: 16px;
  border: 1px solid;
  display: flex;
  gap: 9px;
  align-items: flex-start;
}
.banner.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-text); }
.banner.info { background: var(--accent-soft); border-color: var(--info-line); color: var(--info-text); }
.banner.bad  { background: var(--bad-soft);  border-color: var(--bad-line); color: var(--bad-text); }
/* `display: flex` above outranks the user-agent rule for [hidden], so without
   this every "hidden" error banner renders as an empty coloured box. */
.banner[hidden] { display: none; }
.banner strong { font-weight: 650; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; }
  .nav { display: flex; flex-wrap: wrap; }
  .nav-group { display: contents; }
  .nav-group-label { display: none; }
  .nav button { width: auto; border-left: 0; border-bottom: 3px solid transparent; }
  .nav button.active { border-left: 0; border-bottom-color: var(--accent); }
  .main { padding: 18px; }
  .sidebar-foot { display: none; }
}

.bar { background: var(--raised); border-radius: 999px; height: 6px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar > i.good { background: var(--good); }
.bar > i.warn { background: var(--warn); }

details.assumption { margin-top: 6px; }
details.assumption summary { cursor: pointer; font-size: 12px; color: var(--muted); }
details.assumption div { padding: 8px 0 0 14px; font-size: 12px; color: var(--muted); }
details.assumption li { margin-bottom: 4px; }

.spinner { padding: 30px; text-align: center; color: var(--muted); font-size: 13px; }


/* ------------------------------ sign-in screen ----------------------------- */

.spinner.boot { padding: 80px 30px; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/*
 * Organisation on top, product under it - the same two lines on all four systems.
 *
 * The organisation is the larger of the two because it is the part that does not change between
 * them. Leading with the product name made each system look like separate software that happened
 * to be in the same building, and gave somebody signing into the fourth one nothing familiar to
 * land on. The product name still has to be there, or four identical screens become four screens
 * nobody can tell apart.
 */
.login-brand { text-align: center; margin-bottom: 14px; }
.login-brand h1 { margin: 0; font-size: 19px; letter-spacing: -0.01em; line-height: 1.25; }
/*
 * NOT uppercased. The company is "VFCi", with a lower-case i, and text-transform rendered it
 * "VFCI" - which is a different name. The EMR sets this line in its own case for the same reason.
 */
.login-brand span {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.login-card label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 10px;
}

.login-card input {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}

.login-card input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.login-card .btn { margin-top: 18px; width: 100%; justify-content: center; }

.login-card .banner { margin: 0 0 4px; }

.login-foot {
  margin: 16px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}
.login-foot code { font-size: 10.5px; background: var(--raised); padding: 1px 4px; border-radius: 4px; }

/* signed-in identity block in the sidebar */
.sidebar-foot .who { display: flex; flex-direction: column; margin-bottom: 8px; }
.sidebar-foot .who strong { font-size: 12.5px; color: var(--sidebar-strong); font-weight: 600; }
.sidebar-foot .who span { font-size: 11px; color: var(--sidebar-muted); }

button.linklike {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 11.5px;
  color: var(--sidebar-link);
  cursor: pointer;
  text-decoration: underline;
}
button.linklike:hover { color: var(--sidebar-link-hover); }

.sidebar-foot .build-note { margin-top: 12px; }

@media (max-width: 820px) {
  /* The identity block still matters on mobile even though the rest of the
     sidebar footer is hidden, so bring it back as a compact row. */
  .sidebar-foot { display: block; padding: 10px 18px; border-top: 0; }
  .sidebar-foot .build-note { display: none; }
  .sidebar-foot .who { flex-direction: row; gap: 8px; align-items: baseline; }
}

/* ------------------------------ file uploads ------------------------------ */

.upload-btn { margin-left: 8px; color: var(--accent); }
.upload-btn:hover { color: #1a5fd0; }

.upload-status { font-size: 11.5px; margin-left: 6px; }
.upload-status.good { color: var(--good); }
.upload-status.bad { color: var(--bad); }
.upload-status.muted { color: var(--muted); }

td a[download] { color: var(--accent); text-decoration: none; }
td a[download]:hover { text-decoration: underline; }

.small { font-size: 12px; }

/* -------------------------------- filters --------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.filters select {
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  min-width: 150px;
}

.filters .btn { padding: 7px 12px; }

/* ------------------------------ e-signature ------------------------------- */

.sign-doc {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 14px 0;
  padding: 14px;
  background: #f8f9fb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
@media (max-width: 720px) { .sign-doc { grid-template-columns: 1fr; } }

.sign-doc .label,
.field .label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}

.fingerprint {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--text);
  background: #eef0f3;
  padding: 5px 7px;
  border-radius: 6px;
  word-break: break-all;
}

.field { display: block; margin: 14px 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.field input[type="text"] {
  display: block;
  width: 100%;
  max-width: 340px;
  margin: 4px 0;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
}
.field input[type="text"]:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

#sign-pad {
  display: block;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
  max-width: 100%;
}

.agree {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin: 16px 0;
  padding: 12px;
  background: var(--accent-soft);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: #10457f;
  cursor: pointer;
}
.agree input { margin-top: 2px; flex-shrink: 0; }

.sign-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.cert {
  border: 1px solid var(--border);
  border-left: 3px solid var(--good);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}
.cert.bad { border-left-color: var(--bad); }

.cert-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.danger { color: var(--bad); font-weight: 600; }

.intent {
  margin: 10px 0;
  padding: 10px 12px;
  border-left: 2px solid var(--border);
  background: #f8f9fb;
  font-size: 12.5px;
  font-style: italic;
  color: var(--text);
}

.sig-image {
  display: block;
  max-width: 260px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  margin: 8px 0;
}

.cert-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  margin: 10px 0 6px;
  font-size: 12px;
}
.cert-grid dt { color: var(--muted); font-weight: 600; }
.cert-grid dd { margin: 0; color: var(--text); word-break: break-all; }

/* ---------------------------------- cctv ---------------------------------- */

.cctv-video {
  width: 100%;
  max-width: 720px;
  border-radius: var(--radius);
  background: #000;
  display: block;
}

.notice-text {
  background: #f8f9fb;
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text);
  overflow-x: auto;
}

td .pill.bad + .linklike { margin-left: 6px; }

/* --------------------------------- fleet ---------------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px 16px;
  margin: 14px 0;
}
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }

.form-grid .field { margin: 0; }
.form-grid input,
.form-grid select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 400;
  background: #fff;
  color: var(--text);
}
.form-grid input:focus,
.form-grid select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.banner.good { background: var(--good-soft); border-color: #bfe3cd; color: #14663d; }

td .pill + br + .muted { display: inline-block; margin-top: 3px; }

a.btn { text-decoration: none; display: inline-flex; align-items: center; }

/* ------------------------------ connection bar ---------------------------- */

.connection-bar {
  padding: 9px 18px;
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 50;
}

.connection-bar.offline {
  background: var(--warn-soft);
  color: #7a5200;
  border-bottom: 1px solid #f0d9a8;
}

.connection-bar.syncing {
  background: var(--accent-soft);
  color: #10457f;
  border-bottom: 1px solid #c5daf9;
}

/* ------------------------ standard of practice ------------------------ */

/* A heading and its action on one line, so "Add a procedure" sits with the
   thing it adds to rather than floating at the bottom of the card. */
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-head h3 { margin: 0; }

.sop-category {
  margin: 20px 0 8px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.sop-category:first-of-type { margin-top: 4px; }

/* Read progress. The count is inside the bar rather than beside it: "12/17"
   is the number HR acts on, and a bare percentage hides how many people that
   actually is. */
.sop-bar {
  position: relative;
  min-width: 84px;
  height: 20px;
  background: #eef0f3;
  border-radius: 10px;
  overflow: hidden;
}
.sop-bar-fill { position: absolute; inset: 0 auto 0 0; }
.sop-bar-fill.good { background: var(--good-soft); }
.sop-bar-fill.info { background: var(--accent-soft); }
.sop-bar-fill.bad  { background: var(--bad-soft); }
.sop-bar span {
  position: relative;
  display: block;
  text-align: center;
  line-height: 20px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
}

.checkgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 6px 14px;
  margin: 10px 0 16px;
}
@media (max-width: 620px) { .checkgrid { grid-template-columns: 1fr; } }

.check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
}
.check input { flex-shrink: 0; }

ul.plain { list-style: none; margin: 8px 0; padding: 0; font-size: 13px; }
ul.plain li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
ul.plain li:last-child { border-bottom: 0; }

/* A panel nested inside a card: same shape, no second shadow. */
.card.inner {
  box-shadow: none;
  background: var(--bg);
  margin: 14px 0;
}

/* Procedure text is written with deliberate line breaks and indentation —
   steps, sub-steps, warnings — so it is shown as typed, not reflowed. */
.sop-text-body {
  white-space: pre-wrap;
  font: inherit;
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
  max-height: 420px;
  overflow-y: auto;
}

.form-grid textarea,
.field textarea {
  display: block;
  width: 100%;
  margin: 4px 0;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  resize: vertical;
}
.field textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* A figure worth a second look inside a table cell — a debt that has grown
   past a month's salary, for instance. Not an error, so not .bad. */
.warn-text { color: var(--warn); font-weight: 600; }

/* A figure moving in the employee's favour, beside .warn-text for the other way. */
.good-text { color: var(--good); font-weight: 600; }


/* ------------------------------- theme switch ------------------------------- */

/*
 * A round icon button in the top right, which is where VFCi EMR puts it and therefore where
 * somebody who uses both will look for it first.
 *
 * Positioned against the main pane rather than placed in the flow, because this app has no top
 * bar to sit it in and adding one to hold a single control would cost a strip of every screen.
 * The pane scrolls; the button does not, so it is reachable without scrolling back up.
 */
.theme-toggle {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent-line); }
.theme-toggle svg { width: 16px; height: 16px; }

/* Clear of the button, so a long page title cannot run under it. */
.main > h2:first-child, .main .page-head { padding-right: 52px; }

@media (max-width: 720px) {
  .theme-toggle { top: 10px; right: 12px; width: 30px; height: 30px; }
}
