/* Pedro VPN control panel. No framework: one stylesheet. A dark "night ink" theme in the brand colours: doubloon gold
   for actions, links and focus; conquista red for the brand mark only (never a status); steel for secondary text;
   parchment for text. Statuses use their own green / orange / red so they never read as brand colours. */
:root {
    --bg: #0d0f13;
    --surface: #14161c;          /* Night Ink: cards, menu, top bar */
    --surface-2: #1b1e26;        /* hover, inputs, table heads */
    --surface-3: #232733;
    --border: #252a34;           /* lines inside blocks: table rows, separators */
    --block-border: #2a2f3b;     /* the frame of cards, panels, menu */
    --text: #efe8dc;             /* parchment, toned down for long reading */
    --muted: #98a2ae;            /* steel */
    --accent: #e8b23a;           /* doubloon gold */
    --accent-hover: #f2c560;
    --accent-ink: #1b1305;
    --accent-soft: #2a2312;
    --brand: #b3202a;            /* conquista red */
    --ok: #3dbe8b;
    --ok-soft: #102a20;
    --warn: #f08c3a;             /* orange, so a warning never looks like the gold of buttons */
    --warn-soft: #2e1d0f;
    --danger: #f2605f;
    --danger-soft: #311618;
    --info: #5aa9e6;
    --info-soft: #11243a;
    --chart-down: #e8b23a;
    --chart-up: #6fa8dc;
    /* Nodes in the traffic chart, in node-list order. Checked for colour blindness as a stack on --surface */
    --chart-s1: #9085e9; --chart-s2: #c98500; --chart-s3: #d55181;
    --chart-s4: #3987e5; --chart-s5: #199e70; --chart-s6: #d95926; --chart-other: #6f6962;
    --input-border: #323845;
    --radius: 12px;              /* blocks: cards, panels, dialogs */
    --ctl-radius: 8px;           /* controls: buttons, inputs, message bars */
    --topbar-h: 60px;
    --menu-w: 248px;
    --shadow: 0 1px 2px rgb(0 0 0 / 35%);
    --glow: 0 0 0 1px var(--accent), 0 6px 22px rgb(232 178 58 / 12%);
    --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
    color-scheme: dark;
}
/* The public pages (sign-in, connect) are softer still */
body.public { --radius: 18px; --ctl-radius: 10px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); }
body.public { font-size: 15px; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 600; }
code, pre { font-family: var(--mono); font-size: .86em; }
code { background: var(--surface-2); border-radius: 6px; padding: .1em .4em; overflow-wrap: anywhere; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
kbd { font: 600 .7rem/1 var(--mono); padding: .2rem .4rem; border: 1px solid var(--input-border); border-radius: 5px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .82em; }

/* ---------- 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.5;
    stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px;
}

/* ---------- Shell: 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;
    background: var(--surface); border-right: 1px solid var(--block-border);
}
/* A thin red-to-gold line on top: the brand, once, out of the way of the content */
.sidebar::before { content: ""; flex: none; height: 3px; background: linear-gradient(90deg, var(--brand), var(--accent)); }
.brand { display: flex; align-items: center; gap: .75rem; flex: none; padding: 1rem 1rem .85rem; color: var(--text); }
.brand:hover { color: var(--text); text-decoration: none; }
.brand-mark { width: 40px; height: 40px; flex: none; border-radius: 50%; object-fit: cover; transform: scale(1.04); }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand-name { font-size: 1.05rem; font-weight: 800; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { color: var(--accent); font-size: .7rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: .25rem .65rem; }
.nav-group { padding: 1rem .6rem .35rem; color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; }
.nav-group:first-child { padding-top: .35rem; }
.nav a {
    position: relative; display: flex; align-items: center; gap: .75rem; height: 38px; padding: 0 .65rem;
    border-radius: var(--ctl-radius); color: var(--muted); font-size: .9rem; font-weight: 500; white-space: nowrap;
}
.nav a .icon { width: 18px; height: 18px; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.nav a.active::before { content: ""; position: absolute; left: -.65rem; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.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: .6rem .65rem .6rem 1.25rem; border-top: 1px solid var(--border); }
.version { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.nav-collapse {
    display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: var(--ctl-radius);
    background: none; color: var(--muted); cursor: pointer;
}
.nav-collapse:hover { background: var(--surface-2); color: var(--text); }
.badge { min-width: 1.4rem; padding: 0 .45rem; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: .72rem; font-weight: 700; line-height: 1.35rem; text-align: center; }
.badge.danger { background: var(--danger); color: #1c0909; }
.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.25rem 0 .75rem; background: rgb(13 15 19 / 85%); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar-btn {
    position: relative; display: inline-grid; place-items: center; flex: none; width: 38px; height: 38px; padding: 0;
    border: 0; border-radius: var(--ctl-radius); background: none; color: var(--muted); cursor: pointer;
}
.topbar-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topbar-btn .icon { width: 18px; height: 18px; }
.topbar-count {
    position: absolute; top: 3px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
    background: var(--danger); color: #1c0909; font-size: 10.5px; font-weight: 800; line-height: 16px; text-align: center;
}
.topbar-search { position: relative; display: flex; align-items: center; flex: 1 1 auto; max-width: 520px; }
.topbar-search > .icon { position: absolute; left: .8rem; color: var(--muted); pointer-events: none; }
.topbar-search kbd { position: absolute; right: .6rem; pointer-events: none; }
.topbar-search input {
    height: 38px; padding: 0 2.4rem 0 2.35rem; font-size: .88rem; background: var(--surface);
    border: 1px solid var(--block-border); border-radius: var(--ctl-radius);
}
.topbar-search input:focus-visible { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.topbar-search input:focus + kbd { display: none; }
.topbar-search.miss input { border-color: var(--danger); }
.topbar-right { display: flex; align-items: center; gap: .25rem; flex: none; margin-left: auto; }

.account { position: relative; }
.account > summary {
    display: flex; align-items: center; gap: .55rem; height: 42px; margin: 0; padding: 0 .55rem 0 .3rem;
    border-radius: 99px; list-style: none; color: var(--text); font-weight: 500; cursor: pointer;
}
.account > summary::-webkit-details-marker { display: none; }
.account > summary:hover, .account[open] > summary { background: var(--surface-2); }
.account-name { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; }
.avatar {
    display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #c98a1e); color: var(--accent-ink); font-size: .74rem; font-weight: 800;
}
.avatar.big { width: 44px; height: 44px; font-size: .95rem; }
.avatar.sm { width: 28px; height: 28px; font-size: .72rem; background: var(--surface-3); color: var(--text); }
.account-menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 45; width: 290px; display: flex; flex-direction: column;
    padding: .9rem 0 .5rem; background: var(--surface); border: 1px solid var(--block-border); border-radius: var(--radius);
    box-shadow: 0 16px 40px rgb(0 0 0 / 55%);
}
.account-card { display: flex; align-items: center; gap: .8rem; padding: 0 1rem .9rem; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.menu-item {
    display: flex; align-items: center; gap: .65rem; width: 100%; padding: .55rem 1rem; border: 0; background: none;
    color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.menu-item .icon { color: var(--muted); }
.account-version { padding: .45rem 1rem 0; }

@media (min-width: 861px) {
    .menu-btn { display: none; }
    .menu-collapsed { --menu-w: 68px; }
    .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: .5rem .55rem; padding: 0; overflow: hidden; border-top: 1px solid var(--border); }
    .menu-collapsed .nav a { justify-content: center; padding: 0; }
    .menu-collapsed .nav a .badge { position: absolute; top: 1px; right: 1px; min-width: 15px; padding: 0 3px; font-size: 10px; line-height: 15px; }
    .menu-collapsed .sidebar-foot { justify-content: center; padding-left: .65rem; }
    .menu-collapsed .nav-collapse .icon { transform: scaleX(-1); }
}

/* ---------- Page: breadcrumb, title with actions on the right ---------- */
.content { width: 100%; max-width: 1600px; min-width: 0; margin: 0 auto; padding: 1.25rem 1.75rem 3rem; }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .4rem; font-size: .8rem; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb a::after { content: "/"; margin-left: .4rem; color: var(--border); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: .75rem 1.5rem; margin: 0 0 1.25rem; }
.page-title { min-width: 0; }
.page-title h1 { overflow-wrap: anywhere; }
.page-sub { margin: .2rem 0 0; color: var(--muted); font-size: .86rem; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.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: 36px; height: 36px; padding: 0; border: 1px solid var(--block-border);
    border-radius: var(--ctl-radius); background: var(--surface); color: var(--muted); cursor: pointer;
}
.icon-button:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

@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 .16s ease-out; visibility: hidden;
    }
    .menu-open .sidebar { transform: none; visibility: visible; box-shadow: 10px 0 30px rgb(0 0 0 / 60%); }
    .menu-open .scrim { display: block; position: fixed; z-index: 35; inset: 0; background: rgb(0 0 0 / 55%); }
    .nav-collapse, .account-name, .topbar-search kbd { display: none; }
    .topbar { padding: 0 .75rem; }
    .content { padding: 1rem 1rem 2.5rem; }
}
@media (max-width: 560px) {
    .topbar-search { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ---------- Cards, grids ---------- */
.card { background: var(--surface); border: 1px solid var(--block-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .8rem; 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.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.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): icon, label, a big number, a line of context */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat {
    display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "icon label" "icon value" "icon sub";
    column-gap: .9rem; align-items: center; padding: 1rem 1.1rem; color: var(--text);
    background: var(--surface); border: 1px solid var(--block-border); border-radius: var(--radius); box-shadow: var(--shadow);
}
a.stat:hover { color: var(--text); text-decoration: none; border-color: var(--input-border); background: #171a21; }
.stat-icon {
    grid-area: icon; align-self: start; display: grid; place-items: center; width: 42px; height: 42px;
    border-radius: 10px; background: var(--accent-soft); color: var(--accent);
}
.stat-icon .icon { width: 20px; height: 20px; }
.stat-icon.ok { background: var(--ok-soft); color: var(--ok); }
.stat-icon.warn { background: var(--warn-soft); color: var(--warn); }
.stat-icon.danger { background: var(--danger-soft); color: var(--danger); }
.stat-icon.muted { background: var(--surface-2); color: var(--muted); }
.stat-label { grid-area: label; color: var(--muted); font-size: .8rem; font-weight: 600; }
.stat-value { grid-area: value; font-size: 1.6rem; font-weight: 750; line-height: 1.2; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-value small { font-size: .95rem; font-weight: 500; color: var(--muted); }
.stat-sub { grid-area: sub; color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.warn { border-color: rgb(240 140 58 / 45%); }
.stat.danger { border-color: rgb(242 96 95 / 45%); }
.stat.danger .stat-value { color: var(--danger); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: 1.25rem; align-items: start; margin-bottom: 1.25rem; }
.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: .45rem 0; border-bottom: 1px solid var(--border); }
.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: 1rem; margin-bottom: 1.25rem; }
.tile { display: flex; flex-direction: column; gap: .2rem; background: var(--surface); border: 1px solid var(--block-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1.1rem; color: var(--text); }
a.tile:hover { color: var(--text); text-decoration: none; box-shadow: var(--glow); }
.tile-label { color: var(--muted); font-size: .8rem; font-weight: 600; }
.tile-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-value.small { font-size: 1.15rem; }
.tile-value small { font-size: .9rem; font-weight: 500; color: var(--muted); }
.tile.warn { border-color: var(--warn); }
.tile.danger { border-color: 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: 1rem 1.25rem 0; }
.list-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: 1rem 1.25rem .75rem; }
.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: 36px; padding-left: 2.2rem; }
.tabs { display: flex; gap: .25rem; padding: 0 1.25rem; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs a {
    display: inline-flex; align-items: center; gap: .45rem; padding: .55rem .7rem .65rem; margin-bottom: -1px;
    border-bottom: 2px solid transparent; color: var(--muted); font-size: .88rem; font-weight: 550; white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { min-width: 1.6rem; padding: .05rem .45rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: .75rem; font-weight: 650; text-align: center; font-variant-numeric: tabular-nums; }
.tabs a.active .count { background: var(--accent-soft); color: var(--accent); }
.tabs a.alarm .count { background: var(--warn-soft); color: var(--warn); }
.bulk-bar {
    display: none; align-items: center; flex-wrap: wrap; gap: .5rem; padding: .55rem 1.25rem;
    background: var(--accent-soft); border-bottom: 1px solid rgb(232 178 58 / 25%); font-size: .88rem;
}
.bulk-bar.on { display: flex; }
.bulk-bar > span { margin-right: .5rem; }
.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 .button { margin-top: .6rem; }
.list-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; padding: .75rem 1.25rem; border-top: 1px solid var(--border); 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: 7px;
    color: var(--muted); font-variant-numeric: tabular-nums;
}
.sizes a:hover, .pager a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sizes a.active, .pager .current { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.pager .off { opacity: .35; }
.pager .gap { min-width: 18px; padding: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -1.25rem; padding: 0 1.25rem; }
.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(--border); vertical-align: top; }
th { font-size: .74rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; border-bottom-color: var(--input-border); }
th a { color: inherit; }
th a:hover { color: var(--text); text-decoration: none; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
body.public tbody tr:hover td { background: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.off td { opacity: .55; }
th[data-sort-key] { cursor: pointer; user-select: none; }
th[aria-sort="ascending"]::after { content: " ↑"; color: var(--accent); }
th[aria-sort="descending"]::after { content: " ↓"; color: var(--accent); }
.row-actions { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.row-actions form { margin: 0; }
/* Data tables (lists): roomier rows, vertically centred, edge padding that matches the card */
table.data th { background: var(--surface-2); padding-top: .6rem; padding-bottom: .6rem; }
table.data td { vertical-align: middle; padding-top: .6rem; padding-bottom: .6rem; }
table.data th:first-child, table.data td:first-child { padding-left: 1.25rem; }
table.data th:last-child, table.data td:last-child { padding-right: 1.25rem; }
table.data.compact td { padding-top: .45rem; padding-bottom: .45rem; }
.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(--accent); cursor: pointer; }
.cell-main { display: inline-flex; align-items: center; gap: .65rem; min-width: 0; color: var(--text); }
.cell-main:hover { color: var(--text); text-decoration: none; }
.cell-main:hover strong { color: var(--accent); }
.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 with a dot: Online / Active / Disabled, node states */
.status { display: inline-flex; align-items: center; gap: .4rem; padding: .12rem .6rem .12rem .5rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: .78rem; font-weight: 650; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.ok::before { box-shadow: 0 0 0 3px rgb(61 190 139 / 25%); }
.status.idle { background: var(--info-soft); color: var(--info); }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.status.danger { background: var(--danger-soft); 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: .5rem; }
.meter { width: 70px; height: 6px; display: block; }
.meter .track { fill: var(--surface-3); }
.meter .fill { fill: var(--ok); }
.meter.warn .fill { fill: var(--warn); }
.meter.danger .fill { fill: var(--danger); }
.meter.gold .fill { fill: var(--accent); }
.share-col .meter { width: 100%; max-width: 160px; }
.meter-value { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; min-width: 2.4rem; }

/* ---------- Dialogs ---------- */
dialog.modal {
    width: min(520px, calc(100vw - 2rem)); max-height: calc(100vh - 3rem); padding: 0; color: var(--text);
    background: var(--surface); border: 1px solid var(--block-border); border-radius: 14px; box-shadow: 0 24px 60px rgb(0 0 0 / 60%);
}
dialog.modal.wide { width: min(780px, calc(100vw - 2rem)); }
dialog.modal::backdrop { background: rgb(5 6 8 / 70%); backdrop-filter: blur(2px); }
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.25rem; border-bottom: 1px solid var(--border); }
.modal-head .icon-button { width: 32px; height: 32px; border: 0; background: none; }
.modal-body { padding: 1.1rem 1.25rem; overflow: auto; }
.modal-body > p:first-child { margin-top: 0; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; padding: .9rem 1.25rem; border-top: 1px solid var(--border); background: #12141a; }

/* ---------- Pills, dots ---------- */
.pill { display: inline-block; padding: .05rem .55rem; margin: 0 .2rem .2rem 0; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.muted { opacity: .6; }
/* A server's priority in Happ's "Авто": primaries carry the traffic, secondaries stand by */
.pill.role.primary { background: var(--accent-soft); color: var(--accent); }
.pill.role.secondary { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
.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: .88rem; font-weight: 500; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); }
input, select, textarea {
    font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--input-border); border-radius: var(--ctl-radius);
    padding: .45rem .7rem; min-width: 0; width: 100%;
}
input:hover, select:hover, textarea:hover { border-color: #46506a; }
input[readonly]:hover { border-color: var(--input-border); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.button:focus-visible, summary:focus-visible, a:focus-visible, .icon-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[readonly] { background: var(--surface-2); font-family: var(--mono); font-size: .85rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem 1rem; align-items: end; margin-top: .5rem; }
.form-actions { display: flex; gap: .5rem; align-items: center; }
.form-actions.sticky { position: sticky; bottom: 0; padding: .75rem 0; background: linear-gradient(transparent, var(--bg) 35%); margin-bottom: 1rem; }
.inline-form { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.inline-form select, .inline-form input { width: auto; }
.narrow { max-width: 12rem; }
form { margin: 0; }

.button {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 36px; font: inherit; font-weight: 600;
    font-size: .875rem; padding: .4rem 1rem; border-radius: var(--ctl-radius); border: 1px solid var(--input-border);
    background: var(--surface-2); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; list-style: none;
}
.button:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.button .icon { color: var(--muted); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 14px rgb(232 178 58 / 18%); }
.button.primary .icon { color: inherit; }
.button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.button.ghost { background: none; border-color: transparent; color: var(--muted); }
.button.ghost:hover { background: var(--surface-2); color: var(--text); }
.button.danger { color: var(--danger); }
.button.danger .icon { color: var(--danger); }
.button.danger:hover { background: var(--danger-soft); color: var(--danger); }
.button.small { min-height: 30px; padding: .2rem .7rem; font-size: .8rem; }
.button.wide { width: 100%; }
.button.big { padding: .85rem 1.2rem; font-size: 1.05rem; }
.button:disabled { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: left; }

/* (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: 1px solid var(--muted); border-radius: 50%; color: var(--muted); font: italic 600 .68rem/1 Georgia, serif;
    cursor: help; vertical-align: .12em; user-select: none;
}
.hint:hover, .hint:focus-visible { color: var(--accent); border-color: var(--accent); outline: none; }
.hint::after {
    content: attr(data-tip); position: absolute; z-index: 30; left: -.6rem; bottom: calc(100% + 8px); width: max-content;
    max-width: min(20rem, 72vw); padding: .55rem .7rem; border: 1px solid var(--block-border); border-radius: var(--ctl-radius);
    background: var(--surface-2); color: var(--text); font: 400 .82rem/1.45 var(--font); letter-spacing: 0; text-align: left;
    white-space: normal; text-transform: none; box-shadow: 0 6px 20px rgb(0 0 0 / 60%);
    opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .12s;
}
.hint:hover::after, .hint:focus::after { opacity: 1; visibility: visible; }
h2 .hint { font-size: .62rem; }

/* 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: .5rem 0; border-bottom: 1px solid var(--border); }
.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(--text); 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%); }
.setting .mono { font-family: var(--mono); font-size: .78rem; }
.setting .range { display: inline-flex; align-items: center; gap: .4rem; }
.settings .card { padding-top: .9rem; padding-bottom: .9rem; }
.settings .card-head { margin-bottom: .25rem; }
.inline-settings { display: flex; flex-direction: column; max-width: 34rem; }
.inline-settings .form-actions { margin-top: .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 .4rem; }
.protocol-forms h3 .pill { margin: 0; }
.protocol-forms p.small { margin: .2rem 0 .35rem; }
.protocol-forms .button.primary { align-self: flex-start; margin-top: .7rem; }
table.compact th, table.compact td { padding: .4rem .6rem; font-size: .88rem; }
.sub-head { font-size: .9rem; margin: 1rem 0 .4rem; 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: .4rem; }

.copy-row { display: flex; gap: .5rem; margin: .5rem 0; }
.copy-row input { flex: 1; }

details > summary { cursor: pointer; color: var(--accent); font-weight: 500; margin: .5rem 0; }
details.qr-toggle img { display: block; margin: .5rem 0; background: #fff; border-radius: 8px; max-width: 100%; height: auto; }
details.qr-toggle.inline { position: relative; }
details.qr-toggle.inline > summary { margin: 0; color: var(--text); }
details.qr-toggle.inline[open] img { position: absolute; right: 0; z-index: 5; box-shadow: var(--shadow); border: 1px solid var(--border); }
summary.button::-webkit-details-marker { display: none; }

/* ---------- Flash, alerts ---------- */
/* Message bars: a tinted bar with a status icon and a coloured edge; the text stays readable */
.flash { position: relative; padding: .65rem 1rem .65rem 2.6rem; border-radius: var(--ctl-radius); margin-bottom: 1.25rem; background: var(--ok-soft); border: 1px solid rgb(61 190 139 / 30%); color: var(--text); font-weight: 400; }
.flash.error { border-color: rgb(242 96 95 / 35%); }
.flash.warn { border-color: rgb(240 140 58 / 35%); }
.flash::before {
    content: "✓"; position: absolute; left: .85rem; top: calc(.6rem + 2px); width: 16px; height: 16px; border-radius: 50%;
    background: var(--ok); color: #000; font: 700 10px/16px var(--font); text-align: center;
}
.flash.error { background: var(--danger-soft); }
.flash.error::before { content: "✕"; background: var(--danger); }
.flash.warn { background: var(--warn-soft); }
.flash.warn::before { content: "!"; background: var(--warn); font-size: 11px; }
body.public .flash { padding-left: 1rem; color: var(--ok); font-weight: 500; }
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-soft); color: var(--danger); padding: .75rem; border-radius: var(--ctl-radius); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 16rem; overflow: auto; }

.alert-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.alert-item { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; padding: .65rem .9rem; border-radius: var(--ctl-radius); border-left: 3px solid var(--muted); background: var(--surface-2); }
.alert-item > div, .alert-item { flex-wrap: wrap; }
.alert-item > div { display: flex; flex-direction: column; gap: .15rem; }
.alert-item.critical { border-left-color: var(--danger); }
.alert-item.warning { border-left-color: var(--warn); }
.alert-item.info { border-left-color: var(--accent); }
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: .45rem 0; border-bottom: 1px solid var(--border); }
.rank li:last-child { border-bottom: 0; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 .75rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.services { list-style: none; padding: 0; margin: .5rem 0; display: flex; flex-direction: column; gap: .25rem; }

/* ---------- SSH install ---------- */
.ssh-fields { border: 1px solid var(--block-border); border-radius: var(--radius); padding: .5rem 1rem .75rem; margin: 1rem 0; min-width: 0; }
.ssh-fields legend { padding: 0 .4rem; font-weight: 600; font-size: .9rem; }
.span-2 { grid-column: span 2; }
@media (max-width: 600px) { .span-2 { grid-column: auto; } }
textarea { font-family: var(--mono); font-size: .8rem; resize: vertical; }
textarea.message-input { font-family: inherit; font-size: .9rem; }
.stream-log {
    background: #050505; color: #e0e0e0; border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; margin: .75rem 0; max-height: 26rem; overflow: auto;
    white-space: pre-wrap; overflow-wrap: anywhere; border-left: 4px solid var(--accent);
}
.stream-log.ok { border-left-color: var(--ok); }
.stream-log.failed { border-left-color: var(--danger); }

/* ---------- Inbounds ---------- */
.inbound { border: 1px solid var(--block-border); border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: .75rem; }
.inbound.off { opacity: .65; }
.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: .5rem; flex-wrap: wrap; align-items: center; margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--border); }

/* ---------- Chart ---------- */
.chart-plot { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { stroke: var(--muted); stroke-width: 1; }
.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(--surface-2); }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); margin: 0; pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; list-style: none; margin: 0; padding: 0; font-size: .85rem; color: var(--muted); }
.legend-value { margin-left: .4rem; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-view > .legend { margin-bottom: .6rem; }
.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: 1px solid var(--input-border); border-radius: var(--ctl-radius); overflow: hidden; }
.segmented[hidden] { display: none; }
.segmented button { padding: .2rem .7rem; border: 0; background: none; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--input-border); }
.segmented button:hover { color: var(--text); }
.segmented button[aria-selected="true"] { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.segmented button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.swatch { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.swatch.down { background: var(--chart-down); }
.swatch.up { background: var(--chart-up); }
.tooltip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); border-radius: var(--ctl-radius); padding: .45rem .65rem; font-size: .8rem; line-height: 1.4; white-space: nowrap; transform: translate(-50%, -110%); }

/* ---------- 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-variant-numeric: tabular-nums; 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(--surface-2); border-radius: 99px; }
.bars-track meter.forecast { opacity: .35; }
.bars-track meter + meter { background: transparent; }
.bars-track meter::-webkit-meter-bar { background: transparent; border: 0; border-radius: 99px; height: 100%; }
.bars-track meter::-webkit-meter-optimum-value { background: var(--chart-down); border-radius: 99px; }
.bars-track meter::-moz-meter-bar { background: var(--chart-down); border-radius: 99px; }
.code-block { background: var(--surface-2); 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 70% 55% at 50% -12%, rgb(179 32 42 / 28%), transparent 65%), var(--bg); }
.public-main { max-width: 560px; margin: 0 auto; padding: 2rem 1rem 3rem; }
.login-card {
    max-width: 400px; margin: 7vh auto 0; overflow: hidden; text-align: center; background: var(--surface);
    border: 1px solid var(--block-border); border-radius: var(--radius); box-shadow: 0 30px 70px rgb(0 0 0 / 55%);
}
/* The logo artwork sits on parchment, so it gets a band of the same parchment (#fbf0dc, sampled from the image) */
.login-hero { padding: 1.4rem 1rem 1rem; background: #fbf0dc; border-bottom: 3px solid var(--accent); }
.login-hero img { display: block; width: 190px; height: auto; margin: 0 auto; }
.login-body { display: flex; flex-direction: column; align-items: stretch; gap: .75rem; padding: 1.5rem 1.75rem 1.75rem; }
.login-body h1 { font-size: 1.25rem; }
.login-body p { margin: 0; }
.login-card form { width: 100%; }
.connect-head { display: flex; align-items: center; gap: .85rem; margin-bottom: 1.25rem; }
.connect-head p { margin: 0; }
.connect-main { border-color: var(--accent); }
.connect h2 { margin-bottom: .5rem; }
.platform > summary { list-style: none; color: var(--text); margin: 0; }
.platform > summary::-webkit-details-marker { display: none; }
.platform > summary h2 { display: inline; margin: 0; }
.platform > summary::after { content: "▾"; float: right; color: var(--muted); }
.platform[open] > summary { margin-bottom: .5rem; }
.steps { padding-left: 1.25rem; margin: .5rem 0; }
.apps { list-style: none; padding: 0; margin: 0; }
.apps li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
tr.picked td { background: rgb(232 178 58 / 7%); }
/* Country code chip next to a node's name (Ui.Country) */
.cc {
    display: inline-grid; place-items: center; flex: none; width: 30px; height: 22px; border-radius: 6px;
    background: var(--surface-3); color: var(--text); font: 700 .68rem/1 var(--mono); letter-spacing: .04em;
}
.cc.sm { width: auto; height: auto; padding: 0 .3rem; margin-right: .35rem; background: none; border: 1px solid var(--border); color: var(--muted); font-size: .62rem; line-height: 1.5; }
.card.list .list-more { margin: 0; padding: .7rem 1.25rem; border-top: 1px solid var(--border); }
@media (max-width: 560px) {
    /* Phones: two stat cards per row, without their icons */
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
    .stat { grid-template-columns: minmax(0, 1fr); grid-template-areas: "label" "value" "sub"; padding: .75rem .85rem; }
    .stat-icon { display: none; }
    .stat-value { font-size: 1.3rem; }
    .page-head { align-items: flex-start; }
}
