/* KAD panels: one stylesheet for both (docs/superpowers/specs/2026-10-05-panel-redesign.md, 3.4).
   Every colour comes from a token below: dark by default, the light set
   under :root[data-theme="light"], chosen in the user menu (theme.js). */

/* Hide elements with x-cloak until Alpine processes them. Without this rule
   the markup flashes briefly before Alpine sets the x-show display state. */
[x-cloak] { display: none !important; }

:root {
    color-scheme: dark;
    --bg: #0e1217;
    --surface: #151b22;
    --surface-2: #1b232c;
    --surface-hover: #212b36;
    --border: #26303b;
    --border-strong: #35414e;
    --text: #e6edf3;
    --text-2: #a3afbc;
    --text-3: #7d8896;
    --accent: #4c9aff;
    --accent-strong: #2f7de1;
    --ok: #3fb950;
    --warn: #d29922;
    --danger: #f85149;
    --info: #58a6ff;
    --ok-tint: rgba(63, 185, 80, 0.14);
    --warn-tint: rgba(210, 153, 34, 0.14);
    --danger-tint: rgba(248, 81, 73, 0.14);
    --info-tint: rgba(88, 166, 255, 0.14);
    --neutral-tint: rgba(139, 148, 158, 0.16);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
    --r-control: 6px;
    --r-card: 8px;

    /* The names pages used before the tokens, kept as aliases so inline
       styles and older rules follow the palette. */
    --card: var(--surface);
    --primary: var(--accent-strong);
    --success: var(--ok);
    --warning: var(--warn);
    --input-bg: var(--surface-2);
    --sidebar-bg: var(--surface);
    --hover: var(--surface-hover);
    --text-secondary: var(--text-2);
    --muted: var(--text-3);
}

/* The light theme (theme.js sets data-theme). */
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f6f8fa;
    --surface: #ffffff;
    --surface-2: #f0f3f6;
    --surface-hover: #eaeef2;
    --border: #d0d7de;
    --border-strong: #b6bfc8;
    --text: #1f2328;
    --text-2: #4b5563;
    --text-3: #6b7480;
    --accent: #0969da;
    --accent-strong: #0969da;
    --ok: #1a7f37;
    --warn: #9a6700;
    --danger: #cf222e;
    --info: #0969da;
    --ok-tint: rgba(26, 127, 55, 0.11);
    --warn-tint: rgba(154, 103, 0, 0.11);
    --danger-tint: rgba(207, 34, 46, 0.1);
    --info-tint: rgba(9, 105, 218, 0.1);
    --neutral-tint: rgba(110, 119, 129, 0.12);
    --shadow: 0 8px 24px rgba(31, 35, 40, 0.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
}

.sidebar-header {
    padding: var(--s4);
    border-bottom: 1px solid var(--border);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--s2);
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 6px 10px;
    border-radius: var(--r-control);
    color: var(--text-2);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.12s, color 0.12s;
}

.sidebar-nav a:hover {
    background: var(--surface-hover);
    color: var(--text);
    text-decoration: none;
}

.sidebar-nav a.active {
    background: var(--surface-2);
    color: var(--text);
    box-shadow: inset 2px 0 0 var(--accent);
}

.nav-icon { font-size: 1.05rem; width: 1.25rem; text-align: center; }

.nav-category { margin-bottom: var(--s3); }

.nav-category-back .nav-back-link {
    font-size: 0.85rem;
    color: var(--text-3);
    margin-bottom: var(--s2);
}
.nav-category-back .nav-back-link:hover {
    color: var(--accent);
}

.nav-category-name {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-3);
    padding: var(--s1) 10px;
    letter-spacing: 0.06em;
}

.sidebar-footer {
    padding: var(--s3) var(--s4);
    border-top: 1px solid var(--border);
}

.sidebar-user {
    font-size: 0.8rem;
    color: var(--text-2);
    margin-bottom: var(--s2);
}

.content {
    flex: 1;
    padding: var(--s5) var(--s6);
    max-width: 1280px;
    overflow-y: auto;
    min-width: 0;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-card);
    padding: var(--s4);
    margin-bottom: var(--s4);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--s3);
}

/* Buttons: primary (one per header or form), secondary (the default),
   ghost (row and toolbar actions), danger (outline; solid only on the
   confirm button inside a confirmation). */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-control);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.btn:hover { background: var(--surface-hover); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: #fff;
}
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }

.btn-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}
.btn-danger:hover { background: var(--danger-tint); }
/* The confirm button of a destructive confirmation. */
.btn-danger-solid, .modal-actions .btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-warning {
    background: transparent;
    border-color: var(--warn);
    color: var(--warn);
}
.btn-warning:hover { background: var(--warn-tint); }

.btn-sm { height: 26px; padding: 0 9px; font-size: 0.8rem; }
.btn-secondary { background: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-disabled { opacity: 0.5; cursor: not-allowed !important; pointer-events: none; }

/* Inline notices */
.alert { padding: var(--s3) var(--s4); border-radius: var(--r-control); border: 1px solid var(--border); margin-bottom: var(--s4); font-size: 0.875rem; }
.alert-danger { border-color: var(--danger); background: var(--danger-tint); color: var(--text); }
.alert-warning { border-color: var(--warn); background: var(--warn-tint); color: var(--text); }
.alert-info { border-color: var(--info); background: var(--info-tint); color: var(--text); }

/* Badges: tinted pills (the old solid badges read as alarms). */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    background: var(--neutral-tint);
    color: var(--text-2);
}

.badge-success { background: var(--ok-tint); color: var(--ok); }
.badge-danger { background: var(--danger-tint); color: var(--danger); }
.badge-warning { background: var(--warn-tint); color: var(--warn); }
.badge-info { background: var(--info-tint); color: var(--info); }
.badge-muted, .badge-secondary { background: var(--neutral-tint); color: var(--text-2); }

/* Background utilities */
.bg-danger { background: var(--danger); }
.bg-warning { background: var(--warn); }
.bg-info { background: var(--info); }
.bg-success { background: var(--ok); }

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

.table th,
.table td {
    padding: 9px var(--s4);
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table th {
    font-weight: 600;
    color: var(--text-2);
    font-size: 0.75rem;
}

.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; }

/* Forms */
.form-group {
    margin-bottom: var(--s4);
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-2);
}

input, select, textarea {
    width: 100%;
    min-height: 32px;
    padding: 6px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-control);
    color: var(--text);
    font-size: 0.875rem;
    font-family: inherit;
}

textarea { min-height: 64px; }

/* Checkboxes and radios keep their own size: the width above stretched
   them across their cell, away from their labels. */
input[type="checkbox"], input[type="radio"] {
    width: auto;
    min-height: 0;
    padding: 0;
    flex: none;
    margin: 0;
    vertical-align: middle;
    accent-color: var(--accent);
    cursor: pointer;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--info-tint);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(1, 4, 9, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--s4);
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-card);
    box-shadow: var(--shadow);
    padding: var(--s5);
    width: min(640px, 100%);
    min-width: min(400px, 100%);
    max-height: 85vh;
    overflow-y: auto;
}

.modal-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: var(--s4);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--s2);
    margin-top: var(--s5);
}

/* Toast: bottom right; tinted with a coloured edge. */
.toast-container {
    position: fixed;
    bottom: var(--s4);
    right: var(--s4);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--s2);
}

.toast {
    padding: var(--s3) var(--s4);
    border-radius: var(--r-control);
    font-size: 0.875rem;
    min-width: 250px;
    max-width: 420px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-left-width: 3px;
    box-shadow: var(--shadow);
    animation: toast-in 0.2s ease;
}

.toast-info { border-left-color: var(--info); }
.toast-success { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warn); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(0.5rem); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tabs: views of one object, underlined. */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--s4);
    gap: var(--s1);
    overflow-x: auto;
}

.tabs a, .tabs button {
    padding: 8px 10px;
    border: none;
    background: none;
    color: var(--text-2);
    cursor: pointer;
    font-size: 0.875rem;
    font-family: inherit;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.12s, border-color 0.12s;
}

.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }

.tab-active {
    color: var(--text) !important;
    border-bottom-color: var(--accent) !important;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state {
    text-align: center;
    padding: var(--s7) var(--s4);
    color: var(--text-3);
}

.empty-state p { font-size: 0.9rem; }

/* Login page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--s4);
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-card);
    padding: var(--s6);
    width: 100%;
    max-width: 400px;
}

.login-title {
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: var(--s1);
    color: var(--text);
}

.login-subtitle {
    text-align: center;
    color: var(--text-3);
    font-size: 0.875rem;
    margin-bottom: var(--s5);
}

.login-error {
    background: var(--danger-tint);
    border: 1px solid var(--danger);
    color: var(--text);
    padding: var(--s2) var(--s3);
    border-radius: var(--r-control);
    font-size: 0.85rem;
    margin-bottom: var(--s4);
}

/* Utilities */
.hidden { display: none !important; }
.text-muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
/* Label/value pairs in a responsive grid. */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s4); font-size: 0.9rem; }
.kv-label { font-size: 0.75rem; color: var(--text-2); margin-bottom: 2px; }
.text-right { text-align: right; }
.mt-1 { margin-top: var(--s2); }
.mt-2 { margin-top: var(--s4); }
.mb-1 { margin-bottom: var(--s2); }
.mb-2 { margin-bottom: var(--s4); }
.flex { display: flex; }
/* Display classes for elements with x-show: Alpine drops an inline
   display when it shows an element, so a flex or grid set inline is lost
   (a modal overlay then pins its dialog to the top left). */
.grid { display: grid; }
.inline-flex { display: inline-flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: var(--s2); }
.gap-2 { gap: var(--s4); }

.page-title {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: var(--s5);
}

/* Hamburger for mobile */
.hamburger {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1001;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-control);
    color: var(--text);
    padding: 0.4rem 0.55rem;
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
}

/* Node tile grid — cluster overview */
.node-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--s4);
    margin: var(--s4) 0;
}

.node-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-card);
    padding: var(--s4);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    color: var(--text);
}

.node-tile:hover {
    background: var(--surface-hover);
}

.node-tile.node-tile-local {
    border-color: var(--border-strong);
}

.node-tile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--s2);
}

.node-tile-header strong {
    color: var(--text);
}

.node-tile .badge {
    background: var(--neutral-tint);
    color: var(--text-2);
}

.node-tile-row {
    font-size: 0.875rem;
    margin: var(--s1) 0;
    color: var(--text-2);
}

.health-healthy {
    color: var(--ok);
    font-weight: 500;
}

.health-degraded {
    color: var(--warn);
    font-weight: 500;
}

.health-failed {
    color: var(--danger);
    font-weight: 500;
}

.health-starting, .health-unknown {
    color: var(--text-3);
}

.warn {
    color: var(--warn);
    font-weight: 500;
}

.settings-section {
    margin-bottom: var(--s5);
    padding: var(--s4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-card);
}

.settings-section h2 {
    margin-top: 0;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--s3);
}

.settings-section label {
    display: block;
    margin: var(--s2) 0;
}

.settings-section input[type="text"],
.settings-section input[type="email"] {
    width: 100%;
    max-width: 400px;
    margin-top: var(--s1);
}

/* Sidebar icons, the collapsed rail and the user menu (spec 3.1). */
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-name small { font-weight: 400; font-size: 0.75rem; color: var(--text-3); margin-left: 4px; letter-spacing: 0; }
.rail-toggle { background: none; border: 0; color: var(--text-3); padding: 4px; border-radius: var(--r-control); cursor: pointer; display: inline-flex; flex: none; }
.rail-toggle:hover { background: var(--surface-hover); color: var(--text); }
.sidebar-nav a .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar.rail { width: 60px; }
.sidebar.rail .sidebar-header { flex-direction: column; padding: var(--s4) 0 var(--s2); }
.sidebar.rail .brand-name small, .sidebar.rail .lbl, .sidebar.rail .uname, .sidebar.rail .chev { display: none; }
.sidebar.rail .nav-category-name { font-size: 0; padding: 0; margin: var(--s2) var(--s2); border-top: 1px solid var(--border); }
.sidebar.rail .sidebar-nav a { justify-content: center; padding: 8px 0; }
.sidebar.rail .sidebar-footer { padding: var(--s3) 0; display: flex; justify-content: center; }
.user-btn { display: flex; align-items: center; gap: var(--s2); width: 100%; background: none; border: 0; padding: 6px; border-radius: var(--r-control); color: var(--text); cursor: pointer; font-family: inherit; font-size: 0.85rem; text-align: left; }
.user-btn:hover { background: var(--surface-hover); }
.user-btn .uname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-btn .chev { width: 14px; height: 14px; color: var(--text-3); }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border-strong); display: inline-flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 600; flex: none; }
.sidebar-footer { position: relative; }
.user-menu { position: absolute; bottom: calc(100% + 4px); left: var(--s2); right: var(--s2); min-width: 200px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-card); box-shadow: var(--shadow); padding: var(--s1); z-index: 50; }
.user-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 8px 10px; border-radius: var(--r-control); cursor: pointer; font-family: inherit; font-size: 0.875rem; }
.user-menu button:hover { background: var(--surface-hover); }
.user-menu button.danger { color: var(--danger); }
.user-menu .theme-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: 6px 10px; font-size: 0.875rem; color: var(--text-2); }
.user-menu .theme-row .seg button { width: auto; padding: 5px 8px; border-radius: 0; }
.sidebar.rail .user-menu { left: 8px; right: auto; }
.scope-bar { margin-bottom: var(--s2); }
.scope-bar .tabs { margin-bottom: var(--s4); }

/* Responsive */
@media (max-width: 768px) {
    .hamburger { display: block; }

    .sidebar {
        position: fixed;
        left: -240px;
        z-index: 1000;
        transition: left 0.2s ease;
        height: 100vh;
    }

    .sidebar.open { left: 0; box-shadow: var(--shadow); }
    /* The drawer is always full width: the rail is a desktop thing. */
    .sidebar.rail { width: 240px; }
    .sidebar.rail .lbl, .sidebar.rail .uname, .sidebar.rail .chev, .sidebar.rail .brand-name small { display: revert; }
    .sidebar.rail .sidebar-nav a { justify-content: flex-start; padding: 6px 10px; }
    .sidebar.rail .nav-category-name { font-size: 0.7rem; margin: 0; border-top: 0; padding: var(--s1) 10px; }
    .rail-toggle { display: none; }

    .content { padding: var(--s4); padding-top: 3.5rem; }
    .modal { padding: var(--s4); }
}

/* Game server page */
.mono { font-family: var(--mono); font-size: 0.93em; font-variant-numeric: tabular-nums; }
.crumbs { font-size: 0.85rem; color: var(--text-2); margin-bottom: var(--s2); display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.crumbs a { color: var(--text-2); cursor: pointer; }
.crumbs a:hover { color: var(--text); }
.crumb-here { color: var(--text); }
.server-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s4); }
.server-sub { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin-top: 6px; font-size: 0.875rem; color: var(--text-2); }
.chip { font-size: 0.75rem; height: 20px; display: inline-flex; align-items: center; padding: 0 7px; border: 1px solid var(--border-strong); border-radius: 999px; color: var(--text-2); }
.status-note { padding: var(--s3) var(--s4); border-radius: var(--r-control); border: 1px solid var(--border); margin-bottom: var(--s4); font-size: 0.875rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s4); margin-bottom: var(--s4); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: var(--s4); min-width: 0; }
.stat-label { font-size: 0.75rem; color: var(--text-2); }
.stat-value { font-size: 1.75rem; font-weight: 600; margin: var(--s1) 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat-foot { font-size: 0.75rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: var(--s4); }
.two-col > .card { margin-bottom: var(--s4); }
.chart { width: 100%; height: 160px; display: block; background: var(--surface-2); border-radius: var(--r-control); }
.chart-legend { display: flex; gap: var(--s4); font-size: 0.75rem; align-items: center; color: var(--text-2); }
.chart-legend i { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 2px; margin-right: 0.3rem; vertical-align: -1px; }
/* Drop reasons (kadDropHtml). Not "share-*": ad blockers' social filter
   lists hide those class names (the reasons vanished in Firefox with
   uBlock Origin while the text was in the page). */
.drop-reason { margin-bottom: 0.6rem; }
.drop-reason-bar { height: 4px; background: var(--surface-2); border-radius: 2px; margin-top: var(--s1); overflow: hidden; }
.drop-reason-bar > div { height: 100%; background: var(--danger); }
.check { display: inline-flex; gap: var(--s2); align-items: center; cursor: pointer; font-size: 0.875rem; margin: 0; }
/* A row of fields with their labels above them, bottom-aligned with the
   row's buttons: <div class="form-row"><label>Address <input></label>…</div>. */
.form-row { display: flex; gap: var(--s3); align-items: flex-end; flex-wrap: wrap; }
.form-row > label:not(.check) { display: flex; flex-direction: column; gap: 4px; margin: 0; font-size: 0.8rem; color: var(--text-2); }
.form-row > .check { min-height: 36px; }
.preset-row { display: flex; gap: var(--s3); align-items: center; padding: var(--s2) 0; border-bottom: 1px solid var(--border); }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
@media (max-width: 768px) { .two-col { grid-template-columns: 1fr; } }
.row-link { cursor: pointer; }
.row-link:hover td { background: var(--surface-hover); }
.server-others { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; font-size: 0.85rem; margin-bottom: var(--s4); }
.chip-link { cursor: pointer; display: inline-flex; gap: 0.35rem; align-items: center; color: var(--text); }
.chip-link:hover { border-color: var(--accent); }
.dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; display: inline-block; background: var(--text-3); flex: none; }
.dot.badge-success { background: var(--ok); }
.dot.badge-warning { background: var(--warn); }
.dot.badge-danger { background: var(--danger); }
.wizard-row { display: flex; gap: var(--s4); flex-wrap: wrap; }
.wizard-steps { display: flex; gap: 0.35rem; font-size: 0.75rem; color: var(--text-3); }
.wizard-steps span { padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); }
.wizard-steps span.on { color: var(--text); border-color: var(--accent); }
a.link, .link { color: var(--accent); cursor: pointer; }
a.link:hover { text-decoration: underline; }

/* The address firewall's "Add rule" menu and rule table */
.add-menu { position: relative; }
.add-menu-list { position: absolute; right: 0; top: calc(100% + 0.35rem); z-index: 20; width: min(22rem, 90vw); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-card); box-shadow: var(--shadow); padding: var(--s1); }
.add-menu-list button { display: block; width: 100%; text-align: left; background: none; border: 0; color: inherit; padding: var(--s2) 10px; border-radius: var(--r-control); cursor: pointer; font-family: inherit; }
.add-menu-list button:hover { background: var(--surface-hover); }
.add-menu-list b { display: block; font-size: 0.9rem; font-weight: 500; }
.add-menu-list span { display: block; font-size: 0.78rem; color: var(--text-2); margin-top: 2px; }
.fw-table td { vertical-align: top; }
.fw-table tr.fw-default td { border-top: 2px solid var(--border); }
.fw-table tr.fw-platform td, .fw-table tr.fw-threats td { opacity: 0.8; }
.fw-ports > div + div { margin-top: 2px; }

/* Sortable list columns (kadSortable): click to sort, again to reverse. */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text); }
th.sortable .sort-mark { font-size: 0.7em; opacity: 0.8; }

/* Long lists of addresses (a customer's IP blocks): denser rows. */
.table-compact .table td, .table-compact .table th, .table.table-compact td, .table.table-compact th { padding-top: 5px; padding-bottom: 5px; font-size: 0.85rem; }

/* Pagers under long lists (kadPaging). */
.pager { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; justify-content: flex-end; padding: var(--s2) var(--s4); font-size: 0.8rem; color: var(--text-2); border-top: 1px solid var(--border); }
.pager select { width: auto; min-height: 26px; padding: 2px 6px; font-size: 0.8rem; }

/* ── New primitives (spec 3.4) ───────────────────────────────────────── */

/* Status pill: tinted, a dot and a word, never wraps. */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 500; white-space: nowrap; background: var(--neutral-tint); color: var(--text-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill.plain::before { display: none; }
.pill.ok { background: var(--ok-tint); color: var(--ok); }
.pill.warn { background: var(--warn-tint); color: var(--warn); }
.pill.danger { background: var(--danger-tint); color: var(--danger); }
.pill.info { background: var(--info-tint); color: var(--info); }

/* Tag: an outline for types and facts (BYOIP, KAD tunnel, primary). */
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border: 1px solid var(--border-strong); border-radius: 4px; font-size: 0.72rem; color: var(--text-2); white-space: nowrap; }

/* Banner: one line and one action, under a page header. */
.banner { display: flex; align-items: center; gap: var(--s3); padding: 10px var(--s4); border-radius: var(--r-card); border: 1px solid var(--border); background: var(--surface); margin-bottom: var(--s4); font-size: 0.875rem; flex-wrap: wrap; }
.banner > .grow { flex: 1; min-width: 12rem; }
.banner.ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-tint); }
.banner.warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-tint); }
.banner.danger { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-tint); }
.banner.info { border-color: color-mix(in srgb, var(--info) 40%, transparent); background: var(--info-tint); }

/* Segmented control: filters within a list. */
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r-control); overflow: hidden; }
.seg button, .seg a { font-family: inherit; font-size: 0.8rem; font-weight: 500; line-height: 1; background: none; color: var(--text-2); border: 0; padding: 7px 10px; cursor: pointer; white-space: nowrap; }
.seg > * + * { border-left: 1px solid var(--border-strong) !important; }
.seg .on, .seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.seg button:disabled { color: var(--text-3); cursor: not-allowed; opacity: 0.6; }

/* Needs-attention list (dashboards): dot, title, one meta line, action. */
.att { display: flex; flex-direction: column; }
.att-row { display: flex; align-items: center; gap: var(--s3); padding: 10px var(--s4); border-bottom: 1px solid var(--border); }
.att-row:last-child { border-bottom: 0; }
.att-row .grow { flex: 1; min-width: 0; }
.att-row .t { font-weight: 500; }
.att-row .s { font-size: 0.8rem; color: var(--text-2); }

/* Row actions: a ghost "⋯" at the end of a row. */
.rowact { width: 1%; white-space: nowrap; text-align: right; }

/* Label/value list. */
.kvl { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--s4); font-size: 0.875rem; }
.kvl > dt { color: var(--text-2); }
.kvl > dd { color: var(--text); min-width: 0; overflow-wrap: anywhere; }

/* Secondary detail folded away at a card's foot. */
details.more { margin-top: var(--s3); border-top: 1px solid var(--border); padding-top: var(--s2); }
details.more > summary { cursor: pointer; color: var(--text-2); font-size: 0.85rem; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸ "; }
details.more[open] > summary::before { content: "▾ "; }

/* Info tooltip: an ⓘ button after a title or label (kadTip). Opens on
   hover, focus and tap; the text is in a role="tooltip" element. */
.info { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 4px; padding: 0; border: 1px solid var(--border-strong); border-radius: 50%; background: none; color: var(--text-3); font-family: inherit; font-size: 10px; font-weight: 600; line-height: 1; cursor: help; vertical-align: 1px; position: relative; }
.info:hover, .info:focus-visible, .info[aria-expanded="true"] { color: var(--text); border-color: var(--text-2); }
.tip { position: absolute; z-index: 3000; max-width: 320px; padding: var(--s2) 10px; border-radius: var(--r-control); background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text); font-size: 0.8rem; font-weight: 400; line-height: 1.45; box-shadow: var(--shadow); pointer-events: none; text-align: left; }

/* Switch: the position is the state; no "on"/"off" word beside it. */
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; font-size: 0.875rem; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 32px; height: 18px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background 0.15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .track { background: var(--accent-strong); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .track { opacity: 0.5; }

/* Phone: table rows stack (first cell grows, secondary columns hidden). */
@media (max-width: 640px) {
    .hide-sm { display: none !important; }
    .stack-sm tr { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s3); padding: 10px var(--s4); border-bottom: 1px solid var(--border); }
    .stack-sm td { border: 0; padding: 0; }
    .stack-sm td:first-child { flex: 1 1 100%; }
    .stack-sm thead { display: none; }
}

/* The interactive chart (kadLineChart, shared/customer-pages/chart.js). */
.kchart { min-width: 0; }
.kchart-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s2); }
.kchart .legend { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 0.8rem; }
.kchart .key-wrap { display: inline-flex; align-items: center; }
.kchart .key { display: inline-flex; align-items: center; gap: 6px; font-family: inherit; font-size: 0.78rem; font-weight: 500; background: none; border: 1px solid var(--border-strong); border-radius: 999px; height: 24px; padding: 0 10px; color: var(--text-2); cursor: pointer; }
.kchart .key:not(.on) { opacity: 0.45; text-decoration: line-through; }
.kchart .key i, .kchart-tip .tip-row i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.kchart .plot { position: relative; outline: none; border-radius: var(--r-control); touch-action: pan-y; cursor: crosshair; min-height: 120px; }
.kchart .plot:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.kchart .plot svg { display: block; }
.kchart-empty { color: var(--text-3); font-size: 0.85rem; padding: var(--s5) 0; text-align: center; }
.kchart-tip { position: absolute; top: 8px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-control); padding: 6px 10px; font-size: 0.78rem; pointer-events: none; box-shadow: var(--shadow); min-width: 160px; z-index: 5; }
.kchart-tip .tip-time { font-family: var(--mono); color: var(--text-2); margin-bottom: 4px; }
.kchart-tip .tip-row { display: flex; align-items: center; gap: 6px; }
.kchart-tip .tip-row b { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; padding-left: 12px; }
.kchart-foot { font-size: 0.72rem; color: var(--text-3); margin-top: 4px; text-align: right; }

/* Page header (spec 3.2): title and a one-line summary on the left, at
   most two actions on the right. */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.page-head .page-title { margin-bottom: 0; }
.page-sub { color: var(--text-2); font-size: 0.875rem; margin-top: 4px; }
.page-head .actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
/* A card's header row with a meta line or link on the right. */
.card-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); padding: var(--s4) var(--s4) var(--s2); }
.card-head .meta, .meta { font-size: 0.8rem; color: var(--text-3); }
a.meta { color: var(--accent); }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: var(--s4); }
.grid-2-1 > .card { margin-bottom: var(--s4); }
@media (max-width: 900px) { .grid-2-1 { grid-template-columns: 1fr; } }
.section-title { font-size: 1rem; font-weight: 600; margin: var(--s5) 0 var(--s3); color: var(--text); }
.grid-1-1 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); align-items: start; }
.grid-1-1 > .card, .grid-1-1 > div > .card { margin-bottom: var(--s4); }
@media (max-width: 900px) { .grid-1-1 { grid-template-columns: 1fr; } }
/* The "⋯" menu of a header or row. */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 4px); min-width: 240px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-card); box-shadow: var(--shadow); padding: var(--s1); z-index: 60; }
.dropdown-menu button, .dropdown-menu a { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 8px 10px; border-radius: var(--r-control); cursor: pointer; font-family: inherit; font-size: 0.875rem; text-decoration: none; }
.dropdown-menu button:hover:not(:disabled), .dropdown-menu a:hover { background: var(--surface-hover); }
.dropdown-menu button:disabled { opacity: 0.5; cursor: not-allowed; }
.dropdown-menu button span, .dropdown-menu a span { display: block; font-size: 0.75rem; color: var(--text-3); margin-top: 1px; }
.dropdown-menu .danger { color: var(--danger); }
/* A row menu (kadRowMenu): placed by script, so a clipping table can't hide it. */
.dropdown-menu.fixed { position: fixed; top: auto; right: auto; min-width: 180px; }
details.card.more { padding: var(--s4); }

