:root {
    --app-bg: #f4f7fb;
    --app-surface: #ffffff;
    --app-surface-soft: #f8fafc;
    --app-border: #e5eaf2;
    --app-border-strong: #d7deea;
    --app-text: #172033;
    --app-muted: #6f7b90;
    --app-primary: #3758f9;
    --app-primary-dark: #2745d8;
    --app-primary-soft: #edf1ff;
    --app-success: #159f6d;
    --app-warning: #d68a0a;
    --app-danger: #dc4c64;
    --app-info: #2486d8;
    --app-dark: #182033;
    --sidebar-width: 270px;
    --sidebar-compact-width: 86px;
    --topbar-height: 72px;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --shadow-sm: 0 6px 20px rgba(23, 32, 51, .06);
    --shadow-md: 0 18px 42px rgba(23, 32, 51, .10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background:
        radial-gradient(circle at 90% 0%, rgba(55, 88, 249, .07), transparent 26rem),
        var(--app-bg);
    color: var(--app-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--app-primary); }
a:hover { color: var(--app-primary-dark); }
.min-w-0 { min-width: 0; }

/* Shell */
.app-shell { min-height: 100vh; }
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    background: linear-gradient(180deg, #141c2e 0%, #172238 58%, #111827 100%);
    color: #fff;
    border-right: 1px solid rgba(255,255,255,.05);
    transition: width .24s ease, transform .24s ease;
}
.app-main {
    min-height: 100vh;
    transition: margin-left .24s ease;
}
.app-has-sidebar .app-main { margin-left: var(--sidebar-width); }
.app-no-sidebar .app-main { margin-left: 0; }
.sidebar-brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 6px 18px; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; min-width: 0; color: #fff; text-decoration: none; }
.sidebar-brand:hover { color: #fff; }
.sidebar-brand-mark {
    width: 42px; height: 42px; flex: 0 0 42px; border-radius: 13px;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.25rem;
    background: linear-gradient(135deg, #5572ff, #7c4dff);
    box-shadow: 0 8px 22px rgba(55,88,249,.32);
}
.sidebar-brand-copy { display: flex; flex-direction: column; line-height: 1.1; overflow: hidden; }
.sidebar-brand-copy strong { font-size: 1.02rem; letter-spacing: -.02em; white-space: nowrap; }
.sidebar-brand-copy small { margin-top: 4px; color: rgba(255,255,255,.52); font-size: .69rem; white-space: nowrap; }
.sidebar-collapse-button,
.topbar-icon-button {
    border: 0; display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 11px;
    background: rgba(255,255,255,.08); color: rgba(255,255,255,.8);
    transition: .18s ease;
}
.sidebar-collapse-button:hover { background: rgba(255,255,255,.14); color: #fff; }
.sidebar-school-card {
    display: flex; align-items: center; gap: 10px; margin: 0 2px 18px; padding: 12px;
    color: #fff; text-decoration: none; border: 1px solid rgba(255,255,255,.09);
    border-radius: 16px; background: rgba(255,255,255,.055); transition: .2s ease;
}
.sidebar-school-card:hover { color: #fff; background: rgba(255,255,255,.10); transform: translateY(-1px); }
.school-avatar {
    width: 38px; height: 38px; flex: 0 0 38px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 800; background: rgba(96, 165, 250, .18); color: #b9d7ff;
}
.sidebar-school-copy { min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.sidebar-school-copy small { color: rgba(255,255,255,.48); font-size: .65rem; text-transform: uppercase; letter-spacing: .06em; }
.sidebar-school-copy strong { margin-top: 4px; font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-school-arrow { margin-left: auto; color: rgba(255,255,255,.35); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 2px 0 12px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent; }
.sidebar-nav-label { padding: 0 12px 7px; color: rgba(255,255,255,.35); font-size: .66rem; font-weight: 800; text-transform: uppercase; letter-spacing: .10em; }
.sidebar-nav-link {
    position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px;
    margin: 3px 0; padding: 9px 12px; border-radius: 12px; color: rgba(255,255,255,.68);
    text-decoration: none; font-size: .88rem; font-weight: 600; transition: .18s ease;
}
.sidebar-nav-link i { width: 22px; flex: 0 0 22px; text-align: center; font-size: 1.08rem; }
.sidebar-nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.sidebar-nav-link.active { color: #fff; background: linear-gradient(90deg, rgba(83,112,255,.25), rgba(83,112,255,.10)); box-shadow: inset 3px 0 0 #7790ff; }
.sidebar-footer { padding: 12px 6px 0; border-top: 1px solid rgba(255,255,255,.07); }
.sidebar-version { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.42); font-size: .72rem; }
.sidebar-backdrop { display: none; }

.sidebar-compact .app-sidebar { width: var(--sidebar-compact-width); }
.sidebar-compact.app-has-sidebar .app-main { margin-left: var(--sidebar-compact-width); }
.sidebar-compact .sidebar-brand-copy,
.sidebar-compact .sidebar-school-copy,
.sidebar-compact .sidebar-school-arrow,
.sidebar-compact .sidebar-nav-link span,
.sidebar-compact .sidebar-nav-label,
.sidebar-compact .sidebar-version span { display: none; }
.sidebar-compact .sidebar-brand-row { justify-content: center; flex-wrap: wrap; }
.sidebar-compact .sidebar-brand { justify-content: center; }
.sidebar-compact .sidebar-collapse-button { margin-top: 3px; }
.sidebar-compact .sidebar-school-card { justify-content: center; padding: 10px; }
.sidebar-compact .sidebar-nav-link { justify-content: center; padding-inline: 10px; }
.sidebar-compact .sidebar-nav-link i { width: auto; font-size: 1.16rem; }
.sidebar-compact .sidebar-footer { display: flex; justify-content: center; }

/* Topbar */
.app-topbar {
    position: sticky; top: 0; z-index: 1020; height: var(--topbar-height);
    display: flex; align-items: center; background: rgba(255,255,255,.91);
    backdrop-filter: blur(18px); border-bottom: 1px solid rgba(215,222,234,.8);
}
.app-topbar-inner { width: 100%; max-width: 1680px; margin: 0 auto; padding: 0 28px; display: flex; align-items: center; gap: 22px; }
.topbar-context { min-width: 0; line-height: 1.1; }
.topbar-context span { display: block; color: var(--app-muted); font-size: .67rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.topbar-context strong { display: block; margin-top: 4px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; }
.app-topbar .topbar-icon-button { color: #5e6b82; background: #f2f5f9; }
.app-topbar .topbar-icon-button:hover { color: var(--app-primary); background: var(--app-primary-soft); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-menu-button { display: flex; align-items: center; gap: 9px; border: 0; background: transparent; padding: 4px 7px; border-radius: 13px; color: var(--app-text); }
.user-menu-button:hover { background: #f4f6fa; }
.user-avatar { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; background: var(--app-primary-soft); color: var(--app-primary); }
.user-menu-copy { flex-direction: column; line-height: 1.05; text-align: left; }
.user-menu-copy small { color: var(--app-muted); font-size: .62rem; }
.user-menu-copy strong { margin-top: 4px; font-size: .76rem; }
.topbar-standalone-brand { display: flex; align-items: center; gap: 10px; color: var(--app-text); text-decoration: none; }
.topbar-standalone-brand > span:last-child { display: flex; flex-direction: column; line-height: 1.05; }
.topbar-standalone-brand small { margin-top: 4px; color: var(--app-muted); font-size: .68rem; }
.app-dropdown-menu { min-width: 220px; padding: 8px; border: 1px solid var(--app-border); border-radius: 14px; box-shadow: var(--shadow-md); }
.app-dropdown-menu .dropdown-item { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 9px; font-size: .86rem; }

/* Global search */
.global-search-wrapper { position: relative; width: min(500px, 42vw); margin-inline: auto; }
.topbar-search-field { position: relative; }
.topbar-search-field > i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: #98a3b7; z-index: 2; }
.topbar-search-field .form-control { height: 42px; padding-left: 39px; padding-right: 58px; background: #f5f7fa; border-color: transparent; box-shadow: none; }
.topbar-search-field .form-control:focus { background: #fff; border-color: #bac6ff; box-shadow: 0 0 0 4px rgba(55,88,249,.08); }
.topbar-search-field kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); padding: 3px 6px; border: 1px solid #dde3ec; border-radius: 6px; background: #fff; color: #8590a3; font: 600 .66rem/1.1 inherit; box-shadow: none; }
.global-search-dropdown { position: absolute; inset: calc(100% + 10px) 0 auto 0; z-index: 1080; max-height: 440px; overflow-y: auto; background: #fff; border: 1px solid var(--app-border); border-radius: 16px; box-shadow: 0 22px 58px rgba(23,32,51,.18); padding: 6px; }
.global-search-item { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 10px; padding: 10px; border-radius: 11px; color: var(--app-text); text-decoration: none; }
.global-search-item:hover, .global-search-item.is-active { color: var(--app-text); background: #f4f6ff; }
.global-search-result-icon { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: var(--app-primary-soft); color: var(--app-primary); }
.global-search-item strong { display: block; font-size: .85rem; }
.global-search-item small { display: block; margin-top: 3px; color: var(--app-muted); font-size: .72rem; }
.global-search-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 24px 14px; text-align: center; color: var(--app-muted); }
.global-search-empty > i { font-size: 1.35rem; }

/* Content */
.app-content { padding: 28px; }
.app-content-inner { width: 100%; max-width: 1600px; margin: 0 auto; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.page-title { color: var(--app-text); font-weight: 800; letter-spacing: -.035em; font-size: clamp(1.55rem, 2vw, 2.15rem); }
.page-subtitle { color: var(--app-muted); }
.section-kicker { margin-bottom: 5px; color: var(--app-primary); font-size: .68rem; font-weight: 800; letter-spacing: .10em; text-transform: uppercase; }

/* Generic controls */
.btn { border-radius: 10px; font-weight: 650; padding: .54rem .9rem; transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn-primary { background: var(--app-primary); border-color: var(--app-primary); box-shadow: 0 8px 18px rgba(55,88,249,.16); }
.btn-primary:hover { background: var(--app-primary-dark); border-color: var(--app-primary-dark); }
.btn-success { background: var(--app-success); border-color: var(--app-success); }
.form-control, .form-select { min-height: 42px; border-color: var(--app-border-strong); border-radius: 10px; color: var(--app-text); }
.form-control:focus, .form-select:focus { border-color: #9dadff; box-shadow: 0 0 0 .22rem rgba(55,88,249,.10); }
.form-label { color: #445067; font-size: .8rem; font-weight: 700; }
.input-group-text { border-color: var(--app-border-strong); background: #f7f9fc; color: var(--app-muted); }

.app-card, .card.app-card { border: 1px solid var(--app-border); border-radius: var(--radius-md); background: rgba(255,255,255,.97); box-shadow: var(--shadow-sm); overflow: hidden; }
.app-card-header, .app-card .card-header { padding: 17px 19px; background: #fff; border-bottom: 1px solid var(--app-border); }
.app-card .card-body { padding: 19px; }
.soft-panel { padding: 14px 16px; border-radius: 13px; background: var(--app-surface-soft); border: 1px solid var(--app-border); }

.table { --bs-table-bg: transparent; color: var(--app-text); }
.table > :not(caption) > * > * { padding-top: .85rem; padding-bottom: .85rem; border-bottom-color: #edf0f5; }
.table thead th { padding-top: .72rem; padding-bottom: .72rem; color: #7b879b; font-size: .68rem; font-weight: 800; letter-spacing: .055em; text-transform: uppercase; white-space: nowrap; background: #fbfcfe; border-bottom-width: 1px; }
.table-hover > tbody > tr { transition: background-color .13s ease; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f9faff; }
.pagination .page-link { margin: 0 2px; border-radius: 9px; border-color: var(--app-border); color: #58657a; }
.pagination .active > .page-link { background: var(--app-primary); border-color: var(--app-primary); color: #fff; }

.badge { border-radius: 999px; padding: .43em .66em; font-weight: 700; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; font-size: .72rem; font-weight: 750; border: 1px solid transparent; white-space: nowrap; }
.status-pill-success { color: #0d7b54; background: #eaf8f2; border-color: #c9efdf; }
.status-pill-warning { color: #9a6400; background: #fff6df; border-color: #f7df9a; }
.status-pill-danger { color: #b42c46; background: #fff0f3; border-color: #ffd1da; }
.status-pill-neutral { color: #5d687c; background: #f2f4f8; border-color: #e2e6ed; }
.code-pill { display: inline-block; padding: 4px 7px; border-radius: 7px; background: #f1f3f7; color: #596579; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .75rem; }

.app-alert { display: flex; align-items: flex-start; gap: 10px; border: 0; border-radius: 13px; box-shadow: var(--shadow-sm); }
.app-alert > i { margin-top: 2px; }

/* Metrics */
.metric-grid { --bs-gutter-x: .85rem; }
.metric-card { height: 100%; min-height: 104px; display: flex; align-items: center; gap: 14px; padding: 17px; border: 1px solid var(--app-border); border-radius: var(--radius-md); background: #fff; box-shadow: var(--shadow-sm); }
.metric-icon { width: 44px; height: 44px; flex: 0 0 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 13px; background: #f1f4f9; color: #627089; font-size: 1.1rem; }
.metric-card > div:last-child { min-width: 0; }
.metric-label { display: block; color: var(--app-muted); font-size: .72rem; font-weight: 650; }
.metric-value { display: block; margin-top: 4px; font-size: 1.35rem; line-height: 1.1; letter-spacing: -.025em; }
.metric-card-primary .metric-icon { background: var(--app-primary-soft); color: var(--app-primary); }
.metric-card-success .metric-icon { background: #eaf8f2; color: var(--app-success); }
.metric-card-danger .metric-icon { background: #fff0f3; color: var(--app-danger); }
.metric-card-dark { color: #fff; background: linear-gradient(135deg, #1c273d, #263650); border-color: transparent; }
.metric-card-dark .metric-label { color: rgba(255,255,255,.65); }
.metric-card-dark .metric-icon { color: #fff; background: rgba(255,255,255,.10); }

/* Dashboard */
.dashboard-hero { position: relative; overflow: hidden; padding: 28px; border-radius: 24px; color: #fff; background: linear-gradient(130deg, #1d2a44 0%, #2d3d66 56%, #3758f9 145%); box-shadow: 0 22px 48px rgba(28,39,61,.18); }
.dashboard-hero::after { content: ""; position: absolute; width: 260px; height: 260px; right: -80px; top: -130px; border-radius: 50%; background: rgba(255,255,255,.08); }
.dashboard-hero p { color: rgba(255,255,255,.68); }
.dashboard-hero .section-kicker { color: #aebcff; }
.dashboard-hero-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.dashboard-hero .btn-light { color: #253149; }
.module-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.module-card { position: relative; display: flex; gap: 12px; align-items: center; min-height: 84px; padding: 15px; border: 1px solid var(--app-border); border-radius: 15px; background: #fff; color: var(--app-text); text-decoration: none; transition: .18s ease; box-shadow: 0 5px 16px rgba(23,32,51,.04); }
.module-card:hover { color: var(--app-text); transform: translateY(-3px); border-color: #c9d1ff; box-shadow: 0 14px 28px rgba(23,32,51,.09); }
.module-card-icon { width: 42px; height: 42px; flex: 0 0 42px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--app-primary-soft); color: var(--app-primary); font-size: 1.05rem; }
.module-card strong { display: block; font-size: .84rem; }
.module-card small { display: block; margin-top: 3px; color: var(--app-muted); font-size: .69rem; line-height: 1.25; }
.module-card > i:last-child { margin-left: auto; color: #bdc5d2; }

.chart-row { display: grid; grid-template-columns: 82px minmax(100px, 1fr) 120px; gap: 12px; align-items: center; margin-bottom: 11px; }
.chart-track { position: relative; height: 10px; overflow: hidden; border-radius: 999px; background: #edf0f5; }
.chart-bar { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: #a8b5ff; }
.chart-bar-paid { background: var(--app-success); }

/* Debt */
.debt-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.debt-green { background: var(--app-success)!important; color: #fff!important; }
.debt-yellow { background: #f1b53b!important; color: #4c3500!important; }
.debt-orange { background: #ef8335!important; color: #fff!important; }
.debt-red { background: var(--app-danger)!important; color: #fff!important; }
.debt-badge { font-weight: 700; }
.opening-debt-card { border-color: #f1d68a!important; }
.opening-debt-card .app-card-header { background: linear-gradient(90deg, #fffaf0, #fff); }

/* Collections */
.collections-bulk-toolbar { position: sticky; top: calc(var(--topbar-height) + 10px); z-index: 1010; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 15px; background: rgba(255,255,255,.96); backdrop-filter: blur(14px); border: 1px solid #cfd8ff; border-radius: 14px; box-shadow: 0 12px 30px rgba(23,32,51,.13); }
.collections-checkbox-column { width: 46px; }
.collections-table td { vertical-align: middle; }

/* Invoice preview */
.billing-preview-layout { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(430px, .92fr); gap: 22px; align-items: start; }
.billing-invoice-preview-wrap { position: sticky; top: calc(var(--topbar-height) + 18px); }
.invoice-preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; padding-inline: 2px; }
.live-preview-badge { display: inline-flex; align-items: center; gap: 7px; color: #677387; font-size: .72rem; font-weight: 700; }
.live-preview-badge span { width: 8px; height: 8px; border-radius: 50%; background: var(--app-success); box-shadow: 0 0 0 5px rgba(21,159,109,.10); }
.invoice-paper { position: relative; overflow: hidden; min-height: 680px; padding: 27px; border: 1px solid #dce2eb; border-radius: 8px; background: #fff; box-shadow: 0 22px 52px rgba(23,32,51,.14); transition: transform .18s ease, box-shadow .18s ease; }
.invoice-paper-pulse { animation: invoicePulse .28s ease; }
@keyframes invoicePulse { 0% { transform: scale(.995); } 100% { transform: scale(1); } }
.invoice-paper-accent { position: absolute; inset: 0 0 auto 0; height: 8px; background: var(--invoice-accent, #111827); }
.invoice-paper-header { display: flex; justify-content: space-between; gap: 20px; padding: 12px 0 21px; border-bottom: 1px solid #e8ebf0; }
.invoice-brand-block { display: flex; align-items: center; gap: 13px; min-width: 0; }
.invoice-preview-logo { width: 68px; height: 52px; object-fit: contain; object-position: left center; }
.invoice-preview-logo-placeholder { width: 52px; height: 52px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; background: #f2f4f8; color: #818ca0; font-size: 1.3rem; }
.invoice-business-name { max-width: 210px; font-size: .94rem; font-weight: 800; line-height: 1.15; }
.invoice-muted { margin-top: 4px; color: #7d8799; font-size: .68rem; }
.invoice-type-block { display: grid; grid-template-columns: 34px auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center; text-align: right; }
.invoice-type-letter { grid-row: 1 / 3; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--invoice-accent, #111827); color: var(--invoice-accent, #111827); font-weight: 900; }
.invoice-type-block strong { font-size: .8rem; }
.invoice-type-block span { color: #8993a4; font-size: .62rem; }
.invoice-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0 12px; }
.invoice-info-box { display: flex; flex-direction: column; min-height: 94px; padding: 12px; border: 1px solid #e4e8ef; border-radius: 9px; color: #6c7789; font-size: .68rem; line-height: 1.5; }
.invoice-info-box strong { margin: 2px 0 3px; color: #242e40; font-size: .75rem; }
.invoice-info-label { color: var(--invoice-accent, #111827); font-size: .61rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.invoice-period-line { display: flex; align-items: center; justify-content: space-between; margin: 0 0 15px; padding: 8px 10px; border-radius: 8px; background: #f6f7fa; color: #667186; font-size: .68rem; }
.invoice-period-line strong { color: #2d3748; }
.invoice-items-preview { overflow: hidden; border: 1px solid #e3e7ed; border-radius: 8px; }
.invoice-items-head, .invoice-item-row { display: grid; grid-template-columns: 1fr 110px; gap: 12px; padding: 8px 10px; }
.invoice-items-head { color: #fff; background: var(--invoice-accent, #111827); font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.invoice-items-head span:last-child, .invoice-item-row strong { text-align: right; }
.invoice-item-row { color: #4e596c; border-top: 1px solid #edf0f4; font-size: .68rem; }
.invoice-item-row:first-child { border-top: 0; }
.invoice-item-row:nth-child(even) { background: #fafbfc; }
.invoice-totals-preview { width: min(280px, 72%); margin: 14px 0 16px auto; }
.invoice-totals-preview > div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 2px; color: #7a8597; font-size: .68rem; }
.invoice-totals-preview strong { color: #364055; }
.invoice-total-main { margin-top: 4px; padding: 9px 11px!important; border-radius: 8px; color: #fff!important; background: var(--invoice-accent, #111827); }
.invoice-total-main span, .invoice-total-main strong { color: #fff!important; font-size: .78rem; }
.invoice-due-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.invoice-due-card { display: flex; flex-direction: column; padding: 11px; border: 1px solid #e2e6ed; border-radius: 9px; }
.invoice-due-card span { color: #7b8698; font-size: .61rem; text-transform: uppercase; font-weight: 800; }
.invoice-due-card strong { margin: 4px 0 2px; color: #303a4d; font-size: .82rem; }
.invoice-due-card small { color: #929bac; font-size: .62rem; }
.invoice-due-card-emphasis { border-color: color-mix(in srgb, var(--invoice-accent, #111827) 30%, #e2e6ed); background: color-mix(in srgb, var(--invoice-accent, #111827) 5%, #fff); }
.invoice-preview-footer { display: grid; grid-template-columns: 42px 1fr; gap: 12px; align-items: center; margin-top: 18px; padding-top: 14px; border-top: 1px dashed #dfe3e9; color: #8992a3; font-size: .62rem; }
.invoice-preview-footer > div { font-size: 1.55rem; color: #4d586b; }
.invoice-selector-table-wrap { max-height: 540px; overflow-y: auto; }
.invoice-preview-row { cursor: pointer; outline: none; }
.invoice-preview-row.is-selected > * { --bs-table-bg-state: #f0f3ff!important; }
.invoice-preview-row.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--app-primary); }
.invoice-filter-wrap { position: relative; width: min(220px, 100%); }
.invoice-filter-wrap i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #98a2b4; }
.invoice-filter-wrap input { padding-left: 31px; }
.action-dock { position: sticky; bottom: 14px; z-index: 1005; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 16px; border: 1px solid var(--app-border); border-radius: 16px; background: rgba(255,255,255,.95); backdrop-filter: blur(16px); box-shadow: 0 16px 38px rgba(23,32,51,.16); }

/* Settings logo preview */
.logo-settings-preview { display: flex; align-items: center; gap: 16px; min-height: 92px; padding: 14px; border: 1px dashed #cbd3df; border-radius: 14px; background: #fbfcfe; }
.logo-settings-preview img { width: 120px; height: 66px; object-fit: contain; object-position: left center; border-radius: 8px; background: #fff; }
.logo-preview-placeholder { width: 90px; height: 60px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: #f0f3f7; color: #8b95a7; font-size: 1.35rem; }

/* Launcher legacy compatibility */
.app-launcher-card { background: #fff; border: 1px solid var(--app-border); border-radius: 16px; padding: 17px 12px; text-align: center; height: 100%; transition: .18s ease; box-shadow: 0 5px 18px rgba(23,32,51,.05); }
.app-launcher-card:hover { transform: translateY(-3px); box-shadow: 0 14px 28px rgba(23,32,51,.10); border-color: #cbd3ff; }
.app-launcher-icon { width: 50px; height: 50px; border-radius: 14px; margin: 0 auto 9px; display: flex; align-items: center; justify-content: center; font-size: 24px; background: var(--app-primary-soft); }
.app-launcher-title { color: var(--app-text); font-weight: 750; font-size: .9rem; }
.app-launcher-text { margin-top: 3px; color: var(--app-muted); font-size: .72rem; }

/* Empty state */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding-inline: 20px; color: var(--app-muted); }
.empty-state-icon { width: 56px; height: 56px; margin-bottom: 12px; display: inline-flex; align-items: center; justify-content: center; border-radius: 16px; background: #f1f4f8; color: #8290a6; font-size: 1.35rem; }
.empty-state h5 { color: var(--app-text); }

/* Animations */
.reveal-on-scroll { opacity: 0; transform: translateY(8px); transition: opacity .35s ease, transform .35s ease; }
.reveal-on-scroll.is-visible { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto!important; transition-duration: .01ms!important; animation-duration: .01ms!important; animation-iteration-count: 1!important; }
    .reveal-on-scroll { opacity: 1; transform: none; }
}

@media (max-width: 1399.98px) {
    .module-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
    .billing-preview-layout { grid-template-columns: minmax(0, 1fr) 430px; }
}
@media (max-width: 1199.98px) {
    .app-sidebar { transform: translateX(-100%); width: min(300px, 88vw); box-shadow: 22px 0 50px rgba(15,23,42,.28); }
    .app-has-sidebar .app-main, .sidebar-compact.app-has-sidebar .app-main { margin-left: 0; }
    .sidebar-mobile-open .app-sidebar { transform: translateX(0); }
    .sidebar-mobile-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 1030; background: rgba(15,23,42,.45); backdrop-filter: blur(2px); }
    .sidebar-compact .sidebar-brand-copy, .sidebar-compact .sidebar-school-copy, .sidebar-compact .sidebar-school-arrow, .sidebar-compact .sidebar-nav-link span, .sidebar-compact .sidebar-nav-label, .sidebar-compact .sidebar-version span { display: initial; }
    .sidebar-compact .sidebar-nav-label { display: block; }
    .sidebar-compact .sidebar-brand-row { justify-content: space-between; flex-wrap: nowrap; }
    .sidebar-compact .sidebar-school-card, .sidebar-compact .sidebar-nav-link { justify-content: flex-start; }
    .app-content { padding: 24px; }
    .billing-preview-layout { grid-template-columns: 1fr; }
    .billing-invoice-preview-wrap { position: static; max-width: 700px; width: 100%; margin: 0 auto; }
    .module-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 991.98px) {
    .app-topbar-inner { padding-inline: 18px; gap: 12px; }
    .global-search-wrapper { width: min(420px, 55vw); }
    .module-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .page-heading { flex-direction: column; }
}
@media (max-width: 767.98px) {
    :root { --topbar-height: 64px; }
    .app-content { padding: 18px 14px 28px; }
    .app-topbar-inner { padding-inline: 12px; }
    .global-search-wrapper { width: auto; flex: 1; }
    .topbar-search-field kbd { display: none; }
    .topbar-search-field .form-control { padding-right: 12px; font-size: .82rem; }
    .module-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
    .module-card { min-height: 78px; padding: 12px; }
    .module-card small { display: none; }
    .dashboard-hero { padding: 22px; border-radius: 19px; }
    .invoice-paper { padding: 18px 14px; min-height: 0; }
    .invoice-paper-header { flex-direction: column; }
    .invoice-type-block { align-self: flex-end; }
    .invoice-info-grid { grid-template-columns: 1fr; }
    .invoice-due-grid { grid-template-columns: 1fr; }
    .action-dock { position: static; flex-direction: column; align-items: stretch; }
    .action-dock > div:last-child { justify-content: stretch; }
    .action-dock .btn { flex: 1; }
    .collections-bulk-toolbar { top: 72px; flex-direction: column; align-items: stretch; }
    .chart-row { grid-template-columns: 60px 1fr 88px; gap: 8px; font-size: .76rem; }
}
@media (max-width: 479.98px) {
    .module-grid { grid-template-columns: 1fr; }
    .metric-card { min-height: 94px; }
    .invoice-brand-block { align-items: flex-start; }
    .invoice-preview-logo { width: 58px; }
}

/* Dashboard dinámico */
.dashboard-hero-summary { position: relative; padding: 20px; border: 1px solid rgba(255,255,255,.16); border-radius: 18px; background: rgba(255,255,255,.09); backdrop-filter: blur(10px); }
.dashboard-hero-summary > div:first-child { display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.dashboard-hero-summary span { color: rgba(255,255,255,.72); font-size: .75rem; font-weight: 700; }
.dashboard-hero-summary strong { font-size: 2rem; line-height: 1; letter-spacing: -.04em; }
.dashboard-hero-summary small { display: block; margin-top: 9px; color: rgba(255,255,255,.68); }
.hero-progress { overflow: hidden; height: 8px; margin-top: 15px; border-radius: 999px; background: rgba(255,255,255,.13); }
.hero-progress span { display: block; height: 100%; border-radius: inherit; background: #fff; transition: width .5s ease; }
.opening-debt-total { display: flex; flex-direction: column; padding: 15px; border: 1px solid #f5ddb0; border-radius: 14px; background: #fffaf0; }
.opening-debt-total > span { color: #99711f; font-size: .72rem; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; }
.opening-debt-total > strong { margin: 4px 0; font-size: 1.7rem; letter-spacing: -.03em; }
.opening-debt-total > small { color: var(--app-muted); line-height: 1.35; }
.debt-mini-list { display: grid; gap: 6px; }
.debt-mini-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 11px; border-radius: 10px; color: var(--app-text); text-decoration: none; transition: .16s ease; }
.debt-mini-row:hover { color: var(--app-text); background: #fff8e8; }
.debt-mini-row span { min-width: 0; }
.debt-mini-row span strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; }
.debt-mini-row span small { display: block; margin-top: 2px; color: var(--app-muted); font-size: .67rem; }
.debt-mini-row > strong { flex: 0 0 auto; color: #9a6400; font-size: .76rem; }
.upcoming-due-list { display: grid; gap: 8px; }
.upcoming-due-row { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--app-border); border-radius: 12px; }
.due-date-bubble { width: 42px; height: 42px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 11px; color: var(--app-primary); background: var(--app-primary-soft); line-height: 1; }
.due-date-bubble strong { font-size: .95rem; }
.due-date-bubble small { margin-top: 2px; font-size: .57rem; font-weight: 800; }
.upcoming-due-row > span:nth-child(2) strong, .upcoming-due-row > span:nth-child(2) small { display: block; }
.upcoming-due-row > span:nth-child(2) strong { font-size: .78rem; }
.upcoming-due-row > span:nth-child(2) small { margin-top: 2px; color: var(--app-muted); font-size: .67rem; }
.app-progress { height: 8px; border-radius: 999px; background: #edf0f5; }
.app-progress .progress-bar { border-radius: inherit; background: var(--app-success); transition: width .55s ease; }

/* Personalización visual de factura */
.invoice-brand-settings { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, .8fr); gap: 20px; align-items: stretch; }
.logo-settings-preview { min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 18px; border: 1px dashed var(--app-border-strong); border-radius: 16px; background: var(--app-surface-soft); text-align: center; }
.logo-settings-preview img { max-width: 210px; max-height: 105px; object-fit: contain; }
.logo-settings-preview-placeholder { width: 64px; height: 64px; display: inline-flex; align-items: center; justify-content: center; border-radius: 17px; color: #8a95a8; background: #eef1f5; font-size: 1.5rem; }
.invoice-color-row { display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: center; }
.invoice-color-picker { width: 56px; height: 42px; padding: 4px; border: 1px solid var(--app-border); border-radius: 10px; background: #fff; cursor: pointer; }
.invoice-mini-sample { position: relative; overflow: hidden; min-height: 240px; padding: 18px; border: 1px solid var(--app-border); border-radius: 14px; background: #fff; box-shadow: var(--shadow-sm); }
.invoice-mini-sample::before { content: ""; position: absolute; inset: 0 0 auto; height: 7px; background: var(--invoice-accent, #111827); }
.invoice-mini-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding: 8px 0 15px; border-bottom: 1px solid #e9edf2; }
.invoice-mini-brand { display: flex; align-items: center; gap: 9px; }
.invoice-mini-brand img { width: 48px; height: 38px; object-fit: contain; }
.invoice-mini-logo-placeholder { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; background: #f1f3f7; color: #8994a6; }
.invoice-mini-type { color: var(--invoice-accent, #111827); font-weight: 900; font-size: .73rem; }
.invoice-mini-lines { display: grid; gap: 8px; margin-top: 15px; }
.invoice-mini-line { height: 8px; border-radius: 999px; background: #edf0f4; }
.invoice-mini-line.short { width: 56%; }
.invoice-mini-total { display: flex; justify-content: space-between; margin-top: 22px; padding: 10px 12px; border-radius: 9px; color: #fff; background: var(--invoice-accent, #111827); font-size: .76rem; font-weight: 800; }

@media (max-width: 1199.98px) {
    .module-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .invoice-brand-settings { grid-template-columns: 1fr; }
}
@media (max-width: 767.98px) {
    .dashboard-hero { padding: 22px 18px; }
    .dashboard-hero-actions .btn { flex: 1 1 auto; }
    .module-grid { grid-template-columns: 1fr 1fr; }
    .chart-row { grid-template-columns: 64px 1fr; }
    .chart-row > div:last-child { grid-column: 2; text-align: left!important; }
    .upcoming-due-row { grid-template-columns: 42px 1fr; }
    .upcoming-due-row > .status-pill { grid-column: 2; justify-self: start; }
}
@media (max-width: 479.98px) {
    .module-grid { grid-template-columns: 1fr; }
}

/* Alumnos */
.input-icon-wrap { position: relative; }
.input-icon-wrap > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); z-index: 2; color: #98a2b4; }
.input-icon-wrap .form-control { padding-left: 36px; }
.student-name-cell { display: inline-flex; align-items: center; gap: 10px; min-width: 190px; color: var(--app-text); text-decoration: none; }
.student-name-cell:hover { color: var(--app-primary); }
.student-name-cell > span:last-child { min-width: 0; }
.student-name-cell strong, .student-name-cell small { display: block; }
.student-name-cell small { margin-top: 2px; color: var(--app-muted); font-size: .67rem; }
.student-avatar { width: 36px; height: 36px; flex: 0 0 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; color: var(--app-primary); background: var(--app-primary-soft); font-size: .78rem; font-weight: 900; }
.student-row-inactive { opacity: .63; background: #fafbfc; }
.student-table td { padding-top: .78rem; padding-bottom: .78rem; }
