:root {
    --bg: #0a0a0a;
    --surface: #141414;
    --surface-hover: #1a1a1a;
    --border: #2a2a2a;
    --text: #e5e5e5;
    --text-dim: #888;
    --accent: #6366f1;
    --accent-dim: #4338ca;
    --green: #22c55e;
    --green-dim: #16a34a;
    --red: #ef4444;
    --yellow: #eab308;
    --code-bg: #1a1a2e;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --mono: 'SF Mono', 'Fira Code', monospace;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
    min-height: 100vh;
}

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-card .subtitle {
    color: var(--text-dim);
    margin-bottom: 32px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    gap: 8px;
}

.btn-primary {
    background: var(--accent);
    color: white;
    width: 100%;
}

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

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover { border-color: var(--text-dim); }

.error-msg {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--red);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

.error-msg.visible { display: block; }

/* Dashboard layout */
.app-header {
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    background: rgba(10, 10, 10, 0.92);
    backdrop-filter: blur(12px);
    z-index: 10;
}

.app-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 24px;
}

.header-left h1 {
    font-size: 16px;
    font-weight: 700;
}

.header-left .badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--accent-dim);
    color: white;
    font-weight: 500;
}

.header-nav {
    display: flex;
    gap: 8px;
}

.header-nav a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s;
}

.header-nav a:hover { color: var(--text); background: var(--surface); }
.header-nav a.active { color: var(--text); background: var(--surface); }

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-right .user {
    font-size: 13px;
    color: var(--text-dim);
}

.logout-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
}

.logout-btn:hover { color: var(--text); border-color: var(--text-dim); }

main.container {
    padding-top: 32px;
    padding-bottom: 48px;
}

/* Page title */
.page-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 24px;
}

/* Stat cards grid */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

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

.stat-card .label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

.stat-card .sub {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 6px;
}

.stat-card .value.green { color: var(--green); }
.stat-card .value.accent { color: var(--accent); }

/* Sparkline */
.sparkline {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 32px;
    margin-top: 8px;
}

.sparkline .bar {
    flex: 1;
    background: var(--accent);
    border-radius: 2px;
    min-height: 2px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.sparkline .bar:hover { opacity: 1; }

/* Section headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 16px;
    font-weight: 600;
}

/* Filter pills */
.filter-pills {
    display: flex;
    gap: 6px;
}

.filter-pills button {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
}

.filter-pills button:hover { border-color: var(--text-dim); color: var(--text); }
.filter-pills button.active { background: var(--accent-dim); border-color: var(--accent-dim); color: white; }

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.data-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 14px;
    font-size: 13px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
}

.data-table tr:hover td {
    background: var(--surface-hover);
}

.data-table .mono {
    font-family: var(--mono);
    font-size: 12px;
}

/* Status badges */
.status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status.approved { background: rgba(34, 197, 94, 0.12); color: var(--green); }
.status.rejected { background: rgba(239, 68, 68, 0.12); color: var(--red); }
.status.pending  { background: rgba(234, 179, 8, 0.12); color: var(--yellow); }

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.pagination .info {
    font-size: 12px;
    color: var(--text-dim);
}

.pagination .controls {
    display: flex;
    gap: 6px;
}

.pagination button {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) { border-color: var(--text-dim); color: var(--text); }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }

/* Card wrapper */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

/* Settings page */
.settings-card {
    max-width: 480px;
}

.settings-card h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
}

.success-msg {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: var(--green);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

.success-msg.visible { display: block; }

/* Loading state */
.loading {
    text-align: center;
    padding: 48px;
    color: var(--text-dim);
}

.loading::after {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

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

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-dim);
    font-size: 13px;
}

/* Agent avatar */
.agent-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-dim);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.agent-avatar.large {
    width: 48px;
    height: 48px;
    font-size: 18px;
}

/* Suspended status */
.status.suspended { background: rgba(234, 179, 8, 0.12); color: #f59e0b; }

/* Agent header */
.agent-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.agent-header-info {
    flex: 1;
}

.agent-header-info h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 2px;
}

.agent-header-info .developer {
    color: var(--text-dim);
    font-size: 13px;
}

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

/* Action buttons */
.action-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
    gap: 6px;
}

.action-btn:hover { border-color: var(--text-dim); }

.action-btn.approve { border-color: var(--green-dim); color: var(--green); }
.action-btn.approve:hover { background: rgba(34, 197, 94, 0.1); }

.action-btn.suspend { border-color: #d97706; color: #f59e0b; }
.action-btn.suspend:hover { background: rgba(245, 158, 11, 0.1); }

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

/* API key display */
.key-section {
    margin-top: 24px;
}

.key-display {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 8px;
}

.key-display code {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--text-dim);
    flex: 1;
}

/* Back link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
    margin-bottom: 16px;
    transition: color 0.2s;
}

.back-link:hover { color: var(--text); }

/* Leaderboard */
.leaderboard {
    list-style: none;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

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

.leaderboard-rank {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dim);
    min-width: 24px;
    text-align: center;
}

.leaderboard-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
}

.leaderboard-name a {
    color: var(--text);
    text-decoration: none;
}

.leaderboard-name a:hover { color: var(--accent); }

.leaderboard-stat {
    font-size: 13px;
    color: var(--text-dim);
    font-family: var(--mono);
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    max-width: 480px;
    width: 90%;
}

.modal h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.modal p {
    color: var(--text-dim);
    font-size: 13px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.modal .key-value {
    font-family: var(--mono);
    font-size: 12px;
    word-break: break-all;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 16px;
    user-select: all;
    cursor: text;
}

/* Agent name cell */
.agent-name-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.agent-name-cell a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}

.agent-name-cell a:hover { color: var(--accent); }

/* Click-through rows */
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover td { background: var(--surface-hover); }

/* Generation config */
.generation-config-card {
    max-width: 720px;
}

.config-subtitle {
    color: var(--text-dim);
    font-size: 13px;
    margin-bottom: 20px;
}

.config-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    font-family: var(--mono);
    line-height: 1.5;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.config-textarea:focus { border-color: var(--accent); }

.config-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s;
}

.config-select:focus { border-color: var(--accent); }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.form-hint {
    display: block;
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 6px;
    line-height: 1.5;
}

.form-hint code {
    font-family: var(--mono);
    font-size: 10px;
    background: var(--bg);
    padding: 1px 4px;
    border-radius: 3px;
    border: 1px solid var(--border);
}

.voice-fieldset {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.voice-fieldset legend {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
    padding: 0 8px;
}

.config-history {
    margin-top: 24px;
}

.config-history summary {
    cursor: pointer;
    font-size: 13px;
    color: var(--text-dim);
    padding: 8px 0;
}

.config-history summary:hover { color: var(--text); }

.config-history-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.config-history-item .version-id { font-family: var(--mono); }
.config-history-item .version-meta { display: flex; gap: 12px; }

.config-restore-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
}

.config-restore-btn:hover { color: var(--text); border-color: var(--text-dim); }

/* Toggle switch */
.toggle-switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle-switch input { display: none; }
.toggle-slider {
    width: 44px; height: 24px;
    background: var(--border); border-radius: 12px;
    position: relative; transition: background 0.2s;
}
.toggle-slider::after {
    content: ""; position: absolute;
    top: 3px; left: 3px; width: 18px; height: 18px;
    background: var(--text-dim); border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--green-dim); }
.toggle-switch input:checked + .toggle-slider::after { transform: translateX(20px); background: var(--green); }
.toggle-label { font-size: 13px; font-weight: 600; color: var(--text-dim); }

.reject-btn { background: none; border: 1px solid var(--red); color: var(--red); padding: 3px 10px; border-radius: 4px; font-size: 11px; cursor: pointer; }
.reject-btn:hover { background: var(--red); color: white; }

/* Copyable cells */
.copyable { cursor: pointer; user-select: all; }
.copyable:hover { color: var(--text); }

/* Superseded status badge */
.status.superseded { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }

/* Audio player button */
.play-btn {
    background: none;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
}
.play-btn:hover { background: var(--accent); color: white; }
.play-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.play-btn.playing { background: var(--accent); color: white; }

/* Inline audio player */
.audio-player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 50;
    font-size: 13px;
}

.audio-player-bar .player-label {
    color: var(--text-dim);
    font-size: 12px;
    white-space: nowrap;
}

.audio-player-bar .player-progress {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
}

.audio-player-bar .player-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.1s linear;
}

.audio-player-bar .player-time {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-dim);
    min-width: 40px;
}

.audio-player-bar .player-close {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
}

/* Filter controls (pills + toggle) */
.filter-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.toggle-switch.compact .toggle-slider { width: 36px; height: 20px; }
.toggle-switch.compact .toggle-slider::after { width: 14px; height: 14px; }
.toggle-switch.compact input:checked + .toggle-slider::after { transform: translateX(16px); }

/* Version badge */
.version-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-family: var(--mono);
    color: var(--text-dim);
}

.version-badge .ver-num {
    font-weight: 600;
    color: var(--text);
}

.version-badge .ver-total {
    color: var(--text-dim);
}

.version-badge .ver-expand {
    background: none;
    border: 1px solid var(--border);
    color: var(--accent);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    cursor: pointer;
    font-family: var(--font);
    margin-left: 2px;
    transition: all 0.2s;
}

.version-badge .ver-expand:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* Version history sub-rows */
.data-table tr.version-row td {
    background: var(--bg);
    padding: 8px 14px;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
}

.data-table tr.version-row td:first-child {
    padding-left: 28px;
}

.data-table tr.version-row:hover td {
    background: var(--surface-hover);
}

/* Responsive */
@media (max-width: 640px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .header-nav { display: none; }
    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 8px 10px; }
    .login-card { padding: 28px; }
    .filter-pills { flex-wrap: wrap; }
}
