:root {
    --bg: #0e0e10;
    --bg-elevated: #17171a;
    --bg-card: #1c1c20;
    --border: #2a2a30;
    --accent: #8B0000;
    --accent-bright: #c62828;
    --text: #f2f0ee;
    --text-muted: #9a9aa2;
    --success: #3ba55c;
    --danger: #ed4245;
    --radius: 12px;
    font-family: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.hidden { display: none !important; }

a { color: inherit; text-decoration: none; }

/* ============ LOGIN ============ */

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 20% 20%, rgba(139,0,0,0.25), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(139,0,0,0.15), transparent 40%),
        var(--bg);
    padding: 24px;
}

.login-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-card h1 { margin: 0 0 8px; font-size: 26px; letter-spacing: 0.5px; }
.login-card p { color: var(--text-muted); margin-bottom: 28px; line-height: 1.5; }

.login-error {
    margin-top: 16px;
    color: var(--danger);
    font-size: 14px;
}

.guild-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
}

.guild-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color .15s, transform .15s;
}
.guild-list-item:hover { border-color: var(--accent-bright); transform: translateX(2px); }
.guild-list-item img {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--bg-elevated); object-fit: cover;
}
.guild-list-item .fallback-icon {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent); display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}

/* ============ BUTTONS ============ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 10px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: filter .15s, transform .1s;
}
.btn:active { transform: scale(0.98); }
.btn:hover { filter: brightness(1.12); }

.btn-discord { background: #5865F2; color: #fff; width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-sm { padding: 8px 12px; font-size: 12.5px; }

/* ============ APP LAYOUT ============ */

.app {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.guild-icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--accent); object-fit: cover;
}

.sidebar-title { font-weight: 700; font-size: 14px; }
.sidebar-subtitle { color: var(--text-muted); font-size: 12px; }

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg-card); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-card);
    border-radius: 8px;
    font-size: 13px;
}
.user-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); }
.user-box span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-link { color: var(--text-muted); font-size: 16px; }
.logout-link:hover { color: var(--danger); }

/* ============ MAIN ============ */

.main {
    padding: 32px 40px;
    max-width: 900px;
    position: relative;
}

.section { display: none; }
.section.active { display: block; animation: fadein .2s ease; }

@keyframes fadein { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none; } }

.main h2 { margin: 0 0 4px; font-size: 22px; }
.section-desc { color: var(--text-muted); margin: 0 0 24px; font-size: 14px; }

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}
.card-label { color: var(--text-muted); font-size: 12.5px; margin-bottom: 6px; }
.card-value { font-size: 16px; font-weight: 600; }

.form-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}
.form-card h3 { margin-top: 0; }

.field { margin-bottom: 18px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}
.field .hint {
    display: block;
    font-weight: 400;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 2px;
}

.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }

input[type="text"], input[type="url"], input[type="number"], select, textarea {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-bright); }
textarea { resize: vertical; }

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.switch-row input { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }

.giveaway-list { display: flex; flex-direction: column; gap: 10px; }
.giveaway-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    font-size: 13.5px;
}
.giveaway-item .gv-title { font-weight: 700; margin-bottom: 4px; }
.giveaway-item .gv-meta { color: var(--text-muted); }
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 6px;
}
.badge-live { background: rgba(59,165,92,0.15); color: var(--success); }
.badge-ended { background: rgba(237,66,69,0.15); color: var(--danger); }

.toast {
    position: fixed;
    top: 20px;
    right: 30px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-left: 4px solid var(--success);
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    z-index: 100;
    transition: opacity .2s, transform .2s;
}
.toast.toast-error { border-left-color: var(--danger); }
.toast.hidden { opacity: 0; transform: translateY(-8px); pointer-events: none; }

/* ============ RESPONSIVE ============ */

@media (max-width: 800px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        flex-direction: row;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        align-items: center;
    }
    .sidebar-header { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
    .nav { flex-direction: row; }
    .sidebar-footer { flex-direction: row; border-top: none; padding-top: 0; margin-left: 8px; }
    .main { padding: 20px; }
    .field-row { flex-direction: column; }
}
