:root {
    --bg: #0a0a0f;
    --surface: #111118;
    --surface-hover: #16161e;
    --border: rgba(255,255,255,0.07);
    --border-hover: rgba(255,255,255,0.14);

    --accent: #7c3aed;
    --accent-light: #8b5cf6;
    --accent-glow: rgba(124,58,237,0.25);

    --text: #f1f0f5;
    --text-2: #9896a8;
    --text-3: #5a5870;

    --green: #22c55e;
    --green-bg: rgba(34,197,94,0.08);
    --red: #ef4444;
    --red-bg: rgba(239,68,68,0.08);

    --radius: 8px;
    --radius-lg: 12px;
    --ease: cubic-bezier(0.4,0,0.2,1);
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Subtle grid background ── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

/* ── Accent blob (1 only, subtle) ── */
body::after {
    content: '';
    position: fixed;
    top: -200px;
    right: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(124,58,237,0.12), transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ── Navbar ── */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    background: rgba(10,10,15,0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

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

.brand-icon { font-size: 1.1rem; }

.brand-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.brand-tag {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-light);
    background: rgba(124,58,237,0.12);
    border: 1px solid rgba(124,58,237,0.2);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

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

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.4rem 0.875rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.15s var(--ease);
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 0 1px rgba(124,58,237,0.5), 0 2px 8px var(--accent-glow);
}
.btn-primary:hover {
    background: var(--accent-light);
    box-shadow: 0 0 0 1px rgba(139,92,246,0.6), 0 4px 16px var(--accent-glow);
}
.btn-primary:active { transform: scale(0.98); }

.btn-ghost {
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
    color: var(--text);
}

.btn-danger-ghost {
    background: transparent;
    color: var(--red);
    border: 1px solid rgba(239,68,68,0.2);
    font-size: 0.75rem;
    padding: 0.3rem 0.65rem;
}
.btn-danger-ghost:hover {
    background: var(--red-bg);
    border-color: rgba(239,68,68,0.4);
}

.btn-admin {
    background: rgba(245,158,11,0.08);
    color: #f59e0b;
    border: 1px solid rgba(245,158,11,0.2);
}
.btn-admin:hover {
    background: rgba(245,158,11,0.15);
    border-color: rgba(245,158,11,0.35);
}

/* ── Container ── */
.container {
    position: relative;
    z-index: 1;
    max-width: 1060px;
    margin: 0 auto;
    padding: 5rem 1.5rem 3rem;
}

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    position: relative;
}

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

.card-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ── Inline key row ── */
.key-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
    gap: 1rem;
}
.key-row:hover {
    border-color: var(--border-hover);
    background: rgba(255,255,255,0.02);
}
.key-row.selected {
    border-color: rgba(124,58,237,0.4);
    background: rgba(124,58,237,0.05);
}

.key-info { flex: 1; min-width: 0; }
.key-name {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.key-meta {
    font-size: 0.75rem;
    color: var(--text-3);
    font-family: 'SF Mono', 'Fira Code', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Code block ── */
.code-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.8rem;
    color: #a5b4fc;
    overflow-x: auto;
    white-space: pre;
    line-height: 1.6;
    transition: color 0.25s var(--ease);
}

/* ── Badge ── */
.badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    color: var(--text-2);
    background: var(--surface-hover);
}
.badge-pro {
    color: var(--accent-light);
    background: rgba(124,58,237,0.1);
    border-color: rgba(124,58,237,0.25);
}
.badge-free {
    color: var(--text-3);
    background: transparent;
    border-color: var(--border);
}

/* ── Form elements ── */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-2);
    margin-bottom: 0.375rem;
}
.form-input {
    width: 100%;
    padding: 0.6rem 0.875rem;
    border-radius: var(--radius);
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 0.875rem;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.form-input:focus {
    outline: none;
    border-color: var(--accent-light);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}
.form-input::placeholder { color: var(--text-3); }

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    width: 100%;
    max-width: 380px;
    animation: popIn 0.18s var(--ease);
}
@keyframes popIn {
    from { opacity: 0; transform: scale(0.96) translateY(6px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.modal-title {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 1rem;
}
.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

/* ── Section header ── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.page-title { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.025em; }
.page-subtitle { font-size: 0.8125rem; color: var(--text-2); margin-top: 0.25rem; }

/* ── Two-col grid ── */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 1rem;
    align-items: start;
}

/* ── Rate hint block ── */
.hint-block {
    font-size: 0.75rem;
    color: var(--text-3);
    border-left: 2px solid rgba(124,58,237,0.35);
    padding: 0.6rem 0.75rem;
    margin-top: 1rem;
    line-height: 1.6;
}
.hint-block strong { color: var(--text-2); }

/* ── Auth page ── */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.auth-box {
    width: 100%;
    max-width: 360px;
}
.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}
.auth-logo .brand-icon { font-size: 2rem; }
.auth-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-top: 0.5rem;
}
.auth-logo p { font-size: 0.8125rem; color: var(--text-2); margin-top: 0.25rem; }

/* ── Toasts ── */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    transform: translateX(120%);
    animation: slideIn 0.25s forwards var(--ease);
    max-width: 320px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }

@keyframes slideIn { to { transform: translateX(0); } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(4px); } }

/* ── Utilities ── */
.hidden { display: none !important; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.text-muted { color: var(--text-3); font-size: 0.8125rem; }
.text-center { text-align: center; }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-3);
    font-size: 0.8125rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.empty-state p:first-child { font-size: 0.875rem; color: var(--text-2); margin-bottom: 0.375rem; }

/* ── Divider ── */
hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
