/* ================================================================
   AvalynnAI Platform — Design System
   A single source of truth for all platform page styling.
   ================================================================ */

/* ── Variables ───────────────────────────────────────────────── */
:root {
    --primary: #7c3aed;
    --primary-light: #a855f7;
    --primary-dark: #6d28d9;
    --primary-faint: rgba(124,58,237,0.12);

    --bg: #020208;
    --surface: #0a0a14;
    --surface-2: #12121e;

    --text: #e2e2e8;
    --text-2: #a0a0b0;
    --text-3: rgba(255,255,255,0.45);
    --text-4: rgba(255,255,255,0.25);

    --border: rgba(255,255,255,0.06);
    --border-hover: rgba(124,58,237,0.22);
    --border-focus: rgba(124,58,237,0.45);

    --green: #10b981;
    --green-light: #34d399;
    --yellow: #f59e0b;
    --yellow-light: #fbbf24;
    --red: #ef4444;
    --red-light: #f87171;
    --blue: #3b82f6;
    --blue-light: #60a5fa;
    --purple-light: #c4b5fd;

    --radius: 12px;
    --radius-lg: 16px;
    --radius-pill: 9999px;

    --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;

    --topbar-h: 56px;
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; color-scheme: dark; }

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0 1.5rem;
    height: var(--topbar-h);
    background: rgba(10,10,20,0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.topbar-brand {
    font-size: 1.125rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.025em;
    flex-shrink: 0;
    white-space: nowrap;
}

.topbar-hamburger {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    flex-shrink: 0;
    margin-left: auto;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.topbar-hamburger:active { background: rgba(255,255,255,0.06); }

.topbar-hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-2);
    border-radius: 2px;
    transition: transform 0.25s, opacity 0.25s;
}

.topbar-collapse { display: contents; }

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    flex: 1;
    min-width: 0;
}

.topbar-nav a {
    color: var(--text-3);
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.375rem 0.625rem;
    border-radius: 8px;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.topbar-nav a:hover {
    color: var(--text);
    background: rgba(255,255,255,0.04);
}

.topbar-nav a.active {
    color: #fff;
    background: var(--primary-faint);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    flex-shrink: 0;
}

.topbar-user .avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.7rem;
    color: #fff;
    background: var(--primary);
    flex-shrink: 0;
}

.topbar-username {
    font-size: 0.8125rem;
    color: var(--text-2);
    font-weight: 500;
}

.topbar-logout {
    font-size: 0.75rem;
    color: var(--text-4) !important;
    transition: color 0.15s;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

.topbar-logout:hover {
    color: var(--text-2) !important;
    background: rgba(255,255,255,0.04);
}

/* ── Container ───────────────────────────────────────────────── */
.container       { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem 3rem; }
.container-wide  { max-width: 1200px; }
.container-narrow{ max-width: 960px;  }

/* ── Page Header ─────────────────────────────────────────────── */
.page-header { margin-bottom: 2rem; }

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 0.35rem;
    line-height: 1.2;
}

.page-header p {
    color: var(--text-3);
    font-size: 0.9rem;
    line-height: 1.55;
    max-width: 56ch;
}

.page-header .hint {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-4);
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: border-color 0.2s;
}

.card-hover:hover { border-color: var(--border-hover); }

.card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card p.dim {
    color: var(--text-3);
    font-size: 0.85rem;
    line-height: 1.5;
}

.card-value {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0.5rem 0;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    border: none;
    font-family: inherit;
    line-height: 1.4;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
}

.btn-primary:hover {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(124,58,237,0.3);
}

.btn-outline {
    background: transparent;
    color: var(--primary-light);
    border: 1px solid rgba(168,85,247,0.3);
}

.btn-outline:hover {
    background: rgba(168,85,247,0.08);
    border-color: rgba(168,85,247,0.45);
}

.btn-ghost {
    background: rgba(255,255,255,0.04);
    color: var(--text-2);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 8px;
}

.btn-xs {
    padding: 0.25rem 0.6rem;
    font-size: 0.72rem;
    border-radius: 6px;
}

.btn-block { width: 100%; }

.btn:disabled, .btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-danger {
    background: rgba(239,68,68,0.12);
    color: var(--red-light);
    border: 1px solid rgba(239,68,68,0.2);
}

.btn-danger:hover { background: rgba(239,68,68,0.2); border-color: rgba(239,68,68,0.35); }

.btn-approve { background: rgba(16,185,129,0.15); color: var(--green); border: none; cursor: pointer; font-family: inherit; }
.btn-approve:hover { background: rgba(16,185,129,0.25); }
.btn-deny { background: rgba(239,68,68,0.15); color: var(--red); border: none; cursor: pointer; font-family: inherit; }
.btn-deny:hover { background: rgba(239,68,68,0.25); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success, .badge-green   { background: rgba(16,185,129,0.12);  color: var(--green-light);  }
.badge-warning, .badge-yellow  { background: rgba(245,158,11,0.12);  color: var(--yellow-light); }
.badge-danger,  .badge-red     { background: rgba(239,68,68,0.12);   color: var(--red-light);    }
.badge-info,    .badge-blue    { background: rgba(59,130,246,0.12);   color: var(--blue-light);   }
.badge-muted,   .badge-gray    { background: rgba(255,255,255,0.06);  color: var(--text-3);       }
.badge-purple                  { background: var(--primary-faint);    color: var(--purple-light); }

.badge-lg {
    padding: 0.3rem 0.75rem;
    font-size: 0.78rem;
}

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: var(--surface-2);
    color: var(--text-3);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

td {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}

tr:hover td { background: rgba(124,58,237,0.025); }

.num { font-variant-numeric: tabular-nums; text-align: right; }
.mono { font-family: var(--mono); font-size: 0.78rem; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

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

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-4);
    font-size: 0.75rem;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}

textarea { resize: vertical; min-height: 100px; }

/* ── Tabs ─────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    padding: 0.3rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tabs a,
.tabs button {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-3);
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.tabs a:hover, .tabs button:hover {
    color: var(--text-2);
    background: rgba(255,255,255,0.03);
}

.tabs a.active, .tabs button.active {
    color: var(--primary-light);
    background: var(--primary-faint);
}

.panel { display: none; animation: anim-in 0.2s ease; }
.panel.active { display: block; }
@keyframes anim-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    margin-bottom: 1.25rem;
    border: 1px solid transparent;
    line-height: 1.5;
}

.alert a { color: inherit; font-weight: 600; text-decoration: underline; }

.alert-success { background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.2); color: #6ee7b7; }
.alert-warning { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.2); color: #fde68a; }
.alert-danger, .alert-error { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.2); color: #fca5a5; }
.alert-info { background: rgba(124,58,237,0.08); border-color: rgba(124,58,237,0.2); color: #ddd6fe; }

/* ── Flash (JS-driven) ───────────────────────────────────────── */
.flash {
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    background: var(--primary-faint);
    border: 1px solid rgba(124,58,237,0.25);
    color: #ddd6fe;
    font-size: 0.8125rem;
    display: none;
}

.flash.show { display: block; animation: anim-in 0.25s ease; }

/* ── Stats Grid ──────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem;
}

.stat-card .label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-3);
    margin-bottom: 0.35rem;
}

.stat-card .value {
    font-size: 1.35rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Grid Helpers ─────────────────────────────────────────────── */
.grid     { display: grid; gap: 1.25rem; }
.grid-2   { grid-template-columns: repeat(2, 1fr); }
.grid-3   { grid-template-columns: repeat(3, 1fr); }
.grid-auto{ grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-auto-sm { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

/* ── Section Title ───────────────────────────────────────────── */
.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, rgba(168,85,247,0.2), transparent);
}

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-3);
    font-size: 0.875rem;
}

.empty-state-card {
    background: var(--surface);
    border: 1px dashed rgba(255,255,255,0.08);
    border-radius: var(--radius-lg);
    max-width: 480px;
    margin: 0 auto;
    padding: 3rem 2rem;
    text-align: center;
}

.empty-state h2, .empty-state-card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.empty-state p, .empty-state-card p {
    color: var(--text-3);
    font-size: 0.875rem;
    line-height: 1.55;
    margin-bottom: 1.25rem;
}

/* ── Code / Pre ──────────────────────────────────────────────── */
code { font-family: var(--mono); font-size: 0.8rem; }

code.hl {
    background: rgba(255,255,255,0.05);
    padding: 0.12rem 0.4rem;
    border-radius: 5px;
    border: 1px solid var(--border);
    font-size: 0.78rem;
}

pre {
    background: var(--surface-2);
    color: var(--purple-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-family: var(--mono);
    font-size: 0.78rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-all;
}

pre code { color: inherit; background: transparent; padding: 0; font-size: inherit; }

/* ── Status Pages (pending / denied / request-access) ────────── */
.status-page {
    min-height: calc(100vh - var(--topbar-h));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.status-card {
    max-width: 480px;
    width: 100%;
    text-align: center;
}

.status-card h1 { font-size: 1.35rem; font-weight: 700; margin-bottom: 0.75rem; }
.status-card p  { color: var(--text-3); font-size: 0.9rem; line-height: 1.6; margin-bottom: 1rem; }

.status-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.status-icon svg { width: 36px; height: 36px; }
.status-icon-warning { background: rgba(245,158,11,0.1); color: var(--yellow); }
.status-icon-danger  { background: rgba(239,68,68,0.1);   color: var(--red);    }
.status-icon-success { background: rgba(16,185,129,0.1);  color: var(--green);  }

/* ── Utilities ───────────────────────────────────────────────── */
.text-muted  { color: var(--text-3) !important; }
.text-purple { color: var(--primary-light) !important; }
.text-sm     { font-size: 0.8125rem; }
.text-xs     { font-size: 0.75rem; }
.text-center { text-align: center; }
.sr-only     { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.flex        { display: flex; }
.flex-wrap   { flex-wrap: wrap; }
.items-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: 0.35rem; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 0.75rem; }
.gap-lg { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

/* ================================================================
   Page-Specific Component Styles
   ================================================================ */

/* ── Dashboard: welcome + access banners ─────────────────────── */
.welcome { margin-bottom: 2rem; }
.welcome h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.welcome p  { color: var(--text-3); font-size: 0.9rem; }

.access-banner {
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    text-align: center;
}

.access-banner.pending {
    background: rgba(245,158,11,0.06);
    border: 1px solid rgba(245,158,11,0.15);
}

.access-banner.none {
    background: rgba(124,58,237,0.06);
    border: 1px solid rgba(124,58,237,0.15);
}

.access-banner h2 { font-size: 1.15rem; margin-bottom: 0.5rem; }
.access-banner p  { color: var(--text-3); font-size: 0.85rem; margin-bottom: 1rem; }

/* ── Dashboard: server list ──────────────────────────────────── */
.server-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    background: var(--surface-2);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.server-item .name { font-weight: 600; font-size: 0.9rem; }
.server-item .meta { color: var(--text-3); font-size: 0.8rem; }

/* ── Plans: plan cards ───────────────────────────────────────── */
.plan-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.plan-card:hover { border-color: var(--border-hover); }

.plan-card.current {
    border-color: rgba(124,58,237,0.4);
    box-shadow: 0 0 0 1px rgba(124,58,237,0.15), 0 8px 32px rgba(0,0,0,0.3);
}

.current-pill, .pending-pill {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    background: rgba(124,58,237,0.25);
    color: var(--purple-light);
    border: 1px solid rgba(168,85,247,0.3);
}
.pending-pill {
    background: rgba(245,158,11,0.15);
    color: #fbbf24;
    border-color: rgba(245,158,11,0.3);
}
.plan-card.pending {
    border-color: rgba(245,158,11,0.3);
    box-shadow: 0 0 0 1px rgba(245,158,11,0.1), 0 8px 32px rgba(0,0,0,0.3);
}

.plan-card h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.5rem; }

.plan-card .desc {
    color: var(--text-3);
    font-size: 0.82rem;
    line-height: 1.55;
    margin-bottom: 1.25rem;
    flex: 1;
}

.specs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    margin-bottom: 1.25rem;
}

.spec {
    background: var(--surface-2);
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
}

.spec .label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
    margin-bottom: 0.2rem;
}

.spec .value { font-size: 0.88rem; font-weight: 600; color: var(--text); }

.price-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--border);
}

.price-row .amount {
    font-size: 1.85rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.price-row .amount-original {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-4);
    text-decoration: line-through;
    margin-right: 0.5rem;
}

.price-row .amount-discounted {
    font-size: 1.85rem;
    background: linear-gradient(135deg, var(--green), var(--green-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.discount-pill {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    background: rgba(16,185,129,0.15);
    color: var(--green-light);
    border: 1px solid rgba(16,185,129,0.25);
}

.price-row .period { font-size: 0.8rem; color: var(--text-3); font-weight: 500; }

/* ── Volume Pricing ──────────────────────────────────────────── */
.volume-tier-banner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.volume-tier-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.volume-tier-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.volume-tier-badge.tier-starter {
    background: rgba(255,255,255,0.06);
    color: var(--text-2);
    border: 1px solid var(--border);
}

.volume-tier-badge.tier-growth {
    background: rgba(59,130,246,0.12);
    color: var(--blue-light);
    border: 1px solid rgba(59,130,246,0.25);
}

.volume-tier-badge.tier-scale {
    background: rgba(16,185,129,0.12);
    color: var(--green-light);
    border: 1px solid rgba(16,185,129,0.25);
}

.volume-tier-count {
    font-size: 0.82rem;
    color: var(--text-3);
    font-weight: 500;
}

.volume-tier-msg {
    font-size: 0.82rem;
    color: var(--text-2);
}

.volume-tier-msg strong {
    color: var(--green-light);
}

.volume-tier-steps {
    display: flex;
    gap: 0.5rem;
}

.volume-step {
    padding: 0.5rem 0.85rem;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    text-align: center;
    min-width: 90px;
    transition: border-color 0.2s, background 0.2s;
}

.volume-step.active {
    border-color: rgba(124,58,237,0.35);
    background: var(--primary-faint);
}

.volume-step-pct {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.15rem;
}

.volume-step.active .volume-step-pct {
    color: var(--primary-light);
}

.volume-step-range {
    font-size: 0.68rem;
    color: var(--text-4);
}

/* ── Volume Pricing Table ────────────────────────────────────── */
.volume-pricing-table {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-top: 2rem;
}

.volume-pricing-table h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.volume-pricing-table .dim {
    color: var(--text-3);
    font-size: 0.82rem;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.volume-pricing-table table {
    width: 100%;
    border-collapse: collapse;
}

.volume-pricing-table th {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-3);
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.volume-pricing-table td {
    padding: 0.75rem 0.75rem;
    font-size: 0.82rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.volume-pricing-table tbody tr:last-child td {
    border-bottom: none;
}

.volume-pricing-table tr.row-active {
    background: var(--primary-faint);
}

.volume-pricing-table tr.row-active td {
    border-color: rgba(124,58,237,0.15);
}

.price-struck {
    text-decoration: line-through;
    color: var(--text-4);
    font-size: 0.78rem;
    margin-right: 0.35rem;
}

/* ── Checkout Discount Banner ────────────────────────────────── */
.checkout-discount-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    border-radius: 10px;
    background: rgba(16,185,129,0.08);
    border: 1px solid rgba(16,185,129,0.2);
    font-size: 0.8rem;
    color: var(--green-light);
    margin-bottom: 1rem;
}

.checkout-discount-pct {
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    background: rgba(16,185,129,0.15);
    font-size: 0.75rem;
}

.checkout-price-original {
    font-size: 0.85rem;
    color: var(--text-4);
    text-decoration: line-through;
    line-height: 1;
}

.status-badge-full {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    padding: 0.7rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(16,185,129,0.1);
    color: var(--green-light);
    border: 1px solid rgba(16,185,129,0.2);
}
.status-badge-full.pending {
    background: rgba(245,158,11,0.1);
    color: #fbbf24;
    border-color: rgba(245,158,11,0.2);
}

/* ── Tokens: balance hero ─────────────────────────────────────── */
.balance-hero {
    text-align: center;
    padding: 2rem 1rem 1.5rem;
    background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(124,58,237,0.1), transparent);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: 1.25rem;
}

.balance-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin-bottom: 0.5rem;
}

.balance-value {
    font-size: 2.75rem;
    font-weight: 700;
    line-height: 1.1;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.buy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.btn-buy {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid rgba(168,85,247,0.25);
    background: rgba(124,58,237,0.06);
    color: #e9d5ff;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.btn-buy:hover {
    background: rgba(124,58,237,0.15);
    border-color: rgba(168,85,247,0.4);
    transform: translateY(-1px);
}

.custom-buy {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    padding: 1.25rem;
    background: var(--surface-2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.custom-buy label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-3);
    font-weight: 500;
}

.custom-buy input[type="number"] {
    width: min(200px, 100%);
    min-width: 140px;
}

/* ── Servers: server cards ───────────────────────────────────── */
.server-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    transition: border-color 0.2s;
}

.server-card:hover { border-color: var(--border-hover); }

.server-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.server-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #f4f4f8;
    line-height: 1.3;
    word-break: break-word;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: capitalize;
    white-space: nowrap;
    flex-shrink: 0;
}

.status-active  { background: rgba(16,185,129,0.15);  color: var(--green-light); }
.status-warn    { background: rgba(245,158,11,0.15);  color: var(--yellow-light); }
.status-danger  { background: rgba(239,68,68,0.15);   color: var(--red-light); }
.status-neutral { background: rgba(255,255,255,0.06);  color: var(--text-3); }

.server-url a {
    color: var(--primary-light);
    font-weight: 500;
    font-size: 0.85rem;
    word-break: break-all;
}

.server-url a:hover { text-decoration: underline; color: #c084fc; }
.server-url.muted   { color: var(--text-4); font-size: 0.8rem; }

.server-meta { display: grid; gap: 0.5rem; font-size: 0.82rem; }

.meta-row {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    flex-wrap: wrap;
}

.meta-label { color: var(--text-3); font-weight: 500; min-width: 4rem; }
.meta-value { color: rgba(255,255,255,0.78); }
.meta-value.mono { font-family: var(--mono); font-size: 0.8rem; }

.plan-line {
    color: var(--text-3);
    font-size: 0.8rem;
    line-height: 1.45;
}

.plan-line .sep { color: var(--text-4); margin: 0 0.35rem; }

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.25rem;
}

.summary-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    background: var(--primary-faint);
    border: 1px solid rgba(168,85,247,0.2);
}

.summary-pill strong { color: var(--primary-light); font-weight: 700; }

/* ── Download: cards ─────────────────────────────────────────── */
.download-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.dl-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.dl-card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 8px 28px rgba(0,0,0,0.25);
}

.dl-card .icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-light);
}

.dl-card .icon-wrap svg { width: 24px; height: 24px; display: block; }
.dl-card .title { font-weight: 600; font-size: 0.95rem; color: var(--text); }
.dl-card .arch  { font-size: 0.78rem; color: var(--text-3); }

.dl-card .actions {
    width: 100%;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-dl {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 100%;
    padding: 0.55rem 0.9rem;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    transition: opacity 0.15s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.btn-dl:hover { opacity: 0.92; }
.btn-dl:active { transform: scale(0.98); }

.badge-coming {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: rgba(168,85,247,0.12);
    color: var(--purple-light);
    border: 1px solid rgba(168,85,247,0.28);
}

.badge-live {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: rgba(34,197,94,0.12);
    color: #4ade80;
    border: 1px solid rgba(34,197,94,0.28);
}

/* ── Download: command blocks ─────────────────────────────────── */
.cmd-block { margin-bottom: 1rem; }
.cmd-block:last-child { margin-bottom: 0; }

.cmd-line {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.cmd-line .label {
    flex-shrink: 0;
    min-width: 7.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: rgba(196,181,253,0.55);
    padding-top: 0.15rem;
}

.cmd-line code {
    display: block;
    background: var(--surface-2);
    color: var(--purple-light);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    flex: 1;
    font-size: 0.78rem;
}

.cmd-desc {
    font-size: 0.78rem;
    color: var(--text-4);
    line-height: 1.45;
    margin: 0 0 0 8.25rem;
}

/* ── Download: changelog ──────────────────────────────────────── */
.cl-release {
    position: relative;
    padding-left: 1.35rem;
    margin-bottom: 1.75rem;
    border-left: 2px solid rgba(124,58,237,0.35);
}

.cl-release:last-child { margin-bottom: 0; }

.cl-release::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 0.35rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.2);
}

.cl-meta { display: flex; align-items: baseline; gap: 0.65rem; flex-wrap: wrap; margin-bottom: 0.45rem; }
.cl-version { font-size: 0.95rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.cl-date { font-size: 0.72rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.cl-title { font-size: 0.84rem; font-weight: 600; color: var(--purple-light); margin-bottom: 0.65rem; }
.cl-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.cl-item { display: flex; gap: 0.55rem; align-items: flex-start; font-size: 0.8rem; line-height: 1.5; color: var(--text-3); }
.cl-tag {
    flex-shrink: 0;
    margin-top: 0.12rem;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.12rem 0.4rem;
    border-radius: 5px;
}
.cl-tag-feature     { background: rgba(34,197,94,0.12); color: #4ade80; border: 1px solid rgba(34,197,94,0.28); }
.cl-tag-fix         { background: rgba(248,113,113,0.12); color: #fca5a5; border: 1px solid rgba(248,113,113,0.25); }
.cl-tag-improvement { background: rgba(96,165,250,0.12); color: #93c5fd; border: 1px solid rgba(96,165,250,0.28); }

/* ── Clients: keys & nodes ────────────────────────────────────── */
.key-mono {
    font-family: var(--mono);
    font-size: 0.82rem;
    color: var(--purple-light);
    word-break: break-all;
    line-height: 1.4;
}

.node-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.node-online  { background: rgba(16,185,129,0.15); color: var(--green-light); }
.node-offline { background: rgba(255,255,255,0.06); color: var(--text-3); }

.toolbar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    align-items: center;
}

/* ── Stripe Admin Dashboard ───────────────────────────────────── */
.stripe-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1rem;
}

.stripe-product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: border-color 0.2s;
}

.stripe-product-card:hover { border-color: var(--border-hover); }
.stripe-product-card.inactive { opacity: 0.55; }

.stripe-product-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.stripe-product-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.stripe-product-id {
    font-size: 0.68rem;
    color: var(--text-4);
    margin-top: 0.15rem;
    word-break: break-all;
}

.stripe-product-desc {
    font-size: 0.78rem;
    color: var(--text-3);
    line-height: 1.5;
}

.stripe-product-prices {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.stripe-price-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.65rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.8rem;
}

.stripe-price-amount {
    font-weight: 700;
    color: var(--primary-light);
    min-width: 60px;
}

.stripe-price-label {
    flex: 1;
    color: var(--text-3);
    font-size: 0.75rem;
}

.stripe-product-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 0.35rem;
    border-top: 1px solid var(--border);
}

.stripe-detail-grid {
    display: grid;
    gap: 0.65rem;
}

.stripe-detail {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.82rem;
}

.stripe-detail-label {
    color: var(--text-3);
    font-weight: 500;
    min-width: 120px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .stripe-products-grid { grid-template-columns: 1fr; }
}

/* ── Admin: audit log ─────────────────────────────────────────── */
.audit-item {
    display: flex;
    gap: 1rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
}

.audit-item:last-child { border-bottom: none; }
.audit-time   { color: var(--text-4); white-space: nowrap; min-width: 140px; }
.audit-user   { color: var(--primary-light); min-width: 100px; }
.audit-action { color: var(--text-3); }

/* ── Settings ────────────────────────────────────────────────── */
.settings-field { margin-bottom: 0.75rem; }

.settings-field > label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 0.4rem;
}

.field-hint {
    font-size: 0.78rem;
    color: var(--text-4);
    line-height: 1.5;
}

.input-with-action {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.secret-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.secret-input-wrap input {
    width: 100%;
    padding-right: 2.75rem;
    font-family: var(--mono);
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}

.secret-toggle {
    position: absolute;
    right: 0.5rem;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--text-3);
    transition: color 0.15s, background 0.15s;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}

.secret-toggle:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.secret-toggle svg { width: 18px; height: 18px; }

.key-status { display: flex; align-items: center; gap: 0.5rem; }

/* ── Toggle Group (cluster / local) ─────────────────────────── */
.toggle-group {
    display: inline-flex;
    gap: 0.25rem;
    padding: 0.3rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.toggle-option {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-3);
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.toggle-option:hover { color: var(--text-2); background: rgba(255,255,255,0.03); }

.toggle-option.active {
    color: var(--primary-light);
    background: var(--primary-faint);
    font-weight: 600;
}

.toggle-icon { display: flex; align-items: center; }
.toggle-icon svg { width: 16px; height: 16px; }

.settings-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 0.5rem;
}

/* ── How It Works Grid ──────────────────────────────────────── */
.how-it-works-grid {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.hiw-item {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.hiw-num {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-faint);
    color: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    border: 1px solid rgba(168,85,247,0.2);
}

.hiw-item strong {
    font-size: 0.875rem;
    display: block;
    margin-bottom: 0.25rem;
}

.hiw-item .dim {
    font-size: 0.8rem;
    line-height: 1.5;
}

/* ── Flash error variant ─────────────────────────────────────── */
.flash.flash-error {
    background: rgba(239,68,68,0.08);
    border-color: rgba(239,68,68,0.2);
    color: #fca5a5;
}

/* ── Checkout Modal ──────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal-backdrop.open {
    display: flex;
    opacity: 1;
}

.modal-backdrop.opening { opacity: 0; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    box-shadow: 0 32px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(124,58,237,0.08);
    animation: modal-in 0.25s ease;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(255,255,255,0.04);
    color: var(--text-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.modal-close:hover { background: rgba(255,255,255,0.08); color: var(--text); }

.modal-body { padding: 1.5rem; }

.checkout-plan-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.checkout-plan-name {
    font-size: 1rem;
    font-weight: 700;
}

.checkout-plan-specs {
    font-size: 0.78rem;
    color: var(--text-3);
    margin-top: 0.2rem;
}

.checkout-plan-price {
    text-align: right;
    flex-shrink: 0;
}

.checkout-plan-price .amount {
    font-size: 1.35rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.checkout-plan-price .period {
    font-size: 0.72rem;
    color: var(--text-3);
    display: block;
    text-align: right;
}

.checkout-section {
    margin-bottom: 1.25rem;
}

.checkout-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin-bottom: 0.75rem;
}

.checkout-card-fields {
    display: grid;
    gap: 0.75rem;
}

.checkout-card-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.checkout-field {
    position: relative;
}

.checkout-field label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-3);
    margin-bottom: 0.3rem;
    font-weight: 500;
}

.checkout-field input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    background: var(--surface-2);
    color: var(--text-4);
    font-size: 0.875rem;
    font-family: var(--mono);
    cursor: not-allowed;
}

.checkout-field input::placeholder { color: var(--text-4); }

.checkout-coming-soon {
    position: relative;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    background: rgba(245,158,11,0.06);
    border: 1px solid rgba(245,158,11,0.15);
    text-align: center;
    margin-bottom: 1.25rem;
}

.checkout-coming-soon .icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: block;
}

.checkout-coming-soon h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--yellow-light);
    margin-bottom: 0.35rem;
}

.checkout-coming-soon p {
    font-size: 0.8rem;
    color: var(--text-3);
    line-height: 1.5;
}

.modal-footer {
    padding: 1rem 1.5rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.modal-footer .btn { min-width: 100px; }

/* ================================================================
   Mobile Responsive
   ================================================================ */
@media (max-width: 768px) {
    :root { --topbar-h: auto; }

    .topbar {
        flex-wrap: wrap;
        height: auto;
        padding: 0.75rem 1rem;
        gap: 0;
    }

    .topbar-brand { order: 1; }

    .topbar-hamburger {
        display: flex;
        order: 2;
    }

    .topbar-collapse {
        display: none;
        width: 100%;
        order: 3;
        padding-top: 0.75rem;
        margin-top: 0.75rem;
        border-top: 1px solid var(--border);
    }

    .topbar-collapse.open {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        animation: anim-in 0.2s ease;
    }

    .topbar-nav {
        flex-direction: column;
        gap: 0.125rem;
    }

    .topbar-nav a {
        padding: 0.6rem 0.75rem;
        border-radius: 10px;
        font-size: 0.875rem;
    }

    .topbar-user {
        padding-top: 0.625rem;
        margin-top: 0.375rem;
        border-top: 1px solid var(--border);
        margin-left: 0;
        width: 100%;
    }

    .topbar-hamburger.active span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
    .topbar-hamburger.active span:nth-child(2) { opacity: 0; }
    .topbar-hamburger.active span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

    .container { padding: 1.25rem 1rem 2.5rem; }

    .page-header h1 { font-size: 1.25rem; }
    .page-header p   { font-size: 0.85rem; }

    .grid-2, .grid-3 { grid-template-columns: 1fr; }

    .card { padding: 1.25rem; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    th, td { padding: 0.6rem 0.75rem; font-size: 0.78rem; }

    .btn { padding: 0.7rem 1.25rem; font-size: 0.875rem; }

    .tabs {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }

    .cmd-line { flex-direction: column; align-items: stretch; gap: 0.35rem; }
    .cmd-line .label { min-width: auto; }
    .cmd-desc { margin-left: 0; margin-top: 0.15rem; }

    .server-item { flex-direction: column; align-items: flex-start; gap: 0.75rem; }

    .balance-value { font-size: 2.25rem; }

    .audit-item { flex-direction: column; gap: 0.25rem; }
    .audit-time { min-width: auto; }
    .audit-user { min-width: auto; }

    .modal { max-width: 100%; border-radius: var(--radius) var(--radius) 0 0; }
    .modal-backdrop { align-items: flex-end; padding: 0; }
    .modal-body { padding: 1.25rem; }
    .modal-header { padding: 1rem 1.25rem; }
    .modal-footer { padding: 0.85rem 1.25rem; flex-direction: column; }
    .modal-footer .btn { width: 100%; }

    .checkout-plan-summary { flex-direction: column; gap: 0.5rem; }
    .checkout-plan-price { text-align: left; }
    .checkout-card-row { grid-template-columns: 1fr; }

    .volume-tier-banner { flex-direction: column; gap: 1rem; }
    .volume-tier-steps { width: 100%; }
    .volume-step { flex: 1; min-width: 0; padding: 0.45rem 0.5rem; }
    .volume-step-pct { font-size: 0.72rem; }
    .volume-step-range { font-size: 0.65rem; }

    .volume-pricing-table { padding: 1.25rem; overflow-x: auto; }
    .volume-pricing-table .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    .toggle-group { display: flex; width: 100%; }
    .toggle-option { flex: 1; justify-content: center; font-size: 0.78rem; padding: 0.55rem 0.65rem; }
    .settings-actions { flex-direction: column; }
    .settings-actions .btn { width: 100%; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .topbar-username { display: none; }
    .grid-auto { grid-template-columns: 1fr; }
    .download-grid { grid-template-columns: 1fr; }
    .buy-grid { grid-template-columns: repeat(2, 1fr); }
    .specs { grid-template-columns: 1fr; }
    .volume-tier-steps { flex-direction: column; }
    .volume-step { min-width: auto; }
}

/* ================================================================
   Node Chat Page
   ================================================================ */

.page-node-chat { overflow: hidden; }

.nc-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.nc-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform 0.2s ease;
    z-index: 50;
}

.nc-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.nc-sidebar-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-2);
}

.nc-sidebar-close {
    display: none;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-3);
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 6px;
}

.nc-sidebar-close:hover { background: rgba(255,255,255,0.06); }

.nc-node-list { flex: 1; padding: 0.5rem; }

.nc-node-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 0.85rem;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s;
    margin-bottom: 0.25rem;
}

.nc-node-item:hover { background: rgba(255,255,255,0.03); }
.nc-node-item.active { background: var(--primary-faint); }

.nc-node-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: rgba(255,255,255,0.15);
}

.nc-node-dot.online {
    background: var(--green);
    box-shadow: 0 0 6px rgba(16,185,129,0.4);
}

.nc-node-info { flex: 1; min-width: 0; }

.nc-node-label {
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nc-node-meta {
    font-size: 0.7rem;
    color: var(--text-4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nc-node-status {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-4);
    flex-shrink: 0;
}

.nc-empty {
    padding: 2rem 1.25rem;
    text-align: center;
    color: var(--text-3);
    font-size: 0.85rem;
}

.nc-empty .btn { margin-top: 1rem; }

/* ── Main chat area (uses standard style.css classes) ────── */
/* Re-declare style.css CSS variables inside .main to prevent
   platform.css :root variables from overriding them.          */
body.page-node-chat {
    --bg-primary: #0a0a0f;
    --bg-secondary: #111118;
    --bg-tertiary: #1a1a25;
    --bg-input: #141420;
    --border: #2a2a3a;
    --border-focus: #7c3aed;
    --text-primary: #e8e8ed;
    --text-secondary: #8888a0;
    --text-muted: #555;
    --accent: #7c3aed;
    --accent-light: #a78bfa;
    --user-bubble: #7c3aed;
    --assistant-bubble: #1e1e2e;
    --danger: #ef4444;
    --success: #22c55e;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

.page-node-chat .main {
    --radius: 14px;
    --nav-width: 0px;
    margin-left: 0 !important;
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

/* Override platform.css .topbar rules leaking into the chat topbar */
.page-node-chat .main > .topbar {
    position: static;
    z-index: auto;
    padding: 0.65rem 1rem;
    height: auto;
    min-height: 52px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    box-shadow: none;
}

/* Ensure platform nav keeps its styling and doesn't shrink in the flex column */
.page-node-chat > nav.topbar {
    flex-shrink: 0;
    background: var(--surface, #0a0a14);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Override style.css desktop rules that don't apply here */
@media (min-width: 768px) {
    .page-node-chat .main { margin-left: 0 !important; }
    .page-node-chat #openNav { display: none; }
    .page-node-chat .nav-sidebar { display: none !important; }
    .page-node-chat #ncMenuBtn { display: none; }
}

/* ── Toggle switch (reusable) ────────────────────────────── */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    left: 2px;
    bottom: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(16px);
}

/* ── Settings popover shared ─────────────────────────────── */
.settings-popover {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    min-width: 240px;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.settings-header {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-3);
    margin-bottom: 0.65rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.45rem 0;
}

.settings-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-2);
    font-weight: 500;
}

/* History/notes popovers need toolbar-relative positioning */
.chat-history-wrap,
.notes-wrap,
.settings-wrap {
    position: relative;
}

.page-node-chat .settings-popover {
    right: 0;
    left: auto;
    width: 280px;
    max-width: calc(100vw - 2rem);
}

.history-popover,
.notes-popover {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 280px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.history-header,
.notes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-2);
    flex-shrink: 0;
}

.history-new-btn,
.notes-add-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--primary-light);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-family: inherit;
}

.history-new-btn:hover,
.notes-add-btn:hover { background: var(--primary-faint); }

.history-list { flex: 1; overflow-y: auto; padding: 0.35rem; }

.session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s;
}

.session-item:hover { background: rgba(255,255,255,0.03); }
.session-item.active { background: var(--primary-faint); }

.session-item .title {
    font-size: 0.78rem;
    color: var(--text-2);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-item.active .title { color: var(--primary-light); }

.session-item .delete-btn {
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    color: var(--text-4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 0.7rem;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.12s, color 0.12s;
}

.session-item:hover .delete-btn { opacity: 1; }
.session-item .delete-btn:hover { color: var(--red-light); background: rgba(239,68,68,0.1); }

/* Notes items */
.notes-list { flex: 1; overflow-y: auto; padding: 0.35rem; }

.note-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.55rem;
    border-radius: 6px;
    font-size: 0.78rem;
}

.note-item.disabled { opacity: 0.45; }

.note-toggle {
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--text-4);
    border-radius: 4px;
    background: transparent;
    color: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.12s;
}

.note-item:not(.disabled) .note-toggle {
    border-color: var(--primary-light);
    color: var(--primary-light);
    background: var(--primary-faint);
}

.note-text {
    flex: 1;
    color: var(--text-2);
    line-height: 1.35;
}

.note-delete {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--text-4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
    opacity: 0;
}

.note-item:hover .note-delete { opacity: 1; }
.note-delete:hover { color: var(--red-light); background: rgba(239,68,68,0.08); }

.notes-input-row {
    display: flex;
    gap: 0.4rem;
    padding: 0.5rem 0.65rem;
    border-top: 1px solid var(--border);
}

.notes-input {
    flex: 1;
    padding: 0.4rem 0.6rem !important;
    font-size: 0.78rem !important;
    border-radius: 6px !important;
}

.notes-save-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: var(--primary-faint);
    color: var(--primary-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    flex-shrink: 0;
}

.notes-save-btn:hover { background: rgba(124,58,237,0.2); }

.notes-footer {
    padding: 0.45rem 0.65rem;
    border-top: 1px solid var(--border);
}

.notes-hint {
    font-size: 0.65rem;
    color: var(--text-4);
}

/* ── Dashboard connected-clients section ─────────────────── */
.connected-nodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
}

.cn-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    transition: border-color 0.15s;
}

.cn-card:hover { border-color: var(--border-hover); }

.cn-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    background: rgba(255,255,255,0.12);
}

.cn-status.online {
    background: var(--green);
    box-shadow: 0 0 6px rgba(16,185,129,0.4);
}

.cn-info { flex: 1; min-width: 0; }

.cn-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cn-meta {
    font-size: 0.72rem;
    color: var(--text-4);
    margin-top: 0.15rem;
}

.cn-actions { flex-shrink: 0; }

/* ── Checkout config toggles ─────────────────────────────── */
.checkout-config { margin-bottom: 1.25rem; }

.config-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.config-option:hover { border-color: var(--border-hover); }
.config-option.selected {
    border-color: rgba(124,58,237,0.4);
    background: var(--primary-faint);
}

.config-radio {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--text-4);
    flex-shrink: 0;
    margin-top: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s;
}

.config-option.selected .config-radio {
    border-color: var(--primary-light);
}

.config-option.selected .config-radio::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-light);
}

.config-body { flex: 1; }

.config-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.config-desc {
    font-size: 0.75rem;
    color: var(--text-3);
    line-height: 1.45;
}

.config-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.4rem;
}

.config-tag {
    font-size: 0.62rem;
    font-weight: 600;
    padding: 0.12rem 0.4rem;
    border-radius: 4px;
    background: rgba(255,255,255,0.04);
    color: var(--text-3);
    border: 1px solid var(--border);
}

.checkout-extra {
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}

.checkout-extra-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.checkout-extra-label {
    font-size: 0.82rem;
    font-weight: 600;
}

.checkout-extra-desc {
    font-size: 0.72rem;
    color: var(--text-3);
    margin-top: 0.25rem;
    line-height: 1.4;
}

.checkout-extra-field {
    margin-top: 0.65rem;
}

.checkout-extra-field input {
    font-family: var(--mono);
    font-size: 0.82rem;
}

/* ── Region select ───────────────────────────────────────── */
.region-select-wrap { margin-bottom: 1.25rem; }

.region-select-wrap label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin-bottom: 0.5rem;
}

.region-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.4rem;
}

.region-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text-2);
    transition: border-color 0.15s, background 0.15s;
}

.region-option:hover { border-color: var(--border-hover); }

.region-option.selected {
    border-color: rgba(124,58,237,0.4);
    background: var(--primary-faint);
    color: var(--primary-light);
    font-weight: 600;
}

.region-flag {
    font-size: 1rem;
    line-height: 1;
}

/* ── Upload & Media Settings (node-chat) ──────────────────── */
.upload-preview-area { padding: 0 1rem; }
.upload-inline {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.375rem 0.5rem; font-size: 0.8125rem; color: var(--text-2);
}
.upload-thumb { max-width: 120px; max-height: 80px; border-radius: 6px; border: 1px solid var(--border); }
.upload-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 1rem; padding: 2px; }
.upload-btn-inline {
    background: none; border: 1px solid var(--border); border-radius: 8px;
    padding: 0.5rem; cursor: pointer; color: var(--text-3);
    display: flex; align-items: center; transition: all 0.15s;
    flex-shrink: 0;
}
.upload-btn-inline:hover { border-color: var(--border-hover); color: var(--text-1); }
.settings-divider { border-top: 1px solid var(--border); margin: 0.5rem 0; }

/* ── Node capability badges ──────────────────────────── */
.nc-node-caps {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin-top: 0.3rem;
}

.nc-cap-badge {
    font-size: 0.55rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: rgba(124,58,237,0.1);
    color: var(--purple-light, #c4b5fd);
    border: 1px solid rgba(124,58,237,0.2);
    white-space: nowrap;
}

.nc-cap-more {
    background: rgba(255,255,255,0.04);
    color: var(--text-4, rgba(255,255,255,0.25));
    border-color: var(--border, rgba(255,255,255,0.06));
}

/* ── Relay session indicator ─────────────────────────── */
.session-item.relay .title {
    font-style: italic;
}

.session-relay-icon {
    flex-shrink: 0;
    opacity: 0.4;
    margin-right: 0.15rem;
}

/* ── Streaming message ───────────────────────────────── */
.msg.streaming .msg-bubble {
    border: 1px solid rgba(124,58,237,0.2);
}

.nc-stream-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    font-size: 0.75rem;
    color: var(--text-3, #a0a0b0);
    font-weight: 500;
}

.nc-stream-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(124,58,237,0.3);
    border-top-color: var(--primary, #7c3aed);
    border-radius: 50%;
    animation: nc-spin 0.6s linear infinite;
    flex-shrink: 0;
}

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

.nc-stream-content .md-content,
.nc-stream-thinking .md-content {
    font-size: 0.875rem;
    line-height: 1.6;
}

/* ── Thinking (reasoning) block ──────────────────────── */
.nc-thinking-block {
    margin: 0.5rem 0;
    border-radius: 8px;
    border: 1px solid rgba(124,58,237,0.15);
    background: rgba(124,58,237,0.04);
    overflow: hidden;
}

.nc-thinking-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.45rem 0.65rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--primary-light, #a855f7);
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.nc-thinking-toggle:hover {
    background: rgba(124,58,237,0.06);
}

.nc-chevron {
    margin-left: auto;
    transition: transform 0.2s;
}

.nc-thinking-block.expanded .nc-chevron {
    transform: rotate(180deg);
}

.nc-thinking-content {
    display: none;
    padding: 0 0.65rem 0.5rem;
    font-size: 0.78rem;
    color: var(--text-3, #a0a0b0);
    line-height: 1.55;
    max-height: 300px;
    overflow-y: auto;
}

.nc-thinking-block.expanded .nc-thinking-content {
    display: block;
}

/* ── Tool calls block ────────────────────────────────── */
.nc-tools-block {
    margin: 0.5rem 0;
    border-radius: 8px;
    border: 1px solid rgba(59,130,246,0.15);
    background: rgba(59,130,246,0.04);
    overflow: hidden;
}

.nc-tools-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.45rem 0.65rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--blue-light, #60a5fa);
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.nc-tools-toggle:hover {
    background: rgba(59,130,246,0.06);
}

.nc-tools-block .nc-chevron {
    margin-left: auto;
    transition: transform 0.2s;
}

.nc-tools-block.expanded .nc-chevron {
    transform: rotate(180deg);
}

.nc-tools-content {
    display: none;
    padding: 0 0.65rem 0.5rem;
}

.nc-tools-block.expanded .nc-tools-content {
    display: block;
}

.nc-tool-item {
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.nc-tool-item:last-child { border-bottom: none; }

.nc-tool-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-2, #a0a0b0);
    font-family: var(--mono, monospace);
}

.nc-tool-result {
    margin-top: 0.25rem;
    font-size: 0.7rem;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
    max-height: 120px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-3, #a0a0b0);
}

.nc-tool-fail .nc-tool-name {
    color: var(--red-light, #f87171);
}

.nc-tool-item-mini {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
    color: var(--text-2, #a0a0b0);
}

.nc-tool-running {
    width: 10px;
    height: 10px;
    display: inline-block;
}

.nc-tool-check { color: var(--green, #10b981); font-weight: bold; }
.nc-tool-cross { color: var(--red, #ef4444); font-weight: bold; }

/* ── Media grid ──────────────────────────────────────── */
.nc-media-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.65rem;
}

.nc-media-item {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.2);
    max-width: 320px;
}

.nc-media-item img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.nc-media-item video {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* ── Usage tokens display ────────────────────────────── */
.nc-usage {
    margin-top: 0.4rem;
    font-size: 0.65rem;
    color: var(--text-4, rgba(255,255,255,0.25));
    font-weight: 500;
}

/* ── Note actions group (edit/delete) ────────────────── */
.note-actions {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.12s;
}

.note-item:hover .note-actions { opacity: 1; }

.note-edit {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--text-4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
}

.note-edit:hover { color: var(--primary-light); background: var(--primary-faint); }

.note-edit-row {
    display: flex;
    gap: 0.3rem;
    align-items: center;
    flex: 1;
    padding: 0.15rem 0;
}

.note-edit-input {
    flex: 1;
    padding: 0.3rem 0.5rem !important;
    font-size: 0.78rem !important;
    border-radius: 5px !important;
}

.note-edit-save,
.note-edit-cancel {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: transparent;
    color: var(--text-3);
}

.note-edit-save:hover { color: var(--green); background: rgba(16,185,129,0.08); }
.note-edit-cancel:hover { color: var(--red-light); background: rgba(239,68,68,0.08); }

.note-item.editing { background: rgba(255,255,255,0.02); border-radius: 6px; }

.notes-badge {
    display: none;
    font-size: 0.55rem;
    font-weight: 700;
    min-width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    padding: 0 3px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    margin-left: 0.15rem;
}

.notes-badge.show { display: inline-block; }

.notes-btn-label { font-size: 0.78rem; }
.history-btn-label { font-size: 0.78rem; }

/* ── View tabs (Chat / Direct) ────────────────────────── */
.nc-view-tabs {
    display: flex;
    gap: 0.2rem;
    padding: 0.2rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-left: 0.75rem;
}

.nc-view-tab {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-3);
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    white-space: nowrap;
}

.nc-view-tab:hover { color: var(--text-2); background: rgba(255,255,255,0.04); }

.nc-view-tab.active {
    color: var(--primary-light, #a855f7);
    background: var(--primary-faint, rgba(124,58,237,0.12));
}

.nc-view-tab.nc-tunnel-live::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green, #10b981);
    box-shadow: 0 0 4px rgba(16,185,129,0.5);
    flex-shrink: 0;
}

/* ── Direct view (iframe container) ──────────────────── */
.nc-direct-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.nc-direct-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    background: var(--bg, #020208);
    z-index: 5;
    font-size: 0.85rem;
    color: var(--text-3);
}

.nc-direct-frame {
    flex: 1;
    width: 100%;
    border: none;
    background: #0a0a14;
    min-height: 0;
}

@media (max-width: 768px) {
    .page-node-chat .nc-layout { flex-direction: column; }
    .page-node-chat .nc-sidebar {
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        z-index: 100;
    }
    .page-node-chat .nc-sidebar.open { transform: translateX(0); }
    .page-node-chat .nc-sidebar-close { display: flex; align-items: center; justify-content: center; }
    .page-node-chat #ncMenuBtn { display: flex !important; }
    .page-node-chat .main { margin-left: 0 !important; width: 100%; }
    .page-node-chat .main > .topbar { padding: 0.5rem 0.75rem; }

    .page-node-chat .settings-popover,
    .page-node-chat .history-popover,
    .page-node-chat .notes-popover {
        position: fixed;
        left: 0.75rem;
        right: 0.75rem;
        bottom: 80px;
        width: auto;
        max-width: none;
        max-height: 60vh;
    }
}
