:root {
    /* Same palette as dcms — calm teal */
    --rcms-primary: #0f7a72;
    --rcms-primary-dark: #0b5f59;
    --rcms-primary-light: #5cb3ac;
    --rcms-tint: #eaf6f4;
    --rcms-ink: #24312f;
    --rcms-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    /* Links in the theme color instead of Bootstrap blue. */
    --bs-link-color: #0f7a72;
    --bs-link-color-rgb: 15, 122, 114;
    --bs-link-hover-color: #0b5f59;
    --bs-link-hover-color-rgb: 11, 95, 89;
}

body {
    background-color: #f4f6f9;
    font-family: var(--rcms-font);
    color: var(--rcms-ink);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6,
.navbar-brand, .stat-value, .card-title, .btn {
    letter-spacing: -0.01em;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--rcms-ink);
}

.btn-rcms {
    background-color: var(--rcms-primary);
    border-color: var(--rcms-primary);
    color: #fff;
}

.btn-rcms:hover, .btn-rcms:focus {
    background-color: var(--rcms-primary-dark);
    border-color: var(--rcms-primary-dark);
    color: #fff;
}

.text-rcms { color: var(--rcms-primary) !important; }

/* ---------- Login screen ---------- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, var(--rcms-primary) 0%, var(--rcms-primary-dark) 100%);
}

.login-card {
    width: 100%;
    max-width: 380px;
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.25);
}

/* ---------- Top navbar ---------- */
.rcms-navbar {
    background-color: var(--rcms-primary);
}

.rcms-navbar .navbar-brand {
    font-weight: 700;
    color: #fff !important;
    letter-spacing: 0.02em;
}

.rcms-navbar .navbar-brand small {
    display: block;
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--rcms-tint);
    letter-spacing: 0.08em;
}

/* ---------- Sidebar ---------- */
.rcms-sidebar {
    width: 250px;
    min-height: calc(100vh - 56px);
    background-color: #fff;
    border-right: 1px solid #e3e6ea;
    flex-shrink: 0;
    position: relative;
    transition: width 0.15s ease;
}

.rcms-sidebar .nav-link {
    color: #33404d;
    border-radius: 0.375rem;
    padding: 0.5rem 0.9rem;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rcms-sidebar .nav-link.active {
    background-color: var(--rcms-primary);
    color: #fff !important;
}

.rcms-sidebar .nav-link:hover:not(.active) {
    background-color: var(--rcms-tint);
}

.rcms-sidebar .sidebar-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9aa5b1;
    margin: 0.9rem 0.9rem 0.3rem;
    white-space: nowrap;
    overflow: hidden;
}

/* Small tab pinned to the sidebar's right edge, half-overlapping the content. */
.sidebar-collapse-btn {
    position: absolute;
    top: 1.5rem;
    right: -14px;
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e3e6ea;
    border-radius: 50%;
    background: #fff;
    color: #6c757d;
    box-shadow: 0 0.125rem 0.35rem rgba(36, 49, 47, 0.15);
    z-index: 5;
}

.sidebar-collapse-btn:hover {
    background-color: var(--rcms-tint);
    color: var(--rcms-ink);
}

.rcms-sidebar.collapsed {
    width: 64px;
}

.rcms-sidebar.collapsed .nav-label,
.rcms-sidebar.collapsed .sidebar-section {
    display: none;
}

.rcms-sidebar.collapsed .nav-link {
    text-align: center;
    padding: 0.55rem 0;
}

.rcms-sidebar.collapsed .nav-link i {
    margin-right: 0 !important;
    font-size: 1.05rem;
}

.rcms-content {
    flex-grow: 1;
    padding: 1rem 1.75rem 1.75rem;
    min-width: 0; /* let a collapsed sidebar actually free up space */
}

@media (max-width: 767.98px) {
    .rcms-sidebar { width: 64px; }
    .rcms-sidebar .nav-label, .rcms-sidebar .sidebar-section { display: none; }
    .rcms-sidebar .nav-link { text-align: center; padding: 0.55rem 0; }
    .rcms-sidebar .nav-link i { margin-right: 0 !important; }
    .sidebar-collapse-btn { display: none; }
    .rcms-content { padding: 1rem; }
}

/* ---------- Reusable bits ---------- */
.stat-card {
    border: none;
    border-radius: 0.6rem;
    box-shadow: 0 0.125rem 0.5rem rgba(36, 49, 47, 0.08);
    height: 100%;
}

.stat-card .stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Dashboard A/R row: eight tiles across, so smaller figures. */
.stat-card-sm .stat-value {
    font-size: 1.15rem;
    white-space: nowrap;
}

/* Collection summary cards (collections/index.php): total + one per payment type. */
.collect-card {
    background: #f8faf9;
    border: 1px solid #e3e6ea;
    border-radius: 0.6rem;
    padding: 0.75rem 1rem;
    height: 100%;
}

.collect-card-total {
    background: var(--rcms-tint);
    border-color: var(--rcms-primary-light);
}

.collect-card-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
}

.collect-card-total .collect-card-label,
.collect-card-total .collect-card-value {
    color: var(--rcms-primary-dark);
}

.collect-card-value {
    font-size: 1.35rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.collect-card-meta {
    font-size: 0.78rem;
    color: #6c757d;
}

.collect-card-bar {
    height: 4px;
    background: #e3e6ea;
    border-radius: 2px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.collect-card-bar span {
    display: block;
    height: 100%;
    background: var(--rcms-primary);
}

.table-responsive-card {
    background: #fff;
    border-radius: 0.6rem;
    box-shadow: 0 0.125rem 0.5rem rgba(36, 49, 47, 0.06);
    padding: 1.25rem;
}

.table td.num, .table th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Page tabs (e.g. the student profile) in the theme color. */
.rcms-tabs .nav-link {
    color: #6c757d;
    font-weight: 500;
}

.rcms-tabs .nav-link:hover {
    color: var(--rcms-ink);
}

.rcms-tabs .nav-link.active {
    color: var(--rcms-primary);
    background-color: #fff;
}

.section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6c757d;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

dl.detail-list dt {
    font-weight: 500;
    color: #6c757d;
    font-size: 0.85rem;
}

dl.detail-list dd {
    margin-bottom: 0.6rem;
}

/* ---------- Student profile (same layout as the HRIS employee profile) ---------- */
.profile-photo-placeholder {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background-color: var(--rcms-tint);
    color: var(--rcms-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
}

/* Uploaded student picture (includes/student_photos.php); same footprint as the placeholder */
.profile-photo {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.profile-photo-lg { width: 120px; height: 120px; }
.qr-code svg { display: block; margin: 0 auto; }

/* Student profile card (students/view.php): ID-style header, QR panel, facts. */
.profile-card { padding: 0; overflow: hidden; }
.profile-card-band { height: 72px; background: linear-gradient(135deg, var(--rcms-primary), var(--rcms-primary-light)); }
.profile-card-head { text-align: center; padding: 0 1.25rem 1rem; }
.profile-card-photo { display: flex; justify-content: center; margin-top: -60px; margin-bottom: 0.6rem; }
.profile-card-photo .profile-photo, .profile-card-photo .profile-photo-placeholder { border: 4px solid #fff; box-shadow: 0 0.25rem 0.75rem rgba(36, 49, 47, 0.15); }
.profile-card-name { font-weight: 700; margin-bottom: 0.15rem; line-height: 1.25; }
.profile-qr { display: flex; align-items: center; gap: 0.9rem; margin: 0 1.25rem 1rem; padding: 0.75rem; border: 1px solid #e3e9e8; border-radius: 0.5rem; background: #f8fbfa; }
.profile-qr-code { flex-shrink: 0; padding: 4px; background: #fff; border: 1px solid #e3e9e8; border-radius: 0.35rem; }
.profile-qr-label { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: #6c757d; }
.min-w-0 { min-width: 0; }
.profile-facts { display: grid; grid-template-columns: auto 1fr; gap: 0.45rem 1rem; margin: 0; padding: 1rem 1.25rem 1.25rem; border-top: 1px solid #edf1f0; font-size: 0.875rem; }
.profile-facts dt { font-weight: 500; color: #6c757d; }
.profile-facts dd { margin: 0; text-align: right; font-weight: 500; overflow-wrap: anywhere; }

.timeline {
    border-left: 2px solid var(--rcms-primary-light);
    margin-left: 0.5rem;
    padding-left: 1.25rem;
}

.timeline-item {
    position: relative;
    padding-bottom: 1.25rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.56rem;
    top: 0.3rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--rcms-primary);
}

tr.row-muted td {
    color: #9aa5b1;
    text-decoration: line-through;
}

/* ---------- Password field with an inline show/hide toggle ---------- */
.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 2.75rem;
}

.password-toggle-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 2.75rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #6c757d;
    padding: 0;
}

.password-toggle-btn:hover,
.password-toggle-btn:focus {
    color: var(--rcms-ink);
    outline: none;
    box-shadow: none;
}

/* ---------- Printable documents (receipts, statements, reports) ----------
   A document is styled for paper under .print-view: set on the print copy
   (?print=1, see printLink()) and, by script.js, while any page is printing. */

/* Letterhead (companyLetterhead() in includes/functions.php). printHeader()'s
   copy and the report ending (printFooter()) only show on paper. */
.print-letterhead, .print-end { display: none; }
.lh-top { display: flex; align-items: center; gap: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--rcms-primary); color: #000; }
.lh-logo { height: 16mm; max-width: 36mm; object-fit: contain; }
.lh-company { font-size: 16pt; font-weight: 800; line-height: 1.15; color: var(--rcms-primary-dark); letter-spacing: 0.01em; }
.lh-contact { font-size: 8.5pt; line-height: 1.35; color: #444; }
.lh-title { margin-top: 10px; text-align: center; font-size: 13pt; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: #000; }
.lh-subtitle { text-align: center; font-size: 9pt; color: #444; }

/* Signature lines (signatureBlock()) and the end-of-report marker. */
.print-signatures { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8mm 10mm; margin-top: 12mm; break-inside: avoid; color: #000; }
.print-signatures .sig { flex: 0 1 58mm; }
.print-signatures .sig-label { font-size: 8.5pt; color: #444; }
.print-signatures .sig-line { margin-top: 9mm; min-height: 1.5em; border-bottom: 1px solid #000; text-align: center; font-size: 9pt; font-weight: 700; text-transform: uppercase; }
.print-signatures .sig-caption { margin-top: 2px; text-align: center; font-size: 7pt; color: #666; }
.print-endnote { margin-top: 4mm; text-align: center; font-size: 7.5pt; letter-spacing: 0.15em; color: #555; }

/* The document itself: plain ruled tables in black on white. */
.print-view .print-letterhead { display: block; margin-bottom: 12px; }
.print-view .print-end { display: block; break-inside: avoid; }
.print-view .rcms-content { color: #000; font-size: 9pt; }
.print-view .table-responsive-card { background: transparent; box-shadow: none; border-radius: 0; padding: 0; margin-bottom: 12px !important; }
.print-view .table-responsive { overflow: visible; }
.print-view .table { --bs-table-striped-bg: transparent; --bs-table-bg: transparent; --bs-table-color: #000; font-size: 8.5pt; margin-bottom: 0; }
.print-view .table > :not(caption) > * > * { padding: 0.22rem 0.4rem; border-bottom-color: #d0d0d0; }
.print-view .table thead { --bs-table-bg: var(--rcms-tint); }
.print-view .table thead th { border-top: 1.5px solid #000; border-bottom: 1.5px solid #000; font-size: 7.5pt; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; vertical-align: bottom; }
.print-view .table tfoot { display: table-row-group; } /* totals once, at the end */
.print-view .table tfoot td { border-top: 1.5px solid #000; border-bottom: 3px double #000; font-weight: 700; }
.print-view .table tr { break-inside: avoid; }
.print-view tr.row-muted td { color: #777; }
.print-view .section-title { color: #000; font-size: 8.5pt; font-weight: 700; border-bottom: 1px solid #000; padding-bottom: 2px; margin-bottom: 6px; }
.print-view .text-muted { color: #555 !important; }
.print-view .text-danger, .print-view .text-success { color: #000 !important; }
.print-view a { color: inherit; text-decoration: none; }
.print-view .badge { border: 1px solid #777 !important; background: none !important; color: #000 !important; font-weight: 600; }

/* Summary tiles print as one ruled row of boxes. */
.print-view .report-summary { display: flex; flex-wrap: nowrap; gap: 0; margin: 0 0 12px !important; border: 1px solid #000; }
.print-view .report-summary > * { flex: 1 1 0; width: auto; padding: 0; margin: 0; }
.print-view .report-summary > * + * { border-left: 1px solid #000; }
.print-view .report-summary .stat-card { box-shadow: none; border-radius: 0; background: transparent; }
.print-view .report-summary .card-body { padding: 4px 8px; }
.print-view .report-summary .text-muted.small { font-size: 7pt; letter-spacing: 0.04em; text-transform: uppercase; }
.print-view .report-summary .stat-value { font-size: 11pt; }

/* Acknowledgement of payment (collections/view.php): the same on screen and paper. */
.receipt-doc { position: relative; max-width: 190mm; overflow: hidden; background: #fff; color: #000; border-radius: 0.6rem; box-shadow: 0 0.125rem 0.5rem rgba(36, 49, 47, 0.06); padding: 10mm 12mm; }
.receipt-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8mm; padding-bottom: 8px; border-bottom: 2px solid var(--rcms-primary); }
.receipt-head .lh-top { border-bottom: 0; padding-bottom: 0; }
.receipt-meta { flex-shrink: 0; text-align: right; }
.receipt-kind { font-size: 12pt; font-weight: 800; line-height: 1.2; letter-spacing: 0.08em; text-transform: uppercase; color: var(--rcms-primary-dark); }
.receipt-meta table { margin: 6px 0 0 auto; font-size: 9pt; }
.receipt-meta th { padding: 1px 8px 1px 0; font-weight: 500; color: #555; text-align: right; }
.receipt-meta td { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.receipt-text { margin: 14px 0 10px; font-size: 10pt; line-height: 2; }
.receipt-text .fill { border-bottom: 1px solid #000; font-weight: 700; padding: 0 4px; }
.receipt-amount { display: flex; align-items: stretch; margin: 10px 0 14px; border: 1.5px solid #000; }
.receipt-amount .label { display: flex; align-items: center; padding: 6px 12px; background: var(--rcms-tint); border-right: 1.5px solid #000; font-size: 8pt; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.receipt-amount .words { flex: 1; display: flex; align-items: center; padding: 6px 12px; font-size: 9.5pt; font-style: italic; }
.receipt-amount .figure { display: flex; align-items: center; padding: 6px 12px; border-left: 1.5px solid #000; font-size: 14pt; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.receipt-details { display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; margin-bottom: 12px; font-size: 9pt; }
.receipt-details dt { font-weight: 500; color: #555; }
.receipt-details dd { margin: 0; font-weight: 600; }
.receipt-doc .table { font-size: 9pt; }
.receipt-doc .print-signatures { margin-top: 10mm; }
.receipt-foot { margin-top: 8mm; padding-top: 3mm; border-top: 1px dashed #999; text-align: center; font-size: 8pt; color: #555; }
.receipt-stamp { position: absolute; top: 48%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg); padding: 2mm 8mm; border: 5px solid rgba(220, 53, 69, 0.35); border-radius: 3mm; color: rgba(220, 53, 69, 0.35); font-size: 44pt; font-weight: 800; letter-spacing: 0.15em; pointer-events: none; }
.print-view .receipt-doc { max-width: none; border-radius: 0; box-shadow: none; padding: 0; }

/* Print copy on screen: the document as a sheet of paper, A4 portrait or landscape. */
@media screen {
    body.print-view { background: #d5dae0; }
    .print-view .rcms-navbar, .print-view .rcms-sidebar, .print-view .no-print:not(.print-toolbar), .print-view .alert { display: none !important; }
    .print-view .rcms-content { flex-grow: 0; width: 210mm; max-width: calc(100% - 2rem); min-height: 297mm; margin: 1.5rem auto; padding: 12mm 10mm; background: #fff; box-shadow: 0 0.25rem 1.5rem rgba(0, 0, 0, 0.18); }
    .print-view:has(.print-letterhead.is-landscape) .rcms-content { width: 297mm; min-height: 210mm; }
    .print-toolbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; background: #fff; border-bottom: 1px solid #c9ced4; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06); }
    .print-toolbar .print-toolbar-title { margin-right: auto; font-weight: 600; color: var(--rcms-ink); }
    /* Inside the print preview popup, whose footer has the Print/Close buttons. */
    .in-popup .print-toolbar { display: none !important; }
    .in-popup .print-view .rcms-content { margin: 1rem auto; }
}

/* Print preview popup (#rcmsPrintModal in includes/footer.php). */
.print-modal .modal-xl { --bs-modal-width: min(1280px, 96vw); } /* room for an A4 landscape sheet */
.print-modal .modal-body { position: relative; background: #d5dae0; }
.print-modal-frame { display: block; width: 100%; height: 78vh; border: 0; }
@media (max-width: 991.98px) { .print-modal-frame { height: 100%; } } /* modal-fullscreen-lg-down */
.print-modal-loading { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; }
.print-modal.is-loading .print-modal-loading { display: flex; }
.print-modal.is-loading .print-modal-frame { visibility: hidden; }

/* Document viewer popup (#rcmsDocViewer in footer.php). */
.doc-viewer .modal-xl { --bs-modal-width: min(1280px, 96vw); }
.doc-viewer .modal-header { flex-wrap: wrap; }
.doc-viewer .modal-body { position: relative; background: #2b2f33; height: 80vh; overflow: hidden; }
@media (max-width: 991.98px) { .doc-viewer .modal-body { height: auto; } }
.doc-viewer-zoom { min-width: 4.2em; }
.doc-viewer-stage { position: absolute; inset: 0; overflow: hidden; cursor: grab; touch-action: none; user-select: none; }
.doc-viewer-stage.is-panning { cursor: grabbing; }
.doc-viewer-img { position: absolute; left: 50%; top: 50%; max-width: none; transform-origin: center; }
.doc-viewer-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.doc-viewer-loading { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; z-index: 1; }
.doc-viewer.is-loading .doc-viewer-loading { display: flex; }
.doc-viewer.is-loading .doc-viewer-img { visibility: hidden; }
.doc-viewer.kind-pdf .doc-viewer-stage, .doc-viewer.kind-pdf .doc-viewer-image-tools,
.doc-viewer.kind-image .doc-viewer-frame { display: none; }

@media print {
    .rcms-navbar, .rcms-sidebar, .no-print, .alert { display: none !important; }
    body { background: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .rcms-content { padding: 0; }
    .print-letterhead, .print-end { display: block; }
    .table-responsive-card { box-shadow: none; padding: 0; margin-bottom: 1rem !important; }
    .table-responsive { overflow: visible; }
}

/* Masonry-style two-column stack: each card sits right under the one above it,
   so a short list doesn't leave a gap beside a long one (personal_preference/lists.php). */
.card-columns-2 { column-gap: 1rem; }
.card-columns-2 .card-column-item { break-inside: avoid; margin-bottom: 1rem; display: inline-block; width: 100%; }
@media (min-width: 992px) { .card-columns-2 { column-count: 2; } }

/* Header working filter (review program + season) on the dark navbar. */
.navbar-context .form-select {
    width: auto;
    max-width: 190px;
    background-color: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}
.navbar-context .form-select:focus { border-color: #fff; box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25); }
.navbar-context .form-select option, .navbar-context .form-select optgroup { color: #212529; background-color: #fff; }
