:root {
    --primary: #3157d5;
    --primary-dark: #2443b0;
    --primary-soft: #edf1ff;
    --sidebar: #17233e;
    --sidebar-muted: #a8b4cc;
    --background: #f5f7fb;
    --surface: #ffffff;
    --text: #202b3c;
    --muted: #7c8799;
    --border: #e8ecf3;
    --success: #159b69;
    --radius: 14px;
    --shadow: 0 4px 18px rgba(32, 43, 60, 0.04);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--background);
    color: var(--text);
    font-size: 14px;
}

button, input, select {
    font: inherit;
}

button, a {
    -webkit-tap-highlight-color: transparent;
}

button {
    cursor: pointer;
}

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

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    background: var(--sidebar);
    color: white;
    padding: 25px 16px 18px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.25s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    font-size: 21px;
    font-weight: 700;
    padding: 0 10px;
    margin-bottom: 33px;
}

.brand-icon {
    display: grid;
    place-items: center;
    width: 39px;
    height: 39px;
    background: var(--primary);
    border-radius: 12px;
    font-size: 23px;
}

.brand-light {
    color: #91aaff;
}

.school-label {
    font-size: 10px;
    letter-spacing: 1.2px;
    color: var(--sidebar-muted);
    padding: 0 12px;
    margin-bottom: 12px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nav-link {
    min-height: 43px;
    padding: 11px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 9px;
    color: #c2cce0;
    transition: background 0.2s, color 0.2s;
}

.nav-link > span {
    width: 20px;
    text-align: center;
    font-size: 17px;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.07);
    color: white;
}

.nav-link.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.sidebar-bottom {
    margin-top: auto;
    padding: 20px 12px 0;
    color: white;
}

.school-year, .sidebar-note {
    color: var(--sidebar-muted);
    font-size: 12px;
    margin-bottom: 7px;
}

.sidebar-bottom strong {
    display: block;
    margin-bottom: 18px;
}

.main-area {
    margin-left: 250px;
    min-width: 0;
}

.topbar {
    height: 82px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 17px;
}

.breadcrumb {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 5px;
}

h1, h2, h3, p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 22px;
}

h2 {
    font-size: 23px;
    margin-bottom: 8px;
}

h3 {
    font-size: 15px;
    margin-bottom: 7px;
}

.icon-button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    background: white;
    border-radius: 10px;
    color: var(--text);
}

.menu-toggle {
    display: none;
}

.search-box {
    width: 225px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--border);
    padding: 0 11px;
    height: 39px;
    border-radius: 9px;
    color: var(--muted);
}

.search-box input {
    min-width: 0;
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
}

.profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar, .student-avatar {
    width: 39px;
    height: 39px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #e4eaff;
    color: var(--primary);
    font-weight: 700;
}

.profile-details strong, .profile-details span {
    display: block;
}

.profile-details strong {
    font-size: 12px;
    margin-bottom: 4px;
}

.profile-details span {
    color: var(--muted);
    font-size: 11px;
}

.page-content {
    max-width: 1600px;
    margin: auto;
    padding: 30px;
}

.welcome-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 26px;
}

.welcome-row h2 {
    margin-bottom: 8px;
}

.eyebrow {
    color: var(--primary);
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 1.4px;
    margin-bottom: 10px;
}

.muted {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
    margin-bottom: 0;
}

.date-chip {
    background: white;
    border: 1px solid var(--border);
    padding: 11px 14px;
    border-radius: 10px;
    color: #536075;
    white-space: nowrap;
    font-size: 12px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

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

.stat-card {
    padding: 21px;
    min-width: 0;
}

.stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
}

.stat-icon {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 11px;
    font-size: 19px;
}

.blue {
    color: #3157d5;
    background: #edf1ff;
}

.purple {
    color: #8356cf;
    background: #f2eaff;
}

.green {
    color: #159b69;
    background: #e4f8ef;
}

.orange {
    color: #d88125;
    background: #fff0df;
}

.stat-number {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.8px;
    margin: 18px 0 8px;
}

.stat-foot {
    font-size: 11px;
    color: var(--muted);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 20px;
    margin-bottom: 22px;
}

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

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 23px;
}

.panel-heading h3 {
    margin-bottom: 6px;
}

.status-pill, .table-status {
    color: var(--success);
    background: #e6f8f0;
    border-radius: 20px;
    padding: 7px 11px;
    font-size: 11px;
    white-space: nowrap;
}

.attendance-summary {
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    gap: 20px;
    padding: 8px 0;
}

.attendance-circle {
    width: 150px;
    height: 150px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: conic-gradient(
        var(--primary) 0% var(--att, 0%),
        #e8edf7 var(--att, 0%) 100%
    );
    position: relative;
}

.attendance-circle::before {
    content: "";
    position: absolute;
    inset: 13px;
    border-radius: 50%;
    background: white;
}

.attendance-circle > div {
    z-index: 1;
    text-align: center;
}

.attendance-circle strong, .attendance-circle span {
    display: block;
}

.attendance-circle strong {
    font-size: 25px;
}

.attendance-circle span {
    color: var(--muted);
    font-size: 11px;
    margin-top: 5px;
}

.attendance-legend {
    display: grid;
    gap: 20px;
    min-width: 115px;
}

.attendance-legend > div {
    display: grid;
    grid-template-columns: 10px 1fr;
    gap: 6px 9px;
    align-items: center;
    font-size: 11px;
    color: var(--muted);
}

.attendance-legend strong {
    grid-column: 2;
    color: var(--text);
    font-size: 16px;
}

.legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    grid-row: span 2;
}

.legend-dot.present {
    background: var(--primary);
}

.legend-dot.absent {
    background: #dfe5f1;
}

.fee-amount {
    font-size: 30px;
    font-weight: 700;
    margin: 12px 0 8px;
}

.progress-track {
    height: 9px;
    background: #edf0f7;
    border-radius: 20px;
    overflow: hidden;
    margin-top: 25px;
}

.progress-fill {
    width: 0;
    height: 100%;
    background: var(--primary);
    border-radius: inherit;
}

.fee-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 11px;
    color: var(--muted);
}

.fee-footer strong {
    color: var(--primary);
}

.small-note {
    color: var(--muted);
    font-size: 10px;
    line-height: 1.6;
    margin: 17px 0 0;
}

.primary-button, .secondary-button {
    border: 0;
    padding: 11px 15px;
    border-radius: 9px;
    font-weight: 600;
    font-size: 12px;
}

.primary-button {
    background: var(--primary);
    color: white;
}

.primary-button:hover {
    background: var(--primary-dark);
}

.secondary-button {
    background: #eef1f7;
    color: var(--text);
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

th {
    background: #f8f9fc;
    color: var(--muted);
    text-align: left;
    font-weight: 600;
    font-size: 11px;
}

th, td {
    padding: 15px 13px;
    border-bottom: 1px solid var(--border);
}

td {
    font-size: 12px;
}

.student-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.student-cell strong, .student-cell span {
    display: block;
}

.student-cell strong {
    margin-bottom: 5px;
    font-size: 12px;
}

.student-cell span {
    font-size: 10px;
    color: var(--muted);
}

.student-avatar {
    width: 35px;
    height: 35px;
    flex-shrink: 0;
}

.student-avatar.lavender {
    background: #f0eaff;
    color: #8056c9;
}

.student-avatar.peach {
    background: #fff0e5;
    color: #bf7736;
}

.page-footer {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    color: var(--muted);
    font-size: 11px;
    padding: 27px 0 5px;
}

.student-dialog {
    border: 0;
    border-radius: 16px;
    padding: 26px;
    width: min(450px, calc(100% - 30px));
    box-shadow: 0 20px 80px #17233e35;
}

.student-dialog::backdrop {
    background: #17233e88;
}

.dialog-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 23px;
}

.dialog-heading h2 {
    font-size: 20px;
}

.form-field {
    display: grid;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 17px;
}

.form-field input, .form-field select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    outline-color: var(--primary);
    background: white;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 25px;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    background: #17233e;
    color: white;
    padding: 13px 18px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    z-index: 200;
    display: none;
    max-width: calc(100% - 44px);
}

.toast.show {
    display: block;
}

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

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

    .topbar {
        padding: 0 20px;
    }

    .page-content {
        padding: 22px 20px;
    }
}

@media (max-width: 760px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 12px 0 35px #17233e25;
    }

    .main-area {
        margin-left: 0;
    }

    .topbar {
        height: auto;
        min-height: 75px;
        padding: 15px;
        flex-wrap: wrap;
    }

    .menu-toggle {
        display: grid;
    }

    .topbar-right {
        width: 100%;
        flex-wrap: wrap;
    }

    .search-box {
        flex: 1;
        width: auto;
        min-width: 130px;
    }

    .profile {
        margin-left: auto;
    }

    .page-content {
        padding: 20px 14px;
    }

    .welcome-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .welcome-row h2 {
        font-size: 21px;
    }

    .stats-grid {
        gap: 12px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-number {
        font-size: 24px;
    }

    .attendance-summary {
        justify-content: space-around;
        flex-wrap: wrap;
    }

    .attendance-circle {
        width: 130px;
        height: 130px;
    }

    .panel {
        padding: 17px;
    }

    .page-footer {
        flex-direction: column;
    }
}

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

    .profile-details {
        display: none;
    }

    .attendance-summary {
        gap: 20px;
    }
}
.brand .brand-icon { flex: none; }
.brand-name {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-width: 0;
    font-size: 1rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.search-wrap { position: relative; }
.search-wrap .search-box { width: 260px; }

.search-results {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 60;
    width: min(440px, calc(100vw - 32px));
    max-height: 70vh;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 18px 50px rgba(23, 35, 62, 0.18);
}
.search-results[hidden] { display: none; }

.search-group + .search-group { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
.search-group-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.search-group-title a { color: var(--primary); text-decoration: none; text-transform: none; letter-spacing: 0; font-weight: 600; }
.search-group-title a:hover { text-decoration: underline; }

.search-item {
    display: block;
    padding: 8px 10px;
    border-radius: 9px;
    color: var(--text);
    text-decoration: none;
}
.search-item:hover, .search-item.active { background: var(--primary-soft); }
.search-item-title { display: block; font-weight: 600; font-size: 0.92rem; }
.search-item-sub {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-empty { padding: 16px; color: var(--muted); font-size: 0.9rem; }

@media (max-width: 800px) {
    .search-wrap { flex: 1; min-width: 130px; }
    .search-wrap .search-box { width: 100%; }
    .search-results { right: auto; left: 0; }
}

.brand-icon.has-logo {
    border-radius: 50%;
    background-repeat: no-repeat;
    background-color: #fff !important;
}

.powered-by {
    margin-top: auto;
    padding: 14px 12px 0;
    text-align: center;
}
.powered-by span {
    display: block;
    margin-bottom: 6px;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--sidebar-muted);
}
.powered-by img { width: 130px; max-width: 100%; height: auto; border-radius: 4px; }
@media print { .powered-by { display: none; } }
.sidebar-bottom ~ .powered-by { margin-top: 8px; }

.student-avatar.has-photo {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: transparent;
}


/* Tablet: keep the top bar inside the viewport */
@media (min-width: 761px) and (max-width: 1000px) {
    .topbar-left { flex: 0 0 auto; }
    .topbar-right { min-width: 0; flex: 1 1 auto; justify-content: flex-end; gap: 12px; }
    .search-wrap { flex: 0 1 190px; min-width: 100px; }
    .search-box { width: 100%; }
    .profile { flex: 0 0 auto; }
}

/* Short laptop screens: tighten the sidebar so the footer is reachable */
@media (min-width: 761px) and (max-height: 860px) {
    .nav-link { min-height: 38px; padding-top: 8px; padding-bottom: 8px; }
    .sidebar { padding-top: 18px; }
}

/* Never print the "saved" toast on receipts, statements or reports */
@media print {
    .toast { display: none !important; }
}

/* ===== Dashboard on phones: compact top bar + 2-column stat cards ===== */
@media (max-width: 760px) {
    .topbar { padding: 12px 14px; gap: 10px 12px; min-height: 0; }
    .topbar-left { flex: 1 1 calc(100% - 60px); min-width: 0; gap: 12px; }
    .topbar-left > div:last-child { min-width: 0; }
    .breadcrumb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
    .topbar h1 { font-size: 20px; }
    /* avatar joins the first row; search + buttons share the second row */
    .topbar-right { display: contents; }
    .profile { order: 2; margin-left: 0; }
    .profile-details { display: none; }
    .search-wrap { order: 3; flex: 1 1 100px; min-width: 0; }
    .search-box { width: 100%; min-width: 0; height: 40px; }
    .notification-button { display: none; }
    .topbar-right > span { order: 4; flex: 0 0 auto; gap: 6px !important; }
    .topbar .secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 12px; font-size: 12px; }
    .welcome-row h2 { font-size: 20px; line-height: 1.3; }
}
@media (max-width: 480px) {
    .stat-card { padding: 14px 13px; }
    .stat-top { font-size: 11px; gap: 6px; }
    .stat-icon { width: 32px; height: 32px; font-size: 16px; border-radius: 9px; }
    .stat-number { font-size: 22px; }
}
/* keep two stat cards per row on normal phones (only the very smallest get one) */
@media (min-width: 340px) and (max-width: 390px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ===== Footer credit ===== */
.page-footer { font-size: 12px; align-items: center; flex-wrap: wrap; }
.page-footer a { color: var(--primary-dark, #2443b0); font-weight: 700; text-decoration: none; }
.page-footer a:hover { text-decoration: underline; }
@media print { .page-footer { display: none !important; } }

/* ===== Phone menu overlay + close button ===== */
.sidebar-overlay, .sidebar-close { display: none; }
@media (max-width: 760px) {
    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 90;
        background: rgba(15, 23, 42, .5);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s;
    }
    .sidebar-overlay.show { opacity: 1; pointer-events: auto; }
    .sidebar-close {
        display: grid;
        place-items: center;
        position: absolute;
        top: 14px;
        right: 12px;
        width: 38px;
        height: 38px;
        border: 1px solid rgba(255, 255, 255, .25);
        border-radius: 10px;
        background: rgba(255, 255, 255, .08);
        color: #fff;
        font-size: 16px;
        cursor: pointer;
    }
    .sidebar-close:hover { background: rgba(255, 255, 255, .18); }
    body.nav-open { overflow: hidden; }
}

/* Hide inert bell (it has no notifications behind it yet) */
.notification-button { display: none !important; }

/* Clickable dashboard boxes */
.stat-card.is-link, .panel.is-link { cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.stat-card.is-link:hover, .panel.is-link:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(31, 59, 179, .14); }
.stat-card.is-link:focus-visible, .panel.is-link:focus-visible { outline: 2px solid #2f54d4; outline-offset: 2px; }
