/* SetDesk admin panel
   A deliberately small, dependency-free stylesheet. Everything is driven by
   the tokens below, so the whole panel re-themes from one block. */

:root {
  color-scheme: dark;

  --bg: #0b0d12;
  --bg-elevated: #12151d;
  --bg-panel: #161a24;
  --bg-hover: #1d2230;
  --border: #242a38;
  --border-strong: #323a4d;

  --text: #e8ecf5;
  --text-muted: #939db4;
  --text-faint: #646d84;

  --accent: #4f7cff;
  --accent-hover: #6a91ff;
  --accent-soft: rgba(79, 124, 255, 0.14);

  --success: #2fbf71;
  --success-soft: rgba(47, 191, 113, 0.14);
  --warning: #e4b33c;
  --warning-soft: rgba(228, 179, 60, 0.14);
  --danger: #f0555c;
  --danger-soft: rgba(240, 85, 92, 0.14);

  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.45);

  --sidebar-width: 236px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f4f6fb;
  --bg-elevated: #ffffff;
  --bg-panel: #ffffff;
  --bg-hover: #eef1f8;
  --border: #e0e5f0;
  --border-strong: #cbd3e4;

  --text: #121722;
  --text-muted: #5b6577;
  --text-faint: #8d97ab;

  --accent-soft: rgba(79, 124, 255, 0.1);
  --shadow: 0 14px 40px rgba(20, 30, 60, 0.12);
}

* { box-sizing: border-box; }

/* The shell and the sign-in screen both set an explicit `display`, which beats
   the user-agent rule for [hidden] and would leave a "hidden" element on
   screen. Everything here toggles visibility through that attribute, so it has
   to win outright. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   Sign-in
   -------------------------------------------------------------------------- */

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 15% -10%, rgba(79, 124, 255, 0.16), transparent 60%),
    radial-gradient(800px 400px at 110% 110%, rgba(47, 191, 113, 0.1), transparent 55%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px;
}

.auth-card h1 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.auth-card .subtitle {
  margin: 0 0 26px;
  color: var(--text-muted);
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px;
  font-weight: 650;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #8a5cff);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  width: 100%;
  transition: background 120ms ease, color 120ms ease;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text); }

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 550;
}

.nav-item .icon { width: 16px; text-align: center; opacity: 0.9; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  min-width: 0;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 650;
  font-size: 12px;
  flex-shrink: 0;
}

.account-chip .meta { min-width: 0; }
.account-chip .name { font-size: 13px; font-weight: 550; }
.account-chip .role,
.account-chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-chip .role { font-size: 11.5px; color: var(--text-faint); }

/* --------------------------------------------------------------------------
   Main
   -------------------------------------------------------------------------- */

.main { padding: 26px 30px 60px; min-width: 0; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-head h2 {
  margin: 0 0 3px;
  font-size: 21px;
  letter-spacing: -0.02em;
}

.page-head .hint { margin: 0; color: var(--text-muted); font-size: 13px; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Cards and stats
   -------------------------------------------------------------------------- */

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.card + .card { margin-top: 16px; }

.card-title {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}

.stat .label {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.stat .value {
  font-size: 27px;
  font-weight: 620;
  letter-spacing: -0.03em;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.stat .value small { font-size: 14px; color: var(--text-faint); font-weight: 500; }

/* Schema version and similar identifiers are long and unbreakable; let them
   wrap inside the card rather than pushing past its edge. */
.stat .value.wrap {
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
}

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

thead th {
  text-align: left;
  padding: 11px 16px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }

td.numeric, th.numeric { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; text-align: right; }
td.actions > * + * { margin-left: 6px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: 12.5px; }

.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--text-faint);
}

.empty .big { font-size: 30px; margin-bottom: 8px; opacity: 0.55; }

/* --------------------------------------------------------------------------
   Controls
   -------------------------------------------------------------------------- */

.field { margin-bottom: 14px; }

label {
  display: block;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input.compact, select.compact { width: auto; min-width: 190px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.btn:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn.danger { color: var(--danger); border-color: var(--danger-soft); }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }

.btn.full { width: 100%; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* A nine-digit ID broken over three lines is unreadable, and a row of icon
   buttons that wraps stops looking like one control. */
td.mono,
td.actions { white-space: nowrap; }

/* Addresses can be a long list; one line with the rest on hover keeps the
   table the width of the card it sits in. */
td.ellipsis { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge.online { background: var(--success-soft); color: var(--success); }
.badge.offline { background: var(--bg-hover); color: var(--text-faint); }
.badge.warn { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--accent-soft); color: var(--accent); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.online .dot { box-shadow: 0 0 0 3px var(--success-soft); }

/* --------------------------------------------------------------------------
   Feedback
   -------------------------------------------------------------------------- */

.alert {
  padding: 10px 13px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}

.alert.error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.alert.ok { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.alert.warn { background: var(--warning-soft); border-color: var(--warning); color: var(--warning); }

.toast-stack {
  position: fixed;
  bottom: 22px;
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 100;
}

.toast {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 11px 15px;
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: 340px;
  animation: toast-in 180ms ease;
}

.toast.ok { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: none; }
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 620ms linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   Misc layout helpers
   -------------------------------------------------------------------------- */

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1 1 280px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 9px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.right { text-align: right; }

.switch { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; }
.switch input { width: auto; margin: 0; accent-color: var(--accent); }

.meter {
  height: 5px;
  background: var(--bg-hover);
  border-radius: 999px;
  overflow: hidden;
}

.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .brand { padding: 0 12px 0 4px; }
  .sidebar-footer { margin-top: 0; padding-top: 0; border-top: none; margin-left: auto; }
  .account-chip .meta { display: none; }
  .main { padding: 20px 16px 50px; }
}

/* --------------------------------------------------------------------------
   Notification badge
   -------------------------------------------------------------------------- */

.nav-badge {
  margin-left: auto;
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 12, 0.66);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 200;
  animation: fade-in 140ms ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  animation: modal-in 160ms ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-panel);
}

.modal-head h3 { margin: 0; font-size: 16px; letter-spacing: -0.01em; }

.modal-body { padding: 20px; }

.modal-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px -20px;
}

.modal-section-title {
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 12px;
}

/* --------------------------------------------------------------------------
   Notification list
   -------------------------------------------------------------------------- */

.notif {
  display: flex;
  gap: 13px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}

.notif:last-child { border-bottom: none; }
.notif.unread { background: var(--accent-soft); }

.notif-mark {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
  background: var(--text-faint);
}

.notif-mark.info { background: var(--accent); }
.notif-mark.success { background: var(--success); }
.notif-mark.warning { background: var(--warning); }
.notif-mark.critical { background: var(--danger); }

.notif-body { flex: 1; min-width: 0; }
.notif-body .title { font-weight: 600; font-size: 13.5px; margin-bottom: 3px; }
.notif-body .text { font-size: 13px; color: var(--text-muted); line-height: 1.55; }
.notif-body .meta { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; }
.notif-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* --------------------------------------------------------------------------
   Top bar

   The page scrolls under it; it does not scroll away. What lives here - who
   you are signed in as, what is waiting for you, how to leave - is never about
   the page you happen to be reading.
   -------------------------------------------------------------------------- */

.content { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 58px;
  padding: 0 30px;
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.crumbs { font-size: 14px; font-weight: 600; letter-spacing: -0.1px; }

.topbar-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .16s ease, color .16s ease, transform .12s ease;
}

.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:active { transform: scale(.94); }

.bell-badge {
  position: absolute;
  top: 3px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 650;
  display: grid;
  place-items: center;
}

.profile { position: relative; }

.profile-btn {
  border: 0;
  background: transparent;
  padding: 2px;
  border-radius: 999px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .12s ease;
}

.profile-btn:hover { transform: translateY(-1px); }

.profile-btn .avatar { width: 34px; height: 34px; font-size: 13px; }

.avatar.large { width: 42px; height: 42px; font-size: 15px; }

.profile-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 250px;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .28);
  animation: menu-in .16s ease-out;
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.profile-head { display: flex; gap: 12px; align-items: center; min-width: 0; }
.profile-head .name { font-weight: 600; font-size: 13.5px; }
.profile-head .role { font-size: 11.5px; color: var(--accent); }
.profile-head .faint,
.profile-head .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.profile-menu hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }

.menu-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 9px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  transition: background .14s ease;
}

.menu-item:hover { background: var(--bg-hover); }
.menu-item.danger { color: var(--danger); }

.server-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-radius: var(--radius);
  background: var(--bg-hover);
  font-size: 12px;
  color: var(--text-muted);
}

.server-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

/* Cards and rows arrive rather than appear. */
.card, .stat { animation: rise .26s ease-out both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.stat { transition: transform .18s ease, border-color .18s ease; }
.stat:hover { transform: translateY(-2px); border-color: var(--accent); }

tbody tr { transition: background .14s ease; }

/* A short list of labelled facts, for detail pages. */
.kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px 24px;
}

.kv > div { min-width: 0; }
.kv .faint { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.kv > div > div { margin-top: 3px; font-size: 13.5px; }

.user-link {
  color: var(--text);
  font-weight: 550;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .14s ease, border-color .14s ease;
}

.user-link:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* Two-column forms, for pages that compare one thing against another. */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  align-items: start;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  margin: 4px 0 14px;
  cursor: pointer;
}

.check input { width: 16px; height: 16px; accent-color: var(--accent); }

textarea {
  width: 100%;
  resize: vertical;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: border-color .16s ease;
}

textarea:focus { outline: none; border-color: var(--accent); }

/* What an announcement will look like, as it was typed. */
.preview {
  margin: 14px 0;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
}

/* --------------------------------------------------------------------------
   Dialogs

   The panel asks its own questions rather than the browser's: a styled dialog
   can say which button is the dangerous one, and it does not look like it
   arrived from somewhere else.
   -------------------------------------------------------------------------- */

.dialog-text {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.modal-backdrop { animation: fade-in .16s ease-out; }
.modal-card { animation: pop-in .2s cubic-bezier(.2, .8, .3, 1); }

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Workspace switcher in the profile menu. */
.menu-label {
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 2px 10px 8px;
}

.workspace-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }

.menu-item.workspace {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 2px 9px;
  text-align: left;
}

/* The role sits under the name rather than beside it: squeezing both onto one
   line truncated the name, which is the part being chosen. */
.menu-item.workspace .faint { grid-column: 2; }

.menu-item.workspace .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
}

.menu-item.workspace.current .dot { background: var(--success); }
.menu-item.workspace.current .name { font-weight: 600; }

.menu-item.workspace .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item.workspace .faint { font-size: 11px; }

/* Group headings in the sidebar. */
.nav-group {
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 16px 12px 6px;
}

/* The workspace this session is acting in, in the bar above every page. */
.crumbs { display: flex; align-items: center; gap: 14px; min-width: 0; }

.workspace-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 260px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-hover);
  color: var(--text-muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .16s ease, color .16s ease, transform .12s ease;
}

.workspace-chip:hover { border-color: var(--accent); color: var(--text); }
.workspace-chip:active { transform: scale(.97); }

.workspace-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.workspace-chip #workspace-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-chip .caret { font-size: 10px; opacity: .7; }

/* The two-factor QR. White plate on purpose: a dark-themed page would
   otherwise invert the code and half the scanners would refuse it. */
.qr {
  display: grid;
  place-items: center;
  padding: 14px;
  margin: 0 0 18px;
  border-radius: var(--radius-lg);
  background: #ffffff;
}

.qr img { display: block; image-rendering: pixelated; }

/* --------------------------------------------------------------------------
   Layout corrections

   The sidebar is a column that can outgrow the window: the navigation scrolls
   inside it while the brand and the footer stay put, so a short screen never
   hides the last items. The scrollbar itself is hidden - the list is short and
   a permanent gutter beside seven links is noise.
   -------------------------------------------------------------------------- */

.sidebar {
  overflow: hidden;
  padding-bottom: 14px;
}

.sidebar .brand { flex-shrink: 0; }

.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 -4px;
  padding: 0 4px;
  scrollbar-width: none;
}

.sidebar-nav::-webkit-scrollbar { width: 0; height: 0; }

.sidebar-footer { flex-shrink: 0; }

/* Spacing that adds up.

   Every block on a page - a stat row, a card, a two-column grid - sits in one
   flow with one gap, instead of each carrying its own margin and hoping they
   agree. That is what was making the columns look misaligned: two neighbouring
   cards were being spaced by different rules. */

.main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 30px 60px;
}

.main > .card,
.main > .stat-grid,
.main > .grid-2,
.main > .row { margin: 0; }

.card + .card { margin-top: 0; }

.stat-grid { margin-bottom: 0; }

.grid-2 { align-items: stretch; }
.grid-2 > .card { height: 100%; }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: stretch;
}

.row > .card { flex: 1 1 340px; min-width: 0; }

/* Motion.

   Everything that arrives, arrives the same way: a short rise with a small
   stagger down the page, so a list reads as one thing appearing rather than
   twenty. Anyone who has asked their system to stop animating gets none of it. */

.main > * { animation: rise .3s cubic-bezier(.2, .7, .3, 1) both; }
.main > *:nth-child(1) { animation-delay: .00s; }
.main > *:nth-child(2) { animation-delay: .04s; }
.main > *:nth-child(3) { animation-delay: .08s; }
.main > *:nth-child(4) { animation-delay: .12s; }
.main > *:nth-child(5) { animation-delay: .16s; }
.main > *:nth-child(n+6) { animation-delay: .2s; }

.card {
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.card:hover { border-color: var(--border-strong); }

.nav-item { transition: background .16s ease, color .16s ease, padding-left .16s ease; }
.nav-item:hover { padding-left: 14px; }

.btn { transition: background .16s ease, border-color .16s ease, color .16s ease, transform .12s ease; }
.btn:active { transform: scale(.97); }

@media (prefers-reduced-motion: reduce) {
  .main > *,
  .card,
  .stat,
  .modal-card,
  .modal-backdrop,
  .profile-menu { animation: none !important; transition: none !important; }
}


/* Filtering and paging ----------------------------------------------------
   A list long enough to need a pager needs a search box above it; the two
   belong together and are styled as one bar. */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.filter-bar .input {
  margin: 0;
}

.filter-bar input[type="search"] {
  flex: 1 1 260px;
  min-width: 200px;
}

.filter-bar select {
  width: auto;
  min-width: 140px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.pager-buttons {
  display: flex;
  gap: 8px;
}

.cell-main {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.cell-main .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--text-muted);
  opacity: 0.45;
}

.cell-main .dot.on {
  background: var(--success);
  opacity: 1;
}

.small {
  font-size: 12px;
}


/* ==========================================================================
   Colour and iconography

   The panel was one accent on grey. Administration tools earn their colour:
   each kind of thing gets one, so a glance at a page tells you what you are
   looking at before you read a word. The icons are drawn by CSS from the
   action each control already declares, which keeps the markup about meaning
   and the stylesheet about appearance.
   ========================================================================== */

:root {
  --tint-devices: #4f7cff;
  --tint-sessions: #9b6cff;
  --tint-users: #f0a13c;
  --tint-audit: #38bdf8;
  --tint-fleet: #2fbf71;
}

/* Cards ------------------------------------------------------------------ */

.card {
  position: relative;
  overflow: hidden;
}

/* A thin coloured edge, rather than a coloured card: it marks the section
   without shouting over the content. */
.card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), transparent);
  opacity: 0.85;
}

.stat {
  position: relative;
  overflow: hidden;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px -18px rgba(0, 0, 0, 0.55);
}

.stat::after {
  content: "";
  position: absolute;
  right: -28px;
  top: -28px;
  width: 86px;
  height: 86px;
  border-radius: 999px;
  background: var(--accent-soft);
}

.stat:nth-child(2)::after { background: var(--success-soft); }
.stat:nth-child(3)::after { background: rgba(155, 108, 255, 0.16); }
.stat:nth-child(4)::after { background: rgba(240, 161, 60, 0.16); }

.stat:nth-child(2) .value { color: var(--success); }
.stat:nth-child(3) .value { color: #9b6cff; }
.stat:nth-child(4) .value { color: #f0a13c; }

/* Navigation ------------------------------------------------------------- */

.nav-item .icon {
  color: var(--text-muted);
  transition: color 0.15s ease;
}

.nav-item[data-page="devices"] .icon,
.nav-item[data-page="fleet"] .icon { color: var(--tint-devices); }
.nav-item[data-page="sessions"] .icon { color: var(--tint-sessions); }
.nav-item[data-page="users"] .icon { color: var(--tint-users); }
.nav-item[data-page="audit"] .icon { color: var(--tint-audit); }
.nav-item[data-page="announcements"] .icon { color: #f0a13c; }
.nav-item[data-page="releases"] .icon { color: var(--success); }
.nav-item[data-page="invitations"] .icon,
.nav-item[data-page="email"] .icon { color: #38bdf8; }
.nav-item[data-page="policy"] .icon { color: #9b6cff; }
.nav-item[data-page="database"] .icon { color: var(--danger); }

/* Filter bar ------------------------------------------------------------- */

.filter-bar {
  background: color-mix(in srgb, var(--bg-hover) 60%, transparent);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.filter-bar .input,
.filter-bar input[type="search"],
.filter-bar select {
  height: 38px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.filter-bar input[type="search"] {
  padding-left: 36px;
}

/* One ring, in the accent colour, rather than the browser's own outline. */
.filter-bar .input:focus,
.filter-bar input[type="search"]:focus,
.filter-bar select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-bar input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}

/* The magnifier sits in the field rather than beside it. */
.filter-bar {
  position: relative;
}

.filter-bar::before {
  content: "⌕";
  position: absolute;
  left: 25px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 17px;
  line-height: 1;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 1;
}

.filter-bar select {
  padding-right: 32px;
}

/* Buttons ---------------------------------------------------------------- */

.btn::before {
  font-size: 13px;
  line-height: 1;
}

.btn[data-act="refresh"]::before { content: "↻ "; color: var(--accent); }
.btn[data-act="new"]::before { content: "＋ "; color: var(--success); }
.btn[data-act="invite"]::before { content: "✉ "; color: #38bdf8; }
.btn[data-act="save"]::before { content: "✓ "; color: var(--success); }
.btn[data-act="test"]::before { content: "⇄ "; color: #38bdf8; }
.btn[data-list="prev"]::before { content: ""; }
.btn[data-list="next"]::after { content: ""; }

.btn[data-rename]::before { content: "✎ "; color: var(--accent); }
.btn[data-remove]::before,
.btn[data-delete-user]::before { content: "🗑 "; }
.btn[data-block]::before { content: "⛔ "; }
.btn[data-connect]::before { content: ""; }
.btn[data-detail]::before { content: "◎ "; color: var(--accent); }

/* A primary button keeps its own colour; the icon inherits it rather than
   fighting it. */
.btn.primary::before,
.btn.danger::before { color: currentColor; }

/* Tables ----------------------------------------------------------------- */

tbody tr {
  transition: background 0.12s ease;
}

tbody tr:hover {
  background: var(--bg-hover);
}

.badge {
  border-radius: 999px;
}


/* The live indicator ------------------------------------------------------
   Grey when the panel is on its own, green and gently breathing while the
   server's event stream is open. The pulse runs only when it is live, so a
   disconnected panel costs nothing. */
.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--text-faint);
  opacity: 0.5;
  margin-right: 4px;
}

.live-dot.on {
  background: var(--success);
  opacity: 1;
  box-shadow: 0 0 0 0 rgba(47, 191, 113, 0.55);
  animation: live-pulse 2.4s ease-in-out infinite;
}

@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(47, 191, 113, 0.5); }
  70%  { box-shadow: 0 0 0 7px rgba(47, 191, 113, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 191, 113, 0); }
}


/* An input with no type attribute is still a text box, but the type selectors
   above do not match it. The class does. */
.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* A label that wraps its own control: the word above, the control below. */
label.field {
  display: block;
  margin-bottom: 14px;
  font-weight: 550;
}

label.field > span {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

label.field small {
  display: block;
  margin-top: 6px;
  font-weight: 450;
}

/* Two columns where the pair belongs together, one on a narrow screen. */
.card .grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}


/* Top bar controls --------------------------------------------------------
   One size, one shape, one baseline. The controls were a mix of a bare dot, a
   glyph at one size, an emoji at another and an avatar at a third, which reads
   as four unrelated things rather than one row. */

.topbar-actions {
  gap: 8px;
}

.topbar-actions .icon-btn,
.topbar-actions .profile-btn,
.topbar-actions .profile-btn .avatar {
  width: 36px;
  height: 36px;
}

.topbar-actions .icon-btn {
  font-size: 16px;
  line-height: 1;
  color: var(--text-muted);
}

.topbar-actions .icon-btn:hover {
  color: var(--text);
}

/* The bell is an emoji, which every vendor draws at its own weight; taking the
   colour out of it puts it on terms with the rest. */
#bell {
  filter: grayscale(1);
  opacity: 0.85;
}

#bell:hover {
  filter: none;
  opacity: 1;
}

/* The live dot is a state, not a button, so it keeps its own size but sits on
   the same centre line and takes the same slot width. */
.topbar-actions .live-dot {
  width: 36px;
  height: 36px;
  margin: 0;
  border-radius: 999px;
  background: transparent;
  display: grid;
  place-items: center;
}

.topbar-actions .live-dot::after {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--text-faint);
  opacity: 0.55;
}

.topbar-actions .live-dot.on::after {
  background: var(--success);
  opacity: 1;
}

.topbar-actions .live-dot.on::after {
  animation: live-pulse 2.4s ease-in-out infinite;
}

.topbar-actions .profile-btn .avatar {
  font-size: 12.5px;
}


/* Row actions -------------------------------------------------------------
   One height, one baseline, one gap. The buttons in a table row were sized by
   their own contents - an icon here, two words there - so a row of them read
   as a row of different things. */

td.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

td.actions .btn {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  line-height: 1;
  white-space: nowrap;
}

td.actions .btn::before {
  display: inline-block;
  width: 14px;
  text-align: center;
  font-size: 13px;
}

/* The table cell holding them should not stretch the row taller than the
   buttons need. */
tbody td {
  vertical-align: middle;
}


/* Device detail -----------------------------------------------------------
   A label and a value per line, and a bar per disk. Everything a machine
   reported, in the order somebody asks for it. */

.detail-grid {
  display: grid;
  gap: 2px;
}

.detail-row {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}

.detail-row:last-child { border-bottom: 0; }

.detail-label {
  font-size: 12.5px;
  color: var(--text-muted);
}

.detail-value {
  font-size: 13.5px;
  word-break: break-word;
}

.detail-heading {
  margin: 18px 0 10px;
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.disks { display: grid; gap: 12px; }

.disk-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  margin-bottom: 6px;
}

.meter {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-hover);
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.meter span.warn { background: #f0a13c; }
.meter span.full { background: var(--danger); }


/* Row action buttons ------------------------------------------------------
   Four squares of one size, on one line, each saying what it does on hover.
   Words in a table row push the row wider than the data in it. */

.row-btn {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease, transform 0.1s ease;
}

.row-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--accent);
}

.row-btn:active:not(:disabled) { transform: scale(0.94); }

.row-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.row-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.row-btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.row-btn.danger {
  color: var(--danger);
}

.row-btn.danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger);
}

/* The cell holds them in one line and keeps them together. */
td.actions {
  flex-wrap: nowrap;
  white-space: nowrap;
}

/* Service status ---------------------------------------------------------
   One tile per service on the server overview: the state is the thing being
   read, so it is a colour and a word, not a paragraph. */
.services {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.service {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--bg-hover);
}

.service.ok { border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
.service.degraded { border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); }
.service.down { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }

.service-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 6px;
}

.service-head .dot.warn { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.service-head .dot.off { background: var(--text-faint); }

/* Workspace picker -------------------------------------------------------
   The chip opens its own list, anchored under itself: the workspace is
   chosen where it is shown rather than from the account menu at the far end
   of the bar. */
.workspace-picker { position: relative; }

.workspace-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 10px);
  z-index: 40;
  width: 260px;
  padding: 12px;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .28);
  animation: menu-in .16s ease-out;
}

/* Email templates --------------------------------------------------------
   Editing on the left, the rendered message on the right: the only way to
   judge wording is to see it laid out. */
.tpl-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.tpl-tab {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}

.tpl-tab:hover { border-color: var(--accent); color: var(--text); }

.tpl-tab.current {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.tpl-editor {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(320px, 1.1fr);
  gap: 20px;
  align-items: start;
}

@media (max-width: 1100px) {
  .tpl-editor { grid-template-columns: 1fr; }
}

.tpl-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-hover);
}

.tpl-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.tpl-preview-head .mono {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* White regardless of the panel's theme: it is showing an email, and email
   is read on a white page. */
.tpl-preview iframe {
  display: block;
  width: 100%;
  height: 560px;
  border: 0;
  background: #eef1f7;
}

.input.color {
  padding: 4px;
  height: 38px;
  cursor: pointer;
}

/* Per-platform files on the releases page --------------------------------- */
.platforms {
  margin: 4px 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-hover);
}

.platform {
  display: grid;
  grid-template-columns: 150px 1fr 110px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

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

@media (max-width: 760px) {
  .platform { grid-template-columns: 1fr; }
}
