/* Dashboard-specific styles */

.dashboard-container {
    background: var(--bg, #f4f6f9);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Dashboard grid system */
.dashboard-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.dashboard-grid.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.dashboard-grid.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.dashboard-grid.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Dashboard cards */
.dashboard-card {
    background: #ffffff;
    border: 1px solid #eaecf0;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s ease;
}

.dashboard-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

/* Dashboard stats */
.dashboard-stat {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.dashboard-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.dashboard-stat-icon.primary { background: #ede9fe; color: #7c3aed; }
.dashboard-stat-icon.secondary { background: #dcfce7; color: #16a34a; }
.dashboard-stat-icon.accent { background: #fef3c7; color: #d97706; }
.dashboard-stat-icon.danger { background: #fee2e2; color: #dc2626; }
.dashboard-stat-icon.navy { background: #e8edf8; color: #1a2744; }

.dashboard-stat-content h4 {
    font-size: 0.72rem;
    color: var(--text-dark);
    margin: 0 0 0.15rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dashboard-stat-content .stat-number {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1;
    margin: 0;
}

.dashboard-stat-content .stat-label {
    font-size: 0.7rem;
    color: var(--text-dark);
    font-weight: 600;
    margin: 0.2rem 0 0;
}

/* ── Gradient stat cards — force ALL text white ──────────────── */
.dashboard-card-gradient .dashboard-stat-content h4,
.dashboard-card-gradient .dashboard-stat-content .stat-number,
.dashboard-card-gradient .dashboard-stat-content .stat-label,
.dashboard-card-gradient .dashboard-stat-content p,
.dashboard-card-gradient .dashboard-stat-content span {
    color: #fff !important;
}
/* Also catch cards using inline linear-gradient style */
.dashboard-card[style*="linear-gradient"] .dashboard-stat-content h4,
.dashboard-card[style*="linear-gradient"] .dashboard-stat-content .stat-number,
.dashboard-card[style*="linear-gradient"] .dashboard-stat-content .stat-label,
.dashboard-card[style*="linear-gradient"] .dashboard-stat-content p,
.dashboard-card[style*="linear-gradient"] .dashboard-stat-content span {
    color: #fff !important;
}

/* Welcome card — compact horizontal bar */
.dashboard-welcome {
    background: linear-gradient(120deg, #1a2744 0%, #2d3f6e 100%);
    color: white;
    margin-bottom: 1rem;
    border: none;
    padding: 0.875rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dashboard-welcome h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 0.1rem;
    line-height: 1.2;
}

.dashboard-welcome p {
    opacity: 0.75;
    margin: 0;
    font-size: 0.8rem;
}

.dashboard-welcome .term-badge {
    background: rgba(255,255,255,0.15);
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    margin-top: 0.35rem;
    display: inline-block;
    border: 1px solid rgba(255,255,255,0.2);
}

.dashboard-welcome .date-badge {
    background: rgba(255,255,255,0.12);
    padding: 0.35rem 0.85rem;
    border-radius: 8px;
    font-size: 0.8rem;
    border: 1px solid rgba(255,255,255,0.15);
    white-space: nowrap;
}

/* Alert cards */
.dashboard-alert {
    margin-bottom: 0.75rem;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.dashboard-alert.warning { background: #fffbeb; border: 1px solid #fde68a; }
.dashboard-alert.danger  { background: #fef2f2; border: 1px solid #fecaca; }

.dashboard-alert-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.dashboard-alert.warning .dashboard-alert-icon { background: #f59e0b; color: white; }
.dashboard-alert.danger  .dashboard-alert-icon { background: #ef4444; color: white; }

.dashboard-alert-content strong { font-size: 0.875rem; display: block; margin-bottom: 0.25rem; }
.dashboard-alert.warning strong { color: #92400e; }
.dashboard-alert.danger  strong { color: #991b1b; }
.dashboard-alert-content p { margin: 0; font-size: 0.8rem; }
.dashboard-alert.warning p { color: #b45309; }
.dashboard-alert.danger  p { color: #b91c1c; }

/* Progress bars */
.dashboard-progress {
    background: #e5e7eb;
    border-radius: 9999px;
    height: 8px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.dashboard-progress-bar {
    background: linear-gradient(90deg, #16a34a, #22c55e);
    height: 100%;
    transition: width 0.5s ease;
}

/* Status cards for invoice breakdown */
.dashboard-status-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.dashboard-status-card {
    padding: 0.75rem;
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.dashboard-status-card:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,0.1); }
.dashboard-status-card.unpaid  { background: #fef2f2; color: #dc2626; }
.dashboard-status-card.partial { background: #fffbeb; color: #d97706; }
.dashboard-status-card.paid    { background: #f0fdf4; color: #16a34a; }
.dashboard-status-card.overdue { background: #fef2f2; border: 1px solid #fca5a5; color: #dc2626; }

.dashboard-status-number { font-size: 1.4rem; font-weight: 700; display: block; margin-bottom: 0.15rem; }
.dashboard-status-label  { font-size: 0.7rem; opacity: 0.8; }

/* Quick action buttons */
.dashboard-quick-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: 7px;
    text-decoration: none;
    transition: all 0.15s ease;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: var(--text-dark);
    cursor: pointer;
}
.dashboard-quick-btn:hover { background: #f3f4f6; border-color: #d1d5db; color: var(--text-dark); }
.dashboard-quick-btn.primary { background: #fff1f2; border-color: #fecaca; color: #c0152a; }
.dashboard-quick-btn.primary:hover { background: #fee2e2; border-color: #fca5a5; }

/* Recent items list */
.dashboard-recent-list { list-style: none; padding: 0; margin: 0; }

.dashboard-recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f3f4f6;
}
.dashboard-recent-item:last-child { border-bottom: none; }

.dashboard-recent-name    { font-weight: 700; color: var(--text-dark); margin: 0 0 0.15rem; font-size: 0.825rem; }
.dashboard-recent-details { font-size: 0.7rem; color: var(--text-dark); font-weight: 600; margin: 0; }
.dashboard-recent-amount  { font-weight: 700; color: #16a34a; font-size: 0.825rem; white-space: nowrap; }

/* Dark mode */
[data-theme="dark"] .dashboard-card { background: var(--card-bg); border-color: rgba(255,255,255,0.07); }
[data-theme="dark"] .dashboard-welcome { background: linear-gradient(120deg, #0f1a33 0%, #1a2744 100%); }
[data-theme="dark"] .dashboard-stat-content .stat-number { color: #f1f5f9; }
[data-theme="dark"] .dashboard-stat-content h4 { color: #94a3b8; }
[data-theme="dark"] .dashboard-recent-name { color: #f1f5f9; }
[data-theme="dark"] .dashboard-quick-btn { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.12); color: #cbd5e1; }
[data-theme="dark"] .dashboard-quick-btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); color: #f1f5f9; }
[data-theme="dark"] .dashboard-stat-icon.navy { background: rgba(45,63,110,0.4); }

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-grid.grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .dashboard-grid.grid-4,
    .dashboard-grid.grid-3,
    .dashboard-grid.grid-2 { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }

    /* Compact stat cards — 2 per row */
    .dashboard-card {
        padding: 0.6rem 0.75rem;
        min-width: 0;          /* allow grid cells to shrink below content size */
        overflow: hidden;
    }

    .dashboard-stat {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3rem;
    }

    .dashboard-stat-icon {
        width: 30px;
        height: 30px;
        border-radius: 7px;
        font-size: 0.8rem;
    }

    .dashboard-stat-content {
        width: 100%;
        min-width: 0;
    }

    .dashboard-stat-content h4 {
        font-size: 0.6rem;
        margin-bottom: 0.1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .dashboard-stat-content .stat-number {
        font-size: clamp(0.7rem, 3.5vw, 1.05rem);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        display: block;
        line-height: 1.2;
    }

    .dashboard-stat-content .stat-label {
        font-size: 0.6rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        display: block;
    }

    .dashboard-welcome { padding: 0.75rem 1rem; }
    .dashboard-welcome h2 { font-size: 1rem; }
    .dashboard-status-grid { grid-template-columns: repeat(2, 1fr); }

    /* Reports stats grid — 2 columns on mobile */
    .reports-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }

    .reports-stat-card {
        padding: 0.55rem 0.5rem !important;
    }

    .reports-stat-label {
        font-size: 0.6rem !important;
        margin-bottom: 0.15rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* clamp(min, preferred, max) — scales with viewport width.
       On a 320px phone each card is ~148px wide; 3.5vw ≈ 11px there.
       On a 400px phone each card is ~188px wide; 3.5vw ≈ 14px there. */
    .reports-stat-number {
        font-size: clamp(0.65rem, 3.2vw, 0.95rem) !important;
        line-height: 1.2 !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
        letter-spacing: -0.01em;
    }

    .reports-stat-sub {
        font-size: 0.58rem !important;
        display: block;
    }

    /* Payment Methods page — 2-column grids + compact amounts on mobile */
    .pm-summary-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.6rem !important;
    }

    .pm-summary-card {
        padding: 0.65rem 0.6rem !important;
    }

    .pm-summary-card .pm-amount {
        font-size: 0.95rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .pm-summary-card > div:first-child {
        font-size: 0.62rem !important;
    }

    .pm-summary-card > div:last-child {
        font-size: 0.62rem !important;
    }

    /* Annual/Term/All-Time stat cards — stack to 1 col, hide avg column */
    .pm-stats-grid {
        grid-template-columns: 1fr !important;
        gap: 0.6rem !important;
    }

    .pm-stat-card {
        padding: 0.75rem 0.85rem !important;
        gap: 0.75rem !important;
    }

    .pm-stat-card .pm-amount {
        font-size: 1.05rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Hide the "Avg per txn" column on mobile — saves space */
    .pm-stat-avg {
        display: none !important;
    }

    /* Shrink the icon circle */
    .pm-stat-card > div:first-child {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        border-radius: 8px !important;
    }

    .pm-stat-card > div:first-child i {
        font-size: 1rem !important;
    }

    /* Payment mode breakdown — 2 columns */
    .pm-breakdown-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.6rem !important;
    }

    /* Parent stats grid — 2 columns, compact cards */
    .parent-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.6rem !important;
    }

    .parent-stats-grid .card {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.4rem !important;
        padding: 0.7rem 0.75rem !important;
    }

    /* Shrink the icon circle */
    .parent-stats-grid .card > div:first-child {
        width: 32px !important;
        height: 32px !important;
        border-radius: 8px !important;
        flex-shrink: 0;
    }

    .parent-stats-grid .card > div:first-child i {
        font-size: 0.9rem !important;
    }

    /* Label */
    .parent-stats-grid .card h4 {
        font-size: 0.62rem !important;
        margin-bottom: 0.1rem !important;
    }

    /* Big number */
    .parent-stats-grid .card p {
        font-size: 1.15rem !important;
        margin: 0 !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    /* Sub-label */
    .parent-stats-grid .card span {
        font-size: 0.62rem !important;
    }

    /* Hide the Pay button on very small cards to save space */
    .parent-stats-grid .card a[href] {
        display: none !important;
    }
}

/* Loading / error states */
.dashboard-loading {
    display: flex; align-items: center; justify-content: center;
    min-height: 200px; color: #6b7280;
}
.dashboard-loading::before {
    content: ''; width: 1.5rem; height: 1.5rem;
    border: 2px solid #e5e7eb; border-top-color: #1a2744;
    border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 0.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.dashboard-error {
    background: #fef2f2; border: 1px solid #fecaca;
    border-radius: 8px; padding: 1rem; color: #991b1b; text-align: center;
}

.dashboard-content { opacity: 1; visibility: visible; }
.dashboard-content.loading { opacity: 0.7; }
.dashboard-content.force-visible { opacity: 1 !important; visibility: visible !important; }

/* ============================================
   TABLE STYLES - Added to fix missing data display
   ============================================ */

/* Table container */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Base table styles */
.table {
    width: 100%;
    border-collapse: collapse;
    border: 2px solid #bfbfbf;
    font-size: 0.875rem;
}

/* Table header */
.table thead {
    background: var(--primary-color, #1a1f3c);
    border-bottom: none;
}

.table thead th {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255,255,255,0.9);
    white-space: nowrap;
    border-right: 1px solid rgba(255,255,255,0.25);
    border-bottom: 2px solid rgba(255,255,255,0.3);
}
.table thead th:last-child { border-right: none; }
.table thead th span { color: inherit; }

/* Table body */
.table tbody tr:nth-child(odd)  { background: #ffffff; }
.table tbody tr:nth-child(even) { background: #f2f2f2; }
.table tbody tr:hover { background: #fff3cd !important; }

.table tbody td {
    padding: 0.5rem 0.75rem;
    color: var(--text-dark);
    vertical-align: middle;
    border: 1px solid #d0d0d0;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Footer */
.table tfoot td, .table tfoot th {
    background: #e8e8e8;
    border-top: 2px solid #bfbfbf;
    border: 1px solid #d0d0d0;
    font-weight: 700;
    padding: 0.5rem 0.75rem;
}

/* Numeric alignment */
.table .num {
    text-align: right;
    font-family: 'Inter', monospace;
}

/* Card styles enhancement */
.card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

/* Badge styles */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Empty state styling */
.table tbody tr:has(td[colspan]) {
    text-align: center;
    color: #9ca3af;
}

/* Dark mode support for tables */
[data-theme="dark"] .table { border-color: #4b5563; }
[data-theme="dark"] .table thead { background: rgba(0,0,0,0.4); }
[data-theme="dark"] .table thead th { color: rgba(255,255,255,0.85); border-color: rgba(255,255,255,0.15); }
[data-theme="dark"] .table tbody tr:nth-child(odd)  { background: #1f2937; }
[data-theme="dark"] .table tbody tr:nth-child(even) { background: #111827; }
[data-theme="dark"] .table tbody tr:hover { background: #374151 !important; }
[data-theme="dark"] .table tbody td { color: #d1d5db; border-color: #374151; }
[data-theme="dark"] .table tfoot td, [data-theme="dark"] .table tfoot th { background: #111827; border-color: #4b5563; color: #d1d5db; }

/* ============================================
   MODERN TABLE REFINEMENTS
   Tighter rows, smaller fonts, clean action btns
   ============================================ */

/* Tighter table rows — handled by base styles above */

.table tbody tr:last-child td { border-bottom: 1px solid #d0d0d0; }

/* ── Action button group in tables ── */
table .flex,
table .action-group {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    flex-wrap: nowrap;
}

/* ── Modern table action buttons ─────────────────────────────── */
table .btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    height: 24px;
    min-width: unset !important;
    min-height: unset !important;
    width: auto;
    padding: 0 0.55rem;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

table .btn-sm:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

table .btn-sm:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

table .btn-sm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* View / neutral / edit — indigo tint */
table .btn-outline,
table .btn-edit {
    background: #eef2ff;
    border-color: #c7d2fe;
    color: #4338ca;
}
table .btn-outline:hover:not(:disabled),
table .btn-edit:hover:not(:disabled) {
    background: #e0e7ff;
    border-color: #a5b4fc;
}

/* Primary / create — emerald tint */
table .btn-primary {
    background: #ecfdf5;
    border-color: #6ee7b7;
    color: #065f46;
}
table .btn-primary:hover:not(:disabled) {
    background: #d1fae5;
    border-color: #34d399;
}

/* Warning / disable — amber tint */
table .btn-warning {
    background: #fefce8;
    border-color: #fde68a;
    color: #854d0e;
}
table .btn-warning:hover:not(:disabled) {
    background: #fef9c3;
    border-color: #fcd34d;
}

/* Success / enable — green tint */
table .btn-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}
table .btn-success:hover:not(:disabled) {
    background: #dcfce7;
    border-color: #86efac;
}

/* Danger / delete — rose tint */
table .btn-danger {
    background: #fff1f2;
    border-color: #fecaca;
    color: #dc2626;
}
table .btn-danger:hover:not(:disabled) {
    background: #fee2e2;
    border-color: #fca5a5;
}

/* Secondary / info — sky tint */
table .btn-secondary {
    background: #f0f9ff;
    border-color: #bae6fd;
    color: #0369a1;
}
table .btn-secondary:hover:not(:disabled) {
    background: #e0f2fe;
    border-color: #7dd3fc;
}

/* Dark mode table — consolidated above */
[data-theme="dark"] table .btn-outline,
[data-theme="dark"] table .btn-edit {
    background: rgba(99,102,241,0.15);
    border-color: rgba(99,102,241,0.3);
    color: #a5b4fc;
}
[data-theme="dark"] table .text-primary {
    color: #60a5fa !important;
}
[data-theme="dark"] table a.text-primary:hover {
    color: #93c5fd !important;
    text-decoration: underline;
}
[data-theme="dark"] table .btn-danger {
    background: rgba(220,38,38,0.12);
    border-color: rgba(220,38,38,0.3);
    color: #fca5a5;
}
[data-theme="dark"] table .btn-warning {
    background: rgba(245,158,11,0.12);
    border-color: rgba(245,158,11,0.3);
    color: #fcd34d;
}
[data-theme="dark"] table .btn-success {
    background: rgba(22,163,74,0.12);
    border-color: rgba(22,163,74,0.3);
    color: #86efac;
}
[data-theme="dark"] table .btn-primary {
    background: rgba(6,95,70,0.15);
    border-color: rgba(52,211,153,0.3);
    color: #6ee7b7;
}

/* ── Modern topbar action buttons ────────────────────────────── */
.topbar-right .btn-sm,
.topbar-right .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    height: 30px;
    padding: 0 0.75rem;
    border-radius: 7px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: 0.01em;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.topbar-right .btn-sm:hover,
.topbar-right .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.topbar-right .btn-sm:active,
.topbar-right .btn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Primary — crimson solid */
.topbar-right .btn-primary {
    background: #c0152a;
    border-color: #c0152a;
    color: #fff;
}
.topbar-right .btn-primary:hover {
    background: #a01020;
    border-color: #a01020;
    color: #fff;
}

/* Outline — neutral (white text to match dark topbar) */
.topbar-right .btn-outline,
.topbar-right .btn-sm.btn-outline {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.4);
    color: #ffffff !important;
}
.topbar-right .btn-outline:hover,
.topbar-right .btn-sm.btn-outline:hover {
    background: rgba(255,255,255,0.22);
    border-color: rgba(255,255,255,0.65);
    color: #ffffff !important;
}

/* Success / green */
.topbar-right .btn-success {
    background: rgba(34,197,94,0.2);
    border-color: rgba(34,197,94,0.5);
    color: #ffffff !important;
}
.topbar-right .btn-success:hover {
    background: rgba(34,197,94,0.35);
    border-color: rgba(34,197,94,0.75);
    color: #ffffff !important;
}

/* Warning / amber */
.topbar-right .btn-warning {
    background: rgba(245,158,11,0.2);
    border-color: rgba(245,158,11,0.5);
    color: #ffffff !important;
}
.topbar-right .btn-warning:hover {
    background: rgba(245,158,11,0.35);
    border-color: rgba(245,158,11,0.75);
    color: #ffffff !important;
}

/* Danger / rose */
.topbar-right .btn-danger {
    background: #dc2626;
    border-color: #dc2626;
    color: #ffffff;
}
.topbar-right .btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #ffffff;
}

/* Dark mode topbar buttons */
[data-theme="dark"] .topbar-right .btn-primary {
    background: #c0152a;
    border-color: #c0152a;
    color: #fff;
}

/* Dark mode modern action buttons - matching invoices page */
[data-theme="dark"] .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}
[data-theme="dark"] .btn-primary {
    background: linear-gradient(135deg, #c0152a 0%, #8b1538 100%);
    border-color: rgba(255,255,255,0.15);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(192,21,42,0.3);
}
[data-theme="dark"] .btn-primary:hover {
    background: linear-gradient(135deg, #e11d48 0%, #c0152a 100%);
    box-shadow: 0 4px 12px rgba(192,21,42,0.4);
    transform: translateY(-1px);
}
[data-theme="dark"] .btn-outline {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.2);
    color: #e2e8f0;
}
[data-theme="dark"] .btn-outline:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.3);
    color: #ffffff;
}
[data-theme="dark"] .btn-secondary {
    background: rgba(99,102,241,0.2);
    border-color: rgba(99,102,241,0.4);
    color: #a5b4fc;
}
[data-theme="dark"] .btn-secondary:hover {
    background: rgba(99,102,241,0.3);
    color: #c7d2fe;
}
[data-theme="dark"] .btn-success {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    border-color: rgba(34,197,94,0.3);
    color: #ffffff;
}
[data-theme="dark"] .btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-color: rgba(239,68,68,0.3);
    color: #ffffff;
}
[data-theme="dark"] .btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-color: rgba(245,158,11,0.3);
    color: #ffffff;
}
[data-theme="dark"] .topbar-right .btn-outline {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.25);
    color: #ffffff !important;
}
[data-theme="dark"] .topbar-right .btn-outline:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.4);
    color: #ffffff !important;
}
[data-theme="dark"] .topbar-right .btn-danger {
    background: rgba(220,38,38,0.12);
    border-color: rgba(220,38,38,0.3);
    color: #fca5a5;
}

/* Dark mode dashboard card gradients */
[data-theme="dark"] .card {
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
[data-theme="dark"] .card-header {
    background: linear-gradient(90deg, rgba(124,29,29,0.3) 0%, rgba(192,21,42,0.2) 100%);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    color: #f1f5f9;
}
[data-theme="dark"] .card-header h5,
[data-theme="dark"] .card-header h6 {
    color: #f1f5f9;
}
[data-theme="dark"] .card-header a,
[data-theme="dark"] .card-header .btn-link,
[data-theme="dark"] .card .text-decoration-none {
    color: #60a5fa !important;
    transition: color 0.2s ease;
}
[data-theme="dark"] .card-header a:hover,
[data-theme="dark"] .card-header .btn-link:hover,
[data-theme="dark"] .card .text-decoration-none:hover {
    color: #93c5fd !important;
    text-decoration: underline !important;
}
[data-theme="dark"] .card-body {
    color: #cbd5e1;
}
[data-theme="dark"] .list-group-item {
    background: rgba(30,41,59,0.5);
    border-color: rgba(255,255,255,0.06);
    color: #e2e8f0;
}
[data-theme="dark"] .list-group-item:hover {
    background: rgba(51,65,85,0.5);
}

/* Dark mode students page table */
[data-theme="dark"] table tbody tr {
    background: #1e293b;
    color: #f8fafc !important;
}
[data-theme="dark"] table tbody tr:nth-child(even) {
    background: #0f172a;
}
[data-theme="dark"] table tbody tr td,
[data-theme="dark"] table tbody tr td * {
    color: #f8fafc !important;
}
[data-theme="dark"] table tbody tr td .text-muted,
[data-theme="dark"] table tbody tr td .text-secondary {
    color: #94a3b8 !important;
}
[data-theme="dark"] table tbody tr td .text-dark,
[data-theme="dark"] table tbody tr td [class*="text-dark"] {
    color: #f8fafc !important;
}
[data-theme="dark"] table tbody tr:hover {
    background: #334155 !important;
    color: #ffffff !important;
}
[data-theme="dark"] table tbody tr:hover td,
[data-theme="dark"] table tbody tr:hover td span,
[data-theme="dark"] table tbody tr:hover td div,
[data-theme="dark"] table tbody tr:hover td strong,
[data-theme="dark"] table tbody tr:hover td small {
    color: #ffffff !important;
}
[data-theme="dark"] table tbody tr:hover td * {
    color: #ffffff !important;
}
[data-theme="dark"] table tbody tr:hover td a,
[data-theme="dark"] table tbody tr:hover td a * {
    color: #60a5fa !important;
}
[data-theme="dark"] table tbody tr:hover td a:hover {
    color: #93c5fd !important;
}
[data-theme="dark"] table tbody tr:hover .badge,
[data-theme="dark"] table tbody tr:hover .badge * {
    color: inherit !important;
}

/* Dark mode action buttons */
[data-theme="dark"] table .btn-action,
[data-theme="dark"] table .btn-view,
[data-theme="dark"] table .btn-edit,
[data-theme="dark"] table .btn-delete,
[data-theme="dark"] table .btn-sm {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #e2e8f0;
}
[data-theme="dark"] table .btn-action:hover,
[data-theme="dark"] table .btn-view:hover {
    background: rgba(59,130,246,0.3);
    border-color: rgba(59,130,246,0.5);
    color: #ffffff;
}
[data-theme="dark"] table .btn-edit:hover {
    background: rgba(245,158,11,0.3);
    border-color: rgba(245,158,11,0.5);
    color: #ffffff;
}
[data-theme="dark"] table .btn-delete:hover {
    background: rgba(239,68,68,0.3);
    border-color: rgba(239,68,68,0.5);
    color: #ffffff;
}
[data-theme="dark"] table tbody tr:hover .btn-action,
[data-theme="dark"] table tbody tr:hover .btn-sm {
    background: rgba(255,255,255,0.12);
    color: #ffffff;
}

/* Dark mode Stop column dropdowns and Status badges */
[data-theme="dark"] table td select,
[data-theme="dark"] table td .form-select,
[data-theme="dark"] table td .dropdown-toggle {
    background: rgba(30,41,59,0.8);
    border-color: rgba(255,255,255,0.15);
    color: #e2e8f0;
}
[data-theme="dark"] table td select option {
    background: #1e293b;
    color: #e2e8f0;
}
[data-theme="dark"] table .badge.bg-success,
[data-theme="dark"] table .badge.bg-success * {
    background: rgba(34,197,94,0.25) !important;
    color: #86efac !important;
    border: 1px solid rgba(34,197,94,0.4);
}
[data-theme="dark"] table .badge.bg-warning,
[data-theme="dark"] table .badge.bg-warning * {
    background: rgba(245,158,11,0.25) !important;
    color: #fcd34d !important;
    border: 1px solid rgba(245,158,11,0.4);
}
[data-theme="dark"] table .badge.bg-danger,
[data-theme="dark"] table .badge.bg-danger * {
    background: rgba(239,68,68,0.25) !important;
    color: #fca5a5 !important;
    border: 1px solid rgba(239,68,68,0.4);
}
[data-theme="dark"] table .badge.bg-info,
[data-theme="dark"] table .badge.bg-info * {
    background: rgba(59,130,246,0.25) !important;
    color: #93c5fd !important;
    border: 1px solid rgba(59,130,246,0.4);
}
[data-theme="dark"] table .badge.bg-secondary,
[data-theme="dark"] table .badge.bg-secondary * {
    background: rgba(148,163,184,0.25) !important;
    color: #cbd5e1 !important;
    border: 1px solid rgba(148,163,184,0.4);
}
[data-theme="dark"] table .badge {
    color: #e2e8f0 !important;
}
[data-theme="dark"] table .badge * {
    color: inherit !important;
}
[data-theme="dark"] table tbody tr:hover .badge {
    color: inherit !important;
}
[data-theme="dark"] table th {
    background: linear-gradient(90deg, #1e293b 0%, #0f172a 100%);
    color: #f1f5f9;
    border-color: rgba(255,255,255,0.1);
}
[data-theme="dark"] table .badge {
    background: rgba(99,102,241,0.2);
    color: #a5b4fc;
    border: 1px solid rgba(99,102,241,0.3);
}
[data-theme="dark"] table .badge.bg-success {
    background: rgba(34,197,94,0.2) !important;
    color: #86efac;
    border-color: rgba(34,197,94,0.3);
}
[data-theme="dark"] table .badge.bg-warning {
    background: rgba(245,158,11,0.2) !important;
    color: #fcd34d;
    border-color: rgba(245,158,11,0.3);
}
[data-theme="dark"] table .badge.bg-danger {
    background: rgba(239,68,68,0.2) !important;
    color: #fca5a5;
    border-color: rgba(239,68,68,0.3);
}
[data-theme="dark"] table a {
    color: #60a5fa;
}
[data-theme="dark"] table a:hover {
    color: #93c5fd;
}
[data-theme="dark"] table .btn-sm {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: #cbd5e1;
}

/* Force all students table text to be light in dark mode */
[data-theme="dark"] .table,
[data-theme="dark"] .table *,
[data-theme="dark"] table *,
[data-theme="dark"] tbody *,
/* Dark theme table text - ONLY apply to actual table elements, not dashboard cards */
[data-theme="dark"] .table td *,
[data-theme="dark"] .table tr *,
[data-theme="dark"] table td *,
[data-theme="dark"] table tr * {
    color: #f8fafc !important;
}
/* Exclude dashboard gradient cards from dark theme table overrides */
[data-theme="dark"] .dashboard-card-gradient *,
[data-theme="dark"] .dashboard-card[style*="linear-gradient"] * {
    color: inherit !important;
}
/* Re-apply white to gradient card content */
[data-theme="dark"] .dashboard-card-gradient .dashboard-stat-content h4,
[data-theme="dark"] .dashboard-card-gradient .dashboard-stat-content .stat-number,
[data-theme="dark"] .dashboard-card-gradient .dashboard-stat-content .stat-label,
[data-theme="dark"] .dashboard-card-gradient .dashboard-stat-content p,
[data-theme="dark"] .dashboard-card-gradient .dashboard-stat-content span {
    color: #fff !important;
}
[data-theme="dark"] .table a,
[data-theme="dark"] .table a:link,
[data-theme="dark"] .table a:visited,
[data-theme="dark"] table a,
[data-theme="dark"] table a:link,
[data-theme="dark"] table a:visited {
    color: #60a5fa !important;
}
[data-theme="dark"] .table a:hover,
[data-theme="dark"] table a:hover {
    color: #93c5fd !important;
}
[data-theme="dark"] table .btn-sm:hover {
    background: rgba(255,255,255,0.1);
    color: #ffffff;
}

/* ── Extra-small phones (≤ 360px) ─────────────────────────────────────────── */
@media (max-width: 360px) {
    .reports-stat-number {
        font-size: clamp(0.58rem, 3vw, 0.75rem) !important;
        letter-spacing: -0.02em;
    }

    .reports-stat-card {
        padding: 0.45rem 0.4rem !important;
    }

    .reports-stat-label {
        font-size: 0.55rem !important;
    }

    .reports-stat-sub {
        font-size: 0.52rem !important;
    }
}


/* ── Gradient stat cards — keep all text white ──────────────────────────── */
.dashboard-card.dashboard-stat[style*="linear-gradient"] .dashboard-stat-content h4,
.dashboard-card.dashboard-stat[style*="linear-gradient"] .dashboard-stat-content .stat-number,
.dashboard-card.dashboard-stat[style*="linear-gradient"] .dashboard-stat-content .stat-label {
    color: inherit !important;
}

/* Gradient card class — forces all text white regardless of theme */
.dashboard-card-gradient .dashboard-stat-content h4,
.dashboard-card-gradient .dashboard-stat-content .stat-number,
.dashboard-card-gradient .dashboard-stat-content .stat-label,
.dashboard-card-gradient .dashboard-stat-content * {
    color: #fff !important;
}
[data-theme="dark"] .dashboard-card-gradient .dashboard-stat-content h4,
[data-theme="dark"] .dashboard-card-gradient .dashboard-stat-content .stat-number,
[data-theme="dark"] .dashboard-card-gradient .dashboard-stat-content .stat-label {
    color: #fff !important;
}
