.fees-stats { grid-template-columns: repeat(4, 1fr); }
.fees-stats .student-stat:nth-child(2) strong { color: var(--success); }
.fees-stats .student-stat:nth-child(3) strong { color: #d64545; }

.fees-history { margin-top: 20px; }

.fee-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 600;
}
.fee-status.paid    { background: #e3f6ee; color: var(--success); }
.fee-status.partial { background: #fff4dc; color: #c98a0a; }
.fee-status.unpaid  { background: #fdeaea; color: #d64545; }

button.inline-link {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    cursor: pointer;
}
button.inline-link:disabled { color: var(--muted); cursor: not-allowed; }

.fee-dialog {
    width: min(560px, calc(100% - 32px));
    padding: 24px;
    border: 0;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 20px 60px rgba(23, 35, 62, 0.25);
}
.fee-dialog::backdrop { background: rgba(23, 35, 62, 0.45); }
.fee-dialog h2 { margin: 0 0 4px; }

.fee-breakdown {
    margin: 14px 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--background);
    font-size: 0.9rem;
}
.fee-breakdown .row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
}
.fee-breakdown .row.total {
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-weight: 700;
}

.fee-error { margin: 10px 0 0; color: #d64545; font-size: 0.9rem; }

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

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

.receipt-sheet { display: none; }
@media print {
    .printing-receipt .student-page > *:not(main),
    .printing-receipt main > *:not(#receiptSheet) { display: none !important; }
    .printing-receipt .receipt-sheet { display: block; max-width: 560px; margin: 24px auto; padding: 24px; border: 2px solid #222; font-family: inherit; }
    .receipt-sheet h2, .receipt-sheet h3 { text-align: center; margin: 4px 0; }
    .receipt-sheet .rs-contact { text-align: center; font-size: 0.8rem; margin: 0 0 8px; }
    .receipt-sheet dl { margin: 16px 0; }
    .receipt-sheet dl div { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dotted #999; }
    .receipt-sheet dt { font-weight: 400; }
    .receipt-sheet dd { margin: 0; font-weight: 600; }
    .rs-sign { margin-top: 48px; text-align: right; }
    .rs-sign span { display: inline-block; width: 160px; border-top: 1px solid #222; margin-right: 8px; }
}

.pending-sheet { display: none; }
@media print {
    .printing-pending .student-page > *:not(main),
    .printing-pending main > *:not(#pendingSheet) { display: none !important; }
    .printing-pending .pending-sheet { display: block; }
    .pending-sheet h2, .pending-sheet h3 { text-align: center; margin: 4px 0; }
    .pending-sheet table { width: 100%; border-collapse: collapse; font-size: 10pt; }
    .pending-sheet th, .pending-sheet td { border: 1px solid #222; padding: 4px 6px; text-align: left; }
    .pending-sheet .num { text-align: right; }
    .pending-sheet tfoot td { font-weight: 700; }
    .pending-sheet thead { display: table-header-group; }
    .pending-sheet tr { break-inside: avoid; }
}

.rs-banner { display: block; width: 100%; height: auto; margin-bottom: 8px; }
.rs-banner[hidden] { display: none; }
@media print { .rs-banner { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

.pay-print-row { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; }

@media print {
    .rs-sub { margin: 14px 0 4px; font-size: 0.95rem; }
    .rs-history { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
    .rs-history th, .rs-history td { border: 1px solid #222; padding: 4px 8px; text-align: left; }
    .rs-history .num { text-align: right; }
    .rs-history tfoot td { font-weight: 700; }
    .rs-fees td:first-child { width: 70%; }
    .rs-fees .rs-total td { font-weight: 700; }
    .rs-fees .rs-transport td { font-style: italic; }
    .rs-history .rs-current td { background: #f1f1f1; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.statement-sheet { display: none; }
@media print {
    .printing-statement .student-page > *:not(main),
    .printing-statement main > *:not(#statementSheet) { display: none !important; }
    .printing-statement .statement-sheet { display: block; max-width: 720px; margin: 16px auto; padding: 20px; border: 2px solid #222; }
    .statement-sheet h2, .statement-sheet h3 { text-align: center; margin: 4px 0; }
    .st-info { margin: 12px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 24px; }
    .st-info div { display: flex; justify-content: space-between; border-bottom: 1px dotted #999; padding: 3px 0; }
    .st-info dt { font-weight: 400; }
    .st-info dd { margin: 0; font-weight: 600; }
    .statement-sheet .st-total td { font-weight: 700; }
}

.remind-dialog { width: min(900px, 96vw); }
.remind-table th, .remind-table td { padding: 8px 10px; }
.remind-template { margin-top: 12px; display: block; }
.remind-template textarea { width: 100%; font: inherit; padding: 8px; border: 1px solid var(--border); border-radius: 8px; resize: vertical; }
.remind-table { max-height: 320px; overflow: auto; margin-top: 14px; }
.remind-actions { white-space: nowrap; }
.remind-actions .secondary-button { padding: 4px 10px; font-size: 0.8rem; margin-right: 4px; text-decoration: none; display: inline-block; }

.remind-search { margin-top: 14px; }
.remind-search input { width: 100%; padding: 9px 12px; font: inherit; border: 1px solid var(--border); border-radius: 8px; box-sizing: border-box; }

/* Single-student statement page (opened from the student profile) */
.stmt-bar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.stmt-bar[hidden] { display: none; }
.stmt-bar h1 { margin: 0 0 6px; font-size: 27px; }
.stmt-bar .muted { margin: 0; }
.stmt-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

@media screen {
    .statement-view .student-title-row,
    .statement-view .fees-stats,
    .statement-view main > .student-panel,
    .statement-view .demo-warning { display: none; }

    .statement-view .statement-sheet { display: block; max-width: 760px; margin: 0 auto 24px; padding: 24px; background: #fff; border: 1px solid var(--border, #e8ecf3); border-radius: 14px; }
    .statement-view .statement-sheet h2,
    .statement-view .statement-sheet h3 { text-align: center; margin: 4px 0; }
    .statement-view .statement-sheet .rs-contact { text-align: center; font-size: 0.85rem; margin: 0 0 8px; }
    .statement-view .st-info { margin: 14px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 24px; }
    .statement-view .st-info div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dotted #999; padding: 4px 0; }
    .statement-view .st-info dt { font-weight: 400; color: #555; }
    .statement-view .st-info dd { margin: 0; font-weight: 600; text-align: right; }
    .statement-view .rs-sub { margin: 16px 0 6px; font-size: 0.95rem; }
    .statement-view .rs-history { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
    .statement-view .rs-history th,
    .statement-view .rs-history td { border: 1px solid #ccd2de; padding: 6px 10px; text-align: left; }
    .statement-view .rs-history .num { text-align: right; }
    .statement-view .rs-history tfoot td,
    .statement-view .st-total td { font-weight: 700; }
    .statement-view .rs-sign { margin-top: 40px; text-align: right; }
    .statement-view .rs-sign span { display: inline-block; width: 160px; border-top: 1px solid #222; margin-right: 8px; }
}

@media (max-width: 700px) {
    .statement-view .st-info { grid-template-columns: 1fr; }
    .statement-view .statement-sheet { padding: 14px; }
    .statement-view .rs-history th,
    .statement-view .rs-history td { white-space: normal; padding: 5px 4px; font-size: 0.78rem; }
    .stmt-bar h1 { font-size: 23px; }
}

.fees-history .secondary-button.danger { color: #d64545; }
.fees-history .student-toolbar .inline-link { margin-left: 12px; }

.transport-box { margin: 12px 0 4px; padding: 10px 12px; border: 1px solid #d9dfee; border-radius: 10px; background: #f7f9fe; }
.transport-box .pay-print-row { margin: 0; }
.transport-box .form-field { margin-top: 8px; max-width: 260px; }
.transport-box + .transport-box { margin-top: 8px; }

/* ===== Dialog buttons stay visible on phones and short screens ===== */
@media screen and (max-width: 700px), screen and (max-height: 700px) {
    .fee-dialog-actions {
        position: sticky;
        bottom: -24px;
        margin: 18px -24px -24px;
        padding: 14px 24px;
        background: var(--surface, #fff);
        border-top: 1px solid var(--border, #e8ecf3);
        z-index: 2;
    }
    .fee-dialog-actions button { min-height: 44px; flex: 1 1 0; }
}
