/* ============================================================
   Fee Manager SaaS — Shared Styles
   Design tokens, light/dark themes, layout, components, print
   ============================================================ */

:root {
    --primary: #4f46e5;
    --secondary: #0ea5e9;
    --bg: #f8fafc;
    --bg-elev: #ffffff;
    --bg-muted: #f1f5f9;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --sidebar-w: 240px;
    --topbar-h: 56px;
    --bnav-h: 60px;
}

[data-theme="dark"] {
    --bg: #0b1220;
    --bg-elev: #111a2e;
    --bg-muted: #1a2540;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #1e293b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow: 0 4px 16px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 12px; }

/* ---------- Loader ---------- */
#app-loader {
    position: fixed; inset: 0;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
    transition: opacity .3s ease;
}
#app-loader.hidden { opacity: 0; pointer-events: none; }
.spinner {
    width: 40px; height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Auth ---------- */
.auth-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(135deg, var(--bg), var(--bg-muted));
}
.auth-card {
    background: var(--bg-elev);
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border);
}
.auth-card .brand {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 20px;
}
.auth-card .brand h1 { font-size: 18px; margin: 0; }
.auth-card h2 { margin-bottom: 16px; font-size: 20px; }

/* ---------- Forms ---------- */
label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 14px;
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="file"], select, textarea {
    display: block; width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elev);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .05s, background .15s, border-color .15s;
    text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-elev);
    color: var(--text);
    cursor: pointer;
    font-size: 16px;
}
.btn-icon:hover { background: var(--bg-muted); }

/* ---------- Alerts ---------- */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 14px;
    border: 1px solid transparent;
}
.alert-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-info    { background: #e0f2fe; color: #075985; border-color: #bae6fd; }
[data-theme="dark"] .alert-success { background: #052e16; color: #86efac; border-color: #166534; }
[data-theme="dark"] .alert-error   { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }
[data-theme="dark"] .alert-info    { background: #082f49; color: #7dd3fc; border-color: #0c4a6e; }

/* ---------- Layout ---------- */
.app-body { padding-top: var(--topbar-h); }
.topbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 12px;
    padding: 0 16px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}
.topbar-brand {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700; color: var(--text); text-decoration: none;
    flex: 1;
}
.topbar-brand:hover { text-decoration: none; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.app-main {
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    left: 0;
    width: var(--sidebar-w);
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    padding: 16px 8px;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 90;
}
.sidebar.open { transform: translateX(0); }
.sidebar-header { padding: 8px 12px 16px; }
.sidebar-title {
    font-weight: 700; font-size: 13px; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    transition: background .15s;
}
.nav-item:hover { background: var(--bg-muted); text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { width: 20px; text-align: center; }

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--bnav-h);
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav-item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    gap: 2px;
    padding: 6px 0;
    font-size: 11px;
}
.bottom-nav-item.active { color: var(--primary); }
.bn-icon { font-size: 20px; }
.bn-label { font-size: 11px; }

/* ---------- Responsive ---------- */
@media (min-width: 900px) {
    .sidebar { transform: translateX(0); }
    .app-main { margin-left: var(--sidebar-w); padding: 32px; }
    .topbar { left: var(--sidebar-w); }
    .topbar #menu-toggle { display: none; }
    .bottom-nav { display: none; }
    .app-body { padding-bottom: 0; }
}
@media (max-width: 899px) {
    .app-body { padding-bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom, 0)); }
    .app-main { padding: 16px; }
}

/* ---------- Cards / utility ---------- */
.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.muted { color: var(--text-muted); font-size: 13px; }
.center { text-align: center; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
@media (max-width: 720px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ---------- Modal ---------- */
#modal-root {
    position: fixed; inset: 0; display: none;
    background: rgba(0,0,0,0.5);
    align-items: center; justify-content: center;
    padding: 16px; z-index: 1000;
}
#modal-root.open { display: flex; }
.modal {
    background: var(--bg-elev);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}
.modal h3 { margin-bottom: 16px; }

/* ---------- Print ---------- */
@media print {
    .topbar, .sidebar, .bottom-nav, #app-loader, .btn, .btn-icon, #menu-toggle, #theme-toggle { display: none !important; }
    .app-main { margin: 0 !important; padding: 0 !important; max-width: none !important; }
    body { background: #fff; color: #000; }
}


/* ============================================================
   Stage 2 additions — tables, badges, filters, pagination,
   stat cards, form layout
   ============================================================ */

.table-wrap { overflow-x: auto; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th { background: var(--bg-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-muted); }
.table td.actions { white-space: nowrap; text-align: right; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.4; }
.badge-active    { background: #dcfce7; color: #166534; }
.badge-suspended { background: #fee2e2; color: #991b1b; }
.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-expired   { background: #e2e8f0; color: #475569; }
.badge-info      { background: #e0f2fe; color: #075985; }
[data-theme="dark"] .badge-active    { background: #052e16; color: #86efac; }
[data-theme="dark"] .badge-suspended { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .badge-pending   { background: #451a03; color: #fcd34d; }
[data-theme="dark"] .badge-expired   { background: #1e293b; color: #cbd5e1; }
[data-theme="dark"] .badge-info      { background: #082f49; color: #7dd3fc; }

.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters > div, .filters > label { margin-bottom: 0; }
.filters input[type="text"], .filters select { min-width: 180px; margin-top: 0; }

.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-elev); font-size: 13px; color: var(--text); text-decoration: none; }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { opacity: 0.5; pointer-events: none; }

.form-section-title { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 24px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.form-section-title:first-child { margin-top: 0; }

.form-actions { display: flex; gap: 12px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }

.feature-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.feature-pill { font-size: 11px; padding: 2px 8px; background: var(--bg-muted); color: var(--text-muted); border-radius: 999px; border: 1px solid var(--border); }

.stat-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.actions-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.actions-bar h1 { margin: 0; font-size: 22px; }

.checkbox-row { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 8px; }
.checkbox-row label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: 13px; color: var(--text); margin-bottom: 0; cursor: pointer; }
.checkbox-row input[type="checkbox"] { width: auto; margin: 0; }

.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 900px) { .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 520px) { .grid-4 { grid-template-columns: 1fr; } }


/* ============================================================
   Stage 3 additions — loader variants, color inputs, image
   previews, info rows
   ============================================================ */

/* Loader style variants (spinner is already covered by .spinner; new classes) */
.loader-spinner {
    width: 40px; height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loader-pulse {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--primary);
    animation: pulse-anim 1.2s ease-in-out infinite;
}
@keyframes pulse-anim {
    0%, 100% { transform: scale(0.6); opacity: 0.6; }
    50%      { transform: scale(1);   opacity: 1; }
}
.loader-bars {
    display: flex; gap: 6px; align-items: center; height: 40px;
}
.loader-bars span {
    display: block; width: 8px; height: 100%;
    background: var(--primary); border-radius: 4px;
    animation: bars-anim 1s ease-in-out infinite;
}
.loader-bars span:nth-child(2) { animation-delay: 0.15s; }
.loader-bars span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bars-anim {
    0%, 100% { transform: scaleY(0.4); }
    50%      { transform: scaleY(1); }
}

/* Colour picker row */
.color-input-row { display: flex; gap: 8px; align-items: center; }
.color-input-row input[type="color"] {
    width: 48px; height: 40px; padding: 2px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-elev);
    cursor: pointer; flex: 0 0 auto;
}
.color-input-row input[type="text"] { flex: 1; margin-top: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Image previews */
.image-preview {
    display: flex; align-items: center; justify-content: center;
    max-width: 220px; max-height: 90px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    background: var(--bg-muted);
    margin-top: 8px;
}
.image-preview img { max-width: 100%; max-height: 74px; object-fit: contain; }

/* Info row list */
.info-list { margin-top: 8px; }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.info-row:last-child { border-bottom: none; }
.info-row .label { color: var(--text-muted); }


/* ============================================================
   Stage 4 additions — student avatars, empty states
   ============================================================ */

.student-avatar-cell { display: flex; align-items: center; gap: 10px; }
.avatar-thumb {
    width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
    background: var(--bg-muted); border: 1px solid var(--border); flex-shrink: 0;
}
.empty-state { padding: 40px 20px; text-align: center; color: var(--text-muted); }
.empty-state h3 { color: var(--text); margin-bottom: 6px; }
.empty-state p { margin: 0 0 16px; }





/* ============================================================
   Stage 5 additions — fee statuses, fee summary, receipt
   ============================================================ */

.badge-paid     { background: #dcfce7; color: #166534; }
.badge-partial  { background: #fef3c7; color: #92400e; }
.badge-unpaid   { background: #fee2e2; color: #991b1b; }
.badge-cancelled{ background: #e2e8f0; color: #475569; }
[data-theme="dark"] .badge-paid     { background: #052e16; color: #86efac; }
[data-theme="dark"] .badge-partial  { background: #451a03; color: #fcd34d; }
[data-theme="dark"] .badge-unpaid   { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .badge-cancelled{ background: #1e293b; color: #cbd5e1; }

.fee-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.fee-summary .item {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}
.fee-summary .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.fee-summary .value { font-size: 20px; font-weight: 700; margin-top: 4px; }
@media (max-width: 720px) { .fee-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Receipt layout */
.receipt-wrap { max-width: 720px; margin: 0 auto; }
.receipt-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
}
.receipt-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 16px; padding-bottom: 20px; border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}
.receipt-inst-logo { max-height: 60px; max-width: 120px; object-fit: contain; }
.receipt-inst-name { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.receipt-inst-meta { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.receipt-title {
    text-align: right; font-size: 22px; font-weight: 800; color: var(--primary);
    letter-spacing: 0.08em; text-transform: uppercase; margin: 0;
}
.receipt-number { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.receipt-meta-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 20px;
}
.receipt-meta-grid h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em; }
.receipt-meta-grid div { font-size: 14px; }
.receipt-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 14px; }
.receipt-table th { background: var(--bg-muted); text-align: left; padding: 10px 12px; font-size: 12px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.04em; }
.receipt-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.receipt-totals { margin-left: auto; width: 100%; max-width: 320px; font-size: 14px; }
.receipt-totals .row { display: flex; justify-content: space-between; padding: 6px 0; }
.receipt-totals .row.total { border-top: 2px solid var(--border); margin-top: 6px; padding-top: 10px; font-weight: 700; font-size: 16px; }
.receipt-note { margin-top: 24px; padding: 12px 16px; background: var(--bg-muted); border-radius: var(--radius-sm); font-size: 13px; color: var(--text-muted); }
.receipt-sign { margin-top: 48px; text-align: right; }
.receipt-sign hr { width: 180px; margin: 40px 0 6px auto; border: none; border-top: 1px solid var(--border); }
.receipt-sign div { font-size: 13px; color: var(--text-muted); }
.receipt-actions { display: flex; gap: 10px; justify-content: flex-end; margin: 20px 0; }

@media print {
    .receipt-card { box-shadow: none; border: none; padding: 0; }
    .receipt-actions { display: none !important; }
    .receipt-head { border-bottom: 2px solid #000; }
    .receipt-table th { background: #f0f0f0; }
    body { background: #fff; }
}

/* Invoice item rows */
.invoice-items-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.invoice-items-table th { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 6px; text-align: left; }
.invoice-items-table td { padding: 6px 6px; }
.invoice-items-table input { margin-top: 0; }
.invoice-items-table .col-desc { width: 45%; }
.invoice-items-table .col-qty  { width: 12%; }
.invoice-items-table .col-price{ width: 20%; }
.invoice-items-table .col-total{ width: 15%; text-align: right; font-weight: 600; }
.invoice-items-table .col-remove{ width: 8%; text-align: right; }
.invoice-total-row { display: flex; justify-content: flex-end; gap: 24px; margin-top: 8px; font-weight: 700; }


/* ============================================================
   Stage 6 additions — bar visuals, export bar, upsell, print
   ============================================================ */

.bar-track {
    height: 6px;
    background: var(--bg-muted);
    border-radius: 3px;
    overflow: hidden;
    min-width: 60px;
}
.bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width .25s ease;
}

.tbl-tight th,
.tbl-tight td { padding: 8px 10px; font-size: 13px; }
.tbl-tight td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-tight th.num { text-align: right; }

.export-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}
.export-bar .export-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    margin-right: 4px;
}

.upsell-card {
    background: var(--bg-muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
}
.upsell-card h3 { margin-bottom: 6px; }
.upsell-card p { color: var(--text-muted); margin: 0 0 16px; }

.report-block { margin-top: 24px; }
.report-block h3 { margin: 0 0 12px; font-size: 15px; }

.money-pos { color: var(--success); font-weight: 600; }
.money-due { color: var(--danger); font-weight: 600; }

@media print {
    .export-bar, .actions-bar .btn, .filters { display: none !important; }
    .card, .stat-card, .table-wrap { box-shadow: none !important; border-color: #ddd !important; }
    .app-main { padding: 0 !important; }
}


/* ============================================================
   Stage 8 — Fee calendar matrix
   ============================================================ */

.fee-calendar-wrap {
    overflow-x: auto;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.fee-calendar {
    font-size: 13px;
    border-collapse: collapse;
    min-width: 100%;
}
.fee-calendar th,
.fee-calendar td {
    padding: 8px 6px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    vertical-align: middle;
}
.fee-calendar th:last-child,
.fee-calendar td:last-child { border-right: none; }
.fee-calendar tbody tr:last-child td { border-bottom: none; }

.fee-calendar .sticky-col {
    position: sticky;
    left: 0;
    text-align: left;
    background: var(--bg-elev);
    z-index: 2;
    min-width: 160px;
    box-shadow: 2px 0 4px -2px rgba(0,0,0,0.08);
}
.fee-calendar thead .sticky-col {
    background: var(--bg-muted);
    z-index: 3;
}
.fee-calendar .month-col {
    min-width: 62px;
    font-size: 11px;
    line-height: 1.3;
    padding: 8px 4px;
}
.fee-calendar .month-col.future { opacity: 0.5; }

.fee-calendar .cell-paid,
.fee-calendar .cell-partial,
.fee-calendar .cell-unpaid {
    font-weight: 600;
    font-size: 13px;
}
.fee-calendar .cell-paid    { background: #dcfce7; color: #166534; }
.fee-calendar .cell-partial { background: #fef3c7; color: #92400e; }
.fee-calendar .cell-unpaid  { background: #fee2e2; color: #991b1b; }
.fee-calendar .cell-empty   { color: var(--text-muted); background: var(--bg-muted); }

[data-theme="dark"] .fee-calendar .cell-paid    { background: #052e16; color: #86efac; }
[data-theme="dark"] .fee-calendar .cell-partial { background: #451a03; color: #fcd34d; }
[data-theme="dark"] .fee-calendar .cell-unpaid  { background: #450a0a; color: #fca5a5; }

.fee-calendar a {
    color: inherit;
    text-decoration: none;
    display: block;
    padding: 2px 4px;
    border-radius: 4px;
}
.fee-calendar a:hover {
    text-decoration: underline;
    background: rgba(0,0,0,0.05);
}

/* View tabs on mobile: wrap */
.view-tabs .btn { font-size: 13px; }


/* ============================================================
   Stage 9 — Enhanced fee calendar cells
   ============================================================ */

.fee-calendar .cell-add { background: var(--bg-muted); }
.fee-calendar .cell-add a:hover { background: rgba(79, 70, 229, 0.08); border-radius: 4px; }

.fee-calendar .cell-future {
    background: var(--bg-muted);
    opacity: 0.5;
    cursor: not-allowed;
}

.fee-calendar td.cell-paid,
.fee-calendar td.cell-partial,
.fee-calendar td.cell-unpaid {
    padding: 4px 2px;
    text-align: center;
    vertical-align: middle;
}

.fee-calendar td.cell-paid a:hover,
.fee-calendar td.cell-partial a:hover,
.fee-calendar td.cell-unpaid a:hover {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 4px;
}

[data-theme="dark"] .fee-calendar td.cell-paid a:hover,
[data-theme="dark"] .fee-calendar td.cell-partial a:hover,
[data-theme="dark"] .fee-calendar td.cell-unpaid a:hover {
    background: rgba(255, 255, 255, 0.1);
}






