:root {
    --bg: #0f0f14;
    --surface: #16161d;
    --surface2: #1e1e28;
    --border: #2a2a38;
    --text: #e8e8f0;
    --muted: #8888a0;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --success: #57f287;
    --danger: #ed4245;
    --warning: #fee75c;
    --radius: 12px;
    --shadow: 0 8px 32px rgba(0,0,0,.4);
}

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

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

.hidden { display: none !important; }

/* ─── Landing ─── */
.landing { overflow-x: hidden; }

.bg-grid {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(88,101,242,.25), transparent),
        linear-gradient(rgba(88,101,242,.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(88,101,242,.03) 1px, transparent 1px);
    background-size: auto, 48px 48px, 48px 48px;
    pointer-events: none;
    z-index: 0;
}

.nav {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.logo { font-weight: 700; font-size: 1.25rem; }

.hero {
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 4rem 2rem 6rem;
    text-align: center;
}

.badge {
    display: inline-block;
    background: var(--surface2);
    border: 1px solid var(--border);
    padding: .35rem 1rem;
    border-radius: 999px;
    font-size: .85rem;
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3.25rem);
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 1rem;
}

.gradient {
    background: linear-gradient(135deg, #5865f2, #57f287);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--muted);
    font-size: 1.1rem;
    max-width: 560px;
    margin: 0 auto 2rem;
}

.hero-actions { margin-bottom: 4rem; }

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    text-align: left;
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: border-color .2s, transform .2s;
}

.feature-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.feature-icon { font-size: 2rem; display: block; margin-bottom: .75rem; }
.feature-card h3 { font-size: 1rem; margin-bottom: .35rem; }
.feature-card p { color: var(--muted); font-size: .9rem; }

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

/* ─── Login / Verify ─── */
.login-card {
    position: relative;
    z-index: 1;
    max-width: 440px;
    margin: 0 auto 3rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    text-align: left;
    box-shadow: var(--shadow);
}

.login-card h2 { margin-bottom: 1rem; font-size: 1.15rem; }

.login-hint {
    color: var(--muted);
    font-size: .9rem;
    margin-bottom: 1rem;
}

.login-label {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    font-size: .85rem;
    color: var(--muted);
    margin-bottom: 1rem;
}

.login-label input {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .75rem;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
}

.login-label input:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-full { width: 100%; margin-top: .5rem; }

.login-error {
    color: var(--danger);
    font-size: .85rem;
    margin-top: 1rem;
    text-align: center;
}

.verify-steps {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-bottom: 1rem;
}

.verify-step {
    padding: .5rem .75rem;
    border-radius: 8px;
    background: var(--surface2);
    font-size: .85rem;
    color: var(--muted);
    border: 1px solid var(--border);
}

.verify-step.active {
    border-color: var(--accent);
    color: var(--text);
}

.verify-step.done {
    border-color: rgba(87,242,135,.3);
    color: var(--success);
}

.verify-step code {
    background: var(--bg);
    padding: .1rem .35rem;
    border-radius: 4px;
    font-size: .8rem;
}

.polling-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .65rem;
    padding: .75rem;
    color: var(--muted);
    font-size: .9rem;
    margin: 1rem 0;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

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

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .6rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: .9rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background .15s, transform .1s;
    font-family: inherit;
}

.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-discord { background: var(--accent); color: #fff; }
.btn-discord:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-success { background: rgba(87,242,135,.15); color: var(--success); border: 1px solid rgba(87,242,135,.3); }
.btn-danger { background: rgba(237,66,69,.15); color: var(--danger); border: 1px solid rgba(237,66,69,.3); }
.btn-warning { background: rgba(254,231,92,.12); color: var(--warning); border: 1px solid rgba(254,231,92,.25); }
.btn-sm { padding: .4rem .85rem; font-size: .8rem; }
.btn-lg { padding: .85rem 2rem; font-size: 1rem; }

/* ─── Dashboard layout ─── */
.dashboard-page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-shrink: 0;
}

.sidebar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    padding: .5rem .75rem;
}

.sidebar nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }

.nav-item {
    background: none;
    border: none;
    color: var(--muted);
    text-align: left;
    padding: .65rem .75rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: .9rem;
    transition: background .15s, color .15s;
}

.nav-item:hover, .nav-item.active {
    background: var(--surface2);
    color: var(--text);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .75rem;
    background: var(--surface2);
    border-radius: var(--radius);
    font-size: .85rem;
}

.sidebar-user img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
}

.page-header h1 { font-size: 1.75rem; }
.page-sub { color: var(--muted); font-size: .95rem; margin-top: .25rem; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Bot cards ─── */
.bots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

.bot-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    transition: border-color .2s;
}

.bot-card:hover { border-color: rgba(88,101,242,.4); }

.bot-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.bot-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    overflow: hidden;
}

.bot-avatar img { width: 100%; height: 100%; object-fit: cover; }

.bot-name { font-weight: 600; font-size: 1.05rem; }
.bot-type { color: var(--muted); font-size: .85rem; }

.status-badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    margin-left: auto;
}

.status-active { background: rgba(87,242,135,.15); color: var(--success); }
.status-off { background: rgba(237,66,69,.15); color: var(--danger); }
.status-paused { background: rgba(254,231,92,.15); color: var(--warning); }
.status-restarting { background: rgba(88,101,242,.2); color: #a5b4fc; animation: pulse-status 1.2s ease-in-out infinite; }
.status-starting { background: rgba(87,242,135,.1); color: var(--success); animation: pulse-status 1.2s ease-in-out infinite; }
.status-expired { background: rgba(128,128,128,.15); color: var(--muted); }

@keyframes pulse-status {
    0%, 100% { opacity: 1; }
    50% { opacity: .65; }
}

.bulk-controls { margin-bottom: 1rem; }
.bulk-hint { color: var(--muted); font-size: .88rem; margin: 0 0 1rem; }
.bulk-actions { display: flex; flex-wrap: wrap; gap: .75rem; }

.pause-banner {
    background: rgba(254,231,92,.1);
    border: 1px solid rgba(254,231,92,.3);
    border-radius: 8px;
    padding: .65rem .85rem;
    font-size: .82rem;
    color: var(--warning);
    margin-bottom: .75rem;
}

.bot-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
    font-size: .82rem;
    color: var(--muted);
    margin-bottom: 1rem;
}

.bot-meta span { color: var(--text); }

.bot-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

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

.empty-icon { font-size: 3rem; display: block; margin-bottom: 1rem; }

/* ─── Admin ─── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

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

.stat-card .value { font-size: 1.75rem; font-weight: 700; color: var(--accent); }
.stat-card .label { color: var(--muted); font-size: .85rem; }

.admin-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.admin-card h2 { margin-bottom: 1.25rem; font-size: 1.1rem; }

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

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    font-size: .85rem;
    color: var(--muted);
}

.form-grid label.full { grid-column: 1 / -1; }

.form-grid input, .form-grid select {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .65rem .85rem;
    color: var(--text);
    font-family: inherit;
    font-size: .9rem;
}

.form-grid input:focus, .form-grid select:focus {
    outline: none;
    border-color: var(--accent);
}

/* ─── Modal ─── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.6);
}

.modal-box {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 90%;
    max-width: 420px;
    box-shadow: var(--shadow);
}

.modal-box h3 { margin-bottom: 1rem; }

.modal-box input {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .75rem;
    color: var(--text);
    font-family: inherit;
    margin-bottom: 1rem;
}

.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; }

/* ─── Toast ─── */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    padding: .85rem 1.25rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 200;
    animation: slideIn .3s ease;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

@keyframes slideIn {
    from { transform: translateY(1rem); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 768px) {
    .dashboard-page { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; }
    .sidebar nav { flex-direction: row; flex: none; }
    .form-grid { grid-template-columns: 1fr; }
}
