/* angel-ops-panel — minimal hand-written styles, no framework, no CDN assets. */

:root {
  /* Native widgets (scrollbars, date pickers, select popups) follow the
     theme instead of the OS preference. */
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #5f6d80;
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --danger-bg: #fdecea;
  --danger-text: #8a1f11;
  --info-bg: #eef2ff;
  --info-text: #3730a3;
  --radius: 10px;
  --on-accent: #fff;
  --shadow: rgba(15, 23, 42, 0.08);
  --backdrop: rgba(31, 41, 51, 0.4);
  --warning-bg: #fff6e5;
  --warning-text: #7a4b00;
  --warning-border: #f0d9a8;
  --success-bg: #e5f5e9;
  --success-text: #1c6b2f;
  --success-border: #b7e0c1;
  --neutral-bg: #eef1f4;
  --neutral-text: #3d4852;
  --code-bg: #f1f5f9;
  --danger-btn: #b3261e;
  --danger-btn-hover: #8f1d17;
  --danger-border: #f3c1bc;
  --info-border: #c7d2fe;
  --dispatched-bg: #e7edf7;
  --dispatched-text: #2c4b7c;
  --dispatched-border: #b9c9e6;
  --purple-bg: #f4ecfd;
  --purple-text: #54318c;
  --purple-border: #d9c7f5;
  --target-green: #1e7e34;
  --retired-bg: #eceff1;
  --retired-text: #455a64;
  --retired-border: #90a4ae;
}

/* Angel theme: the PROYECTO ÁNGEL brand palette — white surfaces with a teal
   accent. The site link colour (#39b7e5) is too light for text on white, so
   the accent is its darkened WCAG AA pair. Same var names; every text pair
   stays above WCAG AA (>= 4.5:1). */
[data-theme="angel"] {
  color-scheme: light;
  --bg: #f2f7f8;
  --surface: #ffffff;
  --border: #cfe0e5;
  --text: #12303b;
  --muted: #4e6b76;
  --accent: #0e7490;
  --accent-dark: #155e75;
  --danger-bg: #fdecea;
  --danger-text: #8a1f11;
  --info-bg: #e0f2f7;
  --info-text: #0c546b;
  --on-accent: #ffffff;
  --shadow: rgba(18, 48, 59, 0.1);
  --backdrop: rgba(18, 48, 59, 0.45);
  --warning-bg: #fff6e5;
  --warning-text: #7a4b00;
  --warning-border: #e6cf9a;
  --success-bg: #e3f5ea;
  --success-text: #1c6b2f;
  --success-border: #b0ddc0;
  --neutral-bg: #eaf1f2;
  --neutral-text: #35505a;
  --code-bg: #eef5f6;
  --danger-btn: #b3261e;
  --danger-btn-hover: #8f1d17;
  --danger-border: #f0c4bf;
  --info-border: #a9d8e5;
  --dispatched-bg: #e4eef7;
  --dispatched-text: #2c4b7c;
  --dispatched-border: #b9c9e6;
  --purple-bg: #f1eafc;
  --purple-text: #54318c;
  --purple-border: #d9c7f5;
  --target-green: #1e7e34;
  --retired-bg: #e9eef0;
  --retired-text: #455a64;
  --retired-border: #90a4ae;
}

/* Dark theme: same vars, dark surfaces with lifted text and accent. */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f17;
  --surface: #111827;
  --border: #1f2937;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #818cf8;
  --accent-dark: #a5b4fc;
  --danger-bg: #3a201c;
  --danger-text: #f2b8ae;
  --info-bg: #1e1b4b;
  --info-text: #c7d2fe;
  --on-accent: #10151b;
  --shadow: rgba(0, 0, 0, 0.5);
  --backdrop: rgba(0, 0, 0, 0.6);
  --warning-bg: #3a2c10;
  --warning-text: #f2cd8a;
  --warning-border: #7a5a1e;
  --success-bg: #14301d;
  --success-text: #8fd6a4;
  --success-border: #2c6b41;
  --neutral-bg: #232c35;
  --neutral-text: #c3ccd5;
  --code-bg: #232c35;
  --danger-btn: #c0392b;
  --danger-btn-hover: #e05a50;
  --danger-border: #7a3a33;
  --info-border: #3730a3;
  --dispatched-bg: #1d2c44;
  --dispatched-text: #a9c2ee;
  --dispatched-border: #334f7e;
  --purple-bg: #2c2140;
  --purple-text: #cdb4f5;
  --purple-border: #5b4391;
  --target-green: #7bd88f;
  --retired-bg: #232c35;
  --retired-text: #9fabb8;
  --retired-border: #4a5866;
}

/* High-contrast theme: black surfaces, white text, bright accents. */
[data-theme="high-contrast"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #000000;
  --border: #ffffff;
  --text: #ffffff;
  --muted: #e6e6e6;
  --accent: #ffd600;
  --accent-dark: #fff176;
  --danger-bg: #000000;
  --danger-text: #ff9d94;
  --info-bg: #00263f;
  --info-text: #bfe3ff;
  --on-accent: #000000;
  --shadow: rgba(255, 255, 255, 0.35);
  --backdrop: rgba(0, 0, 0, 0.8);
  --warning-bg: #000000;
  --warning-text: #ffcf4d;
  --warning-border: #ffcf4d;
  --success-bg: #00220f;
  --success-text: #7dffa8;
  --success-border: #7dffa8;
  --neutral-bg: #1a1a1a;
  --neutral-text: #ffffff;
  --code-bg: #1a1a1a;
  --danger-btn: #c00000;
  --danger-btn-hover: #ff0000;
  --danger-border: #ff9d94;
  --info-border: #bfe3ff;
  --dispatched-bg: #001a4d;
  --dispatched-text: #cfe4ff;
  --dispatched-border: #cfe4ff;
  --purple-bg: #2a0052;
  --purple-text: #e3c8ff;
  --purple-border: #e3c8ff;
  --target-green: #7dffa8;
  --retired-bg: #000000;
  --retired-text: #e6e6e6;
  --retired-border: #ffffff;
}

/* Sepia theme: warm, low-glare light surfaces for long sessions. Same var
   names; every text pair stays above WCAG AA (>= 4.5:1). */
[data-theme="sepia"] {
  color-scheme: light;
  --bg: #f0e7d5;
  --surface: #faf4e6;
  --border: #c9b48d;
  --text: #3a2f1d;
  --muted: #6a5a3d;
  --accent: #8a4b0f;
  --accent-dark: #6f3a08;
  --danger-bg: #f7e0d8;
  --danger-text: #8a2110;
  --info-bg: #e4eadb;
  --info-text: #2f4a2a;
  --on-accent: #fff8ea;
  --shadow: rgba(58, 47, 29, 0.12);
  --backdrop: rgba(58, 47, 29, 0.45);
  --warning-bg: #f6e7c2;
  --warning-text: #6b4a00;
  --warning-border: #cfa94e;
  --success-bg: #e3ecd6;
  --success-text: #2d5b1f;
  --success-border: #a9c78a;
  --neutral-bg: #ece3d0;
  --neutral-text: #4a4030;
  --code-bg: #eee4cd;
  --danger-btn: #a8321c;
  --danger-btn-hover: #872615;
  --danger-border: #d9a99b;
  --info-border: #b3bfa8;
  --dispatched-bg: #e5e3d2;
  --dispatched-text: #3f4a2e;
  --dispatched-border: #b5b79a;
  --purple-bg: #ece2ec;
  --purple-text: #5a3760;
  --purple-border: #c9b0cd;
  --target-green: #2d6b2f;
  --retired-bg: #e8e0cf;
  --retired-text: #4f4739;
  --retired-border: #a89b82;
}

/* Midnight theme: deep blue surfaces with cool accents, for night shifts.
   Same var names; every text pair stays above WCAG AA (>= 4.5:1). */
[data-theme="midnight"] {
  color-scheme: dark;
  --bg: #080c18;
  --surface: #0f172a;
  --border: #1e2a44;
  --text: #e6edf7;
  --muted: #94a3b8;
  --accent: #818cf8;
  --accent-dark: #a5b4fc;
  --danger-bg: #34191d;
  --danger-text: #f4b3b8;
  --info-bg: #1e1b4b;
  --info-text: #c7d2fe;
  --on-accent: #08111f;
  --shadow: rgba(0, 0, 0, 0.55);
  --backdrop: rgba(0, 0, 0, 0.65);
  --warning-bg: #33280f;
  --warning-text: #f2cd8a;
  --warning-border: #6d561f;
  --success-bg: #10281c;
  --success-text: #8adcaa;
  --success-border: #2b6042;
  --neutral-bg: #1c2739;
  --neutral-text: #c2cee0;
  --code-bg: #1b2537;
  --danger-btn: #c34a52;
  --danger-btn-hover: #e06b73;
  --danger-border: #713a40;
  --info-border: #3730a3;
  --dispatched-bg: #172439;
  --dispatched-text: #a9c2ee;
  --dispatched-border: #30486f;
  --purple-bg: #241d3a;
  --purple-text: #cdb4f5;
  --purple-border: #4f3f74;
  --target-green: #7bd8a4;
  --retired-bg: #1a2436;
  --retired-text: #9db0c9;
  --retired-border: #45566f;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

/* Text controls: the UA paints them with `color: fieldtext` (black under a
   light OS preference), so a themed background alone left the collapsed
   select value and the inputs unreadable on dark surfaces. Pin text and
   surface together here; the per-form rules below only size and space them. */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  color: var(--text);
  background: var(--surface);
}

/* --- Top bar -------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex: none;
  border-radius: calc(var(--radius) + 2px);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: var(--on-accent);
  box-shadow: 0 6px 16px var(--shadow);
}

.brand-mark .icon {
  width: 1.35rem;
  height: 1.35rem;
  stroke-width: 1.9;
}

.brand-text {
  font-size: 0.98rem;
}

.session {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-card {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.3rem 0.45rem 0.3rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  flex: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: var(--on-accent);
  font-size: 0.72rem;
  font-weight: 700;
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.session .user {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}

.session .role {
  padding: 0.1rem 0.45rem;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.session form {
  margin: 0;
}

.signout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--danger-btn) 35%, transparent);
  border-radius: calc(var(--radius) + 2px);
  background: color-mix(in srgb, var(--danger-btn) 10%, transparent);
  color: var(--danger-text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.signout:hover {
  background: color-mix(in srgb, var(--danger-btn) 18%, transparent);
}

.signout .icon {
  width: 1em;
  height: 1em;
}

/* --- Buttons -------------------------------------------------------------- */

/*
 * Button convention (all templates):
 * - Primary action ("grabar": Create / Save / Add / Filter / Test / sign-in): a plain
 *   <button> or <a class="button"> — accent background, white text.
 * - "Volver atrás" navigation (Back to list / Back to users / Clear filters):
 *   <a class="button button-secondary"> — never a bare link, so back-navigation
 *   reads as a button everywhere.
 * - Non-destructive secondary choices (Refresh options, quick times, Set default):
 *   .button-secondary on the accent outline. The create form's Refresh options
 *   is a plain .refresh-link instead: a small secondary GET that only reloads
 *   the project list and never creates anything.
 * - Destructive actions (Cancel action, Deactivate server, Delete webhook) keep
 *   .button-danger for the irreversible one (cancel) and a data-confirm for the
 *   rest: .button-danger is reserved for destructive actions only, never for
 *   primary or navigation buttons.
 */

button {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

/* --- Dashboard placeholder ------------------------------------------------ */

.container {
  max-width: 60rem;
  margin: 2rem auto;
  padding: 0 1.25rem;
}

.container h1 {
  font-size: 1.4rem;
  margin: 0 0 1rem;
}

.placeholder {
  padding: 2rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}

/* --- Login ---------------------------------------------------------------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  width: 100%;
  max-width: 22rem;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px var(--shadow);
}

.login-card .brand {
  margin: 0;
  font-size: 1.35rem;
}

.login-card .tagline {
  margin: 0.15rem 0 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-card form {
  display: flex;
  flex-direction: column;
}

.login-card label {
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.login-card input {
  margin-bottom: 0.9rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
}

.login-card input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.alert {
  margin-bottom: 1rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.alert-info {
  background: var(--info-bg);
  color: var(--info-text);
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

/* --- Top bar navigation --------------------------------------------------- */

.mainnav {
  display: flex;
  gap: 1rem;
}

.mainnav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2rem;
}

.mainnav a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) + 2px);
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.mainnav a:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 6%, transparent);
}

.mainnav .icon {
  color: currentColor;
  transition: color 0.15s ease;
}

.mainnav a[aria-current="page"] {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-decoration: none;
}

.mainnav a[aria-current="page"] .icon {
  color: var(--accent);
}

/* --- Servers screen ------------------------------------------------------- */

.panel {
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.inline-form {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.inline-form label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.inline-form input {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
}

.hint {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.table th,
.table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* Reported projects nested under each server row (acceptance #8): project name as
   its own link, then the container table (name, state, image tag). */
.reported-project {
  margin-top: 0.65rem;
}

.reported-project:first-child {
  margin-top: 0;
}

.reported-project .project-name {
  font-weight: 600;
}

.reported-project .table {
  margin-top: 0.35rem;
}

.chip {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.chip-online {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.chip-offline {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

code.token {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  word-break: break-all;
}

/* --- Actions screen ------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-dark);
}

.button-secondary {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}

.button-secondary:hover {
  background: var(--info-bg);
}

.button-danger {
  background: var(--danger-btn);
  border-color: var(--danger-btn);
}

.button-danger:hover {
  background: var(--danger-btn-hover);
}

.page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.page-actions h1 {
  margin: 0;
}

/* Action state chips: one color per state of the state machine. */
.chip-pending {
  background: var(--neutral-bg);
  color: var(--neutral-text);
  border: 1px solid var(--border);
}

.chip-queued {
  background: var(--info-bg);
  color: var(--info-text);
  border: 1px solid var(--info-border);
}

.chip-dispatched {
  background: var(--dispatched-bg);
  color: var(--dispatched-text);
  border: 1px solid var(--dispatched-border);
}

.chip-running {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

.chip-succeeded {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.chip-failed {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

.chip-skipped {
  background: var(--purple-bg);
  color: var(--purple-text);
  border: 1px solid var(--purple-border);
}

.chip-cancelled {
  background: var(--code-bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* Action type chips: same families as the state chips (neutral / blue / purple). */
.chip-restart {
  background: var(--neutral-bg);
  color: var(--neutral-text);
  border: 1px solid var(--border);
}

.chip-update {
  background: var(--info-bg);
  color: var(--info-text);
  border: 1px solid var(--info-border);
}

.chip-upgrade {
  background: var(--purple-bg);
  color: var(--purple-text);
  border: 1px solid var(--purple-border);
}

a.key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--accent);
  font-weight: 600;
}

/* --- Create form ---------------------------------------------------------- */

.action-form {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.action-form .field {
  margin-bottom: 1rem;
}

.action-form label,
.action-form legend {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.action-form fieldset {
  margin: 0 0 1rem;
  padding: 0;
  border: none;
}

.action-form select,
.action-form input[type="datetime-local"] {
  min-width: 16rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
}

.action-form .radio {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.3rem;
  font-weight: 400;
}

.action-form .radio input {
  margin: 0;
}

.field-error {
  margin: 0.3rem 0 0;
  color: var(--danger-text);
  font-size: 0.85rem;
  font-weight: 600;
}

.form-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.form-actions button.button-secondary {
  background: var(--surface);
  color: var(--accent);
}

/* Quick schedule buttons above the datetime input (progressive enhancement). */
.quick-times {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.quick-times button {
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
  background: var(--surface);
  color: var(--accent);
}

/* Composed schedule value: display text in the accent color, not an editor. */
dialog #scheduledAt.composed {
  border: none;
  background: transparent;
  padding-left: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
}

/* Clashing times in the overlap box: bold and danger-colored so the collision
   reads at a glance, not as one more ISO timestamp. */
.pending-list time.clash {
  font-weight: 700;
  color: var(--danger-text);
}

/* Upcoming-actions rows (new-action preview, overlap box): no bullets, air
   between rows and between the row data (chip, time, key). */
.pending-list {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
}
.pending-list > li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--border);
}

/* The pending preview reads as its own card/column: info tint so it is
   unmistakable next to the form steps, stacked or docked. */
.steps > #pendingStep {
  background: var(--info-bg);
  border-top: none;
  border-radius: var(--radius);
  padding: 1rem;
}

/* Desktop: the pending preview docks to the right of the new-action form
   while the steps stack on the left. Mobile stays stacked as before: below
   the breakpoint nothing here applies. The dialog only goes wider than the
   shared 52rem width when it actually hosts a preview. */
@media (min-width: 60rem) {
  dialog#action-dialog:has(#pendingStep) {
    width: min(60rem, calc(100vw - 2rem));
    max-width: 60rem;
  }
  .steps:has(#pendingStep) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(15rem, 20rem);
    gap: 0 2rem;
    align-items: start;
  }
  .steps > #pendingStep {
    grid-column: 2;
    grid-row: 1 / span 20;
  }
}

/* --- Stepped create form (where -> when -> what -> details) ----------------- */

/* Numbered steps reuse the form card: no extra chrome, just rhythm. */
.steps {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.step {
  margin: 0;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}

.step:first-child {
  border-top: none;
  padding-top: 0;
}

.step h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

/* Segmented trigger (Now / Scheduled): one control, two options. */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.segmented .radio {
  margin: 0;
  padding: 0.45rem 1rem;
  cursor: pointer;
}

.segmented .radio + .radio {
  border-left: 1px solid var(--border);
}

.segmented .radio:has(input:checked) {
  background: var(--accent);
  color: var(--on-accent);
}

.segmented .radio input {
  accent-color: var(--accent);
}

/* Conditional details blocks toggle without shifting the form abruptly. */
.conditional {
  overflow: clip;
}

.conditional[hidden] {
  display: none;
}

/* Small secondary GET that only reloads options — never a primary button. */
.refresh-link {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.refresh-link:hover {
  background: none;
  color: var(--accent-dark);
}

/* Legends that only exist for assistive technology. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- Settings: alert webhook form ------------------------------------------ */

.settings-form {
  margin-bottom: 1rem;
}

.settings-form label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.settings-form input[type="url"] {
  min-width: 24rem;
  max-width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
}

.settings-form .field {
  margin-bottom: 0.5rem;
}

/* --- Action detail: record + event timeline -------------------------------- */

.record {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.1rem;
  margin: 0;
}

.record dt {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.record dd {
  margin: 0;
  word-break: break-word;
}

#cancel-form {
  margin-top: 1rem;
}

.timeline {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
}

.timeline .event {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}

.timeline .event-at {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.event-level {
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--info-text);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.event-level.level-warn {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.event-message {
  flex: 1;
  word-break: break-word;
}

/* --- P1 UI polish ------------------------------------------------------------ */

/* Skip link: off-screen until focused, so keyboard users can jump past the nav. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.5rem 0.9rem;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  border-radius: 0 0 var(--radius) 0;
  z-index: 100;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

/* Top bar wraps on narrow screens instead of overflowing. */
.topbar {
  flex-wrap: wrap;
}

.mainnav {
  flex-wrap: wrap;
}



/* Tables scroll horizontally inside their wrapper on small screens. */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.table-wrap .table {
  border: none;
  border-radius: 0;
}

/* Visible keyboard focus everywhere (mouse users are unaffected). */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
.button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Deactivated servers read as retired (gray, dashed), never as merely offline. */
.chip-deactivated {
  background: var(--retired-bg);
  color: var(--retired-text);
  border: 1px dashed var(--retired-border);
}

/* Dashboard summary cards. */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card .count {
  font-size: 1.6rem;
  font-weight: 700;
}

.card .label {
  color: var(--muted);
  font-size: 0.85rem;
}

.card a {
  margin-top: 0.4rem;
  color: var(--accent);
  font-weight: 600;
}

/* Register dialog: native modal when JS opens it, plain inline form for
   no-JS clients (the noscript style in servers.html degrades it to block). */
dialog#register-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  max-width: 34rem;
  color: var(--text);
  background: var(--surface);
}

dialog#register-dialog::backdrop {
  background: var(--backdrop);
}

/* Register dialog goes wider on small-desktop and up (stays capped by the
   viewport on mobile). After the base rule on purpose: same specificity,
   later wins. */
@media (min-width: 40rem) {
  dialog#register-dialog {
    width: min(52rem, calc(100vw - 2rem));
    max-width: 52rem;
  }
}

/* Shared dialog layout: title -> description -> fields -> actions, with the
   actions pinned bottom-right on desktop and stacked full-width below 640px.
   Every dialog button (confirm/cancel/back inside a dialog) lives in a
   .dialog-actions block, so there are no per-dialog ad-hoc action styles. */
dialog .inline-form {
  flex-direction: column;
  align-items: stretch;
}

dialog .dialog-actions button,
dialog .dialog-actions .button {
  flex-shrink: 0;
}

/* Shared dialog style (delete server, new action, add webhook, create user):
   the same native-modal look as the register dialog above. */
dialog.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  /* Fixed width (not content-sized): preset rows lay out identically on
     every in-place refresh instead of jumping between renders. Unified with
     the register dialog: every dialog opens at the same 52rem width. */
  width: min(52rem, calc(100vw - 2rem));
  max-width: 52rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  color: var(--text);
  background: var(--surface);
}

/* Compact action dialog: smaller segmented options, tighter steps, and
   full-width text fields so the whole form fits the window. */
dialog .segmented .radio {
  padding: 0.3rem 0.65rem;
  font-size: 0.9rem;
}

dialog .step {
  padding: 0.75rem 0;
}

dialog .step h2 {
  margin-bottom: 0.5rem;
}

dialog .step h2 small {
  font-size: 0.8rem;
  font-weight: 400;
  opacity: 0.8;
}

/* Inline label + options rows (When, What, Schedule): the heading sits to
   the side, every option block stacks in the remaining width. The side
   column matches the register dialog labels (11rem). */
dialog li.inline-step {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: 0 1rem;
  align-items: start;
}

dialog li.inline-step > h2 {
  grid-column: 1;
  margin: 0.3rem 0 0;
  font-size: 0.9rem;
}

dialog li.inline-step > :not(h2) {
  grid-column: 2;
  min-width: 0;
  margin-top: 0;
}

/* Fixed target in the dialog title: server and target in two colors. */
dialog .title-server {
  color: var(--accent);
  font-weight: 700;
}

dialog .title-target {
  color: var(--target-green);
  font-weight: 700;
}

dialog .action-form input[type="text"],
dialog .action-form input[type="datetime-local"],
dialog .action-form textarea,
dialog .action-form select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

dialog .action-form input[type="date"],
dialog .action-form input[type="time"] {
  flex: 1 1 8rem;
  min-width: 0;
  box-sizing: border-box;
}

dialog.modal::backdrop {
  background: var(--backdrop);
}

/* Narrow screens: form fields shrink instead of forcing horizontal scroll. */
@media (max-width: 640px) {
  dialog li.inline-step {
    display: block;
  }

  dialog li.inline-step > h2 {
    margin-bottom: 0.5rem;
  }

  .dialog-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .dialog-actions button,
  .dialog-actions .button {
    width: 100%;
  }

  .settings-form input[type="url"] {
    min-width: auto;
    width: 100%;
  }

  .action-form select,
  .action-form input[type="datetime-local"] {
    min-width: auto;
    width: 100%;
  }

  .inline-form input {
    max-width: 100%;
  }

  .record {
    grid-template-columns: 1fr;
  }
}

/* Respect users who asked for less motion. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* --- Second visual pass: page heads, cards, compact tables ------------------- */

/* The brand links home, like the Dashboard nav entry. */
a.brand {
  color: var(--text);
  text-decoration: none;
}

a.brand:hover {
  color: var(--accent);
}

/* Page head: title plus a counts line (servers, actions, users, settings). */
.page-head {
  margin-bottom: 1.25rem;
}

.page-head h1 {
  margin: 0;
}

.page-head .page-actions {
  margin-bottom: 0.25rem;
  flex-wrap: wrap;
}

.counts {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Muted meta lines under card headers (last seen, project counts, routing). */
.meta {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.meta time {
  color: var(--text);
}

/* Servers: one card per server instead of a raw nested table. */
.server-cards {
  display: grid;
  gap: 1rem;
}

.server-card {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.server-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.server-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}

.server-name:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Compact tables: reported containers, accounts, routing. */
.table--compact th,
.table--compact td {
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
}

/* Empty states with a clear next action. */
.empty-state {
  padding: 2rem 1.5rem;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}

.empty-state p {
  margin: 0 0 0.5rem;
}

.empty-state p:last-child {
  margin-bottom: 0;
}

.empty-state .empty-actions {
  margin-top: 1rem;
}

/* Actions: filters live in a card, per-state counts sit below them. */
.filters {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.filters select,
.filters input[type="date"],
.filter-select {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  background: var(--surface);
}

.state-counts {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.9rem;
}

.state-counts-label {
  font-size: 0.85rem;
  color: var(--muted);
}

/* New action box: the server + target pickers live outside the dialog, so
   the selects share the filters row and the inline error reads as a field
   error below it. The dialog itself starts as a placeholder until the
   locked fragment is injected. */
#new-action-box .filters select {
  min-width: 12rem;
}

#newActionError {
  margin: 0.5rem 0 0;
}

#action-dialog-body > .hint:first-child {
  margin-top: 0;
}

/* Server status filter chips are links in the same style as the actions chips. */
.state-counts a.chip {
  text-decoration: none;
}

.state-counts a.chip[aria-current="true"] {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Pager: centered under the table. */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.25rem;
  color: var(--muted);
}

/* Two-column forms on desktop, single column below 640px. */
.form-grid .field {
  margin-bottom: 1rem;
}

/* Group separators inside grid forms (create-user sections). */
.form-grid hr.form-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.25rem 0 1rem;
}

/* Shared dialog sections (same theme as the new-action dialog): title on the
   left, controls on the right; stacked on narrow screens. Sections are
   separated like the action steps, so no extra <hr> is needed. */
.dlg-section {
  margin: 0;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
}
.dlg-section:first-of-type {
  border-top: none;
}
.dlg-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}
/* Tinted left edge shared by every dialog (instead of tinted titles): the
   color runs the full height of each section, so long headings like
   "Programación" never stick out of it. */
.dlg-section,
dialog .steps > li {
  border-left: 3px solid var(--accent);
  padding-left: 0.75rem;
}
.dlg-section label,
.dlg-section span[id$="-label"] {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.dlg-section input[type="text"],
.dlg-section input[type="password"],
.dlg-section input[type="url"],
.dlg-section select,
.dlg-section textarea {
  width: 100%;
  max-width: 22rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  background: var(--surface);
}
@media (min-width: 641px) {
  .dlg-section {
    display: grid;
    grid-template-columns: 11rem minmax(0, 1fr);
    gap: 0 1.25rem;
    align-items: start;
  }
  .dlg-title {
    padding-top: 0.45rem;
  }
}

.form-grid label,
.form-grid span[id$="-label"] {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.form-grid input[type="text"],
.form-grid input[type="password"],
.form-grid select {
  width: 100%;
  max-width: 22rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  background: var(--surface);
}

@media (min-width: 641px) {
  .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.25rem;
    align-items: start;
  }

  .form-grid .span-2 {
    grid-column: 1 / -1;
  }

  .webhook-cards {
    grid-template-columns: 1fr 1fr;
  }
}

/* Grant checklists scroll instead of pushing the form down. */
.checklist {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.checklist label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 400;
}

.checklist--scroll {
  max-height: 12rem;
  overflow-y: auto;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* Accounts table: role and status chips. */
.chip-admin {
  background: var(--dispatched-bg);
  color: var(--dispatched-text);
  border: 1px solid var(--dispatched-border);
}

.chip-operator {
  background: var(--neutral-bg);
  color: var(--neutral-text);
  border: 1px solid var(--border);
}

.chip-enabled {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.chip-disabled {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

/* Settings: one card per webhook, routing in its own card. */
.webhook-cards {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.webhook-card {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.webhook-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.webhook-card-head h3 {
  margin: 0;
  font-size: 1rem;
  word-break: break-word;
}

.webhook-url {
  margin: 0.5rem 0;
}

.webhook-url code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  word-break: break-all;
}

.webhook-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.section-gap {
  margin-top: 1.5rem;
}

@media (max-width: 640px) {
  .page-head .page-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .server-card-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* --- Server detail policy form (RM-8): block layout, never a flex row, so the
   matrix title sits above the table, the fallback follows it, and the shared
   .form-actions footer pins the save button bottom-right. --- */
.policy-form {
  display: block;
}

.policy-form .matrix-wrap {
  margin-top: 0.6rem;
}

/* --- Register dialog matrix redesign (register-server-matrix) ------------- */
/* Sidebar layout: celeste label column + content column on desktop, stacked
   with strip labels on mobile. Hairlines come from the 1px grid gap. */
.register-form {
  margin-top: 0.75rem;
}

.register-body {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.reg-label {
  margin: 0;
  padding: 0.7rem 0.9rem;
  background: var(--info-bg);
  color: var(--info-text);
  font-size: 0.85rem;
  font-weight: 700;
}

.reg-field {
  min-width: 0;
  padding: 0.7rem 0.9rem;
  background: var(--surface);
}

.reg-field input[type="text"],
.reg-field input[type="password"],
.reg-field input[type="url"],
.reg-field select {
  width: 100%;
  max-width: 22rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  background: var(--surface);
}

.reg-field .hint {
  margin-top: 0.4rem;
}

.matrix-title {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  font-weight: 700;
}

/* Permission matrix: horizontal scroll on small screens. */
.matrix-wrap {
  margin-top: 0.6rem;
}

table.matrix {
  min-width: 34rem;
}

table.matrix tbody th[scope="row"] {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.9rem;
  color: var(--text);
}

table.matrix tr.is-denied th[scope="row"] {
  color: var(--danger-text);
}

/* Pills: green = run-now on, blue = scheduled on, red = denied, gray = off. */
.perm-pill {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-width: 8rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--neutral-bg);
  color: var(--neutral-text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.perm-pill:hover {
  filter: brightness(0.97);
}

.perm-pill .pill-sub {
  font-size: 0.72rem;
  font-weight: 400;
  opacity: 0.9;
}

.perm-pill.is-on-green {
  background: var(--success-bg);
  border-color: var(--success-text);
  color: var(--success-text);
}

.perm-pill.is-on-blue {
  background: var(--info-bg);
  border-color: var(--accent);
  color: var(--info-text);
}

.perm-pill.is-deny {
  background: var(--danger-bg);
  border-color: var(--danger-text);
  color: var(--danger-text);
}

.perm-pill.is-off {
  background: var(--neutral-bg);
  border-color: var(--border);
  color: var(--muted);
}

.perm-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Disabled pills (user edit caps choices at the server base): visibly out of
   reach. Native disabled buttons take no clicks, so no JS guard is needed. */
.perm-pill:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* No-JS fallback radio groups (hidden by ui.js once the matrix is live). */
.policy-fallback {
  margin-top: 0.75rem;
}

.policy-fallback fieldset {
  margin: 0 0 0.6rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.policy-fallback fieldset:last-child {
  margin-bottom: 0;
}

.policy-fallback legend {
  padding: 0 0.3rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.policy-fallback label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .register-body {
    grid-template-columns: 1fr;
  }

  .reg-label {
    padding: 0.45rem 0.9rem;
    border-bottom: none;
  }

  .reg-field input[type="text"],
  .reg-field input[type="password"],
  .reg-field input[type="url"],
  .reg-field select {
    max-width: 100%;
  }

  .perm-pill {
    min-width: 7rem;
  }
}

/* --- User edit server access list (USM accordion) ---------------------------
   One native disclosure per server: the summary is the grant row, the body
   holds the permission matrix. A checked (granted) server reads as selected —
   accent border and name — via :has(), so the server-rendered and the toggled
   states paint identically with no extra JavaScript. */
.server-access-list {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

details.server-access {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

details.server-access > summary.server-access-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  list-style: none;
}

details.server-access > summary.server-access-head::-webkit-details-marker {
  display: none;
}

details.server-access > summary.server-access-head::after {
  content: "▾";
  margin-left: auto;
  color: var(--muted);
}

details.server-access[open] > summary.server-access-head::after {
  content: "▴";
}

.server-access-name {
  font-weight: 600;
}

details.server-access:has(> summary input[name="serverIds"]:checked) {
  border-color: var(--accent);
}

details.server-access:has(> summary input[name="serverIds"]:checked) .server-access-name {
  color: var(--accent-dark);
}

details.server-access .server-access-body {
  padding: 0 0.75rem 0.75rem;
  border-top: 1px dashed var(--border);
}

details.server-access .server-access-body > .hint:first-child {
  margin-top: 0.6rem;
}

/* User edit password box: independent box with the change-password opener.
   The dialog follows the shared dialog pattern (users.html, actions.html). */
.password-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.password-box .hint {
  margin: 0.25rem 0 0;
}

/* --- Navigation layout: top bar, left sidebar or right sidebar --------------
   One global admin setting (`layout` in app_setting, same catalog pattern as
   the theme). The markup never changes: the existing header becomes the
   sidebar column and the content takes the other column, so no-JS clients and
   the server render stay identical. Only an authenticated page gets the grid;
   the login card keeps its own centred layout. Below 48rem every side layout
   falls back to the top bar, because a permanent column would eat the
   viewport on a phone. */

[data-layout="left"] body:not(.login-body),
[data-layout="right"] body:not(.login-body) {
  display: grid;
  min-height: 100vh;
  align-items: start;
}

[data-layout="left"] body:not(.login-body) {
  grid-template-columns: 15rem minmax(0, 1fr);
  grid-template-areas: "nav main";
}

[data-layout="right"] body:not(.login-body) {
  grid-template-columns: minmax(0, 1fr) 15rem;
  grid-template-areas: "main nav";
}

[data-layout="left"] .topbar,
[data-layout="right"] .topbar {
  grid-area: nav;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: flex-start;
  gap: 1rem;
  height: 100vh;
  overflow-y: auto;
  padding: 1.25rem 1rem;
}

[data-layout="left"] .topbar {
  border-right: 1px solid var(--border);
  border-bottom: none;
}

[data-layout="right"] .topbar {
  border-left: 1px solid var(--border);
  border-bottom: none;
}

[data-layout="left"] .mainnav,
[data-layout="right"] .mainnav {
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0.1rem;
}

[data-layout="left"] .mainnav a,
[data-layout="right"] .mainnav a {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: calc(var(--radius) + 2px);
}

[data-layout="left"] .mainnav a:hover,
[data-layout="right"] .mainnav a:hover {
  background: color-mix(in srgb, var(--text) 6%, transparent);
}

/* Session footer: the user card reads as one block and the sign-out spans the
   column, matching the navigation rows above it. */
[data-layout="left"] .session,
[data-layout="right"] .session {
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  margin-top: auto;
  padding: 0.85rem 0.4rem 0;
  border-top: 1px solid var(--border);
}

[data-layout="left"] .user-card,
[data-layout="right"] .user-card {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border-radius: calc(var(--radius) + 4px);
  background: color-mix(in srgb, var(--code-bg) 55%, transparent);
}

[data-layout="left"] .user-meta,
[data-layout="right"] .user-meta {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
}

[data-layout="left"] .session .user,
[data-layout="right"] .session .user {
  white-space: normal;
}

[data-layout="left"] .signout,
[data-layout="right"] .signout {
  width: 100%;
  padding: 0.5rem;
}

[data-layout="left"] .container,
[data-layout="right"] .container {
  grid-area: main;
  width: 100%;
}

@media (max-width: 48rem) {
  [data-layout="left"] body:not(.login-body),
  [data-layout="right"] body:not(.login-body) {
    display: block;
  }

  [data-layout="left"] .topbar,
  [data-layout="right"] .topbar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    overflow: visible;
    padding: 0.65rem 1.25rem;
    border-right: none;
    border-left: none;
    border-bottom: 1px solid var(--border);
  }

  [data-layout="left"] .mainnav,
  [data-layout="right"] .mainnav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  [data-layout="left"] .session,
  [data-layout="right"] .session {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0;
    padding: 0;
    border-top: none;
  }

  [data-layout="left"] .mainnav a,
  [data-layout="right"] .mainnav a {
    width: auto;
  }

  [data-layout="left"] .user-card,
  [data-layout="right"] .user-card {
    width: auto;
    padding: 0;
    border: none;
    background: transparent;
  }

  [data-layout="left"] .user-meta,
  [data-layout="right"] .user-meta {
    flex-direction: row;
    align-items: center;
    gap: 0.45rem;
  }

  [data-layout="left"] .signout,
  [data-layout="right"] .signout {
    width: auto;
    padding: 0.45rem 0.7rem;
  }
}

/* --- Visual pass: iconography, a wider canvas and livelier cards -----------
   Icons are inline SVG symbols (icon-sprite.html) painted with currentColor,
   so every theme keeps them readable without new colour variables or assets.
   The canvas grows to 90rem on wide screens while staying fluid below that. */

.icon-sprite {
  display: none;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.18em;
}

/* Keep the top bar reachable while the page scrolls (side layouts already
   pin their column). The translucent surface is what makes the bar read as a
   floating layer over the content. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
}

/* Wider working canvas: 960px was a third of a modern desktop. */
.container {
  width: 100%;
  max-width: 90rem;
  margin: 1.75rem auto 3rem;
  padding: 0 clamp(1rem, 2.2vw, 2.5rem);
}

/* Surfaces: panels and tables share one soft card language. */
.panel {
  padding: 1.3rem 1.5rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-color: color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: 0 1px 2px var(--shadow);
}

.panel h2 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1rem;
  font-size: 1.05rem;
}

.table-wrap {
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  overflow: auto;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.table-wrap .table {
  border: none;
}

.table th,
.table td {
  padding: 0.75rem 0.95rem;
}

.table th {
  background: color-mix(in srgb, var(--code-bg) 65%, transparent);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
}

.table tbody tr {
  transition: background 0.12s ease;
}

.table tbody tr:hover {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.table--compact th,
.table--compact td {
  padding: 0.5rem 0.7rem;
}

/* Page titles: one accent badge per screen, so every page opens with a mark. */
.page-head h1,
.page-actions h1,
main > h1 {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0;
  flex-wrap: wrap;
  font-size: 1.55rem;
  letter-spacing: -0.015em;
}

.heading-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  flex: none;
  border-radius: calc(var(--radius) + 4px);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: var(--on-accent);
  box-shadow: 0 8px 20px var(--shadow);
}

.heading-icon .icon {
  width: 1.35rem;
  height: 1.35rem;
  stroke-width: 2;
}

.page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-actions h1 {
  margin: 0;
}

.page-head {
  margin-bottom: 1.5rem;
}

.counts {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Section headings inside panels get a small accent tile. */
.section-icon {
  width: 1.9rem;
  height: 1.9rem;
  padding: 0.36rem;
  margin-right: 0;
  flex: none;
  border-radius: calc(var(--radius) + 1px);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

/* Dashboard cards: label and value on the left, icon tile on the right, the
   link pinned to the card footer. */
.cards {
  grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr));
  gap: 1.1rem;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 1.25rem 1.35rem;
  border-radius: calc(var(--radius) + 6px);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border-color: color-mix(in srgb, var(--border) 80%, transparent);
  box-shadow: 0 1px 2px var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: 0 12px 26px var(--shadow);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.card-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.card-value {
  display: block;
  margin-top: 0.35rem;
  font-size: 2rem;
  font-weight: 750;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.card-foot {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.card-foot a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.card-foot a:hover {
  color: var(--accent-dark);
}

.card-foot .icon {
  width: 1em;
  height: 1em;
  transition: transform 0.15s ease;
}

.card-foot a:hover .icon {
  transform: translateX(2px);
}

.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  margin-bottom: 0;
  flex: none;
  border-radius: calc(var(--radius) + 2px);
  background: var(--info-bg);
  color: var(--info-text);
  border: 1px solid var(--info-border);
}

.card-icon .icon {
  width: 1.35rem;
  height: 1.35rem;
}

.card-icon--online {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

.card-icon--offline,
.card-icon--failed {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

.card-icon--pending {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: var(--warning-border);
}

/* Server and webhook cards fill wide screens instead of one long column. */
.server-cards {
  grid-template-columns: repeat(auto-fill, minmax(25rem, 1fr));
  align-items: start;
}

.server-card {
  padding: 1.15rem 1.25rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.server-card:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 20px var(--shadow);
}

.webhook-cards {
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
}

@media (max-width: 52rem) {
  .server-cards {
    grid-template-columns: 1fr;
  }
}

/* Empty states: a quiet line-art mark above the copy. */
.empty-state {
  padding: 2.5rem 1.5rem;
}

.empty-art {
  display: block;
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.9rem;
  color: var(--accent);
  opacity: 0.8;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Login: a real mark and a soft tint instead of a plain white card. */
.login-body {
  background-color: var(--bg);
  background-image: radial-gradient(70rem 32rem at 50% -12%, var(--info-bg), var(--bg) 62%);
  background-attachment: fixed;
}

.login-card {
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 18px 44px var(--shadow);
}

.login-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: 0.9rem;
  border-radius: 0.9rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: var(--on-accent);
  box-shadow: 0 10px 24px var(--shadow);
}

.login-mark .icon {
  width: 1.7rem;
  height: 1.7rem;
  stroke-width: 1.7;
}

/* The icons are decorative; the surrounding text keeps the meaning. */
@media (forced-colors: active) {
  .heading-icon,
  .card-icon,
  .login-mark {
    border: 1px solid currentColor;
  }
}

/* Back-navigation buttons carry the arrow that matches their direction; the
   button itself is a flex box, so the icon and label share one baseline. */

/* Status chips read at a glance: a coloured dot for reachability and a slow
   pulse while an action runs (motion is disabled by the reduced-motion rule). */
.chip-online::before,
.chip-offline::before,
.chip-deactivated::before,
.chip-running::before {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  margin-right: 0.35rem;
  border-radius: 50%;
  background: currentColor;
  vertical-align: 0.05em;
}

.chip-running::before {
  animation: chip-pulse 1.6s ease-in-out infinite;
}

@keyframes chip-pulse {
  50% {
    opacity: 0.35;
  }
}

/* --- Redesign pass: shared surfaces, controls and dialogs ------------------
   Same tokens as the shell. Nothing here hardcodes a colour outside the theme
   variables, so high-contrast and sepia keep their own palettes. */

.button,
button {
  border-radius: calc(var(--radius) + 2px);
}

.button {
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 18%, transparent);
}

.button:hover {
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 26%, transparent);
}

.button-secondary,
.button-danger {
  box-shadow: none;
}

.button-secondary:hover {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.alert {
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  border-radius: calc(var(--radius) + 2px);
}

.placeholder,
.action-form,
.password-box,
details.server-access {
  border-radius: calc(var(--radius) + 4px);
}

dialog {
  border-radius: calc(var(--radius) + 6px);
  border-color: color-mix(in srgb, var(--border) 80%, transparent);
  box-shadow: 0 24px 60px var(--shadow);
}

dialog::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(3px);
}

.login-card {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-color: color-mix(in srgb, var(--border) 80%, transparent);
}

.empty-state {
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border-radius: calc(var(--radius) + 6px);
}

/* Tables inside dialogs and nested blocks use the same header treatment. */
.table th {
  font-weight: 700;
}

/* Long keys and timestamps keep their monospace rhythm on the new surfaces. */
.key,
time[data-relative] {
  font-variant-numeric: tabular-nums;
}
