/* ====== VARIABLES ====== */
:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    --danger: #DC2626;
    --danger-hover: #B91C1C;
    --danger-light: #FEF2F2;
    --success: #059669;
    --success-light: #ECFDF5;
    --warning: #D97706;
    --warning-light: #FFFBEB;
    --surface: #FFFFFF;
    --surface-ground: #F8FAFC;
    --surface-elevated: #FFFFFF;
    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --text: #0F172A;
    --text-secondary: #64748B;
    --text-tertiary: #94A3B8;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --sidebar-width: 260px;
    --topbar-height: 64px;
}

/* ====== RESET ====== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--surface-ground);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ====== SIDEBAR ====== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--text);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: transform 0.25s ease;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar__brand .material-icons { font-size: 28px; color: var(--primary-light); }
.sidebar__brand-text { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; }

.sidebar__nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s;
    border: none;
    background: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
}
.sidebar__link .material-icons { font-size: 20px; }
.sidebar__link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar__link.is-active { background: var(--primary); color: #fff; }
.sidebar__link--danger:hover { background: rgba(220,38,38,0.2); color: #FCA5A5; }

.sidebar__footer {
    padding: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ====== TOPBAR ====== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    z-index: 30;
}
.topbar__toggle { display: none; background: none; border: none; cursor: pointer; color: var(--text); }
.topbar__title { font-size: 1.1rem; font-weight: 700; white-space: nowrap; }
.topbar__spacer { flex: 1; }
.topbar__user { font-size: 0.85rem; color: var(--text-secondary); }

/* ====== CONTENT ====== */
.content {
    padding: 2rem 1.5rem;
    max-width: 1400px;
}

/* ====== CARDS ====== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}
.stat-card__icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.stat-card__icon .material-icons { font-size: 24px; color: #fff; }
.stat-card__icon--primary { background: var(--primary); }
.stat-card__icon--success { background: var(--success); }
.stat-card__icon--warning { background: var(--warning); }
.stat-card__icon--danger { background: var(--danger); }
.stat-card__label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card__value { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; }

/* ====== PANELS ====== */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}
.panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}
.panel__title { font-size: 1rem; font-weight: 700; }
.panel__subtitle { font-size: 0.85rem; color: var(--text-secondary); margin-top: 0.15rem; }
.panel__body { padding: 1.5rem; }

/* ====== TABLE ====== */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--surface-ground); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ====== BADGES ====== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge--primary { background: var(--primary-light); color: var(--primary); }
.badge--success { background: var(--success-light); color: var(--success); }
.badge--warning { background: var(--warning-light); color: var(--warning); }
.badge--danger { background: var(--danger-light); color: var(--danger); }

/* ====== FORMS ====== */
.form-stack { display: grid; gap: 1rem; }
.field {}
.field__label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.4rem; color: var(--text); }
.input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.input::placeholder { color: var(--text-tertiary); }

.search-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface-ground);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 0.85rem;
}
.search-bar .material-icons { color: var(--text-tertiary); font-size: 20px; }
.search-bar .input { border: none; background: transparent; padding-left: 0; }
.search-bar .input:focus { box-shadow: none; }

/* ====== BUTTONS ====== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    text-decoration: none;
}
.btn .material-icons { font-size: 18px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn--outlined { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn--outlined:hover:not(:disabled) { background: var(--surface-ground); }
.btn--sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
.btn--full { width: 100%; }
.btn--icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); }

/* ====== ALERTS ====== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    display: none;
    margin-bottom: 1rem;
}
.alert.is-visible { display: block; }
.alert--error { background: var(--danger-light); color: var(--danger); }
.alert--success { background: var(--success-light); color: var(--success); }

/* ====== EMPTY STATE ====== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}
.empty-state .material-icons { font-size: 48px; color: var(--text-tertiary); margin-bottom: 0.75rem; }
.empty-state p { margin: 0.25rem 0; }

/* ====== SPINNER ====== */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary);
    gap: 0.5rem;
}

/* ====== UTILITY ====== */
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.85rem; }
.fw-600 { font-weight: 600; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }

/* ====== RESPONSIVE ====== */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.is-open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.2); }
    .main-wrapper { margin-left: 0; }
    .topbar__toggle { display: block; }
}

@media (max-width: 640px) {
    .content { padding: 1rem; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .panel__header { padding: 1rem; }
    .panel__body { padding: 1rem; }
    .data-table th, .data-table td { padding: 0.6rem 0.75rem; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
}
