:root {
    --color-primary: #ff9800;
    --color-primary-dark: #f57c00;
    --color-surface: #ffffff;
    --color-bg: #fff7ec;
    --color-text: #343a40;
    --color-text-muted: #6c757d;
    --color-border: #e9ecef;
    --color-sidebar: #1f2430;
    --color-sidebar-text: #e9ecef;
}
html[data-theme="dark"] {
    --color-surface: #1f2430;
    --color-bg: #12151c;
    --color-text: #f1f3f5;
    --color-text-muted: #a9adb3;
    --color-border: #333947;
    --color-sidebar: #161a23;
    --color-sidebar-text: #d0d4db;
}
* { box-sizing: border-box; }
body { font-family: 'Nunito', sans-serif; background: var(--color-bg); color: var(--color-text); margin: 0; transition: background .3s, color .3s; }
.app-layout { display: flex; min-height: 100vh; }

/* ============================================
   SIDEBAR — redesign
   ============================================ */
#sidebar {
    width: 264px;
    background: linear-gradient(180deg, var(--color-sidebar) 0%, rgba(0,0,0,.18) 100%), var(--color-sidebar);
    color: var(--color-sidebar-text);
    flex-shrink: 0;
    padding: 0 0 24px;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,152,0,.4) transparent;
}
#sidebar::-webkit-scrollbar { width: 6px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,152,0,.35); border-radius: 999px; }

#sidebar .sidebar-header {
    padding: 26px 22px 22px;
    text-align: center;
    position: relative;
}
#sidebar .sidebar-header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 22px; right: 22px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,152,0,.45), transparent);
}
#sidebar .sidebar-header img {
    max-width: 130px;
    max-height: 56px;
    display: block;
    margin: 0 auto 12px;
    background: #fff;
    padding: 6px 10px;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0,0,0,.28);
}
#sidebar .sidebar-header h3 {
    margin: 0;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: .5px;
    color: var(--color-primary);
}

#sidebar .components { list-style: none; padding: 14px 12px 0; margin: 0; }
#sidebar .components > li { margin-bottom: 3px; }

#sidebar .components > li > a,
#sidebar .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 12px;
    color: inherit;
    text-decoration: none;
    font-weight: 600;
    font-size: .92rem;
    cursor: pointer;
    transition: background .2s, color .2s, transform .15s;
}
#sidebar .components > li > a > i:first-child,
#sidebar .dropdown-toggle > i:first-child {
    width: 20px;
    text-align: center;
    font-size: .95rem;
    color: rgba(255,255,255,.55);
    transition: color .2s;
}
#sidebar .components > li > a:hover,
#sidebar .dropdown-toggle:hover {
    background: rgba(255,152,0,.14);
    color: #fff;
    transform: translateX(2px);
}
#sidebar .components > li > a:hover > i:first-child,
#sidebar .dropdown-toggle:hover > i:first-child { color: var(--color-primary); }

#sidebar .components > li.active > a {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: #fff;
    box-shadow: 0 6px 16px rgba(255,152,0,.35);
}
#sidebar .components > li.active > a > i:first-child { color: #fff; }

#sidebar .dropdown-toggle .arrow {
    margin-left: auto;
    font-size: .68rem;
    color: rgba(255,255,255,.4);
    transition: transform .3s, color .2s;
}
#sidebar .dropdown.open > .dropdown-toggle {
    background: rgba(255,152,0,.08);
    color: #fff;
}
#sidebar .dropdown.open > .dropdown-toggle .arrow {
    transform: rotate(180deg);
    color: var(--color-primary);
}

#sidebar .submenu {
    list-style: none;
    padding: 0;
    margin: 2px 0 4px;
    max-height: 0;
    overflow: hidden;
    transition: max-height .35s ease;
}
#sidebar .dropdown.open .submenu { max-height: 320px; }
#sidebar .submenu li { position: relative; }
#sidebar .submenu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px 9px 46px;
    margin: 0 6px;
    border-radius: 10px;
    font-size: .85rem;
    color: rgba(255,255,255,.65);
    text-decoration: none;
    position: relative;
}
#sidebar .submenu li a::before {
    content: '';
    position: absolute;
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255,255,255,.3);
    transition: background .2s, box-shadow .2s;
}
#sidebar .submenu li a:hover {
    background: rgba(255,152,0,.1);
    color: #fff;
}
#sidebar .submenu li a:hover::before { background: var(--color-primary); }
#sidebar .submenu li.active a {
    color: var(--color-primary);
    font-weight: 700;
    background: rgba(255,152,0,.08);
}
#sidebar .submenu li.active a::before {
    background: var(--color-primary);
    box-shadow: 0 0 8px var(--color-primary);
}

#sidebar .sidebar-section-title {
    padding: 18px 22px 8px;
    margin-top: 10px;
}
#sidebar .sidebar-section-title span {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,.35);
    font-weight: 700;
}

#sidebar .logout-link {
    color: #ff8a8a !important;
    margin: 18px 12px 0 !important;
    padding-top: 14px !important;
    border-top: 1px solid rgba(255,255,255,.08) !important;
}
#sidebar .logout-link > i:first-child { color: #ff8a8a !important; }
#sidebar .logout-link:hover {
    background: rgba(220,38,38,.16) !important;
    color: #fff !important;
}
#sidebar .logout-link:hover > i:first-child { color: #fff !important; }

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content-wrapper { padding: 24px; flex: 1; }

.top-navbar { background: var(--color-surface); padding: 12px 24px; display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--color-border); position: sticky; top: 0; z-index: 100; min-height: 68px; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.navbar-title { font-size: 1.2rem; font-weight: 700; margin: 0; flex: 1; }
.user-info { display: flex; align-items: center; gap: 14px; }
.user-avatar { font-size: 2rem; color: var(--color-primary); }
.user-details { display: flex; flex-direction: column; align-items: flex-end; }
.user-name { font-weight: 700; font-size: .92rem; }
.user-role-badge { font-size: .7rem; padding: 2px 10px; border-radius: 999px; color: #fff; font-weight: 700; }
.badge.bg-orange-500 { background: #f97316; }
.badge.bg-blue-500 { background: #3b82f6; }

.icon-btn { width: 42px; height: 42px; border-radius: 50%; background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .2s; }
.icon-btn:hover { color: var(--color-primary); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.08); }

.btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark)); color: #fff !important; border: none; cursor: pointer; font-weight: 700; transition: transform .15s, box-shadow .2s; box-shadow: 0 4px 14px rgba(255,152,0,.28); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(255,152,0,.4); }

.btn-hamburger { display: none; background: none; border: none; font-size: 1.4rem; color: var(--color-text); cursor: pointer; padding: 8px; }

.app-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.05); }

input, select, textarea { font-family: inherit; font-size: .95rem; transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-primary) !important; box-shadow: 0 0 0 4px rgba(255,152,0,.18); }

table { border-collapse: collapse; width: 100%; }

.footer { background: var(--color-surface); border-top: 1px solid var(--color-border); padding: 15px 24px; font-size: .85rem; color: var(--color-text-muted); }
.footer-content { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.footer-left, .footer-right { display: flex; align-items: center; gap: 10px; }
.footer-separator { color: var(--color-border); }

#appToast { position: fixed; top: 20px; right: 20px; z-index: 9999; max-width: 360px; padding: 14px 18px; border-radius: 12px; background: var(--color-surface); color: var(--color-text); box-shadow: 0 20px 50px rgba(0,0,0,.25); border-left: 4px solid var(--color-primary); display: flex; align-items: flex-start; gap: 10px; font-size: .9rem; transform: translateX(420px); opacity: 0; transition: transform .4s, opacity .4s; }
#appToast.danger { border-left-color: #dc2626; }
#appToast.success { border-left-color: #2e7d32; }
#appToast.warning { border-left-color: #e65100; }
#appToast.info { border-left-color: #2563eb; }
#appToast .close-toast { margin-left: auto; cursor: pointer; color: var(--color-text-muted); padding: 2px 6px; }

.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 150; }
.overlay.active { display: block; }

@media (max-width: 768px) {
    #sidebar { position: fixed; left: -280px; top: 0; bottom: 0; z-index: 200; transition: left .3s; box-shadow: 4px 0 20px rgba(0,0,0,.3); }
    #sidebar.open { left: 0; }
    .btn-hamburger { display: flex; }
    .content-wrapper { padding: 16px; }
    .user-details { display: none !important; }
    .navbar-title { font-size: 1rem; }
    #appToast { left: 16px; right: 16px; max-width: none; }
}