/* ============================================================
   LLM MARKET — DESIGN SYSTEM
   Inspired by OpenRouter, vast.ai, digitec
   ============================================================ */

/* === FONTS === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

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

/* === DESIGN TOKENS === */
:root {
    /* Color — Dark (default) */
    --bg: #0b0d10;
    --surface: #13161b;
    --surface-2: #181c23;
    --surface-3: #1f242d;
    --border: #262c36;
    --border-strong: #353c48;
    --text: #e4e7eb;
    --text-muted: #8a94a4;
    --text-subtle: #5b6573;
    --primary: #5b8def;
    --primary-hover: #7aa3ff;
    --primary-bg: rgba(91, 141, 239, 0.08);
    --primary-border: rgba(91, 141, 239, 0.25);
    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.08);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.08);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.08);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, monospace;
    --fs-xs: 0.75rem;
    --fs-sm: 0.8125rem;
    --fs-base: 0.875rem;
    --fs-md: 0.9375rem;
    --fs-lg: 1.0625rem;
    --fs-xl: 1.25rem;
    --fs-2xl: 1.5rem;
    --fs-3xl: 2rem;

    /* Spacing */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;
    --sp-12: 48px;
    --sp-16: 64px;

    /* Radius */
    --r-sm: 4px;
    --r-md: 6px;
    --r-lg: 8px;
    --r-xl: 12px;

    /* Shadow */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);

    /* Layout */
    --header-h: 56px;
    --container-w: 1280px;
}

/* Light mode overrides */
body.light-mode {
    --bg: #ffffff;
    --surface: #fafbfc;
    --surface-2: #f3f5f8;
    --surface-3: #e9ecf1;
    --border: #e3e7ec;
    --border-strong: #cdd3db;
    --text: #1c2129;
    --text-muted: #5f6877;
    --text-subtle: #8b94a3;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-bg: rgba(37, 99, 235, 0.06);
    --primary-border: rgba(37, 99, 235, 0.2);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* === GLOBAL === */
html { font-size: 16px; }

body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    font-feature-settings: 'cv11', 'ss01', 'ss02';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s;
}
a:hover { color: var(--primary-hover); }

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

code, pre, .mono {
    font-family: var(--font-mono);
}

::selection {
    background: var(--primary);
    color: white;
}

/* === SVG ICONS === */
svg { display: inline-block; vertical-align: -2px; }

/* === HEADER / NAVBAR === */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 var(--sp-6);
    gap: var(--sp-6);
    backdrop-filter: blur(8px);
}
.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: 700;
    font-size: var(--fs-md);
    color: var(--text);
    letter-spacing: -0.01em;
}
.navbar-brand svg { color: var(--primary); }
.navbar-nav {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    margin-left: var(--sp-6);
}
.nav-link {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-md);
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-weight: 500;
    transition: all 0.15s;
}
.nav-link:hover {
    color: var(--text);
    background: var(--surface);
}
.nav-link.active {
    color: var(--text);
    background: var(--surface-2);
}
.nav-link svg { opacity: 0.8; }

.navbar-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    padding: 6px;
    cursor: pointer;
    transition: all 0.15s;
    margin-left: auto;
}
.navbar-toggle:hover { background: var(--surface); border-color: var(--border-strong); }
.navbar-toggle-icon { display: block; }
.navbar-toggle[aria-expanded="true"] .navbar-toggle-icon use { transform: rotate(90deg); }

@media (max-width: 768px) {
    .navbar-toggle { display: inline-flex; align-items: center; }
    .navbar-nav {
        position: fixed;
        top: var(--header-h);
        left: 0;
        right: 0;
        background: var(--bg);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        align-items: stretch;
        margin-left: 0;
        padding: var(--sp-3);
        gap: 2px;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.25s ease, padding 0.25s ease;
        padding-top: 0;
        padding-bottom: 0;
        z-index: 99;
    }
    .navbar-nav.open {
        max-height: 480px;
        padding-top: var(--sp-3);
        padding-bottom: var(--sp-3);
    }
    .nav-link {
        padding: var(--sp-3);
        justify-content: flex-start;
        font-size: var(--fs-md);
    }
    .navbar-actions { margin-left: auto; }
}

.navbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 8px var(--sp-3);
    border-radius: var(--r-md);
    font-size: var(--fs-sm);
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
    border: 1px solid transparent;
    white-space: nowrap;
}
.nav-btn-secondary {
    color: var(--text-muted);
    border-color: var(--border);
    background: transparent;
}
.nav-btn-secondary:hover {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border-strong);
}
.nav-btn-primary {
    color: white;
    background: var(--primary);
    border-color: var(--primary);
}
.nav-btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}
@media (max-width: 480px) {
    .nav-btn span { display: none; }
    .nav-btn { padding: 8px; }
}

.wallet-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px 6px 8px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    font-size: var(--fs-sm);
    font-weight: 600;
    transition: all 0.15s;
    white-space: nowrap;
}
.wallet-pill svg { color: var(--primary); }
.wallet-pill:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
    color: var(--text);
}
.wallet-pill-amount { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.wallet-pill-chevron { color: var(--text-muted); opacity: 0.6; }
.wallet-pill[data-balance="low"] { border-color: var(--warning); }
.wallet-pill[data-balance="low"] .wallet-pill-amount { color: var(--warning); }
.wallet-pill[data-balance="zero"] { border-color: var(--danger); }
.wallet-pill[data-balance="zero"] .wallet-pill-amount { color: var(--danger); }
@media (max-width: 600px) {
    .wallet-pill-chevron { display: none; }
    .wallet-pill { padding: 6px 8px; }
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--r-md);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.icon-btn:hover {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.icon-btn .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
/* The .hidden utility must win over the inline-flex above so the badge
   disappears when there are 0 notifications. !important is required here
   because .icon-btn .badge has very high specificity. */
.icon-btn .badge.hidden {
    display: none !important;
}

/* === USER MENU === */
.user-menu { position: relative; }
.user-trigger {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-1) var(--sp-3) var(--sp-1) var(--sp-1);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s;
}
.user-trigger:hover {
    border-color: var(--border-strong);
}
.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: var(--fs-xs);
}
/* When the avatar is an <img>, hide the gradient/text and show the photo cropped */
.user-avatar.user-avatar-img {
    background: transparent;
    object-fit: cover;
    overflow: hidden;
}
.user-name {
    font-size: var(--fs-sm);
    color: var(--text);
    font-weight: 500;
}
.user-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-1);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: all 0.15s;
    z-index: 200;
}
.user-menu.open .user-dropdown {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.user-dropdown-header {
    padding: var(--sp-3) var(--sp-3) var(--sp-2);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--sp-1);
}
.user-dropdown-header-name {
    font-weight: 600;
    font-size: var(--fs-sm);
    color: var(--text);
}
.user-dropdown-header-email {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}
.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-md);
    color: var(--text);
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: background 0.1s;
    text-decoration: none;
}
.user-dropdown-item:hover {
    background: var(--surface-2);
}
.user-dropdown-item.danger { color: var(--danger); }
.user-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: var(--sp-1) 0;
}

/* === CONTAINER === */
.container {
    max-width: var(--container-w);
    margin: 0 auto;
    padding: var(--sp-6);
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.2;
    white-space: nowrap;
}
.btn:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
}
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}
.btn-secondary {
    background: var(--surface-2);
}
.btn-ghost {
    background: transparent;
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--surface);
}
.btn-danger {
    background: var(--danger-bg);
    border-color: rgba(248, 113, 113, 0.3);
    color: var(--danger);
}
.btn-danger:hover {
    background: var(--danger);
    color: white;
}
.btn-sm { padding: 4px var(--sp-3); font-size: var(--fs-xs); }
.btn-lg { padding: var(--sp-3) var(--sp-5); font-size: var(--fs-md); }
.btn:disabled, .btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === FORMS === */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    margin-bottom: var(--sp-4);
}
.form-label {
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text);
}
.form-hint {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: var(--sp-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    font-size: var(--fs-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}
.form-textarea { resize: vertical; min-height: 80px; }

/* === CARD === */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-5);
    transition: border-color 0.15s;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-4);
}
.card-title {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}
.card-title svg { color: var(--text-muted); }

/* === AUTH PAGES === */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-6);
    background: var(--bg);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--sp-8);
    box-shadow: var(--shadow-md);
}

/* === ADMIN PAGES === */
/* Wider than auth-card because admin tables need horizontal room.
   Uses same surface treatment for visual consistency with auth/login pages. */
.admin-page {
    min-height: 100vh;
    padding: var(--sp-6) var(--sp-4);
    background: var(--bg);
}
.admin-card {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--sp-8);
    box-shadow: var(--shadow-md);
}
/* Stat-cards in admin context: real grid (vs the auth-page stacked column).
   Default = 4 columns on desktop, 2 on tablet, 1 on phone. */
.admin-card .info-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--sp-3);
}
.admin-card .info-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-4);
}
.admin-card .info-card-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}
.admin-card .info-card-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}
.admin-card .info-card-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* === ADMIN MODAL === */
/* Used by all /admin/* pages for ban/unban/delete actions. Triggered by
   showAdminModal() defined in base.html. No links, just buttons + modal. */
.admin-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
    opacity: 0;
    transition: opacity 0.18s ease;
}
.admin-modal-overlay.open { opacity: 1; }
.admin-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    width: 100%;
    max-width: 520px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    transform: translateY(-10px) scale(0.97);
    transition: transform 0.18s ease;
}
.admin-modal-overlay.open .admin-modal { transform: translateY(0) scale(1); }
.admin-modal-header {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-5) var(--sp-6);
    border-bottom: 1px solid var(--border);
}
.admin-modal-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    flex-shrink: 0;
}
.admin-modal-icon.danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}
.admin-modal-icon.success {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}
.admin-modal-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}
.admin-modal-subtitle {
    margin: 4px 0 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.admin-modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
    transition: background 0.12s;
}
.admin-modal-close:hover { background: var(--surface-2); color: var(--text); }
.admin-modal-body {
    padding: var(--sp-5) var(--sp-6);
    font-size: 0.9rem;
    color: var(--text);
}
.admin-modal-footer {
    padding: var(--sp-4) var(--sp-6);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-3);
}

/* === ADMIN LAYOUT (Sidebar-Tabs) === */
/* Two-column layout: vertical sidebar with navigation buttons on the left,
   main content on the right. The sidebar replaces the need for links
   scattered throughout the page — admin pages should feel like a control panel. */
.admin-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 0;
    min-height: calc(100vh - 200px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    overflow: hidden;
}
.admin-sidebar {
    background: var(--surface-2);
    border-right: 1px solid var(--border);
    padding: var(--sp-4) 0;
}
.admin-sidebar-header {
    padding: 0 var(--sp-4) var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--sp-3);
}
.admin-sidebar-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text);
}
.admin-sidebar-header p {
    margin: 4px 0 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.admin-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 var(--sp-2);
}
.admin-nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
    transition: background 0.12s, border-color 0.12s;
    background: transparent;
}
.admin-nav-item:hover {
    background: var(--surface);
    text-decoration: none;
}
.admin-nav-item.active {
    background: var(--surface);
    border-color: var(--border);
    color: var(--primary);
}
.admin-nav-item.active .admin-nav-icon {
    color: var(--primary);
}
.admin-nav-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}
.admin-nav-item.active svg { opacity: 1; }
.admin-nav-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-muted);
    flex-shrink: 0;
}
.admin-nav-item.active .admin-nav-icon {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}
.admin-nav-label {
    display: flex;
    flex-direction: column;
    flex: 1;
}
.admin-nav-label-text {
    font-weight: 600;
    line-height: 1.2;
}
.admin-nav-label-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
}
.admin-content {
    padding: var(--sp-6);
    overflow-x: auto;
}
@media (max-width: 768px) {
    .admin-layout {
        grid-template-columns: 1fr;
    }
    .admin-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
}

/* === ADMIN STATUS BADGES === */
.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}
.admin-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.admin-badge.success {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
}
.admin-badge.success::before { background: #10b981; }
.admin-badge.danger {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}
.admin-badge.danger::before { background: #ef4444; }
.admin-badge.warning {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}
.admin-badge.warning::before { background: #f59e0b; }
.admin-badge.neutral {
    background: var(--surface-2);
    color: var(--text-muted);
}
.admin-badge.neutral::before { background: var(--text-muted); }

/* Role badges for the Role column */
.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.role-badge.role-admin {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.role-badge.role-host {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.3);
}
.role-badge.role-customer {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* === ADMIN SECTION CARDS === */
/* Used inside .admin-content to wrap logical groups (filter, stats, table) */
.admin-section {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-4);
    margin-bottom: var(--sp-4);
}
.admin-section-title {
    margin: 0 0 var(--sp-3) 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* Filter-bar inside admin section */
.admin-filter {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.admin-filter input[type="text"],
.admin-filter select {
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
    flex: 1;
    min-width: 180px;
}
.admin-filter label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
}

/* Stat cards row */
.admin-stats {
    display: flex;
    gap: var(--sp-3);
    flex-wrap: wrap;
    margin-bottom: var(--sp-4);
}
.admin-stat-card {
    flex: 1 1 180px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-3) var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.admin-stat-card.danger { border-color: rgba(239, 68, 68, 0.4); background: rgba(239, 68, 68, 0.05); }
.admin-stat-card.warning { border-color: rgba(245, 158, 11, 0.4); background: rgba(245, 158, 11, 0.05); }
.admin-stat-card.success { border-color: rgba(16, 185, 129, 0.4); background: rgba(16, 185, 129, 0.05); }
.admin-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}
.admin-stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    font-family: var(--font-mono);
    line-height: 1.1;
}
.admin-stat-card.danger .admin-stat-value { color: #ef4444; }
.admin-stat-card.warning .admin-stat-value { color: #f59e0b; }
.admin-stat-card.success .admin-stat-value { color: #10b981; }

/* Action buttons — labelled, with hover effect */
.admin-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
    flex-wrap: nowrap;
}
.admin-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    font-size: 0.78rem;
    padding: 5px 10px;
}

/* Ban-reason display under user (so admin sees WHY they're banned) */
.ban-reason {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
    font-style: italic;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Long model-name truncation in audit table */
.cell-truncate {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cell-multiline-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 320px;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Inline-edit input for provision % */
.admin-inline-input {
    width: 60px;
    padding: 4px 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    text-align: right;
    transition: border-color 0.12s;
}
.admin-inline-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Empty-state inside table */
.admin-empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--text-muted);
}
.admin-empty-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    opacity: 0.4;
}
.auth-logo {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: var(--sp-6);
    font-weight: 700;
    font-size: var(--fs-lg);
    color: var(--text);
}
.auth-logo svg { color: var(--primary); }
.auth-title {
    font-size: var(--fs-xl);
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--sp-1);
    letter-spacing: -0.01em;
}
.auth-subtitle {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-bottom: var(--sp-6);
}
.auth-footer {
    margin-top: var(--sp-6);
    text-align: center;
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

/* === DASHBOARD === */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}
.page-title {
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    margin-bottom: var(--sp-1);
}
.page-subtitle {
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

/* Stat Cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-5);
    transition: border-color 0.15s;
}
.stat-card:hover { border-color: var(--border-strong); }
.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--sp-3);
}
.stat-label {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.stat-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--r-md);
    background: var(--primary-bg);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.stat-value {
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    margin-bottom: var(--sp-1);
}
.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--fs-xs);
    color: var(--text-muted);
}
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* === TABLE === */
.table-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}
.data-table thead {
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.data-table th {
    text-align: left;
    padding: var(--sp-3) var(--sp-4);
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.data-table td {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}
.data-table tbody tr {
    transition: background 0.1s;
}
.data-table tbody tr:hover {
    background: var(--surface-2);
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}
.data-table .num {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* === BADGE / PILL === */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px var(--sp-2);
    border-radius: 10px;
    font-size: var(--fs-xs);
    font-weight: 500;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    line-height: 1.4;
}
.pill-success { background: var(--success-bg); color: var(--success); border-color: rgba(52, 211, 153, 0.2); }
.pill-warning { background: var(--warning-bg); color: var(--warning); border-color: rgba(251, 191, 36, 0.2); }
.pill-danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(248, 113, 113, 0.2); }
.pill-primary { background: var(--primary-bg); color: var(--primary); border-color: var(--primary-border); }
.pill-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
}

/* === CHAT === */
.chat-shell {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 720px;
}
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.chat-model-info {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
    color: var(--text);
}
.chat-model-info-name { font-weight: 600; }
.chat-model-info-meta { font-size: var(--fs-xs); color: var(--text-muted); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-6) var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
}

.chat-msg {
    display: flex;
    gap: var(--sp-3);
    max-width: 760px;
    width: 100%;
}
.chat-msg-user { align-self: flex-end; flex-direction: row-reverse; }

.chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--r-md);
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-muted);
}
.chat-msg-user .chat-msg-avatar {
    background: var(--primary-bg);
    color: var(--primary);
    border-color: var(--primary-border);
}
.chat-msg-assistant .chat-msg-avatar {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: white;
    border-color: transparent;
}
.chat-msg-bubble {
    flex: 1;
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    color: var(--text);
    line-height: 1.6;
    font-size: var(--fs-sm);
}
.chat-msg-user .chat-msg-bubble {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.chat-msg-content { white-space: pre-wrap; word-break: break-word; }

.chat-input-area {
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    padding: var(--sp-3) var(--sp-4);
}
.chat-input-toolbar {
    display: flex;
    gap: var(--sp-1);
    margin-bottom: var(--sp-2);
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--border);
}
.chat-toolbar-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: var(--r-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
}
.chat-toolbar-btn:hover {
    background: var(--surface);
    color: var(--text);
}
.chat-input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--sp-3);
    color: var(--text);
    font-size: var(--fs-sm);
    line-height: 1.5;
    resize: none;
    min-height: 56px;
    max-height: 200px;
}
.chat-input:focus { outline: none; border-color: var(--primary); }
.chat-input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--sp-2);
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

/* === CODE BLOCK === */
.code-block {
    background: #0a0d12;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin: var(--sp-3) 0;
    overflow: hidden;
}
.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sp-2) var(--sp-3);
    background: var(--surface-3);
    border-bottom: 1px solid var(--border);
}
.code-block-lang {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    text-transform: lowercase;
    letter-spacing: 0.05em;
}
.code-block pre {
    padding: var(--sp-3);
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: #d4d4d4;
    overflow-x: auto;
    line-height: 1.5;
}
.code-copy-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 2px var(--sp-2);
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: var(--fs-xs);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}
.code-copy-btn:hover {
    background: var(--surface-2);
    color: var(--text);
}

/* === EMPTY STATES === */
.empty-state {
    text-align: center;
    padding: var(--sp-12) var(--sp-6);
    color: var(--text-muted);
}
.empty-state-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--r-lg);
    background: var(--surface-2);
    color: var(--text-subtle);
    margin: 0 auto var(--sp-4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.empty-state-title {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--sp-1);
}
.empty-state-message {
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

/* === STATUS DOT === */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.online { background: var(--success); box-shadow: 0 0 8px rgba(52, 211, 153, 0.4); }
.status-dot.offline { background: var(--danger); }
.status-dot.slow { background: var(--warning); }

/* === FOOTER === */
.footer {
    margin-top: var(--sp-12);
    padding: var(--sp-8) var(--sp-6);
    border-top: 1px solid var(--border);
    color: var(--text-subtle);
    font-size: var(--fs-xs);
    text-align: center;
}

/* === TOAST === */
.toast-container {
    position: fixed;
    top: calc(var(--header-h) + var(--sp-4));
    right: var(--sp-4);
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    pointer-events: none;
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--sp-3) var(--sp-4);
    min-width: 300px;
    max-width: 400px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    pointer-events: auto;
    animation: toast-in 0.2s ease;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--primary); }
@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* === MODAL === */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 8000;
    animation: fade-in 0.15s ease;
}
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--sp-6);
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: modal-in 0.2s ease;
}
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes modal-in {
    from { opacity: 0; transform: scale(0.95) translateY(-8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-title {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--sp-2);
}
.modal-actions {
    display: flex;
    gap: var(--sp-2);
    justify-content: flex-end;
    margin-top: var(--sp-5);
}

/* === UTILITIES === */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.font-mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .container { padding: var(--sp-4); }
    .stat-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: stretch; }
    .navbar-nav { display: none; }
    .auth-card { padding: var(--sp-5); }
    .chat-messages { padding: var(--sp-4) var(--sp-3); }
}

/* === LEGACY TEMPLATE OVERRIDES === */
/* Old classes used by market, host, chat, api-keys, profile etc.
   These overrides map the legacy classes to the new design system. */

/* Market / Leaderboard */
.market-page { max-width: var(--container-w); margin: 0 auto; padding: var(--sp-6); }
.market-header { margin-bottom: var(--sp-6); }
.market-header h1 { font-size: var(--fs-2xl); font-weight: 700; color: var(--text); letter-spacing: -0.02em; margin-bottom: var(--sp-1); display: flex; align-items: center; gap: var(--sp-2); }
.market-header p { font-size: var(--fs-sm); color: var(--text-muted); }

.search-bar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); margin-bottom: var(--sp-4); }
.search-input-wrap { position: relative; }
.search-icon { position: absolute; left: var(--sp-3); top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; z-index: 2; }
.search-input-wrap input[type="text"] { width: 100%; padding: var(--sp-3) var(--sp-3) var(--sp-3) 36px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); color: var(--text); font-size: var(--fs-sm); transition: border-color 0.15s, box-shadow 0.15s; }
.search-input-wrap input[type="text"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.clear-btn { position: absolute; right: var(--sp-3); top: 50%; transform: translateY(-50%); background: var(--surface-2); border: none; color: var(--text-muted); width: 22px; height: 22px; border-radius: 50%; cursor: pointer; display: none; align-items: center; justify-content: center; }
.clear-btn.visible { display: inline-flex; }
.clear-btn:hover { background: var(--surface-3); color: var(--text); }

.search-suggestions { padding-top: var(--sp-3); border-top: 1px solid var(--border); margin-top: var(--sp-3); }
.suggestions-label { font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: var(--sp-2); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.suggestion-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.suggestion-chip { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: var(--sp-1) var(--sp-3); border-radius: 16px; font-size: var(--fs-xs); cursor: pointer; transition: all 0.15s; display: inline-flex; align-items: center; gap: 4px; }
.suggestion-chip:hover { background: var(--surface-3); border-color: var(--border-strong); }
.suggestion-quick { background: var(--primary-bg); border-color: var(--primary-border); color: var(--primary); }
.suggestion-quick:hover { background: var(--primary); color: white; border-color: var(--primary); }

.filter-chips-bar, .filter-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); margin-bottom: var(--sp-3); align-items: center; }
.filter-chip { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: var(--sp-1) var(--sp-3); border-radius: 16px; font-size: var(--fs-xs); cursor: pointer; transition: all 0.15s; display: inline-flex; align-items: center; gap: 4px; }
.filter-chip:hover { background: var(--surface-3); border-color: var(--border-strong); }
.filter-chip.active { background: var(--primary); color: white; border-color: var(--primary); }
.filter-chip.active .filter-count { background: rgba(255,255,255,0.2); color: white; }
.filter-count { background: rgba(0,0,0,0.15); padding: 0 6px; border-radius: 8px; font-weight: 600; font-size: 10px; margin-left: 4px; }
.filter-chip:not(.active) .filter-count { background: var(--surface-3); color: var(--text-muted); }

.sort-buttons-bar, .sort-controls { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); margin-bottom: var(--sp-4); }
.sort-btn { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: var(--sp-1) var(--sp-3); border-radius: var(--r-md); font-size: var(--fs-xs); cursor: pointer; transition: all 0.15s; display: inline-flex; align-items: center; gap: 4px; }
.sort-btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.sort-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.sort-btn.filter-btn { background: var(--success-bg); color: var(--success); border-color: rgba(52,211,153,0.3); }
.sort-btn.filter-btn:hover { background: var(--success); color: white; }

.trend-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); margin-top: var(--sp-6); }
.trend-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-4); flex-wrap: wrap; gap: var(--sp-3); }
.trend-header h2 { font-size: var(--fs-md); font-weight: 600; color: var(--text); display: inline-flex; align-items: center; gap: var(--sp-2); }
.trend-timeframe-btns { display: inline-flex; gap: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: 2px; }
.trend-timeframe-btn { background: transparent; border: none; color: var(--text-muted); padding: 4px 12px; border-radius: 6px; cursor: pointer; font-size: var(--fs-xs); transition: all 0.15s; }
.trend-timeframe-btn:hover { color: var(--text); }
.trend-timeframe-btn.active { background: var(--primary); color: white; }
.trend-chart-container { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-4); min-height: 260px; }
.trend-no-data { padding: var(--sp-8); text-align: center; color: var(--text-muted); }

.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 12px; font-size: var(--fs-xs); font-weight: 500; }
.status-healthy { background: rgba(52,211,153,0.15); color: var(--success); }
.status-partial { background: rgba(251,191,36,0.15); color: var(--warning); }
.status-warning { background: rgba(251,191,36,0.15); color: var(--warning); }
.status-unreachable { background: rgba(248,113,113,0.15); color: var(--danger); }
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.rating-star { color: var(--warning); cursor: pointer; transition: transform 0.1s; display: inline-block; }
.rating-star:hover { transform: scale(1.2); }

.price-cell, .speed-cell, .score-cell, .trend-cell, .tps-cell { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* === DRAG & DROP (Custom Sort) === */
.drag-handle-cell {
    transition: opacity 0.15s ease;
}
.drag-handle-cell:hover .drag-handle-icon {
    color: var(--primary);
}
.drag-handle-icon {
    transition: color 0.1s ease;
}
tbody tr[draggable="true"] {
    cursor: grab;
}
tbody tr.dragging {
    opacity: 0.4;
    background: rgba(99, 102, 241, 0.08) !important;
    cursor: grabbing;
}

.tps-cell { color: var(--text-1); font-weight: 500; }
.tps-cell .tps-unit { color: var(--text-3); font-size: 0.85em; margin-left: 1px; }
.tps-cell .tps-none { color: var(--text-3); font-style: italic; }

.link-arrow { color: var(--primary); text-decoration: none; font-size: var(--fs-sm); display: inline-flex; align-items: center; gap: 4px; }
.link-arrow:hover { text-decoration: underline; }

.section-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-4); }

.info-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--sp-3); margin-top: var(--sp-4); margin-bottom: var(--sp-4); }
.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); }
.info-card h3 { font-size: var(--fs-sm); font-weight: 600; color: var(--text); margin-bottom: var(--sp-1); display: inline-flex; align-items: center; gap: var(--sp-2); }
.info-card p { font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.6; }

.sparkline-cell { display: inline-flex; align-items: center; gap: 6px; }
.sparkline-canvas { display: block; }
.sparkline-summary { font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums; }
.sparkline-up { color: var(--success); }
.sparkline-down { color: var(--danger); }
.sparkline-flat { color: var(--text-muted); }

.compare-toggle-bar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4); display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }

.refresh-btn { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: var(--sp-2) var(--sp-4); border-radius: var(--r-md); cursor: pointer; font-size: var(--fs-sm); display: inline-flex; align-items: center; gap: var(--sp-2); transition: all 0.15s; }
.refresh-btn:hover { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); }

.trend-chart-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-4); min-height: 260px; color: var(--text); }
.trend-chart-card canvas { max-height: 320px; }
.trend-loading { padding: var(--sp-8); text-align: center; color: var(--text-muted); }

.row-preview-tooltip { position: fixed; top: 0; left: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); width: 320px; max-width: 90vw; z-index: 1500; box-shadow: var(--shadow-lg); pointer-events: none; opacity: 0; transform: translateY(4px); transition: opacity 0.15s, transform 0.15s; }
.row-preview-tooltip.visible { opacity: 1; transform: translateY(0); }
.row-preview-tooltip .preview-header { font-size: var(--fs-md); font-weight: 600; color: var(--text); margin-bottom: var(--sp-3); padding-bottom: var(--sp-2); border-bottom: 1px solid var(--border); }
.row-preview-tooltip .preview-grid { display: grid; gap: 6px; margin-bottom: var(--sp-3); }
.row-preview-tooltip .preview-row { display: flex; justify-content: space-between; align-items: center; font-size: var(--fs-xs); gap: var(--sp-2); }
.row-preview-tooltip .preview-row span { color: var(--text-muted); display: inline-flex; align-items: center; gap: 4px; }
.row-preview-tooltip .preview-row strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.row-preview-tooltip .preview-healthy { color: var(--success); }
.row-preview-tooltip .preview-offline { color: var(--danger); }
.row-preview-tooltip .preview-sparkline-section { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.row-preview-tooltip .preview-sparkline-chart svg { display: block; width: 100%; height: 40px; }
.row-preview-tooltip .preview-sparkline-empty { padding: var(--sp-3); text-align: center; color: var(--text-muted); font-size: var(--fs-xs); }
.row-preview-tooltip .preview-hint { margin-top: var(--sp-3); padding-top: var(--sp-2); border-top: 1px solid var(--border); text-align: center; color: var(--primary); font-size: var(--fs-xs); font-weight: 500; }

.wallet-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-5);
}
.topup-preset {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: var(--r-md);
    cursor: pointer;
    font-size: var(--fs-sm);
    font-weight: 600;
    transition: all 0.15s;
    flex: 1;
    min-width: 50px;
}
.topup-preset:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
@media (max-width: 700px) {
    .wallet-page > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
}

.docs-page { max-width: 900px; margin: 0 auto; padding: var(--sp-6) var(--sp-4); }
.docs-hero { padding: var(--sp-8) 0 var(--sp-6); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-6); }
.docs-hero h1 { font-size: var(--fs-3xl); font-weight: 700; color: var(--text); margin-bottom: var(--sp-2); display: inline-flex; align-items: center; gap: var(--sp-3); }
.docs-subtitle { color: var(--text-muted); font-size: var(--fs-md); }
.docs-toc { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-8); padding: var(--sp-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.docs-toc a { padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md); color: var(--text-muted); font-size: var(--fs-sm); transition: all 0.15s; }
.docs-toc a:hover { background: var(--surface-2); color: var(--text); }
.docs-section { margin-bottom: var(--sp-10); scroll-margin-top: 80px; }
.docs-section h2 { font-size: var(--fs-2xl); font-weight: 700; color: var(--text); margin-bottom: var(--sp-3); padding-bottom: var(--sp-2); border-bottom: 1px solid var(--border); }
.docs-section h3 { font-size: var(--fs-lg); font-weight: 600; color: var(--text); margin-top: var(--sp-4); margin-bottom: var(--sp-2); }
.docs-section p, .docs-section li { color: var(--text-muted); line-height: 1.7; font-size: var(--fs-sm); }
.docs-section strong { color: var(--text); font-weight: 600; }
.docs-section a { color: var(--primary); text-decoration: none; }
.docs-section a:hover { text-decoration: underline; text-underline-offset: 3px; }
.docs-section code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; color: var(--text); font-family: var(--font-mono); }
.docs-section ul, .docs-section ol { margin-left: var(--sp-5); margin-bottom: var(--sp-3); }
.docs-section li { margin-bottom: 6px; }
.docs-steps { counter-reset: step; list-style: none; padding-left: 0; }
.docs-steps > li { counter-increment: step; position: relative; padding-left: var(--sp-6); margin-bottom: var(--sp-3); }
.docs-steps > li::before { content: counter(step); position: absolute; left: -8px; top: -2px; background: var(--primary); color: white; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: var(--fs-xs); font-weight: 700; }
.docs-code { background: #0a0c10; border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3); overflow-x: auto; margin-bottom: var(--sp-3); }
.docs-code code { background: transparent; padding: 0; color: #c9d1d9; font-size: var(--fs-xs); line-height: 1.6; white-space: pre; display: block; }
.docs-faq { margin-bottom: var(--sp-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); }
.docs-faq summary { cursor: pointer; font-weight: 600; color: var(--text); padding: var(--sp-1) 0; user-select: none; }
.docs-faq summary:hover { color: var(--primary); }
.docs-faq[open] summary { margin-bottom: var(--sp-2); }
.docs-faq p { margin: 0; }

.alert-success { color: var(--success); background: var(--success-bg); border: 1px solid rgba(52,211,153,0.3); padding: var(--sp-3); border-radius: var(--r-md); }

.compare-toggle-bar { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); padding: var(--sp-3) var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.compare-info { font-size: var(--fs-sm); color: var(--text); display: inline-flex; align-items: center; gap: var(--sp-2); }
.compare-count { background: var(--primary-bg); color: var(--primary); padding: 2px var(--sp-2); border-radius: 10px; font-size: var(--fs-xs); font-weight: 600; }
.compare-sticky-bar { position: fixed; bottom: var(--sp-6); left: 50%; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: var(--sp-3); z-index: 200; }
.compare-drawer { position: fixed; top: 0; right: 0; width: 600px; max-width: 100vw; height: 100vh; background: var(--surface); border-left: 1px solid var(--border); z-index: 300; overflow-y: auto; box-shadow: var(--shadow-lg); display: none; }
.compare-drawer.open, .compare-drawer.visible { display: block; }
.compare-drawer-content { padding: var(--sp-6); }

.leaderboard-table, .compare-table, .data-table {
    width: 100%; border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    font-size: var(--fs-sm);
}
.leaderboard-table thead, .compare-table thead, .data-table thead {
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.leaderboard-table th, .compare-table th, .data-table th {
    text-align: left; padding: var(--sp-3) var(--sp-4);
    font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
}
.leaderboard-table td, .compare-table td, .data-table td {
    padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); color: var(--text);
}
.leaderboard-table tbody tr, .compare-table tbody tr, .data-table tbody tr { transition: background 0.1s; }
.leaderboard-table tbody tr:hover, .compare-table tbody tr:hover, .data-table tbody tr:hover { background: var(--surface-2); }
.leaderboard-table tbody tr:last-child td, .compare-table tbody tr:last-child td, .data-table tbody tr:last-child td { border-bottom: none; }

.provider-name-cell { display: flex; flex-direction: column; gap: 2px; }
.provider-detail-btn { background: transparent; border: none; cursor: pointer; padding: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--text); text-align: left; text-decoration: none; transition: color 0.15s; }
.provider-detail-btn:hover { color: var(--primary); text-decoration: underline; text-decoration-color: var(--primary); text-underline-offset: 3px; }
.provider-model { font-size: var(--fs-xs); color: var(--text-muted); font-family: var(--font-mono); }

.provider-rating-cell { display: inline-flex; gap: 2px; align-items: center; }
.provider-favorite-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: var(--sp-1); transition: color 0.15s; }
.provider-favorite-btn:hover { color: var(--warning); }
.provider-favorite-btn.active { color: var(--warning); }

.compare-row-btn { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: var(--sp-1) var(--sp-3); border-radius: var(--r-md); cursor: pointer; font-size: var(--fs-xs); transition: all 0.15s; }
.compare-row-btn:hover { background: var(--primary-bg); color: var(--primary); border-color: var(--primary-border); }
.compare-row-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.compare-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); margin-top: var(--sp-6); }
.compare-section:not(.visible) { display: none; }
.compare-header { margin-bottom: var(--sp-4); display: flex; justify-content: space-between; align-items: center; }
.compare-header h2 { font-size: var(--fs-lg); font-weight: 600; }

.compare-chip { display: inline-flex; align-items: center; gap: var(--sp-2); background: var(--surface-2); border: 1px solid var(--border); padding: var(--sp-1) var(--sp-3); border-radius: 16px; font-size: var(--fs-xs); }
.compare-chip-remove { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0; line-height: 1; }
.compare-chip-remove:hover { color: var(--danger); }

/* Health & Detail Modals */
.health-modal-overlay, .rating-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 8000; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.health-modal-overlay.visible, .rating-modal-overlay.visible { display: flex; opacity: 1; pointer-events: auto; }
.health-modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: var(--sp-6); max-width: 800px; width: 90%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); position: relative; }
.health-modal-close { position: absolute; top: var(--sp-4); right: var(--sp-4); background: var(--surface-2); border: 1px solid var(--border); width: 32px; height: 32px; border-radius: var(--r-md); color: var(--text-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.health-modal-close:hover { background: var(--surface-3); color: var(--text); }
.health-modal h2 { font-size: var(--fs-lg); font-weight: 600; margin-bottom: var(--sp-2); }
.provider-meta { font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: var(--sp-4); }
.health-stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); margin-bottom: var(--sp-4); }
.health-stat-box { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-4); text-align: center; }
.health-stat-value { display: block; font-size: var(--fs-xl); font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; margin-bottom: 4px; }
.health-stat-label { font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.health-chart-container { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-4); min-height: 220px; display: flex; align-items: center; justify-content: center; }
.health-loading { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--text-muted); font-size: var(--fs-sm); }
.health-no-data { padding: var(--sp-6); text-align: center; color: var(--text-muted); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.no-results-msg, .empty-msg { text-align: center; padding: var(--sp-12) var(--sp-6); color: var(--text-muted); }

/* Host Dashboard / Provider Detail / Generic Pages */
.host-page, .profile-page, .api-keys-page, .chat-page, .provider-detail-page { max-width: var(--container-w); margin: 0 auto; padding: var(--sp-6); }
.host-header, .profile-header, .chat-header-page, .page-header-default { margin-bottom: var(--sp-6); }
.host-header h1, .profile-header h1, .chat-header-page h1 { font-size: var(--fs-2xl); font-weight: 700; color: var(--text); letter-spacing: -0.02em; margin-bottom: var(--sp-1); display: flex; align-items: center; gap: var(--sp-2); }

.card-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); margin-bottom: var(--sp-5); }
.card-section h2 { font-size: var(--fs-md); font-weight: 600; color: var(--text); margin-bottom: var(--sp-4); display: flex; align-items: center; gap: var(--sp-2); }
.card-section p { color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.6; }

.stat-mini-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-4); }
.stat-mini { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-4); }
.stat-mini-label { font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; margin-bottom: 4px; }
.stat-mini-value { font-size: var(--fs-xl); font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* Forms / Buttons in legacy templates */
.btn-primary, .btn-secondary, .btn-ghost, .btn-danger { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-4); border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; transition: all 0.15s; text-decoration: none; border: 1px solid var(--border); line-height: 1.2; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text); }

/* Edit-Provider button — neutral surface, primary-tinted border on hover */
.btn-edit { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-edit:hover { background: var(--surface-3); border-color: var(--primary); color: var(--primary); }

/* Modal overlay + box used for the Edit-Provider dialog */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: var(--sp-4); }
.modal-box { background: var(--surface-1, #15181d); border: 1px solid var(--border); border-radius: var(--r-lg, 8px); padding: var(--sp-5); max-width: 520px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,0.4); }
.modal-box h2 { margin-top: 0; }
.modal-box label { display: block; font-size: var(--fs-sm); color: var(--text-muted); margin-top: var(--sp-3); margin-bottom: 4px; }
.modal-box input { width: 100%; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; color: var(--text); font: inherit; }
.modal-box input:focus { outline: none; border-color: var(--primary); }

.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(248,113,113,0.3); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-sm { padding: 4px var(--sp-3); font-size: var(--fs-xs); }
.btn-block { width: 100%; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], textarea, select {
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    padding: var(--sp-3); border-radius: var(--r-md); font-size: var(--fs-sm); width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
input::placeholder, textarea::placeholder { color: var(--text-subtle); }

.alert { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); margin-bottom: var(--sp-4); font-size: var(--fs-sm); }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(248,113,113,0.3); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(52,211,153,0.3); }
.alert-info { background: var(--primary-bg); color: var(--primary); border: 1px solid var(--primary-border); }

.help-icon, .icon-only-btn { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); cursor: pointer; padding: var(--sp-1) var(--sp-2); border-radius: var(--r-md); }
.help-icon:hover { background: var(--surface-3); color: var(--text); }

/* Empty States Generic */
.empty-state-row { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--r-lg); padding: var(--sp-12) var(--sp-6); text-align: center; }
.empty-state-row h3 { font-size: var(--fs-md); font-weight: 600; color: var(--text); margin-bottom: var(--sp-1); }
.empty-state-row p { color: var(--text-muted); font-size: var(--fs-sm); }

/* Code blocks (pre/code) */
pre { background: #0a0d12; border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3); font-family: var(--font-mono); font-size: 0.8125rem; color: #d4d4d4; overflow-x: auto; }
code { font-family: var(--font-mono); font-size: 0.875em; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; color: var(--text); }
pre code { background: transparent; padding: 0; color: inherit; }

/* Footer */
.footer { margin-top: var(--sp-12); padding: var(--sp-8) var(--sp-6); border-top: 1px solid var(--border); color: var(--text-subtle); font-size: var(--fs-xs); text-align: center; }

/* Tab navigation */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: var(--sp-5); }
.tab { padding: var(--sp-3) var(--sp-4); cursor: pointer; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 500; border-bottom: 2px solid transparent; transition: all 0.15s; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Onboarding Tour (legacy) */
.onboarding-tooltip, .tour-tooltip { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); box-shadow: var(--shadow-lg); max-width: 320px; }
.onboarding-tooltip h3, .tour-tooltip h3 { font-size: var(--fs-sm); font-weight: 600; color: var(--text); margin-bottom: var(--sp-1); }
.onboarding-tooltip p, .tour-tooltip p { font-size: var(--fs-xs); color: var(--text-muted); }