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

:root {
    --color-primary: #2563EB;
    --color-primary-dark: #1D4ED8;
    --color-primary-soft: #EFF6FF;
    --color-secondary: #64748B;
    --color-success: #16A34A;
    --color-success-soft: #F0FDF4;
    --color-warning: #F59E0B;
    --color-warning-soft: #FFFBEB;
    --color-danger: #DC2626;
    --color-danger-soft: #FEF2F2;
    --color-bg: #F8FAFC;
    --color-surface: #FFFFFF;
    --color-text: #0F172A;
    --color-muted: #64748B;
    --color-border: #E2E8F0;

    --sidebar-width: 260px;
    --sidebar-width-collapsed: 76px;
    --topbar-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgb(15 23 42 / 0.05);
    --shadow-md: 0 4px 12px -2px rgb(15 23 42 / 0.08);
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.55;
    overflow-x: hidden;
}

a {
    text-decoration: none;
}

/* ---------- Typography ---------- */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
}

.card-title-sm {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text);
}

.text-caption {
    font-size: 0.75rem;
    color: var(--color-muted);
}

.text-muted-custom {
    color: var(--color-muted) !important;
}

/* ---------- App Shell ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.25s ease, width 0.25s ease;
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
}

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

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 10px;
}

.nav-section-label {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-muted);
    padding: 0.75rem 0.75rem 0.375rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--color-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-link i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-link:hover {
    background: var(--color-primary-soft);
    color: var(--color-primary);
}

.sidebar-link.active {
    background: var(--color-primary);
    color: #fff;
}

.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.25s ease;
}

.topbar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    gap: 1rem;
}

.topbar-search {
    position: relative;
    max-width: 360px;
    flex: 1;
}

.topbar-search input {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    font-size: 0.875rem;
    width: 100%;
}

.topbar-search i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-muted);
}

.topbar-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-secondary);
    background: transparent;
    border: none;
    position: relative;
    transition: background-color 0.15s ease;
}

.topbar-icon-btn:hover {
    background: var(--color-bg);
}

.notif-dot {
    position: absolute;
    top: 6px;
    right: 7px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-danger);
    border: 2px solid var(--color-surface);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.25rem 0.5rem 0.25rem 0.25rem;
    border-radius: 999px;
    cursor: pointer;
}

.user-chip:hover {
    background: var(--color-bg);
}

.avatar-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8125rem;
    flex-shrink: 0;
}

.main-content {
    padding: 1.5rem;
    flex: 1;
}

.breadcrumb-custom {
    font-size: 0.8125rem;
    color: var(--color-muted);
    margin-bottom: 0.5rem;
}

.breadcrumb-custom a {
    color: var(--color-muted);
}

.breadcrumb-custom a:hover {
    color: var(--color-primary);
}

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

.kpi-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}

.kpi-trend {
    font-size: 0.75rem;
    font-weight: 600;
}

.kpi-trend.up { color: var(--color-success); }
.kpi-trend.down { color: var(--color-danger); }

/* ---------- Badges ---------- */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-info { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-muted { background: #F1F5F9; color: var(--color-muted); }

/* ---------- Forms ---------- */
.form-label-required::after {
    content: ' *';
    color: var(--color-danger);
}

.form-control, .form-select {
    border-color: var(--color-border);
    font-size: 0.875rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
}

.form-control:focus, .form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.12);
}

.form-helper {
    font-size: 0.75rem;
    color: var(--color-muted);
    margin-top: 0.25rem;
}

.form-error {
    font-size: 0.75rem;
    color: var(--color-danger);
    margin-top: 0.25rem;
}

.is-invalid {
    border-color: var(--color-danger) !important;
}

/* ---------- Buttons ---------- */
.btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.btn-primary:hover, .btn-primary:focus {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

.btn {
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.btn:focus-visible, a:focus-visible, input:focus-visible, .sidebar-link:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--color-muted);
}

.empty-state i {
    font-size: 2.5rem;
    color: var(--color-border);
    margin-bottom: 0.75rem;
}

.empty-state h6 {
    color: var(--color-text);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

/* ---------- Auth Pages ---------- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #F8FAFC 0%, #EFF6FF 100%);
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
}

.auth-brand-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
    margin: 0 auto 1rem;
}

/* ---------- Error Pages ---------- */
.error-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    padding: 1.5rem;
    text-align: center;
}

.error-code {
    font-size: 4rem;
    font-weight: 800;
    color: var(--color-primary);
    line-height: 1;
}

/* ---------- Timeline ---------- */
.timeline {
    position: relative;
    padding-left: 1.5rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--color-border);
}

.timeline-item {
    position: relative;
    padding-bottom: 1.25rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -1.5rem;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2px solid var(--color-surface);
    box-shadow: 0 0 0 2px var(--color-primary);
}

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

    .sidebar.show {
        transform: translateX(0);
        box-shadow: var(--shadow-md);
    }

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

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgb(15 23 42 / 0.4);
        z-index: 1035;
    }

    .sidebar-backdrop.show {
        display: block;
    }

    .topbar-search {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .main-content {
        padding: 1rem;
    }

    .kpi-value {
        font-size: 1.5rem;
    }
}

/* ---------- Print ---------- */
@media print {
    .sidebar, .topbar, .no-print {
        display: none !important;
    }

    .main-wrapper {
        margin-left: 0 !important;
    }
}
