:root {
    --primary: #EE7A1E;
    --primary-hover: #D9680D;
    --primary-light: #FEF0E3;
    --navy: #152B4E;
    --navy-dark: #0E1D36;
    --bg: #F6F1E6;
    --text: #152B4E;
    --text-muted: #8C816C;
    --border: #EDE2CC;
    --white: #ffffff;
    --shadow: 0 6px 20px rgba(21, 43, 78, 0.06);
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

.app-wrapper { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--navy) 0%, var(--navy-dark) 100%);
    color: #fff;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1040;
    box-shadow: 4px 0 24px rgba(21, 43, 78, 0.1);
}

.sidebar-brand {
    padding: 1.6rem 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
}

.sidebar-logo {
    width: 150px;
    height: auto;
    display: block;
}

.sidebar-menu { list-style: none; margin: 0; padding: 1rem 0.75rem; flex: 1; }

.menu-header {
    padding: 0.9rem 0.75rem 0.4rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.4);
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.8rem 0.9rem;
    margin-bottom: 0.3rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    border-radius: 10px;
    transition: all 0.2s ease;
}

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

.sidebar-menu li.active a {
    background: linear-gradient(135deg, var(--primary), #F49A45);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(238, 122, 30, 0.35);
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.45);
}

/* ---------- Main ---------- */
.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.sidebar-toggle { border: 0; background: none; font-size: 22px; color: var(--text); display: none; margin-right: 10px; }

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    background: var(--primary-light);
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    border: 1px solid rgba(238, 122, 30, 0.25);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text);
}

.user-badge .role-tag {
    background: var(--primary);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
}

.page-container { padding: 1.75rem; flex: 1; }

/* ---------- Cards ---------- */
.card-custom {
    background: var(--white);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card-custom-body { padding: 1.4rem; }

.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    box-shadow: var(--shadow);
    height: 100%;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(21, 43, 78, 0.1); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-label { color: var(--text-muted); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 0.25rem; }
.stat-value { font-size: 1.35rem; font-weight: 800; color: var(--text); line-height: 1.1; }

/* ---------- Buttons ---------- */
.btn-primary-custom {
    background: linear-gradient(135deg, var(--primary), #F49A45);
    border: none;
    color: #fff;
    font-weight: 600;
    padding: 0.55rem 1.3rem;
    border-radius: 10px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(238, 122, 30, 0.3);
}

.btn-primary-custom:hover { background: linear-gradient(135deg, var(--primary-hover), var(--primary)); color: #fff; transform: translateY(-1px); }

/* ---------- Tables ---------- */
.table-custom { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

.table-custom thead th {
    background: #FAF4E8;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table-custom tbody td { padding: 0.9rem 1rem; border-bottom: 1px solid #F2EADA; vertical-align: middle; }
.table-custom tbody tr:last-child td { border-bottom: 0; }
.table-custom tbody tr:hover { background: #FDFAF3; }

/* ---------- Login ---------- */
.login-bg {
    min-height: 100vh;
    background:
        radial-gradient(circle at 20% 20%, rgba(238, 122, 30, 0.18) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(250, 172, 48, 0.12) 0%, transparent 40%),
        linear-gradient(135deg, #152B4E 0%, #0E1D36 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    background: var(--white);
    width: 100%;
    max-width: 420px;
    border-radius: 20px;
    padding: 2.75rem;
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.35);
}

.login-logo-wrap {
    width: 92px;
    height: 92px;
    margin: 0 auto 1.1rem;
    border-radius: 20px;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    border: 1px solid rgba(238, 122, 30, 0.2);
}

.login-logo { width: 100%; height: 100%; object-fit: contain; display: block; }

.login-card h4 { color: var(--text); font-weight: 800; }

.input-icon {
    background: var(--primary-light);
    border: 1px solid var(--border);
    border-right: 0;
    border-radius: 10px 0 0 10px !important;
    color: var(--primary);
}

.form-control {
    border-radius: 10px;
    border-color: var(--border);
    padding: 0.6rem 0.9rem;
}

.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 0.2rem rgba(238, 122, 30, 0.15); }

.form-label { font-weight: 700; font-size: 0.72rem; letter-spacing: 0.05em; color: var(--text-muted); }

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: inline-flex; align-items: center; }
    .sidebar-overlay.open { display: block; }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(14, 29, 54, 0.5);
    z-index: 1035;
}

@media (max-width: 575px) {
    .page-container { padding: 1rem; }
    .topbar { padding: 0.75rem 1rem; }
    .user-badge span:first-child { display: none; }
    .login-card { padding: 2rem; }
}
