/* ============================================================
   TrustMemory Dashboard — Clean, modern dark theme
   ============================================================ */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161822;
    --bg-card: #1c1f2e;
    --bg-hover: #242738;
    --bg-input: #1a1d2b;

    --border: #2a2d3e;
    --border-light: #363950;

    --text-primary: #e8eaed;
    --text-secondary: #9ba1b0;
    --text-muted: #6b7280;

    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-bg: rgba(99, 102, 241, 0.1);

    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --sidebar-width: 240px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.4);
}

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

img {
    max-width: 100%;
    height: auto;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ---- Sidebar ---- */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

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

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

.logo-icon {
    color: var(--accent);
    font-size: 1.5rem;
}

.logo-icon-svg {
    height: 32px;
    width: auto;
    flex-shrink: 0;
}

.logo-text {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
}

.version {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 2px 6px;
    border-radius: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    min-height: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-bg);
    color: var(--accent);
}

.nav-icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s;
}

.status-dot.connected { background: var(--success); }
.status-dot.disconnected { background: var(--danger); }

/* ---- Main Content ---- */

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 1200px;
}

.page { display: none; }
.page.active { display: block; }

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.subtitle {
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-size: 0.9rem;
}

/* ---- Stats Grid ---- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---- Cards ---- */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.card-body {
    padding: 1rem 1.25rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* ---- Pools Grid ---- */

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

.pool-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pool-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.pool-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.pool-name {
    font-weight: 600;
    font-size: 1rem;
}

.pool-domain {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    background: var(--accent-bg);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 4px;
}

.pool-desc {
    font-size: 0.825rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pool-stats {
    display: flex;
    gap: 1.25rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.pool-stat-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* ---- Pool Detail ---- */

.pool-detail {
    max-width: 900px;
}

.btn-back {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
    transition: all 0.15s;
}

.btn-back:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.detail-item {
    font-size: 0.85rem;
}

.detail-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-value {
    font-weight: 500;
    margin-top: 0.15rem;
}

/* ---- Claims ---- */

.claim-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
}

.claim-statement {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.claim-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.claim-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.claim-status.validated { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.claim-status.pending_validation { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.claim-status.rejected { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.claim-status.disputed { background: rgba(59, 130, 246, 0.15); color: var(--info); }

.claim-tags {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    background: var(--bg-hover);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 3px;
}

/* ---- Confidence Bar ---- */

.confidence-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.confidence-track {
    flex: 1;
    height: 6px;
    background: var(--bg-hover);
    border-radius: 3px;
    overflow: hidden;
    max-width: 80px;
}

.confidence-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.confidence-fill.high { background: var(--success); }
.confidence-fill.medium { background: var(--warning); }
.confidence-fill.low { background: var(--danger); }

/* ---- Search ---- */

.search-container {
    margin-bottom: 2rem;
}

.search-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.search-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--accent);
}

.search-options {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    gap: 1rem;
    align-items: center;
}

.search-options input[type="range"] {
    width: 120px;
    accent-color: var(--accent);
    vertical-align: middle;
    margin: 0 0.5rem;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.search-result {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.search-result .statement {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.relevance-score {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 500;
}

/* ---- Agents ---- */

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

.agent-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.agent-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.agent-model {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.agent-trust {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 0.5rem;
}

.agent-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.agent-badges {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--accent-bg);
    color: var(--accent);
}

/* ---- Trust Badges ---- */

.trust-badges {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    margin-top: 0.6rem;
}

.trust-badge {
    font-size: 0.6rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 100px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
    line-height: 1.4;
}

.tb-bronze   { background: rgba(180, 83, 9, 0.12);  color: #d97706; border: 1px solid rgba(180, 83, 9, 0.2); }
.tb-silver   { background: rgba(156, 163, 175, 0.12); color: #9ca3af; border: 1px solid rgba(156, 163, 175, 0.2); }
.tb-gold     { background: rgba(245, 158, 11, 0.12); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.2); }
.tb-green    { background: rgba(74, 222, 128, 0.12); color: #4ade80; border: 1px solid rgba(74, 222, 128, 0.2); }
.tb-elite    { background: rgba(167, 139, 250, 0.12); color: #a78bfa; border: 1px solid rgba(167, 139, 250, 0.2); }
.tb-anchor   { background: rgba(56, 189, 248, 0.12); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.2); }
.tb-domain   { background: rgba(196, 181, 253, 0.12); color: #c4b5fd; border: 1px solid rgba(196, 181, 253, 0.2); }
.tb-verified { background: rgba(52, 211, 153, 0.12); color: #34d399; border: 1px solid rgba(52, 211, 153, 0.2); }
.tb-default  { background: var(--accent-bg); color: var(--accent); border: 1px solid var(--border); }

/* ---- Leaderboard ---- */

.leaderboard {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.leaderboard-row {
    display: grid;
    grid-template-columns: 50px 1fr 120px 100px;
    align-items: center;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    transition: background 0.15s;
}

.leaderboard-row:last-child {
    border-bottom: none;
}

.leaderboard-row:hover {
    background: var(--bg-hover);
}

.leaderboard-row.header {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rank {
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-muted);
}

.rank.top-3 {
    color: var(--warning);
}

.trust-score {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}

/* ---- Buttons ---- */

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.65rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

/* ---- Input ---- */

.input-field {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.input-field:focus {
    border-color: var(--accent);
}

.filters-bar {
    margin-bottom: 1.5rem;
}

/* ---- Pool List in Dashboard ---- */

.pool-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.pool-list-item:last-child {
    border-bottom: none;
}

.pool-list-name {
    font-weight: 500;
}

.pool-list-domain {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ---- Agent List in Dashboard ---- */

.agent-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.agent-list-item:last-child {
    border-bottom: none;
}

/* ---- Utility ---- */

.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-size: 0.85rem;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 1rem;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- User Info (Sidebar Footer) ---- */

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.user-info {
    padding: 0.5rem 0;
}

.user-email {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-tier {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
    margin-top: 3px;
}

.tier-free { background: rgba(99, 102, 241, 0.15); color: var(--accent); }
.tier-pro { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.tier-enterprise { background: rgba(34, 197, 94, 0.15); color: var(--success); }

.btn-signout {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.btn-signout:hover {
    border-color: var(--danger);
    color: var(--danger);
}

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

/* ---- Agent Management Buttons ---- */

.btn-small {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    font-family: inherit;
    transition: all 0.15s;
}

.btn-outline-small {
    background: none;
    color: var(--text-secondary);
}

.btn-outline-small:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-danger-small {
    background: none;
    color: var(--text-muted);
}

.btn-danger-small:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* ---- API Key Box ---- */

.api-key-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem 1rem;
}

.api-key-box code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--accent);
    word-break: break-all;
    flex: 1;
}

.btn-copy {
    background: var(--accent);
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

.btn-copy:hover {
    background: var(--accent-hover);
}

/* ---- Form (Agent Creation) ---- */

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

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

/* ---- My Agent Cards (dynamic) ---- */

.my-agent-card {
    margin-bottom: 1rem;
}

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

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

.my-agent-name {
    font-weight: 600;
    font-size: 1.05rem;
}

.my-agent-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.my-agent-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

.my-agent-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.my-agent-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---- Mobile Header (hidden on desktop) ---- */

.mobile-header {
    display: none;
}

.sidebar-overlay {
    display: none;
}

.hamburger {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transition: all 0.2s ease;
}

/* ---- Responsive ---- */

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* Mobile header — fixed top bar */
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 52px;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border);
        padding: 0 1rem;
        z-index: 200;
    }

    .mobile-header .logo {
        gap: 0.4rem;
    }

    .mobile-header .logo-icon-svg {
        height: 24px;
    }

    .mobile-header .logo-text {
        font-size: 0.95rem;
    }

    /* Sidebar — off-canvas drawer */
    .sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 300;
        top: 0;
        height: 100vh;
        height: 100dvh;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Overlay behind open sidebar */
    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 250;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* Main content — full width with top padding for header */
    .main-content {
        margin-left: 0;
        padding: 68px 1rem 1.5rem;
        max-width: 100%;
    }

    /* Page headers */
    .page-header h1 {
        font-size: 1.35rem;
    }

    .page-header {
        margin-bottom: 1.25rem;
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        margin-bottom: 1.25rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    /* Dashboard grid */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Pools grid */
    .pools-grid {
        grid-template-columns: 1fr;
    }

    .pool-card {
        padding: 1rem;
    }

    .pool-stats {
        flex-wrap: wrap;
        gap: 0.5rem 1rem;
    }

    /* Pool detail */
    .detail-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 1rem;
    }

    /* Agents grid */
    .agents-grid {
        grid-template-columns: 1fr;
    }

    .agent-card {
        padding: 1rem;
    }

    .agent-stats {
        grid-template-columns: 1fr 1fr;
        gap: 0.35rem;
        font-size: 0.75rem;
    }

    /* Leaderboard */
    .leaderboard-row {
        grid-template-columns: 36px 1fr 70px;
        padding: 0.75rem 0.75rem;
        font-size: 0.8rem;
    }

    .leaderboard-row.header span:last-child {
        display: none;
    }

    .leaderboard-row:not(.header) span:last-child {
        display: none;
    }

    /* Search */
    .search-bar {
        flex-direction: column;
        gap: 0.5rem;
    }

    .search-input {
        font-size: 0.9rem;
    }

    .search-options {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .search-result {
        padding: 1rem;
    }

    /* My Agents page header */
    #page-my-agents > .page-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch !important;
    }

    #page-my-agents > .page-header .btn-primary {
        align-self: flex-start;
    }

    /* Form */
    .form-row {
        grid-template-columns: 1fr;
    }

    /* API key box */
    .api-key-box {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .api-key-box code {
        font-size: 0.7rem;
    }

    /* My Agent cards */
    .my-agent-header {
        flex-direction: column;
    }

    .my-agent-actions {
        align-self: flex-start;
    }

    .my-agent-stats {
        gap: 0.35rem 1rem;
        font-size: 0.75rem;
    }

    /* Inputs full width */
    .input-field {
        width: 100%;
    }

    .filters-bar {
        margin-bottom: 1rem;
    }

    /* Claims */
    .claim-card {
        padding: 0.85rem 1rem;
    }

    .claim-meta {
        gap: 0.5rem 0.75rem;
    }

    /* Cards */
    .card-body {
        padding: 0.85rem 1rem;
    }

    .card-title {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 380px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .main-content {
        padding: 60px 0.75rem 1rem;
    }

    .leaderboard-row {
        grid-template-columns: 30px 1fr 60px;
        padding: 0.6rem;
        font-size: 0.75rem;
    }
}

/* ── Billing Page ─────────────────────────────────── */

.billing-plan-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: border-color 0.2s, transform 0.2s;
}
.billing-plan-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}
.billing-plan-card ul li {
    padding: 0.2rem 0;
}
.billing-plan-card ul li::before {
    content: "\2713 ";
    color: var(--success);
    margin-right: 0.3rem;
}

.payment-row {
    display: grid;
    grid-template-columns: 1fr 80px 90px 80px 100px;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    align-items: center;
}
.payment-row:last-child { border-bottom: none; }
.payment-row .payment-status {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    text-align: center;
    font-weight: 600;
}
.payment-status.finished { background: rgba(34,197,94,0.15); color: var(--success); }
.payment-status.waiting { background: rgba(245,158,11,0.15); color: var(--warning); }
.payment-status.expired, .payment-status.failed { background: rgba(239,68,68,0.15); color: var(--danger); }
.payment-status.confirming, .payment-status.confirmed { background: rgba(59,130,246,0.15); color: var(--info); }

.payment-header {
    display: grid;
    grid-template-columns: 1fr 80px 90px 80px 100px;
    gap: 0.75rem;
    padding: 0.5rem 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

@media (max-width: 768px) {
    .payment-row, .payment-header {
        grid-template-columns: 1fr 70px 80px;
    }
    .payment-row > :nth-child(4),
    .payment-row > :nth-child(5),
    .payment-header > :nth-child(4),
    .payment-header > :nth-child(5) {
        display: none;
    }
    .billing-plans-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 480px) {
    .payment-row, .payment-header {
        grid-template-columns: 1fr 65px;
        font-size: 0.75rem;
    }
    .payment-row > :nth-child(3),
    .payment-header > :nth-child(3) {
        display: none;
    }
    .support-resources-grid {
        grid-template-columns: 1fr;
    }
    .faq-question {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }
}

/* ── Support Page ──────────────────────────────────── */

.support-tier-banner {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
}

.support-tier-banner-content {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.support-tier-icon {
    font-size: 2rem;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-bg);
    border-radius: var(--radius);
}

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

.support-tier-label {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.support-tier-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.support-tier-upgrade {
    flex-shrink: 0;
}

/* Support Sections */

.support-section {
    margin-bottom: 2.5rem;
}

.support-section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.support-section-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

/* Channel Cards */

.support-channels-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.support-channel-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.15rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

.support-channel-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.support-channel-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    width: 40px;
    text-align: center;
}

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

.support-channel-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.support-channel-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    line-height: 1.4;
}

.support-channel-arrow {
    font-size: 1.1rem;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: color 0.2s, transform 0.2s;
}

.support-channel-card:hover .support-channel-arrow {
    color: var(--accent);
    transform: translateX(3px);
}

/* Support Form */

.support-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.support-form-row label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.support-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.support-input:focus {
    border-color: var(--accent);
}

.support-textarea {
    min-height: 140px;
    resize: vertical;
    line-height: 1.6;
}

select.support-input {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ba1b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

select.support-input option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.support-form-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.support-form-note {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Success message */

.support-success {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1.25rem;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-radius: var(--radius);
}

.support-success-icon {
    font-size: 1.25rem;
    color: var(--success);
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(34, 197, 94, 0.15);
    border-radius: 50%;
}

.support-success-text strong {
    color: var(--success);
    font-size: 0.9rem;
}

.support-success-text p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* FAQ */

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.faq-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.2s;
}

.faq-item[open] {
    border-color: var(--accent);
}

.faq-question {
    padding: 0.85rem 1.25rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    transition: color 0.2s;
    user-select: none;
}

.faq-question::-webkit-details-marker {
    display: none;
}

.faq-question::after {
    content: "+";
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.2s;
}

.faq-item[open] .faq-question::after {
    content: "\2212";
    color: var(--accent);
}

.faq-question:hover {
    color: var(--accent);
}

.faq-answer {
    padding: 0 1.25rem 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.65;
}

.faq-answer p {
    margin-bottom: 0.5rem;
}

.faq-answer p:last-child {
    margin-bottom: 0;
}

.faq-answer ul {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.faq-answer ul li {
    margin-bottom: 0.35rem;
}

.faq-answer a {
    color: var(--accent);
    text-decoration: none;
}

.faq-answer a:hover {
    text-decoration: underline;
}

/* Resources Grid */

.support-resources-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.support-resource-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

.support-resource-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.support-resource-icon {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
}

.support-resource-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.support-resource-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ── Support Page — Responsive ────────────────────── */

@media (max-width: 1024px) {
    .support-resources-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .support-tier-banner-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .support-tier-upgrade {
        align-self: stretch;
    }

    .support-tier-upgrade .btn-primary {
        width: 100%;
        text-align: center;
    }

    .support-channels-grid {
        grid-template-columns: 1fr;
    }

    .support-resources-grid {
        grid-template-columns: 1fr 1fr;
    }

    .support-form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .support-form-note {
        text-align: center;
    }
}

@media (max-width: 380px) {
    .support-resources-grid {
        grid-template-columns: 1fr;
    }

    .support-channel-card {
        padding: 0.85rem 1rem;
    }
}
