:root {
    --ink: #172a2a;
    --muted: #647777;
    --teal: #087c72;
    --teal-dark: #075f59;
    --line: #e3eae8;
    --paper: #ffffff;
    --canvas: #f3f7f6;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font: 15px/1.5 "Segoe UI", Arial, sans-serif;
}
a { color: var(--teal-dark); }
.topbar {
    min-height: 70px;
    padding: 12px max(24px, calc((100% - 1220px) / 2));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    color: #fff;
    background: #123b39;
}
.brand-link, .top-actions, .top-actions form {
    display: flex;
    align-items: center;
}
.brand-link { gap: 12px; color: #fff; text-decoration: none; }
.brand-link strong, .brand-link small { display: block; }
.brand-link small { color: #b7d5d0; font-size: 11px; letter-spacing: .08em; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid #82c5b9;
    border-radius: 50%;
    color: #a4d5ca;
    font: 700 22px Georgia, serif;
}
.top-actions { gap: 22px; }
.top-actions a:not(.button), .link-button { color: #edf8f5; text-decoration: none; }
.top-actions form { margin: 0; }
.link-button, .danger-link {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    cursor: pointer;
}
.page { width: min(1220px, calc(100% - 40px)); min-height: calc(100vh - 130px); margin: 34px auto; }
.app-footer { padding: 18px 20px; color: var(--muted); text-align: center; font-size: 12px; }
h1 { margin: 4px 0 5px; font-size: clamp(26px, 3vw, 34px); line-height: 1.2; letter-spacing: -.03em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { color: var(--teal); font-size: 11px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.page-heading, .print-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 24px; }
.page-heading p, .print-toolbar p { margin: 0; }
.heading-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.record-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.record-pill { display: inline-flex; min-height: 30px; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid #d5e5e1; border-radius: 999px; color: #536a67; background: #fff; font-size: 12px; }
.record-pill strong { color: var(--teal-dark); font-size: 14px; }
.button {
    display: inline-flex;
    min-height: 42px;
    padding: 9px 16px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--teal);
    border-radius: 7px;
    color: #fff;
    background: var(--teal);
    font: 650 14px "Segoe UI", Arial, sans-serif;
    text-decoration: none;
    cursor: pointer;
}
.button:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.button-secondary { color: var(--teal-dark); background: #eff8f6; border-color: #b9dcd5; }
.button-secondary:hover { color: #fff; }
.button-quiet { color: var(--ink); background: #fff; border-color: var(--line); }
.button-small { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.filter-panel, .table-wrap, .form-panel, .auth-panel {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
    box-shadow: 0 5px 18px rgba(20, 54, 51, .035);
}
.filter-panel { padding: 16px; margin-bottom: 14px; }
.filter-form { display: flex; align-items: end; gap: 12px; }
.filter-form label, .stack-form label, .student-form label { display: grid; gap: 6px; color: #415957; font-size: 13px; font-weight: 650; }
.filter-form .search-field { flex: 1; }
input, select {
    width: 100%;
    min-height: 40px;
    padding: 8px 11px;
    border: 1px solid #cedbd8;
    border-radius: 6px;
    color: var(--ink);
    background: #fff;
    font: 14px "Segoe UI", Arial, sans-serif;
}
input:focus, select:focus { outline: 3px solid rgba(8, 124, 114, .14); border-color: var(--teal); }
.plain-link { padding: 9px 2px; white-space: nowrap; }
.table-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin: 15px 2px; }
.select-all { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
input[type="checkbox"] { width: 16px; min-height: 16px; margin: 0; accent-color: var(--teal); }
.table-wrap { overflow-x: auto; }
.student-thumb { display: block; width: 36px; height: 42px; border-radius: 4px; background: #087c7c; object-fit: contain; }
.student-thumb-empty { display: grid; place-items: center; color: #dcebe6; font-size: 18px; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 12px 14px; border-bottom: 1px solid #edf1f0; vertical-align: middle; white-space: nowrap; }
th { color: #667a78; background: #f8faf9; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
td { font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.missing-photo-row > td { background: #fff7e8; }
tbody tr.missing-photo-row > td:first-child { box-shadow: inset 3px 0 #d49a32; }
.row-actions { display: flex; align-items: center; gap: 12px; }
.row-actions form { margin: 0; }
.whatsapp-link { color: #167746; font-weight: 650; }
.button-whatsapp { border-color: #16834a; background: #16834a; }
.button-whatsapp:hover { border-color: #116b3c; background: #116b3c; }
.button:disabled { border-color: #aab9b6; color: #f7f9f8; background: #9aa9a6; cursor: not-allowed; }
.student-message-preview { margin: 24px 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; background: #f8faf9; }
.student-message-preview > div { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 5px 0; }
.student-message-preview dt { color: var(--muted); font-size: 13px; font-weight: 650; }
.student-message-preview dd { margin: 0; font-weight: 650; }
.whatsapp-batch-preview { max-height: 260px; overflow: auto; margin: 18px 0; padding: 8px 16px 8px 34px; border: 1px solid var(--line); border-radius: 8px; background: #f8faf9; }
.whatsapp-batch-preview li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid #e9efed; }
.whatsapp-batch-preview li:last-child { border-bottom: 0; }
.batch-student-meta { display: flex; flex-direction: column; }
.whatsapp-batch-preview .batch-student-meta span { color: var(--muted); font-size: 11px; }
.whatsapp-batch-preview li span { color: var(--muted); font-size: 12px; }
.whatsapp-confirm { display: flex !important; grid-template-columns: auto 1fr !important; align-items: start; gap: 9px !important; }
.whatsapp-confirm input { width: 16px; min-height: 16px; margin-top: 2px; }
.danger-link { color: #b33a37; font-size: 13px; }
.empty-state { padding: 32px; color: var(--muted); text-align: center; }
.pagination { display: flex; gap: 6px; justify-content: center; margin: 20px 0; }
.pagination a { min-width: 34px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 5px; background: #fff; text-align: center; text-decoration: none; }
.pagination .current { color: #fff; border-color: var(--teal); background: var(--teal); }
.notice { margin: 0 0 18px; padding: 12px 15px; border: 1px solid #c5e1d7; border-radius: 8px; color: #175c45; background: #effaf4; }
.notice-error { border-color: #f0c5bf; color: #872e25; background: #fff4f1; }
.auth-panel, .form-panel { width: min(760px, 100%); margin: 45px auto; padding: clamp(22px, 5vw, 40px); }
.auth-panel { width: min(480px, 100%); }
.auth-panel > p { color: var(--muted); }
.stack-form { display: grid; gap: 16px; margin-top: 24px; }
.stack-form .button { margin-top: 4px; }
.student-form { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 25px; }
.student-form .photo-field, .student-form .form-actions { grid-column: 1 / -1; }
.required { color: #b33a37; }
.current-photo { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.current-photo img { width: 55px; height: 65px; object-fit: cover; border-radius: 5px; }
.form-actions { display: flex; gap: 10px; padding-top: 5px; }
.print-toolbar { margin-bottom: 20px; }
.toolbar-actions { display: flex; align-items: center; gap: 10px; }
.cards-grid { display: grid; grid-template-columns: repeat(2, 85.6mm); justify-content: center; align-items: start; gap: 7mm; }
.id-card {
    position: relative;
    display: flex;
    width: 85.6mm;
    height: 54mm;
    overflow: hidden;
    break-inside: avoid;
    border: .3mm solid #d5dedb;
    border-radius: 3mm;
    color: #111;
    background: #fff;
    box-shadow: 0 5px 15px rgba(16, 54, 50, .12);
    font-family: Arial, sans-serif;
}
.card-side {
    position: relative;
    display: flex;
    width: 36.5%;
    flex: 0 0 36.5%;
    flex-direction: column;
    align-items: center;
    padding: 4.3mm 4mm 2mm;
    background: #087c7c;
}
.card-side::after { position: absolute; top: 0; right: 0; width: 1.8mm; height: 100%; background: linear-gradient(to bottom, #72a995 0 65%, #b4bf89 65% 100%); content: ""; }
.portrait { width: 20mm; height: 19.5mm; flex: 0 0 auto; overflow: hidden; background: #087c7c; }
.portrait img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center; }
.portrait span { display: grid; width: 100%; height: 100%; place-items: center; color: var(--teal-dark); font-size: 25pt; font-weight: 700; }
.card-seal { display: block; width: 25mm; height: 25mm; flex: 0 0 auto; margin-top: 3.3mm; object-fit: contain; }
.card-content { position: relative; display: flex; min-width: 0; flex: 1; flex-direction: column; padding: 1.8mm 2mm 1.5mm; }
.card-brand { display: flex; min-height: 10mm; flex-direction: column; align-items: flex-end; justify-content: center; border-bottom: .25mm solid #28847e; padding: 0 0 1mm; line-height: 1; }
.college-site { color: #b51e27; font-size: 7.2pt; font-weight: 750; }
.brand-lockup { display: flex; align-items: baseline; gap: 1.2mm; margin-top: .6mm; color: #111; white-space: nowrap; }
.card-brand i { color: #39745e; font: italic bold 15.5pt Georgia, "Times New Roman", serif; }
.card-brand strong { font: 700 13.5pt Georgia, "Times New Roman", serif; letter-spacing: -.35px; }
.card-brand b { display: inline-block; width: 8mm; height: 2.8mm; margin-left: .4mm; vertical-align: 1.3mm; background: linear-gradient(90deg, #087c7c 58%, #111 58% 69%, #9da98b 69%); }
.card-details { display: grid; gap: .2mm; padding: .6mm 0 1mm; border-bottom: .25mm solid #28847e; }
.card-details > div { display: grid; grid-template-columns: 31% 69%; align-items: baseline; min-height: 3.35mm; font-size: 8pt; line-height: 1.06; }
.card-details span { color: #111; font-weight: 750; white-space: nowrap; }
.card-details strong { overflow: hidden; font-size: 8.3pt; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.card-details .valid-row { min-height: 3.8mm; margin-top: .25mm; }
.card-details .valid-row span { color: #623b15; }
.valid-row strong { color: #b51e27; font-size: 8.8pt; }
.card-campus { display: flex; margin-top: auto; flex-direction: column; align-items: center; text-align: center; line-height: 1.02; }
.card-campus strong { font: 900 15pt "Arial Black", Arial, sans-serif; letter-spacing: .2mm; white-space: nowrap; }
.card-campus span { margin-top: .4mm; font-size: 8.5pt; font-weight: 750; }
.card-campus b { margin-top: .6mm; font-size: 7.7pt; font-weight: 750; }
.student-roster { page: roster; }
.roster-table thead { display: table-header-group; }
.roster-table tr { break-inside: avoid; }

@media (max-width: 760px) {
    .topbar { padding: 12px 16px; }
    .top-actions { gap: 10px; }
    .top-actions > a:first-child, .link-button { font-size: 12px; }
    .page { width: calc(100% - 24px); margin: 22px auto; }
    .page-heading, .print-toolbar { align-items: flex-start; }
    .filter-form { align-items: stretch; flex-wrap: wrap; }
    .filter-form .search-field { flex-basis: 100%; }
    .student-form { grid-template-columns: 1fr; }
    .student-form .photo-field, .student-form .form-actions { grid-column: auto; }
    .cards-grid { grid-template-columns: 85.6mm; }
}
@media print {
    @page { size: A4 portrait; margin: 10mm; }
    @page roster { size: A4 landscape; margin: 10mm; }
    body { background: #fff; }
    .topbar, .app-footer, .print-toolbar, .notice, .roster-filter, .no-print { display: none !important; }
    .page { width: auto; min-height: 0; margin: 0; }
    .cards-grid { grid-template-columns: repeat(2, 85.6mm); gap: 6mm 7mm; justify-content: center; }
    .id-card { box-shadow: none; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
    .roster-table { overflow: visible; border: 0; box-shadow: none; }
    .roster-table th, .roster-table td { padding: 6px 8px; border: 1px solid #d5dedb; font-size: 9pt; white-space: normal; }
    .roster-table th { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
