:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --card: #ffffff;
    --panel: #ffffff;
    --background: #f4f7fb;
    --surface-2: #eef3fb;
    --text: #172033;
    --muted: #6b7280;
    --line: #dbe3ef;
    --border: #dbe3ef;
    --primary: #2563eb;
    --brand: #2563eb;
    --brand-2: #0f766e;
    --danger: #dc2626;
    --warning: #d97706;
    --success: #16a34a;
    --shadow: 0 22px 55px rgba(15, 23, 42, .10);
    --radius: 22px;
}

html[data-theme="dark"],
html.dark,
html.dark-mode,
html.theme-dark {
    --bg: #09111f;
    --background: #09111f;
    --surface: #111827;
    --card: #111827;
    --panel: #111827;
    --surface-2: #172033;
    --text: #f9fafb;
    --muted: #a6b0c3;
    --line: #263348;
    --border: #263348;
    --primary: #60a5fa;
    --brand: #60a5fa;
    --brand-2: #2dd4bf;
    --shadow: 0 22px 55px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, .18), transparent 28rem),
        radial-gradient(circle at bottom right, rgba(15, 118, 110, .14), transparent 28rem),
        var(--bg);
}

html.dark body,
html.dark-mode body,
html.theme-dark body,
body.dark,
body.dark-mode,
body.theme-dark,
body[data-theme="dark"] {
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(96, 165, 250, .12), transparent 28rem),
        radial-gradient(circle at bottom right, rgba(45, 212, 191, .10), transparent 28rem),
        var(--bg);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 285px 1fr;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 18px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    border-right: 1px solid var(--line);
    backdrop-filter: blur(18px);
    overflow-y: auto;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px 10px 24px;
}
.brand img {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    object-fit: cover;
    border: 1px solid var(--line);
    background: var(--surface-2);
}
.brand strong { display: block; font-size: 15px; line-height: 1.2; }
.brand span { color: var(--muted); font-size: 12px; }

.nav-list { display: grid; gap: 8px; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 13px;
    border-radius: 15px;
    color: var(--muted);
    transition: .18s ease;
}
.nav-link:hover, .nav-link.active {
    color: var(--text);
    background: linear-gradient(135deg, rgba(37, 99, 235, .14), rgba(15, 118, 110, .10));
}
.nav-icon {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    display: inline-grid;
    place-items: center;
    background: var(--surface-2);
    color: var(--brand);
    font-size: 15px;
    flex: 0 0 auto;
}

.main-panel {
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 76px;
    padding: 16px 26px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    backdrop-filter: blur(18px);
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}
.topbar-title h1 { margin: 0; font-size: clamp(22px, 2.5vw, 31px); letter-spacing: -.03em; }
.topbar-title p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
}
.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: white;
    display: inline-grid;
    place-items: center;
    font-weight: 800;
}
.content { padding: 26px; width: min(1500px, 100%); }
.footer { padding: 18px 26px 30px; color: var(--muted); font-size: 13px; }

.card {
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card.pad { padding: 22px; }
.card-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}
.card-header h2 { margin: 0; font-size: 18px; }
.card-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--surface) 86%, transparent), color-mix(in srgb, var(--surface-2) 80%, transparent));
}
.stat span { color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 8px; font-size: 30px; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.searchbox {
    min-width: min(360px, 100%);
    position: relative;
}
.searchbox input { padding-left: 40px; }
.searchbox:before {
    content: '⌕';
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

.btn {
    border: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 14px;
    padding: 10px 14px;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    transition: .18s ease;
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.02); }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: white; }
.btn.danger { background: rgba(220, 38, 38, .12); color: var(--danger); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.small { padding: 7px 10px; border-radius: 11px; font-size: 13px; }
.btn.icon-only { width: 42px; padding-inline: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 800; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 800;
    background: var(--surface-2);
    color: var(--muted);
}
.badge.Active { background: rgba(22, 163, 74, .13); color: var(--success); }
.badge.Inactive { background: rgba(107, 114, 128, .15); color: var(--muted); }
.badge.Suspended { background: rgba(220, 38, 38, .13); color: var(--danger); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
label { color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 11px 13px;
    background: var(--surface);
    color: var(--text);
    outline: none;
}
textarea { min-height: 105px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    border-color: color-mix(in srgb, var(--brand) 70%, var(--line));
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: none;
    background: rgba(2, 6, 23, .62);
    padding: 24px;
    overflow-y: auto;
}
.modal-backdrop.open { display: grid; place-items: start center; }
.modal {
    width: min(780px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 26px;
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-block: 24px;
}
.modal.large { width: min(980px, 100%); }
.modal-header, .modal-footer {
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}
.modal-footer { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; }
.modal-body { padding: 20px; }
.modal h3 { margin: 0; }

.tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab-button {
    border: 0;
    padding: 12px 14px;
    color: var(--muted);
    background: transparent;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 800;
}
.tab-button.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.access-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.check-card {
    border: 1px solid var(--line);
    background: var(--surface-2);
    border-radius: 15px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.check-card input { width: auto; }


.profile-photo-xl {
    width: 132px;
    height: 132px;
    border-radius: 38px;
    object-fit: cover;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    background: var(--surface-2);
}
.profile-photo-xl.initials {
    display: inline-grid;
    place-items: center;
    font-size: 48px;
    font-weight: 900;
    color: white;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.profile-facts {
    display: grid;
    gap: 10px;
}
.profile-facts div {
    padding: 12px;
    border-radius: 16px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}
.profile-facts span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 5px;
}
.profile-facts strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: 14px;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-card {
    width: min(1060px, 100%);
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    overflow: hidden;
}
.login-hero {
    padding: 42px;
    background: linear-gradient(135deg, rgba(37, 99, 235, .18), rgba(15, 118, 110, .16));
}
.login-hero img { width: 76px; height: 76px; object-fit: cover; border-radius: 22px; border: 1px solid var(--line); }
.login-hero h1 { font-size: clamp(34px, 4vw, 54px); letter-spacing: -.05em; margin: 28px 0 12px; }
.login-form { padding: 42px; }

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 90;
    display: grid;
    gap: 10px;
}
.toast-item {
    min-width: min(360px, calc(100vw - 36px));
    padding: 13px 15px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.toast-item.success { border-color: rgba(22, 163, 74, .35); }
.toast-item.error { border-color: rgba(220, 38, 38, .35); }

.mobile-menu { display: none; }

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .content > .grid[style] { grid-template-columns: 1fr !important; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 60;
        width: 290px;
        transform: translateX(-105%);
        transition: .22s ease;
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .mobile-menu { display: inline-flex; }
    .content, .topbar { padding-inline: 18px; }
    .grid-2, .grid-3, .form-grid, .login-card { grid-template-columns: 1fr; }
    .login-hero { display: none; }
    .user-chip span { display: none; }
}

@media (max-width: 620px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .topbar-actions { width: 100%; justify-content: space-between; }
    .toolbar { align-items: stretch; }
    .toolbar > * { width: 100%; }
    .access-grid { grid-template-columns: 1fr; }
    th, td { padding: 12px; }
}

/* NWA IPTV module design + dark-mode compatibility patch */
:root {
    color-scheme: light;
    --hero-from: #0f172a;
    --hero-mid: #1e3a8a;
    --hero-to: #0891b2;
    --soft-blue: rgba(37, 99, 235, .10);
    --soft-cyan: rgba(14, 165, 233, .10);
    --soft-green: rgba(22, 163, 74, .12);
    --soft-amber: rgba(217, 119, 6, .13);
    --soft-red: rgba(220, 38, 38, .12);
}
html[data-theme="dark"], html.dark, html.dark-mode, html.theme-dark {
    color-scheme: dark;
    --hero-from: #020617;
    --hero-mid: #0f172a;
    --hero-to: #155e75;
    --soft-blue: rgba(96, 165, 250, .16);
    --soft-cyan: rgba(34, 211, 238, .13);
    --soft-green: rgba(34, 197, 94, .15);
    --soft-amber: rgba(251, 191, 36, .15);
    --soft-red: rgba(248, 113, 113, .15);
}
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .grid-4 { grid-template-columns: 1fr; } }

.card, .stat, .modal, .toast-item, .check-card,
.iptv-card, .iptv-kpi, .billing-card, .billing-kpi,
.employee-profile-card, .release-detail-card, .cash-info-box,
.loan-info-box, .payroll-info-box, .attendance-info-box,
.portal-card, .subscriber-card, .tech-card, .it-card, .settings-card {
    background: color-mix(in srgb, var(--surface) 94%, transparent) !important;
    border-color: var(--line) !important;
    color: var(--text) !important;
}
.stat, .iptv-kpi, .billing-kpi {
    box-shadow: 0 10px 28px rgba(15, 23, 42, .08);
}
html.dark .stat, html.dark .iptv-kpi, html.dark .billing-kpi,
html.dark-mode .stat, html.dark-mode .iptv-kpi, html.dark-mode .billing-kpi,
html.theme-dark .stat, html.theme-dark .iptv-kpi, html.theme-dark .billing-kpi {
    box-shadow: 0 16px 36px rgba(0, 0, 0, .32) !important;
}

.iptv-hero, .billing-hero, .module-hero, .page-hero {
    background: linear-gradient(135deg, var(--hero-from), var(--hero-mid) 55%, var(--hero-to)) !important;
    color: #fff !important;
    border: 1px solid rgba(255,255,255,.16) !important;
    border-radius: 24px !important;
    box-shadow: 0 18px 42px rgba(15,23,42,.20) !important;
}
.iptv-hero *, .billing-hero *, .module-hero *, .page-hero * { color: inherit; }
.iptv-hero p, .billing-hero p, .module-hero p, .page-hero p { color: #dbeafe !important; }
.iptv-pill, .billing-pill, .module-pill {
    background: rgba(255,255,255,.14) !important;
    border: 1px solid rgba(255,255,255,.26) !important;
    color: #fff !important;
}
.iptv-pill:hover, .billing-pill:hover, .module-pill:hover { background: rgba(255,255,255,.22) !important; }

input, select, textarea, .form-control, .form-select {
    background: var(--surface) !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
}
input::placeholder, textarea::placeholder { color: var(--muted) !important; opacity: .85; }
select option { background: var(--surface); color: var(--text); }

.table-wrap, .iptv-table-wrap, .billing-table-wrap, .data-table-wrap {
    border-color: var(--line) !important;
    background: var(--surface) !important;
}
table, .iptv-table, .billing-table { color: var(--text) !important; }
th, .iptv-table th, .billing-table th {
    background: color-mix(in srgb, var(--surface-2) 78%, transparent) !important;
    color: var(--muted) !important;
    border-color: var(--line) !important;
}
td, .iptv-table td, .billing-table td { border-color: var(--line) !important; color: var(--text); }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 58%, transparent) !important; }
.money, .amount, .total-amount { color: var(--text) !important; font-weight: 900; }
.muted, small, .text-muted { color: var(--muted) !important; }

.btn.success, .btn.success-soft { background: var(--soft-green) !important; color: var(--success) !important; border: 1px solid rgba(22,163,74,.22) !important; }
.btn.warning, .btn.warning-soft { background: var(--soft-amber) !important; color: var(--warning) !important; border: 1px solid rgba(217,119,6,.22) !important; }
.btn.danger, .btn.danger-soft { background: var(--soft-red) !important; color: var(--danger) !important; border: 1px solid rgba(220,38,38,.22) !important; }
.btn.primary { color: #fff !important; border: 0 !important; }
.btn.ghost { background: transparent !important; border: 1px solid var(--line) !important; color: var(--text) !important; }

.badge.Pending, .badge.PendingVerification, .badge.pending, .badge.cash-status-pending, .badge.loan-status-pending,
.badge.payment-status-pending { background: var(--soft-amber) !important; color: var(--warning) !important; }
.badge.Verified, .badge.Approved, .badge.Activated, .badge.Active, .badge.verified, .badge.approved, .badge.active,
.badge.cash-status-paid, .badge.loan-status-paid, .badge.payment-status-paid { background: var(--soft-green) !important; color: var(--success) !important; }
.badge.Rejected, .badge.Cancelled, .badge.Expired, .badge.rejected, .badge.cancelled, .badge.expired,
.badge.cash-status-rejected, .badge.cash-status-cancelled, .badge.loan-status-rejected, .badge.loan-status-cancelled { background: var(--soft-red) !important; color: var(--danger) !important; }
.badge.Released, .badge.cash-status-released, .badge.loan-status-released { background: rgba(124, 58, 237, .14) !important; color: #a78bfa !important; }

.mini-row, .profile-facts div, .release-detail-card, .holiday-day, .holiday-calendar-cell,
.attendance-summary-card, .employee-profile-card, .loan-payment-row, .cash-payment-row {
    background: color-mix(in srgb, var(--surface-2) 70%, transparent) !important;
    border-color: var(--line) !important;
    color: var(--text) !important;
}

html.dark [style*="background:#fff"], html.dark [style*="background: #fff"], html.dark [style*="background:white"], html.dark [style*="background: white"],
html.dark-mode [style*="background:#fff"], html.dark-mode [style*="background: #fff"], html.dark-mode [style*="background:white"], html.dark-mode [style*="background: white"],
html.theme-dark [style*="background:#fff"], html.theme-dark [style*="background: #fff"], html.theme-dark [style*="background:white"], html.theme-dark [style*="background: white"] {
    background: var(--surface) !important;
    color: var(--text) !important;
}
html.dark [style*="background:#f8fafc"], html.dark [style*="background: #f8fafc"], html.dark [style*="background:#f1f5f9"], html.dark [style*="background: #f1f5f9"],
html.dark-mode [style*="background:#f8fafc"], html.dark-mode [style*="background: #f8fafc"], html.dark-mode [style*="background:#f1f5f9"], html.dark-mode [style*="background: #f1f5f9"],
html.theme-dark [style*="background:#f8fafc"], html.theme-dark [style*="background: #f8fafc"], html.theme-dark [style*="background:#f1f5f9"], html.theme-dark [style*="background: #f1f5f9"] {
    background: var(--surface-2) !important;
    color: var(--text) !important;
}
html.dark [style*="color:#0f172a"], html.dark [style*="color: #0f172a"], html.dark [style*="color:#111827"], html.dark [style*="color: #111827"],
html.dark-mode [style*="color:#0f172a"], html.dark-mode [style*="color: #0f172a"], html.dark-mode [style*="color:#111827"], html.dark-mode [style*="color: #111827"],
html.theme-dark [style*="color:#0f172a"], html.theme-dark [style*="color: #0f172a"], html.theme-dark [style*="color:#111827"], html.theme-dark [style*="color: #111827"] {
    color: var(--text) !important;
}
html.dark [style*="color:#64748b"], html.dark [style*="color: #64748b"], html.dark [style*="color:#6b7280"], html.dark [style*="color: #6b7280"],
html.dark-mode [style*="color:#64748b"], html.dark-mode [style*="color: #64748b"], html.dark-mode [style*="color:#6b7280"], html.dark-mode [style*="color: #6b7280"],
html.theme-dark [style*="color:#64748b"], html.theme-dark [style*="color: #64748b"], html.theme-dark [style*="color:#6b7280"], html.theme-dark [style*="color: #6b7280"] {
    color: var(--muted) !important;
}

.nav-children, .nav-section-label { color: var(--muted); }
.nav-child-link { color: var(--muted); }
.nav-child-link:hover, .nav-child-link.active { color: var(--text); background: color-mix(in srgb, var(--surface-2) 72%, transparent); }

@media (max-width: 820px) {
    .iptv-hero, .billing-hero, .module-hero, .page-hero { border-radius: 18px !important; }
}

.hr-hero { display:flex; align-items:center; justify-content:space-between; gap:18px; padding:24px; margin-bottom:18px; }
.hr-hero h1 { margin:4px 0 6px; font-size:clamp(26px,4vw,42px); font-weight:900; letter-spacing:-.04em; }
.hr-hero p { max-width:760px; margin:0; }
@media(max-width:820px){ .hr-hero{flex-direction:column; align-items:flex-start;} }


/* =========================================================
   Responsive shell upgrade: collapsible sidebar + compact header
========================================================= */
.sidebar-backdrop { display:none; }
.sidebar-head { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:8px; }
.sidebar-collapse-btn { flex:0 0 auto; }
.brand { min-width:0; border-radius:18px; }
.brand-logo { transition: .18s ease; }
.brand-text { min-width:0; }
.brand-text strong, .brand-text span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:175px; }
.topbar { min-height:58px; padding:10px 18px; }
.topbar-title h1 { font-size: clamp(18px, 2vw, 24px); }
.topbar-title p { font-size:12px; margin-top:1px; }
.topbar-actions { flex-wrap:nowrap; }
.compact-theme-btn { min-height:38px; padding:8px 11px; font-size:12px; }
.notify-btn { position:relative; min-width:40px; min-height:40px; }
.notify-badge { position:absolute; top:-6px; right:-6px; min-width:19px; height:19px; padding:0 5px; border-radius:999px; background:var(--danger); color:#fff; font-size:11px; font-weight:900; display:grid; place-items:center; border:2px solid var(--surface); }
body.sidebar-collapsed .app-shell { grid-template-columns: 88px 1fr; }
body.sidebar-collapsed .sidebar { padding:14px 12px; }
body.sidebar-collapsed .brand { justify-content:center; padding:10px 6px 12px; }
body.sidebar-collapsed .brand-logo { width:42px; height:42px; border-radius:14px; }
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-link > span:not(.nav-icon),
body.sidebar-collapsed .nav-parent-title,
body.sidebar-collapsed .nav-caret,
body.sidebar-collapsed .nav-section-label > span:not(.nav-icon),
body.sidebar-collapsed .nav-children { display:none !important; }
body.sidebar-collapsed .nav-link,
body.sidebar-collapsed .nav-section-label,
body.sidebar-collapsed .nav-parent { justify-content:center; padding:10px; }
body.sidebar-collapsed .nav-icon { width:38px; height:38px; }
body.sidebar-collapsed .sidebar-head { justify-content:center; flex-direction:column; }
.mobile-menu { display:none; }
@media (max-width: 980px) {
    .app-shell { grid-template-columns:1fr; }
    .sidebar { position:fixed; left:0; top:0; bottom:0; width:min(86vw, 320px); height:100dvh; z-index:80; transform:translateX(-105%); transition:transform .22s ease; box-shadow: 24px 0 80px rgba(15,23,42,.22); }
    body.sidebar-open .sidebar { transform:translateX(0); }
    body.sidebar-open .sidebar-backdrop { display:block; position:fixed; inset:0; z-index:70; background:rgba(2,6,23,.45); backdrop-filter:blur(2px); }
    body.sidebar-collapsed .app-shell { grid-template-columns:1fr; }
    body.sidebar-collapsed .sidebar { padding:18px; }
    body.sidebar-collapsed .brand-text,
    body.sidebar-collapsed .nav-link > span:not(.nav-icon),
    body.sidebar-collapsed .nav-parent-title,
    body.sidebar-collapsed .nav-caret,
    body.sidebar-collapsed .nav-section-label > span:not(.nav-icon) { display:inline !important; }
    body.sidebar-collapsed .nav-children { display:none; }
    body.sidebar-collapsed .nav-group.open .nav-children { display:grid; }
    body.sidebar-collapsed .nav-link,
    body.sidebar-collapsed .nav-section-label,
    body.sidebar-collapsed .nav-parent { justify-content:flex-start; }
    .sidebar-collapse-btn { display:none; }
    .mobile-menu { display:inline-flex; }
    .topbar { padding:9px 12px; gap:10px; }
    .topbar-title { min-width:0; flex:1; }
    .topbar-title h1 { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .topbar-title p { display:none; }
    .topbar-actions { gap:6px; }
    .user-chip { padding:5px; }
    .user-chip span:not(.avatar) { display:none; }
    .topbar .btn.danger { padding:8px 10px; font-size:12px; }
    .compact-theme-btn { width:40px; padding:0; font-size:0; }
    .compact-theme-btn:before { content:'◐'; font-size:16px; }
    .content { padding:14px; }
    .footer { padding:14px 16px 24px; }
}
@media (max-width: 520px) {
    .topbar .btn.danger { display:none; }
    .notify-btn { min-width:38px; min-height:38px; }
}


/* Mobile dark-mode toggle visibility fix */
@media (max-width: 820px) {
    .topbar-actions .compact-theme-btn,
    .topbar-actions #globalThemeToggle,
    #globalThemeToggle[data-theme-toggle] {
        display: inline-grid !important;
        place-items: center !important;
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        max-width: 34px !important;
        padding: 0 !important;
        margin: 0 !important;
        border-radius: 12px !important;
        font-size: 0 !important;
        line-height: 1 !important;
        overflow: visible !important;
        opacity: 1 !important;
        visibility: visible !important;
        flex: 0 0 34px !important;
        color: var(--text, #0f172a) !important;
        background: var(--soft, rgba(37,99,235,.08)) !important;
        border: 1px solid var(--line, rgba(148,163,184,.28)) !important;
    }

    html.dark .topbar-actions .compact-theme-btn,
    html.dark-mode .topbar-actions .compact-theme-btn,
    html.theme-dark .topbar-actions .compact-theme-btn,
    html[data-theme="dark"] .topbar-actions .compact-theme-btn,
    body.dark .topbar-actions .compact-theme-btn,
    body.dark-mode .topbar-actions .compact-theme-btn,
    body.theme-dark .topbar-actions .compact-theme-btn,
    body[data-theme="dark"] .topbar-actions .compact-theme-btn {
        color: #f8fafc !important;
        background: rgba(30,41,59,.92) !important;
        border-color: rgba(148,163,184,.35) !important;
    }

    .topbar-actions .compact-theme-btn::before,
    .topbar-actions #globalThemeToggle::before,
    #globalThemeToggle[data-theme-toggle]::before {
        content: '◐' !important;
        display: block !important;
        font-size: 17px !important;
        line-height: 1 !important;
    }
}

@media (max-width: 520px) {
    .topbar-actions .compact-theme-btn,
    .topbar-actions #globalThemeToggle,
    #globalThemeToggle[data-theme-toggle] {
        display: inline-grid !important;
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        max-width: 32px !important;
        flex-basis: 32px !important;
        border-radius: 11px !important;
    }

    .topbar-actions .compact-theme-btn::before,
    .topbar-actions #globalThemeToggle::before,
    #globalThemeToggle[data-theme-toggle]::before {
        font-size: 16px !important;
    }

    .topbar-actions {
        gap: 3px !important;
    }
}


/* Icon-only theme toggle: moon in light mode, sun in dark mode */
.theme-icon-toggle,
#globalThemeToggle.theme-icon-toggle {
    font-size: 0 !important;
    gap: 0 !important;
    display: inline-grid !important;
    place-items: center !important;
    position: relative !important;
}
.theme-icon-toggle::before,
#globalThemeToggle.theme-icon-toggle::before {
    content: none !important;
    display: none !important;
}
.theme-icon-toggle .theme-icon,
#globalThemeToggle.theme-icon-toggle .theme-icon {
    grid-area: 1 / 1;
    font-size: 18px !important;
    line-height: 1 !important;
    width: 1em;
    height: 1em;
    display: inline-grid !important;
    place-items: center !important;
    transition: transform .18s ease, opacity .18s ease;
}
.theme-icon-toggle .theme-icon-sun,
#globalThemeToggle.theme-icon-toggle .theme-icon-sun {
    opacity: 0;
    transform: scale(.75) rotate(-30deg);
    pointer-events: none;
}
.theme-icon-toggle .theme-icon-moon,
#globalThemeToggle.theme-icon-toggle .theme-icon-moon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
    pointer-events: none;
}
html.dark .theme-icon-toggle .theme-icon-moon,
html.dark-mode .theme-icon-toggle .theme-icon-moon,
html.theme-dark .theme-icon-toggle .theme-icon-moon,
html[data-theme="dark"] .theme-icon-toggle .theme-icon-moon,
html[data-bs-theme="dark"] .theme-icon-toggle .theme-icon-moon,
body.dark .theme-icon-toggle .theme-icon-moon,
body.dark-mode .theme-icon-toggle .theme-icon-moon,
body.theme-dark .theme-icon-toggle .theme-icon-moon,
body[data-theme="dark"] .theme-icon-toggle .theme-icon-moon,
body[data-bs-theme="dark"] .theme-icon-toggle .theme-icon-moon {
    opacity: 0;
    transform: scale(.75) rotate(30deg);
}
html.dark .theme-icon-toggle .theme-icon-sun,
html.dark-mode .theme-icon-toggle .theme-icon-sun,
html.theme-dark .theme-icon-toggle .theme-icon-sun,
html[data-theme="dark"] .theme-icon-toggle .theme-icon-sun,
html[data-bs-theme="dark"] .theme-icon-toggle .theme-icon-sun,
body.dark .theme-icon-toggle .theme-icon-sun,
body.dark-mode .theme-icon-toggle .theme-icon-sun,
body.theme-dark .theme-icon-toggle .theme-icon-sun,
body[data-theme="dark"] .theme-icon-toggle .theme-icon-sun,
body[data-bs-theme="dark"] .theme-icon-toggle .theme-icon-sun {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}
@media (max-width: 820px) {
    .theme-icon-toggle .theme-icon,
    #globalThemeToggle.theme-icon-toggle .theme-icon { font-size: 17px !important; }
}
@media (max-width: 520px) {
    .theme-icon-toggle .theme-icon,
    #globalThemeToggle.theme-icon-toggle .theme-icon { font-size: 16px !important; }
}
