:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #20242e;
  --border: #2b303b;
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --ok: #2faa6b;
  --warn: #d9a13a;
  --bad: #e0594f;
  --manual: #8b6fd6;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }

/* External deep-link icon (open device in a backend console). */
.ext-link {
  color: var(--accent); text-decoration: none;
  display: inline-flex; align-items: center; padding: 0 3px;
  vertical-align: middle; opacity: .85;
}
.ext-link:hover { opacity: 1; text-decoration: none; }
.ext-link svg { display: block; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 54px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); }
.topbar nav { display: flex; gap: 18px; flex: 1; }
.topbar nav a { color: var(--muted); }
.topbar nav a.active, .topbar nav a:hover { color: var(--text); text-decoration: none; }
.topbar .user { display: flex; align-items: center; gap: 10px; color: var(--muted); }

.content { max-width: 1040px; margin: 0 auto; padding: 28px 20px 60px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 28px 0 10px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 18px; }
.flash.error { background: rgba(224,89,79,.15); border: 1px solid var(--bad); }
.flash.ok { background: rgba(47,170,107,.15); border: 1px solid var(--ok); }
.flash.warn { background: rgba(217,161,58,.15); border: 1px solid var(--warn); }
.flash.warn ul { margin: 6px 0 0; padding-left: 20px; }
.flash.warn li { margin: 2px 0; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--panel-2); }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin-bottom: 18px; }
.warn-card { border-color: var(--warn); background: rgba(217,161,58,.08); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.stat .n { font-size: 28px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; }

form label { display: block; margin: 12px 0; color: var(--muted); font-size: 14px; }
input, select { width: 100%; padding: 9px 11px; margin-top: 6px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { margin: 0; flex: 1; min-width: 140px; }

button { cursor: pointer; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font-size: 14px; white-space: nowrap; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.ghost { background: transparent; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { display: inline; }
/* The job-header status pill (Blocked / Failed / Completed) sits next to the
   "Run automated steps" button — size it to match so the text stays centered
   and the pill lines up with the button rather than stretching off-center. */
#job-status { padding: 9px 16px; font-size: 14px; border: 1px solid transparent; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; text-transform: capitalize; }
.badge.pending { background: rgba(154,163,178,.2); color: var(--muted); }
.badge.running { background: rgba(79,140,255,.2); color: var(--accent); }
.badge.success, .badge.completed { background: rgba(47,170,107,.2); color: var(--ok); }
.badge.failed { background: rgba(224,89,79,.2); color: var(--bad); }
/* Skipped: a dashed outline (not a solid pill) so it reads as "won't run",
   visually distinct from the solid grey ``pending`` pill it used to mimic. */
.badge.skipped { background: transparent; color: var(--muted); border: 1px dashed var(--muted); padding: 1px 8px; }
.badge.superseded { background: transparent; color: var(--muted); border: 1px solid var(--muted); text-decoration: line-through; }
.badge.manual, .badge.blocked { background: rgba(139,111,214,.22); color: var(--manual); }
.badge.mode-retire { background: rgba(224,89,79,.18); color: var(--bad); }
.badge.mode-release { background: rgba(79,140,255,.2); color: var(--accent); }
/* Bare/neutral badges + badge-styled links (Related cleanup page, clients link). */
.badge.neutral, a.badge { background: rgba(154,163,178,.18); color: var(--muted); text-decoration: none; }
/* The "N Dismissed" rollup pill is a button (a cross-cutting view toggle sitting among
   the neutral state-count pills) — strip native chrome, give it an amber "set aside"
   look, and a filled state while the view is active. */
button.badge { border: none; cursor: pointer; font-family: inherit; }
.badge.dismissed-pill { background: rgba(217,161,58,.2); color: var(--warn); text-transform: none; }
.badge.dismissed-pill:hover { filter: brightness(1.12); }
.badge.dismissed-pill.active { background: var(--warn); color: #1a1205; }
/* State-count pills are clickable filters (click to scope the table to that lifecycle
   state); highlight on hover and fill when the filter is active. */
.badge.state-pill:hover { filter: brightness(1.12); }
.badge.state-pill.active { background: var(--accent); color: #fff; }
a.badge:hover { color: var(--accent); }
.badges { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
/* Related-cleanup filter bar: label/select/checkbox/search in one aligned row,
   export pushed to the right. Override the global full-width input/select/label
   rules so nothing stretches (the checkbox especially) or stacks. */
.filter-bar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin: .6rem 0; }
.filter-bar label { display: inline-flex; align-items: center; gap: .4rem; margin: 0; color: var(--text); }
.filter-bar select { width: auto; margin: 0; }
.filter-bar input[type="search"] { width: auto; min-width: 16rem; margin: 0; }
.filter-bar input[type="checkbox"] { width: auto; margin: 0; }
.filter-bar #tr-export { margin-left: auto; }
/* Row/select-all checkboxes must not inherit the global full-width input rule. */
#tr-table input[type="checkbox"] { width: auto; margin: 0; }

/* Coverage column: each service rendered as a colored pill — blue when enrolled,
   red when absent, yellow for partial ABM (in ABM but unassigned). */
.cov-cell { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.cov-cell a { text-decoration: none; }
.cov { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.cov.on { background: rgba(79,140,255,.2); color: var(--accent); }
.cov.off { background: rgba(224,89,79,.2); color: var(--bad); }
.cov.partial { background: rgba(217,161,58,.2); color: var(--warn); }
/* The ABM pill is a <button> (opens the portal root + copies the serial, since ABM has
   no per-device deep link) — strip the native button chrome so it still reads as a pill. */
button.cov { border: none; cursor: pointer; font-family: inherit; line-height: 1.2; }
button.cov:hover { filter: brightness(1.15); }
/* The coverage "gap" is a row-level annotation, not a 4th service — so it reads
   as an outlined amber chip, distinct from the solid enrolled/absent pills. */
.cov-gap { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
  color: var(--warn); border: 1px solid var(--warn); background: transparent; }

/* Silent agent (reporting gap) — a device enrolled in a platform whose agent has gone
   dark. Distinct look from the (coverage) gap pill so the two aren't confused. */
.cov-silent { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
  color: var(--bad); border: 1px solid var(--bad); background: transparent; }

.kind { font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }

button.sm { padding: 4px 10px; font-size: 12px; }
/* Manifest deep link (atm://) in the Serial cell — revealed on row hover / keyboard focus
   so it never clutters the dense listing at rest. */
.serial-cell .mf-link { opacity: 0; text-decoration: none; margin-left: 2px; transition: opacity .1s; }
tr:hover .serial-cell .mf-link, .serial-cell .mf-link:focus { opacity: 1; }
/* Always-visible manifest link on the less-dense pages (device card, job page, provision
   confirm) — small, muted, no underline. */
.manifest-link { font-size: 12px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.manifest-link:hover { color: var(--accent); }
/* Anchor styled as a small button (e.g. the /fleet row Provision action) so it reads
   as an action, not an inline link. `.provision` is green to distinguish it from the
   blue (accent) Offboard button. */
a.btn { display: inline-block; padding: 4px 10px; font-size: 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  text-decoration: none; white-space: nowrap; }
a.btn:hover { border-color: var(--accent); }
a.btn.provision { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
a.btn.provision:hover { filter: brightness(1.08); }
.hint { font-size: 12px; margin: 8px 0 0; }

/* Clients overview: per-row hide/un-hide action + the hidden-clients disclosure. */
td.row-actions { text-align: right; white-space: nowrap; }
td.row-actions form { display: inline; margin: 0; }
details.hidden-clients { margin-top: 22px; }
details.hidden-clients > summary { cursor: pointer; color: var(--muted); padding: 6px 0; user-select: none; }
details.hidden-clients > summary:hover { color: var(--text); }
details.hidden-clients[open] > summary { margin-bottom: 6px; }

.selcol { width: 1%; text-align: center; padding-right: 0; }
.bulk-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px;
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--panel-2); border: 1px solid var(--accent); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.4); z-index: 50; }
.bulk-bar[hidden] { display: none; }
.bulk-count { font-size: 13px; }

.checklist-step { margin: 8px 0; }
.checklist-serials { font-size: 13px; margin-top: 3px; }

/* Live "still working" cues for a running batch. */
@keyframes ec-pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.badge.running { animation: ec-pulse 1.2s ease-in-out infinite; }
.spinner { display: inline-block; width: 9px; height: 9px; margin-right: 7px;
  border-radius: 50%; background: var(--accent); vertical-align: middle;
  animation: ec-pulse 1s ease-in-out infinite; }

/* The job/device currently being processed in a background run. */
tr.row-active > td { background: rgba(79,140,255,.1); }
tr.row-active > td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.enr { display: inline-block; font-size: 13px; font-weight: 600; white-space: nowrap; }
.enr.enr-yes { color: var(--warn); }   /* present = still consuming a paid seat */
.enr.enr-no { color: var(--ok); }      /* absent = already clean */
.enr.enr-na { color: var(--muted); }   /* no org / unknown — not a definite answer */

pre { background: #0b0d11; border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 13px; }
.diff .add { color: var(--ok); }
.diff .del { color: var(--bad); }
.err { color: var(--bad); }
.task-row td { vertical-align: top; }
/* A step that won't run is de-emphasized so the actionable steps pop. The
   detail toggle (errors) stays legible on the rare skipped-with-result row. */
.task-row.task-skipped td { opacity: .45; }
.task-row.task-skipped td .detail-toggle { opacity: 1; }
.task-name { font-weight: 600; }
.task-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.detail-toggle { padding: 4px 10px; font-size: 13px; white-space: nowrap; }
.detail-toggle.has-error { border-color: var(--bad); color: var(--bad); }
.detail-row td { padding-top: 0; }
.detail-row .err { margin-bottom: 8px; }
.detail-row pre { margin: 0; max-width: 100%; white-space: pre-wrap; word-break: break-word; }

.login-card { max-width: 360px; margin: 8vh auto 0; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 28px; }
.login-card button { width: 100%; margin-top: 10px; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.timeline .when { color: var(--muted); font-size: 12px; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
