/* VPN admin panel — local IBM Plex + Lucide, no CDN.
   Light-first slate/teal system; optional prefers-color-scheme dark. */

/* ─── IBM Plex Sans (OFL) ─────────────────────────────────── */
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans/ibm-plex-sans-cyrillic-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans/ibm-plex-sans-cyrillic-400-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans/ibm-plex-sans-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans/ibm-plex-sans-cyrillic-ext-500-normal.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans/ibm-plex-sans-cyrillic-500-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans/ibm-plex-sans-latin-ext-500-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans/ibm-plex-sans-cyrillic-ext-600-normal.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans/ibm-plex-sans-cyrillic-600-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans/ibm-plex-sans-latin-ext-600-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans/ibm-plex-sans-cyrillic-ext-700-normal.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans/ibm-plex-sans-cyrillic-700-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans/ibm-plex-sans-latin-ext-700-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-sans/ibm-plex-sans-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ─── IBM Plex Mono (OFL) — IPs / CN / audit ──────────────── */
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-mono/ibm-plex-mono-cyrillic-400-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-mono/ibm-plex-mono-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-mono/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-mono/ibm-plex-mono-cyrillic-500-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-mono/ibm-plex-mono-latin-ext-500-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-mono/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light dark;

  /* Public palette */
  --bg: #F4F7F9;
  --surface: #FFFFFF;
  --border: #D9E2EC;
  --text: #102A43;
  --muted: #627D98;
  --primary: #0F766E;
  --danger: #E11D48;
  --success: #059669;
  --warn: #D97706;

  --primary-hover: #0D9488;
  --primary-press: #115E59;
  --primary-soft: rgba(15, 118, 110, 0.12);
  --danger-soft: rgba(225, 29, 72, 0.12);
  --success-soft: rgba(5, 150, 105, 0.12);
  --warn-soft: rgba(217, 119, 6, 0.14);

  /* Compatibility aliases used across the stylesheet */
  --bg-elevated: var(--surface);
  --bg-grouped: var(--surface);
  --bg-inset: #E8EEF4;
  --bg-fill: rgba(16, 42, 67, 0.06);
  --bg-fill-strong: rgba(16, 42, 67, 0.10);
  --separator: var(--border);
  --separator-opaque: #CBD5E1;
  --text-secondary: var(--muted);
  --text-tertiary: #9FB3C8;
  --label: var(--text);
  --accent: var(--primary);
  --accent-press: var(--primary-press);
  --accent-soft: var(--primary-soft);
  --ok: var(--success);
  --ok-soft: var(--success-soft);
  --bad: var(--danger);
  --bad-soft: var(--danger-soft);

  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --radius-btn: 10px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --pad: var(--space-4);
  --pad-sm: var(--space-3);
  --pad-xs: var(--space-2);
  --control-font: 15px;
  --control-pad-y: 10px;
  --control-pad-x: 12px;

  --shadow-nav: 0 1px 0 var(--border);
  --shadow-card: 0 1px 2px rgba(16, 42, 67, 0.04);
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --nav-h: 52px;
  --tab-h: 44px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --content-max: 980px;
  --phone-max: 420px;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --duration: 180ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1220;
    --surface: #152033;
    --border: #243B53;
    --text: #F0F4F8;
    --muted: #9FB3C8;
    --primary: #2DD4BF;
    --danger: #FB7185;
    --success: #34D399;
    --warn: #FBBF24;

    --primary-hover: #5EEAD4;
    --primary-press: #99F6E4;
    --primary-soft: rgba(45, 212, 191, 0.16);
    --danger-soft: rgba(251, 113, 133, 0.16);
    --success-soft: rgba(52, 211, 153, 0.16);
    --warn-soft: rgba(251, 191, 36, 0.16);

    --bg-inset: #1E2D3F;
    --bg-fill: rgba(159, 179, 200, 0.10);
    --bg-fill-strong: rgba(159, 179, 200, 0.16);
    --separator-opaque: #334E68;
    --text-tertiary: #627D98;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35);
  }
}

/* ─── Lucide line icons (local SVG masks) ─────────────────── */

.icon {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
  vertical-align: -0.15em;
}
.icon-sm { width: 1em; height: 1em; }
.icon-lg { width: 1.5em; height: 1.5em; }
.icon-xl { width: 2.25em; height: 2.25em; }

.icon-layout-dashboard { --icon: url("/static/icons/layout-dashboard.svg"); }
.icon-chart-column { --icon: url("/static/icons/chart-column.svg"); }
.icon-users { --icon: url("/static/icons/users.svg"); }
.icon-settings { --icon: url("/static/icons/settings.svg"); }
.icon-log-out { --icon: url("/static/icons/log-out.svg"); }
.icon-log-in { --icon: url("/static/icons/log-in.svg"); }
.icon-plus { --icon: url("/static/icons/plus.svg"); }
.icon-download { --icon: url("/static/icons/download.svg"); }
.icon-file-down { --icon: url("/static/icons/file-down.svg"); }
.icon-search { --icon: url("/static/icons/search.svg"); }
.icon-link { --icon: url("/static/icons/link.svg"); }
.icon-shield { --icon: url("/static/icons/shield.svg"); }
.icon-shield-check { --icon: url("/static/icons/shield-check.svg"); }
.icon-key { --icon: url("/static/icons/key.svg"); }
.icon-monitor { --icon: url("/static/icons/monitor.svg"); }
.icon-inbox { --icon: url("/static/icons/inbox.svg"); }
.icon-x { --icon: url("/static/icons/x.svg"); }
.icon-globe { --icon: url("/static/icons/globe.svg"); }
.icon-refresh-cw { --icon: url("/static/icons/refresh-cw.svg"); }
.icon-ban { --icon: url("/static/icons/ban.svg"); }
.icon-trash-2 { --icon: url("/static/icons/trash-2.svg"); }
.icon-power { --icon: url("/static/icons/power.svg"); }
.icon-wifi { --icon: url("/static/icons/wifi.svg"); }
.icon-wifi-off { --icon: url("/static/icons/wifi-off.svg"); }
.icon-user-plus { --icon: url("/static/icons/user-plus.svg"); }
.icon-arrow-left { --icon: url("/static/icons/arrow-left.svg"); }
.icon-check { --icon: url("/static/icons/check.svg"); }
.icon-external-link { --icon: url("/static/icons/external-link.svg"); }
.icon-activity { --icon: url("/static/icons/activity.svg"); }
.icon-folder { --icon: url("/static/icons/folder.svg"); }
.icon-folders { --icon: url("/static/icons/folders.svg"); }
.icon-folder-plus { --icon: url("/static/icons/folder-plus.svg"); }
.icon-folder-open { --icon: url("/static/icons/folder-open.svg"); }
.icon-pencil { --icon: url("/static/icons/pencil.svg"); }
.icon-chevron-down { --icon: url("/static/icons/chevron-down.svg"); }

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 480px at 10% -10%, rgba(15, 118, 110, 0.08), transparent 55%),
    radial-gradient(900px 420px at 100% 0%, rgba(16, 42, 67, 0.05), transparent 50%),
    var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (prefers-color-scheme: dark) {
  body {
    background:
      radial-gradient(1000px 420px at 8% -8%, rgba(45, 212, 191, 0.08), transparent 55%),
      var(--bg);
  }
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity var(--duration) var(--ease);
}
a:hover { opacity: 0.8; }
a:active { opacity: 0.6; }

/* ─── Top chrome ─────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--separator);
  padding:
    max(var(--space-2), env(safe-area-inset-top, 0px))
    max(var(--pad), env(safe-area-inset-right, 0px))
    var(--space-2)
    max(var(--pad), env(safe-area-inset-left, 0px));
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  max-width: var(--content-max);
  margin: 0 auto;
  min-height: var(--nav-h);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
  color: var(--text);
  line-height: 1.15;
  min-width: 0;
}
.brand:hover { opacity: 1; text-decoration: none; }
.brand .brand-org {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52vw;
}
.brand .brand-mark {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}
.brand .brand-mark span { color: var(--accent); }

.topbar .logout {
  margin: 0;
  flex-shrink: 0;
}
.topbar .logout .btn-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Segmented control / pill tabs */
.tabs {
  display: flex;
  gap: 2px;
  max-width: var(--content-max);
  margin: 4px auto 0;
  padding: 3px;
  background: var(--bg-fill);
  border: 1px solid var(--separator);
  border-radius: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs .tab {
  flex: 1 1 0;
  min-width: max-content;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 8px 12px;
  border-radius: 9px;
  border: none;
  background: transparent;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease),
    transform var(--duration) var(--ease);
  white-space: nowrap;
}
.tabs .tab .icon { width: 15px; height: 15px; }
.tabs .tab:hover {
  opacity: 1;
  text-decoration: none;
  color: var(--text);
}
.tabs .tab:active { transform: scale(0.98); }
.tabs .tab.active {
  background: var(--bg-elevated);
  color: var(--primary);
  box-shadow: var(--shadow-card), 0 0 0 1px var(--separator);
}
@media (prefers-color-scheme: dark) {
  .tabs .tab.active {
    background: var(--bg-inset);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  }
}

/* ─── Main layout ────────────────────────────────────────── */

main {
  padding: var(--space-2) max(var(--pad), env(safe-area-inset-right, 0px)) var(--space-6)
           max(var(--pad), env(safe-area-inset-left, 0px));
  margin: 0 auto;
  width: 100%;
}
main.wide {
  max-width: var(--content-max);
  padding-bottom: calc(var(--space-6) + var(--safe-bottom));
}
main.narrow {
  max-width: var(--phone-max);
  padding-top: max(8vh, var(--space-6));
  padding-bottom: calc(var(--space-6) * 2);
}

#app-panel {
  transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
}
#app-panel.loading {
  opacity: 0.45;
  pointer-events: none;
  transform: translateY(2px);
}

.crumb {
  margin: 4px 0 6px;
  font-size: 14px;
}
.crumb a { font-weight: 500; }

/* ─── Typography ─────────────────────────────────────────── */

h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin: var(--space-2) 0 var(--space-4);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}
h1.mono { font-family: var(--font-mono); font-size: 24px; }

h2 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin: var(--space-5) 0 var(--space-2) var(--pad);
  display: flex;
  align-items: center;
  gap: 8px;
}
h2 .icon { width: 14px; height: 14px; opacity: 0.85; }
h2:first-child,
.card > h2:first-child { margin-top: 0; }
.card > h2 {
  margin-left: 0;
  margin-bottom: var(--space-3);
}
h2.danger { color: var(--bad); }

p { margin: 0 0 var(--space-3); }
p.muted { color: var(--text-secondary); font-size: 14px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin: 0 0 var(--space-4);
}
.page-head h1 { margin: 0; }
.page-head .btn { margin-top: 0; }
.page-head-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.toolbar.filters {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
}
.toolbar.filters .filter-field {
  min-width: 200px;
  max-width: 280px;
}
.toolbar.filters label {
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.toolbar.filters label .icon,
label .icon {
  width: 13px;
  height: 13px;
  color: var(--text-tertiary);
}

#profiles-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
#profiles-list > .card { margin-top: 0; }

.profile-group-details { margin: 0; }
.profile-group-summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
  margin: calc(var(--pad) * -1);
  margin-bottom: 0;
  padding: var(--pad-sm) var(--pad);
  border-bottom: 1px solid transparent;
}
.profile-group-details[open] .profile-group-summary {
  border-bottom-color: var(--separator);
  margin-bottom: var(--space-2);
}
.profile-group-summary::-webkit-details-marker { display: none; }
.profile-group-title {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text);
  min-width: 0;
}
.profile-group-count {
  font-size: 12px;
  font-weight: 500;
  margin-left: auto;
}
.profile-group-chevron {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  transition: transform var(--duration) var(--ease);
}
.profile-group-details:not([open]) .profile-group-chevron {
  transform: rotate(-90deg);
}
.profile-group .profile-list {
  margin-top: 0;
}
.profile-group .empty-state.compact {
  padding: var(--space-4) var(--pad);
}
.profile-group .empty-state.compact p { font-size: 13px; }

.group-create-form {
  margin-bottom: var(--space-4);
}
.group-create-form input { flex: 1; min-width: 0; }
.group-manage-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.group-manage-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  background: var(--bg-inset);
}
.group-rename-form {
  flex: 1;
  min-width: 0;
}
.group-rename-form input { flex: 1; min-width: 0; }
.empty-state.compact {
  padding: var(--space-4);
}
.empty-state.compact .icon {
  width: 22px;
  height: 22px;
}

/* ─── Grouped cards ──────────────────────────────────────── */

.card {
  background: var(--bg-grouped);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  padding: var(--pad);
  margin-bottom: 0;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.card + .card,
.stats + .card,
.alert + .card,
.cols + .card,
.card + .cols,
.cols + .cols {
  margin-top: var(--space-4);
}
section.card { margin-top: 0; }
section.card + section.card,
.stats + section.card,
.alert + section.card { margin-top: var(--space-4); }

.card.auth {
  padding: var(--space-5) var(--pad) var(--space-4);
  border-radius: var(--radius-lg);
}
.card.auth h1 {
  font-size: 26px;
  margin: 0 0 var(--space-2);
}
.card.auth > p.muted { margin-bottom: var(--space-4); }

.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.cols > .card { margin-top: 0; }
@media (max-width: 900px) {
  .cols { grid-template-columns: 1fr; gap: var(--space-4); }
}

/* ─── Stat tiles ─────────────────────────────────────────── */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
}
.stat {
  background: var(--bg-grouped);
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  padding: var(--pad-sm) var(--pad);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-height: 76px;
  box-shadow: var(--shadow-card);
  transition: transform var(--duration) var(--ease);
}
.stat .num {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
}
.stat .num.ok { color: var(--ok); }
.stat .num.muted { color: var(--text-secondary); }
.stat .num.bad { color: var(--bad); }
.stat .num.warn { color: var(--warn); }
.stat .label {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
}

/* ─── Empty states ───────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--pad);
  text-align: center;
  color: var(--text-secondary);
}
.empty-state .icon {
  width: 28px;
  height: 28px;
  opacity: 0.55;
  color: var(--muted);
}
.empty-state p {
  margin: 0;
  font-size: 14px;
}

/* ─── Forms ──────────────────────────────────────────────── */

label {
  display: block;
  margin: var(--space-3) 0 var(--space-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

input,
select,
textarea {
  width: 100%;
  padding: var(--control-pad-y) var(--control-pad-x);
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 10px;
  font-family: var(--font);
  font-size: var(--control-font);
  line-height: 1.35;
  letter-spacing: -0.01em;
  appearance: none;
  -webkit-appearance: none;
  transition: box-shadow var(--duration) var(--ease), background var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
input::placeholder,
textarea::placeholder { color: var(--text-tertiary); }

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--bg-elevated);
}
@media (prefers-color-scheme: dark) {
  input:focus,
  select:focus,
  textarea:focus {
    background: var(--bg-inset);
  }
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23627D98' d='M1.4.6L6 5.2 10.6.6 12 2 6 8 0 2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

small.muted {
  display: block;
  margin-top: var(--space-2);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1) var(--pad);
}
.grid .span2 { grid-column: 1 / -1; }
@media (max-width: 700px) {
  .grid { grid-template-columns: 1fr; }
}

.row {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
  margin: var(--space-3) 0;
}
.row input,
.row select { width: auto; flex: 1 1 200px; }
.inline { display: inline-block; }
.buttons {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-2);
}

/* ─── Buttons ────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: var(--control-pad-y) var(--pad);
  margin-top: var(--space-3);
  background: var(--bg-fill-strong);
  color: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  font-family: var(--font);
  font-size: var(--control-font);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
  cursor: pointer;
  text-align: center;
  transition:
    opacity var(--duration) var(--ease),
    transform var(--duration) var(--ease),
    background var(--duration) var(--ease),
    border-color var(--duration) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn .icon { width: 15px; height: 15px; }
.btn:hover { opacity: 0.9; text-decoration: none; }
.btn:active { transform: scale(0.98); opacity: 0.8; }

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.btn.primary:hover { background: var(--primary-hover); opacity: 1; }
@media (prefers-color-scheme: dark) {
  .btn.primary { color: #0B1220; }
}

.btn.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.btn.danger {
  background: var(--bad-soft);
  color: var(--bad);
}
.btn.ghost {
  background: transparent;
  color: var(--accent);
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}
.btn.small {
  padding: var(--space-1) var(--space-3);
  font-size: 12px;
  margin-top: 0;
  border-radius: 8px;
}
.btn.block {
  width: 100%;
  margin-top: var(--space-4);
  border-radius: 12px;
  padding: var(--space-3) var(--pad);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-text {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  color: var(--accent);
  font-family: var(--font);
  font-size: var(--control-font);
  font-weight: 600;
  cursor: pointer;
  padding: var(--space-2) var(--space-1);
  margin: 0;
  border-radius: 8px;
  transition: opacity var(--duration) var(--ease);
}
.btn-text .icon { width: 15px; height: 15px; }
.btn-text:hover { opacity: 0.75; }
.btn-text:active { opacity: 0.55; }

.small-select {
  width: auto;
  padding: var(--space-1) 32px var(--space-1) var(--space-3);
  font-size: var(--control-font);
  border-radius: 8px;
}

/* ─── Tables ─────────────────────────────────────────────── */

.card table { margin: var(--space-1) calc(var(--pad) * -1) 0; width: calc(100% + var(--pad) * 2); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--separator);
  padding: var(--space-3) var(--pad);
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}
td {
  padding: var(--space-3) var(--pad);
  border-bottom: 1px solid var(--separator);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:active td { background: var(--bg-fill); }

table .mono { font-size: 12px; }
table .pill { font-size: 11px; }
table .small { font-size: 12px; }

.profile-row { cursor: pointer; }
.profile-row:hover td { background: var(--bg-fill); }

td.actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}
td.actions input {
  width: 130px;
  padding: var(--space-1) var(--space-3);
  font-size: 13px;
}
td.actions .btn,
td.actions .btn.small {
  font-size: 12px;
}

@media (max-width: 720px) {
  .card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .card table {
    min-width: 560px;
  }
}

/* ─── Meta / helpers ─────────────────────────────────────── */

.mono {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: -0.01em;
}
.muted { color: var(--text-secondary); }
.small { font-size: 13px; }
.break { word-break: break-all; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  border: none;
  background: var(--bg-fill-strong);
  color: var(--text-secondary);
  line-height: 1.3;
}
.pill.ok {
  color: var(--ok);
  background: var(--ok-soft);
}
.pill.bad {
  color: var(--bad);
  background: var(--bad-soft);
}
.pill.muted {
  color: var(--text-secondary);
  background: var(--bg-fill);
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--separator-opaque);
  vertical-align: middle;
}
.dot.on {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}

.alert {
  padding: var(--pad-sm) var(--pad);
  border-radius: var(--radius);
  margin-bottom: var(--pad);
  border: 1px solid transparent;
  background: var(--bg-fill);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}
.alert.error {
  background: var(--bad-soft);
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 25%, transparent);
}
.alert.warn {
  background: var(--warn-soft);
  color: #9A5B00;
  border-color: color-mix(in srgb, var(--warn) 25%, transparent);
}
.alert.ok {
  background: var(--ok-soft);
  color: #1B7A34;
  border-color: color-mix(in srgb, var(--ok) 25%, transparent);
}
@media (prefers-color-scheme: dark) {
  .alert.warn { color: var(--warn); }
  .alert.ok { color: var(--ok); }
}

.flash {
  padding: var(--space-3) var(--pad);
  border-radius: var(--radius);
  margin-bottom: var(--pad);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
  animation: flash-in 220ms var(--ease);
}
@keyframes flash-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

dl.meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 18px;
  margin: 18px 0 0;
  font-size: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--separator);
}
dl.meta dt { color: var(--text-secondary); font-weight: 500; }
dl.meta dd { margin: 0; }

pre.secret {
  background: var(--bg-inset);
  border: 1px solid var(--separator);
  padding: 12px 14px;
  border-radius: 10px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
}
.qr {
  background: #fff;
  padding: 14px;
  border-radius: 14px;
  width: max-content;
  margin: 14px 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--separator);
}
.qr img { display: block; }

.pager {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  padding: 0 4px;
}

.footer {
  padding: 20px max(16px, env(safe-area-inset-right, 0px))
           calc(24px + var(--safe-bottom))
           max(16px, env(safe-area-inset-left, 0px));
  color: var(--text-tertiary);
  font-size: 12px;
  text-align: center;
  border-top: none;
  max-width: var(--content-max);
  margin: 0 auto;
}

code {
  background: var(--bg-fill);
  padding: 2px 7px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
}

body:not(:has(.topbar)) .footer {
  position: sticky;
  top: 100%;
}

/* ─── Narrow / mobile bottom tab bar ─────────────────────── */

@media (max-width: 640px) {
  body:has(.topbar) {
    padding-bottom: calc(56px + var(--safe-bottom));
  }

  .topbar {
    border-bottom: none;
    padding-bottom: 4px;
  }

  .topbar .tabs.tabs-dock {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    gap: 0;
    margin: 0;
    padding: 4px 6px calc(4px + var(--safe-bottom));
    background: color-mix(in srgb, var(--bg-elevated) 90%, transparent);
    -webkit-backdrop-filter: saturate(160%) blur(16px);
    backdrop-filter: saturate(160%) blur(16px);
    border: none;
    border-top: 1px solid var(--separator);
    border-radius: 0;
    max-width: none;
    overflow: visible;
  }
  .topbar .tabs.tabs-dock .tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    padding: 6px 4px 4px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    box-shadow: none;
    border-radius: 8px;
  }
  .topbar .tabs.tabs-dock .tab .icon {
    width: 20px;
    height: 20px;
  }
  .topbar .tabs.tabs-dock .tab.active {
    color: var(--accent);
    background: transparent;
    box-shadow: none;
  }
  .topbar .tabs.tabs-dock .tab:hover { color: inherit; opacity: 1; }
  .topbar .tabs.tabs-dock .tab.active:hover { color: var(--accent); }

  h1 { font-size: 26px; margin-bottom: 16px; }
  main.wide { padding-top: 4px; }
}

@media (min-width: 1100px) {
  main.wide { max-width: 920px; }
  .topbar-inner,
  .tabs { max-width: 920px; }
}

/* ─── Modals / sheets ────────────────────────────────────── */

html.modal-open,
body.modal-open {
  overflow: hidden;
}

.modal[hidden] { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--pad);
  padding-bottom: calc(var(--pad) + var(--safe-bottom));
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 42, 67, 0.45);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  backdrop-filter: saturate(140%) blur(8px);
  animation: modal-fade-in var(--duration) var(--ease);
}

.modal-sheet {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(88dvh, 920px);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  box-shadow:
    0 16px 48px rgba(16, 42, 67, 0.22),
    0 2px 8px rgba(16, 42, 67, 0.08);
  overflow: hidden;
  animation: modal-sheet-in 220ms var(--ease);
}
.modal-sheet-wide {
  width: min(860px, 100%);
}
.modal.loading .modal-sheet {
  opacity: 0.55;
  pointer-events: none;
}

.modal-chrome {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: var(--space-2) var(--pad);
  border-bottom: 1px solid var(--separator);
  flex-shrink: 0;
}
.modal-title {
  flex: 1;
  margin: 0;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.modal-title .icon {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}
.modal-chrome .modal-close {
  flex: 0 0 auto;
  min-width: 64px;
  padding: var(--space-2) 0;
  text-align: left;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.modal-chrome-spacer {
  flex: 0 0 64px;
}

.modal-body {
  padding: var(--pad);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-body > .cols {
  margin-top: 0;
}
.modal-body > .card,
.modal-body > .cols + .card {
  margin-top: var(--space-4);
}
.modal-body > .alert {
  margin-bottom: var(--pad);
}
.modal-profile-head {
  margin: 0 0 var(--space-3);
}
.modal-profile-cn {
  font-size: 22px;
  margin: 0;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-sheet-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 640px) {
  .modal {
    align-items: flex-end;
    padding: 0;
  }
  .modal-sheet,
  .modal-sheet-wide {
    width: 100%;
    max-height: min(92dvh, 100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: modal-sheet-up 240ms var(--ease);
  }
  @keyframes modal-sheet-up {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: none; }
  }
}
