/* Minimal app chrome — no build step required. */

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Montserrat', system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    background: #f4f6fa;
    color: #1f2937;
}

.topnav {
    background: #16305f;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.topnav-inner {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.topnav a {
    position: relative;
    display: inline-block;
    color: #a9bce3;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.9rem 0.7rem;
    transition: color 0.15s;
}
.topnav a:hover { color: #fff; }
.topnav a.active { color: #fff; }
.topnav a.active::after {
    content: "";
    position: absolute;
    left: 0.7rem;
    right: 0.7rem;
    bottom: 0;
    height: 2px;
    background: #5b8def;
    border-radius: 2px 2px 0 0;
}
.topnav .brand {
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.01em;
    margin-right: 0.75rem;
    padding: 0.9rem 0;
}
.topnav .brand:hover { color: #fff; }
.topnav-spacer { margin-left: auto; }
.topnav-user { color: #a9bce3; font-size: 0.85rem; padding: 0 0.25rem; }
.topnav-logout {
    background: none;
    border: 1px solid #3d5694;
    color: #a9bce3;
    font-size: 0.82rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.topnav-logout:hover { color: #fff; border-color: #fff; }

/* "Manage" dropdown — native <details>, no JS framework needed. Closed by
 * a small script in the layout when clicking outside it. */
.nav-dropdown { position: relative; }
.nav-dropdown > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.9rem 0.7rem;
    color: #a9bce3;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.15s;
}
.nav-dropdown > summary::-webkit-details-marker { display: none; }
.nav-dropdown > summary::after { content: "\25BE"; font-size: 0.7em; margin-top: 0.1em; }
.nav-dropdown > summary:hover,
.nav-dropdown[open] > summary,
.nav-dropdown.active > summary { color: #fff; }
.nav-dropdown.active > summary::before {
    content: "";
    position: absolute;
    left: 0.7rem;
    right: 1.4rem;
    bottom: 0;
    height: 2px;
    background: #5b8def;
    border-radius: 2px 2px 0 0;
}
.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.4rem;
    min-width: 190px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
    padding: 0.4rem;
    z-index: 200;
}
.nav-dropdown-menu a {
    display: block;
    padding: 0.5rem 0.7rem;
    border-radius: 6px;
    color: #1f2937;
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: none;
}
.nav-dropdown-menu a:hover { background: #eef2fa; color: #1b3a7a; }
.nav-dropdown-menu a.active { background: #eef2fa; color: #1b3a7a; }

/* Login page */
.guest-body { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.guest-wrapper { width: 100%; max-width: 380px; padding: 1rem; }
.guest-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 2rem 1.75rem; }
.guest-brand { color: #1b3a7a; font-weight: 700; font-size: 0.95rem; margin-bottom: 0.5rem; }
.guest-card h1 { font-size: 1.4rem; margin: 0 0 1.25rem; }

/* Public teacher-ID verification page (QR scan target) */
.verify-card { text-align: center; }
.verify-status {
    display: inline-block;
    padding: 0.4rem 1rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.95rem;
    margin: 0.5rem 0 1.25rem;
}
.verify-status--active { background: #e7f6ec; color: #14652f; }
.verify-status--inactive { background: #fdecec; color: #8c1d1d; }
.verify-photo {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid #e2e8f0;
    margin-bottom: 1rem;
}
.verify-name { font-size: 1.25rem; margin: 0 0 0.5rem; }
.verify-detail { font-size: 0.95rem; color: #475569; margin-bottom: 0.25rem; }
.verify-employee-no { margin-top: 0.75rem; font-weight: 600; color: #1b3a7a; }

.container { max-width: 960px; margin: 1.5rem auto; padding: 0 1rem; }
.container--full { max-width: none; padding: 0 1.5rem; }
.container--edge { max-width: none; padding: 0 0.75rem; margin-top: 1rem; }

/* Sidebar workspace layout: reused by the teacher show page (photo tools |
 * card preview | adjustments) and the school form (card images | details |
 * background photo). */
.workspace, .teacher-workspace {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr) 340px;
    gap: 1rem;
    align-items: start;
}
@media (max-width: 1200px) {
    .workspace, .teacher-workspace { grid-template-columns: 1fr; }
}
.workspace .sidebar-title, .teacher-workspace .sidebar-title { font-size: 1.05rem; margin: 0 0 0.75rem; }
.sidebar-control { margin-bottom: 1rem; }
.sidebar-control label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; }
.sidebar-control input[type="range"] { width: 100%; }
.sidebar-control .value { font-size: 0.85rem; color: #64748b; }

/* Dropzone-style file picker */
.dropzone {
    display: block;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.dragover { border-color: #1b3a7a; background: #eef2fa; }
.dropzone-icon { font-size: 1.8rem; line-height: 1; margin-bottom: 0.4rem; }
.dropzone-text { font-size: 0.9rem; color: #475569; font-weight: 600; }
.dropzone-hint { font-size: 0.78rem; color: #94a3b8; margin-top: 0.2rem; }
.dropzone-filename { font-size: 0.85rem; color: #1b3a7a; font-weight: 600; margin-top: 0.4rem; word-break: break-all; }
.dropzone-preview-img { max-width: 100%; max-height: 90px; object-fit: contain; margin-bottom: 0.4rem; border-radius: 4px; }

/* Mode tabs — e.g. Upload vs Draw on the signature panel */
.mode-tabs { display: flex; gap: 1rem; margin-bottom: 0.9rem; border-bottom: 1px solid #e2e8f0; }
.mode-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.5rem 0.1rem;
    margin-bottom: -1px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
}
.mode-tab:hover { color: #1b3a7a; }
.mode-tab.active { color: #1b3a7a; border-bottom-color: #1b3a7a; }

/* Signature pad fullscreen — native Fullscreen API on #sig-pad-wrap; the
 * canvas's own size is set directly by JS (see resizeSigPadTo) since it
 * needs to resize the drawing buffer at the same time, not just the CSS box. */
#sig-pad-wrap:fullscreen,
#sig-pad-wrap:-webkit-full-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fff;
    padding: 2rem;
}

/* 12-column grid for precise field widths (e.g. school form: 75/25, 50/50) */
.grid-12 { display: grid; grid-template-columns: repeat(12, 1fr); gap: 1rem; }
.gcol-3 { grid-column: span 3; }
.gcol-4 { grid-column: span 4; }
.gcol-6 { grid-column: span 6; }
.gcol-9 { grid-column: span 9; }
.gcol-12 { grid-column: span 12; }
@media (max-width: 640px) {
    .grid-12 { grid-template-columns: 1fr; }
    .gcol-3, .gcol-4, .gcol-6, .gcol-9, .gcol-12 { grid-column: span 1; }
}

.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alert-success { background: #e7f6ec; color: #14652f; border: 1px solid #bfe5cc; }
.alert-error { background: #fdecec; color: #8c1d1d; border: 1px solid #f3c3c3; }
.alert ul { margin: 0; padding-left: 1.2rem; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.page-header h1 { font-size: 1.4rem; font-weight: 700; color: #0f172a; margin: 0; }

.card-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

table.list {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
table.list th, table.list td { padding: 0.7rem 0.9rem; text-align: left; border-bottom: 1px solid #eef2f7; font-size: 0.9rem; }
table.list th {
    background: #f8fafc;
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #e2e8f0;
}
table.list tbody tr { transition: background 0.1s; }
table.list tbody tr:nth-child(even) { background: #fbfcfe; }
table.list tbody tr:hover { background: #eef2fa; }
table.list tr:last-child td { border-bottom: none; }
table.list td a { color: #1b3a7a; font-weight: 600; text-decoration: none; }
table.list td a:hover { text-decoration: underline; }

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 7px;
    border: 1px solid transparent;
    background: #1b3a7a;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { background: #142c5e; }
.btn:focus-visible, .btn-secondary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(27, 58, 122, 0.25);
}
.btn-secondary { background: #fff; color: #1b3a7a; border-color: #cbd5e1; }
.btn-secondary:hover { background: #f8fafc; border-color: #1b3a7a; }
.btn-danger { background: #b91c1c; }
.btn-danger:hover { background: #991616; }
.btn:disabled, .btn-secondary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: #fff;
    color: #94a3b8;
    border-color: #cbd5e1;
}
.btn:disabled:hover, .btn-secondary:disabled:hover { background: #fff; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.25rem; color: #334155; }
.field input, .field select {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    font-size: 0.92rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus {
    outline: none;
    border-color: #1b3a7a;
    box-shadow: 0 0 0 3px rgba(27, 58, 122, 0.12);
}
.field .hint { font-size: 0.78rem; color: #64748b; margin-top: 0.2rem; }
.field .error { font-size: 0.8rem; color: #b91c1c; margin-top: 0.2rem; }

/* helper to make a field span the full width of the grid */
.field--full { grid-column: 1 / -1; }

.thumb { width: 42px; height: 52px; object-fit: cover; border-radius: 5px; background: #e2e8f0; }
.thumb--round { width: 42px; height: 42px; border-radius: 50%; }

/* Front/back toggle switch */
.side-toggle { display: flex; align-items: center; justify-content: center; gap: 0.75rem; margin: 1rem 0; }
.side-toggle .label { font-size: 0.9rem; font-weight: 600; color: #64748b; }
.side-toggle .label.active { color: #1b3a7a; }

.switch { position: relative; display: inline-block; width: 52px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute;
    inset: 0;
    background: #1b3a7a;
    border-radius: 28px;
    cursor: pointer;
    transition: background 0.2s;
}
.switch .slider::before {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.switch input:checked + .slider::before { transform: translateX(24px); }

/* Import hub option cards */
.import-options { display: flex; gap: 1rem; flex-wrap: wrap; }
.import-option {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    flex: 1 1 320px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.import-option:hover { border-color: #1b3a7a; box-shadow: 0 4px 10px rgba(0,0,0,0.06); }
.import-option-icon { font-size: 2.2rem; line-height: 1; }
.import-option-body h2 { font-size: 1.1rem; margin: 0 0 0.35rem; color: #1b3a7a; }
.import-option-body p { font-size: 0.88rem; color: #475569; margin: 0 0 0.5rem; }
.import-option-count { font-size: 0.78rem; color: #94a3b8; }

.preview-stage { display: flex; justify-content: center; padding: 1.5rem 0; }

/* Teacher preview: front and back shown at once, stacked with a small gap
 * (no front/back toggle — both sides need to be visible together). */
.tcard-stack { display: flex; flex-direction: column; align-items: center; gap: 1mm; padding: 1.5rem 0; }

.preview-wrapper { display: flex; flex-direction: column; align-items: center; }
.preview-control { width: 100%; display: flex; justify-content: center; }

/* Template picker previews in school form */
.template-grid { display:flex; gap:0.8rem; flex-wrap:wrap; justify-content:flex-start; margin-top:0.6rem; }
.template-item { display:flex; flex-direction:column; align-items:flex-start; width:200px; cursor:pointer; border:1px solid transparent; padding:0.4rem; border-radius:8px; }
.template-item input { display:none; }
.template-item.selected { border-color:#cbd5e1; box-shadow:0 4px 10px rgba(0,0,0,0.06); }
.template-thumb { width:180px; height:286px; overflow:hidden; display:flex; align-items:flex-start; justify-content:flex-start; }
.template-label { margin-top:0.5rem; font-weight:600; font-size:0.95rem; text-align:left; }
.template-placeholder { width:180px; height:286px; display:flex;align-items:center;justify-content:center;background:#f3f4f6;border-radius:6px;color:#64748b }

/* Search/filter bar atop a listing table (students, teachers, employees). */
.filter-bar { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.filter-bar input[type="search"] { flex: 1; min-width: 200px; }
.filter-bar input[type="search"], .filter-bar select {
    padding: 0.55rem 0.7rem;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    font-size: 0.92rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.filter-bar input[type="search"]:focus, .filter-bar select:focus {
    outline: none;
    border-color: #1b3a7a;
    box-shadow: 0 0 0 3px rgba(27, 58, 122, 0.12);
}

.pagination { margin-top: 1rem; }

.pager { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.pager-link {
    display: inline-block;
    min-width: 2.1rem;
    padding: 0.35rem 0.6rem;
    text-align: center;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    color: #1b3a7a;
    font-size: 0.9rem;
    text-decoration: none;
}
.pager-link:hover { background: #eef2fa; border-color: #1b3a7a; }
.pager-current { background: #1b3a7a; border-color: #1b3a7a; color: #fff; font-weight: 600; }
.pager-current:hover { background: #1b3a7a; }
.pager-disabled { color: #cbd5e1; background: #f8fafc; }
.pager-disabled:hover { background: #f8fafc; border-color: #cbd5e1; }
.pager-summary { margin-top: 0.5rem; font-size: 0.85rem; color: #64748b; }

/* Status badges: card lifecycle (pending/printed/claimed) and employment
 * (active/inactive), used throughout the listing tables. */
.badge { display: inline-flex; align-items: center; gap: 0.35em; padding: 0.25rem 0.65rem; border-radius: 999px; font-size: 0.76rem; font-weight: 700; letter-spacing: 0.01em; text-transform: uppercase; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-pending { background: #fdf3e0; color: #92610c; }
.badge-printed { background: #e5edfd; color: #1d4ed8; }
.badge-claimed { background: #e7f6ec; color: #14652f; }
.badge-employment-active { background: #e7f6ec; color: #14652f; }
.badge-employment-inactive { background: #fdecec; color: #8c1d1d; }

.status-select {
    padding: 0.4rem 0.6rem;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    font-size: 0.88rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.status-select:focus { outline: none; border-color: #1b3a7a; box-shadow: 0 0 0 3px rgba(27, 58, 122, 0.12); }
.status-select:disabled { color: #94a3b8; cursor: not-allowed; }
