:root {
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --primary: #1e3a5f;
    --primary-light: #2a4d7a;
    --primary-dark: #152c4a;
    --accent: #4f8fea;
    --accent-hover: #3d7dd8;
    --surface: #f8f9fc;
    --surface-card: #ffffff;
    --border: #e2e8f0;
    --text-primary: #1a202c;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
    --transition: 0.2s ease;
}

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

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--surface);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== App Layout ===== */
.app-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1040;
    transition: transform var(--transition);
}

.sidebar-brand {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 10px;
}

.sidebar-brand-icon {
    font-size: 1.5rem;
    color: var(--accent);
}

.sidebar-brand-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
}

.sidebar-brand-sub {
    display: block;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 4px;
    padding-left: 36px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu-item {
    margin-bottom: 2px;
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
}

.sidebar-menu-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-menu-item.active .sidebar-menu-link {
    color: #fff;
    background: var(--accent);
    box-shadow: 0 2px 8px rgba(79, 143, 234, 0.3);
}

.sidebar-menu-link i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user-avatar {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.6);
}

.sidebar-user-email {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 170px;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
}

/* ===== Topbar ===== */
.topbar {
    height: var(--topbar-height);
    background: var(--surface-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
    flex-shrink: 0;
}

.topbar-title {
    flex: 1;
}

.topbar-title h1 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.btn-ghost {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
}

.btn-ghost:hover {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.sidebar-toggle {
    color: var(--text-secondary);
    padding: 4px;
    text-decoration: none;
}

/* ===== Content Area ===== */
.content-area {
    flex: 1;
    padding: 28px;
    overflow-y: auto;
}

/* ===== Auth Wrapper ===== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 50%, var(--accent) 100%);
    padding: 20px;
}

.auth-card {
    background: var(--surface-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 32px;
}

.auth-brand-icon {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 12px;
}

.auth-brand h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.auth-brand p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ===== Cards ===== */
.card {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-body {
    padding: 24px;
}

/* ===== Stat Cards ===== */
.stat-card {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 16px;
}

.stat-card-icon.blue {
    background: rgba(79, 143, 234, 0.1);
    color: var(--accent);
}

.stat-card-icon.green {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-card-icon.amber {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-card-icon.red {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.stat-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== Tables ===== */
.table-container {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-container .table {
    margin-bottom: 0;
}

.table {
    font-size: 0.875rem;
}

.table thead th {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text-primary);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table-hover tbody tr:hover {
    background: rgba(79, 143, 234, 0.03);
}

/* ===== Badges ===== */
.badge {
    font-weight: 500;
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.02em;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.badge-info {
    background: rgba(6, 182, 212, 0.1);
    color: #0891b2;
}

.badge-secondary {
    background: rgba(100, 116, 139, 0.1);
    color: #475569;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

/* ===== Buttons ===== */
.btn {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.8125rem;
    padding: 8px 16px;
    border-radius: var(--radius);
    transition: all var(--transition);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

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

.btn-outline-secondary {
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background: var(--surface);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.btn-outline-primary {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-outline-primary:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
}

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: #fff;
}

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

.btn-sm {
    padding: 5px 12px;
    font-size: 0.75rem;
}

/* ===== Forms ===== */
.form-label {
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control,
.form-select {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 14px;
    font-size: 0.875rem;
    transition: all var(--transition);
    color: var(--text-primary);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 143, 234, 0.12);
}

/* ===== Pagination ===== */
.pagination {
    gap: 4px;
}

.page-link {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 6px 12px;
}

.page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
}

/* ===== Page Headers ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* ===== Detail Lists ===== */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.detail-grid dt {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 14px 0 4px;
}

.detail-grid dd {
    font-size: 0.9rem;
    color: var(--text-primary);
    padding-bottom: 14px;
    margin: 0;
    border-bottom: 1px solid var(--border);
}

.detail-grid dd:last-of-type {
    border-bottom: none;
}

/* ===== Modal ===== */
.modal-content {
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 20px 24px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top: 1px solid var(--border);
    padding: 16px 24px;
}

/* ===== Utilities ===== */
.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.9rem;
}

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }
}

@media (min-width: 768px) {
    html {
        font-size: 14px;
    }
}

/* ===== Error Pages ===== */
.dev-error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 3rem 1.5rem;
    text-align: center;
}

.dev-error-illustration {
    width: 120px;
    height: 120px;
    margin-bottom: 1.75rem;
    animation: dev-err-float 4.5s ease-in-out infinite;
}

@keyframes dev-err-float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-8px); }
}

.dev-error-code {
    font-size: clamp(4.5rem, 16vw, 8rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.875rem;
    user-select: none;
}

.dev-error-code-500 {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

.dev-error-code-other {
    background: linear-gradient(135deg, var(--text-secondary, #64748b) 0%, var(--text-muted, #94a3b8) 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

.dev-error-title {
    font-size: clamp(1.25rem, 4vw, 1.625rem);
    font-weight: 700;
    color: var(--text-primary, #1a202c);
    margin: 0 0 0.75rem;
}

.dev-error-body {
    font-size: 0.9375rem;
    color: var(--text-secondary, #64748b);
    max-width: 38rem;
    line-height: 1.65;
    margin: 0 0 0.5rem;
}

.dev-error-ref {
    font-size: 0.8125rem;
    color: var(--text-muted, #94a3b8);
    margin: 0 0 2rem;
}

.dev-error-ref code {
    font-size: 0.8125rem;
    background: var(--surface, #f8f9fc);
    border: 1px solid var(--border, #e2e8f0);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    color: var(--text-secondary, #64748b);
}

.dev-error-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1.75rem;
}
