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

:root {
    --bg: #0a0a0a;
    --surface: #111;
    --surface2: #1a1a1a;
    --border: #2a2a2a;
    --text: #f0f0f0;
    --text-muted: #888;
    --accent: #c8a96e;
    --accent-hover: #d4b97e;
    --danger: #e05252;
    --success: #52c07a;
    --radius: 8px;
    --sidebar-w: 220px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.hidden { display: none !important; }

/* --- LOGIN --- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 0%, #1a1507 0%, #0a0a0a 70%);
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
}

.login-logo {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: -1px;
    margin-bottom: 1.5rem;
    text-align: center;
}

.logo-ag { color: var(--accent); }
.logo-year { color: var(--text); }

.login-box h1 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 0.5rem;
}

.login-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 1.75rem;
}

.google-signin-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

/* --- DASHBOARD --- */
.dashboard {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar-logo {
    font-size: 1.6rem;
    font-weight: 900;
    letter-spacing: -1px;
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-item {
    display: block;
    width: 100%;
    padding: 0.7rem 1.25rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    border-left: 3px solid transparent;
}

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

.logout-btn {
    margin: 1rem;
    padding: 0.6rem 1rem;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    transition: color 0.2s, border-color 0.2s;
}

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

.content-area {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 2rem;
    max-width: 900px;
}

/* --- SECTIONS --- */
.section { display: none; }
.section.active { display: block; }

.section-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.section-top h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* --- CARDS LIST --- */
.cards-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.card-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    transition: border-color 0.2s;
}

.card-row:hover { border-color: #444; }

.card-thumb {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 4px;
    background: var(--surface2);
    flex-shrink: 0;
}

.card-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    background: var(--surface2);
    border-radius: 4px;
    flex-shrink: 0;
}

.card-info { flex: 1; min-width: 0; }
.card-title { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { color: var(--text-muted); font-size: 0.8rem; }

.card-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* --- FORMS / FIELDS --- */
.field {
    margin-bottom: 1rem;
}

.field label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
textarea,
select {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
    transition: border-color 0.2s;
    outline: none;
}

input:focus, textarea:focus { border-color: var(--accent); }

textarea { resize: vertical; }

.checkbox-field label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    text-transform: none;
    font-size: 0.9rem;
    color: var(--text);
}

.checkbox-field input[type="checkbox"] {
    width: auto;
    accent-color: var(--accent);
}

.upload-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.upload-row input[type="file"] {
    width: auto;
    background: var(--surface2);
    padding: 0.4rem 0.6rem;
    cursor: pointer;
}

.upload-row span { color: var(--text-muted); }
.upload-row input[type="url"] { flex: 1; min-width: 180px; }

.img-preview {
    margin-top: 0.5rem;
    min-height: 0;
}

.img-preview img {
    max-height: 80px;
    max-width: 200px;
    object-fit: contain;
    border-radius: 4px;
    background: var(--surface2);
    display: block;
}

/* --- BUTTONS --- */
.btn-primary {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius);
    padding: 0.6rem 1.25rem;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

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

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 1.25rem;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.btn-secondary:hover { border-color: #555; }

.btn-icon {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: color 0.2s, border-color 0.2s;
}

.btn-icon:hover { color: var(--text); border-color: #555; }
.btn-icon.danger:hover { color: var(--danger); border-color: var(--danger); }

/* --- MODALS --- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-box h3 {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* --- CONFIG FORM --- */
.config-form fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.config-form legend {
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 0.5rem;
}

.stat-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

/* --- MESSAGES --- */
.error-msg { color: var(--danger); font-size: 0.85rem; padding: 0.5rem 0; }
.success-msg { color: var(--success); font-size: 0.85rem; padding: 0.5rem 0; }

/* --- TOAST --- */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    z-index: 2000;
    animation: slideIn 0.3s ease;
}

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

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

/* --- RESPONSIVE --- */
@media (max-width: 640px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .sidebar-nav {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 0;
    }

    .nav-item { border-left: none; border-bottom: 3px solid transparent; }
    .nav-item.active { border-bottom-color: var(--accent); border-left: none; }

    .content-area {
        margin-left: 0;
        padding: 1rem;
    }

    .dashboard { flex-direction: column; }
}
