@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-body: #f4f5f7;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f9fafb;
    --bg-surface-alt: #f8fafc;

    --sidebar-bg: #0b1121;
    --sidebar-border: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #e2e8f0;
    --sidebar-text-active: #ffffff;
    --sidebar-bg-hover: rgba(255, 255, 255, 0.05);
    --sidebar-bg-active: rgba(255, 255, 255, 0.1);
    --sidebar-accent: #38bdf8;

    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-invert: #ffffff;

    --border: #e2e8f0;
    --border-hover: #cbd5e1;

    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: #e0f2fe;
    --primary-text: #0c4a6e;

    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-light: #fef2f2;
    --danger-text: #991b1b;

    --success: #059669;
    --success-light: #d1fae5;
    --success-text: #065f46;

    --warning: #d97706;
    --warning-light: #fffbeb;
    --warning-text: #92400e;

    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.05);

    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 6px;

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-12: 3rem;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-size: 0.875rem;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }

.app-container { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background-color: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; flex-shrink: 0; border-right: 1px solid var(--sidebar-border); z-index: 40; }
.sidebar-header { padding: var(--space-5) var(--space-6); display: flex; align-items: center; gap: var(--space-3); border-bottom: 1px solid rgba(255,255,255,0.05); }
.brand-icon { color: var(--sidebar-accent); display: flex; align-items: center; }
.brand-text { font-size: 1.125rem; font-weight: 600; color: var(--text-invert); letter-spacing: -0.01em; }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: var(--space-4) 0; }
.nav-section { padding: var(--space-4) var(--space-6) var(--space-2); font-size: 0.6875rem; text-transform: uppercase; font-weight: 600; letter-spacing: 0.05em; color: rgba(255,255,255,0.4); }

.sidebar-nav a { display: flex; align-items: center; gap: var(--space-3); padding: 0.5rem var(--space-6); color: var(--sidebar-text); text-decoration: none; font-size: 0.875rem; font-weight: 500; transition: all 0.15s ease; border-left: 3px solid transparent; }
.sidebar-nav a svg { width: 18px; height: 18px; opacity: 0.7; transition: opacity 0.15s; }
.sidebar-nav a:hover { background: var(--sidebar-bg-hover); color: var(--sidebar-text-hover); text-decoration: none; }
.sidebar-nav a:hover svg { opacity: 1; }
.sidebar-nav a.active { background: var(--sidebar-bg-active); color: var(--sidebar-text-active); border-left-color: var(--sidebar-accent); }
.sidebar-nav a.active svg { color: var(--sidebar-accent); opacity: 1; }

.sidebar-footer { padding: var(--space-4) var(--space-6); border-top: 1px solid rgba(255,255,255,0.05); background: rgba(0,0,0,0.1); }
.user-profile { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.user-avatar { width: 32px; height: 32px; border-radius: 4px; background: rgba(255,255,255,0.1); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.875rem; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.875rem; font-weight: 600; color: var(--text-invert); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 0.75rem; color: var(--sidebar-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { margin-bottom: var(--space-3); }
.badge-admin { background: rgba(56, 189, 248, 0.1); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.2); }

.logout-form { margin: 0; }
.logout-btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: var(--space-2); padding: 0.5rem; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.05); border-radius: var(--radius-md); color: var(--sidebar-text); cursor: pointer; font-size: 0.8125rem; font-weight: 500; transition: all 0.15s ease; }
.logout-btn:hover { background: rgba(255,255,255,0.1); color: var(--text-invert); }

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 60px; background: var(--bg-surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 var(--space-6); font-size: 1rem; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,0.02); justify-content: space-between; position: sticky; top: 0; z-index: 30; }
.topbar-title { display: flex; align-items: center; gap: var(--space-3); color: var(--text-main); }
.content-area { padding: var(--space-8); flex: 1; overflow-y: auto; }

.mobile-menu-toggle { display: none; }
.mobile-menu-btn { display: none; cursor: pointer; padding: var(--space-1); margin-left: -var(--space-2); border-radius: 4px; color: var(--text-muted); }
.mobile-menu-btn:hover { background: var(--bg-surface-hover); color: var(--text-main); }
.mobile-overlay { display: none; position: fixed; inset: 0; background: rgba(11,17,33,0.5); z-index: 35; backdrop-filter: blur(2px); }

@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .sidebar { position: fixed; left: -280px; top: 0; bottom: 0; width: 280px; transition: transform 0.3s ease; }
    .mobile-menu-btn { display: inline-flex; align-items: center; }
    .mobile-menu-toggle:checked ~ .app-container .sidebar { transform: translateX(280px); }
    .mobile-menu-toggle:checked ~ .mobile-overlay { display: block; }
    .content-area { padding: var(--space-4); }
}

/* Page headers */
.page-breadcrumbs { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8125rem; color: var(--text-muted); margin-bottom: var(--space-3); }
.page-breadcrumbs a { color: var(--text-muted); transition: color 0.15s; }
.page-breadcrumbs a:hover { color: var(--primary); text-decoration: none; }
.page-breadcrumbs .current { color: var(--text-main); font-weight: 500; }

.page-header { margin-bottom: var(--space-6); display: flex; flex-wrap: wrap; gap: var(--space-4); justify-content: space-between; align-items: flex-end; }
.page-header > div { flex: 1; min-width: 200px; }
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--text-main); margin: 0 0 0.25rem 0; letter-spacing: -0.02em; }
.page-description { font-size: 0.875rem; color: var(--text-muted); margin: 0; }

/* Cards & Data */
.card { background: var(--bg-surface); border-radius: var(--radius-md); border: 1px solid var(--border); box-shadow: var(--shadow-sm); margin-bottom: var(--space-6); display: flex; flex-direction: column; }
.card-header { padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: var(--space-4); justify-content: space-between; align-items: center; background: var(--bg-surface); border-top-left-radius: var(--radius-md); border-top-right-radius: var(--radius-md); }
.card-title { font-size: 1.125rem; font-weight: 600; color: var(--text-main); letter-spacing: -0.01em; margin: 0; }
.card-body { padding: var(--space-6); flex: 1; }
.card-footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border); background: var(--bg-surface-alt); display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: flex-end; align-items: center; border-bottom-left-radius: var(--radius-md); border-bottom-right-radius: var(--radius-md); }

/* Tables */
.table-responsive { overflow-x: auto; width: 100%; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; }
th { background: var(--bg-surface-alt); padding: 0.75rem 1.5rem; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); border-top: 1px solid var(--border); white-space: nowrap; }
th:first-child { border-left: none; }
th:last-child { border-right: none; }
td { padding: 0.875rem 1.5rem; border-bottom: 1px solid var(--border); color: var(--text-main); font-size: 0.875rem; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-surface-hover); }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 0.125rem 0.5rem; border-radius: 2px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; text-transform: uppercase; letter-spacing: 0.025em; border: 1px solid transparent; }
.badge-success { background: var(--success-light); color: var(--success-text); border-color: #a7f3d0; }
.badge-danger { background: var(--danger-light); color: var(--danger-text); border-color: #fecaca; }
.badge-warning { background: var(--warning-light); color: var(--warning-text); border-color: #fde68a; }
.badge-neutral { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.badge-primary { background: #eff6ff; color: #075985; border-color: #bae6fd; }
.code-badge { background: var(--bg-body); padding: 0.125rem 0.375rem; border-radius: 4px; font-family: monospace; font-size: 0.8125rem; border: 1px solid var(--border); color: var(--primary-text); }

/* Detail Grid */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-6); }
.detail-item { display: flex; flex-direction: column; gap: 0.25rem; }
.detail-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em; }
.detail-value { font-size: 0.9375rem; color: var(--text-main); font-weight: 500; }

/* Grid stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-6); margin-bottom: var(--space-6); }
.stat-card { background: var(--bg-surface); padding: var(--space-5) var(--space-6); border-radius: var(--radius-md); border: 1px solid var(--border); box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: var(--space-4); position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); border-top-left-radius: var(--radius-md); border-bottom-left-radius: var(--radius-md); }
.stat-card:nth-child(2)::before { background: var(--success); }
.stat-card:nth-child(3)::before { background: var(--warning); }
.stat-icon { width: 48px; height: 48px; border-radius: 4px; background: var(--bg-surface-alt); border: 1px solid var(--border); color: var(--text-muted); display: flex; align-items: center; justify-content: center; }
.stat-icon svg { width: 24px; height: 24px; stroke-width: 1.5; }
.stat-info { flex: 1; }
.stat-info h3 { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; }
.stat-info .value { font-size: 1.75rem; font-weight: 700; color: var(--text-main); line-height: 1.2; letter-spacing: -0.02em; }

/* Forms */
.form-group { margin-bottom: var(--space-5); }
.form-label { display: block; font-weight: 500; margin-bottom: var(--space-2); color: var(--text-main); font-size: 0.875rem; }
.form-control { width: 100%; padding: 0.625rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 0.875rem; transition: border-color 0.15s ease, box-shadow 0.15s ease; background-color: var(--bg-surface); color: var(--text-main); appearance: none; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15); }
.form-control::placeholder { color: #94a3b8; }
.form-hint { display: block; margin-top: 0.375rem; font-size: 0.75rem; color: var(--text-muted); }
.form-hint.danger { color: var(--danger); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.5rem 1rem; font-size: 0.875rem; font-weight: 500; border-radius: var(--radius-md); border: 1px solid transparent; transition: all 0.15s ease; gap: 0.5rem; text-decoration: none; line-height: 1.25rem; cursor: pointer; white-space: nowrap; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary { background-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(2, 132, 199, 0.2); }
.btn-primary:hover { background-color: var(--primary-hover); text-decoration: none; }

.btn-secondary { background-color: var(--bg-surface); border-color: var(--border); color: var(--text-main); box-shadow: 0 1px 2px rgba(0,0,0,0.02); }
.btn-secondary:hover { background-color: var(--bg-surface-hover); border-color: var(--border-hover); text-decoration: none; }

.btn-danger { background-color: var(--danger); color: #fff; box-shadow: 0 1px 2px rgba(220, 38, 38, 0.2); }
.btn-danger:hover { background-color: var(--danger-hover); text-decoration: none; }

.btn-sm { padding: 0.25rem 0.625rem; font-size: 0.75rem; border-radius: 2px; }
.btn-block { width: 100%; }

/* Checkbox Grid */
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-3); }
.checkbox-item { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-md); cursor: pointer; transition: all 0.15s ease; background: var(--bg-surface); margin: 0; }
.checkbox-item:hover { border-color: var(--primary); background: var(--bg-surface-hover); }
.checkbox-item:has(input:checked) { border-color: var(--primary); background: rgba(2, 132, 199, 0.02); }
.checkbox-item input[type="checkbox"] { margin-top: 0.125rem; width: 1rem; height: 1rem; accent-color: var(--primary); cursor: pointer; }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius-md); margin-bottom: var(--space-5); font-size: 0.875rem; display: flex; align-items: center; gap: 0.5rem; font-weight: 500; border: 1px solid transparent; }
.alert svg { width: 20px; height: 20px; flex-shrink: 0; }
.alert-danger { background-color: var(--danger-light); color: var(--danger-text); border-color: #fecaca; }
.alert-info { background-color: var(--primary-light); color: var(--primary-text); border-color: #bae6fd; }
.alert-success { background-color: var(--success-light); color: var(--success-text); border-color: #a7f3d0; }

/* Empty state */
.empty-state { text-align: center; padding: var(--space-12) var(--space-4); color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto var(--space-4); color: var(--border-hover); }
.empty-state h3 { font-size: 1.125rem; color: var(--text-main); margin-bottom: var(--space-2); }

/* Auth Layout */
.auth-layout { display: flex; min-height: 100vh; background: var(--bg-surface); }
.auth-sidebar { flex: 1; background: var(--sidebar-bg); color: var(--text-invert); padding: var(--space-12); display: none; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
@media (min-width: 900px) { .auth-sidebar { display: flex; } }
.auth-brand { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); position: relative; z-index: 10; }
.auth-brand svg { width: 32px; height: 32px; color: var(--sidebar-accent); }
.auth-brand h1 { font-size: 1.75rem; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.auth-sidebar > p { font-size: 1.125rem; color: var(--sidebar-text); max-width: 400px; position: relative; z-index: 10; line-height: 1.6; }
.auth-illustration { position: absolute; right: -100px; bottom: 10%; width: 500px; height: 300px; background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.05); border-radius: 8px; transform: rotate(-5deg); padding: 2rem; display: flex; flex-direction: column; gap: 1rem; }
.auth-illustration .dash-row { height: 16px; background: rgba(255,255,255,0.05); border-radius: 2px; }

.auth-content { flex: 1; display: flex; align-items: center; justify-content: center; padding: var(--space-8); background: var(--bg-body); }
@media (min-width: 900px) { .auth-content { background: var(--bg-surface); } }
.auth-form-wrapper { width: 100%; max-width: 400px; background: var(--bg-surface); padding: var(--space-8); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
@media (min-width: 900px) { .auth-form-wrapper { padding: 0; box-shadow: none; border: none; } }
.auth-title { font-size: 1.5rem; font-weight: 700; color: var(--text-main); margin: 0 0 0.5rem 0; letter-spacing: -0.02em; }
.auth-subtitle { color: var(--text-muted); margin: 0 0 var(--space-6) 0; font-size: 0.9375rem; }
