/*
 * Stylesheet modelled on Atlassian Statuspage's default look (e.g.
 * https://d2o.statuspage.io). Values lifted from statuspage's own
 * production CSS: 850px container, rounded coloured page-status card
 * (not a full-width hero), bordered components list with thin
 * dividers, #2ecc71/#f1c40f/#e67e22/#e74c3c/#3498db status palette,
 * 16px / 24px line-height body type, white background.
 */

:root {
  color-scheme: light;

  /* Page surfaces — always white per d2o's customized statuspage. */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-muted: #f8f9fa;
  --border: #dddddd;

  /* Text */
  --fg: #333333;
  --fg-muted: #6b6b6b;
  --fg-subtle: #999999;

  /* Brand / accent */
  --accent: #1868db;
  --accent-hover: #144fac;
  --accent-fg: #ffffff;
  --focus-ring: rgba(24, 104, 219, 0.25);

  /* Status palette — d2o.statuspage.io theme overrides. */
  --status-ok: #00875a;
  --status-degraded: #f1c40f;
  --status-partial: #b35e14;
  --status-major: #de2f1b;
  --status-maintenance: #1868db;
  /* Uptime-bar "no data" tint. */
  --uptime-empty: #e6e6e6;

  /* Shape */
  --radius: 4px;
  --container: 850px;

  --font-sans: "proxima-nova", -apple-system, BlinkMacSystemFont,
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html {
  font-size: 16px;
  line-height: 24px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 16px;
  line-height: 24px;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: subpixel-antialiased;
  min-height: 100vh;
}

/* ───── Container ───── */
.container {
  width: 90%;
  max-width: var(--container);
  margin: 0 auto;
  padding-top: 70px;
  padding-bottom: 4rem;
}

/* Pages without a .container wrapper (admin shell, auth forms,
   error pages) get the same centred narrow layout via direct-child
   constraints — no markup churn required. */
body:not(:has(> .container)) {
  padding: 2.5rem 1.5rem 4rem;
}
body:not(:has(> .container)) > * {
  max-width: var(--container);
  margin-left: auto;
  margin-right: auto;
}

/* ───── Masthead ───── */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 50px;
}
.masthead-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.masthead h1, .masthead h3 {
  font-size: 1.5rem;
  font-weight: 500;
  margin: 0;
  color: var(--fg);
  letter-spacing: -0.005em;
}
.masthead-logo {
  max-height: 40px;
  max-width: 200px;
  width: auto;
  height: auto;
}
a.masthead-title {
  color: inherit;
  text-decoration: none;
}
a.masthead-title:hover {
  color: inherit;
  text-decoration: none;
}
a.masthead-title:hover h1 {
  color: var(--accent);
}

/* "Subscribe to Updates" button in the masthead, lifted from
   statuspage's `.show-updates-dropdown` style. */
.subscribe-button {
  display: inline-block;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #ffffff !important;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  box-shadow: 0 -2px 0 rgba(0, 0, 0, 0.15) inset;
  white-space: nowrap;
}
.subscribe-button:hover {
  background: var(--accent-hover);
  text-decoration: none;
}

/* ───── Page-status banner ─────
   A rounded coloured card with white text — the centrepiece of every
   statuspage page. Same shape, padding, and palette as statuspage.io. */
.banner {
  display: block;
  border-radius: var(--radius);
  border: 1px solid rgba(0, 0, 0, 0.1);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
  padding: 0.875rem 1.25rem;
  margin: 0 0 50px;
  font-weight: 500;
  background: var(--surface-muted);
  color: var(--fg);
}
.banner .status {
  display: block;
  color: #ffffff;
  font-size: 1.25rem;
  line-height: 1.8125rem;
  font-weight: 500;
  margin: 0;
}
.banner.ok { background: var(--status-ok); }
.banner.degraded { background: var(--status-degraded); }
.banner.partial { background: var(--status-partial); }
.banner.major { background: var(--status-major); }
.banner.maintenance { background: var(--status-maintenance); }

/* ───── Headings ───── */
h1, h2, h3, h4, h5, h6 { color: var(--fg); font-weight: 500; line-height: 1.25; margin: 0; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.125rem; margin: 1.75rem 0 0.75rem; }
h3 { font-size: 1.0625rem; margin: 1.25rem 0 0.5rem; }

p { margin: 0 0 1rem; }
small {
  color: var(--fg-muted);
  font-size: 0.875rem;
  display: block;
  margin-top: 0.25rem;
}
strong { font-weight: 600; }

/* ───── Links ───── */
a { color: var(--accent); text-decoration: none; }
a:hover, a:focus { color: var(--accent-hover); text-decoration: underline; }

/* ───── Code ───── */
code, pre { font-family: var(--font-mono); font-size: 0.875rem; }
code {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
pre {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
}
pre code { background: transparent; border: 0; padding: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

/* ───── Forms ───── */
form { margin: 0 0 1.5rem; }
form:has(label) {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  max-width: 30rem;
}
label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg);
  margin: 0.875rem 0 0.375rem;
}
form:has(label) p:first-of-type label { margin-top: 0; }

input, select, textarea {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  transition: border-color 80ms ease, box-shadow 80ms ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
input::placeholder, textarea::placeholder { color: var(--fg-subtle); }
input[type="checkbox"], input[type="radio"] { display: inline-block; width: auto; margin-right: 0.5em; vertical-align: middle; }
textarea { min-height: 6rem; resize: vertical; }

button, input[type="submit"] {
  cursor: pointer;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--accent);
  color: var(--accent-fg);
  border: 1px solid var(--accent);
  padding: 0.625rem 1.125rem;
  border-radius: var(--radius);
  transition: background 80ms ease, border-color 80ms ease;
}
button:hover, input[type="submit"]:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
button:focus-visible, input[type="submit"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}
button[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Anchor styled to match buttons (e.g. "Edit" link in admin tables). */
.button-link {
  display: inline-block;
  cursor: pointer;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: transparent;
  color: var(--accent) !important;
  border: 1px solid var(--accent);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  margin-right: 0.25rem;
}
.button-link:hover {
  background: var(--accent);
  color: #ffffff !important;
  text-decoration: none;
}

button[style*="#b00"] {
  background: transparent;
  color: var(--status-major);
  border-color: var(--status-major);
}
button[style*="#b00"]:hover {
  background: var(--status-major);
  color: var(--accent-fg);
}

p[style*="#b00"] {
  background: #fce4e1;
  color: var(--status-major);
  border-left: 3px solid var(--status-major);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin: 0 0 1rem;
  font-weight: 500;
}

/* ───── Tables ───── */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0 0 1.5rem;
}
th, td { padding: 0.625rem 0.875rem; text-align: left; border-bottom: 1px solid var(--border); }
th {
  background: var(--surface-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
}
tr:last-child td { border-bottom: 0; }
table[border] { border-width: 1px; }
table[border] th, table[border] td { border: 0; border-bottom: 1px solid var(--border); }

/* ───── Lists ───── */
ul, ol { padding-left: 1.25em; margin: 0 0 1rem; }
li { margin: 0.25em 0; }

/* Admin shell: flat <ul> of links → stacked settings card. */
body:not(:has(> .container)) > ul:not(.components):not([class]) {
  list-style: none;
  padding: 0;
  margin: 1.5rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
body:not(:has(> .container)) > ul:not(.components):not([class]) > li {
  margin: 0;
  border-bottom: 1px solid var(--border);
}
body:not(:has(> .container)) > ul:not(.components):not([class]) > li:last-child {
  border-bottom: 0;
}
body:not(:has(> .container)) > ul:not(.components):not([class]) > li > a {
  display: block;
  padding: 0.875rem 1.125rem;
  color: var(--fg);
  font-weight: 400;
}
body:not(:has(> .container)) > ul:not(.components):not([class]) > li > a:hover {
  background: var(--surface-muted);
  color: var(--accent);
  text-decoration: none;
}
body:not(:has(> .container)) > ul:not(.components):not([class]) > li > a::after {
  content: "›";
  float: right;
  color: var(--fg-subtle);
  font-weight: 400;
}

/* Inline-styled "card" divs (the onboarding checklist). */
div[style*="border:1px solid"] {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  padding: 1.5rem !important;
  margin: 1.5rem 0 !important;
}
div[style*="border:1px solid"] h2 { margin-top: 0; }

/* ───── Public-page components list ─────
   Match statuspage's `.components-container.one-column` look: one
   bordered, rounded card with all rows separated by 1px dividers. */
ul.components {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
li.component {
  display: block;
  padding: 1.1rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  margin: 0;
}
li.component:last-child { border-bottom: 0; }
li.component .component-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
li.component .component-name-block { min-width: 0; padding-right: 1rem; }
li.component .name { color: var(--fg); font-weight: 400; }
li.component .component-description {
  margin: 0.125rem 0 0 0.875rem;
  font-size: 0.8125rem;
  color: var(--fg-muted);
}
li.component .status {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--status-ok);
}
li.component.ok .status { color: var(--status-ok); }
li.component.degraded .status { color: var(--status-degraded); }
li.component.partial .status { color: var(--status-partial); }
li.component.major .status { color: var(--status-major); }
li.component.maintenance .status { color: var(--status-maintenance); }

/* ───── 90-day uptime bar ─────
   A row of thin vertical segments, oldest on the left, today on the
   right. Each segment is coloured by its `bucket` (ok/minor/notable/
   major) or stays gray when there's no measurement. */
.uptime-bar {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  margin-top: 0.75rem;
  height: 34px;
}
.uptime-bar .day {
  display: block;
  flex: 1 1 0;
  height: 100%;
  border-radius: 1px;
  background: var(--uptime-empty);
  transition: opacity 80ms ease;
}
.uptime-bar .day:hover { opacity: 0.7; }
.uptime-bar .day.ok { background: var(--status-ok); }
.uptime-bar .day.minor { background: var(--status-degraded); }
.uptime-bar .day.notable { background: var(--status-partial); }
.uptime-bar .day.major { background: var(--status-major); }

.uptime-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--fg-muted);
  margin-top: 0.375rem;
}

/* Group heading above a components list. Visually tied to the
   bordered card below it: the card hugs the underside of the
   heading without an extra margin gap. */
.container > h2 {
  margin: 2rem 0 0.625rem;
  font-size: 1rem;
  font-weight: 500;
  color: var(--fg);
  text-transform: none;
  letter-spacing: 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.container > h2 + ul.components {
  border-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* ───── Component groups (statuspage.io's is-group / is-child) ─────
   A group is itself a row in the components list. <details>/<summary>
   gives native collapse without JS; we hide the default disclosure
   arrow and draw our own [+] / [-] indicator on the .group-toggle. */
li.component-group {
  display: block;
  padding: 0;
}
li.component-group > details {
  width: 100%;
}
li.component-group > details > summary {
  cursor: pointer;
  list-style: none;
  padding: 1.1rem 1.25rem 1rem;
  display: block;
}
li.component-group > details > summary::-webkit-details-marker { display: none; }
li.component-group > details > summary:hover {
  background: var(--surface-muted);
}
li.component-group > details > summary > .component-row .name {
  font-weight: 500;
}
li.component-group > details > summary > .component-row .name::before {
  display: none;
}
li.component-group .group-toggle {
  display: inline-block;
  width: 0.875rem;
  height: 0.875rem;
  text-align: center;
  line-height: 0.875rem;
  margin-right: 0.5rem;
  color: var(--fg-muted);
  font-weight: 500;
  font-size: 0.875rem;
}
li.component-group .group-toggle::before { content: "+"; }
li.component-group > details[open] .group-toggle::before { content: "−"; }

/* Per status, paint the aggregated status text. */
li.component-group.ok > details > summary .status { color: var(--status-ok); }
li.component-group.degraded > details > summary .status { color: var(--status-degraded); }
li.component-group.partial > details > summary .status { color: var(--status-partial); }
li.component-group.major > details > summary .status { color: var(--status-major); }
li.component-group.maintenance > details > summary .status { color: var(--status-maintenance); }

/* Child components: indented sub-list, no card border (parent already
   provides one), thinner dividers, smaller leading. */
ul.child-components {
  list-style: none;
  padding: 0 0 0.5rem 1.875rem;
  margin: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface-muted);
}
ul.child-components > li.component {
  padding: 0.75rem 1.25rem 0.625rem 0;
  border-bottom: 1px dashed var(--border);
}
ul.child-components > li.component:last-child {
  border-bottom: 0;
}
ul.child-components .uptime-bar { height: 24px; }
.group-empty {
  margin: 0;
  padding: 0.75rem 1.5rem;
  color: var(--fg-muted);
  background: var(--surface-muted);
  font-size: 0.875rem;
}

/* Incidents (active + history). */
section.incidents { margin: 0 0 2rem; }
article.incident {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin: 0 0 1rem;
}
article.incident h3 { margin: 0 0 0.5rem; font-size: 1.125rem; font-weight: 500; }
article.incident.impact-minor { border-top: 4px solid var(--status-degraded); }
article.incident.impact-major { border-top: 4px solid var(--status-partial); }
article.incident.impact-critical { border-top: 4px solid var(--status-major); }
article.incident .timestamp { font-size: 0.875rem; color: var(--fg-muted); margin: 0; }
article.incident .latest-update { margin: 0.5rem 0; color: var(--fg); }
article.incident .latest-update p:last-child { margin-bottom: 0; }

/* ───── Public-page system metrics ───── */
section.public-metrics { margin: 0 0 2rem; }
.public-metrics-heading {
  font-size: 1rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg);
  margin: 1.5rem 0 0.75rem;
}
.public-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}
.public-metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
}
.public-metric-name {
  margin: 0 0 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}
.public-metric-figure {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--fg);
  letter-spacing: -0.005em;
}
.public-metric-value { color: var(--fg); }
.public-metric-unit {
  font-size: 0.875rem;
  color: var(--fg-muted);
  font-weight: 400;
}
.public-metric-when {
  margin: 0;
  font-size: 0.75rem;
  color: var(--fg-subtle);
}

/* ───── Scheduled maintenance section ───── */
section.maintenances { margin: 0 0 2rem; }
article.maintenance {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--status-maintenance);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin: 0 0 1rem;
}
article.maintenance h3 { margin: 0 0 0.375rem; font-size: 1.125rem; font-weight: 500; }
article.maintenance.in-progress { background: var(--status-maintenance-bg, #e1f0fa); }
article.maintenance .maintenance-window {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  color: var(--fg-muted);
}
article.maintenance .maintenance-body { color: var(--fg); }
article.maintenance .maintenance-body p:last-child { margin-bottom: 0; }

/* History list at /history. */
ul.history {
  list-style: none;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
ul.history li {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin: 0;
}
ul.history li:last-child { border-bottom: 0; }
nav.pager { display: flex; gap: 1rem; margin: 1.5rem 0; }

/* Footer ("Snapshot generated at …"). */
p.footer {
  text-align: center;
  font-size: 0.875rem;
  color: var(--fg-muted);
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ───── Subscribe / confirm / unsubscribe pages ───── */
.subscribe-heading {
  font-size: 1.5rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  margin: 0 0 1.25rem;
}
fieldset.subscribe-channel,
fieldset.subscribe-scope,
fieldset.subscribe-components {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1.125rem;
  margin: 0 0 1rem;
  background: var(--surface);
}
fieldset.subscribe-channel legend,
fieldset.subscribe-scope legend,
fieldset.subscribe-components legend {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg);
  padding: 0 0.375rem;
}
label.radio, label.checkbox {
  display: block;
  font-size: 0.9375rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin: 0.375rem 0;
  color: var(--fg);
  cursor: pointer;
}
label.radio input, label.checkbox input { margin-right: 0.5rem; }

/* ───── Past Incidents section ─────
   Statuspage shows the last 7 days as a stack of date-labeled blocks.
   Empty days render "No incidents reported.". */
.past-incidents { margin-top: 3rem; }
.past-incidents-header {
  font-size: 1.5rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg);
  margin: 0 0 1.5rem;
}
.status-day {
  border-top: 1px solid var(--border);
  padding: 1rem 0 1.5rem;
}
.status-day .date {
  font-size: 1.125rem;
  font-weight: 500;
  margin: 0 0 0.5rem;
  color: var(--fg);
}
.status-day .no-incidents {
  color: var(--fg-muted);
  font-size: 0.9375rem;
  margin: 0;
}
.past-incident {
  padding: 0.5rem 0 0.5rem 0.75rem;
  margin: 0.5rem 0;
  border-left: 3px solid var(--border);
}
.past-incident.impact-minor { border-left-color: var(--status-degraded); }
.past-incident.impact-major { border-left-color: var(--status-partial); }
.past-incident.impact-critical { border-left-color: var(--status-major); }
.past-incident .incident-title { margin: 0; font-weight: 500; color: var(--fg); }
.past-incident .incident-meta {
  margin: 0.125rem 0 0;
  font-size: 0.875rem;
  color: var(--fg-muted);
}

/* ───── Admin chrome (injected on the manage host + /superadmin) ─────
   A single full-height left rail: brand at the top, scrollable nav in the
   middle, and a user/avatar menu pinned to the foot. No top bar — global
   actions live in the avatar dropdown. Content sits to the right of the rail. */
:root {
  --admin-sidebar-width: 240px;
}

.admin-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--admin-sidebar-width);
  background: #172b4d;
  color: #c1c7d0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  font-size: 0.9375rem;
}
/* Brand block at the very top of the rail. */
.admin-sidebar-brand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 1.25rem;
  box-sizing: border-box;
  color: #ffffff !important;
  font-weight: 600;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.admin-sidebar-brand:hover {
  color: #ffffff !important;
  text-decoration: none;
}
/* Nav fills the space between brand and the user footer, scrolling on its own
   so the avatar menu stays pinned to the bottom. */
.admin-sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.5rem 0 1rem;
}
.admin-sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 1.25rem;
  color: #c1c7d0 !important;
  text-decoration: none;
  font-weight: 400;
  border-left: 3px solid transparent;
}
.admin-sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff !important;
  text-decoration: none;
}
.admin-sidebar-nav a.active,
.admin-sidebar-nav a[aria-current="page"] {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff !important;
  border-left-color: var(--accent);
}
.admin-sidebar-icon {
  /* Inline Feather/Lucide-style line icons. `stroke: currentColor` means they
     inherit the link colour (and its hover/active states) for free. */
  flex: 0 0 auto;
  width: 1.05rem;
  height: 1.05rem;
  opacity: 0.85;
}
.admin-sidebar-subitem {
  padding-left: 2.75rem !important;
  font-size: 0.875rem;
  color: #9097a5 !important;
}
.admin-sidebar-section {
  padding: 0.875rem 1.25rem 0.25rem;
  color: #7a869a;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.25rem;
}

/* ───── User / avatar menu at the foot of the rail ─────
   A native <details> disclosure, so the menu (incl. Log out) works without
   JS; app.js only enhances it (close-on-outside-click + avatar/email). */
.admin-user {
  flex: 0 0 auto;
  position: relative;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.admin-user-toggle {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.625rem 1rem;
  box-sizing: border-box;
  background: transparent;
  border: 0;
  color: #c1c7d0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  list-style: none; /* hide the default <summary> disclosure triangle */
}
.admin-user-toggle::-webkit-details-marker { display: none; }
.admin-user-toggle::marker { content: ""; }
.admin-user-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}
.admin-avatar {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  line-height: 1;
}
.admin-avatar svg { width: 18px; height: 18px; }
.admin-user-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
}
.admin-user-caret {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  opacity: 0.7;
  transition: transform 0.15s ease;
}
.admin-user[open] .admin-user-caret { transform: rotate(180deg); }

/* Pop-up menu (the <details> body). Floats above the toggle. */
.admin-user-menu {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(100% - 0.25rem);
  padding: 0.375rem;
  background: #1f3a5f;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(9, 16, 31, 0.45);
  z-index: 40;
}
.admin-user-menu form {
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  max-width: none;
}
.admin-user-menu a,
.admin-user-menu button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.625rem;
  box-sizing: border-box;
  border-radius: 6px;
  background: transparent;
  border: 0;
  color: #dfe4ec !important;
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}
.admin-user-menu a:hover,
.admin-user-menu button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff !important;
}
.admin-user-menu svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  opacity: 0.8;
}

/* Floating hamburger that opens the off-canvas rail on small viewports. With
   no top bar to host it, it sits as a fixed button over the content; hidden on
   desktop and revealed in the media query below. */
.admin-menu-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 35;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #172b4d;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(9, 16, 31, 0.35);
}
.admin-menu-toggle:hover { background: #1f3a5f; }
.admin-menu-toggle svg {
  width: 22px;
  height: 22px;
}
/* Dim overlay behind the open drawer. Hidden until the drawer opens (and the
   `hidden` attribute keeps it inert on desktop / when closed). */
.admin-nav-backdrop {
  display: none;
}

.admin-main {
  display: block;
  margin-left: var(--admin-sidebar-width);
  padding: 2rem 2rem 4rem;
  min-height: 100vh;
  box-sizing: border-box;
  max-width: none;
  background: var(--bg);
}

/* ───── Compact action buttons in admin list rows ─────
   A list row's action cell packs several controls (status changes, reorder,
   edit, delete). The default button — large, uppercase, solid accent — stacks
   into a wide, noisy mess. Inside a table cell (and inside a `.row-actions`
   cluster) render them small and quiet instead: a tidy wrapping row of
   "secondary" buttons. Applies to every list page with no markup change. */
.admin-main table td form {
  display: inline;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
}
.admin-main table td button,
.admin-main table td input[type="submit"],
.admin-main table td .button-link,
.row-actions button,
.row-actions input[type="submit"],
.row-actions .button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  margin: 0.1rem 0.25rem 0.1rem 0;
  padding: 0.22rem 0.6rem;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg) !important;
  white-space: nowrap;
}
.admin-main table td button:hover,
.admin-main table td input[type="submit"]:hover,
.admin-main table td .button-link:hover,
.row-actions button:hover,
.row-actions .button-link:hover {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--accent) !important;
}
/* In a flex cluster the gap handles spacing — drop the per-button margins. */
.row-actions button,
.row-actions input[type="submit"],
.row-actions .button-link {
  margin: 0;
}
/* Destructive actions (Delete) read red on hover. Covers the `.danger` class
   and the legacy inline `style="color:#b00"` buttons. */
.admin-main table td button.danger:hover,
.row-actions button.danger:hover,
.admin-main table td button[style*="#b00"]:hover {
  background: var(--status-major);
  border-color: var(--status-major);
  color: #ffffff !important;
}
/* Components list: the current status is a filled, non-clickable pill sitting
   among the other status buttons (replaces the old status text column). */
.status-actions button.status-current {
  opacity: 1;
  cursor: default;
  color: var(--accent-fg) !important;
  background: var(--accent);
  border-color: var(--accent);
}

/* ───── Modal (one-time API-token reveal) ───── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(9, 16, 31, 0.55);
}
.modal {
  width: 100%;
  max-width: 30rem;
  box-sizing: border-box;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(9, 16, 31, 0.35);
}
.modal-title {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
}
.modal-sub {
  margin: 0 0 1rem;
  color: var(--fg-muted);
  font-size: 0.9rem;
}
.token-reveal {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.token-value {
  flex: 1 1 auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  word-break: break-all;
  user-select: all;
  color: var(--fg);
}
.copy-token {
  flex: 0 0 auto;
  padding: 0.3rem 0.7rem;
  font-size: 0.8125rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.copy-token:hover {
  background: var(--bg);
  border-color: var(--accent);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
}

/* Bulleted list inside a table cell (e.g. token scopes) — tidier than a
   comma-separated run-on. */
.cell-list {
  margin: 0;
  padding-left: 1.1rem;
  list-style: disc;
}
.cell-list li {
  margin: 0.1rem 0;
}
.cell-muted {
  color: var(--fg-muted);
}

/* Scope checkbox grid (token mint form + permission editor). */
.scope-label {
  margin: 0 0 0.4rem;
  font-weight: 600;
}
.scope-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.4rem 1rem;
  margin-bottom: 1rem;
}
.scope-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ───── Per-page header (title left, action right) ───── */
.admin-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin: 0 0 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.admin-page-title-block { min-width: 0; flex: 1 1 auto; }
.admin-page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--fg);
}
.admin-page-subtitle {
  margin: 0.125rem 0 0;
  color: var(--fg-muted);
  font-size: 0.875rem;
}
.admin-page-action {
  display: inline-block;
  flex: 0 0 auto;
  background: var(--accent);
  color: #ffffff !important;
  padding: 0.5rem 1.125rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  white-space: nowrap;
}
.admin-page-action:hover {
  background: var(--accent-hover);
  color: #ffffff !important;
  text-decoration: none;
}

/* ───── Page analytics bar chart ─────
   30 thin vertical bars in a flex row. Each bar grows up from the
   baseline; the `--accent` fill is what the eye reads. */
.analytics-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 160px;
  margin-bottom: 0.5rem;
}
.analytics-bar {
  flex: 1 1 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
  background: var(--surface-muted);
  border-radius: 2px;
  cursor: default;
}
.analytics-bar-fill {
  width: 100%;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  min-height: 1px;
  transition: opacity 80ms;
}
.analytics-bar:hover .analytics-bar-fill { opacity: 0.75; }
.analytics-axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--fg-muted);
  margin: 0;
}

/* ───── Affected-components checkbox grid (incidents create form) ───── */
fieldset.affected-components {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1.125rem;
  margin: 0 0 1rem;
  background: var(--surface);
}
fieldset.affected-components legend {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg);
  padding: 0 0.375rem;
}
.affected-current {
  color: var(--fg-muted);
  font-size: 0.8125rem;
  margin-left: 0.25rem;
}

/* ───── Sub-tab strip inside a section page ───── */
.admin-subtabs {
  display: flex;
  gap: 0.25rem;
  margin: -0.5rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
}
.admin-subtabs a {
  padding: 0.5rem 0.875rem;
  color: var(--fg-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.admin-subtabs a:hover {
  color: var(--fg);
  text-decoration: none;
}
.admin-subtabs a.active {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

/* ───── Card wrapper used inside admin pages ───── */
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 0 0 1.5rem;
}
.admin-card > table { margin: 0; border: 0; box-shadow: none; }

/* "Please confirm your email" banner on the admin dashboard. Re-uses
   the public `.banner.degraded` colour so it stands out without
   needing a new palette. */
.confirm-email-banner {
  margin-bottom: 1.5rem;
  text-align: left;
  padding: 0.875rem 1.125rem;
}
.confirm-email-banner p { margin: 0; font-size: 0.9375rem; }

/* ───── Incident-update timeline (admin detail) ───── */
.update {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 0 0 0.875rem;
}
.update-head { display: flex; align-items: baseline; justify-content: space-between; }
.update-head h3 { margin: 0; font-size: 1rem; font-weight: 500; }
.update-when { font-weight: 400; color: var(--fg-muted); font-size: 0.875rem; }
.update-body { margin-top: 0.5rem; }
.update-body p:last-child { margin-bottom: 0; }
.update-edit summary {
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--accent);
  margin-top: 0.75rem;
}
.update-edit form { margin-top: 0.75rem; max-width: none; padding: 0; background: transparent; border: 0; box-shadow: none; }
.update-edit textarea { width: 100%; }

/* ───── Apps grid ───── */
.admin-page-intro {
  color: var(--fg-muted);
  max-width: 48rem;
  margin: 0 0 1.5rem;
}
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.125rem 1.25rem;
}
.app-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.app-card-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg);
}
.app-card-category {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-subtle);
}
.app-card-desc {
  margin: 0.625rem 0 0.875rem;
  font-size: 0.9375rem;
  color: var(--fg-muted);
}
.app-card-status {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
}
.app-card-status.native { color: var(--status-ok); }
.app-card-status.preview { color: var(--fg-subtle); }

/* ───── Empty state ───── */
.admin-empty {
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 3rem 1.5rem;
  margin: 0 0 1.5rem;
}
.admin-empty-headline {
  margin: 0 0 0.375rem;
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg);
}
.admin-empty-body {
  margin: 0 auto 1.25rem;
  max-width: 32rem;
  color: var(--fg-muted);
}
/* Admin pages: don't let the existing body :not(:has) fallback re-
   centre content inside the main wrapper. */
body:has(> .admin-sidebar) {
  padding: 0;
}
body:has(> .admin-sidebar) > :not(.admin-sidebar):not(.admin-main):not(.admin-nav-backdrop):not(.admin-menu-toggle) {
  display: none;
}
/* The generic `body:not(:has(> .container)) > *` fallback caps every loose
   child at 850px + auto-centres it. The admin chrome must escape that: the
   sidebar keeps its fixed rail and main clears it. Higher specificity than the
   fallback, so these win. */
body:has(> .admin-sidebar) > .admin-sidebar {
  max-width: none;
  margin: 0;
}
body:has(> .admin-sidebar) > .admin-main {
  max-width: none;
  margin: 0 0 0 var(--admin-sidebar-width);
}
/* The admin pages render their own <h1>; size it for the new layout
   and tighten the gap below it. */
.admin-main h1:first-of-type {
  margin: 0 0 1.5rem;
  font-size: 1.5rem;
  font-weight: 500;
}

/* Small viewports: the rail becomes an off-canvas drawer opened by the floating
   hamburger (wired in app.js). Content uses the whole width with no gutter. */
@media (max-width: 720px) {
  /* Collapses the main-content gutter (keyed off this var) to zero; the drawer
     sets its own width below. */
  :root { --admin-sidebar-width: 0px; }

  .admin-menu-toggle { display: inline-flex; }
  /* The floating hamburger overlays the top-left of the open drawer; indent the
     brand so its text clears the button. */
  .admin-sidebar-brand { padding-left: 3.5rem; }

  /* Off-screen by default; slides in when the body gets `.admin-nav-open`. */
  .admin-sidebar {
    width: min(280px, 82vw);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 25;
    box-shadow: 2px 0 18px rgba(9, 16, 31, 0.35);
  }
  body.admin-nav-open .admin-sidebar {
    transform: translateX(0);
  }
  body.admin-nav-open .admin-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(9, 16, 31, 0.55);
    z-index: 24;
  }

  /* Leave headroom for the floating hamburger. */
  .admin-main {
    padding: 4rem 1rem 3rem;
  }
}

/* ───── 404 page ───── */
.not-found-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  margin-top: 1rem;
}
.not-found-title {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg);
}
.not-found-card p { color: var(--fg-muted); }

/* ───── Incident detail page (/incidents/:id) ───── */
.incident-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 1rem;
}
.incident-detail.impact-minor { border-top: 4px solid var(--status-degraded); }
.incident-detail.impact-major { border-top: 4px solid var(--status-partial); }
.incident-detail.impact-critical { border-top: 4px solid var(--status-major); }
.incident-detail-title {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg);
}
.incident-detail .incident-meta {
  margin: 0 0 1.5rem;
  font-size: 0.875rem;
  color: var(--fg-muted);
}
.incident-timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--border);
}
.timeline-entry {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin: 0;
}
.timeline-entry:last-child { border-bottom: 0; }
.timeline-status { margin: 0 0 0.25rem; color: var(--fg); }
.timeline-when { font-weight: 400; color: var(--fg-muted); font-size: 0.875rem; }
.timeline-body { color: var(--fg); }
.timeline-body p:last-child { margin-bottom: 0; }

/* Published postmortem on /incidents/:id */
.postmortem {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.postmortem-title {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.postmortem-meta {
  margin: 0 0 1rem;
  color: var(--fg-muted);
  font-size: 0.875rem;
}
.postmortem-body { color: var(--fg); }
.postmortem-body p:last-child { margin-bottom: 0; }

/* ───── Page footer (Powered by + feed links) ───── */
.page-footer {
  text-align: center;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--fg-muted);
}
.page-footer p { margin: 0.25rem 0; }
.page-footer .footer-links a { color: var(--fg-muted); }
.page-footer .footer-links a:hover { color: var(--accent); }
.page-footer .powered-by { font-size: 0.8125rem; color: var(--fg-subtle); }

/* Helpers under headings (admin "Signed in as …" + auth "Need an
   account?" lines). */
body > h1 + p { color: var(--fg-muted); }
form:has(label) + p {
  max-width: 30rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--fg-muted);
}
