/* Server-Manager: one small stylesheet, no inline styles (CSP).
   Colours and components follow Website-Builder (web/static/app.css), so both
   tools look like one family: dark by default, light with the ☀ switch
   (cookie sm_theme, rendered as data-theme="light" on <html>). */
:root {
  --bg: #14171c; --panel: #1c2027; --line: #2d333d; --text: #e6e9ef; --muted: #9aa3b2;
  --accent: #4f8cff; --accent-text: #0b0e14; --accent-soft: #1d2b45; --radius: 8px;
  --ok: #4ac26b; --warning: #e3b341; --critical: #ff6b6b; --unknown: #7d8696;
  --ok-bg: #16301f; --warning-bg: #3a3218; --critical-bg: #3d1f1f; --unknown-bg: #252a33;
  --warn-line: #8a6d1d; --code-bg: #111418;
  color-scheme: dark;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg);
}
:root[data-theme="light"] {
  --bg: #f6f7f9; --panel: #ffffff; --line: #e3e6eb; --text: #1d2330; --muted: #677085;
  --accent: #2563eb; --accent-text: #fff; --accent-soft: #e8effd;
  --ok: #1a7f37; --warning: #9a6700; --critical: #c62828; --unknown: #6e7781;
  --ok-bg: #e6f4ea; --warning-bg: #fff6db; --critical-bg: #fdecec; --unknown-bg: #eef0f3;
  --warn-line: #f0c94a; --code-bg: #f0f2f5;
  color-scheme: light;
}
* { box-sizing: border-box; }
/* passkey.js hides passkey buttons in browsers without passkeys; display rules
   on buttons and forms must not bring them back. */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code, pre { font: 12.5px/1.5 ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace; }
small, .meta, .crumbs { color: var(--muted); }
.meta { font-size: .9rem; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
h1 small { font-weight: 500; }
/* Card and section headings: small capitals in the muted colour, like the builder. */
h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .75rem; font-weight: 600; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }

/* --- top bar --- */
.topbar { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 52px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .45rem; font-weight: 700; color: var(--text); margin-right: .4rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { display: block; border-radius: 5px; }
.main-nav { display: flex; gap: .4rem; flex-wrap: wrap; }
.main-nav a, .segmented a, a.button {
  display: inline-flex; align-items: center; padding: .4rem .75rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--text); white-space: nowrap;
}
.main-nav a:hover, .segmented a:hover, a.button:hover { border-color: var(--muted); text-decoration: none; }
.main-nav a[aria-current], .segmented a[aria-current], a.button[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.segmented { display: inline-flex; }
.segmented a { border-radius: 0; margin-left: -1px; }
.segmented a:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.segmented a:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.segmented a:only-child { border-radius: var(--radius); }
.segmented a:hover, .segmented a[aria-current] { position: relative; z-index: 1; }
.spacer { flex: 1; }
.topbar form { margin: 0; }
.account-link { max-width: 18rem; overflow: hidden; text-overflow: ellipsis; }
/* The menu for phones (see the end); wider screens show the links in the bar. */
.menu { display: none; }

main { width: 100%; max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem; flex: 1; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 1.5rem 0 2rem; }

/* --- cards and layout --- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.2rem; margin-bottom: 1rem; overflow-x: auto; }
.card > h2:first-child { margin-top: .1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 1rem; align-items: start; margin-bottom: 1rem; }
.grid > .card { margin-bottom: 0; }
.title-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.title-row h1 { margin-bottom: .5rem; }
.tenant { margin-bottom: 1.75rem; }
.crumbs { margin: 0 0 .5rem; font-size: .9rem; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }
/* Sign-in, two-factor, confirmation and other single forms: a card in the middle, like the builder's. */
.narrow { width: min(420px, 100%); margin: 3rem auto; padding: 1.75rem 2rem; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.narrow h1 { font-size: 1.2rem; }
.narrow > button[data-passkey] { width: 100%; }

/* --- tables, like the builder's admin tables --- */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
table.servers { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; border-collapse: separate; border-spacing: 0; overflow: hidden; }
table.servers th, table.servers td { padding: .6rem .75rem; }
table.servers tbody tr:hover { background: var(--accent-soft); }
table.servers td:nth-child(2) a { white-space: nowrap; font-weight: 600; }
td.barcell { width: 40%; }
td.num { white-space: nowrap; text-align: right; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.25rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.empty { color: var(--muted); padding: .75rem 0; margin: 0; }
.pager { display: flex; gap: 1rem; margin-top: 1rem; }
/* Wide tables that stay tables (the audit log) scroll in their own box. */
.scroll { overflow-x: auto; }
table.audit td.detail { min-width: 14rem; overflow-wrap: anywhere; }

/* --- status: traffic lights --- */
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; background: var(--unknown); flex: none; }
.dot.ok { background: var(--ok); }
.dot.warning { background: var(--warning); }
.dot.critical { background: var(--critical); box-shadow: 0 0 0 3px var(--critical-bg); }
.pill, .tag { display: inline-block; border-radius: 999px; padding: .05rem .55rem; font-size: .78rem; font-weight: 500; background: var(--unknown-bg); color: var(--muted); border: 1px solid transparent; white-space: nowrap; vertical-align: middle; }
.pill.ok, .tag.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warning, .tag.warning { background: var(--warning-bg); color: var(--warning); }
.pill.critical, .tag.critical { background: var(--critical-bg); color: var(--critical); }
.counts { display: flex; gap: .4rem; margin: 0; flex-wrap: wrap; }
ul.problems { margin: 0; padding-left: 0; list-style: none; display: grid; gap: .2rem; }
.problems .warning, .warning-text { color: var(--warning); }
.problems .critical, .critical-text { color: var(--critical); }
.problems .unknown, .unknown-text { color: var(--unknown); }
.problems .note { color: var(--muted); font-size: .85rem; }
.ok-text { color: var(--ok); }
section.websites { margin-bottom: 1.75rem; }
section.websites h2 { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
section.websites h2 a { color: inherit; margin-right: .5rem; }
.app + .app { border-top: 1px solid var(--line); margin-top: .75rem; padding-top: .75rem; }
.app h3 { display: flex; align-items: center; gap: .5rem; }
.app h3 small { font-weight: normal; }
table.checks td { padding: .25rem .4rem; border-bottom: 0; }
table.checks td:first-child { width: 1rem; }

/* --- charts and bars --- */
meter { width: 100%; height: .7rem; }
svg.spark { width: 100%; height: 48px; display: block; margin-bottom: .5rem; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
svg.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
svg.spark polygon { fill: var(--accent); opacity: .18; stroke: none; }
svg.spark line { stroke: var(--line); stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; }
.chart-label { margin: .25rem 0 0; display: flex; justify-content: space-between; }

/* --- messages --- */
.notice { background: var(--ok-bg); color: var(--ok); border-left: 3px solid var(--ok); border-radius: 6px; padding: .55rem .8rem; margin: 0 0 1rem; }
.notice.warning { background: var(--warning-bg); color: var(--warning); border-left-color: var(--warning); }
.error { background: var(--critical-bg); color: var(--critical); border-left: 3px solid var(--critical); border-radius: 6px; padding: .55rem .8rem; }
.error[hidden] { display: none; }
pre.cmd, pre.codes, pre.code { background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; overflow-x: auto; }
pre.cmd, pre.codes { user-select: all; }
pre.codes { columns: 2; }
pre.code { max-height: 40rem; white-space: pre-wrap; word-break: break-word; }
code.secret, code.wrap { word-break: break-all; }
img.qr { display: block; background: #fff; padding: 8px; border-radius: 8px; margin: 1rem 0; }

/* --- forms and buttons, like the builder's --- */
form { margin: 0; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.stack label, .grid-form label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; }
.stack label small, .grid-form label small { font-weight: 400; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: .75rem; align-items: end; }
.inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .25rem 0; }
.inline label { display: flex; gap: .4rem; align-items: center; }
.compact { font-size: .9rem; }
.manage form { margin-bottom: .75rem; }
.or { text-align: center; color: var(--muted); margin: 1rem 0; }
input, select, textarea { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .4rem .55rem; min-width: 0; }
input[type=file] { padding: .3rem; }
input:user-invalid { border-color: var(--critical); }
/* The main action of a form is filled; secondary and danger ones are outlined. */
button { font: inherit; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .3rem; white-space: nowrap;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text); border-radius: var(--radius); padding: .4rem .85rem; }
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .6; cursor: progress; }
button.secondary { background: var(--panel); border-color: var(--line); color: var(--text); }
button.secondary:hover, button.danger:hover, button.icon:hover { filter: none; border-color: var(--muted); }
button.danger { background: var(--panel); border-color: var(--line); color: var(--critical); }
button.icon { background: var(--panel); border-color: var(--line); color: var(--text); padding: .4rem .55rem; line-height: 1; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }
button.link.danger { color: var(--critical); }

/* --- actions and jobs --- */
.actions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(18rem, 100%), 1fr)); gap: 1rem; margin-bottom: 1rem; }
.actions-grid .action { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; }
.actions-grid .action h3 { margin-top: 0; }
.actions-grid .action form { flex: 1; }
.actions-grid .action form > button { margin-top: auto; }
.actions-grid .action button { width: 100%; }

@media (max-width: 700px) {
  main { padding: 1rem .75rem; overflow-wrap: anywhere; }
  .narrow { margin: 1rem auto; padding: 1.25rem; }
  /* A long title wraps beside its status dot, not below it. */
  h1 { font-size: 1.35rem; flex-wrap: nowrap; align-items: baseline; }

  /* Top bar: brand, theme switch and a menu that opens on tap. It is a
     <details>, so it works without script and the browser tells screen
     readers whether it is open. */
  .topbar { position: relative; flex-wrap: nowrap; gap: .4rem; padding: .4rem .6rem; }
  .topbar > .main-nav, .topbar > .segmented, .topbar > .account-link, .topbar > .logout { display: none; }
  .topbar button.icon { min-width: 44px; }
  .menu { display: block; }
  .menu > summary { display: inline-flex; align-items: center; gap: .55rem; min-height: 44px; padding: 0 .85rem; list-style: none; cursor: pointer;
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); user-select: none; }
  .menu > summary::-webkit-details-marker { display: none; }
  .menu > summary:hover { border-color: var(--muted); }
  .menu[open] > summary { background: var(--accent-soft); border-color: var(--accent); }
  .bars, .bars::before, .bars::after { display: block; width: 16px; height: 2px; border-radius: 1px; background: currentColor; }
  .bars { position: relative; }
  .bars::before, .bars::after { content: ""; position: absolute; left: 0; top: -5px; }
  .bars::after { top: 5px; }
  .menu[open] .bars { background: transparent; }
  .menu[open] .bars::before { top: 0; transform: rotate(45deg); }
  .menu[open] .bars::after { top: 0; transform: rotate(-45deg); }
  .menu-panel { position: absolute; left: 0; right: 0; top: 100%; z-index: 10; display: grid; gap: .75rem; padding: .75rem;
    background: var(--panel); border-bottom: 1px solid var(--line); box-shadow: 0 14px 28px rgb(0 0 0 / .3); }
  .menu-panel nav { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
  .menu-panel nav + nav, .menu-account { padding-top: .75rem; border-top: 1px solid var(--line); }
  .menu-panel nav a { display: flex; align-items: center; min-height: 44px; padding: 0 .75rem; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--panel); color: var(--text); }
  .menu-panel nav a:hover { border-color: var(--muted); text-decoration: none; }
  .menu-panel nav a[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
  .menu-account { display: flex; gap: .4rem; }
  .menu-account .account-link { display: block; flex: 1; max-width: none; min-width: 0; line-height: 42px; padding: 0 .75rem; }

  /* Fingertip-sized controls; 16 px text keeps iOS from zooming into fields. */
  button, a.button, select, input:not([type=hidden], [type=checkbox], [type=radio]) { min-height: 44px; }
  input, select, textarea { font-size: 16px; }
  input[type=file] { padding: .55rem; }
  form.inline { flex-direction: column; align-items: stretch; }
  /* Block, not flex: a label's text may hold markup ("Type <strong>web-1</strong> to confirm"). */
  form.inline label { display: block; }
  form.inline label > input, form.inline label > select { display: block; margin-top: .3rem; }
  form.inline button, .stack button, .grid-form button, .actions-grid .action button { width: 100%; }
  /* Compact forms in table cells (users): text and link buttons in a row. */
  form.inline.compact { flex-direction: row; align-items: center; gap: 0 1rem; }
  form.inline.compact button.link { width: auto; }
  .stack input, .stack select, .inline input, .inline select, .grid-form input, .grid-form select { width: 100%; }

  /* Tables become a card per row, a "label: value" line per cell, the
     labels from data-label. Status dot and title share the first line. */
  table.cards, table.cards > tbody { display: block; }
  table.cards > thead { display: none; }
  table.cards > tbody > tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .5rem; margin-bottom: .6rem; padding: .65rem .8rem;
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
  .card table.cards > tbody > tr { margin: 0; padding: .65rem 0; background: none; border: 0; border-top: 1px solid var(--line); border-radius: 0; }
  .card table.cards > tbody > tr:first-child { border-top: 0; padding-top: .2rem; }
  table.cards td { display: block; position: relative; flex: 1 1 100%; min-width: 0; width: auto; padding: .15rem 0 .15rem 7.5rem; border: 0; text-align: left; }
  table.cards td::before { content: attr(data-label); position: absolute; left: 0; top: .3rem; width: 7rem;
    color: var(--muted); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; line-height: 1.3; }
  table.cards td:not([data-label]) { padding-left: 0; }
  table.cards td:not([data-label])::before { content: none; }
  table.cards td.full { padding-left: 0; }
  table.cards td.full::before { position: static; display: block; width: auto; margin-bottom: .2rem; }
  table.cards td:empty { display: none; }
  table.cards td.status { flex: 0 0 auto; order: -2; padding: 0; }
  table.cards td.title { flex: 1 1 0; order: -1; padding: 0 0 .3rem; font-weight: 600; }
  table.cards td.title small { font-weight: 400; }
  table.servers.cards { background: none; border: 0; border-radius: 0; overflow: visible; }
  table.servers.cards tbody tr:hover { background: var(--panel); }
  table.servers td:nth-child(2) a { white-space: normal; }
  /* The audit log stays a table and scrolls sideways in its box. */
  .scroll table.audit { overflow-wrap: normal; }
  .scroll table.audit td:not(.detail) { white-space: nowrap; }
  .scroll table.audit td.detail { min-width: 24rem; overflow-wrap: anywhere; }

  pre { max-width: 100%; }
}
/* Releases: image references and digests are long. */
td.refs div { margin: .1rem 0; }
td.refs small.ref { display: block; overflow-wrap: anywhere; font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace; }
.action select.release { font-weight: 600; }
