:root {
    --bg-main: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-sidebar: #0f172a;
    --text-primary: #0f172a;
    --text-muted: #64748b;
    --text-sidebar: #cbd5e1;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --border: #e2e8f0;
    --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
}

.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.auth-card {
    background: var(--bg-surface);
    width: 100%;
    max-width: 420px;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}

.brand-badge {
    display: inline-block;
    background: #eff6ff;
    color: var(--accent);
    font-weight: 700;
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.auth-header h1 { font-size: 1.5rem; margin-bottom: 0.35rem; }
.auth-header p { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.auth-footer { margin-top: 1.5rem; text-align: center; font-size: 0.75rem; color: var(--text-muted); }

.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #1e293b;
}

.logo-text { font-size: 1.25rem; font-weight: 800; color: #ffffff; letter-spacing: 0.03em; }
.logo-text span { color: #38bdf8; }
.btn-close-sidebar { display: none; background: none; border: none; color: #ffffff; font-size: 1.5rem; cursor: pointer; }
.sidebar-nav { padding: 0.75rem; overflow-y: auto; flex: 1; }

.nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.85rem;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 6px;
    margin-bottom: 0.2rem;
}

.nav-item:hover:not(.disabled) { background: #1e293b; color: #ffffff; }
.nav-item.active { background: var(--accent); color: #ffffff; font-weight: 600; }
.nav-item.disabled { opacity: 0.5; cursor: not-allowed; }
.badge-stage { font-size: 0.65rem; background: #1e293b; padding: 0.1rem 0.4rem; border-radius: 4px; color: #94a3b8; }

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0.9rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.topbar-left { display: flex; align-items: center; gap: 0.75rem; }
.btn-menu-toggle { display: none; background: none; border: 1px solid var(--border); padding: 0.35rem 0.6rem; border-radius: 6px; font-size: 1.1rem; cursor: pointer; }
.page-heading { font-size: 1.15rem; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.user-info { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; }
.role-badge { background: #dbeafe; color: #1e40af; font-size: 0.7rem; font-weight: 700; padding: 0.15rem 0.45rem; border-radius: 4px; }
.content-container { padding: 1.5rem; max-width: 1400px; width: 100%; margin: 0 auto; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--bg-surface); padding: 1.25rem; border-radius: var(--radius); border: 1px solid var(--border); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.stat-value { font-size: 1.75rem; font-weight: 800; margin: 0.25rem 0; }
.stat-value small { font-size: 0.85rem; font-weight: 500; color: var(--text-muted); }
.stat-desc { font-size: 0.75rem; color: var(--text-muted); }

.grid-two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.25rem; }
.stack-col { display: flex; flex-direction: column; gap: 1.25rem; }
.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 1rem; }

.table-responsive { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th, .data-table td { padding: 0.75rem 1.25rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { background: #f8fafc; font-weight: 600; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; }

.badge { display: inline-block; padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.7rem; font-weight: 700; }
.badge-div { background: #f1f5f9; color: #334155; }
.badge-ai { background: #e0f2fe; color: #0369a1; }
.badge-sup { background: #fef3c7; color: #b45309; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }

.page-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap; }
.brands-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.25rem; }
.brand-card { padding: 1.25rem; display: flex; flex-direction: column; justify-content: space-between; }
.brand-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.75rem; }
.brand-code { font-size: 0.7rem; font-weight: 700; color: var(--accent); }
.brand-desc { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 1rem; }
.brand-meta { font-size: 0.8rem; background: #f8fafc; padding: 0.75rem; border-radius: 6px; margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.35rem; }
.brand-card-footer { display: flex; justify-content: space-between; gap: 0.5rem; border-top: 1px solid var(--border); padding-top: 0.85rem; }

.form-group { margin-bottom: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.35rem; }
input, select, textarea { width: 100%; padding: 0.6rem 0.75rem; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.875rem; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.6rem 1rem; border-radius: 6px; font-size: 0.875rem; font-weight: 600; cursor: pointer; border: 1px solid transparent; text-decoration: none; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.78rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: #fff; border-color: #cbd5e1; color: var(--text-primary); }
.btn-outline:hover { background: #f8fafc; }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-danger:hover { background: #fecaca; }

.alert { padding: 0.85rem 1rem; border-radius: 6px; margin-bottom: 1.25rem; font-size: 0.875rem; font-weight: 500; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); font-size: 0.875rem; }

.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); z-index: 50; align-items: center; justify-content: center; padding: 1rem; }
.modal-backdrop.open { display: flex; }
.modal-dialog { background: #fff; width: 100%; max-width: 620px; max-height: 90vh; overflow-y: auto; border-radius: var(--radius); }
.modal-header, .modal-footer { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-footer { border-bottom: none; border-top: 1px solid var(--border); justify-content: flex-end; gap: 0.5rem; }
.modal-body { padding: 1.25rem; }
.btn-close-modal { background: none; border: none; font-size: 1.5rem; cursor: pointer; }

@media (max-width: 960px) { .grid-two-col { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
    .sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .btn-menu-toggle, .btn-close-sidebar { display: inline-block; }
    .form-row { grid-template-columns: 1fr; }
}