@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/assets/fonts/jetbrains-mono.woff2') format('woff2');
}

:root {
  --bg:        #0a0b10;
  --surface:   #14161e;
  --line:      #232636;
  --fg:        #eef0f7;
  --muted:     #8389a0;
  --accent:    #5fb8ff;
  --accent-dim:#3a8bd0;
  --missing:   #ff7a7a;
  --ok:        #6ee7b7;
  --selection: rgba(95, 184, 255, .25);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 12px/1.55 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--selection); }
img.pixel { image-rendering: pixelated; image-rendering: crisp-edges; }
img { max-width: 100%; height: auto; }

.app {
  display: flex;
  min-height: 100vh;
}
main {
  flex: 1; min-width: 0;
  padding: 1.5rem 2rem 4rem;
}

.standalone { max-width: 360px; margin: 0 auto; padding: 4rem 1.5rem; }

/* ---- sidebar nav ---- */
nav.side {
  width: 13rem; flex-shrink: 0;
  display: flex; flex-direction: column;
  padding: 1.25rem 1rem;
  border-right: 1px solid var(--line);
  background: var(--surface);
  font-size: .8rem;
}
nav.side .brand {
  display: inline-flex; align-items: center; gap: .55rem;
  line-height: 1; margin-bottom: 1.4rem;
  border-bottom: 1px solid transparent;
}
nav.side .brand img { height: 22px; width: auto; display: block; }
nav.side .brand .name { color: var(--fg); font-size: .9rem; font-weight: 700; letter-spacing: .04em; }
nav.side .brand:hover .name { border-bottom: 1px solid var(--accent); }

nav.side .nav-items { display: flex; flex-direction: column; gap: 1px; flex: 1; }
nav.side a {
  display: block; padding: .35rem .65rem;
  color: var(--muted); text-decoration: none; border: 0;
  border-radius: 3px;
}
nav.side a:hover { color: var(--accent); background: var(--bg); }
nav.side a.active {
  color: var(--fg); background: var(--bg);
  box-shadow: inset 2px 0 0 var(--accent);
}
nav.side .nav-heading {
  font-size: .65rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); opacity: .65;
  padding: 1rem .65rem .25rem;
}

nav.side .sidebar-footer {
  margin-top: 1.5rem; padding-top: 1rem;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: .5rem;
}
nav.side form.logout { margin: 0; padding: 0 .65rem; }
nav.side .btn {
  border: 1px solid var(--line); padding: .25rem .7rem; border-radius: 4px;
  color: var(--muted); background: transparent; cursor: pointer; font: inherit; width: 100%;
}
nav.side .btn:hover { border-color: var(--accent); color: var(--accent); }

.nav-toggle-cb { display: none; }
.burger { display: none; }
.burger-scrim { display: none; }

/* ---- uniform page header ---- */
.page-header {
  display: flex;
  align-items: center;
  padding: 0 0 1rem;
  margin: 0 0 1.5rem;
  border-bottom: 1px solid var(--line);
}
.page-header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.3;
}

@media (max-width: 760px) {
  /* Burger button — lives inside the page header, inline with the H1. */
  .page-header .burger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2rem; height: 2rem;
    background: var(--surface);
    border: 1px solid var(--line); border-radius: 4px;
    color: var(--fg); cursor: pointer;
    font-size: 1rem; line-height: 1;
    margin-right: .7rem; flex-shrink: 0;
  }
  .page-header .burger:hover { border-color: var(--accent); color: var(--accent); }

  /* Sidebar slides in from the left when the checkbox is on. */
  nav.side {
    position: fixed; top: 0; left: -100%;
    height: 100vh; width: 80%; max-width: 18rem;
    transition: left .2s ease;
    z-index: 200;
    overflow-y: auto;
    box-shadow: 4px 0 12px rgba(0,0,0,.45);
  }
  .nav-toggle-cb:checked ~ nav.side { left: 0; }

  /* Scrim behind the open sidebar — tap to close. Sits above the
     burger so it disappears with the rest of the content. */
  .nav-toggle-cb:checked ~ .burger-scrim {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 199;
  }

  main { padding: 1rem .9rem 3rem; }
}

.badge {
  display: inline-block;
  background: var(--missing); color: var(--bg);
  border-radius: 999px;
  padding: 0 .45em;
  font-size: .75em;
  font-weight: 700;
  margin-left: .2em;
  vertical-align: 1px;
}

/* ---- typography ---- */
h1, h2, h3, h4 { line-height: 1.25; margin: 1.6em 0 .5em; font-weight: 700; color: var(--fg); }
h1 { font-size: 1.2rem; margin-top: 0; }
h2 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 700;
  margin: 1.4em 0 .5em;
}
h2:first-child { margin-top: 0; }
p, ul, ol, blockquote, pre, table { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
a:hover { border-bottom-color: var(--accent); }
strong, b { color: var(--fg); font-weight: 700; }
code {
  font: inherit; background: var(--surface); padding: 0 .35em; border-radius: 3px;
  border: 1px solid var(--line); color: var(--fg);
}
.muted { color: var(--muted); }
.footnote { font-size: .8rem; margin-top: 1.5rem; color: var(--muted); }

section { margin-bottom: 1.8rem; }

/* ---- tables (kb-style: bottom borders only, no card) ---- */
/* sections become the scroll container on narrow viewports so wide
   tables don't push the whole page sideways. */
section { overflow-x: auto; }

table.servers {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}
table.servers th, table.servers td {
  text-align: left;
  padding: .4rem .7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}
table.servers th {
  color: var(--accent);
  font-weight: 400;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding-top: 0;
}
table.servers th:first-child,
table.servers td:first-child { padding-left: 0; }
/* The narrow 1.5rem width only applies when the first cell is *just*
   a status dot — full-text first cells (Module name, Asset name) need
   to expand to their content. */
table.servers th:first-child:empty { width: 1.5rem; }
table.servers td:first-child:has(.dot:only-child) { width: 1.5rem; }
table.servers th:last-child,
table.servers td:last-child { padding-right: 0; }
table.servers td.host { font-weight: 700; color: var(--fg); white-space: normal; }
table.servers tr.stale td { color: var(--muted); }
table.servers td.actions { white-space: nowrap; }
table.servers td.actions form, table.servers td.actions a.btn { margin-left: .3rem; }

/* ---- status dot ---- */
.dot {
  display: inline-block;
  width: .55rem; height: .55rem;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px rgba(110, 231, 183, .45);
  vertical-align: middle;
}
tr.stale .dot {
  background: var(--missing);
  box-shadow: 0 0 6px rgba(255, 122, 122, .45);
}

/* ---- forms / buttons ---- */
form.inline { display: inline-flex; gap: .3rem; align-items: center; margin: 0; }
form.inline input[type=text],
form.inline input[type=password],
form.inline input[type=number],
form.inline select {
  font: inherit;
  padding: .2rem .5rem;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
  border-radius: 4px;
  min-width: 8rem;
}
form.inline select { min-width: 6rem; }
form.inline input:focus, form.inline select:focus { outline: none; border-color: var(--accent-dim); }
form.inline label { color: var(--muted); display: inline-flex; gap: .3rem; align-items: center; }

/* Search + per-page bar on list views (patches host pages) — roomier
   than a bare inline form so the controls don't feel cramped. */
form.inline.list-controls {
  gap: .55rem;
  flex-wrap: wrap;
  margin: .4rem 0 1.2rem;
}
form.inline.list-controls input[type=text],
form.inline.list-controls select,
form.inline.list-controls .btn { padding-top: .34rem; padding-bottom: .34rem; }
form.inline.list-controls label { gap: .45rem; margin-left: .35rem; }

.btn {
  font: inherit;
  padding: .2rem .7rem;
  border: 1px solid var(--line); background: transparent; color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
  border-color: var(--accent); background: var(--accent); color: var(--bg);
}
.btn-primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); color: var(--bg); }
.btn-danger { border-color: var(--missing); color: var(--missing); }
.btn-danger:hover { background: var(--missing); color: var(--bg); }

.token-display {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: .6rem .8rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .85rem;
  word-break: break-all;
  user-select: all;
  margin: .5rem 0 1rem;
}

/* ---- empty state ---- */
.empty {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--muted);
}
.empty p { margin: .4rem 0; }

/* ---- flash ---- */
.flash {
  border: 1px solid var(--accent-dim);
  background: rgba(95, 184, 255, .08);
  color: var(--accent);
  padding: .4rem .7rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: .85rem;
}

/* ---- login ---- */
.login-hero {
  display: flex; flex-direction: column; align-items: center;
  margin: 4rem auto 1.5rem; gap: 1rem;
}
.login-hero img { width: 52px; height: 52px; display: block; }
.login-hero .wordmark { font-size: 1rem; font-weight: 700; color: var(--fg); letter-spacing: .03em; }
form.login {
  max-width: 320px; margin: 0 auto;
  display: flex; flex-direction: column; gap: .9rem;
}
form.login h1 { margin: 0; text-align: center; font-size: .85rem; font-weight: 400; color: var(--muted); letter-spacing: .04em; }
form.login label { display: flex; flex-direction: column; gap: .15rem; color: var(--muted); }
form.login input {
  font: inherit; padding: .35rem .6rem; border: 1px solid var(--line); border-radius: 4px;
  background: var(--surface); color: var(--fg);
}
form.login input:focus { outline: none; border-color: var(--accent-dim); }
form.login button {
  font: inherit; padding: .35rem 1rem; border-radius: 4px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--bg); cursor: pointer;
}
form.login button:hover { background: var(--accent-dim); border-color: var(--accent-dim); }
form.login .error { color: var(--missing); margin: 0; font-size: .85rem; }


/* ---- meta strip (host header info: IP / agent / uptime / OS / EOL) ---- */
/* Flex-wrap with per-chunk nowrap so each `· segment` is atomic and the
   strip falls onto multiple lines instead of overflowing the viewport. */
.meta-strip {
    display: flex;
    flex-wrap: wrap;
    column-gap: .9rem;
    row-gap: .2rem;
    align-items: baseline;
    margin: 0 0 .4rem;
}
.meta-strip > span { white-space: nowrap; }
.meta-strip + .meta-strip { margin-bottom: 1rem; }

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: .75rem;
    margin-bottom: 2rem;
}
.metric-card {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: .65rem .85rem;
    background: var(--surface);
}
.metric-card .label {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
}
.metric-card .value {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.2;
    margin-top: .15rem;
}
.metric-card .value .sub { font-size: .65rem; color: var(--muted); margin-left: .2em; font-weight: 400; }
.metric-card .sub { font-size: .75rem; color: var(--muted); }
.metric-card svg.spark { display: block; margin-top: .4rem; width: 100%; max-width: 100%; height: 36px; }
.metric-card .chip-strip { margin-top: .4rem; }

.usage-bar {
    display: inline-block;
    height: 6px;
    width: 80px;
    background: var(--line);
    border-radius: 2px;
    vertical-align: middle;
    overflow: hidden;
    margin-right: .4rem;
}
.usage-bar .fill {
    display: block;
    height: 100%;
    background: var(--accent);
}
.usage-bar.warn .fill { background: #f6c560; }
.usage-bar.crit .fill { background: var(--missing); }

/* ---- form disclosures (Add a path / Link an asset) ---- */
.form-disclosure { margin-top: 1rem; }
.form-disclosure > summary {
    cursor: pointer;
    color: var(--accent);
    font-size: .9rem;
    user-select: none;
    width: max-content;
    list-style: none;
}
.form-disclosure > summary::-webkit-details-marker { display: none; }
.form-disclosure > summary::before {
    content: "+";
    display: inline-block;
    width: 1em;
    margin-right: .2em;
    color: var(--muted);
}
.form-disclosure[open] > summary::before { content: "−"; }
.form-disclosure > summary:hover { color: var(--accent-dim); }
.form-disclosure[open] > summary { margin-bottom: .6rem; }
/* Keep a disclosed table.form from stretching its inputs full-width. */
.form-disclosure table.form input[type=text],
.form-disclosure table.form select {
    min-width: 0;
    width: 24rem;
    max-width: 100%;
}

/* ---- per-row pop-out (key rotation form, audit detail, …) ---- */
/* A <details> in a table cell. When opened its content (whatever the
   non-summary child is) becomes an absolutely-positioned popover
   anchored under the summary — out of flow, so it never widens the
   table column or shoves a sibling out of the row. The section hosting
   such a table carries .has-popout so the popover isn't clipped by the
   section's overflow box. */
details.row-popout {
    position: relative;
    display: inline-block;
    vertical-align: top;
    margin-left: .3rem;
}
details.row-popout > summary {
    display: inline-block;
    list-style: none;
}
details.row-popout > summary::-webkit-details-marker { display: none; }
details.row-popout > summary::marker { content: ""; }
details.row-popout[open] > *:not(summary) {
    position: absolute;
    top: calc(100% + .35rem);
    right: 0;
    z-index: 30;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: .55rem .65rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .55);
}
section.has-popout { overflow: visible; }

/* ---- audit-log detail row ---- */
/* The Detail cell is a [data-row-toggle] button; the JSON lives in a
   full-width .detail-row directly below the entry, shown / hidden by
   the toggle (pulse.js). Keeps the space-less JSON blob out of the
   table's column-width budget entirely. */
.audit-toggle {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    font-size: .8rem;
    color: var(--accent);
    cursor: pointer;
}
.audit-toggle::before { content: "▸ "; }
.audit-toggle.is-open::before { content: "▾ "; }
tr.detail-row { display: none; }
tr.detail-row.open { display: table-row; }
td.detail-cell {
    background: rgba(255, 255, 255, .022);
    padding: .5rem .7rem .65rem;
}
.audit-detail-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: .8rem;
    color: var(--fg);
}

/* ---- modules + assets ---- */
.small { font-size: .8rem; }

nav.subnav { display: flex; gap: .85rem; margin: .8rem 0 1rem; font-size: .9rem; }
nav.subnav a { color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; padding-bottom: 2px; }
nav.subnav a.active { color: var(--fg); border-bottom-color: var(--accent); }
nav.subnav a:hover { color: var(--accent); }

.user-actions { display: flex; flex-wrap: wrap; gap: .9rem 1.2rem; margin: .6rem 0 1rem; align-items: center; }
.user-actions > form { margin: 0; }
table.grants { max-width: 36rem; margin: 0 0 .6rem; }
table.grants td:nth-child(2), table.grants td:nth-child(3),
table.grants th:nth-child(2), table.grants th:nth-child(3) { text-align: center; width: 4rem; }
table.grants input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }

/* user-card section heading: regular case + the role chip next to it */
section.user-card h2 { text-transform: none; letter-spacing: 0; font-size: 1rem; color: var(--fg); margin-bottom: .15rem; }
section.user-card h2 .role-chip {
  display: inline-block; margin-left: .4rem;
  padding: 0 .45em; font-size: .65em; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  border-radius: 3px; background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  vertical-align: 2px;
}
section.user-card h2 .role-chip.admin { color: var(--accent); border-color: var(--accent-dim); }
section.user-card { padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 5px; margin-bottom: 1rem; }
section.user-card + section.user-card { margin-top: 0; }

/* generic status chip — the account page reuses it outside a user-card */
.role-chip {
  display: inline-block; margin-left: .4rem;
  padding: 0 .45em; font-size: .65em; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  border-radius: 3px; background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  vertical-align: 2px;
}
.role-chip.admin { color: var(--accent); border-color: var(--accent-dim); }

/* 2FA enrollment QR (data: GIF filled in by pulse.js); keep it crisp */
.totp-qr { width: 176px; height: 176px; background: #fff; padding: 6px; border-radius: 4px; image-rendering: pixelated; }

.module-shortcuts h2 { font-size: .85rem; font-weight: 400; color: var(--muted); letter-spacing: .04em; margin: 0 0 .6rem; }
.shortcut-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1.5rem; }
.shortcut {
  display: inline-flex; flex-direction: column; gap: .15rem;
  padding: .55rem .85rem;
  border: 1px solid var(--line); border-radius: 5px;
  background: var(--surface); color: var(--fg);
  text-decoration: none; border-bottom: 1px solid var(--line);
  min-width: 14rem;
}
.shortcut:hover { border-color: var(--accent); border-bottom-color: var(--accent); }
.shortcut-name   { color: var(--fg);   font-weight: 700; font-size: .85rem; }
.shortcut-action { color: var(--accent); font-size: .8rem; }
.shortcut:hover .shortcut-action { color: var(--accent); }

.flash-error {
  border-color: var(--missing);
  background: rgba(255, 122, 122, .1);
  color: var(--missing);
}
.flash-warn {
  border-color: #f6c560;
  background: rgba(246, 197, 96, .1);
  color: #f6c560;
}

table.form { border-collapse: collapse; margin: 0 0 1rem; }
table.form th { text-align: left; padding: .3rem .8rem .3rem 0; font-weight: 400; color: var(--muted); vertical-align: top; }
table.form td { padding: .3rem 0; }
table.form input[type=text],
table.form input[type=password],
table.form input[type=number],
table.form select {
  font: inherit; padding: .3rem .55rem; border: 1px solid var(--line); border-radius: 4px;
  background: var(--surface); color: var(--fg); min-width: 24rem;
}
table.form input:focus, table.form select:focus {
  outline: none; border-color: var(--accent-dim);
}

.ok   { color: var(--ok); }
.warn { color: #f6c560; }
.crit { color: var(--missing); }

tr.form-row td {
  background: rgba(255,255,255,.015);
  padding-top: .3rem; padding-bottom: .5rem;
  border-top: 0;
}
tr.form-row input[type=text], tr.form-row input[type=password] {
  font: inherit; padding: .2rem .45rem; border: 1px solid var(--line); border-radius: 4px;
  background: var(--surface); color: var(--fg); min-width: 16rem;
}

.kind-badge {
  display: inline-block; padding: 0 .45em; border-radius: 3px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  font-size: .8em; letter-spacing: .03em;
}

/* Fleet rollup chips — one per module attached to an asset, coloured
   by latest status. Hover reveals the headline via the title attr. */
.fleet-chip {
  display: inline-block;
  padding: .1em .55em;
  margin: .1em .2em .1em 0;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: .8em;
  letter-spacing: .03em;
  text-decoration: none;
  white-space: nowrap;
}
.fleet-chip.ok    { color: var(--ok); border-color: rgba(110,231,183,.4); }
.fleet-chip.warn  { color: #f6c560; border-color: rgba(246,197,96,.4); }
.fleet-chip.crit  { color: var(--missing); border-color: rgba(229,90,90,.4); }
.fleet-chip.muted { color: var(--muted); }
.fleet-chip:hover { background: rgba(255,255,255,.04); }

/* Scorecard row: a wrapping group of pass/fail chips. */
.chip-strip { display: inline-flex; flex-wrap: wrap; align-items: center; }

/* Fleet table: chip column should breathe, host column stays tight. */
table.servers.fleet td:last-child { line-height: 1.9; }

/* Per-probe stack on outbound-module index pages: one <li> per probe
   that has reported, rendered below the rollup chip in the Status
   column. Compact line-height so a 3-probe target stays readable. */
ul.probe-stack {
  list-style: none;
  margin: .3rem 0 0;
  padding: 0;
}
ul.probe-stack li { margin: .2rem 0; line-height: 1.4; }


/* SSH-key sub-row on /agent/accounts/<host>: visually nested under
   the account it belongs to. */
.account-keys-row td { padding-top: .1rem; border-top: 0; }
ul.account-keys { margin: .2rem 0 .4rem; padding-left: 1.2rem; }
ul.account-keys li { margin: .1rem 0; }

/* ---------- utility classes ----------
   Used to replace inline `style=""` attributes so we can drop
   'unsafe-inline' from the style-src CSP. */
.mt-0    { margin-top: 0; }
.mb-1    { margin-bottom: 1rem; }
.ml-1    { margin-left: 1em; }
.inline-ml-1 { display: inline; margin-left: 1em; }
.min-w-sm { min-width: 8rem; }
.min-w-md { min-width: 14rem; }
.min-w-lg { min-width: 22rem; }
.min-w-xl { min-width: 30rem; }
.kind-badge.stale { color: var(--missing); border-color: var(--missing); }

/* ---------- usage-bar fill via bucketed data-pct ----------
   The .fill width was the one remaining inline `style="width: X%"`.
   Round the value to the nearest 5% in PHP and the matching selector
   below sizes the bar. Keeps the dashboard CSP-clean without a JS
   shim. */
.usage-bar .fill[data-pct="0"]   { width: 0%; }
.usage-bar .fill[data-pct="5"]   { width: 5%; }
.usage-bar .fill[data-pct="10"]  { width: 10%; }
.usage-bar .fill[data-pct="15"]  { width: 15%; }
.usage-bar .fill[data-pct="20"]  { width: 20%; }
.usage-bar .fill[data-pct="25"]  { width: 25%; }
.usage-bar .fill[data-pct="30"]  { width: 30%; }
.usage-bar .fill[data-pct="35"]  { width: 35%; }
.usage-bar .fill[data-pct="40"]  { width: 40%; }
.usage-bar .fill[data-pct="45"]  { width: 45%; }
.usage-bar .fill[data-pct="50"]  { width: 50%; }
.usage-bar .fill[data-pct="55"]  { width: 55%; }
.usage-bar .fill[data-pct="60"]  { width: 60%; }
.usage-bar .fill[data-pct="65"]  { width: 65%; }
.usage-bar .fill[data-pct="70"]  { width: 70%; }
.usage-bar .fill[data-pct="75"]  { width: 75%; }
.usage-bar .fill[data-pct="80"]  { width: 80%; }
.usage-bar .fill[data-pct="85"]  { width: 85%; }
.usage-bar .fill[data-pct="90"]  { width: 90%; }
.usage-bar .fill[data-pct="95"]  { width: 95%; }
.usage-bar .fill[data-pct="100"] { width: 100%; }

.module-meta dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .3rem 1.2rem;
  margin: 1rem 0 1.5rem;
  font-size: .85rem;
}
.module-meta dt { color: var(--muted); }
.module-meta dd { margin: 0; color: var(--fg); }

.markdown { max-width: 70ch; line-height: 1.6; }
.markdown h2 { font-size: 1rem; margin: 1.6em 0 .5em; color: var(--fg); }
.markdown h3 { font-size: .9rem; margin: 1.3em 0 .4em; color: var(--fg); }
.markdown p { margin: 0 0 .9em; }
.markdown ul, .markdown ol { margin: 0 0 .9em 1.4em; padding: 0; }
.markdown li { margin: .15em 0; }
.markdown code {
  font: inherit; background: var(--surface); padding: 0 .35em;
  border: 1px solid var(--line); border-radius: 3px; color: var(--fg);
}
.markdown pre {
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
  padding: .6em .8em; overflow-x: auto; margin: 0 0 .9em;
}
.markdown pre code { background: none; border: 0; padding: 0; }

@media (max-width: 1024px) {
  /* On narrower viewports (tablet + small laptop + mobile), table rows
     become labelled cards. Each <td> shows its value next to (or under)
     its column header, drawn from the data-label attribute on the cell.
     The breakpoint sits at 1024px because the rich tables (10 columns
     on /, 9 on /probes/tls, etc.) only fit cleanly from ~1100px up.

     Tables that haven't been data-label-tagged fall back to plain
     stacked rows with no label — still readable, no sideways scroll. */
  section { overflow-x: visible; }

  table.servers,
  table.servers thead,
  table.servers tbody,
  table.servers tr,
  table.servers th,
  table.servers td {
    display: block;
    width: auto;
  }
  table.servers thead { display: none; }
  table.servers tr {
    margin: 0 0 .65rem;
    padding: .55rem .7rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface);
  }
  table.servers td {
    padding: .12rem 0;
    border: 0;
    white-space: normal;
    display: flex;
    justify-content: space-between;
    gap: .8rem;
    align-items: baseline;
    font-size: .82rem;
  }
  /* The label, drawn from data-label, is only shown when present. */
  table.servers td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    flex-shrink: 0;
  }
  /* The first cell (typically a status dot or the row's primary name)
     takes the top spot full-width, no label, slightly bigger. */
  table.servers td:first-child {
    padding-top: 0;
    padding-bottom: .25rem;
    margin-bottom: .25rem;
    border-bottom: 1px solid var(--line);
    font-weight: 700;
    font-size: .95rem;
  }
  table.servers td:first-child::before { content: none; }
  /* Audit detail row: a plain full-width block, not a card-title cell. */
  table.servers tr.detail-row { display: none; }
  table.servers tr.detail-row.open { display: block; }
  table.servers tr.detail-row td.detail-cell {
    display: block;
    border: 0;
    margin: 0;
    padding: .2rem 0 0;
    font-weight: 400;
    font-size: .8rem;
  }
  /* Actions cell on its own row, buttons spread. */
  table.servers td.actions {
    flex-wrap: wrap; gap: .4rem;
    margin-top: .4rem; padding-top: .4rem;
    border-top: 1px solid var(--line);
    justify-content: flex-start;
  }
  table.servers td.actions::before { content: none; }

  /* Decorative leading cells (just a status dot, nothing else) are
     hidden on mobile — the host name takes the card title slot. */
  table.servers td:has(.dot:only-child) { display: none; }

  /* Anything explicitly tagged data-mobile-hide is dropped on mobile
     (lower-priority columns). */
  table.servers td[data-mobile-hide],
  table.servers th[data-mobile-hide] { display: none; }

  /* Form tables — stack label above input, inputs go full-width
     instead of the 24rem min-width that overflows narrow phones. */
  table.form, table.form tbody, table.form tr,
  table.form th, table.form td {
    display: block; width: auto;
  }
  table.form th {
    padding: .5rem 0 .15rem;
  }
  table.form td {
    padding: 0 0 .6rem;
  }
  table.form input[type=text],
  table.form input[type=password],
  table.form input[type=number],
  table.form select {
    min-width: 0; width: 100%;
  }

  /* Inline forms shouldn't overflow either. The form itself wraps
     so a long <select> doesn't push the button off-screen, and the
     fields shrink to fill available space. */
  form.inline {
    display: flex; flex-wrap: wrap; max-width: 100%;
  }
  form.inline > * { max-width: 100%; }
  form.inline input[type=text],
  form.inline input[type=password],
  form.inline input[type=number],
  form.inline select {
    min-width: 0; max-width: 100%; flex: 1 1 12rem;
  }

  /* User-card section on /admin/users — tighten padding. */
  section.user-card { padding: .8rem .85rem; }
  .user-actions { gap: .6rem .85rem; }
}
