/* Bouncilla — design tokens taken from the Pjanda Homelab Figma file (dark theme). */
:root {
  --bg: #0e0f11;
  --surface: #151619;
  --surface-2: #1b1c20;
  --border: #26272c;
  --border-strong: #35373d;
  --text: #ececee;
  --text-2: #b6b8bd;
  --text-3: #8a8d94;
  --accent: #6b8cff;
  --accent-ink: #0b0f1d;
  --accent-soft: rgba(107, 140, 255, 0.16);
  --accent-line: rgba(107, 140, 255, 0.35);
  --focus-ring: 0 0 0 3px rgba(107, 140, 255, 0.12);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --up: #4cc38a;    /* status colours from the Statistieken design */
  --down: #ef6b73;
  --warn: #e3b25d;  /* partly down */

  --font: "Host Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", "Cascadia Code", ui-monospace, "SF Mono", Consolas, monospace;
  --radius: 8px;
  --radius-lg: 12px;

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 12px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
h1, h2, p { margin: 0; }
button { font: inherit; color: inherit; }
.icon { flex: none; display: block; }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.spacer { flex: 1 1 auto; }
[hidden] { display: none !important; }  /* classes like .btn or .form-error set `display` and would otherwise win over the hidden attribute */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ brand / profile button */
.brand-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: var(--radius);
  width: 100%; list-style: none; cursor: default;
}
.brand-btn::-webkit-details-marker { display: none; }
.brand-avatar { width: 30px; height: 30px; object-fit: cover; flex: none; }
.brand-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
.brand-name { font-size: 15px; font-weight: 600; line-height: 19.5px; letter-spacing: -0.15px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-family: var(--mono); font-size: 11.7px; line-height: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-chevron { width: 14px; height: 14px; flex: none; transition: transform .15s ease; }

/* ------------------------------------------------------------------ auth pages (login / setup) */
.auth-page { position: relative; min-height: 100%; }
.auth-brand { position: absolute; top: 0; left: 0; width: 250px; padding: 10px 10px 6px; }
.auth-main { min-height: 100vh; display: grid; place-items: center; padding: 80px 16px 40px; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 356px; max-width: 100%;
}
.auth-title { font-size: 22px; font-weight: 600; line-height: 27.5px; letter-spacing: -0.33px; color: var(--text); }
.auth-lead { margin-top: 8px; color: var(--text-2); font-size: 13px; line-height: 20px; }
.auth-lead strong { color: var(--text); font-weight: 500; }
.auth-form { display: flex; flex-direction: column; gap: 16px; padding: 24px 0 15px; }
.auth-icon { width: 44px; height: 44px; border-radius: var(--radius-lg); display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); margin-bottom: 16px; }
.auth-icon-danger { color: var(--danger); }
.auth-code { font-family: var(--mono); color: var(--text-3); font-size: 12px; margin-bottom: 4px; }
.auth-actions { display: flex; gap: 8px; margin-top: 24px; }
.auth-actions .btn { flex: 1; }

/* ------------------------------------------------------------------ form controls */
.field { display: flex; flex-direction: column; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field-label { font-size: 13px; font-weight: 500; line-height: 20.15px; letter-spacing: -0.045px; color: var(--text-2); padding: 0; }
.field-hint { font-size: 12px; color: var(--text-3); line-height: 18px; }
.input {
  height: 38px; width: 100%;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit; font-size: 14px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input::placeholder { color: var(--text-3); opacity: .7; font-family: var(--mono); font-size: 13px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.input[readonly] { color: var(--text-2); }
.input-mono { font-family: var(--mono); font-size: 13px; }
.form-error {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--radius);
  background: var(--danger-soft); border: 1px solid rgba(248, 113, 113, 0.3);
  color: #fecaca; font-size: 13px;
}
.form-error .icon { color: var(--danger); margin-top: 1px; }

.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14px; color: var(--text); }
.check input { margin: 2px 0 0; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.check small { display: block; color: var(--text-3); font-size: 12px; margin-top: 2px; }
.check strong { font-weight: 500; }
.check code { margin-left: 4px; }
.check-card { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.check-card:has(input:checked) { border-color: var(--accent-line); background: rgba(107, 140, 255, 0.06); }
.check-list { display: flex; flex-direction: column; gap: 2px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); max-height: 220px; overflow: auto; }
.check-list .check { padding: 6px 6px; border-radius: 6px; }
.check-list .check:hover { background: var(--surface-2); }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; min-height: 30px; padding: 0 12px;
  border-radius: var(--radius); border: 1px solid transparent;
  font-size: 13px; font-weight: 500; line-height: 1; white-space: nowrap;
  cursor: pointer; text-decoration: none;
  transition: background-color .12s ease, border-color .12s ease, filter .12s ease;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: transparent; border-color: rgba(248, 113, 113, 0.35); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 28px; min-height: 28px; padding: 0 10px; font-size: 12.5px; }
/* Login "Doorgaan" button, exact from Figma */
.btn-block { width: 100%; height: 34px; padding: 0 13px; gap: 7px; font-size: 14px; font-weight: 500; line-height: 21.7px; }
.btn-arrow { width: 16px; height: 16px; display: grid; place-items: center; flex: none; }
.btn-arrow img { display: block; width: 10.5px; height: 10.5px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--text-3); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ------------------------------------------------------------------ app shell */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--bg); border-right: 1px solid var(--border);
}
.profile { position: relative; padding: 10px 10px 6px; }
.profile > summary { cursor: pointer; }
.profile > summary:hover { background: var(--surface-2); }
.profile[open] .brand-chevron { transform: rotate(180deg); }
.menu {
  position: absolute; z-index: 20; left: 10px; right: 10px; top: calc(100% - 2px);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 4px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.menu-head { padding: 8px 10px; color: var(--text-3); font-size: 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-head strong { color: var(--text); font-weight: 500; }
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  height: 32px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent;
  color: var(--text-2); font-size: 13.5px; text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

.nav { display: flex; flex-direction: column; padding: 2px 10px 16px; flex: 1 1 auto; overflow: auto; }
.nav-section { padding: 20px 10px 6px; font-size: 13px; font-weight: 500; color: var(--text-3); }
.nav-item {
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px 0 10px;
  border-radius: var(--radius); color: var(--text-2); font-size: 14px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.is-active { background: var(--accent-soft); color: var(--text); }
.nav-item.is-active .icon { color: var(--accent); }

.sidebar-foot { padding: 6px 10px 12px; }
.user-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 10px 6px 10px 12px;
}
.user-card-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-card-name { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card-role { font-size: 12px; color: var(--text-3); }

.avatar {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line);
  font-size: 12px; font-weight: 600;
}

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: rgba(14, 15, 17, 0.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.crumb { display: flex; align-items: center; gap: 8px; padding-left: 12px; font-size: 13.5px; font-weight: 500; color: var(--text); }
.crumb .icon { color: var(--text-3); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search {
  display: flex; align-items: center; gap: 8px; width: 240px; height: 32px; padding: 0 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-3);
}
.search:focus-within { border-color: var(--accent); box-shadow: var(--focus-ring); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 13px; outline: none; }
.search input::placeholder { color: var(--text-3); }

.content { width: 100%; max-width: 1040px; margin: 0 auto; padding: 28px 24px 120px; }

/* ------------------------------------------------------------------ hero (header card) */
.hero {
  display: flex; align-items: center; gap: 18px;
  padding: 22px 24px; border-radius: var(--radius-lg);
  border: 1px solid var(--accent-line);
  background:
    linear-gradient(180deg, rgba(107, 140, 255, 0.12) 0%, rgba(107, 140, 255, 0) 45%),
    var(--surface);
}
.hero-icon { width: 52px; height: 52px; flex: none; border-radius: var(--radius-lg); display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.hero-avatar { font-size: 22px; font-weight: 600; color: var(--accent); background: var(--accent-soft); }
.hero-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hero h1 { font-size: 28px; font-weight: 600; line-height: 35px; letter-spacing: -0.42px; overflow-wrap: anywhere; }
.hero p { font-size: 13px; color: var(--text-3); }

/* ------------------------------------------------------------------ flash messages */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius); font-size: 13.5px; border: 1px solid; }
.flash-success { background: var(--ok-soft); border-color: rgba(74, 222, 128, 0.25); color: #bbf7d0; }
.flash-success .icon { color: var(--ok); }
.flash-error { background: var(--danger-soft); border-color: rgba(248, 113, 113, 0.3); color: #fecaca; }
.flash-error .icon { color: var(--danger); }

/* ------------------------------------------------------------------ toolbar + table */
.toolbar { display: flex; align-items: center; gap: 4px; padding: 28px 0 10px; }
.toolbar-label { font-size: 13px; font-weight: 500; color: var(--text-2); }

.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  height: 40px; padding: 0 12px; text-align: left;
  font-size: 13px; font-weight: 400; color: var(--text-3);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table th:first-child { padding-left: 18px; color: var(--text); }
.table th .sort { color: var(--accent); }
.table td { height: 48px; padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: middle; }
.table td:first-child { padding-left: 18px; color: var(--text); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:not(.row-empty):hover td { background: rgba(255, 255, 255, 0.015); }
.col-actions { width: 1%; text-align: right; padding-right: 14px !important; }
.m-label { display: none; } /* label shown only in the mobile card layout */

.cell-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-stack { display: flex; flex-direction: column; min-width: 0; }
.cell-title { color: var(--text); font-size: 14.5px; white-space: nowrap; }
.cell-sub { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.cell-icon { color: var(--text-3); }

.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 999px; font-size: 11.5px; color: var(--text-2); border: 1px solid var(--border-strong); white-space: nowrap; }
.badge-accent { color: var(--accent); border-color: var(--accent-line); background: rgba(107, 140, 255, 0.08); }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok { color: var(--ok); background: var(--ok-soft); border: 1px solid rgba(74, 222, 128, 0.25); }
.pill-off { color: var(--text-3); background: var(--surface-2); border: 1px solid var(--border-strong); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.chip-more { color: var(--text-3); }

.table-empty { padding: 28px; text-align: center; color: var(--text-3); }
.empty { padding: 36px 16px; text-align: center; color: var(--text-3); font-size: 13px; }
.empty-title { color: var(--text); font-size: 15px; font-weight: 500; margin-bottom: 4px; }

/* ------------------------------------------------------------------ tiles (Mijn services) */
.section-label { margin: 28px 0 10px; font-size: 13px; color: var(--text-3); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 4px; padding: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text);
  transition: border-color .12s ease, background-color .12s ease;
}
a.tile:hover { border-color: var(--accent-line); background: var(--surface-2); text-decoration: none; }
.tile-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); color: var(--accent); margin-bottom: 14px; }
.tile-title { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 500; }
.tile-title .icon { color: var(--text-3); }
.tile-sub { font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ panels (account) */
.panels { display: grid; gap: 16px; margin-top: 28px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px 24px; }
.panel-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 20px; }
.panel-head h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; }
.panel-head p { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.panel-icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); color: var(--text-2); }
.stack { display: flex; flex-direction: column; gap: 16px; max-width: 360px; }

/* ------------------------------------------------------------------ service logos */
.service-logo { display: block; object-fit: contain; }
.cell-icon.has-logo { display: grid; place-items: center; width: 28px; height: 28px; flex: none; }
.tile-icon.has-logo { background: var(--surface-2); padding: 6px; }
.tile-icon.has-logo .service-logo { width: 100%; height: 100%; }
.logo-edit { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo-preview { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3); overflow: hidden; }
.logo-preview img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.logo-preview img[hidden] { display: none; }
.logo-edit label.btn { position: relative; }
.logo-edit label.btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ invites */
.invite-new { margin-top: 20px; border-color: var(--accent-line); }
.invite-new .codeline code { overflow-wrap: anywhere; }
.table td form { display: inline; }

/* ------------------------------------------------------------------ language */
.lang-switch { position: fixed; top: 14px; right: 16px; display: flex; gap: 4px; font-size: 13px; z-index: 1; }
.lang-switch a { padding: 4px 10px; border-radius: var(--radius); color: var(--text-3); text-decoration: none; }
.lang-switch a:hover { color: var(--text); background: var(--surface-2); }
.lang-switch a[aria-current] { color: var(--text); background: var(--surface); border: 1px solid var(--border); }
.lang-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
select.input { appearance: auto; }

/* ------------------------------------------------------------------ profile pictures */
img.avatar-img { display: block; object-fit: cover; padding: 0; background: var(--surface-2); }
.account-intro { font-size: 13px; margin-top: 12px; }
.avatar-edit { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.avatar-preview { width: 72px; height: 72px; flex: none; border-radius: 50%; object-fit: cover; background: var(--surface-2); border: 1px solid var(--border-strong); }
.avatar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.avatar-actions form { display: flex; gap: 8px; }
.avatar-actions label.btn { position: relative; }
.avatar-actions label.btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ statistics (Figma: "Statistieken") */
.stats { display: flex; flex-direction: column; gap: 28px; }
.stat-card {
  display: flex; flex-direction: column; gap: 16px;
  padding: 24px 26px; border-radius: var(--radius-lg);
  border: 1px solid var(--accent-line);
  background:
    linear-gradient(180deg, rgba(107, 140, 255, 0.12) 0%, rgba(107, 140, 255, 0) 45.5%),
    var(--surface);
}
.stat-card[hidden], .server-slide[hidden] { display: none; }
.server-slide { display: flex; flex-direction: column; gap: 16px; }
.stat-title { font-size: 21px; font-weight: 600; line-height: 27px; color: var(--text); margin: 0; overflow-wrap: anywhere; }
.stat-note { font-size: 13px; color: var(--text-3); }
.stat-divider { height: 1px; background: var(--border); }

.server-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.server-id { display: flex; align-items: center; gap: 24px; min-height: 27px; flex-wrap: wrap; row-gap: 8px; }
.server-uptime { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; }
.server-uptime span { font-size: 13px; line-height: 21px; color: var(--text-3); }
.server-uptime strong { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--text); }

.state-badge {
  display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 9px;
  border-radius: 999px; border: 1px solid; font-size: 12px; font-weight: 500; line-height: 19px;
}
.state-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.state-badge.is-up { background: #1c302b; border-color: #2a5140; color: var(--up); }
.state-badge.is-down { background: #33201f; border-color: #5a2d30; color: var(--down); }

.ip-grid, .metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 23px; }
.ip-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ip-label { font-size: 13px; line-height: 21px; color: var(--text-2); }
.ip-box {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: 34px; padding: 0 6px 0 12px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.ip-value { font-size: 14px; font-weight: 500; line-height: 22px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-btn { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border: 0; border-radius: 6px; background: transparent; cursor: pointer; }
.copy-btn:hover { background: var(--border); }
/* Two overlapping sheets, as drawn in the design (14x16). */
.copy-glyph { position: relative; display: block; width: 14px; height: 16px; }
.copy-glyph::before, .copy-glyph::after {
  content: ""; position: absolute; width: 10px; height: 12px; border: 1px solid #a5a8b3; border-radius: 1.5px;
}
.copy-glyph::before { left: 4px; top: 0; }
.copy-glyph::after { left: 0; top: 4px; background: var(--surface-2); }
.copy-btn:hover .copy-glyph::after { background: var(--border); }
.copy-btn.is-copied .copy-glyph::before, .copy-btn.is-copied .copy-glyph::after { border-color: var(--up); }

.metric { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.metric-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 25px; }
.metric-head span { font-size: 13px; line-height: 21px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-head strong { font-size: 18px; line-height: 25px; font-weight: 600; color: var(--text); }
.meter { height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.meter-fill { display: block; height: 100%; width: 0; border-radius: 2px; background: var(--accent); transition: width .4s ease; }
.metric-sub { font-size: 12px; line-height: 19px; color: var(--text-3); }
.metric-grid.is-stale { opacity: .5; }
.metric-grid.is-stale .meter-fill { background: var(--text-3); }

.usage-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 4px; }
.usage-title { font-size: 13px; color: var(--text-2); }
.range-tabs { display: flex; gap: 2px; padding: 2px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.range-tabs a { padding: 3px 10px; border-radius: 6px; font-size: 12.5px; color: var(--text-3); text-decoration: none; }
.range-tabs a:hover { color: var(--text); }
.range-tabs a.is-active { background: var(--surface-2); color: var(--text); }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 23px; }
.chart { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--text-2); }
.chart-stats { font-size: 12px; color: var(--text-3); }
.chart svg { display: block; width: 100%; height: 80px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.chart-grid-line { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-area { fill: var(--accent-soft); stroke: none; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart-axis { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--text-3); }

.carousel-nav { display: flex; align-items: center; justify-content: center; gap: 32px; height: 30px; }
.carousel-btn { display: block; width: 30px; height: 30px; padding: 0; border: 0; background: none; border-radius: var(--radius); cursor: pointer; }
.carousel-btn img { display: block; }
.carousel-btn:hover img { filter: brightness(1.25); }
.carousel-dots { display: flex; align-items: center; gap: 12px; }
.carousel-dot { width: 6px; height: 6px; padding: 0; border: 0; border-radius: 50%; background: #62697b; cursor: pointer; }
.carousel-dot.is-active { background: var(--accent); }

.services-card { gap: 20px; }
.services-head { display: flex; flex-direction: column; gap: 4px; }
.services-head p { font-size: 13px; line-height: 22px; color: var(--text-3); }
.status-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.status-table th {
  height: 29px; padding: 0; text-align: left; vertical-align: middle;
  font-size: 13px; font-weight: 400; line-height: 22px; color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
.status-table td { height: 48px; padding: 0; vertical-align: middle; font-size: 14px; line-height: 22px; color: var(--text-2); border-top: 1px solid var(--border); }
.status-table tbody tr:first-child td { border-top: 0; }
.status-table th:not(:first-child), .status-table td:not(:first-child) { padding-left: 24px; }
.status-table .col-uptime { width: 194px; }
.status-table .col-pct { width: 184px; }
.status-table .col-status { width: 136px; }
.status-table td.st-name { font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-table td.col-pct { font-weight: 500; color: var(--text); }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 500; line-height: 19px; }
.status .state-dot { width: 7px; height: 7px; }
.status-up { color: var(--up); }
.status-down { color: var(--down); }
.status-unknown { color: var(--text-3); }

.services-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.refresh-btn.is-loading { opacity: .7; cursor: progress; }
.refresh-btn.is-loading .icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .refresh-btn.is-loading .icon { animation: none; } }

.row-toggle {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 0; border: 0; background: none;
  font: inherit; font-weight: 500; color: var(--text); text-align: left; cursor: pointer;
}
.row-toggle .icon { color: var(--text-3); transition: transform .15s ease; }
.row-toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }
.row-toggle:hover span { text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.status-table tr.detail-row td { height: auto; padding: 0 0 18px; border-top: 0; }
.status-table tr.detail-row[hidden] { display: none; }
.detail { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.detail-meta { font-size: 12.5px; color: var(--text-3); overflow-wrap: anywhere; }
.bars { display: flex; flex-direction: column; gap: 6px; }
.bars-title { font-size: 12.5px; color: var(--text-2); }
.bars svg { display: block; width: 100%; height: 28px; }
.bar-ok { fill: var(--up); background: var(--up); }
.bar-warn { fill: var(--warn); background: var(--warn); }
.bar-bad { fill: var(--down); background: var(--down); }
.bar-none { fill: var(--border-strong); background: var(--border-strong); }
.bars rect:hover { opacity: .75; }
.bar-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-3); }
.bar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.bar-legend i { width: 10px; height: 10px; border-radius: 2px; display: block; }

.dialog > .dialog-step { display: flex; flex-direction: column; max-height: calc(100vh - 50px); }
.dialog > .dialog-step[hidden], .dialog > form[hidden] { display: none; }
.remote-ready .codeline code { font-size: 13px; }
.remote-fields { margin: 18px 0 0; padding: 0; border: 0; min-width: 0; }
.remote-fields .sub-head { padding: 0; margin: 0 0 10px; }
.remote-fields .field-hint { margin-top: 8px; }
.remote-log { margin-top: 18px; font-size: 13px; color: var(--text-2); }
.remote-log summary { cursor: pointer; color: var(--text-3); }
.remote-log ul { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.log-ok { color: var(--up); }
.log-fail { color: var(--down); }
.icon-btn.is-copied { color: var(--up); }

.stats-foot { display: flex; justify-content: flex-start; margin-top: 20px; }

/* Editing servers */
.crumb-link { color: var(--text); }
.agent-help { margin-top: 20px; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; color: var(--text-2); font-size: 13.5px; }
.steps li .btn { margin: 6px 6px 0 0; }
.server-edit { margin-top: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.sub-head { margin: 24px 0 10px; font-size: 14px; font-weight: 600; color: var(--text); }
.monitor-list { display: flex; flex-direction: column; gap: 8px; }
.monitor-row { display: grid; grid-template-columns: minmax(0, 1fr) 190px minmax(0, 1.3fr) 112px; gap: 8px; align-items: center; }
.monitor-row-head { font-size: 12px; color: var(--text-3); }
.monitor-row-new .input { border-style: dashed; }
.monitor-del { font-size: 13px; color: var(--text-2); }
.kind-help { margin: 12px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 2px; }
.kind-help strong { color: var(--text-2); font-weight: 500; }
.panel-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ------------------------------------------------------------------ dialogs */
.dialog {
  width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}
.dialog::backdrop { background: rgba(5, 6, 8, 0.7); backdrop-filter: blur(2px); }
.dialog > form:first-child { display: flex; flex-direction: column; max-height: calc(100vh - 50px); }
.dialog-head { display: flex; align-items: center; gap: 12px; padding: 18px 16px 4px 24px; }
.dialog-head h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.25px; flex: 1; overflow-wrap: anywhere; }
.dialog-body { display: flex; flex-direction: column; gap: 16px; padding: 16px 24px 20px; overflow-y: auto; }
.dialog-foot { display: flex; align-items: center; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--border); background: rgba(14, 15, 17, 0.4); }
.codeline { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.codeline code { flex: 1; background: none; border: 0; padding: 0; overflow-x: auto; white-space: nowrap; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 820px) {
  /* minmax(0, …) so wide content (tables) can't stretch the page past the screen width. */
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .profile { padding: 8px 10px 4px; }
  /* Nav becomes one horizontally scrollable row. */
  .nav { flex-direction: row; flex-wrap: nowrap; gap: 4px; padding: 0 10px 10px; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item { flex: none; }
  .nav-section { display: none; }
  .sidebar-foot { display: none; }
  /* The active nav item already says where you are, so the topbar only holds the search. */
  .topbar { position: static; height: auto; padding: 12px 16px 0; border-bottom: 0; background: none; backdrop-filter: none; }
  .topbar:not(:has(.topbar-actions > *)) { display: none; }
  .crumb { display: none; }
  .topbar-actions { flex: 1; margin-left: 0; }
  .search { width: 100%; }
  .content { padding: 16px 16px 80px; }
  .hero { padding: 18px; }
  .hero h1 { font-size: 22px; line-height: 28px; }
  .auth-brand { width: auto; }
  .auth-card { padding: 24px; }
}

@media (max-width: 640px) {
  .hero { gap: 14px; padding: 16px; }
  .hero-icon { width: 44px; height: 44px; }
  .toolbar { padding: 22px 0 10px; }
  .panel { padding: 18px; }
  .stack { max-width: none; }

  /* Bigger tap targets. */
  .btn { height: 38px; min-height: 38px; padding: 0 14px; font-size: 14px; }
  .btn-sm { height: 34px; min-height: 34px; padding: 0 12px; font-size: 13px; }
  .icon-btn { width: 38px; height: 38px; }
  .nav-item { height: 36px; }
  .menu-item { height: 40px; }
  .check-list { max-height: 260px; }
  .check-list .check { padding: 9px 6px; }
  /* 16px inputs stop iOS Safari from zooming in when a field gets focus. */
  .input, .search input { font-size: 16px; }
  .input { height: 42px; }
  .input::placeholder { font-size: 14px; }
  .search { height: 40px; }

  /* Tables become a list of cards: name + edit button on top, the rest below. */
  .table-card { overflow: visible; }
  .table, .table tbody { display: block; }
  .table thead { display: none; }
  .table tr {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
    column-gap: 12px; row-gap: 10px; padding: 14px 14px 14px 16px; border-bottom: 1px solid var(--border);
  }
  .table tr[hidden] { display: none; }
  .table tbody tr:last-child { border-bottom: 0; }
  .table tbody tr:not(.row-empty):hover td { background: none; }
  .table td, .table td:first-child { display: block; height: auto; padding: 0; border: 0; grid-column: 1 / -1; min-width: 0; }
  .table td:first-child { grid-column: 1 / 3; }
  .table td.col-actions { grid-column: 3; grid-row: 1; width: auto; padding: 0 !important; }
  .table td.td-left { grid-column: 1; }
  .table td.td-right { grid-column: 2 / -1; white-space: normal; font-size: 13px; }
  .table .row-empty td { grid-column: 1 / -1; }
  .m-label { display: inline; }
  .cell-main { flex-wrap: wrap; row-gap: 4px; }
  .cell-main > .cell-stack { flex: 1 1 0; }
  .cell-title { white-space: normal; overflow-wrap: anywhere; }
  .cell-sub { max-width: none; white-space: normal; overflow-wrap: anywhere; }

  /* Dialogs open as a bottom sheet. */
  .dialog {
    width: 100%; max-width: 100%; margin: auto 0 0;
    max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
    border-radius: 16px 16px 0 0; border-bottom: 0;
  }
  .dialog > form:first-child { max-height: calc(100vh - 26px); max-height: calc(100dvh - 26px); }
  .dialog-head { padding: 14px 10px 2px 18px; }
  .dialog-body { padding: 14px 18px 18px; }
  .dialog-foot { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); }
  .dialog-foot .spacer { display: none; }
  .dialog-foot .btn { flex: 1 1 0; }
  .dialog-foot .btn-danger { flex: none; width: 38px; padding: 0; }
  .hide-sm { display: none; }

  /* Statistics: one column; the service table drops the current-uptime column. */
  .stat-card { padding: 18px; }
  .server-head { flex-wrap: wrap; }
  .server-uptime { align-items: flex-start; }
  .ip-grid, .metric-grid, .chart-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .status-table .col-uptime { display: none; }
  .status-table .col-pct { width: 96px; }
  .status-table .col-status { width: 100px; }
  .status-table th:not(:first-child), .status-table td:not(:first-child) { padding-left: 12px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .monitor-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding-bottom: 10px; border-bottom: 1px solid var(--border); }
  .monitor-row > .input-mono { grid-column: 1 / -1; }
  .monitor-row-head { display: none; }

  /* Service tiles: icon left, text right. */
  .tiles { gap: 10px; }
  .tile { display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 14px; row-gap: 2px; align-items: center; padding: 14px 16px; }
  .tile-icon { grid-row: 1 / span 2; margin-bottom: 0; }
}
