/* ═══════════════════════════════════════════════════════════
   MaxAI Dashboard - Layout & Components (Responsive)
   ═══════════════════════════════════════════════════════════ */

.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

/* ─── Theme Variables ────────────────────────────────────── */

[data-theme="light"] {
    --bg: #f8f9fa;
    --bg-card: #ffffff;
    --bg-input: #f1f3f5;
    --border: #dee2e6;
    --text: #212529;
    --text-muted: #6c757d;
    --text-dim: #adb5bd;
    --primary-glow: rgba(99, 102, 241, 0.1);
}

/* ─── Sidebar ────────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 50;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }

.nav-item.active { background: var(--primary-glow); color: var(--primary-hover); }

[data-theme="light"] .nav-item:hover { background: rgba(99, 102, 241, 0.08); }

.nav-icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    min-width: 18px;
    text-align: center;
    line-height: 1.3;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-footer-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.sidebar-footer-actions .btn-block {
    flex: 1;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

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

.user-name { font-size: 14px; font-weight: 600; }
.user-tier { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

/* ─── Theme Toggle ───────────────────────────────────────── */

.theme-toggle-btn {
    width: 36px;
    height: 36px;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.topbar-icon-btn {
    position: relative;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 6px 10px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-icon-btn:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: var(--text);
}

.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 999px;
    min-width: 16px;
    text-align: center;
    line-height: 1.4;
}

/* ─── Main Content ───────────────────────────────────────── */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 40;
    min-height: var(--topbar-height);
    gap: 12px;
    flex-wrap: wrap;
}

[data-theme="light"] .topbar {
    background: rgba(248, 249, 250, 0.9);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.sidebar-toggle:hover { background: rgba(255,255,255,0.1); }

.page-title { font-size: 20px; font-weight: 700; }

.last-updated {
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.balance-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--primary-glow);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-hover);
    white-space: nowrap;
}

.content-area { padding: 32px; }

/* ─── Pages ──────────────────────────────────────────────── */

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@keyframes pulse-update {
    0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(99, 102, 241, 0); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.stat-card.updated {
    animation: pulse-update 0.6s ease;
}

.page-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    align-items: center;
}

/* ─── Search Input ───────────────────────────────────────── */

.search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 320px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    pointer-events: none;
    z-index: 1;
}

.search-input {
    padding-left: 36px !important;
}

/* ─── Date Range Picker ──────────────────────────────────── */

.date-range-picker {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-input {
    width: 150px;
    font-size: 13px;
}

.date-separator {
    color: var(--text-muted);
    font-size: 13px;
}

/* ─── Stats Grid ─────────────────────────────────────────── */

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

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

.stat-icon { font-size: 28px; flex-shrink: 0; }

.stat-info { min-width: 0; }

.stat-info .stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-info .stat-value {
    font-size: 24px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Cards ──────────────────────────────────────────────── */

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 8px;
}

.card-header h3 { font-size: 16px; font-weight: 600; }

.card-body { padding: 20px; }

/* ─── Grids ──────────────────────────────────────────────── */

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.mt-2 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }

/* ─── API Keys ───────────────────────────────────────────── */

.keys-grid { display: grid; gap: 16px; }

.key-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
    flex-wrap: wrap;
}

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

.key-card-icon { font-size: 28px; flex-shrink: 0; }

.key-card-info { flex: 1; min-width: 150px; }

.key-card-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.key-card-prefix {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--text-muted);
}

.key-card-stats {
    display: flex;
    gap: 24px;
    font-size: 13px;
    color: var(--text-muted);
}

.key-card-stat { text-align: center; }

.key-card-stat .value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.key-card-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.key-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.key-status.active { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.key-status.inactive { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* ─── Config ─────────────────────────────────────────────── */

.config-grid { display: grid; gap: 16px; }

.config-item label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.copy-field {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #0d1117;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    overflow: hidden;
}

[data-theme="light"] .copy-field {
    background: #f1f3f5;
}

.copy-field code {
    flex: 1;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--success);
    overflow-x: auto;
    white-space: nowrap;
}

/* ─── Models ─────────────────────────────────────────────── */

.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.model-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
}

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

.model-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 8px;
}

.model-name {
    font-size: 14px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-provider {
    font-size: 12px;
    padding: 2px 8px;
    background: var(--primary-glow);
    color: var(--primary-hover);
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
}

.model-pricing {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.model-pricing .price { font-weight: 600; color: var(--text); }
/* --- Models Table (SumoPod style) --- */

.models-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.models-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    background: var(--bg-input);
    position: sticky;
    top: 0;
    z-index: 1;
}

.models-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.models-table th.sortable:hover {
    color: var(--primary-hover);
}

.models-table th.sortable .sort-icon {
    margin-left: 4px;
    font-size: 10px;
    opacity: 0.4;
    display: inline-block;
}

.models-table th.sortable.asc .sort-icon,
.models-table th.sortable.desc .sort-icon {
    opacity: 1;
    color: var(--primary-hover);
}

.models-table th.sortable.asc .sort-icon { font-size: 0; }
.models-table th.sortable.asc .sort-icon::after { content: '▲'; font-size: 10px; }
.models-table th.sortable.desc .sort-icon { font-size: 0; }
.models-table th.sortable.desc .sort-icon::after { content: '▼'; font-size: 10px; }

.models-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    vertical-align: middle;
}

.models-table tbody tr {
    transition: background 0.15s;
}

.models-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

[data-theme="light"] .models-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.04);
}

.models-table .model-name-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 500;
}

.type-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.type-badge.chat { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.type-badge.embedding { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.type-badge.vision { background: rgba(236, 72, 153, 0.15); color: #ec4899; }
.type-badge.audio { background: rgba(234, 179, 8, 0.15); color: #eab308; }
.type-badge.image { background: rgba(168, 85, 247, 0.15); color: #a855f7; }

.provider-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.provider-badge.openai { background: rgba(156, 163, 175, 0.2); color: #9ca3af; }
.provider-badge.anthropic { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.provider-badge.google, .provider-badge.gemini { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.provider-badge.deepseek { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.provider-badge.alibaba { background: rgba(168, 85, 247, 0.2); color: #a855f7; }
.provider-badge.mimo { background: rgba(236, 72, 153, 0.2); color: #ec4899; }
.provider-badge.byteplus { background: rgba(6, 182, 212, 0.2); color: #06b6d4; }
.provider-badge.zai, .provider-badge.z\.ai { background: rgba(20, 184, 166, 0.2); color: #14b8a6; }
.provider-badge.minimax { background: rgba(244, 63, 94, 0.2); color: #f43f5e; }
.provider-badge.moonshot { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.provider-badge.maxai { background: var(--primary-glow); color: var(--primary-hover); }

.discount-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    margin-left: 6px;
}

/* --- Provider Filter Dropdown --- */

.model-filter-dropdown {
    position: relative;
}

.filter-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-count {
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 999px;
    min-width: 16px;
    text-align: center;
}

.filter-toggle .chevron {
    font-size: 10px;
    transition: transform 0.2s;
}

.filter-panel {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 220px;
    max-height: 320px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 100;
    overflow: hidden;
}

.filter-panel.open {
    display: block;
    animation: fadeIn 0.15s ease;
}

.filter-panel-header {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.filter-checkboxes {
    max-height: 250px;
    overflow-y: auto;
    padding: 8px 12px;
}

.filter-checkboxes label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
    cursor: pointer;
}

.filter-checkboxes input[type="checkbox"] {
    accent-color: var(--primary);
}

/* --- Chat Playground --- */

.chat-playground {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    min-height: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-input);
    gap: 12px;
    flex-wrap: wrap;
}

.chat-model-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-model-selector label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.chat-model-selector .select {
    min-width: 250px;
    font-size: 13px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-dim);
    gap: 8px;
}

.chat-welcome-icon { font-size: 48px; margin-bottom: 8px; }
.chat-welcome h3 { color: var(--text); font-size: 20px; }
.chat-welcome p { font-size: 14px; max-width: 400px; line-height: 1.5; }

.chat-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-bubble.user {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-bubble.assistant {
    align-self: flex-start;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    color: var(--text);
}

.chat-bubble-meta {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 6px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.chat-bubble.user .chat-bubble-meta { color: rgba(255,255,255,0.6); }

.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-input);
}

.chat-input {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus { border-color: var(--primary); }
.chat-input::placeholder { color: var(--text-dim); }

.chat-send-btn {
    width: 42px;
    height: 42px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: var(--radius);
}

.chat-send-btn .send-icon { font-size: 16px; }

.chat-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    color: var(--text-muted);
    font-size: 14px;
}

.chat-loading .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* --- Key Budget Bar --- */

.budget-section { margin-top: 8px; }

.budget-bar-container {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}

.budget-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.budget-bar.warning { background: var(--warning); }
.budget-bar.danger { background: var(--danger); }

.budget-text {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 2px;
}

/* --- Billing --- */
/* ─── Billing ────────────────────────────────────────────── */

.balance-display { text-align: center; padding: 32px 0; }

.balance-amount {
    font-size: 48px;
    font-weight: 800;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.balance-label { font-size: 14px; color: var(--text-muted); margin-top: 8px; }

.topup-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.plan-info { text-align: center; }

.plan-name { font-size: 28px; font-weight: 700; margin-bottom: 24px; }

.plan-quota { text-align: left; }

.quota-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    gap: 8px;
}

.quota-item span:first-child { color: var(--text-muted); }
.quota-item span:last-child { font-weight: 600; text-align: right; }

/* ─── Coupon ─────────────────────────────────────────────── */

.coupon-result {
    margin-top: 8px;
    font-size: 13px;
    min-height: 20px;
}

.coupon-result.success { color: var(--success); }
.coupon-result.error { color: var(--danger); }

/* ─── Referral Section ───────────────────────────────────── */

.referral-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.referral-section label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.referral-stats {
    display: flex;
    gap: 32px;
    justify-content: center;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.referral-stat { text-align: center; }

.referral-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-hover);
}

.referral-stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ─── Invoice Card ───────────────────────────────────────── */

.invoice-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    gap: 12px;
    flex-wrap: wrap;
}

.invoice-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.invoice-id {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 500;
}

.invoice-date {
    font-size: 12px;
    color: var(--text-muted);
}

.invoice-amount {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-hover);
}

.invoice-actions {
    display: flex;
    gap: 8px;
}

/* ─── Notifications ──────────────────────────────────────── */

.notifications-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    cursor: pointer;
    border: 1px solid transparent;
}

.notification-item:hover {
    background: rgba(255, 255, 255, 0.02);
    border-color: var(--border);
}

.notification-item.unread {
    background: var(--primary-glow);
    border-color: rgba(99, 102, 241, 0.15);
}

.notification-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border-radius: 50%;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.notification-body {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

.notification-time {
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
    flex-shrink: 0;
}

.notification-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
    margin-top: 6px;
}

.notification-item.read .notification-dot {
    visibility: hidden;
}

/* ─── Security / 2FA ─────────────────────────────────────── */

.tfa-qr-container {
    text-align: center;
    padding: 20px;
    background: #fff;
    border-radius: var(--radius);
    display: inline-block;
    margin: 0 auto 16px;
    width: 100%;
    max-width: 280px;
}

.tfa-qr-img {
    width: 200px;
    height: 200px;
    display: block;
    margin: 0 auto;
}

.text-success { color: var(--success); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }

.model-scopes-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 250px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.model-scope-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    font-size: 13px;
}

.model-scope-item input[type="checkbox"] {
    accent-color: var(--primary);
    flex-shrink: 0;
}

.model-scope-item label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── Pagination ─────────────────────────────────────────── */

.pagination-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px 0;
    flex-wrap: wrap;
}

.pagination-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    min-width: 36px;
    text-align: center;
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--primary);
    background: var(--primary-glow);
    color: var(--primary-hover);
}

.pagination-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
    padding: 0 8px;
}

/* ─── Onboarding Modal ───────────────────────────────────── */

.onboarding-modal {
    max-width: 520px;
    text-align: center;
}

.onboarding-step {
    display: none;
}

.onboarding-step.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.onboarding-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.onboarding-step h2 {
    font-size: 24px;
    margin-bottom: 12px;
}

.onboarding-step p {
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 24px;
}

.onboarding-steps-indicator {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 24px;
}

.step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    transition: var(--transition);
}

.step-dot.active {
    background: var(--primary);
    width: 24px;
    border-radius: 5px;
}

.step-dot.completed {
    background: var(--success);
}

/* ─── Tables ─────────────────────────────────────────────── */

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-container table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

.table-container th,
.table-container td {
    padding: 10px 14px;
    text-align: left;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.table-container th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.table-container tr:hover { background: rgba(255, 255, 255, 0.02); }

[data-theme="light"] .table-container tr:hover { background: rgba(0, 0, 0, 0.02); }

/* ─── Activity List ──────────────────────────────────────── */

.activity-list { max-height: 300px; overflow-y: auto; }

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    flex-wrap: wrap;
}

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

.activity-model {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    padding: 2px 6px;
    background: var(--bg-input);
    border-radius: 4px;
}

.activity-time { margin-left: auto; color: var(--text-dim); font-size: 12px; }

/* ─── Docs Links ─────────────────────────────────────────── */

.docs-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.doc-item {
    padding: 16px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.doc-item h4 { font-size: 14px; margin-bottom: 8px; }

.doc-item code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--success);
    word-break: break-all;
}

/* ─── Danger Zone ────────────────────────────────────────── */

.danger-zone { border-color: var(--danger) !important; }
.danger-zone .card-header { border-color: rgba(239, 68, 68, 0.3); }
.danger-zone p { color: var(--text-muted); margin-bottom: 16px; font-size: 14px; }

/* ─── Empty & Loading States ─────────────────────────────── */

.empty-state { text-align: center; padding: 40px; color: var(--text-dim); font-size: 14px; }
.loading-state { text-align: center; padding: 40px; color: var(--text-dim); }

/* ─── Chart ──────────────────────────────────────────────── */

.chart-container { position: relative; height: 300px; width: 100%; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════ */

/* Tablet (768px - 1023px) */
@media (max-width: 1023px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .docs-links { grid-template-columns: 1fr; }

    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .sidebar-overlay { display: none; }
    .sidebar-overlay.active { display: block; }
}

/* Mobile (< 768px) */
@media (max-width: 767px) {
    .content-area { padding: 20px 16px; }
    .topbar { padding: 12px 16px; }
    .page-title { font-size: 17px; }

    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; gap: 10px; }
    .stat-icon { font-size: 22px; }
    .stat-info .stat-value { font-size: 18px; }

    .key-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .key-card-stats { flex-wrap: wrap; gap: 16px; }
    .key-card-actions { width: 100%; }
    .key-card-actions .btn { flex: 1; }

    .balance-amount { font-size: 36px; }
    .topup-actions { gap: 6px; }
    .topup-actions .btn { flex: 1; min-width: 60px; }

    .chart-container { height: 220px; }

    .page-actions { flex-direction: column; }
    .page-actions .select { width: 100%; }
    .page-actions .input { width: 100%; }

    .models-grid { grid-template-columns: 1fr; }

    .card-body { padding: 16px; }

    .copy-field { flex-direction: column; align-items: stretch; }
    .copy-field code { font-size: 11px; }
    .copy-field .btn { align-self: flex-end; }

    .quota-item { flex-direction: column; gap: 2px; }
    .quota-item span:last-child { text-align: left; }

    .date-range-picker {
        flex-wrap: wrap;
    }

    .date-input {
        width: 100%;
    }

    .topbar-right {
        gap: 8px;
    }

    .topbar-icon-btn {
        padding: 4px 8px;
        font-size: 16px;
    }

    .referral-stats {
        flex-direction: column;
        gap: 16px;
    }

    .invoice-card {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Small mobile (< 400px) */
@media (max-width: 399px) {
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card { flex-direction: row; }
    .balance-amount { font-size: 28px; }
    .plan-name { font-size: 22px; }
}
