/* ── Base ─────────────────────────────────────────── */
html { font-size: 14px; }
@media (min-width: 768px) { html { font-size: 15px; } }
body { margin: 0; }

/* ── Auth Layout ──────────────────────────────────── */
body.auth-layout {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 60%, #15294a 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}
.auth-wrapper { width: 100%; max-width: 440px; }
.auth-card {
    background: #fff;
    border-radius: 1.25rem;
    box-shadow: 0 24px 60px rgba(0,0,0,.35);
    padding: 2.75rem 2.5rem;
}
.auth-brand { text-align: center; margin-bottom: 2rem; }
.auth-brand-icon { font-size: 2.75rem; display: block; margin-bottom: .4rem; }
.auth-brand-name { font-size: 1.4rem; font-weight: 700; color: #0f172a; }
.auth-brand-sub { font-size: .8rem; color: #64748b; margin-top: .15rem; }
.auth-footer { color: rgba(255,255,255,.35); font-size: .78rem; text-align: center; margin-top: 1.5rem; }

/* ── Sidebar variables ────────────────────────────── */
:root {
    --sb-w: 255px;
    --sb-bg: #0f172a;
    --sb-text: #94a3b8;
    --sb-hover-bg: rgba(255,255,255,.06);
    --sb-active-color: #60a5fa;
    --tb-h: 58px;
}

/* ── Sidebar ──────────────────────────────────────── */
#appSidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sb-w);
    height: 100%;
    background: var(--sb-bg);
    z-index: 1040;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform .25s ease;
    display: flex;
    flex-direction: column;
}
.sb-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 1.3rem 1.25rem;
    color: #fff;
    font-weight: 700;
    font-size: .95rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    text-decoration: none;
    flex-shrink: 0;
}
.sb-brand:hover { color: #fff; text-decoration: none; }
.sb-brand-icon { font-size: 1.6rem; line-height: 1; flex-shrink: 0; }
.sb-section {
    font-size: .63rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(255,255,255,.28);
    padding: 1.2rem 1.25rem .3rem;
    font-weight: 600;
    user-select: none;
}
.sb-nav { list-style: none; margin: 0; padding: .35rem .5rem; }
.sb-nav li { margin: 1px 0; }
.sb-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 7px;
    color: var(--sb-text);
    font-size: .875rem;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.sb-nav a:hover { background: var(--sb-hover-bg); color: #e2e8f0; text-decoration: none; }
.sb-nav a.active { background: rgba(96,165,250,.13); color: var(--sb-active-color); font-weight: 600; }
.sb-nav a .sb-icon { width: 18px; text-align: center; font-size: .9rem; opacity: .8; }
.sb-nav a.active .sb-icon { opacity: 1; }
.sb-spacer { flex: 1; }
.sb-footer {
    padding: .85rem 1.25rem;
    font-size: .73rem;
    color: rgba(255,255,255,.2);
    border-top: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

/* ── Page Wrapper ─────────────────────────────────── */
#pageWrapper {
    margin-left: var(--sb-w);
    min-height: 100vh;
    background: #f1f5f9;
    display: flex;
    flex-direction: column;
}

/* ── Top bar ──────────────────────────────────────── */
.app-topbar {
    height: var(--tb-h);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: .75rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    flex-shrink: 0;
}
.topbar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 .25rem;
    color: #64748b;
    line-height: 1;
}
.topbar-title {
    font-weight: 600;
    font-size: .95rem;
    color: #1e293b;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.topbar-user { display: flex; align-items: center; gap: .6rem; color: #374151; font-size: .875rem; font-weight: 500; }
.topbar-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: #3b82f6;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: .7rem;
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
}
.topbar-logout {
    font-size: .8rem;
    color: #94a3b8;
    background: none;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.topbar-logout:hover { color: #ef4444; border-color: #fca5a5; }

/* ── Page content ─────────────────────────────────── */
.page-content { flex: 1; padding: 1.5rem; }

/* ── App footer ───────────────────────────────────── */
.app-footer {
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding: .7rem 1.5rem;
    font-size: .78rem;
    color: #94a3b8;
    text-align: center;
    flex-shrink: 0;
}

/* ── Sidebar overlay on mobile ────────────────────── */
#sbOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1039;
}
#sbOverlay.show { display: block; }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 991.98px) {
    #appSidebar { transform: translateX(calc(-1 * var(--sb-w))); }
    #appSidebar.sb-open { transform: translateX(0); }
    #pageWrapper { margin-left: 0; }
    .topbar-toggle { display: block; }
}

/* ── Card overrides ───────────────────────────────── */
.card { border: 1px solid #e8edf2; border-radius: .625rem; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.card-header { background: #fff; border-bottom: 1px solid #f1f5f9; font-weight: 600; border-radius: .625rem .625rem 0 0 !important; padding: .85rem 1.25rem; }
.card-body { padding: 1.25rem; }

/* ── Focus rings ──────────────────────────────────── */
.btn:focus, .form-control:focus, .form-select:focus, .form-check-input:focus {
    box-shadow: 0 0 0 .2rem rgba(59,130,246,.2);
}

/* ── DataTable overrides ──────────────────────────── */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: .85rem;
}
.dataTables_wrapper .dataTables_info { font-size: .8rem; color: #6b7280; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: #3b82f6 !important;
    color: #fff !important;
    border-color: #3b82f6 !important;
    border-radius: 5px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #f1f5f9 !important;
    color: #374151 !important;
    border-color: #e2e8f0 !important;
    border-radius: 5px;
}
table.dataTable thead th { white-space: nowrap; }
table.dataTable thead .sorting:after,
table.dataTable thead .sorting_asc:after,
table.dataTable thead .sorting_desc:after { opacity: .6; }
