* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Arial, sans-serif; }
html { -webkit-text-size-adjust: 100%; }
body { background: #f4f6f9; color: #222; line-height: 1.4; }

/* ==== Navbar (mobile-first, collapsible) ==== */
.navbar { background: #1e3a5f; color: #fff; padding: 12px 20px; }
.navbar-top { display: flex; justify-content: space-between; align-items: center; }
.navbar h1 { font-size: 18px; }
.navbar a { color: #fff; text-decoration: none; font-size: 14px; margin-left: 14px; }
.navbar-links { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.navbar-links a { margin-left: 0; padding: 8px 4px; border-bottom: 1px solid rgba(255,255,255,.08); display: block; }
.navbar-links a:hover { color: #cfe0f5; }
.nav-toggle { display: block; background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; padding: 4px 8px; }
.navbar:not(.nav-open) .navbar-links { display: none; }

@media (min-width: 860px) {
    .navbar { padding: 14px 24px; }
    .navbar-top { display: contents; }
    .navbar { display: flex; justify-content: space-between; align-items: center; }
    .navbar h1 { font-size: 20px; }
    .navbar-links { display: flex !important; flex-direction: row; gap: 0; margin-top: 0; }
    .navbar-links a { border-bottom: none; margin-left: 16px; padding: 0; }
    .nav-toggle { display: none; }
}

.container { max-width: 1000px; margin: 20px auto; padding: 0 14px; }
.card { background: #fff; border-radius: 8px; padding: 18px; box-shadow: 0 2px 6px rgba(0,0,0,0.08); margin-bottom: 18px; }
h2 { margin-bottom: 16px; color: #1e3a5f; font-size: 19px; }

table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { padding: 10px; border-bottom: 1px solid #e0e0e0; text-align: left; font-size: 14px; }
th { background: #f0f3f7; }

input, select { width: 100%; padding: 10px; margin: 6px 0 14px; border: 1px solid #ccc; border-radius: 5px; font-size: 15px; }
button, .btn { background: #1e3a5f; color: #fff; border: none; padding: 10px 18px; border-radius: 5px; cursor: pointer; font-size: 14px; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { background: #16304f; }
.btn-danger { background: #b3261e; }
.btn-small { padding: 6px 11px; font-size: 12px; margin: 2px 2px 2px 0; }
.btn-camera { background: #315480; }
.msg-error { background: #fdecea; color: #b3261e; padding: 10px; border-radius: 5px; margin-bottom: 14px; }
.msg-success { background: #e6f4ea; color: #1e7a34; padding: 10px; border-radius: 5px; margin-bottom: 14px; }
.login-box { max-width: 420px; margin: 20px auto; }
#loginTypeSelect { font-size: 16px; font-weight: 600; border: 2px solid #1e3a5f; }
.login-type-form { margin-top: 10px; }
.tag-available { color: #1e7a34; font-weight: 600; }
.tag-unavailable { color: #b3261e; font-weight: 600; }
.search-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.search-bar input { margin: 0; flex: 1; min-width: 180px; }
code { background: #eef1f5; padding: 2px 6px; border-radius: 4px; font-size: 13px; word-break: break-all; }
.tag-admin { background: #b3261e; color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 10px; margin-left: 6px; vertical-align: middle; white-space: nowrap; }
.tag-teacher { background: #315480; color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 10px; margin-left: 6px; vertical-align: middle; white-space: nowrap; }
.scan-input-row { display: flex; gap: 8px; align-items: flex-start; }
.scan-input-row input { flex: 1; }

/* ==== Responsive tables: horizontal-scroll fallback + card view on small screens ==== */
.table-scroll { width: 100%; overflow-x: auto; }

@media (max-width: 700px) {
    .table-scroll table thead, .table-scroll table th { display: none; }
    .table-scroll table, .table-scroll table tbody, .table-scroll table tr, .table-scroll table td { display: block; width: 100%; }
    .table-scroll table tr:not(:first-child) { margin-bottom: 12px; border: 1px solid #e0e0e0; border-radius: 8px; padding: 6px 8px; background: #fafbfc; }
    .table-scroll table tr:first-child { display: none; }
    .table-scroll table td { border-bottom: none; padding: 6px 4px 6px 46%; position: relative; min-height: 20px; }
    .table-scroll table td[data-label]:before {
        content: attr(data-label);
        position: absolute; left: 8px; top: 6px; width: 42%;
        font-weight: 600; color: #1e3a5f; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .table-scroll table td:not([data-label]), .table-scroll table td[data-label=""] { padding-left: 8px; }
    .table-scroll table td:not([data-label]):before, .table-scroll table td[data-label=""]:before { content: none; }
}

/* ==== Reports module ==== */
.report-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn-active { background: #16304f; box-shadow: inset 0 0 0 2px #4d88d1; }
.report-filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-top: 16px; padding-top: 16px; border-top: 1px solid #e0e0e0; }
.report-filters > div { min-width: 160px; flex: 1; }
.report-filters label { display: block; font-size: 13px; margin-bottom: 4px; }
.report-filters input, .report-filters select { margin: 0; }
.report-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.report-count { margin-top: 12px; font-size: 13px; color: #555; }
.print-only { display: none; }

@media print {
    .navbar, .no-print { display: none !important; }
    .container { max-width: 100%; margin: 0; padding: 0; }
    .card { box-shadow: none; border: none; padding: 0; margin-bottom: 24px; }
    .print-only { display: block; }
    body { background: #fff; }
    .table-scroll table th { display: table-cell !important; }
    .table-scroll table, .table-scroll table tbody, .table-scroll table tr, .table-scroll table td { display: revert; width: auto; }
    .table-scroll table td:before { content: none !important; }
}

/* ==== Archive/Trash module ==== */
.archive-note { background: #fff8e1; color: #7a5b00; padding: 10px 14px; border-radius: 5px; font-size: 13px; margin-top: 10px; border-left: 3px solid #e0a800; }

/* ==== Landing page / Hero (public homepage, no school selected) ==== */
.hero { background: linear-gradient(135deg, #1e3a5f 0%, #315480 60%, #4d88d1 100%); color: #fff; border-radius: 14px; padding: 32px 24px; margin-bottom: 20px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.hero-text { flex: 1; min-width: 220px; }
.hero-text h1 { font-size: 22px; line-height: 1.35; margin-bottom: 10px; color: #fff; }
.hero-highlight { color: #ffd166; }
.hero-text p { font-size: 14px; opacity: .92; }
.hero-admin-btn { display: inline-block; margin-top: 16px; background: #fff; color: #1e3a5f; font-weight: 600; }
.hero-admin-btn:hover { background: #ffd166; color: #1e3a5f; }
.hero-emoji { font-size: 40px; text-align: center; flex-shrink: 0; }

@media (min-width: 700px) {
    .hero { padding: 48px 40px; }
    .hero-text h1 { font-size: 30px; }
    .hero-text p { font-size: 15px; max-width: 520px; }
    .hero-emoji { font-size: 56px; }
}

.school-finder-card h2 { margin-bottom: 10px; }
.school-results { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.school-result-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid #e0e0e0; border-radius: 8px; text-decoration: none; color: #222; transition: background .15s; }
.school-result-item:hover { background: #f0f3f7; }
.school-banner { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid #e0e0e0; }

.feature-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 20px; }
.feature-card { background: #fff; border-radius: 10px; padding: 20px; text-align: center; box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
.feature-icon { font-size: 30px; margin-bottom: 10px; }
.feature-card h3 { color: #1e3a5f; font-size: 15px; margin-bottom: 6px; }
.feature-card p { font-size: 13px; color: #555; }

@media (min-width: 700px) {
    .feature-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ==== Camera Barcode/QR Scanner modal ==== */
.cam-modal { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 1000; align-items: center; justify-content: center; padding: 16px; }
.cam-modal-box { background: #fff; border-radius: 12px; padding: 16px; width: 100%; max-width: 420px; }
.cam-modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-weight: 600; color: #1e3a5f; }
.cam-modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: #555; padding: 0 6px; }
.cam-reader { width: 100%; min-height: 220px; border-radius: 8px; overflow: hidden; background: #000; }
.cam-hint { font-size: 12px; color: #666; margin-top: 10px; text-align: center; }

/* ==== QR code box (id cards) ==== */
.qr-code-box { display: inline-block; }
.qr-code-box img, .qr-code-box canvas { margin: 0 auto; }

/* ==== Bulk actions (books) ==== */
.bulk-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.bulk-select-all { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.bulk-select-all input { width: auto; margin: 0; }

/* ==== Photo thumbnails (Students/Staff tables) ==== */
.thumb { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; display: block; }
.thumb-placeholder { display: flex; align-items: center; justify-content: center; background: #eef1f5; font-size: 16px; }
