:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-text: #cbd5e1;
    --body-bg: #f1f5f9;
}

* { box-sizing: border-box; }
body { background: var(--body-bg); font-family: 'Segoe UI', system-ui, sans-serif; color: #1e293b; }

/* ============ AUTH ============ */
.auth-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%); padding: 1rem;
}
.auth-wrapper { width: 100%; max-width: 410px; }
.auth-card { background: #fff; border-radius: 16px; padding: 2.25rem; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth-logo { width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 16px;
    background: linear-gradient(135deg,#4f46e5,#7c3aed); color:#fff; font-size: 2rem;
    display:flex; align-items:center; justify-content:center; }
.auth-header { margin-bottom: 1.5rem; }
.demo-chip { background:#f1f5f9; border-radius:8px; padding:.4rem; font-weight:600; line-height:1.2; transition:.15s; }
.demo-chip:hover { background:#e0e7ff; }
.demo-chip span { font-weight:400; color:#64748b; font-size:.72rem; }

/* ============ LAYOUT ============ */
.app-layout { display: flex; min-height: 100vh; }
.app-sidebar {
    width: 260px; background: var(--sidebar-bg); color: var(--sidebar-text);
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 1040; overflow-y: auto;
    transition: transform .25s ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: .6rem; padding: 1.15rem 1.25rem;
    font-size: 1.2rem; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand i { color: #818cf8; font-size: 1.5rem; }
.sidebar-nav { padding: .75rem 0; }
.sidebar-heading { padding: .9rem 1.25rem .35rem; font-size: .7rem; text-transform: uppercase;
    letter-spacing: .05em; color: #64748b; font-weight: 700; }
.sidebar-link {
    display: flex; align-items: center; gap: .75rem; padding: .65rem 1.25rem;
    color: var(--sidebar-text); text-decoration: none; font-size: .92rem; transition: .15s;
    border-left: 3px solid transparent;
}
.sidebar-link i { font-size: 1.1rem; width: 20px; text-align: center; }
.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-link.active { background: var(--sidebar-hover); color: #fff; border-left-color: #818cf8; }
.sidebar-backdrop { display:none; position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:1039; }

.app-main { flex: 1; margin-left: 260px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: 64px; background: #fff; border-bottom: 1px solid #e2e8f0;
    display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem;
    position: sticky; top: 0; z-index: 1030;
}
.topbar-title { font-weight: 600; }
.app-content { padding: 1.5rem; flex: 1; }

.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
    color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.user-btn, .notif-btn { background: transparent; border: none; }
.notif-btn .notif-count { position: absolute; top: 2px; right: 2px; font-size: .6rem; }
.notif-menu { width: 340px; }

/* ============ CARDS / STATS ============ */
.stat-card { border: none; border-radius: 14px; overflow: hidden; transition: .2s; }
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.stat-icon { width: 52px; height: 52px; border-radius: 12px; display:flex;
    align-items:center; justify-content:center; font-size: 1.5rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-label { color: #64748b; font-size: .85rem; }

.card { border: none; border-radius: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card-header { background: #fff; border-bottom: 1px solid #eef2f7; font-weight: 600; border-radius: 14px 14px 0 0 !important; }
.table thead th { background: #f8fafc; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: #64748b; }
.page-header { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:.75rem; margin-bottom:1.25rem; }

/* progress meter */
.meter { height: 8px; border-radius: 4px; background: #e2e8f0; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 4px; }

/* notifications */
.notif-item { padding:.7rem 1rem; border-bottom:1px solid #f1f5f9; display:block; text-decoration:none; color:inherit; }
.notif-item:hover { background:#f8fafc; }
.notif-item.unread { background:#eef2ff; }
.notif-item .notif-title { font-weight:600; font-size:.85rem; }
.notif-item .notif-msg { font-size:.8rem; color:#64748b; }
.notif-item .notif-time { font-size:.72rem; color:#94a3b8; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); box-shadow: 4px 0 24px rgba(0,0,0,.25); }
    .app-sidebar.show { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .sidebar-backdrop.show { display: block; }
}

/* ============ MOBILE TWEAKS ============ */
@media (max-width: 767.98px) {
    .app-content { padding: 1rem .85rem; }
    .topbar { padding: 0 .85rem; gap: .5rem; }
    .topbar-title { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45vw; }

    /* Page header stacks vertically; action button goes full width */
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header .btn,
    .page-header > select { width: 100%; }

    .stat-value { font-size: 1.4rem; }
    .stat-icon { width: 44px; height: 44px; font-size: 1.25rem; }
    .card-body { padding: 1rem; }

    /* DataTables controls stack and fill width on mobile */
    .dataTables_wrapper .row > div { width: 100%; text-align: left !important; margin-bottom: .4rem; }
    .dataTables_filter input { width: 100%; margin-left: 0 !important; }
    .dataTables_length select { min-width: 70px; }
    table.dataTable { font-size: .85rem; }

    /* Tables that are not DataTables: allow horizontal scroll */
    .table-responsive { -webkit-overflow-scrolling: touch; }

    /* Notification dropdown fits small screens */
    .notif-menu { width: 92vw; max-width: 340px; }

    .modal-dialog { margin: .5rem; }
    .auth-card { padding: 1.5rem; }
}

@media (max-width: 575.98px) {
    .topbar-title { max-width: 38vw; }
    .stat-label { font-size: .78rem; }
    h4 { font-size: 1.15rem; }
}

/* DataTables Responsive: child-row expand icon styling */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before {
    background-color: var(--primary);
    border-color: var(--primary);
}
