:root {
      --bg-primary: #0b0f1a;
      --bg-secondary: #111827;
      --bg-card: #1a2235;
      --bg-hover: #243049;
      --border: #2a3a55;
      --text-primary: #e8edf5;
      --text-secondary: #8b9ab8;
      --accent: #3b82f6;
      --accent-glow: rgba(59, 130, 246, 0.3);
      --success: #10b981;
      --warning: #f59e0b;
      --error: #ef4444;
      --purple: #8b5cf6;
      --cyan: #06b6d4;
      --pink: #ec4899;
      --glass: rgba(26, 34, 53, 0.7);
    }
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
      background: var(--bg-primary);
      color: var(--text-primary);
      min-height: 100vh;
    }
    body::before {
      content: '';
      position: fixed; top: 0; left: 0; right: 0; bottom: 0;
      background:
        radial-gradient(ellipse at 20% 50%, rgba(59,130,246,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(6,182,212,0.05) 0%, transparent 50%);
      pointer-events: none; z-index: 0;
    }
    .header {
      background: var(--glass); border-bottom: 1px solid var(--border);
      padding: 14px 32px; display: flex; align-items: center; justify-content: space-between;
      position: sticky; top: 0; z-index: 100;
    }
    @media(min-width:769px){.header{backdrop-filter:blur(20px)}}
    .header-left { display: flex; align-items: center; gap: 14px; }
    .logo {
      padding: 8px 16px;
      background: linear-gradient(135deg, var(--accent), var(--purple), var(--cyan));
      border-radius: 8px; display: flex; align-items: center; justify-content: center;
      font-size: 14px; font-weight: 700; color: white;
      box-shadow: 0 2px 12px rgba(59,130,246,0.3);
      text-decoration: none; cursor: pointer; border: none;
      transition: all 0.2s;
    }
    .logo:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(59,130,246,0.4); }
    .header h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
    .header h1 span { background: linear-gradient(135deg, var(--accent), var(--cyan)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
    .header-right { display: flex; align-items: center; gap: 10px; }
    .status-badge {
      display: flex; align-items: center; gap: 6px;
      padding: 5px 14px; border-radius: 20px;
      background: rgba(16,185,129,0.12); border: 1px solid rgba(16,185,129,0.2);
      color: var(--success); font-size: 12px; font-weight: 600;
    }
    .status-dot {
      width: 7px; height: 7px; border-radius: 50%;
      background: var(--success); animation: pulse 2s infinite;
    }
    @keyframes pulse { 0%,100% { opacity:1; box-shadow:0 0 0 0 rgba(16,185,129,0.4); } 50% { opacity:0.8; box-shadow:0 0 0 6px rgba(16,185,129,0); } }
    .main { padding: 20px 32px; max-width: 1440px; margin: 0 auto; position: relative; z-index: 1; }
    .hero {
      background: linear-gradient(135deg, rgba(59,130,246,0.12) 0%, rgba(139,92,246,0.1) 40%, rgba(6,182,212,0.08) 100%);
      border: 1px solid rgba(59,130,246,0.15);
      border-radius: 20px; padding: 28px 32px; margin-bottom: 20px;
      position: relative; overflow: hidden;
    }
    .hero::before {
      content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
      background: radial-gradient(circle at 30% 50%, rgba(59,130,246,0.06) 0%, transparent 50%);
      animation: heroGlow 10s ease-in-out infinite;
    }
    @keyframes heroGlow { 0%,100% { transform: translate(0,0); } 50% { transform: translate(5%,3%); } }
    .hero-content { position: relative; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 20px; }
    .hero-text h2 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
    .hero-text p { color: var(--text-secondary); font-size: 13px; line-height: 1.6; }
    .hero-text .badges { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
    .hero-text .badge {
      padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600;
      background: rgba(59,130,246,0.12); color: var(--accent); border: 1px solid rgba(59,130,246,0.15);
    }
    .hero-text .badge.green { background: rgba(16,185,129,0.12); color: var(--success); border-color: rgba(16,185,129,0.15); }
    .hero-text .badge.purple { background: rgba(139,92,246,0.12); color: var(--purple); border-color: rgba(139,92,246,0.15); }
    .hero-stats { display: flex; gap: 24px; }
    .hero-stat { text-align: center; padding: 12px 20px; background: rgba(0,0,0,0.2); border-radius: 14px; min-width: 90px; }
    .hero-stat-val { font-size: 26px; font-weight: 800; background: linear-gradient(135deg, var(--accent), var(--cyan)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
    .hero-stat-label { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
    .stat-card {
      background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
      padding: 18px 20px; transition: border-color 0.25s, transform 0.25s, box-shadow 0.25s; position: relative; overflow: hidden;
    }
    .stat-card::before {
      content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
      background: linear-gradient(90deg, var(--accent), var(--purple));
      opacity: 0; transition: opacity 0.25s;
    }
    .stat-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 30px rgba(59,130,246,0.1); }
    .stat-card:hover::before { opacity: 1; }
    .stat-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; margin-bottom: 10px; }
    .stat-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
    .stat-value { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
    .stat-value.gradient { background: linear-gradient(135deg, var(--text-primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
    .stat-sub { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }
    .tabs {
      display: flex; gap: 3px; padding: 4px; background: var(--bg-secondary);
      border-radius: 12px; margin-bottom: 16px; border: 1px solid var(--border);
      overflow-x: auto;
    }
    .tab {
      padding: 9px 18px; border-radius: 9px; border: none;
      background: transparent; color: var(--text-secondary);
      font-size: 13px; font-weight: 500; cursor: pointer;
      transition: all 0.15s; white-space: nowrap;
    }
    .tab.active { background: var(--accent); color: white; box-shadow: 0 2px 10px rgba(59,130,246,0.3); }
    .tab:hover:not(.active) { color: var(--text-primary); background: var(--bg-hover); }
    .section {
      background: var(--bg-card); border: 1px solid var(--border);
      border-radius: 16px; margin-bottom: 16px; overflow: hidden;
    }
    .section-header {
      padding: 14px 20px; border-bottom: 1px solid var(--border);
      display: flex; align-items: center; justify-content: space-between;
    }
    .section-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
    .section-title .count { font-size: 11px; color: var(--text-secondary); background: var(--bg-primary); padding: 2px 8px; border-radius: 10px; }
    .section-body { padding: 16px 20px; }
    .providers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
    .providers-grid.list-view { grid-template-columns: 1fr; }
    .providers-grid.list-view .provider-card { flex-direction: row; }
    .providers-grid.list-view .provider-icon { width: 36px; height: 36px; font-size: 14px; }
    .providers-grid.list-view .provider-url { max-width: 300px; }
    .provider-card {
      background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 12px;
      padding: 14px 16px; display: flex; align-items: center; gap: 12px;
      transition: border-color 0.2s, background 0.2s; cursor: default;
    }
    .provider-card:hover { border-color: var(--accent); background: var(--bg-hover); }
    .provider-icon {
      width: 42px; height: 42px; border-radius: 10px;
      display: flex; align-items: center; justify-content: center;
      font-size: 16px; font-weight: 800; flex-shrink: 0;
    }
    .provider-info { flex: 1; min-width: 0; }
    .provider-name { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
    .provider-url { font-size: 10px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .provider-meta { display: flex; gap: 6px; align-items: center; margin-top: 5px; flex-wrap: wrap; }
    .tag { padding: 3px 8px; border-radius: 6px; font-size: 10px; font-weight: 600; }
    .tag-weight { background: var(--bg-primary); color: var(--text-secondary); }
    .tag-latency { background: rgba(6,182,212,0.1); color: var(--cyan); }
    .tag-failures { background: rgba(239,68,68,0.1); color: var(--error); }
    .provider-status { padding: 4px 10px; border-radius: 10px; font-size: 11px; font-weight: 700; flex-shrink: 0; }
    .provider-status.active { background: rgba(16,185,129,0.12); color: var(--success); }
    .provider-status.blocked { background: rgba(239,68,68,0.12); color: var(--error); }
    .provider-status.unhealthy { background: rgba(245,158,11,0.12); color: var(--warning); }
    .models-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
    .model-card {
      display: flex; align-items: center; gap: 8px; padding: 10px 14px;
      background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 10px;
      font-size: 12px; transition: border-color 0.15s, background 0.15s;
    }
    .no-transition, .no-transition * { transition: none !important; animation: none !important; }
    .model-card:hover { border-color: var(--accent); background: var(--bg-hover); }
    .model-free { background: rgba(16,185,129,0.15); color: var(--success); font-size: 9px; padding: 2px 6px; border-radius: 5px; font-weight: 700; }
    .model-paid { background: rgba(245,158,11,0.15); color: var(--warning); font-size: 9px; padding: 2px 6px; border-radius: 5px; font-weight: 700; }
    .model-provider-tag { font-size: 9px; padding: 2px 6px; border-radius: 4px; background: rgba(139,92,246,0.12); color: var(--purple); margin-left: auto; }
    .model-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
    .search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
    .search-bar input {
      flex: 1; background: var(--bg-primary); border: 1px solid var(--border);
      border-radius: 8px; color: var(--text-primary); padding: 8px 12px;
      font-size: 12px; outline: none;
    }
    .search-bar input:focus { border-color: var(--accent); }
    .logs-table { width: 100%; border-collapse: collapse; }
    .logs-table th {
      text-align: left; padding: 10px 12px; font-size: 11px; font-weight: 700;
      color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px;
      border-bottom: 1px solid var(--border); background: var(--bg-secondary);
    }
    .logs-table td { padding: 9px 12px; font-size: 12px; border-bottom: 1px solid rgba(42,58,85,0.4); }
    .logs-table tr:hover td { background: var(--bg-hover); }
    .log-status { padding: 3px 8px; border-radius: 6px; font-size: 10px; font-weight: 700; }
    .log-status.success { background: rgba(16,185,129,0.12); color: var(--success); }
    .log-status.error { background: rgba(239,68,68,0.12); color: var(--error); }
    .log-status.streaming { background: rgba(139,92,246,0.12); color: var(--purple); }
    .log-provider { padding: 3px 8px; border-radius: 6px; font-size: 10px; font-weight: 600; background: rgba(59,130,246,0.12); color: var(--accent); }
    .playground { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
    .playground-input, .playground-output {
      background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
    }
    .playground textarea {
      width: 100%; min-height: 100px; background: var(--bg-primary);
      border: 1px solid var(--border); border-radius: 8px; color: var(--text-primary);
      padding: 10px; font-family: 'JetBrains Mono','Fira Code',monospace;
      font-size: 12px; resize: vertical; outline: none;
    }
    .playground textarea:focus { border-color: var(--accent); }
    .playground select, .playground input[type="text"] {
      width: 100%; background: var(--bg-primary); border: 1px solid var(--border);
      border-radius: 8px; color: var(--text-primary); padding: 8px 10px;
      font-size: 12px; outline: none; margin-bottom: 10px;
    }
    .playground select:focus, .playground input:focus { border-color: var(--accent); }
    .playground label { font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; display: block; font-weight: 600; }
    .btn {
      padding: 8px 18px; border-radius: 8px; border: none;
      font-size: 12px; font-weight: 700; cursor: pointer; transition: all 0.15s;
    }
    .btn-primary { background: linear-gradient(135deg, var(--accent), var(--purple)); color: white; }
    .btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 15px rgba(59,130,246,0.3); }
    .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
    .btn-secondary { background: var(--bg-hover); color: var(--text-primary); border: 1px solid var(--border); }
    .btn-secondary:hover { border-color: var(--accent); }
    .btn-danger { background: rgba(239,68,68,0.12); color: var(--error); }
    .btn-danger:hover { background: rgba(239,68,68,0.2); }
    .btn-success { background: rgba(16,185,129,0.12); color: var(--success); }
    .btn-sm { padding: 5px 10px; font-size: 11px; }
    .btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
    .btn-outline:hover { border-color: var(--accent); color: var(--text-primary); }
    .output-area {
      background: var(--bg-primary); border: 1px solid var(--border); border-radius: 8px;
      padding: 10px; min-height: 100px; font-family: 'JetBrains Mono','Fira Code',monospace;
      font-size: 12px; white-space: pre-wrap; word-break: break-all;
      max-height: 350px; overflow-y: auto;
    }
    .guide-card {
      background: var(--bg-secondary); border: 1px solid var(--border);
      border-radius: 10px; padding: 14px 16px; margin-bottom: 10px;
    }
    .guide-card h4 { font-size: 13px; margin-bottom: 6px; color: var(--accent); }
    .guide-card p { font-size: 12px; color: var(--text-secondary); line-height: 1.6; }
    .guide-card a { color: var(--accent); text-decoration: none; }
    .guide-card a:hover { text-decoration: underline; }
    .guide-card code { background: var(--bg-primary); padding: 2px 5px; border-radius: 4px; font-size: 11px; }
    .admin-login {
      background: var(--bg-card); border: 1px solid var(--border);
      border-radius: 16px; padding: 24px; max-width: 380px; margin: 40px auto; text-align: center;
    }
    .admin-login h3 { margin-bottom: 12px; }
    .admin-login input {
      width: 100%; background: var(--bg-primary); border: 1px solid var(--border);
      border-radius: 8px; color: var(--text-primary); padding: 10px;
      font-size: 13px; outline: none; margin-bottom: 10px; text-align: center;
    }
    .admin-login input:focus { border-color: var(--accent); }
    .key-row {
      display: flex; gap: 10px; align-items: center;
      background: var(--bg-secondary); border: 1px solid var(--border);
      border-radius: 10px; padding: 10px 14px;
    }
    .filter-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
    .filter-bar select, .filter-bar input {
      background: var(--bg-primary); border: 1px solid var(--border);
      border-radius: 6px; color: var(--text-primary); padding: 5px 8px;
      font-size: 11px; outline: none;
    }
    .filter-bar select:focus, .filter-bar input:focus { border-color: var(--accent); }
    .modal-overlay {
      position: fixed; top: 0; left: 0; right: 0; bottom: 0;
      background: rgba(0,0,0,0.6); display: none; align-items: center; justify-content: center;
      z-index: 1000;
    }
    .modal-overlay.show { display: flex; }
    .modal {
      background: var(--bg-card); border: 1px solid var(--border);
      border-radius: 16px; padding: 20px; width: 90%; max-width: 480px; max-height: 80vh; overflow-y: auto;
    }
    .modal h3 { margin-bottom: 14px; font-size: 16px; }
    .modal label { display: block; font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; font-weight: 600; }
    .modal input, .modal select {
      width: 100%; background: var(--bg-primary); border: 1px solid var(--border);
      border-radius: 8px; color: var(--text-primary); padding: 8px 10px;
      font-size: 12px; outline: none; margin-bottom: 10px;
    }
    .modal input:focus, .modal select:focus { border-color: var(--accent); }
    .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
    .toast {
      position: fixed; bottom: 20px; right: 20px;
      padding: 10px 18px; border-radius: 10px;
      font-size: 12px; font-weight: 600; z-index: 1000;
      animation: slideIn 0.3s ease; display: none;
    }
    .toast.show { display: block; }
    .toast.success { background: var(--success); color: white; }
    .toast.error { background: var(--error); color: white; }
    .toast.info { background: var(--accent); color: white; }
    @keyframes slideIn { from { transform: translateY(20px); opacity:0; } to { transform: translateY(0); opacity:1; } }

    /* User Dashboard Specific */
    .user-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
    .user-stat {
      background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 12px;
      padding: 16px; text-align: center; transition: all 0.2s;
    }
    .user-stat:hover { border-color: var(--accent); }
    .user-stat-icon { font-size: 20px; margin-bottom: 6px; }
    .user-stat-val { font-size: 22px; font-weight: 800; }
    .user-stat-label { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }
    .chart-container {
      background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 12px;
      padding: 16px; margin-bottom: 14px;
    }
    .chart-title { font-size: 13px; font-weight: 600; margin-top: 6px; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
    /* Layout fixes — external CSS overrides cached HTML inline styles */
    #modelDistChart { padding-top: 24px !important; min-height: 160px !important; }
    .bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 10px; }
    .bar-col { display: flex; flex-direction: column; align-items: center; flex: 1; height: 100%; justify-content: flex-end; }
    .bar {
      width: 100%; min-height: 4px; border-radius: 4px 4px 0 0;
      background: linear-gradient(180deg, var(--accent), var(--purple));
      transition: height 0.5s ease; position: relative;
    }
    .bar:hover { opacity: 0.85; }
    .bar-label { font-size: 9px; color: var(--text-secondary); margin-top: 6px; text-align: center; }
    .bar-value { font-size: 9px; color: var(--text-primary); margin-bottom: 2px; font-weight: 600; }
    .line-chart { position: relative; height: 100px; border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); margin: 10px 0; }
    .line-chart svg { width: 100%; height: 100%; }
    .suggestion-card {
      background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 10px;
      padding: 12px 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 10px;
      cursor: pointer; transition: all 0.15s;
    }
    .suggestion-card:hover { border-color: var(--accent); background: var(--bg-hover); }
    .suggestion-icon { font-size: 18px; }
    .suggestion-text { font-size: 12px; }
    .suggestion-text strong { display: block; margin-bottom: 2px; }
    .suggestion-text span { color: var(--text-secondary); font-size: 11px; }
    .perf-bar {
      height: 6px; background: var(--bg-primary); border-radius: 3px; overflow: hidden;
      margin-top: 6px;
    }
    .perf-bar-fill {
      height: 100%; border-radius: 3px; transition: width 0.6s ease;
    }
    .api-key-row {
      display: flex; align-items: center; gap: 8px; padding: 8px 12px;
      background: var(--bg-primary); border: 1px solid var(--border); border-radius: 8px;
      margin-bottom: 6px; font-size: 12px;
    }
    .api-key-row code { flex: 1; font-family: 'JetBrains Mono','Fira Code',monospace; color: var(--cyan); font-size: 11px; }
    .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

    @media (max-width: 768px) {
      .stats-grid { grid-template-columns: repeat(2, 1fr); }
      .user-grid { grid-template-columns: repeat(2, 1fr) !important; }
      .two-col { grid-template-columns: 1fr; }
      .playground { grid-template-columns: 1fr; }
      .main { padding: 12px; }
      .header { padding: 10px 14px; }
      .hero-content { flex-direction: column; }
      .hero-stats { width: 100%; justify-content: space-around; }
    }
    @media (max-width: 1200px) {
      .user-grid { grid-template-columns: repeat(3, 1fr) !important; }
    }
    ::-webkit-scrollbar { width: 5px; height: 5px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
    ::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }
