:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --sidebar: #ffffff;
  --text: #1c1f24;
  --muted: #6b7280;
  --border: #e3e6ea;
  --hover: #eef1f5;
  --accent: #2f6fde;
  --on-accent: #ffffff;
  --ok: #1f9d55;
  --bad: #d64545;
  --bad-bg: #fdf1f1;
  --warn: #a15c00;
  --sidebar-width: 236px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1d2025;
    --sidebar: #181a1e;
    --text: #e7e9ec;
    --muted: #9aa1ab;
    --border: #2c3037;
    --hover: #24282e;
    --accent: #6c9cf0;
    --on-accent: #0b1220;
    --ok: #3ec27a;
    --bad: #f07272;
    --bad-bg: #2a1d1f;
    --warn: #e8a64a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ------------------------------------------------------------ layout --- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

main { padding: 28px 32px; width: 100%; min-width: 0; }

.mobilebar { display: none; }

/* ----------------------------------------------------------- sidebar --- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  color: var(--accent);
  text-decoration: none;
}
.sidebar > .brand { padding: 2px 10px 18px; color: var(--accent); font-weight: 700; }
.sidebar > .brand:hover { background: none; }

.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li + li { margin-top: 2px; }

.sidebar a,
.sidebar summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  user-select: none;
}
.sidebar a:hover,
.sidebar summary:hover { background: var(--hover); }
.sidebar a:focus-visible,
.sidebar summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.sidebar a[aria-current="page"] {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-weight: 600;
}

.icon { width: 18px; height: 18px; flex: none; color: var(--muted); }
.sidebar a[aria-current="page"] .icon { color: var(--accent); }

/* Settings group */
.sidebar summary { list-style: none; }
.sidebar summary::-webkit-details-marker { display: none; }
.chevron {
  margin-left: auto;
  width: 7px; height: 7px;
  border-right: 1.8px solid var(--muted);
  border-bottom: 1.8px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
details[open] > summary .chevron { transform: rotate(45deg); }
.group ul { margin: 2px 0 4px; }
.group ul a { padding-left: 38px; }

.soon {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--hover);
  border-radius: 99px;
  padding: 1px 7px;
}

.sidebar-foot { margin: auto 0 0; padding: 16px 10px 0; font-size: 12px; }

/* ------------------------------------------------------ narrow screens --- */

@media (max-width: 800px) {
  .shell { display: block; }

  .mobilebar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 10px 16px;
    background: var(--sidebar);
    border-bottom: 1px solid var(--border);
  }

  .menu-toggle {
    display: grid;
    place-items: center;
    width: 36px; height: 36px;
    padding: 0;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 7px;
  }
  .burger, .burger::before, .burger::after {
    display: block;
    width: 16px; height: 2px;
    background: currentColor;
    border-radius: 2px;
    position: relative;
  }
  .burger::before, .burger::after { content: ""; position: absolute; left: 0; }
  .burger::before { top: -5px; }
  .burger::after { top: 5px; }

  .sidebar {
    position: fixed;
    z-index: 30;
    left: 0;
    width: min(280px, 85vw);
    /* Closed: off screen, and hidden so its links can't be tabbed to. */
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.2s, visibility 0s 0.2s;
  }
  .nav-open .sidebar {
    transform: none;
    visibility: visible;
    transition: transform 0.2s;
    box-shadow: 0 0 40px rgb(0 0 0 / 0.25);
  }

  main { padding: 20px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .chevron { transition: none; }
}

/* ------------------------------------------------------------ content --- */

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 15px; margin: 0 0 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card.error { background: var(--bad-bg); border-color: var(--bad); }
.card.error h2 { color: var(--bad); }

.planned .soon { display: inline-block; margin: 0 0 10px; }
.planned p:first-of-type { margin-top: 0; }
.planned h2 { margin-top: 18px; }
.planned ul { margin: 0 0 12px; padding-left: 20px; }
.planned li + li { margin-top: 4px; }

.muted { color: var(--muted); font-size: 13px; }

dl { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; border-top: 0; }

code, pre { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
pre { white-space: pre-wrap; margin: 8px 0 0; }

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--warn); }

@media (max-width: 520px) {
  dl { grid-template-columns: 1fr; }
  dd { margin-bottom: 8px; }
}

/* ---------------------------------------------------- buttons, actions --- */

.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.actions p { margin: 6px 0 0; }

button, a.button {
  display: inline-block;
  font: inherit;
  font-weight: 550;
  color: var(--on-accent);
  background: var(--accent);
  border: 0;
  border-radius: 7px;
  padding: 8px 14px;
  text-decoration: none;
  cursor: pointer;
}
button:hover, a.button:hover { filter: brightness(1.08); }
button:focus-visible, a.button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------- jobs --- */

.pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
}
.pill.ok      { color: var(--ok);     background: color-mix(in srgb, var(--ok) 14%, transparent); }
.pill.bad     { color: var(--bad);    background: color-mix(in srgb, var(--bad) 14%, transparent); }
.pill.warn    { color: var(--warn);   background: color-mix(in srgb, var(--warn) 14%, transparent); }
.pill.running { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }

.result {
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
}
.result.new,
.result.running   { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.result.succeeded { color: var(--ok);     background: color-mix(in srgb, var(--ok) 12%, transparent); }
.result.failed    { color: var(--bad);    background: var(--bad-bg); }
.result.warning   { color: var(--warn);   background: color-mix(in srgb, var(--warn) 12%, transparent); }

.spinner {
  display: inline-block;
  width: 12px; height: 12px;
  margin-right: 6px;
  vertical-align: -1px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.terminal {
  background: #111418;
  color: #d8dee6;
  border-radius: 8px;
  padding: 14px 16px;
  margin: 0 0 10px;
  min-height: 120px;
  max-height: 60vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

/* ---------------------------------------------------------- software --- */

.section-title { margin: 24px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.section-title:first-of-type { margin-top: 0; }

.features { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 8px; }
.features .card { margin: 0; display: flex; flex-direction: column; }
.feature-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.feature h3 { margin: 0; font-size: 16px; }
.feature p { margin: 8px 0 0; }
.feature .soon { margin-left: 0; }
.feature.is-soon h3, .feature.is-soon p { color: var(--muted); }
.feature-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 14px; }

a.button.secondary, button.secondary {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
}
a.button.secondary:hover, button.secondary:hover { background: var(--hover); filter: none; }
a.button.small { padding: 4px 10px; font-size: 13px; }

.pill.neutral { color: var(--muted); background: var(--hover); }
.dot.off { background: var(--muted); }

.table-scroll { overflow-x: auto; }
td { vertical-align: top; }
td code.muted { font-size: 12px; }
.row-actions { text-align: right; white-space: nowrap; }

.result.confirm { color: var(--text); background: color-mix(in srgb, var(--warn) 12%, transparent); font-weight: 500; }
.confirm-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.terminal:empty { display: none; }

/* ------------------------------------------------------- data tables --- */

.card.flush { padding: 0; overflow: hidden; }
.pad { padding: 18px 20px; margin: 0; }
table.data th, table.data td { padding: 12px 16px; vertical-align: middle; }
table.data th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; background: color-mix(in srgb, var(--hover) 60%, transparent); }
table.data tbody tr:hover { background: color-mix(in srgb, var(--hover) 50%, transparent); }
table.data tr.is-soon td { color: var(--muted); }
table.data tr.sub-feature td:first-child { padding-left: 32px; }
.sub-mark { color: var(--muted); margin-right: 6px; }
table.data .soon { margin-left: 0; }
td.nowrap, .nowrap { white-space: nowrap; }
td.prose { max-width: 60ch; }
td strong + br + .pill, td strong + br + .soon { margin-top: 4px; }
.col-actions { text-align: right; white-space: nowrap; width: 1%; }
.col-actions .button + .button { margin-left: 6px; }
code.pkg {
  display: inline-block;
  font-size: 12px;
  padding: 1px 6px;
  margin: 2px 0;
  border-radius: 5px;
  background: var(--hover);
}

/* Things that cannot be undone. */
button.danger, a.button.danger { background: var(--bad); color: #fff; }
a.button.danger-outline { background: transparent; color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 50%, transparent); }
a.button.danger-outline:hover { background: var(--bad-bg); filter: none; }

/* Choices on a confirmation screen. */
.choices { border: 0; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; }
.choice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.choice.danger:has(input:checked) { border-color: var(--bad); background: var(--bad-bg); }
.choice input { margin-top: 4px; accent-color: var(--accent); }
.choice.danger input { accent-color: var(--bad); }

/* On phones, drop secondary columns so the action buttons stay in view. */
@media (max-width: 700px) {
  .hide-narrow { display: none; }
  table.data th, table.data td { padding: 10px 10px; }
  .col-actions .button { margin: 2px 0 2px 4px; }
  .col-actions { white-space: normal; text-align: right; }
}
@media (max-width: 420px) {
  table.data { font-size: 14px; }
  table.data th, table.data td { padding: 10px 6px; }
  table.data th:first-child, table.data td:first-child { padding-left: 10px; }
  table.data th:last-child, table.data td:last-child { padding-right: 10px; }
}

/* Command preview before an action runs. */
.result.review { color: var(--text); background: var(--hover); font-weight: 500; }
.script-title { margin: 16px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
pre.script { min-height: 0; color: #e6edf3; white-space: pre; overflow-x: auto; }
.script-note { margin: 0 0 14px; }

/* Expandable components on the Software page. */
button.expand {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer;
}
button.expand:hover strong { color: var(--accent); }
button.expand:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.chevron {
  width: 8px; height: 8px; flex: none;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform 0.15s;
}
button.expand[aria-expanded="true"] .chevron { transform: rotate(45deg); }
.no-expand { margin-left: 16px; }
td .sub { display: block; margin-left: 16px; font-size: 12px; }
table.data tr.details > td { background: color-mix(in srgb, var(--hover) 45%, transparent); padding: 4px 16px 18px 40px; }
.sub-title { margin: 14px 0 2px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.sub-note { margin: 0 0 8px; max-width: 75ch; }
table.sub-table { width: 100%; }
table.sub-table th, table.sub-table td { padding: 6px 10px 6px 0; vertical-align: middle; }
table.sub-table th { font-size: 12px; }
table.sub-table td.col-actions { padding-right: 0; }
.ext-tools { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 4px 0 8px; }
.ext-filter {
  font: inherit; font-size: 14px; padding: 6px 10px; min-width: 0; width: 240px; max-width: 100%;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: inherit;
}
.ext-all { font-size: 14px; display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
@media (max-width: 700px) {
  table.data tr.details > td { padding: 4px 10px 14px 10px; }
}
.pinned { font-size: 12px; color: var(--warn); white-space: nowrap; }
table.sub-table td.version { overflow-wrap: anywhere; }
td.ext-state { white-space: nowrap; }
@media (max-width: 700px) {
  td.ext-state { white-space: normal; }
  .pinned { white-space: normal; }
}
table.components td.name strong { white-space: nowrap; }
.show-narrow { display: none; }
@media (max-width: 700px) {
  .show-narrow { display: block; margin-top: 2px; }
}
table.sub-table td.version { white-space: nowrap; }
@media (max-width: 700px) {
  table.sub-table td.version { white-space: normal; }
}

/* Domains */
.domain-form { display: grid; gap: 8px; max-width: 560px; }
.field-label { font-weight: 600; font-size: 14px; }
.domain-form input[type="text"], .domain-form select {
  font: inherit; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: inherit; width: 100%;
}
.domain-form input[aria-invalid="true"] { border-color: var(--bad); }
.field-error { color: var(--bad); margin: 0; font-size: 14px; }
fieldset.uses { border: 0; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
label.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
label.check input { margin-top: 4px; }
label.check.is-soon { cursor: default; opacity: 0.7; }
.domain-form button { justify-self: start; }

/* Files a task writes from templates */
.config-file { margin: 0 0 12px; }
.config-file-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; margin-bottom: 6px; font-size: 14px; }
.config-file-head code { font-weight: 600; overflow-wrap: anywhere; }
.lead { max-width: 80ch; margin: -4px 0 16px; color: var(--muted); }
ul.problems { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.card p code, .lead code { overflow-wrap: anywhere; }

/* Tabs in an expanded row */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 6px 0 12px; }
.tabs [role=tab] {
  font: inherit; font-size: 14px; padding: 8px 14px; border: 0; background: none; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.tabs [role=tab]:hover { color: var(--text); }
.tabs [role=tab][aria-selected=true] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs [role=tab]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tab-panel { padding-bottom: 4px; }
.tab-panel > p { margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* git-style diff */
pre.diff {
  background: #111418; color: #d8dee6; border-radius: 8px; padding: 10px 0; margin: 10px 0;
  overflow-x: auto; line-height: 1.45; font-size: 13px;
}
pre.diff span { display: block; padding: 0 14px; white-space: pre; }
pre.diff .meta { color: #e6edf3; font-weight: 600; }
pre.diff .hunk { color: #79c0ff; }
pre.diff .add { color: #7ee787; background: rgba(46, 160, 67, 0.15); }
pre.diff .del { color: #ffa198; background: rgba(248, 81, 73, 0.15); }
/* the characters that changed within a line */
pre.diff mark { color: inherit; border-radius: 2px; }
pre.diff .add mark { background: rgba(46, 160, 67, 0.45); }
pre.diff .del mark { background: rgba(248, 81, 73, 0.45); }
label.check.sub-option { margin-left: 26px; }
table.data tr.details .button.secondary { background: var(--surface); }

/* on/off switch (a link to the run page, so the change is previewed first) */
.switch { display: inline-block; position: relative; width: 40px; height: 22px; border-radius: 11px;
  background: var(--border); vertical-align: middle; transition: background 0.15s; }
.switch span { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: left 0.15s; }
.switch.on { background: var(--ok, #2ea043); }
.switch.on span { left: 21px; }
a.switch:hover { filter: brightness(1.15); }
a.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch.disabled { opacity: 0.5; cursor: not-allowed; }
.switch-note { margin-left: 8px; font-size: 13px; }
details.template-vars { margin-top: 12px; }
details.template-vars summary { cursor: pointer; color: var(--muted); }

/* scheduled tasks */
table.sub-table.facts th { width: 1%; white-space: nowrap; padding-right: 24px; font-weight: 500; color: var(--muted); font-size: 14px; }
.schedule-choice { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 14px 0 4px; }
.button.current { background: var(--accent); color: #fff; border-color: var(--accent); cursor: default; }
.task-actions { margin-top: 12px; }

/* Settings -> Cipher suites: one table, a column per service */
.tls-note { margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
table.tls-suites th.col-service, table.tls-suites td.col-service { text-align: center; width: 1%; white-space: nowrap; }
table.tls-suites tr.group th, table.tls-suites tr.group td { background: color-mix(in srgb, var(--hover) 60%, transparent); font-size: 13px; padding-top: 8px; padding-bottom: 8px; }
table.tls-suites tr.tls-versions th { font-weight: 600; text-align: left; }
table.tls-suites tr.tls-versions th .sub { display: block; font-weight: 400; margin-top: 4px; }
table.tls-suites td.is-soon { opacity: 0.55; }
table.tls-suites td:first-child { width: 2em; }
.tls-choice { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.button.disabled { opacity: 0.5; cursor: not-allowed; }
.small { font-size: 12px; }
.sub { font-size: 12px; }

/* A domain's SSL and PHP tabs */
table.domain-settings td { color: inherit; }
table.domain-settings td.col-switch { width: 1%; white-space: nowrap; text-align: right; padding-right: 0; }
.tab-heading { margin: 18px 0 6px; font-size: 15px; }
.hsts-form { display: grid; gap: 10px; max-width: 560px; margin-top: 10px; }
.hsts-form select { max-width: 220px; }
table.tls-suites tbody th { text-transform: none; letter-spacing: 0; font-size: 14px; background: none; }
table.tls-suites tr.group th { font-weight: 600; }
.hsts-form button { justify-self: start; }
table.domain-settings td { white-space: normal; }

/* Settings -> Integrations */
.token-form { display: grid; gap: 8px; max-width: 560px; margin-top: 18px; }
.token-form button { justify-self: start; }
.token-form input[type="password"] { font: inherit; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: inherit; width: 100%; box-sizing: border-box; }
.status-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.notice.ok { color: var(--ok); }

/* Sortable table headers */
th button.sort { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; }
th button.sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
th button.sort::after { content: "↕"; opacity: 0.35; font-size: 11px; }
th[aria-sort="ascending"] button.sort::after { content: "↑"; opacity: 0.9; }
th[aria-sort="descending"] button.sort::after { content: "↓"; opacity: 0.9; }

/* Mail */
.token-form input[type="text"], .mailbox-form input {
  font: inherit; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: inherit; width: 100%; box-sizing: border-box; }
.token-form input[aria-invalid="true"], .mailbox-form input[aria-invalid="true"] { border-color: var(--bad); }
.mailbox-form { display: grid; gap: 8px; max-width: 560px; margin: 4px 0 12px; }
.mailbox-form button { justify-self: start; }
.address-input { display: flex; align-items: center; gap: 6px; }
.address-input input { flex: 1; min-width: 0; }
table.mailboxes { margin-bottom: 8px; }

/* Cipher suites form: switches and presets are form inputs (a preview until Save) */
label.switch { cursor: pointer; }
label.switch input, label.preset input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
label.switch:has(input:checked) { background: var(--ok, #2ea043); }
label.switch:has(input:checked) span { left: 21px; }
label.switch:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }
label.switch:has(input:focus-visible), label.preset:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
label.preset { position: relative; cursor: pointer; display: block; text-align: center; font-weight: 550; font-size: 13px; padding: 4px 10px;
  border-radius: 7px; color: var(--text); background: transparent; border: 1px solid var(--border); }
label.preset:hover { background: var(--hover); }
label.preset:has(input:checked), label.preset:has(input:checked):hover { background: var(--accent); color: #fff; border-color: var(--accent); }
label.preset:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }
.tls-save[hidden] { display: none; }
.tls-save { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 12px 0; background: var(--bg); }


/* Domains: DNS tab */
table.dns-records td.dns-content code { overflow-wrap: anywhere; word-break: break-all; font-size: 12px; }

.small-note { font-size: 13px; margin: 6px 0 0; }
/* A record Cloudflare has with another value: - now, + what Sync makes of it. */
.dns-diff { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.dns-diff span { display: block; padding: 1px 6px; white-space: pre-wrap; word-break: break-all; }
.dns-diff .del { color: #ffa198; background: rgba(248, 81, 73, 0.15); border-radius: 4px 4px 0 0; }
.dns-diff .add { color: #7ee787; background: rgba(46, 160, 67, 0.15); border-radius: 0 0 4px 4px; }
.dns-diff span:only-child { border-radius: 4px; }
.dns-diff mark { color: inherit; border-radius: 2px; }
.dns-diff .del mark { background: rgba(248, 81, 73, 0.45); }
.dns-diff .add mark { background: rgba(46, 160, 67, 0.45); }

/* What is wrong with an installed feature's configuration (Software). */
.feature-problem { display: block; margin-top: 4px; max-width: 260px; white-space: normal; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

/* Aliases of a mailbox (domain Mail tab). */
td.aliases .alias { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
td.aliases .alias-remove { font-size: 12px; }
td.aliases .alias-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 2px; }
td.aliases .alias-form input[type=text] { width: 9em; }

/* Features & Software: a full-width card per feature, its switch on the
   right. The feature is the big thing; its enhancements are smaller, indented
   below it. */
.feature-card h2 { margin: 0 0 6px; font-size: 22px; font-weight: 700; text-transform: none; letter-spacing: 0; color: var(--text); }
.feature-head p { font-size: 15px; }
.feature-head, .enhancements li { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.feature-head p, .enhancements p { margin: 0; }
.feature-head .switch, .enhancements .switch { flex: none; margin-top: 4px; }
.feature-card .sub-title { margin: 18px 0 4px; font-size: 11px; }
.enhancements { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--border); }
.enhancements li { padding: 6px 0; align-items: center; }
.enhancements li + li { border-top: 1px solid var(--border); }
.enhancements strong { font-size: 13px; font-weight: 600; }
.enhancements p { font-size: 12px; }
/* name | description | switch: the names get one fixed width on every card,
   so every description starts at the same place */
.enhancements li { display: grid; grid-template-columns: 8.5rem 1fr auto; column-gap: 16px; }
.enhancements .switch { transform: scale(0.8); transform-origin: right center; margin-top: 0; }
button.switch { border: 0; padding: 0; cursor: pointer; font: inherit; }
button.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.switch:disabled { opacity: 0.4; cursor: not-allowed; }

/* Fail2Ban: the rule forms read as a sentence */
/* A page's title with its on/off switch at the right */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.page-head h1 { margin-right: auto; }
.page-head .switch { flex: none; }
/* The red mark in the menu: something there needs repair. */
.menu-alert { margin-left: auto; flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bad); color: #fff; font-size: 12px; font-weight: 700; line-height: 1; }
/* Things in a page head right of the title: a state, a button, the switch. */
.head-actions { display: flex; align-items: center; gap: 10px; flex: none; }

/* Tabs that are pages (links) */
/* Page tabs scroll sideways on a narrow screen. A scroll box clips what
   sticks out, so the gray line is drawn inside (a shadow, under the tabs)
   and the tabs don't hang over it: nothing to scroll up and down. */
.tabs.page-tabs { margin: 0 0 16px; overflow-x: auto; overflow-y: hidden; border-bottom: 0; box-shadow: inset 0 -1px var(--border); }
.tabs.page-tabs a { margin-bottom: 0; }
.tabs a {
  font-size: 14px; padding: 10px 16px; color: var(--muted); text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); }
.tabs a.tab-end { margin-left: auto; }
.tabs a[aria-current=page] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.page-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
table.data td.inherited { color: var(--muted); }

/* Settings forms: a label and its field per row */
.settings-form { display: grid; gap: 18px; max-width: 640px; }
.settings-form .form-row { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 8px 24px; align-items: center; }
.settings-form .form-row > label, .settings-form .form-label { font-weight: 550; font-size: 14px; }
.settings-form input[type=text], .settings-form input[type=number], .settings-form input[type=password], .settings-form select {
  font: inherit; height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: inherit; width: 100%; max-width: 360px; box-sizing: border-box;
}
.settings-form input:focus, .settings-form select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
.settings-form input::placeholder { color: var(--muted); }
.settings-form .input-group { display: flex; gap: 8px; max-width: 360px; }
.settings-form .input-group input { flex: 1 1 0; min-width: 0; }
.settings-form .input-group select { flex: 0 0 130px; }
.settings-form .form-value { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 38px; }
.settings-form .input-suffix { align-self: center; color: var(--muted); font-size: 14px; }
.settings-form .form-actions { display: flex; gap: 8px; padding-left: 204px; }
.settings-form .form-note { margin: -6px 0 0 204px; color: var(--muted); font-size: 13px; }
.settings-form .form-success {
  margin: 0; padding: 10px 14px; border-radius: 7px; font-size: 14px;
  color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent);
}
.settings-form button:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.settings-form .form-error {
  margin: 0; padding: 10px 14px; border-radius: 7px; font-size: 14px;
  color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent);
}
@media (max-width: 620px) {
  .settings-form .form-row { grid-template-columns: 1fr; gap: 6px; }
  .settings-form .form-actions { padding-left: 0; }
  .settings-form .form-note { margin-left: 0; }
}

/* Progress of an action running in the background (not developer mode). */
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 50; max-width: min(420px, calc(100vw - 32px));
  padding: 10px 14px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3); font-size: 14px; display: flex; gap: 8px; align-items: center; }
.toast[hidden] { display: none; }
.toast.succeeded { border-color: var(--ok, #2ea043); }
.toast.failed { border-color: var(--bad); }
.toast a { white-space: nowrap; }

/* DNS tab: the sync switch, its state and Sync Now on one line. */
.dns-sync { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; }
.dns-sync .form-label { font-weight: 600; }

/* Features: an icon per feature (a tile) and per additional feature. */
.feature-icon { flex: none; width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, transparent); }
.feature-icon .icon { width: 24px; height: 24px; color: var(--accent); }
.feature-head .feature-text { flex: 1; min-width: 0; }
.enhancements li { grid-template-columns: 18px 8.5rem 1fr auto; }
.enhancement-icon { display: grid; place-items: center; }
.enhancement-icon .icon { width: 16px; height: 16px; }
@media (max-width: 600px) { .enhancements li { grid-template-columns: 18px 1fr auto; } .enhancements li p { grid-column: 2 / 3; } }

/* A page under a list: a round back button, then its title. */
.title-back { display: flex; align-items: center; justify-content: flex-start; gap: 12px; min-width: 0; }
.title-back { margin: 0 0 16px; flex-wrap: wrap; row-gap: 10px; }
/* The title takes the line; what is right of it wraps below on a phone. */
.title-back h1 { margin: 0 auto 0 0; overflow-wrap: anywhere; flex: 1 1 14rem; min-width: 0; }
.back-button { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); }
.back-button:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.back-button .icon { width: 20px; height: 20px; color: var(--text); }

/* An icon link in the page head, e.g. the Mail page's settings. */
.icon-button { flex: none; width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; }
.icon-button:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.icon-button .icon { width: 22px; height: 22px; color: var(--muted); }
.icon-button:hover .icon { color: var(--accent); }

/* Mail -> Filter Rules and Quarantine */
.notice.warn { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; border-radius: 8px;
  color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.notice.warn span { flex: 1 1 20rem; }
table.filter-rules .col-order { width: 2.5rem; }
table.filter-rules .filter-words { max-width: 24rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-frame { display: block; width: 100%; height: 70vh; min-height: 360px; border: 0; border-radius: inherit; background: #fff; resize: vertical; }
.mail-facts th { width: 8rem; }
.mail-link-url code { overflow-wrap: anywhere; word-break: break-all; font-size: 12px; }
textarea { font: inherit; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  color: inherit; width: 100%; box-sizing: border-box; resize: vertical; }
/* A small icon link in a table row (quarantine: inbox, spam, delete). */
.row-icon { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--border);
  color: var(--muted); vertical-align: middle; }
.row-icon + .row-icon { margin-left: 4px; }
.row-icon .icon { width: 16px; height: 16px; }
.row-icon:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.row-icon.disabled { opacity: .35; }
.row-icon.danger:hover { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
td.mail-address { min-width: 7rem; }
/* A table inside an expanded row scrolls on its own instead of widening the
   table it is in (width 0 keeps it out of the cell's width; min-width fills it). */
table.data tr.details > td > .table-scroll { width: 0; min-width: 100%; overflow-x: auto; }

/* Dashboard graphs. */
.charts { display: grid; gap: 16px; }
.chart-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 12px; }
.chart-head h2 { margin: 0; }
.chart-now { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-pointer { margin-left: auto; font-variant-numeric: tabular-nums; }
.chart-plot { position: relative; }
.chart-plot svg { display: block; width: 100%; height: 160px; overflow: visible; touch-action: pan-y; }
.chart-plot .grid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-plot .grid.base { stroke: var(--muted); opacity: .5; }
.chart-plot .line { fill: none; stroke: var(--chart); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart-plot .dot { stroke-width: 4; stroke-linecap: round; }
.chart-plot .area { fill: var(--chart); opacity: .12; stroke: none; }
.chart-plot .cursor { display: none; stroke: var(--muted); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-plot .cursor.on { display: inline; }
.chart-plot .y-label { position: absolute; left: 4px; font-size: 11px; line-height: 1; color: var(--muted); pointer-events: none; }
.chart-plot .y-top { top: 3px; }
.chart-plot .y-mid { top: calc(50% + 3px); }
.x-labels { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-empty { margin: 0; }
.chart-cpu { --chart: var(--accent); }
.chart-mem { --chart: #8a5cd6; }
.chart-disk { --chart: var(--ok); }
@media (prefers-color-scheme: dark) { .chart-mem { --chart: #a98ae8; } }
@media (max-width: 560px) { .x-labels span:nth-child(even) { display: none; } }

/* Tables of the same kind (the addresses of each domain on Mail, the records
   of each domain on DNS) get the same columns, whatever is in them: fixed
   widths, the first or the content column taking the rest. */
table.mailbox-table, table.dns-records { table-layout: fixed; min-width: 600px; }
table.mailbox-table { min-width: 700px; }
table.mailbox-table th:nth-child(2) { width: 80px; }
table.mailbox-table th:nth-child(3) { width: 100px; }
table.mailbox-table th:nth-child(4) { width: 90px; }
table.mailbox-table th:nth-child(5) { width: 100px; }
table.mailbox-table th:nth-child(6) { width: 96px; }
table.mailbox-table td:first-child { white-space: normal; overflow-wrap: anywhere; }
table.dns-records th:nth-child(1) { width: 30%; }
table.dns-records th:nth-child(2) { width: 72px; }
table.dns-records th:nth-child(4) { width: 112px; }
table.dns-records td:first-child code { overflow-wrap: anywhere; }

/* The sidebar's foot: Log Out and the version. */
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-foot form { margin: 0; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; }
.link-button:hover { color: var(--accent); text-decoration: underline; }

/* The login page: a card in the middle, without the menu. */
main.bare { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; margin: 0; }
.login-card h1 { font-size: 20px; margin: 0 0 16px; }
.login-brand { margin: 0 0 20px; font-weight: 700; color: var(--accent); }
.login-form { display: grid; gap: 6px; }
.login-form label { font-size: 13px; font-weight: 600; margin-top: 8px; }
.login-form button { margin-top: 16px; }
.login-card pre { white-space: pre-wrap; }
.login-form input { font: inherit; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: inherit; width: 100%; box-sizing: border-box; }
.login-form input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
.login-form .form-error { margin: 0 0 4px; padding: 10px 14px; border-radius: 7px; font-size: 14px;
  color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }
