/* =============================================================================
   Pesaflex Middleware — design tokens v0.1
   Direction: calm industrial ops-console, warmed up. Deep evergreen chrome
   over warm paper; cobalt actions; Figtree UI / IBM Plex Mono (open-source,
   self-hostable for the offline/low-bandwidth constraint). Panels sit on a
   real 2-step elevation scale — flat-with-no-shadow read as unfinished.
   Status is never color-alone: every badge carries text + a dot glyph.

   The `pf-` class prefix namespaces this UI layer. (Built by Collate.)
   ========================================================================== */

:root {
  /* ---- Surfaces ---------------------------------------------------------- */
  --paper: #F5F4EF;            /* app body — warm off-white                  */
  --surface: #FFFFFF;          /* cards, tables                              */
  --surface-sunken: #EFEDE6;   /* wells, empty states, zebra rows            */
  --hairline: #E4E2D9;         /* default 1px border                         */
  --hairline-strong: #D2CFC3;  /* table header rule                          */

  /* ---- Ink (text) -------------------------------------------------------- */
  --ink: #1D2623;              /* primary text                               */
  --ink-2: #4C5651;            /* secondary text                            */
  --ink-3: #5F6A65;            /* placeholders, captions — 5.1:1 on paper,
                                  was #7C8580 (3.45:1), an AA failure at the
                                  11–12.5px sizes it is used at              */

  /* ---- Chrome (header / dark surfaces) ----------------------------------- */
  --chrome: #0F2C22;           /* deep evergreen                             */
  --chrome-2: #143527;         /* raised chrome (menus, wells)               */
  --chrome-raised: #1A3A2D;    /* hover wells on chrome                      */
  --chrome-fg: #F2F1E9;
  --chrome-fg-muted: rgba(242, 241, 233, 0.62);
  --chrome-hairline: rgba(242, 241, 233, 0.14);

  /* ---- Action (brand cobalt — also the "protected" family) ---------------- */
  --action: #1E5FBE;
  --action-hover: #174E9F;
  --action-tint: #E9F0FA;
  --action-ring: rgba(30, 95, 190, 0.28);

  /* ---- Device states (one per loan) --------------------------------------
     pending=grey · protected=cobalt · unlocked=green · released=violet ·
     unenrolled=amber · locked=crimson. AA: all fg ≥ 4.5:1 on their tint.    */
  --st-pending-bg: #ECEAE2;    --st-pending-fg: #50584F;   --st-pending-dot: #98A094;
  --st-protected-bg: #E6EFFB;  --st-protected-fg: #1A4C9C; --st-protected-dot: #2563C4;
  --st-unlocked-bg: #E1F1E6;   --st-unlocked-fg: #1B6437;  --st-unlocked-dot: #2E9254;
  --st-released-bg: #ECE8FA;   --st-released-fg: #5234A6;  --st-released-dot: #7456CC;
  --st-unenrolled-bg: #FAEED5; --st-unenrolled-fg: #855505; --st-unenrolled-dot: #D99A1B;
  --st-locked-bg: #FAE6E2;     --st-locked-fg: #9E2F1F;    --st-locked-dot: #C2402F;
  /* Lock armed but not yet fired (fires at 17:00) — amber, not crimson. */
  --st-scheduled-bg: #FBEBCE;  --st-scheduled-fg: #8A4B0A;  --st-scheduled-dot: #D97A16;

  /* ---- Action results (audit log) ----------------------------------------- */
  --rs-success-bg: #E1F1E6;    --rs-success-fg: #1B6437;   --rs-success-dot: #2E9254;
  --rs-failed-bg: #FAE6E2;     --rs-failed-fg: #9E2F1F;    --rs-failed-dot: #C2402F;
  --rs-skipped-bg: #ECEAE2;    --rs-skipped-fg: #50584F;   --rs-skipped-dot: #98A094;
  --rs-alerted-bg: #FAEED5;    --rs-alerted-fg: #855505;   --rs-alerted-dot: #D99A1B;

  /* ---- Alert / danger ----------------------------------------------------- */
  --danger: #BB3A28;
  --danger-tint: #FAE6E2;
  --warn: #B97E12;
  --warn-tint: #FAEED5;
  --ok: #237A44;
  --ok-tint: #E1F1E6;

  /* ---- Mode beacon -------------------------------------------------------- */
  --mode-live: #C03A2B;          /* solid crimson — real phones get locked   */
  --mode-live-fg: #FFFFFF;
  --mode-sim: #EBAE3A;           /* hazard amber                              */
  --mode-sim-fg: #231A05;
  --mode-sim-stripe: repeating-linear-gradient(135deg,
      #EBAE3A 0 8px, #C98F22 8px 16px);

  /* ---- Type --------------------------------------------------------------- */
  --font-ui: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --text-11: 0.6875rem; --text-12: 0.75rem;  --text-13: 0.8125rem;
  --text-14: 0.875rem;  --text-15: 0.9375rem; --text-16: 1rem;
  --text-18: 1.125rem;
  --text-22: 1.375rem;  --text-28: 1.75rem;  --text-36: 2.25rem;

  /* ---- Geometry ----------------------------------------------------------- */
  --r-card: 10px;
  --r-ctl: 6px;
  --r-badge: 4px;

  /* Elevation. Resting panels get --shadow-1; anything that lifts on hover
     or floats (menus, popovers) steps up. --shadow-card is kept as an alias
     of --shadow-1 so existing rules keep working.                          */
  --shadow-1: 0 1px 2px rgba(29, 38, 35, .06), 0 2px 6px rgba(29, 38, 35, .05);
  --shadow-2: 0 2px 4px rgba(29, 38, 35, .07), 0 6px 16px rgba(29, 38, 35, .08);
  --shadow-card: var(--shadow-1);
  --shadow-pop: 0 8px 24px rgba(29, 38, 35, 0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; }

/* ============================================================================
   Base helpers
   ========================================================================== */

body.pf-app {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-15);
  line-height: 1.55;
  min-height: 100vh;
}

.pf-mono { font-family: var(--font-mono); }
.pf-tab  { font-variant-numeric: tabular-nums; }

/* Inline icons (Lucide-style). Geometry lives in the #pf-icons sprite; stroke
   styling is applied here so a bare <use> renders correctly. */
.ic { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; flex: none; }

.pf-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-1);
}
/* Cards that are themselves a link/target lift a step on hover. */
.pf-card.is-link { transition: box-shadow 140ms ease, transform 140ms ease; }
/* When the card itself is the <a>, keep the card's own typography — the global
   `a { color: var(--action) }` would otherwise turn the big count blue+underlined. */
a.pf-card.is-link, a.pf-card.is-link:hover { color: inherit; text-decoration: none; }
.pf-card.is-link:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }

/* ---- Badges — squared tags, mono uppercase, dot + text (never color alone) */
.pf-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px 2px 7px;
  border-radius: var(--r-badge);
  font-family: var(--font-mono);
  font-size: var(--text-12);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.pf-badge .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex: none;
}
.pf-badge.st-pending    { background: var(--st-pending-bg);    color: var(--st-pending-fg); }
.pf-badge.st-pending    .dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--st-pending-dot); }
.pf-badge.st-protected  { background: var(--st-protected-bg);  color: var(--st-protected-fg); }
.pf-badge.st-protected  .dot { background: var(--st-protected-dot); }
.pf-badge.st-unlocked   { background: var(--st-unlocked-bg);   color: var(--st-unlocked-fg); }
.pf-badge.st-unlocked   .dot { background: var(--st-unlocked-dot); }
.pf-badge.st-released   { background: var(--st-released-bg);   color: var(--st-released-fg); }
.pf-badge.st-released   .dot { background: var(--st-released-dot); }
.pf-badge.st-unenrolled { background: var(--st-unenrolled-bg); color: var(--st-unenrolled-fg); }
.pf-badge.st-unenrolled .dot { background: var(--st-unenrolled-dot); }
.pf-badge.st-locked     { background: var(--st-locked-bg);     color: var(--st-locked-fg); }
.pf-badge.st-locked     .dot { background: var(--st-locked-dot); }
.pf-badge.st-lock_scheduled { background: var(--st-scheduled-bg); color: var(--st-scheduled-fg); }
.pf-badge.st-lock_scheduled .dot { background: var(--st-scheduled-dot); }

.pf-badge.rs-success { background: var(--rs-success-bg); color: var(--rs-success-fg); }
.pf-badge.rs-success .dot { background: var(--rs-success-dot); }
.pf-badge.rs-failed  { background: var(--rs-failed-bg);  color: var(--rs-failed-fg); }
.pf-badge.rs-failed  .dot { background: var(--rs-failed-dot); }
.pf-badge.rs-skipped { background: var(--rs-skipped-bg); color: var(--rs-skipped-fg); }
.pf-badge.rs-skipped .dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--rs-skipped-dot); }
.pf-badge.rs-alerted { background: var(--rs-alerted-bg); color: var(--rs-alerted-fg); }
.pf-badge.rs-alerted .dot { background: var(--rs-alerted-dot); }

/* ---- Mode chips ----------------------------------------------------------- */
.pf-mode {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 25px;
  padding: 0 10px;
  border-radius: var(--r-badge);
  font-family: var(--font-mono);
  font-size: var(--text-12);
  font-weight: 600;
  letter-spacing: 0.1em;
}
.pf-mode.live { background: var(--mode-live); color: var(--mode-live-fg); }
.pf-mode.live .pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: #FFD9D2;
  animation: pf-pulse 1.6s ease-in-out infinite;
}
.pf-mode.sim { background: var(--mode-sim); color: var(--mode-sim-fg); }
.pf-mode.sim .pulse {
  width: 7px; height: 7px; border-radius: 1px;
  background: var(--mode-sim-fg);
}
@keyframes pf-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}
@media (prefers-reduced-motion: reduce) {
  .pf-mode.live .pulse { animation: none; }
  .pf-card.is-link { transition: none; }
  .pf-card.is-link:hover { transform: none; }
}

/* Keyline — full-width strip under the header.
   .pf-keyline is the standing one: production is now the only real mode, so
   the strip is brand evergreen, not an alarm. .pf-keyline-sim stays loud —
   simulated mode must never be mistaken for the real thing.
   .pf-keyline-live is the old crimson alarm, kept only until the templates
   finish migrating to .pf-keyline; it now renders identically to it.        */
.pf-keyline      { height: 3px; background: var(--chrome); }
.pf-keyline-live { height: 3px; background: var(--chrome); }
.pf-keyline-sim  { height: 5px; background: var(--mode-sim-stripe); }

/* ---- Buttons --------------------------------------------------------------- */
.pf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-ctl);
  border: 1px solid transparent;
  font-family: var(--font-ui);
  font-size: var(--text-13);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.pf-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--action-ring); }
.pf-btn.primary { background: var(--action); color: #fff; }
.pf-btn.primary:hover { background: var(--action-hover); }
.pf-btn.outline { background: var(--surface); color: var(--ink); border-color: var(--hairline-strong); }
.pf-btn.outline:hover { background: var(--surface-sunken); }
.pf-btn.ghost { background: transparent; color: var(--ink-2); }
.pf-btn.ghost:hover { background: var(--surface-sunken); color: var(--ink); }
.pf-btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.pf-btn.danger:hover { filter: brightness(1.06); }
.pf-btn.sm { height: 28px; padding: 0 10px; font-size: var(--text-12); }

/* ---- Inputs ----------------------------------------------------------------- */
.pf-input {
  height: 34px;
  width: 100%;
  padding: 0 11px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  font-family: var(--font-ui);
  font-size: var(--text-13);
  color: var(--ink);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.pf-input::placeholder { color: var(--ink-3); }
.pf-input:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px var(--action-ring); }
.pf-input.sm { height: 32px; }
.pf-input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(187,58,40,.15); }

/* ---- Tables ------------------------------------------------------------------ */
.pf-table { width: 100%; border-collapse: collapse; font-size: var(--text-13); }
.pf-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: var(--text-12);
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline-strong);
}
.pf-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}
.pf-table tr:last-child td { border-bottom: none; }
.pf-table tbody tr { transition: background-color 100ms ease; }
.pf-table.hoverable tbody tr:hover { background: #FAFAF6; }
.pf-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.pf-rowlink { cursor: pointer; }

/* ---- Section heading style used inside cards ---------------------------------- */
.pf-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--hairline);
}
.pf-card-title { font-size: var(--text-15); font-weight: 600; display: flex; align-items: center; gap: 9px; }

.pf-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-12);
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ============================================================================
   APP LAYOUT LAYER — classes the Django templates compose with. These mirror
   the inline-styled boards from the design canvas, lifted into reusable CSS.
   ========================================================================== */

a { color: var(--action); }

/* ---- Top chrome / nav ----------------------------------------------------- */
.pf-header {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: var(--chrome);
  color: var(--chrome-fg);
}
.pf-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.pf-brand .name { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; color: var(--chrome-fg); }
.pf-brand .div  { width: 1px; height: 14px; background: var(--chrome-hairline); }
.pf-brand .mod  { font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--chrome-fg-muted); }

.pf-nav { margin-left: 14px; display: flex; align-items: center; gap: 2px; }
.pf-nav a {
  height: 30px; display: inline-flex; align-items: center; padding: 0 11px;
  border-radius: 6px; font-size: 13px; text-decoration: none; font-weight: 400;
  color: var(--chrome-fg-muted); background: transparent;
}
.pf-nav a:hover { color: var(--chrome-fg); background: var(--chrome-raised); }
.pf-nav a.active {
  font-weight: 600; color: var(--chrome-fg); background: var(--chrome-raised);
  box-shadow: inset 0 -2px 0 rgba(242,241,233,.35);
}

.pf-header-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.pf-clock { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12px; color: var(--chrome-fg-muted); }
.pf-clock .utc { opacity: .55; }

/* User menu (no-JS <details> dropdown) */
.pf-user { position: relative; }
.pf-user > summary {
  list-style: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; height: 32px;
  padding: 0 10px; border-radius: 6px; background: rgba(242,241,233,.08);
  border: 1px solid var(--chrome-hairline); font-size: 13px; color: var(--chrome-fg);
}
.pf-user > summary::-webkit-details-marker { display: none; }
.pf-user .avatar {
  width: 22px; height: 22px; border-radius: 50%; background: #2E6B52;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
}
.pf-user .menu {
  position: absolute; right: 0; top: 38px; min-width: 168px; z-index: 30;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 8px; box-shadow: var(--shadow-pop); padding: 6px; display: flex; flex-direction: column;
}
.pf-user .menu a, .pf-user .menu button {
  text-align: left; background: none; border: 0; width: 100%;
  font: inherit; font-size: 13px; color: var(--ink); padding: 8px 10px;
  border-radius: 6px; cursor: pointer; text-decoration: none;
}
.pf-user .menu a:hover, .pf-user .menu button:hover { background: var(--surface-sunken); }

/* ---- Page frame ----------------------------------------------------------- */
.pf-main { padding: 24px 26px 44px; display: flex; flex-direction: column; gap: 18px; max-width: 1320px; margin: 0 auto; }
.pf-pagetitle { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pf-pagetitle h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.pf-pagetitle p { margin: 4px 0 0; font-size: var(--text-13); color: var(--ink-2); }
.pf-pagetitle .actions { display: flex; gap: 8px; }

.pf-breadcrumb { display: flex; align-items: center; gap: 7px; font-size: var(--text-12); color: var(--ink-3); flex-wrap: wrap; }
.pf-breadcrumb a { color: var(--action); text-decoration: none; }
.pf-breadcrumb .sep { color: var(--ink-3); }
.pf-breadcrumb .here { color: var(--ink-2); font-weight: 600; }

/* ---- Flash / outcome messages -------------------------------------------- */
.pf-flash { display: flex; flex-direction: column; gap: 9px; }
.pf-flash .msg {
  display: flex; align-items: center; gap: 11px; padding: 11px 15px;
  border-radius: 8px; font-size: 13px; border: 1px solid; border-left-width: 4px;
}
.pf-flash .msg .ico { display: inline-flex; flex: none; }
.pf-flash .msg.success { background: var(--ok-tint); border-color: var(--ok); color: var(--ink); }
.pf-flash .msg.success .ico { color: var(--ok); }
.pf-flash .msg.warning { background: var(--warn-tint); border-color: var(--warn); color: var(--ink); }
.pf-flash .msg.warning .ico { color: var(--warn); }
.pf-flash .msg.error   { background: var(--danger-tint); border-color: var(--danger); color: var(--ink); }
.pf-flash .msg.error .ico   { color: var(--danger); }
.pf-flash .msg.info    { background: var(--surface-sunken); border-color: var(--hairline-strong); color: var(--ink); }
.pf-flash .msg.info .ico    { color: var(--ink-3); }

/* ---- State / count cards -------------------------------------------------- */
/* auto-fit, not a fixed column count: the tile count varies (a synthetic
   "Lock scheduled" tile appears alongside the six states) and a hard repeat(6)
   orphaned the seventh alone on row two. */
.pf-statecards { display: grid; grid-template-columns: repeat(auto-fit, minmax(152px, 1fr)); gap: 12px; }
.pf-statecards.five { grid-template-columns: repeat(auto-fit, minmax(152px, 1fr)); }
.pf-statecard { padding: 16px 18px; }
.pf-statecard.hot { background: var(--st-unenrolled-bg); border-color: var(--st-unenrolled-dot); }
.pf-statecard .n { font-variant-numeric: tabular-nums; font-size: 28px; font-weight: 700; margin-top: 8px; line-height: 1.1; }
.pf-statecard .cap { font-size: var(--text-13); color: var(--ink-2); margin-top: 5px; }

/* ---- Verdict banner ------------------------------------------------------- */
.pf-verdict { border-radius: var(--r-card); border: 1px solid; padding: 20px 24px; display: flex; align-items: center; gap: 18px; }
.pf-verdict .icon { width: 46px; height: 46px; border-radius: 50%; flex: none; color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.pf-verdict .big { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.pf-verdict .sub { font-size: 13px; margin-top: 4px; }
.pf-verdict .chips { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.pf-verdict .chips span {
  font-family: var(--font-mono); font-size: var(--text-12); font-weight: 600;
  padding: 3px 9px; border-radius: 4px; background: rgba(255,255,255,.65);
}
.pf-verdict.bad { border-color: var(--st-unenrolled-dot); background: var(--warn-tint); }
.pf-verdict.bad .icon { background: var(--st-unenrolled-dot); }
.pf-verdict.bad .big, .pf-verdict.bad .sub { color: #5C3D03; }
.pf-verdict.bad .chips span { border: 1px solid var(--st-unenrolled-dot); color: #5C3D03; }
.pf-verdict.ok { border-color: var(--st-unlocked-dot); background: var(--ok-tint); }
.pf-verdict.ok .icon { background: var(--ok); }
.pf-verdict.ok .big { color: #14502C; }
.pf-verdict.ok .sub { color: #2A5E3E; }
.pf-verdict .spacer { flex: 1; }

/* ---- Card count pill + header action ------------------------------------- */
.pf-count {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: 99px; background: var(--surface-sunken); color: var(--ink-2);
}
.pf-count.warn { background: var(--warn-tint); color: var(--rs-alerted-fg); }
.pf-card-action { font-size: 12.5px; color: var(--action); font-weight: 600; cursor: pointer; text-decoration: none; }

/* ---- Attention table cells ----------------------------------------------- */
.pf-attn-reason { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.pf-attn-reason .ico.failed { color: var(--danger); }
.pf-attn-reason .ico.alerted { color: var(--warn); }
.pf-attn-fix { font-size: var(--text-13); color: var(--ink-2); margin-top: 2px; }
.pf-retry { font-family: var(--font-mono); font-size: var(--text-12); color: var(--ink-2); display: inline-flex; gap: 5px; align-items: center; }

.pf-retrynote {
  display: flex; align-items: center; gap: 8px; padding: 9px 16px;
  border-top: 1px solid var(--hairline); background: var(--surface-sunken);
  border-radius: 0 0 var(--r-card) var(--r-card); font-size: 12.5px; color: var(--ink-2);
}

/* ---- Empty / centered states --------------------------------------------- */
.pf-empty { padding: 34px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.pf-empty .glyph {
  width: 46px; height: 46px; border-radius: 12px; background: var(--surface-sunken);
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-3);
}
.pf-empty .glyph.ok { width: 40px; height: 40px; border-radius: 50%; background: var(--ok-tint); color: var(--ok); }
.pf-empty .glyph.bad { background: var(--danger-tint); color: var(--danger); }
.pf-empty .title { font-weight: 700; font-size: 15px; margin-top: 12px; }
.pf-empty .body { font-size: var(--text-13); color: var(--ink-2); margin: 5px 0 14px; max-width: 360px; }

/* ---- Toolbar / search / filter chips ------------------------------------- */
.pf-toolbar { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.pf-toolbar-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pf-search { position: relative; flex: 1; max-width: 420px; }
.pf-search .ico { position: absolute; left: 11px; top: 9px; color: var(--ink-3); }
.pf-search .pf-input { padding-left: 33px; }
.pf-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pf-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  border-radius: 6px; font-size: 12.5px; font-weight: 600; cursor: pointer; text-decoration: none;
  border: 1px solid var(--hairline-strong); background: var(--surface); color: var(--ink-2);
}
.pf-chip.active { border-color: var(--action); background: var(--action-tint); color: var(--action); }
.pf-chip .c { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 11px; padding: 0 5px; border-radius: 99px; background: var(--surface-sunken); color: var(--ink-3); }
.pf-chip.active .c { background: var(--action); color: #fff; }
.pf-vrule { width: 1px; height: 20px; background: var(--hairline); margin: 0 2px; }
.pf-selectish { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border: 1px solid var(--hairline-strong); border-radius: 6px; font-size: 12.5px; background: var(--surface); }

/* ---- Pagination footer ---------------------------------------------------- */
.pf-tablefoot { display: flex; align-items: center; justify-content: space-between; padding: 11px 16px; border-top: 1px solid var(--hairline); background: var(--surface-sunken); }
.pf-tablefoot .count { font-size: 12.5px; color: var(--ink-2); }
.pf-pager { display: flex; gap: 6px; }
.pf-pager a, .pf-pager span {
  min-width: 30px; height: 30px; padding: 0 9px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; font-size: 12.5px; text-decoration: none; border: 1px solid var(--hairline-strong);
  background: var(--surface); color: var(--ink-2); font-weight: 500;
}
.pf-pager .current { border-color: var(--action); background: var(--action); color: #fff; font-weight: 700; }
.pf-pager .disabled { opacity: .4; pointer-events: none; }

/* ---- Detail: identity header + fix callout + timeline --------------------- */
.pf-fields { display: grid; gap: 14px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--hairline); }
.pf-fields .k { font-size: var(--text-11); }
.pf-fields .v { font-size: 13px; margin-top: 3px; }
.pf-fields .v.mono { font-family: var(--font-mono); font-size: 12px; }

.pf-callout { border: 1px solid var(--st-unenrolled-dot); border-radius: var(--r-card); background: var(--st-unenrolled-bg); overflow: hidden; }
.pf-callout.danger { border-color: var(--danger); background: var(--danger-tint); }
.pf-callout .row { display: flex; gap: 13px; padding: 15px 18px; }
.pf-callout .glyph { width: 36px; height: 36px; flex: none; border-radius: 8px; background: var(--st-unenrolled-dot); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.pf-callout.danger .glyph { background: var(--danger); }
.pf-callout .t { font-size: 14.5px; font-weight: 700; color: #5C3D03; }
.pf-callout.danger .t, .pf-callout.danger p { color: #6E1D12; }
.pf-callout p { margin: 5px 0 0; font-size: 13px; line-height: 1.55; color: #5C3D03; }
.pf-callout .pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: #5C3D03; background: rgba(255,255,255,.6); padding: 4px 9px; border-radius: 5px; }

.pf-timeline { padding: 16px 20px 8px; }
.pf-tl-row { display: flex; gap: 14px; }
.pf-tl-gutter { display: flex; flex-direction: column; align-items: center; width: 14px; flex: none; }
.pf-tl-dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--surface); margin-top: 3px; }
.pf-tl-dot.success { background: var(--rs-success-dot); box-shadow: 0 0 0 1px var(--rs-success-dot); }
.pf-tl-dot.failed  { background: var(--rs-failed-dot);  box-shadow: 0 0 0 1px var(--rs-failed-dot); }
.pf-tl-dot.skipped { background: var(--rs-skipped-dot); box-shadow: 0 0 0 1px var(--rs-skipped-dot); }
.pf-tl-dot.alerted { background: var(--rs-alerted-dot); box-shadow: 0 0 0 1px var(--rs-alerted-dot); }
.pf-tl-line { width: 2px; flex: 1; background: var(--hairline); margin: 4px 0; }
.pf-tl-body { flex: 1; padding-bottom: 18px; }
.pf-tl-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pf-tl-head .act { font-size: 13.5px; font-weight: 600; }
.pf-tl-body p { margin: 5px 0 6px; font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }
.pf-tl-meta { display: flex; gap: 14px; font-size: var(--text-12); color: var(--ink-3); font-family: var(--font-mono); flex-wrap: wrap; }
.pf-tl-meta .err { color: var(--danger); }

/* ---- System / health rows ------------------------------------------------- */
.pf-modebanner { padding: 0; overflow: hidden; }
.pf-modebanner .bar { display: flex; align-items: center; gap: 14px; padding: 16px 20px; color: #fff; }
.pf-modebanner.live { border-color: var(--mode-live); }
.pf-modebanner.live .bar { background: var(--mode-live); }
.pf-modebanner.sim { border-color: var(--mode-sim); }
.pf-modebanner.sim .bar { background: var(--mode-sim); color: var(--mode-sim-fg); }
.pf-modebanner .ttl { font-size: 15px; font-weight: 700; letter-spacing: .02em; }
.pf-modebanner .det { font-size: 12.5px; opacity: .92; }

.pf-health { display: flex; align-items: center; gap: 13px; padding: 13px 0; border-bottom: 1px solid var(--hairline); }
.pf-health:last-child { border-bottom: none; }
.pf-health .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.pf-health .lbl { font-size: 13.5px; font-weight: 600; }
.pf-health .det { font-size: 12px; color: var(--ink-2); margin-top: 1px; }
.pf-health .stat { font-size: 11px; font-weight: 700; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .05em; padding: 3px 9px; border-radius: 4px; }
.pf-health.ok   .dot { background: var(--ok); }
.pf-health.ok   .stat { color: var(--ok); background: var(--ok-tint); }
.pf-health.warn .dot { background: var(--warn); }
.pf-health.warn .stat { color: var(--warn); background: var(--warn-tint); }
.pf-health.bad  .dot { background: var(--danger); }
.pf-health.bad  .stat { color: var(--danger); background: var(--danger-tint); }

/* ---- Grid helpers --------------------------------------------------------- */
.pf-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.pf-stack { display: flex; flex-direction: column; gap: 18px; }
.pf-stack-sm { display: flex; flex-direction: column; gap: 10px; }
.pf-muted-note { font-size: var(--text-12); color: var(--ink-3); text-align: center; }

/* ---- Simulation control room --------------------------------------------- */
.pf-sim-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 2px 2px 0; }
.pf-sim-cols .pf-eyebrow { display: flex; align-items: center; gap: 7px; }
.pf-sim-loan { overflow: hidden; }
.pf-sim-split { display: grid; grid-template-columns: 1fr 1fr; }
.pf-sim-vendor { padding: 14px 16px; border-right: 1px solid var(--hairline); }
.pf-sim-device { padding: 14px 16px; background: var(--surface-sunken); }
.pf-sim-stat { display: flex; gap: 18px; margin-top: 10px; flex-wrap: wrap; }
.pf-sim-stat .k { font-size: var(--text-11); }
.pf-sim-actions { display: flex; gap: 7px; margin-top: 13px; flex-wrap: wrap; align-items: flex-end; }
.pf-sim-actions form { display: inline-flex; gap: 5px; align-items: center; margin: 0; }
.pf-sim-actions .pf-input { width: 84px; }
.pf-formgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pf-formgrid label { font-size: var(--text-12); font-weight: 600; color: var(--ink-2); display: block; margin-bottom: 5px; }
.pf-seg { display: flex; gap: 6px; height: 32px; }
.pf-seg label { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 6px; font-size: 12.5px; font-weight: 600; cursor: pointer; border: 1px solid var(--hairline-strong); background: var(--surface); color: var(--ink-2); margin: 0; }
.pf-seg input { position: absolute; opacity: 0; pointer-events: none; }
.pf-seg label:has(input:checked) { border-color: var(--action); background: var(--action-tint); color: var(--action); }

/* ---- Login ---------------------------------------------------------------- */
.pf-login { min-height: 100vh; display: flex; flex-direction: column; }
.pf-login-grid { flex: 1; display: grid; grid-template-columns: 1.05fr 0.95fr; background: var(--paper); }
.pf-login-brand { background: linear-gradient(160deg, #0F2C22 0%, #143527 60%, #16382A 100%); color: var(--chrome-fg); padding: 44px 48px; display: flex; flex-direction: column; justify-content: space-between; }
.pf-login-brand h2 { margin: 12px 0 14px; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; max-width: 380px; }
.pf-login-brand p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--chrome-fg-muted); max-width: 400px; }
.pf-login-features { display: flex; gap: 22px; margin-top: 26px; flex-wrap: wrap; }
.pf-login-features div { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--chrome-fg-muted); }
.pf-login-foot { font-size: var(--text-12); color: var(--chrome-fg-muted); }
.pf-login-form { display: flex; align-items: center; justify-content: center; padding: 40px; }
.pf-login-form .inner { width: 360px; max-width: 100%; }
.pf-login-head { display: flex; justify-content: space-between; align-items: center; }
.pf-login-form h1 { margin: 0; font-size: 22px; font-weight: 700; }
.pf-login-form .lede { margin: 6px 0 24px; font-size: 13.5px; color: var(--ink-2); }
.pf-login-form label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: block; }
.pf-login-form .pf-input { height: 38px; margin: 6px 0 16px; }
.pf-login-warn { margin-top: 22px; padding: 11px 13px; border-radius: 8px; background: var(--mode-live); color: #fff; display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; line-height: 1.45; }
.pf-login-err { background: var(--danger-tint); border: 1px solid var(--danger); color: var(--ink); border-radius: 8px; padding: 10px 13px; font-size: 12.5px; margin-bottom: 16px; }

/* ---- Footer --------------------------------------------------------------- */
.pf-footer { text-align: center; padding: 20px; font-size: var(--text-12); color: var(--ink-3); }
.pf-footer a { color: var(--ink-2); }

@media (max-width: 760px) {
  .pf-login-grid { grid-template-columns: 1fr; }
  .pf-login-brand { display: none; }
  .pf-statecards, .pf-statecards.five { grid-template-columns: repeat(2, 1fr); }
  .pf-grid-2, .pf-sim-split, .pf-sim-cols, .pf-formgrid { grid-template-columns: 1fr; }
  .pf-sim-vendor { border-right: none; border-bottom: 1px solid var(--hairline); }
  .pf-nav { display: none; }
}

/* ============================================================================
   UTILITIES — the small set of things templates kept re-inventing inline.
   ========================================================================== */

.pf-meta { font-size: var(--text-12); color: var(--ink-3); }
/* Tables are wider than a phone; scroll the table, not the page. */
.pf-tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* Headline figure (counts, totals). */
.pf-num { font-size: var(--text-28); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
/* Dual CAT/UTC stamps otherwise wrap to three lines in a table cell. */
.pf-timestamp { white-space: nowrap; }

/* Quiet inline disclosure ("Show all 14 backups") — a native <details> with
   the summary styled as a text link. No JS, keyboard-operable for free.     */
.pf-expander > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-13);
  font-weight: 600;
  color: var(--action);
  border-radius: var(--r-ctl);
  padding: 2px 4px;
  margin: 0 -4px;
}
.pf-expander > summary::-webkit-details-marker { display: none; }
.pf-expander > summary::marker { content: ""; }
.pf-expander > summary:hover { color: var(--action-hover); text-decoration: underline; }
.pf-expander > summary:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
/* Caret drawn in CSS so no icon sprite is needed. */
.pf-expander > summary::after {
  content: "";
  width: 6px; height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}
.pf-expander[open] > summary::after { transform: translateY(1px) rotate(-135deg); }
.pf-expander[open] > summary { margin-bottom: 10px; }

/* ---- Accessibility: skip link + visible keyboard focus ------------------- */
.pf-skip { position: absolute; left: 8px; top: -48px; z-index: 100; background: var(--chrome); color: var(--chrome-fg); padding: 8px 14px; border-radius: 6px; font-size: 13px; transition: top 120ms ease; }
.pf-skip:focus { top: 8px; }
a:focus-visible, button:focus-visible, summary:focus-visible,
.pf-nav a:focus-visible, .pf-chip:focus-visible, .pf-card-action:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
.pf-rowlink { cursor: pointer; }
/* Keyboard access to row targets is via the loan-id <a> inside the row
   (covered by the a:focus-visible rule above); a <tr> can't take focus. */

/* ---- Mobile: make the top nav usable on a phone (it was hidden) ---------- */
@media (max-width: 760px) {
  .pf-header { flex-wrap: wrap; height: auto; padding: 8px 12px; row-gap: 8px; }
  .pf-nav { display: flex; order: 3; width: 100%; margin-left: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .pf-nav a { flex: none; }
  .pf-header-right .pf-clock { display: none; }
  .pf-main { padding: 16px 14px 32px; }
}
