/* ==========================================================================
   ISRAR WireGuard Manager
   Design rule: the chrome is achromatic. Every coloured pixel is peer state.
   ========================================================================== */

:root {
  /* Surfaces, dark by default. */
  --ink:        #0f1216;
  --surface:    #161a20;
  --raised:     #1d222a;
  --sunken:     #0b0e12;
  --line:       #2a313b;
  --line-soft:  #212832;

  --text:       #e7ebf0;
  --text-dim:   #a8b2c0;
  --muted:      #8a94a3;
  --faint:      #626d7c;

  /* The only hues in the interface. Each one means a peer state. */
  --online:     #39d98a;
  --idle:       #7a8698;
  --disabled:   #e8b451;
  --expired:    #f0655c;

  --online-bg:   rgba(57, 217, 138, .12);
  --idle-bg:     rgba(122, 134, 152, .14);
  --disabled-bg: rgba(232, 180, 81, .13);
  --expired-bg:  rgba(240, 101, 92, .13);

  /* Primary action carries no hue, so status colours never compete. */
  --action:      #f0f2f5;
  --action-text: #12161c;
  --focus:       #6ea8fe;

  --rail-w: 232px;
  --radius-control: 7px;
  --radius-panel: 11px;

  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text",
          "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono",
          "Roboto Mono", Consolas, "Liberation Mono", monospace;

  --shadow-pop: 0 24px 60px rgba(0, 0, 0, .5);
  --dur: .16s;
}

[data-theme="light"] {
  --ink:        #f6f7f9;
  --surface:    #ffffff;
  --raised:     #f0f2f5;
  --sunken:     #eceff3;
  --line:       #dde2e9;
  --line-soft:  #e7ebf0;

  --text:       #141922;
  --text-dim:   #3d4756;
  --muted:      #64707f;
  --faint:      #8a94a3;

  --online:     #17a463;
  --idle:       #7a8698;
  --disabled:   #ad7a10;
  --expired:    #cf3a30;

  --online-bg:   rgba(23, 164, 99, .1);
  --idle-bg:     rgba(122, 134, 152, .12);
  --disabled-bg: rgba(173, 122, 16, .1);
  --expired-bg:  rgba(207, 58, 48, .09);

  --action:      #141922;
  --action-text: #ffffff;
  --focus:       #1d5fd0;

  --shadow-pop: 0 24px 60px rgba(20, 25, 34, .18);
}

* { box-sizing: border-box; }

html, body { height: 100%; }
html { overflow: hidden; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

/* Machine data only: addresses, keys, ports, byte counts. */
.mono, .m { font-family: var(--mono); font-size: .92em; letter-spacing: -.01em; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

/* ------------------------------------------------------------------ shell */

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

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

.rail-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.rail-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: grid; place-items: center;
  background: var(--raised);
  border: 1px solid var(--line);
  flex: none;
}

.rail-mark svg { width: 19px; height: 19px; }

.rail-title { font-weight: 640; letter-spacing: -.01em; line-height: 1.2; }
.rail-sub { color: var(--muted); font-size: 11.5px; line-height: 1.3; }

.rail-nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--radius-control);
  color: var(--text-dim);
  text-decoration: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  width: 100%;
  text-align: left;
  transition: background var(--dur), color var(--dur);
}

.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .82; }
.nav-item:hover { background: var(--raised); color: var(--text); }

.nav-item[aria-current="page"] {
  background: var(--raised);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--text);
}

.nav-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.rail-foot { padding: 12px 10px 16px; border-top: 1px solid var(--line-soft); }

.account {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-control);
  background: var(--raised);
  border: 1px solid var(--line-soft);
}

.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ink);
  border: 1px solid var(--line);
  font-size: 11.5px; font-weight: 640;
  flex: none;
}

.account-name { font-size: 12.5px; font-weight: 570; line-height: 1.25; }
.account-role { font-size: 11px; color: var(--muted); line-height: 1.25; }

.rail-tools { display: flex; gap: 6px; margin-top: 8px; }
.rail-tools .btn { flex: 1; justify-content: center; }

/* ------------------------------------------------------------------- main */

.main { min-width: 0; display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 26px;
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.page-title { font-size: 17px; font-weight: 640; letter-spacing: -.015em; margin: 0; }
.page-note { color: var(--muted); font-size: 12.5px; margin: 1px 0 0; }

.topbar-spacer { flex: 1; }

.live {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--muted);
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.live .pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--online);
}

.live.paused .pulse { background: var(--idle); }

.live[data-live="true"] .pulse { animation: breathe 2.4s ease-in-out infinite; }

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}

.content {
  padding: 22px 26px 26px;
  max-width: none;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Views that fill the viewport: the page stays still and the table scrolls
   inside its own panel, with the header and pager pinned. */
.content.fill { overflow: hidden; display: flex; flex-direction: column; }
.content.fill > section:not([hidden]) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.content.fill .panel.grow {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

.content.fill .panel.grow .toolbar,
.content.fill .panel.grow .panel-head,
.content.fill .panel.grow .bulk-bar,
.content.fill .panel.grow .pager { flex: none; }

.content.fill .panel.grow .table-wrap { flex: 1; min-height: 0; overflow: auto; }
.content.fill .panel.grow .activity-strip { flex: 1; min-height: 0; overflow-y: auto; align-content: start; }
.content.fill .panel.grow .empty { margin: auto 0; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--text);
  padding: 8px 13px;
  border-radius: var(--radius-control);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  transition: background var(--dur), border-color var(--dur), opacity var(--dur);
}

.btn svg { width: 15px; height: 15px; }
.btn:hover:not(:disabled) { border-color: var(--faint); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.primary {
  background: var(--action);
  border-color: var(--action);
  color: var(--action-text);
}
.btn.primary:hover:not(:disabled) { opacity: .88; }

.btn.ghost { background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--raised); }

.btn.destructive {
  background: transparent;
  border-color: color-mix(in srgb, var(--expired) 45%, transparent);
  color: var(--expired);
}
.btn.destructive:hover:not(:disabled) {
  background: var(--expired-bg);
}

.btn.solid-destructive {
  background: var(--expired);
  border-color: var(--expired);
  color: #fff;
}

.btn.sm { padding: 5px 9px; font-size: 12px; gap: 5px; }
.btn.sm svg { width: 14px; height: 14px; }
.btn.icon { padding: 7px; }
.btn.icon svg { width: 16px; height: 16px; }
.btn.block { width: 100%; justify-content: center; }

/* ----------------------------------------------------------------- panels */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  margin-bottom: 18px;
  overflow: hidden;
}

.panel-head {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-head h2 { margin: 0; font-size: 14.5px; font-weight: 620; letter-spacing: -.01em; }
.panel-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 18px; }

/* ------------------------------------------------------------------ stats */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  padding: 14px 15px;
}

.stat-label { color: var(--muted); font-size: 12px; margin-bottom: 7px; }

.stat-value {
  font-size: 23px; font-weight: 640;
  letter-spacing: -.025em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-value.small { font-size: 15px; font-weight: 570; letter-spacing: -.01em; }
.stat-meta { color: var(--faint); font-size: 11.5px; margin-top: 5px; }
.stat-value.on { color: var(--online); }
.stat-value.warn { color: var(--disabled); }
.stat-value.bad { color: var(--expired); }

/* --------------------------------------------------- peer activity strip */

.activity-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
  gap: 10px;
  padding: 16px 18px;
}

.peer-tile {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 12px;
  background: var(--raised);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: border-color var(--dur);
}

.peer-tile:hover { border-color: var(--faint); }

.peer-tile-top {
  display: flex; align-items: center; gap: 7px; margin-bottom: 3px;
}

.peer-tile-name {
  font-weight: 570; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.peer-tile-ip { color: var(--muted); font-size: 11.5px; }

.spark { display: block; width: 100%; height: 26px; margin-top: 8px; }

/* ----------------------------------------------------------------- status */

.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 540;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }

.status-online   { color: var(--online);   background: var(--online-bg);   border-color: color-mix(in srgb, var(--online) 28%, transparent); }
.status-idle     { color: var(--idle);     background: var(--idle-bg);     border-color: color-mix(in srgb, var(--idle) 28%, transparent); }
.status-disabled { color: var(--disabled); background: var(--disabled-bg); border-color: color-mix(in srgb, var(--disabled) 30%, transparent); }
.status-expired  { color: var(--expired);  background: var(--expired-bg);  border-color: color-mix(in srgb, var(--expired) 30%, transparent); }

.status-online   .dot { background: var(--online); }
.status-idle     .dot { background: var(--idle); }
.status-disabled .dot { background: var(--disabled); }
.status-expired  .dot { background: var(--expired); }

/* ------------------------------------------------------------------ table */

.toolbar {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

.search {
  position: relative; flex: 1; min-width: 190px; max-width: 380px;
}

.search svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--muted); pointer-events: none;
}

.search input { padding-left: 32px; }

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  overflow: hidden;
  background: var(--raised);
}

.segmented button {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 12px; font: inherit; font-size: 12.5px; font-weight: 540;
  cursor: pointer; white-space: nowrap;
  border-right: 1px solid var(--line-soft);
}

.segmented button:last-child { border-right: 0; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 560;
  color: var(--muted);
  background: var(--raised);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 3;
}

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th .arrow { opacity: .55; font-size: 10px; margin-left: 3px; }

td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  vertical-align: middle;
}

tbody tr:hover { background: var(--raised); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.selected { background: var(--raised); }

td.shrink { width: 1%; white-space: nowrap; }
.cell-name { font-weight: 560; }
.cell-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

.key-cell {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
  max-width: 130px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.row-actions { display: flex; gap: 5px; justify-content: flex-end; }

.tag-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--raised);
  border: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-dim);
}

/* -------------------------------------------------------------- selection */

.bulk-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.bulk-bar .spacer { flex: 1; }

input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--focus);
  cursor: pointer;
  margin: 0;
}

/* ----------------------------------------------------------------- paging */

.pager {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12.5px;
}

.pager .spacer { flex: 1; }

/* ------------------------------------------------------------------ forms */

label { display: block; color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--sunken);
  color: var(--text);
  border-radius: var(--radius-control);
  padding: 9px 11px;
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color var(--dur);
}

input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { border-color: var(--focus); }
input:disabled, textarea:disabled { opacity: .6; cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: var(--faint); }

textarea { font-family: var(--mono); font-size: 12.5px; resize: vertical; line-height: 1.55; }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

.field { margin-bottom: 14px; }
.field-hint { color: var(--faint); font-size: 11.5px; margin-top: 5px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.span-2 { grid-column: 1 / -1; }

.inline-group { display: flex; gap: 8px; }
.inline-group input { flex: 1; }

/* ---------------------------------------------------------------- dialogs */

dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 60px);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 13px;
  padding: 0;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

dialog::backdrop { background: rgba(6, 8, 11, .72); backdrop-filter: blur(2px); }
dialog.wide { width: min(880px, calc(100vw - 32px)); }

.dialog-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.dialog-head h3 { margin: 0; font-size: 15px; font-weight: 620; letter-spacing: -.01em; }
.dialog-head p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.dialog-head .spacer { flex: 1; }

.dialog-body {
    padding: 20px 20px 24px;
    overflow-y: auto;
    max-height: calc(100vh - 220px);
}

.dialog-body > *:last-child {
    margin-bottom: 0;
}
.dialog-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
  background: var(--raised);
}

.dialog-foot .spacer { flex: 1; }

/* ---------------------------------------------------------------- notices */

.notice {
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.55;
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--text-dim);
}

.notice.caution {
  border-color: color-mix(in srgb, var(--disabled) 35%, transparent);
  background: var(--disabled-bg);
  color: var(--disabled);
}

.notice.danger {
  border-color: color-mix(in srgb, var(--expired) 35%, transparent);
  background: var(--expired-bg);
  color: var(--expired);
}

.form-error {
  color: var(--expired);
  font-size: 12.5px;
  margin-top: 10px;
  min-height: 17px;
}

/* ----------------------------------------------------------------- toasts */

.toast-stack {
  position: fixed; right: 20px; top: 74px; z-index: 9999;
  display: flex; flex-direction: column; gap: 9px;
  width: min(390px, calc(100vw - 32px));
  pointer-events: none;
}

/* Toasts raised into the top layer alongside a modal. */
dialog > .toast-stack {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1;
}

.toast {
  pointer-events: auto;
  display: grid; grid-template-columns: 20px 1fr 18px; gap: 11px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  animation: toast-in .18s ease-out;
}

.toast .glyph { width: 18px; height: 18px; margin-top: 1px; }
.toast.success { border-color: color-mix(in srgb, var(--online) 38%, transparent); }
.toast.success .glyph { color: var(--online); }
.toast.error { border-color: color-mix(in srgb, var(--expired) 40%, transparent); }
.toast.error .glyph { color: var(--expired); }
.toast.info .glyph { color: var(--muted); }

.toast-title { font-weight: 590; font-size: 13px; }
.toast-text { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.45; word-break: break-word; }

.toast-close {
  border: 0; background: transparent; color: var(--muted);
  font-size: 17px; line-height: 1; cursor: pointer; padding: 0;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------ empty/load */

.empty {
  padding: 52px 24px;
  text-align: center;
  color: var(--muted);
}

.empty h3 { margin: 0 0 6px; font-size: 14.5px; font-weight: 590; color: var(--text); }
.empty p { margin: 0 0 16px; font-size: 13px; max-width: 42ch; margin-inline: auto; }

.skeleton {
  background: linear-gradient(90deg, var(--raised) 25%, var(--line-soft) 50%, var(--raised) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  border-radius: 5px;
  height: 11px;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ------------------------------------------------------------- key/value */

.kv { display: grid; grid-template-columns: 190px 1fr; gap: 9px 18px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

/* ------------------------------------------------------------------- tabs */

.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }

.tabs button {
  border: 0; background: transparent; color: var(--muted);
  padding: 9px 13px; font: inherit; font-size: 13px; font-weight: 540;
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}

.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }

/* -------------------------------------------------------------- QR + code */

.qr-frame {
  display: grid; place-items: center;
  padding: 16px;
  background: #fff;
  border-radius: 9px;
  border: 1px solid var(--line);
}

.qr-frame img { display: block; width: 100%; max-width: 246px; height: auto; image-rendering: pixelated; }

.config-split { display: grid; grid-template-columns: 262px 1fr; gap: 18px; align-items: start; }

/* ------------------------------------------------------------------ chart */

.chart-wrap { padding: 6px 4px 0; }
.chart-legend {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--muted);
    margin: 10px 0 18px;
}
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 9px; height: 9px; border-radius: 2px; }

/* ------------------------------------------------------------------ login */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 50% -12%,
      color-mix(in srgb, var(--surface) 85%, transparent), transparent 68%),
    var(--ink);
}

.login-card {
  width: min(392px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 30px 28px 26px;
  box-shadow: var(--shadow-pop);
}

.login-mark {
  width: 44px; height: 44px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--raised); border: 1px solid var(--line);
  margin-bottom: 18px;
}

.login-mark svg { width: 23px; height: 23px; }
.login-card h1 { margin: 0 0 4px; font-size: 19px; font-weight: 640; letter-spacing: -.02em; }
.login-card .lede { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-foot { margin-top: 20px; text-align: center; color: var(--faint); font-size: 11.5px; }

/* ------------------------------------------------------------ responsive */

.rail-toggle { display: none; }

@media (max-width: 1100px) {
  :root { --rail-w: 62px; }
  .rail-brand { justify-content: center; padding: 18px 8px; }
  .rail-brand .rail-text, .rail-sub { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-item span, .nav-count { display: none; }
  .account-text, .rail-tools { display: none; }
  .account { justify-content: center; padding: 7px; }
  .config-split { grid-template-columns: 1fr; }
}

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

  .rail {
    position: fixed; inset: 0 auto 0 0;
    width: 232px; height: 100vh; z-index: 60;
    transform: translateX(-100%);
    transition: transform var(--dur) ease-out;
  }

  .rail.open { transform: none; }
  :root { --rail-w: 0px; }

  .rail-brand { justify-content: flex-start; padding: 20px 18px 18px; }
  .rail-brand .rail-text, .rail-sub { display: block; }
  .nav-item { justify-content: flex-start; padding: 9px 11px; }
  .nav-item span, .nav-count { display: inline; }
  .account { justify-content: flex-start; padding: 9px 10px; }
  .account-text, .rail-tools { display: block; }
  .rail-tools { display: flex; }

  .rail-toggle { display: inline-flex; }
  .content { padding: 16px 14px 48px; }
  .topbar { padding: 12px 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
  .toast-stack { right: 12px; left: 12px; width: auto; top: 66px; }
  .page-note { display: none; }
}

.scrim {
  display: none;
  position: fixed; inset: 0; z-index: 50;
  background: rgba(6, 8, 11, .55);
}

.scrim.show { display: block; }

@media (min-width: 761px) { .scrim { display: none !important; } }

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


.rail-mark {
  background: #fff;
  border-color: var(--line);
  padding: 4px;
  overflow: hidden;
}

.rail-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

[data-theme="dark"] .rail-mark {
  /* A white plate keeps the navy readable against the graphite rail. */
  background: #f4f5f7;
}

.login-logo {
  display: block;
  width: 92px;
  height: auto;
  margin: 0 auto 20px;
}

[data-theme="dark"] .login-logo {
  /* The wordmark is dark navy; lift it slightly so it does not disappear. */
  filter: brightness(1.08);
}

/* ------------------------------------------------------------- help page */

.help-layout {
  display: grid;
  grid-template-columns: 216px 1fr;
  gap: 22px;
  align-items: start;
}

.help-toc {
  position: sticky;
  top: 78px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  padding: 12px 10px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.help-toc-title {
  color: var(--muted);
  font-size: 11.5px;
  padding: 2px 9px 8px;
}

.help-toc a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 12.5px;
  padding: 6px 9px;
  border-radius: 6px;
  line-height: 1.35;
  transition: background var(--dur), color var(--dur);
}

.help-toc a:hover { background: var(--raised); color: var(--text); }

.help-toc a.active {
  background: var(--raised);
  color: var(--text);
  font-weight: 570;
  box-shadow: inset 2px 0 0 var(--text);
}

.help-body { min-width: 0; }

.help-prose { font-size: 13.5px; line-height: 1.65; color: var(--text-dim); }

.help-prose h3 {
  font-size: 13.5px;
  font-weight: 620;
  color: var(--text);
  margin: 22px 0 8px;
  letter-spacing: -.01em;
}

.help-prose h3:first-child { margin-top: 0; }
.help-prose p { margin: 0 0 12px; max-width: 76ch; }
.help-prose ul, .help-prose ol { margin: 0 0 12px; padding-left: 20px; max-width: 76ch; }
.help-prose li { margin-bottom: 6px; }
.help-prose .kv { margin: 0 0 14px; align-items: start; }
.help-prose .kv dt { color: var(--text); font-weight: 560; }
.help-prose .kv dd { color: var(--text-dim); margin-bottom: 8px; }
.help-prose .notice { margin-bottom: 14px; }
.help-prose table { font-size: 13px; }
.help-prose .table-wrap { margin-bottom: 14px; border: 1px solid var(--line); border-radius: 8px; }

.help-prose code {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--sunken);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 1px 5px;
  word-break: break-word;
}

.help-prose kbd {
  font-family: var(--mono);
  font-size: .85em;
  background: var(--raised);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
}

.help-prose a { color: var(--focus); text-decoration: none; }
.help-prose a:hover { text-decoration: underline; }

.help-note {
  border-left: 2px solid var(--disabled);
  padding-left: 12px;
  color: var(--text-dim);
}

.help-watch {
  border-left: 2px solid var(--idle);
  padding-left: 12px;
  font-size: 13px;
}

.help-good { color: var(--online); font-family: var(--mono); font-size: 12.5px; }
.help-bad  { color: var(--muted);  font-family: var(--mono); font-size: 12.5px; }

.help-states { display: flex; flex-direction: column; gap: 9px; margin-bottom: 14px; }

.help-states > div {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.help-states > div > span:last-child { flex: 1; min-width: 240px; font-size: 13px; }

@media (max-width: 1000px) {
  .help-layout { grid-template-columns: 1fr; }
  .help-toc {
    position: static;
    max-height: none;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }
  .help-toc-title { width: 100%; }
}

/* ---------------------------------------------------------- import UI */

.drop-zone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-panel);
  padding: 26px 20px;
  text-align: center;
  background: var(--sunken);
  cursor: pointer;
  transition: border-color var(--dur), background var(--dur);
}

.drop-zone:hover, .drop-zone.over { border-color: var(--focus); background: var(--raised); }
.drop-zone svg { width: 26px; height: 26px; color: var(--muted); margin-bottom: 8px; }
.drop-zone strong { display: block; font-size: 13.5px; margin-bottom: 3px; }
.drop-zone span { color: var(--muted); font-size: 12.5px; }
.drop-zone.has-file { border-style: solid; border-color: var(--online); }

.import-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.import-stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: var(--raised);
}

.import-stat b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.import-stat span { color: var(--muted); font-size: 11.5px; }
.import-stat.ok b   { color: var(--online); }
.import-stat.warn b { color: var(--disabled); }
.import-stat.bad b  { color: var(--expired); }

.import-rows { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.import-rows table { font-size: 12.5px; }
.import-rows th { position: sticky; top: 0; z-index: 2; }
.row-ok      { color: var(--online); }
.row-warning { color: var(--disabled); }
.row-error   { color: var(--expired); }

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  font-size: 13px;
}

.checkbox-row input { width: 15px; flex: none; margin-top: 2px; }
.checkbox-row span { color: var(--muted); font-size: 12px; display: block; margin-top: 2px; }
.checkbox-row label { margin: 0; color: var(--text); font-size: 13px; }

.step-list { counter-reset: step; margin: 0; padding: 0; list-style: none; }

.step-list li {
  position: relative;
  padding-left: 30px;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.6;
}

.step-list li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0; top: 1px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--raised);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
  color: var(--text);
}
/* ===========================================================================
   APPEND THIS TO THE END OF wwwroot/css/app.css
   Interface scale-up, roughly 15 percent.

   These use the same selectors as the rules above, so they win simply by
   coming later. To tune, change the numbers here rather than hunting through
   the original rules. To undo, delete this whole block.
   =========================================================================== */

:root {
  --rail-w: 262px;
}

body { font-size: 16px; }

/* ------------------------------------------------------------ navigation */

.rail-brand { padding: 22px 20px 20px; }
.rail-mark { width: 40px; height: 40px; border-radius: 10px; }
.rail-mark svg { width: 22px; height: 22px; }
.rail-title { font-size: 16.5px; }
.rail-sub { font-size: 13px; }

.nav-item { padding: 11px 13px; gap: 12px; font-size: 15px; }
.nav-item svg { width: 19px; height: 19px; }
.nav-count { font-size: 12.5px; }

.avatar { width: 32px; height: 32px; font-size: 13px; }
.account-name { font-size: 14px; }
.account-role { font-size: 12.5px; }

/* ---------------------------------------------------------------- topbar */

.topbar { padding: 16px 30px; }
.page-title { font-size: 19.5px; }
.page-note { font-size: 14px; }
.live { font-size: 13.5px; padding: 7px 12px; }
.live .pulse { width: 8px; height: 8px; }

.content { padding: 26px 30px 30px; }

/* --------------------------------------------------------------- buttons */

.btn { font-size: 14.5px; padding: 9px 15px; gap: 8px; }
.btn svg { width: 17px; height: 17px; }
.btn.sm { font-size: 13.5px; padding: 6px 11px; }
.btn.sm svg { width: 15px; height: 15px; }
.btn.icon { padding: 8px; }
.btn.icon svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- panels */

.panel-head { padding: 17px 20px; }
.panel-head h2 { font-size: 16.5px; }
.panel-head p { font-size: 14px; }
.panel-body { padding: 20px; }

.stat { padding: 16px 17px; }
.stat-label { font-size: 13.5px; }
.stat-value { font-size: 26px; }
.stat-value.small { font-size: 17px; }
.stat-meta { font-size: 13px; }

.peer-tile { padding: 13px 14px; }
.peer-tile-name { font-size: 14.5px; }
.peer-tile-ip { font-size: 13px; }

/* ----------------------------------------------------------------- table */

th { font-size: 13.5px; padding: 11px 16px; }
td { font-size: 14.5px; padding: 13px 16px; }
.cell-sub { font-size: 12.5px; }
.key-cell { font-size: 13px; max-width: 160px; }
.tag-chip { font-size: 13px; padding: 3px 9px; }
.status { font-size: 13.5px; padding: 4px 10px 4px 8px; }
.dot { width: 8px; height: 8px; }

.toolbar { padding: 14px 20px; gap: 10px; }
.search { min-width: 220px; max-width: 440px; }
.search input { padding-left: 36px; }
.search svg { width: 17px; height: 17px; left: 11px; }
.segmented button { font-size: 13.5px; padding: 8px 14px; }
.bulk-bar { font-size: 14.5px; padding: 12px 20px; }
.pager { font-size: 13.5px; padding: 13px 20px; }

/* ----------------------------------------------------------------- forms */

label { font-size: 13.5px; }
input, select, textarea { font-size: 14.5px; padding: 10px 12px; }
textarea { font-size: 13.5px; }
.field-hint { font-size: 12.5px; }
.field { margin-bottom: 16px; }
input[type="checkbox"] { width: 17px; height: 17px; }

/* --------------------------------------------------------------- dialogs */

dialog { width: min(700px, calc(100vw - 32px)); }
dialog.wide { width: min(1000px, calc(100vw - 32px)); }
.dialog-head { padding: 19px 22px; }
.dialog-head h3 { font-size: 17px; }
.dialog-head p { font-size: 14px; }
.dialog-body { padding: 22px 22px 26px; }
.dialog-foot { padding: 16px 22px; }

.notice { font-size: 14px; padding: 13px 15px; }
.form-error { font-size: 13.5px; }
.kv { font-size: 14.5px; grid-template-columns: 210px 1fr; }
.empty h3 { font-size: 16px; }
.empty p { font-size: 14.5px; }

/* ---------------------------------------------------------------- toasts */

.toast-stack { width: min(430px, calc(100vw - 32px)); }
.toast-title { font-size: 14.5px; }
.toast-text { font-size: 13.5px; }

/* ------------------------------------------------------------------ help */

.help-toc { width: 100%; }
.help-toc a { font-size: 13.5px; padding: 7px 10px; }
.help-toc-title { font-size: 12.5px; }
.help-prose { font-size: 15px; }
.help-prose h3 { font-size: 15px; }
.help-prose table { font-size: 14.5px; }
.help-layout { grid-template-columns: 246px 1fr; }

/* ---------------------------------------------------------------- import */

.import-stat b { font-size: 20px; }
.import-stat span { font-size: 12.5px; }
.import-rows table { font-size: 13.5px; }
.drop-zone strong { font-size: 15px; }
.drop-zone span { font-size: 13.5px; }
.checkbox-row { font-size: 14.5px; }
.checkbox-row label { font-size: 14.5px; }
.checkbox-row span { font-size: 13px; }
.step-list li { font-size: 14.5px; padding-left: 34px; }
.step-list li::before { width: 23px; height: 23px; font-size: 12px; }

/* ------------------------------------------------------------ responsive */

/* The collapsed icon rail needs to grow with everything else. */
@media (max-width: 1100px) {
  :root { --rail-w: 70px; }
}

@media (max-width: 760px) {
  :root { --rail-w: 0px; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 14px 16px; }
}
