/* Pedro VPN control panel. No framework: one stylesheet.
   "Pedro's ledger": the mascot is drawn in heavy ink outlines on parchment, so the panel is too. Parchment paper,
   night-ink frames with hard offset shadows (printed, not glowing), doubloon gold as foil on ink and as the press
   colour of primary buttons, conquista red as the brand mark and the active-tab stamp. Statuses are rubber stamps in
   their own inks (green / orange / red / blue) and always carry a word, never colour alone.
   Type: Piazzolla (display, optical sizes), Golos Text (UI, made for Cyrillic), Martian Mono (keys, hosts, codes).
   All three are self-hosted (OFL, see /fonts): the CSP allows fonts from 'self' only. */

/* ---------- Fonts ---------- */
@font-face {
    font-family: "Piazzolla"; font-style: normal; font-weight: 100 900; font-display: swap;
    src: url(/fonts/piazzolla-latin.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: "Piazzolla"; font-style: normal; font-weight: 100 900; font-display: swap;
    src: url(/fonts/piazzolla-cyrillic.woff2) format("woff2");
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: "Piazzolla"; font-style: italic; font-weight: 100 900; font-display: swap;
    src: url(/fonts/piazzolla-latin-italic.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: "Piazzolla"; font-style: italic; font-weight: 100 900; font-display: swap;
    src: url(/fonts/piazzolla-cyrillic-italic.woff2) format("woff2");
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: "Golos Text"; font-style: normal; font-weight: 400 900; font-display: swap;
    src: url(/fonts/golos-latin.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: "Golos Text"; font-style: normal; font-weight: 400 900; font-display: swap;
    src: url(/fonts/golos-cyrillic.woff2) format("woff2");
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: "Martian Mono"; font-style: normal; font-weight: 100 800; font-stretch: 75% 112.5%; font-display: swap;
    src: url(/fonts/martian-mono-latin.woff2) format("woff2");
}

:root {
    /* Paper */
    --paper: #f2e7d3;            /* the page */
    --paper-hi: #fbf6ec;         /* cards, inputs: a cleaner sheet on the page */
    --paper-lo: #ebdfc8;         /* wells: table heads, hover, readonly fields */
    --paper-deep: #ddcdaf;       /* meter tracks, pressed */
    /* Ink */
    --ink: #14161c;              /* night ink: text, frames, the menu */
    --ink-2: #23252d;
    --ink-3: #30333d;
    --muted: #6b6253;            /* warm grey on parchment (steel reads too cold and too faint here) */
    --rule: rgb(20 22 28 / 13%); /* hairlines inside blocks */
    --rule-2: rgb(20 22 28 / 30%);
    --frame: var(--ink);         /* the frame of cards, dialogs, buttons */
    --shade: var(--ink);         /* the hard offset shadow under frames */
    --rule-heavy: var(--ink);    /* the rule under table heads, tabs, page titles */
    --plate: var(--ink);         /* the outline of country chips */
    --field: #fffbf3;            /* inputs */
    --placeholder: #9a907e;
    --hover-wash: rgb(243 220 156 / 38%);
    --picked: rgb(243 220 156 / 55%);
    --topbar-bg: rgb(242 231 211 / 88%);
    --scrollbar: #b8aa8f;
    /* Fixed in both themes: the menu, avatars, the install terminal, red badges */
    --night: #14161c;
    --cream: #f2e7d3;
    --brand-red: #b3202a;
    --menu-bg: linear-gradient(180deg, #181a21, #14161c 40%);
    --primary-icon: var(--gold);
    --public-glow: rgb(232 178 58 / 30%);
    /* Brand */
    --gold: #e8b23a;             /* doubloon gold: foil on ink, the press shadow of primary buttons */
    --gold-hi: #f4c95e;
    --gold-ink: #87590a;         /* gold as text on paper */
    --gold-wash: #f3dc9c;
    --red: #b3202a;              /* conquista red: the brand mark, the active tab, danger */
    --red-wash: #f4d4cc;
    /* Status inks */
    --ok: #26704a;     --ok-wash: #d6e6cf;
    --warn: #a9520d;   --warn-wash: #f5dcbd;
    --danger: #b3202a; --danger-wash: #f4d4cc;
    --info: #2a5d8f;   --info-wash: #d5e0ea;
    /* Charts (validated for colour blindness on --paper-hi) */
    --chart-down: #a87a00;
    --chart-up: #1d67b0;
    --chart-s1: #c0356f; --chart-s2: #1d67b0; --chart-s3: #a87a00;
    --chart-s4: #00826f; --chart-s5: #8e3ba3; --chart-s6: #d9601f; --chart-other: #a39a8a;

    --radius: 6px;               /* blocks */
    --ctl-radius: 5px;           /* controls */
    --topbar-h: 64px;
    --menu-w: 252px;
    --press: 3px 3px 0 var(--shade);
    --press-lg: 5px 5px 0 var(--shade);
    --font: "Golos Text", "Segoe UI", system-ui, sans-serif;
    --display: "Piazzolla", "Iowan Old Style", Georgia, serif;
    --mono: "Martian Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
    /* Paper grain and the menu's azulejo lattice: SVG data URIs (img-src allows data:) */
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .32 0 0 0 0 .22 0 0 0 0 .1 0 0 0 .11 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    --lattice-gold: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56'%3E%3Cg fill='none' stroke='%23e8b23a' stroke-opacity='.075'%3E%3Crect x='18' y='18' width='20' height='20'/%3E%3Cpath d='M28 13.9 42.1 28 28 42.1 13.9 28Z'/%3E%3Cpath d='M0 0l18 18M56 0 38 18M0 56l18-18M56 56 38 38M28 0v13.9M28 42.1V56M0 28h13.9M42.1 28H56'/%3E%3C/g%3E%3C/svg%3E");
    --lattice-ink: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56'%3E%3Cg fill='none' stroke='%2314161c' stroke-opacity='.045'%3E%3Crect x='18' y='18' width='20' height='20'/%3E%3Cpath d='M28 13.9 42.1 28 28 42.1 13.9 28Z'/%3E%3Cpath d='M0 0l18 18M56 0 38 18M0 56l18-18M56 56 38 38M28 0v13.9M28 42.1V56M0 28h13.9M42.1 28H56'/%3E%3C/g%3E%3C/svg%3E");
    --lattice: var(--lattice-ink);
    color-scheme: light;
}
/* The night ledger: the same frames, stamps and type on black lacquer. Ink becomes parchment, so everything that was
   ink on paper (primary buttons, tooltips, the bulk bar, the selected tab count) turns into parchment on ink by itself.
   Chosen per browser with the top bar switch (cookie "pedrovpn-theme", read by the layouts: no flash on load). */
:root[data-theme="dark"] {
    --paper: #111217;
    --paper-hi: #1a1c23;
    --paper-lo: #23262e;
    --paper-deep: #30333d;
    --field: #14151a;
    --ink: #eee5d3;
    --ink-2: #d8cdb8;
    --ink-3: #c2b79f;
    --muted: #a39a89;
    --rule: rgb(238 229 211 / 10%);
    --rule-2: rgb(238 229 211 / 24%);
    --rule-heavy: rgb(238 229 211 / 42%);
    --frame: #484b56;
    --shade: #040506;
    --plate: rgb(238 229 211 / 55%);
    --placeholder: #6f685c;
    --hover-wash: rgb(232 178 58 / 7%);
    --picked: rgb(232 178 58 / 13%);
    --topbar-bg: rgb(17 18 23 / 86%);
    --scrollbar: #3d404b;
    --menu-bg: #08090b;
    --primary-icon: var(--brand-red);
    --public-glow: rgb(232 178 58 / 11%);
    --gold-ink: #e8b23a;
    --gold-wash: rgb(232 178 58 / 17%);
    --red: #ef5b60;
    --red-wash: #3a1a1d;
    --ok: #4cc38a;     --ok-wash: #143025;
    --warn: #f0913f;   --warn-wash: #33220f;
    --danger: #f26b6b; --danger-wash: #3a1a1c;
    --info: #6aa8e8;   --info-wash: #15283d;
    /* Charts (validated for colour blindness on the dark --paper-hi) */
    --chart-down: #c4921c;
    --chart-up: #5a9fe6;
    --chart-s1: #e0588f; --chart-s2: #4c8fe0; --chart-s3: #c4921c;
    --chart-s4: #1fb39a; --chart-s5: #b46ad0; --chart-s6: #e0702e; --chart-other: #77716a;
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .95 0 0 0 0 .9 0 0 0 0 .8 0 0 0 .045 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    --lattice: var(--lattice-gold);
    color-scheme: dark;
}
/* The switch: a moon on paper, a sun at night. Switching wipes the new theme in from the button (app.js) */
.theme-toggle .icon { transition: transform .4s cubic-bezier(.3, 1.6, .5, 1); }
.theme-toggle:hover .icon { transform: rotate(-25deg) scale(1.1); }
.theme-toggle .i-sun, [data-theme="dark"] .theme-toggle .i-moon { display: none; }
[data-theme="dark"] .theme-toggle .i-sun { display: block; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
body.public { --radius: 10px; --ctl-radius: 6px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--scrollbar) transparent; }
body {
    margin: 0; font: 14px/1.5 var(--font); color: var(--ink); font-variant-numeric: tabular-nums;
    background: var(--grain), var(--paper); -webkit-font-smoothing: antialiased;
}
body.public { font-size: 15px; }
::selection { background: var(--gold-wash); color: var(--ink); }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--red); text-decoration-color: var(--red); }
h1, h2, h3 { margin: 0; line-height: 1.15; font-family: var(--display); color: var(--ink); font-variant-numeric: lining-nums proportional-nums; }
h1 { font-size: 2.35rem; font-weight: 800; letter-spacing: -.012em; word-spacing: .04em; }
h2 { font-size: 1.22rem; font-weight: 700; letter-spacing: -.005em; }
h3 { font-size: 1.02rem; font-weight: 700; }
code, pre, kbd { font-family: var(--mono); font-stretch: 78%; }
code, pre { font-size: .8em; }
code { background: var(--paper-lo); border: 1px solid var(--rule); border-radius: 4px; padding: .08em .4em; overflow-wrap: anywhere; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 1rem 0; }
kbd { font-size: .66rem; font-weight: 600; line-height: 1; padding: .22rem .4rem; border: 1px solid var(--rule-2); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); background: var(--paper-hi); }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-stretch: 78%; font-size: .76em; }

/* ---------- Icons (an SVG sprite in _Layout: <svg class="icon"><use href="#i-name"/></svg>) ---------- */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
    width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6;
    stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px;
}

/* ---------- Shell: the ink menu on the left (full height), top bar and page on the right ---------- */
.shell { display: grid; grid-template-columns: var(--menu-w) minmax(0, 1fr); min-height: 100vh; }
.shell:not(:has(.sidebar)) { grid-template-columns: minmax(0, 1fr); }
.main { display: flex; flex-direction: column; min-width: 0; }

.sidebar {
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow: hidden auto;
    color: var(--cream); background: var(--lattice-gold), var(--menu-bg);
    scrollbar-color: var(--ink-3) transparent; scrollbar-width: thin;
}
/* Red and gold, the brand's two inks, once: a band on top */
.sidebar::before { content: ""; flex: none; height: 4px; background: linear-gradient(90deg, var(--brand-red) 0 62%, var(--gold) 62%); }
.brand { display: flex; align-items: center; gap: .8rem; flex: none; padding: 1.15rem 1rem 1rem 1.1rem; color: var(--cream); text-decoration: none; }
.brand:hover { color: var(--cream); }
.brand-mark {
    width: 46px; height: 46px; flex: none; border-radius: 50%; object-fit: cover;
    box-shadow: 0 0 0 2px var(--night), 0 0 0 3.5px var(--gold); transition: transform .3s cubic-bezier(.3, 1.6, .5, 1);
}
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.05); }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.05; }
.brand-name { font: italic 800 1.42rem/1.05 var(--display); letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { margin-top: .3rem; color: var(--gold); font-size: .62rem; font-weight: 700; letter-spacing: .24em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: .4rem .7rem .4rem .7rem; }
.nav-group {
    display: flex; align-items: center; gap: .6rem; padding: 1.15rem .55rem .4rem; color: #8c8473;
    font-size: .62rem; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; white-space: nowrap;
}
.nav-group::after { content: ""; flex: 1; height: 1px; background: rgb(232 178 58 / 18%); }
.nav-group:first-child { padding-top: .35rem; }
.nav a {
    position: relative; display: flex; align-items: center; gap: .75rem; height: 40px; padding: 0 .7rem;
    border-radius: var(--ctl-radius); color: rgb(242 231 211 / 70%); font-size: .9rem; font-weight: 500; white-space: nowrap;
    text-decoration: none; transition: background .15s, color .15s;
}
.nav a .icon { width: 18px; height: 18px; }
.nav a:hover { background: rgb(242 231 211 / 7%); color: var(--cream); }
/* The current page is a parchment tab cut out of the ink: it runs into the page, with rounded inner corners */
.nav a.active {
    margin-right: -.7rem; padding-right: 1.4rem; border-radius: 8px 0 0 8px;
    background: var(--paper); color: var(--ink); font-weight: 650;
}
.nav a.active .icon { color: var(--red); }
[data-theme="dark"] .nav a.active { box-shadow: inset 3px 0 0 var(--gold); }
.nav a.active::before, .nav a.active::after {
    content: ""; position: absolute; right: 0; width: 12px; height: 12px; pointer-events: none;
}
.nav a.active::before { top: -12px; background: radial-gradient(circle at 0 0, transparent 11.5px, var(--paper) 12px); }
.nav a.active::after { bottom: -12px; background: radial-gradient(circle at 0 100%, transparent 11.5px, var(--paper) 12px); }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot {
    display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: auto;
    padding: .7rem .7rem .7rem 1.25rem; border-top: 1px solid rgb(232 178 58 / 16%);
}
.version { color: #8c8473; font: 500 .66rem var(--mono); font-stretch: 78%; letter-spacing: .04em; }
.nav-collapse {
    display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: var(--ctl-radius);
    background: none; color: #8c8473; cursor: pointer;
}
.nav-collapse:hover { background: rgb(242 231 211 / 8%); color: var(--cream); }
.badge {
    min-width: 1.45rem; padding: 0 .4rem; border-radius: 4px; background: var(--gold); color: var(--night);
    font-size: .7rem; font-weight: 800; line-height: 1.3rem; text-align: center;
}
.badge.danger { background: var(--brand-red); color: var(--cream); }
.scrim { display: none; }

/* ---------- Top bar: menu button (phones / collapse), search, alerts, account ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: .75rem;
    padding: 0 1.75rem 0 1rem; background: var(--topbar-bg); backdrop-filter: blur(8px) saturate(1.2);
    border-bottom: 1px solid var(--rule);
}
.topbar-btn {
    position: relative; display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0;
    border: 0; border-radius: var(--ctl-radius); background: none; color: var(--ink); cursor: pointer; text-decoration: none;
}
.topbar-btn:hover { background: var(--paper-lo); color: var(--ink); }
.topbar-btn .icon { width: 19px; height: 19px; }
.topbar-count {
    position: absolute; top: 3px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 4px;
    background: var(--brand-red); color: var(--cream); font-size: 10.5px; font-weight: 800; line-height: 17px; text-align: center;
    box-shadow: 0 0 0 2px var(--paper);
}
/* The search is a ledger line, not a box: it only gets a box while you type in it */
.topbar-search { position: relative; display: flex; align-items: center; flex: 1 1 auto; max-width: 520px; }
.topbar-search > .icon { position: absolute; left: .7rem; color: var(--muted); pointer-events: none; }
.topbar-search kbd { position: absolute; right: .55rem; pointer-events: none; }
.topbar-search input {
    height: 40px; padding: 0 2.4rem 0 2.3rem; font-size: .9rem; background: transparent;
    border: 1.5px solid transparent; border-bottom-color: var(--rule-2); border-radius: var(--ctl-radius) var(--ctl-radius) 0 0;
}
.topbar-search input:hover { border-bottom-color: var(--ink); }
.topbar-search input:focus-visible {
    outline: 0; border-color: var(--ink); border-radius: var(--ctl-radius); background: var(--paper-hi); box-shadow: var(--press);
}
.topbar-search input:focus + kbd { display: none; }
.topbar-search.miss input { border-color: var(--danger); }
.topbar-right { display: flex; align-items: center; gap: .35rem; flex: none; margin-left: auto; }

.account { position: relative; }
.account > summary {
    display: flex; align-items: center; gap: .55rem; height: 44px; margin: 0; padding: 0 .7rem 0 .3rem;
    border-radius: 99px; list-style: none; color: var(--ink); font-weight: 500; cursor: pointer;
}
.account > summary::-webkit-details-marker { display: none; }
.account > summary:hover, .account[open] > summary { background: var(--paper-lo); }
.account-name { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; }
.avatar {
    display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%;
    background: var(--night); color: var(--gold); font: italic 700 .9rem/1 var(--display);
    box-shadow: 0 0 0 1.5px var(--paper), 0 0 0 3px var(--gold);
}
.avatar.big { width: 46px; height: 46px; font-size: 1.15rem; }
.avatar.sm {
    width: 30px; height: 30px; font-size: .88rem; background: var(--paper-hi); color: var(--ink);
    box-shadow: inset 0 0 0 1.5px var(--ink);
}
.account-menu {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 45; width: 290px; display: flex; flex-direction: column;
    padding: .9rem 0 .5rem; background: var(--paper-hi); border: 1.5px solid var(--frame); border-radius: var(--radius);
    box-shadow: var(--press-lg); animation: drop .16s ease-out;
}
.account-card { display: flex; align-items: center; gap: .85rem; padding: 0 1rem .9rem; border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; }
.account-card strong { font-family: var(--display); font-size: 1.05rem; }
.menu-item {
    display: flex; align-items: center; gap: .65rem; width: 100%; padding: .55rem 1rem; border: 0; background: none;
    color: var(--ink); font: inherit; text-align: left; cursor: pointer; text-decoration: none;
}
.menu-item:hover { background: var(--paper-lo); color: var(--ink); }
.menu-item .icon { color: var(--muted); }
.account-version { padding: .45rem 1rem 0; font-family: var(--mono); font-stretch: 78%; font-size: .68rem; }

@media (min-width: 861px) {
    .menu-btn { display: none; }
    .menu-collapsed { --menu-w: 72px; }
    .menu-collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }
    .menu-collapsed .brand-text, .menu-collapsed .nav-label, .menu-collapsed .version { display: none; }
    .menu-collapsed .nav-group { height: 0; margin: .55rem .4rem; padding: 0; overflow: hidden; border-top: 1px solid rgb(232 178 58 / 18%); }
    .menu-collapsed .nav-group::after { content: none; }
    .menu-collapsed .nav a { justify-content: center; padding: 0; }
    .menu-collapsed .nav a.active { padding-right: .7rem; }
    .menu-collapsed .nav a .badge { position: absolute; top: 1px; right: 3px; min-width: 15px; padding: 0 3px; font-size: 10px; line-height: 15px; }
    .menu-collapsed .nav a.active .badge { right: 14px; }
    .menu-collapsed .sidebar-foot { justify-content: center; padding-left: .7rem; }
    .menu-collapsed .nav-collapse .icon { transform: scaleX(-1); }
}

/* ---------- Page: breadcrumb, title with actions on the right, a double rule under it ---------- */
.content { width: 100%; max-width: 1600px; min-width: 0; margin: 0 auto; padding: 1.6rem 2rem 3.5rem; }
.breadcrumb {
    display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin-bottom: .55rem;
    font-size: .66rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--red); }
.breadcrumb a::after { content: "/"; margin-left: .45rem; color: var(--rule-2); }
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: .75rem 1.5rem;
    margin: 0 0 1.6rem; padding-bottom: 1.05rem; border-bottom: 3px double var(--rule-heavy);
}
.page-title { min-width: 0; }
.page-title h1 { overflow-wrap: anywhere; }
.page-sub { margin: .35rem 0 0; color: var(--muted); font: italic 400 1.05rem/1.35 var(--display); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.page-actions form { display: flex; align-items: center; margin: 0; }
.page-actions label.check { padding: 0 .4rem; font-size: .85rem; font-weight: 400; }
.icon-button {
    display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1.5px solid var(--frame);
    border-radius: var(--ctl-radius); background: var(--paper-hi); color: var(--ink); cursor: pointer; text-decoration: none;
    box-shadow: 2px 2px 0 var(--shade); transition: transform .12s, box-shadow .12s;
}
.icon-button:hover { color: var(--ink); transform: translate(-1px, -1px); box-shadow: var(--press); }
.icon-button:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--shade); }
.icon-button:hover .icon { animation: spin .5s ease-out; }

@media (max-width: 860px) {
    /* Phones: the menu is a drawer over the page, opened by the menu button */
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar {
        position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(280px, 85vw); height: auto;
        transform: translateX(-100%); transition: transform .18s ease-out; visibility: hidden;
    }
    .menu-open .sidebar { transform: none; visibility: visible; box-shadow: 6px 0 0 var(--gold); }
    .menu-open .scrim { display: block; position: fixed; z-index: 35; inset: 0; background: rgb(20 22 28 / 45%); }
    /* In the drawer the tab has no page to run into */
    .nav a.active { margin-right: 0; padding-right: .7rem; border-radius: var(--ctl-radius); }
    .nav a.active::before, .nav a.active::after { content: none; }
    .nav-collapse, .account-name, .topbar-search kbd { display: none; }
    .topbar { padding: 0 .75rem; }
    .content { padding: 1.1rem 1rem 2.5rem; }
    h1 { font-size: 1.9rem; }
}
@media (max-width: 560px) {
    .topbar-search { display: none; }
}

/* ---------- Cards: printed sheets with an ink frame and a hard shadow ---------- */
.card {
    background: var(--paper-hi); border: 1.5px solid var(--frame); border-radius: var(--radius); box-shadow: var(--press);
    padding: 1.15rem 1.3rem; margin-bottom: 1.5rem; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .85rem; flex-wrap: wrap; }
.card > p:last-child { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.5rem; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 1.5rem; }
.stack > .card { margin-bottom: 0; }
.empty { color: var(--muted); padding: .5rem 0; }
.ok-note { display: flex; align-items: center; gap: .6rem; margin: 0; }
.list-more { margin: .6rem 0 0; font-size: .85rem; }

/* Stat cards (dashboard): tickets. Small-caps label, a big printed figure, a perforated stub with the context */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 1.1rem; margin-bottom: 1.75rem; }
.stat {
    position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label icon" "value value" "sub sub";
    align-items: center; padding: .95rem 1.15rem 0; color: var(--ink); text-decoration: none; overflow: hidden;
    background: var(--paper-hi); border: 1.5px solid var(--frame); border-radius: var(--radius); box-shadow: var(--press);
    transition: transform .14s ease-out, box-shadow .14s ease-out;
}
a.stat:hover { color: var(--ink); transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--shade); }
a.stat:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shade); }
.stat-icon { grid-area: icon; display: grid; place-items: center; color: var(--muted); }
.stat-icon .icon { width: 19px; height: 19px; }
.stat-icon.ok { color: var(--ok); }
.stat-icon.warn { color: var(--warn); }
.stat-icon.danger { color: var(--danger); }
.stat-label { grid-area: label; color: var(--muted); font-size: .66rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.stat-value {
    grid-area: value; padding: .35rem 0 .55rem; font: 650 2.45rem/1 var(--display); letter-spacing: -.025em;
    font-variant-numeric: lining-nums tabular-nums; white-space: nowrap;
}
.stat-value small { font: italic 500 1.15rem var(--display); color: var(--muted); letter-spacing: 0; }
.stat-sub {
    grid-area: sub; margin: 0 -1.15rem; padding: .5rem 1.15rem .6rem; border-top: 1.5px dashed var(--rule-2);
    background: var(--paper-lo); color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Trouble changes the ink of the shadow, the stub and the figure */
.stat.warn { box-shadow: 3px 3px 0 var(--warn); border-color: var(--warn); }
.stat.warn .stat-sub { background: var(--warn-wash); color: var(--warn); font-weight: 600; }
a.stat.warn:hover { box-shadow: 5px 5px 0 var(--warn); }
.stat.danger { box-shadow: 3px 3px 0 var(--danger); border-color: var(--danger); }
.stat.danger .stat-value { color: var(--danger); }
.stat.danger .stat-sub { background: var(--danger-wash); color: var(--danger); font-weight: 600; }
a.stat.danger:hover { box-shadow: 5px 5px 0 var(--danger); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: 1.5rem; align-items: start; margin-bottom: 1.5rem; }
.dash-grid > .card { margin-bottom: 0; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--rule); }
.people li:last-child { border-bottom: 0; padding-bottom: 0; }

/* Older small tiles (Costs page) */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1.1rem; margin-bottom: 1.5rem; }
.tile {
    display: flex; flex-direction: column; gap: .3rem; background: var(--paper-hi); border: 1.5px solid var(--frame);
    border-radius: var(--radius); box-shadow: var(--press); padding: .95rem 1.15rem; color: var(--ink); text-decoration: none;
    transition: transform .14s, box-shadow .14s;
}
a.tile:hover { color: var(--ink); transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--shade); }
.tile-label { color: var(--muted); font-size: .66rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.tile-value { font: 650 1.85rem/1.1 var(--display); letter-spacing: -.02em; font-variant-numeric: lining-nums tabular-nums; }
.tile-value.small { font-size: 1.3rem; }
.tile-value small { font: italic 500 1rem var(--display); color: var(--muted); }
.tile.warn { border-color: var(--warn); box-shadow: 3px 3px 0 var(--warn); }
.tile.danger { border-color: var(--danger); box-shadow: 3px 3px 0 var(--danger); }
.tile.danger .tile-value { color: var(--danger); }

/* ---------- Lists at scale: toolbar (search), tabs with counts, bulk bar, table, pager ---------- */
.card.list { padding: 0; overflow: hidden; }
.card.list > .card-head { padding: 1.05rem 1.3rem 0; }
.list-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: 1.05rem 1.3rem .8rem; }
.search-field { position: relative; display: flex; flex-direction: row; align-items: center; flex: 1 1 22rem; max-width: 30rem; margin: 0; }
.search-field > .icon { position: absolute; left: .75rem; color: var(--muted); pointer-events: none; }
.search-field input { height: 38px; padding-left: 2.25rem; }
.tabs { display: flex; gap: .2rem; padding: 0 1.3rem; border-bottom: 1.5px solid var(--rule-heavy); overflow-x: auto; scrollbar-width: none; }
.tabs a {
    position: relative; display: inline-flex; align-items: center; gap: .5rem; padding: .55rem .75rem .65rem;
    color: var(--muted); font-size: .88rem; font-weight: 550; white-space: nowrap; text-decoration: none;
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); font-weight: 650; }
.tabs a.active::after { content: ""; position: absolute; left: .45rem; right: .45rem; bottom: -1.5px; height: 4px; border-radius: 2px 2px 0 0; background: var(--red); }
.tabs .count {
    min-width: 1.6rem; padding: .05rem .4rem; border-radius: 4px; background: var(--paper-lo); color: var(--muted);
    font-size: .72rem; font-weight: 700; text-align: center;
}
.tabs a.active .count { background: var(--ink); color: var(--paper-hi); }
.tabs a.alarm .count { background: var(--warn-wash); color: var(--warn); }
.bulk-bar {
    display: none; align-items: center; flex-wrap: wrap; gap: .5rem; padding: .6rem 1.3rem;
    background: var(--ink); color: var(--paper); font-size: .88rem;
}
.bulk-bar.on { display: flex; animation: drop .16s ease-out; }
.bulk-bar > span { margin-right: .5rem; font-weight: 600; }
.bulk-bar .button { box-shadow: 2px 2px 0 var(--gold); border-color: var(--paper); }
.bulk-bar .button.ghost { color: var(--paper); border-color: transparent; box-shadow: none; }
.bulk-bar .button.ghost:hover { background: rgb(242 231 211 / 12%); color: var(--paper-hi); }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: 3rem 1rem; text-align: center; }
.empty-state p { margin: 0; }
.empty-state strong { font: italic 700 1.25rem var(--display); }
.empty-state .button { margin-top: .7rem; }
.list-foot {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem;
    padding: .75rem 1.3rem; border-top: 1.5px solid var(--rule-heavy); background: var(--paper-lo); font-size: .85rem;
}
.list-foot-right { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.5rem; }
.sizes, .pager { display: flex; align-items: center; gap: .2rem; }
.sizes .muted { margin-right: .3rem; }
.sizes a, .pager a, .pager span {
    display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 .45rem; border-radius: 4px;
    color: var(--muted); text-decoration: none;
}
.sizes a:hover, .pager a:hover { background: var(--paper-deep); color: var(--ink); }
.sizes a.active, .pager .current { background: var(--ink); color: var(--paper-hi); font-weight: 700; }
.pager .off { opacity: .35; }
.pager .gap { min-width: 18px; padding: 0; }

/* ---------- Tables: a ledger. Small-caps heads over a heavy rule, hairlines between rows ---------- */
.table-wrap { overflow-x: auto; margin: 0 -1.3rem; padding: 0 1.3rem; }
.card.list .table-wrap { margin: 0; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th {
    font-size: .64rem; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; color: var(--muted);
    white-space: nowrap; border-bottom: 1.5px solid var(--rule-heavy);
}
th a { color: inherit; text-decoration: none; }
th a:hover { color: var(--ink); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s; }
tbody tr:hover td { background: var(--hover-wash); }
body.public tbody tr:hover td { background: none; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.num { font-variant-numeric: lining-nums tabular-nums; }
tr.off td { opacity: .5; }
th[data-sort-key] { cursor: pointer; user-select: none; }
th[aria-sort="ascending"]::after { content: " ↑"; color: var(--red); }
th[aria-sort="descending"]::after { content: " ↓"; color: var(--red); }
.row-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.row-actions form { margin: 0; }
/* Data tables (lists): roomier rows, vertically centred, edge padding that matches the card */
table.data th { padding-top: .7rem; padding-bottom: .55rem; }
table.data td { vertical-align: middle; padding-top: .62rem; padding-bottom: .62rem; }
table.data th:first-child, table.data td:first-child { padding-left: 1.3rem; }
table.data th:last-child, table.data td:last-child { padding-right: 1.3rem; }
table.data.compact td { padding-top: .5rem; padding-bottom: .5rem; }
.card:not(.list) table.data th:first-child, .card:not(.list) table.data td:first-child { padding-left: .75rem; }
th.check, td.check { width: 1%; padding-right: 0; }
td.check input, th.check input { width: 16px; height: 16px; accent-color: var(--ink); cursor: pointer; }
.cell-main { display: inline-flex; align-items: center; gap: .7rem; min-width: 0; color: var(--ink); text-decoration: none; }
.cell-main:hover { color: var(--ink); }
.cell-main:hover strong { color: var(--red); text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.cell-main > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.cell-main strong { font-weight: 600; }
.cell-sub { display: block; color: var(--muted); font-size: .78rem; line-height: 1.3; }
.flag { font-size: 1.1rem; line-height: 1; }
.share-col { width: 22%; }

/* Status: a rubber stamp in its own ink. Online / Active / Disabled, node states */
.status {
    display: inline-flex; align-items: center; gap: .4rem; padding: .14rem .5rem .1rem .42rem; border-radius: 4px;
    border: 1.5px solid currentColor; background: var(--paper-lo); color: var(--muted);
    font-size: .64rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; line-height: 1.35;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.ok { background: var(--ok-wash); color: var(--ok); }
.status.ok::before { animation: beat 2.4s ease-in-out infinite; }
.status.idle { background: var(--info-wash); color: var(--info); }
.status.warn { background: var(--warn-wash); color: var(--warn); }
.status.danger { background: var(--danger-wash); color: var(--danger); }

/* A small bar for a share (memory, traffic) drawn as SVG: the CSP allows no inline styles */
.meter-cell { display: inline-flex; align-items: center; gap: .55rem; }
.meter { width: 72px; height: 6px; display: block; }
.meter .track { fill: var(--paper-deep); }
.meter .fill { fill: var(--ok); }
.meter.warn .fill { fill: var(--warn); }
.meter.danger .fill { fill: var(--danger); }
.meter.gold .fill { fill: var(--chart-down); }
.share-col .meter { width: 100%; max-width: 160px; }
.meter-value { color: var(--muted); font-size: .78rem; min-width: 2.4rem; }

/* ---------- Dialogs ---------- */
dialog.modal {
    width: min(520px, calc(100vw - 2rem)); max-height: calc(100vh - 3rem); padding: 0; color: var(--ink);
    background: var(--paper-hi); border: 1.5px solid var(--frame); border-radius: var(--radius); box-shadow: 8px 8px 0 var(--shade);
}
dialog.modal[open] { animation: drop .18s ease-out; }
dialog.modal.wide { width: min(780px, calc(100vw - 2rem)); }
dialog.modal::backdrop { background: rgb(20 22 28 / 50%); backdrop-filter: blur(2px) sepia(.3); }
dialog.modal > form { display: flex; flex-direction: column; max-height: inherit; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.3rem; border-bottom: 3px double var(--rule-heavy); }
.modal-head .icon-button { width: 32px; height: 32px; border: 0; background: none; box-shadow: none; }
.modal-head .icon-button:hover { background: var(--paper-lo); transform: none; }
.modal-head .icon-button:hover .icon { animation: none; }
.modal-body { padding: 1.15rem 1.3rem; overflow: auto; }
.modal-body > p:first-child { margin-top: 0; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .6rem; padding: .9rem 1.3rem; border-top: 1px solid var(--rule); background: var(--paper-lo); }

/* ---------- Pills, dots ---------- */
.pill {
    display: inline-block; padding: .06rem .5rem; margin: 0 .2rem .2rem 0; border-radius: 4px; font-size: .74rem; font-weight: 650;
    background: var(--paper-lo); color: var(--muted); white-space: nowrap; box-shadow: inset 0 0 0 1px var(--rule);
}
.pill.ok { background: var(--ok-wash); color: var(--ok); box-shadow: none; }
.pill.warn { background: var(--warn-wash); color: var(--warn); box-shadow: none; }
.pill.danger { background: var(--danger-wash); color: var(--danger); box-shadow: none; }
.pill.muted { opacity: .6; }
/* A server's role: primaries carry the traffic, secondaries stand by, trial nodes serve trial users only, whitelist relays
   (Russian clouds) are the last resort */
.pill.role.primary { background: var(--night); color: var(--gold); box-shadow: inset 0 0 0 1px rgb(232 178 58 / 35%); }
.pill.role.secondary { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--rule-2); }
.pill.role.trial { background: transparent; color: var(--muted); box-shadow: none; outline: 1px dashed var(--rule-2); outline-offset: -1px; }
.pill.role.whitelist { background: var(--gold-wash); color: var(--gold-ink); box-shadow: none; }
.pill.role.private { background: transparent; color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--muted); margin-right: .35rem; vertical-align: baseline; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.danger { background: var(--danger); }

/* ---------- Forms, buttons ---------- */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .86rem; font-weight: 550; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--ink); font-weight: 500; }
input, select, textarea {
    font: inherit; color: var(--ink); background: var(--field); border: 1.5px solid var(--rule-2); border-radius: var(--ctl-radius);
    padding: .45rem .7rem; min-width: 0; width: 100%; transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:hover, select:hover, textarea:hover { border-color: rgb(20 22 28 / 55%); }
input[readonly]:hover { border-color: var(--rule-2); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--ink); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 0; border-color: var(--ink); box-shadow: 0 0 0 3px var(--gold-wash); }
.button:focus-visible, summary:focus-visible, a:focus-visible, .icon-button:focus-visible { outline: 2.5px solid var(--gold); outline-offset: 2px; }
input[readonly] { background: var(--paper-lo); font-family: var(--mono); font-stretch: 78%; font-size: .78rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem 1rem; align-items: end; margin-top: .5rem; }
.form-actions { display: flex; gap: .6rem; align-items: center; }
.form-actions.sticky { position: sticky; bottom: 0; padding: .85rem 0; background: linear-gradient(transparent, var(--paper) 35%); margin-bottom: 1rem; }
.inline-form { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }
.inline-form select, .inline-form input { width: auto; }
.narrow { max-width: 12rem; }
form { margin: 0; }

/* Buttons are printed blocks that press down into the page */
.button {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 36px; font: inherit; font-weight: 650;
    font-size: .86rem; padding: .4rem 1rem; border-radius: var(--ctl-radius); border: 1.5px solid var(--frame);
    background: var(--paper-hi); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; list-style: none;
    box-shadow: 2px 2px 0 var(--shade); transition: transform .1s ease-out, box-shadow .1s ease-out, background .1s;
}
.button:hover { color: var(--ink); transform: translate(-1px, -1px); box-shadow: var(--press); }
.button:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--shade); }
.button .icon { color: inherit; }
.button.primary { background: var(--ink); border-color: var(--ink); color: var(--paper-hi); box-shadow: 3px 3px 0 var(--gold); }
.button.primary .icon { color: var(--primary-icon); }
.button.primary:hover { background: var(--ink-2); color: var(--paper-hi); box-shadow: 4px 4px 0 var(--gold); }
.button.primary:active { box-shadow: 0 0 0 var(--gold); }
.button.ghost { background: none; border-color: transparent; box-shadow: none; color: var(--ink); }
.button.ghost:hover { background: var(--gold-wash); transform: none; box-shadow: none; }
.button.ghost:active { transform: none; background: var(--paper-deep); }
/* A ghost link ("All nodes") is a small-caps pointer with an arrow that nudges on hover */
.card-head a.button.ghost { font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.card-head a.button.ghost:not(:has(.icon))::after { content: "→"; font-size: .9rem; letter-spacing: 0; transition: transform .15s; }
.card-head a.button.ghost:hover::after { transform: translateX(3px); }
.button.danger { color: var(--danger); border-color: var(--danger); box-shadow: 2px 2px 0 var(--danger); }
.button.danger:hover { background: var(--danger-wash); color: var(--danger); box-shadow: 3px 3px 0 var(--danger); }
.button.danger:active { box-shadow: 0 0 0 var(--danger); }
.button.small { min-height: 30px; padding: .2rem .7rem; font-size: .8rem; }
.card-head a.button.ghost.small { font-size: .66rem; }
.button.wide { width: 100%; }
.button.big { padding: .85rem 1.2rem; font-size: 1.05rem; }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 2px 2px 0 var(--shade); }
button.link {
    background: none; border: 0; padding: 0; font: inherit; color: var(--ink); cursor: pointer; text-align: left;
    text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 2px; text-underline-offset: 3px;
}
button.link:hover { color: var(--red); text-decoration-color: var(--red); }

/* (i) next to a label: the explanation shows on hover, keyboard focus or tap (Ui.Hint) */
.hint {
    position: relative; display: inline-grid; place-items: center; flex: none; width: 1.05rem; height: 1.05rem; margin-left: .3rem;
    border: 1.5px solid var(--muted); border-radius: 50%; color: var(--muted); font: italic 700 .7rem/1 var(--display);
    cursor: help; vertical-align: .12em; user-select: none; letter-spacing: 0; text-transform: none;
}
.hint:hover, .hint:focus-visible { color: var(--paper-hi); background: var(--ink); border-color: var(--ink); outline: none; }
.hint::after {
    content: attr(data-tip); position: absolute; z-index: 30; left: -.6rem; bottom: calc(100% + 9px); width: max-content;
    max-width: min(20rem, 72vw); padding: .6rem .75rem; border-radius: var(--ctl-radius);
    background: var(--ink); color: var(--paper); font: 400 .82rem/1.45 var(--font); letter-spacing: 0; text-align: left;
    white-space: normal; text-transform: none; box-shadow: 3px 3px 0 var(--gold);
    display: none; pointer-events: none;
}
/* Hidden tips take no room (a hidden-but-laid-out tip near the right edge would widen the page) */
.hint:hover::after, .hint:focus::after { display: block; animation: tip .14s ease-out; }
h2 .hint { font-size: .66rem; }

/* Settings: one compact row per setting, label (with its hint) left, a field sized to its content right */
.setting { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .4rem 1rem; padding: .55rem 0; border-bottom: 1px solid var(--rule); }
.setting:last-child { border-bottom: 0; padding-bottom: 0; }
.setting.stacked { flex-direction: column; align-items: stretch; }
.setting-label { display: inline-flex; align-items: center; min-width: 0; }
.setting-label label { display: inline-flex; flex-direction: row; align-items: center; gap: .45rem; color: var(--ink); font-size: .9rem; font-weight: 500; }
.setting input, .setting select, .setting textarea { font-size: .86rem; padding: .3rem .55rem; border-radius: var(--ctl-radius); }
.setting .w-xs { width: 5rem; }
.setting .w-sm { width: 9rem; }
.setting .w-md { width: min(15rem, 100%); }
/* A Stars price with what it comes to in money beside it (Settings → Payments → Telegram Stars) */
.price-input { display: inline-flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: .3rem .7rem; }
.price-input output { font-variant-numeric: tabular-nums; }
.setting .mono { font-family: var(--mono); font-size: .74rem; }
.setting .range { display: inline-flex; align-items: center; gap: .4rem; }
.settings .card { padding-top: 1rem; padding-bottom: 1rem; }
.settings .card-head { margin-bottom: .3rem; }
.settings-group { scroll-margin-top: calc(var(--topbar-h) + .5rem); margin-top: 1rem; }
.settings .card[id] { scroll-margin-top: calc(var(--topbar-h) + .5rem); }
.group-head { display: flex; align-items: center; gap: .4rem; font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: .25rem 0 .75rem; }
.inline-settings { display: flex; flex-direction: column; max-width: 34rem; }
.inline-settings .form-actions { margin-top: .6rem; }
.protocol-forms { gap: 1.5rem; }
.protocol-forms form { display: flex; flex-direction: column; min-width: 0; }
.protocol-forms h3 { display: flex; align-items: center; flex-wrap: wrap; gap: .1rem .45rem; }
.protocol-forms h3 .pill { margin: 0; }
.protocol-forms p.small { margin: .2rem 0 .35rem; }
.protocol-forms .button.primary { align-self: flex-start; margin-top: .8rem; }
table.compact th, table.compact td { padding: .42rem .6rem; font-size: .88rem; }
table.compact th { font-size: .62rem; }
.sub-head { font-size: 1rem; margin: 1.1rem 0 .45rem; display: flex; align-items: center; }

/* User page: all servers, or only the ticked ones (the ticks only matter for "only these") */
.server-choice { display: flex; flex-direction: column; gap: .35rem; }
.server-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: .3rem 1rem; padding-left: 1.6rem; }
.server-choice:has(input[value="all"]:checked) .server-checks { opacity: .45; pointer-events: none; }
.server-choice .form-actions { margin-top: .5rem; }

.copy-row { display: flex; gap: .55rem; margin: .5rem 0; }
.copy-row input { flex: 1; }

details:not(.account, .platform) > summary { cursor: pointer; color: var(--ink); font-weight: 600; margin: .5rem 0; text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 2px; text-underline-offset: 3px; }
details:not(.account, .platform) > summary:hover { color: var(--red); }
.platform > summary { cursor: pointer; }
details.qr-toggle img { display: block; margin: .5rem 0; background: #fff; border: 1.5px solid var(--ink); border-radius: var(--ctl-radius); max-width: 100%; height: auto; }

/* ---------- Flash, alerts ---------- */
/* Message bars: a printed slip with a stamp on the left; the shadow takes the status ink */
.flash {
    position: relative; padding: .7rem 1rem .7rem 2.75rem; border-radius: var(--ctl-radius); margin-bottom: 1.5rem;
    background: var(--paper-hi); border: 1.5px solid var(--ok); box-shadow: 3px 3px 0 var(--ok); color: var(--ink); font-weight: 450;
    animation: drop .22s ease-out;
}
.flash::before {
    content: "✓"; position: absolute; left: .85rem; top: calc(.68rem + 1px); width: 18px; height: 18px; border-radius: 4px;
    background: var(--ok); color: var(--paper-hi); font: 800 11px/18px var(--font); text-align: center;
}
.flash.error { border-color: var(--danger); box-shadow: 3px 3px 0 var(--danger); }
.flash.error::before { content: "✕"; background: var(--danger); }
.flash.warn { border-color: var(--warn); box-shadow: 3px 3px 0 var(--warn); }
.flash.warn::before { content: "!"; background: var(--warn); font-size: 12px; }
body.public .flash { padding-left: 1rem; color: var(--ok); font-weight: 550; }
body.public .flash.error { color: var(--danger); }
body.public .flash.warn { color: var(--warn); }
body.public .flash::before { content: none; }
.error-box {
    background: var(--danger-wash); color: var(--danger); padding: .75rem; border-radius: var(--ctl-radius); border-left: 4px solid var(--danger);
    white-space: pre-wrap; overflow-wrap: anywhere; max-height: 16rem; overflow: auto; font-family: var(--mono); font-stretch: 78%; font-size: .76rem;
}

.alert-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .55rem; }
.alert-item {
    display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; padding: .7rem .9rem .7rem 1rem;
    border-radius: 0 var(--ctl-radius) var(--ctl-radius) 0; border-left: 4px solid var(--muted); background: var(--paper-lo);
}
.alert-item > div, .alert-item { flex-wrap: wrap; }
.alert-item > div { display: flex; flex-direction: column; gap: .15rem; }
.alert-item strong { font-weight: 650; }
.alert-item.critical { border-left-color: var(--danger); background: linear-gradient(90deg, var(--danger-wash), var(--paper-lo) 70%); }
.alert-item.warning { border-left-color: var(--warn); background: linear-gradient(90deg, var(--warn-wash), var(--paper-lo) 70%); }
.alert-item.info { border-left-color: var(--info); }
ul.alert-list > li.alert-item:not(:has(> div)) { flex-direction: column; gap: .15rem; }

.rank { list-style: none; margin: 0; padding: 0; }
.rank li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--rule); }
.rank li:last-child { border-bottom: 0; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0; margin: 0 0 .75rem; }
.facts dt, .facts dd { padding: .4rem 0; border-bottom: 1px dotted var(--rule-2); }
.facts dt { padding-right: 1.25rem; color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; line-height: 1.9; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.facts dt:last-of-type, .facts dd:last-of-type { border-bottom: 0; }
.services { list-style: none; padding: 0; margin: .5rem 0; display: flex; flex-direction: column; gap: .3rem; }

/* ---------- SSH install ---------- */
.ssh-fields { border: 1.5px dashed var(--rule-2); border-radius: var(--radius); padding: .55rem 1rem .8rem; margin: 1rem 0; min-width: 0; }
.ssh-fields legend { padding: 0 .45rem; font: italic 700 1rem var(--display); color: var(--ink); }
.span-2 { grid-column: span 2; }
@media (max-width: 600px) { .span-2 { grid-column: auto; } }
textarea { font-family: var(--mono); font-stretch: 78%; font-size: .76rem; resize: vertical; }
textarea.message-input { font-family: inherit; font-stretch: 100%; font-size: .9rem; }
/* The live install log is the one dark screen: a terminal printed into the ledger */
.stream-log {
    background: var(--night); color: #e9dfcb; border: 1.5px solid var(--frame); border-radius: var(--radius); padding: .9rem 1rem; margin: .75rem 0;
    max-height: 26rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 4px 4px 0 var(--gold);
    font-size: .74rem; line-height: 1.6;
}
.stream-log.ok { box-shadow: 4px 4px 0 var(--ok); }
.stream-log.failed { box-shadow: 4px 4px 0 var(--danger); }

/* ---------- Inbounds ---------- */
.inbound { border: 1.5px solid var(--frame); border-radius: var(--radius); padding: .9rem 1.05rem; margin-bottom: .85rem; background: var(--field); }
.inbound.off { opacity: .6; border-style: dashed; }
.inbound header { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .35rem; }
.inbound p { margin: .35rem 0; }
.inbound footer { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; margin-top: .7rem; padding-top: .7rem; border-top: 1.5px dashed var(--rule-2); }

/* ---------- Chart ---------- */
.chart-plot { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .axis { stroke: var(--rule-heavy); stroke-width: 1.5; }
.chart .tick { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart .down { fill: var(--chart-down); }
.chart .up { fill: var(--chart-up); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--hover-wash); }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); margin: 0; pointer-events: none; font: italic 1.05rem var(--display); }
.legend { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; list-style: none; margin: 0; padding: 0; font-size: .84rem; color: var(--muted); }
.legend-value { margin-left: .4rem; color: var(--ink); font-weight: 600; }
.chart-view > .legend { margin-bottom: .7rem; }
.chart-view + .chart-view:not([hidden]) { margin-top: 1rem; }
.chart .s1, .swatch.s1 { fill: var(--chart-s1); background: var(--chart-s1); }
.chart .s2, .swatch.s2 { fill: var(--chart-s2); background: var(--chart-s2); }
.chart .s3, .swatch.s3 { fill: var(--chart-s3); background: var(--chart-s3); }
.chart .s4, .swatch.s4 { fill: var(--chart-s4); background: var(--chart-s4); }
.chart .s5, .swatch.s5 { fill: var(--chart-s5); background: var(--chart-s5); }
.chart .s6, .swatch.s6 { fill: var(--chart-s6); background: var(--chart-s6); }
.chart .other, .swatch.other { fill: var(--chart-other); background: var(--chart-other); }
.segmented { display: inline-flex; border: 1.5px solid var(--frame); border-radius: var(--ctl-radius); overflow: hidden; background: var(--paper-hi); }
.segmented[hidden] { display: none; }
.segmented button { padding: .25rem .8rem; border: 0; background: none; color: var(--muted); font: inherit; font-size: .82rem; font-weight: 550; cursor: pointer; }
.segmented button + button { border-left: 1.5px solid var(--frame); }
.segmented button:hover { color: var(--ink); background: var(--paper-lo); }
.segmented button[aria-selected="true"] { background: var(--ink); color: var(--paper-hi); font-weight: 650; }
.segmented button:focus-visible { outline: 2.5px solid var(--gold); outline-offset: -3px; }
.swatch { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-right: .4rem; vertical-align: -1px; }
.swatch.down { background: var(--chart-down); }
.swatch.up { background: var(--chart-up); }
.tooltip {
    position: absolute; pointer-events: none; background: var(--ink); color: var(--paper); border-radius: var(--ctl-radius);
    padding: .5rem .7rem; font-size: .8rem; line-height: 1.45; white-space: nowrap; transform: translate(-50%, -110%);
    box-shadow: 3px 3px 0 var(--gold);
}

/* ---------- Costs ---------- */
.chart .cost { fill: var(--chart-down); }
.chart .cost-forecast { fill: var(--chart-down); opacity: .35; }
.swatch.cost { background: var(--chart-down); }
.swatch.cost-forecast { background: var(--chart-down); opacity: .35; }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: 5.5rem 1fr 7.5rem; gap: .75rem; align-items: center; padding: .3rem 0; }
.bars-label { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.bars-value { text-align: right; font-size: .9rem; }
.bars-track { position: relative; height: .7rem; }
.bars-track meter { position: absolute; inset: 0; width: 100%; height: 100%; appearance: none; border: 0; background: var(--paper-deep); border-radius: 2px; }
.bars-track meter.forecast { opacity: .35; }
.bars-track meter + meter { background: transparent; }
.bars-track meter::-webkit-meter-bar { background: transparent; border: 0; border-radius: 2px; height: 100%; }
.bars-track meter::-webkit-meter-optimum-value { background: var(--chart-down); border-radius: 2px; }
.bars-track meter::-moz-meter-bar { background: var(--chart-down); border-radius: 2px; }
.code-block { background: var(--paper-lo); border: 1px solid var(--rule); border-radius: var(--ctl-radius); padding: .75rem 1rem; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Public pages (login, connect) ---------- */
body.public {
    min-height: 100vh;
    background: radial-gradient(ellipse 60% 45% at 50% 0%, var(--public-glow), transparent 70%), var(--lattice), var(--grain), var(--paper);
}
.public-main { max-width: 560px; margin: 0 auto; padding: 2rem 1rem 3rem; }
.login-card {
    position: relative; max-width: 400px; margin: 7vh auto 0; text-align: center; background: var(--paper-hi);
    border: 2px solid var(--frame); border-radius: var(--radius); box-shadow: 8px 8px 0 var(--shade); animation: rise .5s cubic-bezier(.2, .7, .2, 1) backwards;
}
/* A gold frame printed inside the card's edge, like a ticket */
.login-card::before { content: ""; position: absolute; inset: 6px; border: 1px solid var(--gold); border-radius: 6px; pointer-events: none; }
/* The logo artwork sits on parchment (#fbf0dc, sampled from the image), so it gets a band of the same parchment */
.login-hero { padding: 1.6rem 1rem 1.1rem; background: #fbf0dc; border-bottom: 3px double var(--rule-heavy); border-radius: 8px 8px 0 0; }
.login-hero img { display: block; width: 180px; height: auto; margin: 0 auto; animation: swing .9s cubic-bezier(.3, 1.4, .5, 1) .15s backwards; }
.login-body { display: flex; flex-direction: column; align-items: stretch; gap: .8rem; padding: 1.4rem 1.9rem 2rem; }
.login-body h1 { font-size: 1.9rem; font-style: italic; }
.login-body p { margin: 0; }
.login-card form { width: 100%; }
.connect-head { display: flex; align-items: center; gap: .9rem; margin-bottom: 1.4rem; }
.connect-head p { margin: 0; }
.connect-head img { flex: none; border-radius: 50%; box-shadow: 0 0 0 2px var(--night), 0 0 0 4px var(--gold); }
.connect-main { box-shadow: 5px 5px 0 var(--gold); }
/* Install view: download, the App Store country steps, then open */
.connect-main > .button + *, .connect-main > * + .button { margin-top: .75rem; }
.connect h2 { margin-bottom: .5rem; }
.platform > summary { list-style: none; color: var(--ink); margin: 0; text-decoration: none; }
.platform > summary::-webkit-details-marker { display: none; }
.platform > summary h2 { display: inline; margin: 0; }
.platform > summary::after { content: "▾"; float: right; color: var(--muted); transition: transform .15s; }
.platform[open] > summary::after { transform: rotate(180deg); }
.platform[open] > summary { margin-bottom: .55rem; }
.steps { padding-left: 1.25rem; margin: .5rem 0; }
.steps li::marker { font: italic 700 1em var(--display); color: var(--red); }
.apps { list-style: none; padding: 0; margin: 0; }
.apps li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .65rem 0; border-top: 1px solid var(--rule); flex-wrap: wrap; }
tr.picked td { background: var(--picked); }
/* Country code chip next to a node's name (Ui.Country): a little licence plate */
.cc {
    display: inline-grid; place-items: center; flex: none; width: 32px; height: 22px; border-radius: 3px;
    background: var(--paper-hi); color: var(--ink); border: 1.5px solid var(--plate); box-shadow: 1.5px 1.5px 0 var(--shade);
    font: 700 .6rem/1 var(--mono); font-stretch: 78%; letter-spacing: .02em;
}
.cc.sm { width: auto; height: auto; padding: 0 .3rem; margin-right: .35rem; border-width: 1px; box-shadow: none; color: var(--muted); border-color: var(--rule-2); font-size: .56rem; line-height: 1.6; }
.card.list .list-more { margin: 0; padding: .75rem 1.3rem; border-top: 1px solid var(--rule); }

/* ---------- Motion: one orchestrated entrance per page; everything else is a press or a nudge ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }
@keyframes tip { from { opacity: 0; transform: translateY(3px); } }
@keyframes spin { from { transform: rotate(-200deg); } }
@keyframes beat { 0%, 100% { box-shadow: 0 0 0 0 rgb(38 112 74 / 45%); } 50% { box-shadow: 0 0 0 4px rgb(38 112 74 / 0%); } }
@keyframes swing { from { opacity: 0; transform: rotate(-14deg) scale(.85); } }
.page-head, .breadcrumb { animation: rise .4s cubic-bezier(.2, .7, .2, 1) backwards; }
.content > .stats > * { animation: rise .45s cubic-bezier(.2, .7, .2, 1) backwards; }
.content > .stats > :nth-child(1) { animation-delay: .04s; }
.content > .stats > :nth-child(2) { animation-delay: .08s; }
.content > .stats > :nth-child(3) { animation-delay: .12s; }
.content > .stats > :nth-child(4) { animation-delay: .16s; }
.content > .stats > :nth-child(5) { animation-delay: .2s; }
.content > .stats > :nth-child(6) { animation-delay: .24s; }
.content > .stats > :nth-child(7) { animation-delay: .28s; }
.content > .stats > :nth-child(8) { animation-delay: .32s; }
.content > :is(.card, .dash-grid, .grid-2, .tiles, .settings, section, form) { animation: rise .5s cubic-bezier(.2, .7, .2, 1) .12s backwards; }
.content > :is(.card, .dash-grid, .grid-2, .tiles, .settings, section, form) ~ :is(.card, .dash-grid, .grid-2, .tiles, .settings, section, form) { animation-delay: .22s; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 560px) {
    /* Phones: two stat cards per row, without their icons */
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
    .stat { grid-template-columns: minmax(0, 1fr); grid-template-areas: "label" "value" "sub"; padding: .75rem .85rem 0; }
    .stat-sub { margin: 0 -.85rem; padding: .45rem .85rem .5rem; }
    .stat-icon { display: none; }
    .stat-value { font-size: 1.75rem; }
    .page-head { align-items: flex-start; }
}
