html,
body {
    min-height: 100%;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 20px 16px;
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    z-index: 1040;
    overflow-y: auto;
}

.brand,
.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand {
    margin-bottom: 28px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary-color), var(--success-color));
    color: #ffffff;
    font-weight: var(--font-weight-bold);
}

.brand strong,
.auth-brand h1 {
    display: block;
    margin: 0;
    color: var(--text-color);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    line-height: 1.2;
}

.brand small,
.auth-brand p,
.page-subtitle,
.panel-head p {
    margin: 0;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.nav-list {
    display: grid;
    gap: 8px;
    padding: 0 10px;
}

.nav-list .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    padding: 10px 14px;
    border-radius: 12px;
    color: var(--text-color);
    font-weight: 500;
    font-size: 1.05rem;
    transition: all 0.2s ease;
}

.nav-list .nav-link:hover {
    background: color-mix(in srgb, var(--primary-color) 8%, transparent);
    color: var(--primary-color);
}

[data-theme="dark"] .nav-list .nav-link:hover {
    background: rgba(255,255,255,0.05);
}

.nav-list .nav-link.active {
    background: #1c1c28;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

[data-theme="dark"] .nav-list .nav-link.active {
    background: var(--primary-color);
    color: #ffffff;
}

.nav-link svg,
.icon-btn svg,
.module-icon svg,
.panel-head svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

/* Sidebar Grouping & Submenus */
.nav-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-group-toggle {
    cursor: pointer;
}

.nav-group-toggle .chevron-icon {
    transition: transform 0.2s ease;
    width: 16px;
    height: 16px;
    opacity: 0.6;
}

.nav-group-toggle[aria-expanded="true"] .chevron-icon {
    transform: rotate(180deg);
}

.nav-submenu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-left: 12px;
    margin-top: 4px;
    border-left: 2px solid var(--border-color);
    margin-left: 23px;
}

.nav-list .submenu-link {
    padding: 8px 12px;
    min-height: 38px;
    font-size: 0.95rem;
}

.submenu-bullet {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-muted);
    transition: background-color 0.2s;
}

.submenu-link:hover .submenu-bullet,
.submenu-link.active .submenu-bullet {
    background-color: var(--primary-color);
}

/* Hide scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
    display: none;
}
.sidebar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.app-main {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 78px;
    padding: 14px 28px;
    background: color-mix(in srgb, var(--bg-color) 86%, transparent);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(16px);
}

.page-title {
    margin: 0;
    color: var(--text-color);
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-bold);
    line-height: 1.2;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-color);
    color: var(--text-color);
    box-shadow: none;
}

.icon-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.danger-btn {
    color: #ef4444;
}

.danger-btn:hover {
    border-color: #ef4444;
    background-color: #ef4444;
    color: #ffffff;
}

.theme-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.theme-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.theme-switch span {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    width: 66px;
    height: 36px;
    padding: 4px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--surface-color);
    color: var(--text-muted);
}

.theme-switch span::before {
    content: "";
    position: absolute;
    left: 5px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-color);
    transform: translateX(0);
    transition: transform var(--transition);
}

.theme-switch input:checked + span::before {
    transform: translateX(30px);
}

.theme-switch svg {
    z-index: 1;
    justify-self: center;
    width: 15px;
    height: 15px;
    transition: color 0.3s ease;
}

.theme-switch input:not(:checked) + span svg:first-of-type {
    color: #ffffff;
}

.theme-switch input:checked + span svg:last-of-type {
    color: #ffffff;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 6px 10px 6px 6px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-color);
}

.user-chip > span {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--primary-color) 16%, var(--surface-muted));
    color: var(--primary-color);
    font-weight: var(--font-weight-bold);
}

.user-chip strong,
.user-chip small {
    display: block;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.15;
}

.user-chip small {
    color: var(--text-muted);
}

.content-wrap {
    width: min(100%, 1480px);
    margin: 0 auto;
    padding: 26px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 18px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-column: 1 / -1;
    gap: 18px;
}

.metric-card,
.panel {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface-color);
    box-shadow: var(--shadow-card);
}

.metric-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 140px;
    padding: 20px;
    border: none;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 24px rgba(0,0,0,0.1);
}

.metric-card-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.metric-card .metric-label {
    margin: 0;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    font-weight: 500;
}

.metric-card .metric-value {
    margin: auto 0 0 auto;
    color: #ffffff;
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
}

/* Background Gradients */
.metric-card-primary { background: linear-gradient(135deg, #f97316 0%, #ef683d 100%); } /* Orange */
.metric-card-success { background: linear-gradient(135deg, #10b981 0%, #319c50 100%); } /* Green */
.metric-card-info { background: linear-gradient(135deg, #3b82f6 0%, #3b96c4 100%); } /* Blue */
.metric-card-warning { background: linear-gradient(135deg, #8b5cf6 0%, #7e62b0 100%); } /* Purple */
.metric-card-danger { background: linear-gradient(135deg, #d946ef 0%, #cd5a9b 100%); } /* Magenta */

/* The wave/chart background */
.metric-card-bg {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    opacity: 0.35;
    background-repeat: no-repeat;
    background-position: bottom left;
    background-size: contain;
}

.metric-card-danger .metric-card-bg {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 50' preserveAspectRatio='none'%3E%3Cpath fill='%23fff' d='M10 50v-30h5v30zm10 0v-20h5v20zm10 0v-40h5v40zm10 0v-10h5v10zm10 0v-25h5v25zm10 0v-15h5v15zm10 0v-35h5v35z'/%3E%3C/svg%3E");
    background-size: 60% 60%;
    background-position: left 20px bottom 20px;
}

.metric-card-warning .metric-card-bg {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 50' preserveAspectRatio='none'%3E%3Cpath fill='%23fff' d='M0 50 V30 Q25 10 50 30 T100 30 V50 z'/%3E%3C/svg%3E");
    background-size: cover;
    opacity: 0.2;
}

.metric-card-info .metric-card-bg {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 50' preserveAspectRatio='none'%3E%3Cpolyline fill='none' stroke='%23fff' stroke-width='2' points='10,40 30,20 50,30 70,10 90,40'/%3E%3Ccircle cx='10' cy='40' r='3' fill='%23fff'/%3E%3Ccircle cx='30' cy='20' r='3' fill='%23fff'/%3E%3Ccircle cx='50' cy='30' r='3' fill='%23fff'/%3E%3Ccircle cx='70' cy='10' r='3' fill='%23fff'/%3E%3Ccircle cx='90' cy='40' r='3' fill='%23fff'/%3E%3C/svg%3E");
    background-size: 70% 60%;
    background-position: left 20px bottom 20px;
}

.metric-card-primary .metric-card-bg {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 50' preserveAspectRatio='none'%3E%3Cpath fill='%23fff' d='M10 50v-40h5v40zm10 0v-20h5v20zm10 0v-30h5v30zm10 0v-10h5v10zm10 0v-40h5v40zm10 0v-25h5v25zm10 0v-15h5v15z'/%3E%3C/svg%3E");
    background-size: 60% 60%;
    background-position: left 20px bottom 20px;
}

.metric-card-success .metric-card-bg {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 50' preserveAspectRatio='none'%3E%3Cpath fill='%23fff' d='M0 50 V40 Q25 50 50 20 T100 30 V50 z'/%3E%3C/svg%3E");
    background-size: cover;
    opacity: 0.2;
}
    font-weight: var(--font-weight-medium);
}

.tone-primary { color: var(--primary-color); }
.tone-success { color: var(--success-color); }
.tone-warning { color: var(--warning-color); }
.tone-info { color: var(--info-color); }
.tone-danger { color: var(--danger-color); }

.panel {
    min-width: 0;
    padding: 18px;
}

.chart-panel {
    grid-column: span 8;
}

.dashboard-grid > .panel:not(.chart-panel) {
    grid-column: span 4;
}

.dashboard-grid > .panel {
    background: linear-gradient(145deg, var(--surface-color), color-mix(in srgb, var(--primary-color) 3%, var(--surface-color)));
    border: 1px solid color-mix(in srgb, var(--primary-color) 8%, var(--border-color));
    box-shadow: 0 8px 32px rgb(var(--shadow-color) / 0.05);
}

.notifications-panel {
    grid-column: span 8;
}

.panel-head,
.module-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.panel-head h2,
.module-head h2 {
    margin: 0;
    color: var(--text-color);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    line-height: 1.25;
}

.chart-box {
    min-height: 280px;
}

.status-pill,
.badge-soft {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--success-color) 14%, var(--surface-muted));
    color: var(--success-color);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-xs);
}

.fee-summary {
    display: grid;
    gap: 14px;
}

.fee-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-muted);
}

.fee-row strong {
    color: var(--text-color);
}

.progress {
    height: 10px;
    background: var(--surface-muted);
}

.progress-bar {
    background: linear-gradient(90deg, var(--success-color), var(--primary-color));
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--surface-color);
    color: var(--text-color);
    font-weight: var(--font-weight-medium);
    text-align: center;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02);
}

.quick-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05);
}

.qa-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    margin-bottom: 4px;
}

.qa-icon-wrapper svg {
    width: 24px;
    height: 24px;
    stroke-width: 2;
}

/* Primary (Orange) */
.quick-action.qa-primary { background-color: rgba(239, 104, 61, 0.04); border-color: rgba(239, 104, 61, 0.15); }
.qa-primary .qa-icon-wrapper { background-color: rgba(239, 104, 61, 0.15); color: var(--primary-color); }
.quick-action.qa-primary:hover { background-color: rgba(239, 104, 61, 0.08); border-color: var(--primary-color); color: var(--primary-color); }

/* Success (Green) */
.quick-action.qa-success { background-color: rgba(16, 185, 129, 0.04); border-color: rgba(16, 185, 129, 0.15); }
.qa-success .qa-icon-wrapper { background-color: rgba(16, 185, 129, 0.15); color: var(--success-color); }
.quick-action.qa-success:hover { background-color: rgba(16, 185, 129, 0.08); border-color: var(--success-color); color: var(--success-color); }

/* Info (Blue) */
.quick-action.qa-info { background-color: rgba(59, 130, 246, 0.04); border-color: rgba(59, 130, 246, 0.15); }
.qa-info .qa-icon-wrapper { background-color: rgba(59, 130, 246, 0.15); color: var(--info-color); }
.quick-action.qa-info:hover { background-color: rgba(59, 130, 246, 0.08); border-color: var(--info-color); color: var(--info-color); }

/* Warning (Purple) */
.quick-action.qa-warning { background-color: rgba(139, 92, 246, 0.04); border-color: rgba(139, 92, 246, 0.15); }
.qa-warning .qa-icon-wrapper { background-color: rgba(139, 92, 246, 0.15); color: var(--warning-color); }
.quick-action.qa-warning:hover { background-color: rgba(139, 92, 246, 0.08); border-color: var(--warning-color); color: var(--warning-color); }

/* Danger (Red) */
.quick-action.qa-danger { background-color: rgba(239, 68, 68, 0.04); border-color: rgba(239, 68, 68, 0.15); }
.qa-danger .qa-icon-wrapper { background-color: rgba(239, 68, 68, 0.15); color: var(--danger-color); }
.quick-action.qa-danger:hover { background-color: rgba(239, 68, 68, 0.08); border-color: var(--danger-color); color: var(--danger-color); }

.notification-list {
    display: grid;
    gap: 10px;
}

.notification-item {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-muted);
}

.notification-item strong {
    color: var(--text-color);
}

.notification-item p {
    margin: 0;
    color: var(--text-muted);
}

.module-shell {
    display: grid;
    gap: 18px;
}

.module-head {
    margin-bottom: 0;
}

.module-head > div {
    display: flex;
    align-items: center;
    gap: 12px;
}

.module-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
    justify-content: flex-end;
    overflow-x: auto;
}

.module-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
    border-radius: 6px;
}

.module-actions .btn svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

.attendance-self-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
    gap: 18px;
}

.attendance-status-panel,
.attendance-summary-panel {
    display: grid;
    gap: 16px;
}

.attendance-status-card {
    display: grid;
    gap: 8px;
    min-height: 122px;
    align-content: center;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-muted);
}

.attendance-status-card strong {
    color: var(--text-color);
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    line-height: 1.2;
}

.attendance-status-card small {
    color: var(--text-muted);
}

.attendance-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.attendance-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.class-attendance-panel {
    display: grid;
    gap: 16px;
}

.class-attendance-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) auto;
    gap: 12px;
    align-items: end;
}

.class-attendance-toolbar-actions {
    display: flex;
    gap: 10px;
}

.class-attendance-toolbar-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
}

.timetable-filter-toolbar {
    display: grid;
    grid-template-columns: minmax(200px, 320px) minmax(200px, 320px);
    gap: 12px;
}

.timetable-grid-table th[title],
.timetable-grid-table td[title] {
    cursor: help;
}

.invoice-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--surface-muted);
}

.bank-details-card {
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-muted);
}

.payment-settings-block {
    padding-bottom: 4px;
}

.class-attendance-table td strong,
.class-attendance-table td small {
    display: block;
}

.class-attendance-table td small {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.class-attendance-table .form-select,
.class-attendance-table .form-control {
    min-width: 150px;
}

.attendance-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.attendance-summary-grid div {
    display: grid;
    gap: 4px;
    min-height: 74px;
    align-content: center;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-muted);
}

.attendance-summary-grid span {
    color: var(--text-color);
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    line-height: 1;
}

.attendance-summary-grid small {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.module-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--primary-color);
}

.responsive-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.module-table {
    min-width: 720px;
}

.module-table th {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
}

.module-table td {
    vertical-align: middle;
}

.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.row-actions .icon-btn {
    width: 34px;
    height: 34px;
}

.empty-state {
    display: grid;
    place-items: center;
    gap: 10px;
    min-height: 220px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state svg {
    width: 38px;
    height: 38px;
}

.auth-body {
    min-height: 100vh;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--primary-color) 12%, transparent), transparent 36%),
        var(--bg-color);
}

.auth-page {
    display: grid;
    grid-template-columns: minmax(320px, 480px) minmax(0, 1fr);
    min-height: 100vh;
}

.auth-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 24px;
    padding: clamp(24px, 5vw, 56px);
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
}

.auth-brand h1 {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
}

.auth-form {
    display: grid;
    gap: 16px;
}

.auth-visual {
    position: relative;
    display: grid;
    place-items: center;
    padding: 48px;
    overflow: hidden;
}

body .modal-content {
    background: var(--surface-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

body .modal-header,
body .modal-footer {
    border-color: var(--border-color);
}

.student-profile-view {
    display: grid;
    gap: 16px;
}

.profile-hero {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-muted);
}

.profile-avatar {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    border-radius: 8px;
    background: var(--primary-color);
    color: var(--primary-contrast);
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    overflow: hidden;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-photo {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
}

.profile-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;
}

.profile-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.user-chip-link {
    cursor: pointer;
}

.user-chip-link:hover {
    border-color: var(--primary-color);
    color: var(--text-color);
}

.user-chip-link small {
    color: var(--text-muted);
}

.profile-hero h3,
.profile-panel h4 {
    margin: 0;
    color: var(--text-color);
}

.profile-hero p {
    margin: 4px 0 0;
    color: var(--text-muted);
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.profile-panel {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-color);
}

.profile-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.profile-panel-head .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.profile-panel h4 {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
}

.profile-row,
.profile-list-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-top: 1px solid var(--border-color);
}

.profile-row span,
.profile-list-item span {
    color: var(--text-muted);
}

.profile-row strong,
.profile-list-item strong {
    color: var(--text-color);
    text-align: right;
}

.profile-list-main {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.profile-list-main strong {
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
}

.student-detail-page {
    display: grid;
    gap: 16px;
}

.student-detail-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.student-detail-toolbar .btn,
.student-identity-actions .btn,
.detail-section-head .btn,
.record-item .btn,
.student-profile-tabs .nav-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.profile-actions .btn svg,
.student-detail-page .btn svg,
.student-profile-tabs .nav-link svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.student-detail-layout {
    display: grid;
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.student-identity-panel,
.student-detail-main {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-color);
    box-shadow: var(--shadow-soft);
}

.student-identity-panel {
    position: sticky;
    top: 96px;
    display: grid;
    gap: 16px;
    padding: 18px;
}

.student-detail-photo-wrap {
    display: grid;
    place-items: center;
    min-height: 164px;
    border-radius: 8px;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
}

.student-detail-photo {
    width: 142px;
    height: 142px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
}

.student-detail-avatar {
    display: grid;
    place-items: center;
    width: 142px;
    height: 142px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary-color), var(--success-color));
    color: #ffffff;
    font-size: var(--font-size-display);
    font-weight: var(--font-weight-bold);
}

.student-identity-copy {
    display: grid;
    justify-items: center;
    gap: 6px;
    text-align: center;
}

.student-identity-copy h2 {
    margin: 0;
    color: var(--text-color);
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    line-height: 1.25;
}

.student-identity-copy p {
    margin: 0;
    color: var(--text-muted);
}

.student-identity-actions {
    display: grid;
    gap: 8px;
}

.student-side-details {
    display: grid;
    gap: 2px;
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
}

.student-detail-main {
    min-width: 0;
    overflow: hidden;
}

.student-profile-tabs {
    gap: 6px;
    padding: 14px 14px 0;
    border-bottom: 1px solid var(--border-color);
}

.student-profile-tabs .nav-link {
    min-height: 38px;
    border-radius: 8px 8px 0 0;
    color: var(--text-muted);
    font-weight: var(--font-weight-semibold);
}

.student-profile-tabs .nav-link.active {
    background: var(--primary-color);
    color: var(--primary-contrast);
}

.student-tab-content {
    padding: 18px;
}

.detail-section {
    display: grid;
    gap: 14px;
}

.detail-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.detail-section-head h3 {
    margin: 0;
    color: var(--text-color);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
}

.detail-section-head span {
    color: var(--text-muted);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 18px;
}

.detail-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    min-height: 42px;
    padding: 10px 0;
    border-top: 1px solid var(--border-color);
}

.detail-row span {
    color: var(--text-muted);
}

.detail-row strong {
    color: var(--text-color);
    text-align: right;
    overflow-wrap: anywhere;
}

.record-list {
    display: grid;
    gap: 10px;
}

.record-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-muted);
}

.record-item > div:first-child {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.record-item strong {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-color);
}

.record-item span {
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

.detail-table {
    margin: 0;
}

.settings-page {
    display: grid;
    gap: 16px;
}

.settings-form {
    display: grid;
    gap: 16px;
}

.settings-section {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-color);
    box-shadow: var(--shadow-soft);
}

.settings-section h3 {
    margin: 0;
    color: var(--text-color);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
}

.settings-section .form-check {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-muted);
    min-height: 44px;
    transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.settings-section .form-check:hover {
    border-color: color-mix(in srgb, var(--primary-color) 35%, var(--border-color));
    background: color-mix(in srgb, var(--primary-color) 6%, var(--surface-muted));
}

.settings-section .form-check-input {
    flex: 0 0 auto;
    margin-top: 0;
}

.settings-section .form-check-label {
    flex: 1 1 auto;
    color: var(--text-color);
    font-weight: var(--font-weight-medium);
}

.settings-section .form-check-input:checked + .form-check-label {
    color: var(--primary-color);
}

.role-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.role-grid .form-check {
    display: flex;
    align-items: center;
    margin: 0;
}

.school-action-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.school-action-group .icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
}

.school-action-group .icon-btn svg {
    width: 16px;
    height: 16px;
}

.auth-visual::before {
    content: "";
    position: absolute;
    inset: 8%;
    border-radius: 8px;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--primary-color) 24%, transparent), transparent),
        linear-gradient(315deg, color-mix(in srgb, var(--success-color) 22%, transparent), transparent),
        var(--surface-color);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
}

.visual-grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    gap: 18px;
    width: min(760px, 100%);
}

.visual-stat {
    padding: 22px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: color-mix(in srgb, var(--surface-color) 86%, transparent);
    backdrop-filter: blur(10px);
}

.visual-stat span {
    display: block;
    color: var(--text-color);
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-bold);
}

.visual-stat small {
    color: var(--text-muted);
}

.min-w-0 {
    min-width: 0;
}

@media (max-width: 1180px) {
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .chart-panel,
    .dashboard-grid > .panel:not(.chart-panel),
    .notifications-panel {
        grid-column: 1 / -1;
    }

    .attendance-self-grid {
        grid-template-columns: 1fr;
    }

    .class-attendance-toolbar {
        grid-template-columns: 1fr 180px;
    }

    .timetable-filter-toolbar {
        grid-template-columns: 1fr 1fr;
    }

    .class-attendance-toolbar-actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 991.98px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: 0;
        transform: translateX(-100%);
        width: min(86vw, 300px);
        box-shadow: var(--shadow-soft);
        transition: transform var(--transition);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .topbar {
        padding: 12px 16px;
    }

    .content-wrap {
        padding: 18px 14px 28px;
    }

    .user-chip div {
        display: none;
    }

    .auth-page {
        grid-template-columns: 1fr;
    }

    .auth-visual {
        display: none;
    }

    .student-detail-layout {
        grid-template-columns: 1fr;
    }

    .student-identity-panel {
        position: static;
    }
}

@media (max-width: 640px) {
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .topbar-actions {
        gap: 6px;
    }

    .theme-switch span {
        width: 58px;
    }

    .theme-switch input:checked + span::before {
        transform: translateX(22px);
    }

    .panel,
    .metric-card {
        padding: 14px;
    }

    .profile-grid {
        grid-template-columns: 1fr;
    }

    .profile-hero,
    .profile-row,
    .profile-list-item {
        align-items: flex-start;
    }

    .profile-actions {
        width: 100%;
        margin-left: 0;
    }

    .student-profile-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 8px;
    }

    .student-profile-tabs .nav-link {
        white-space: nowrap;
        border-radius: 8px;
    }

    .student-tab-content {
        padding: 14px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-section-head,
    .record-item,
    .detail-row {
        align-items: flex-start;
    }

    .detail-section-head,
    .record-item {
        flex-direction: column;
    }

    .detail-row strong {
        max-width: 58%;
    }

    .role-grid {
        grid-template-columns: 1fr;
    }

    .attendance-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .attendance-actions .btn {
        flex: 1 1 150px;
        justify-content: center;
    }

    .class-attendance-toolbar {
        grid-template-columns: 1fr;
    }

    .timetable-filter-toolbar {
        grid-template-columns: 1fr;
    }

    .class-attendance-toolbar-actions .btn {
        flex: 1 1 140px;
        justify-content: center;
    }
}

/* --- Table & Status Redesign --- */
.table, .module-table {
    border-collapse: separate !important;
    border-spacing: 0 4px !important;
    margin-top: 10px;
}

.table thead, .module-table thead {
    background-color: #2b3445;
}

.table thead th, .module-table thead th {
    color: #ffffff !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none !important;
    padding: 12px 10px !important;
    white-space: nowrap !important;
}

.table thead th:first-child, .module-table thead th:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.table thead th:last-child, .module-table thead th:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.table tbody tr, .module-table tbody tr {
    background-color: var(--surface-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
    transition: transform 0.2s;
}

.table tbody tr:hover, .module-table tbody tr:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.table tbody td, .module-table tbody td {
    border: none !important;
    padding: 12px 10px !important;
    vertical-align: middle;
    color: var(--text-color);
    font-size: 0.85rem;
}

.table tbody td:first-child, .module-table tbody td:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.table tbody td:last-child, .module-table tbody td:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* Pagination Overrides */
.pagination {
    margin-top: 1rem;
    gap: 4px;
}
.page-item .page-link {
    border: none;
    border-radius: 50% !important;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-weight: 500;
}
.page-item.active .page-link {
    background-color: var(--danger-color);
    color: #fff;
    box-shadow: 0 2px 4px rgba(205, 90, 155, 0.4);
}

/* Status Badges */
.badge-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    padding: 6px 12px;
    border-radius: 6px;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.badge-active, .badge-paid, .badge-success, .badge-open { background: var(--success-color) !important; }
.badge-inactive, .badge-failed { background: var(--danger-color) !important; }
.badge-process, .badge-pending { background: var(--danger-color) !important; } 
.badge-on-hold, .badge-draft { background: var(--info-color) !important; }
.badge-warning { background: var(--warning-color) !important; } 

.badge-status:not([class*="badge-"]) {
    background: var(--primary-color) !important;
}