* { box-sizing: border-box; }
body {
    font-family: 'Hind Siliguri', 'Segoe UI', Arial, sans-serif;
    margin: 0; background: #f1f5f9; color: #1e293b; font-size: 15px;
}
a { color: #2563eb; }

/* ---------- Top bar ---------- */
.topbar {
    background: #0f172a; color: #fff; display: flex; align-items: center;
    flex-wrap: wrap; padding: 10px 20px; gap: 10px; position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 17px; margin-right: auto; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px; }
.topbar nav a {
    color: #cbd5e1; text-decoration: none; padding: 6px 12px; border-radius: 6px; font-size: 14px;
}
.topbar nav a:hover, .topbar nav a.active { background: #1e293b; color: #fff; }
.topbar nav a.logout { color: #fca5a5; }
.menu-toggle { display: none; background: none; border: 1px solid #334155; color: #fff;
    font-size: 20px; border-radius: 6px; padding: 2px 10px; cursor: pointer; }
@media (max-width: 860px) {
    .menu-toggle { display: block; }
    .topbar nav { display: none; width: 100%; flex-direction: column; }
    body.nav-open .topbar nav { display: flex; }
}

.container { max-width: 1250px; margin: 20px auto; padding: 0 14px; }
h2 { margin: 6px 0 14px; font-size: 21px; }
h3 { margin: 0 0 12px; font-size: 17px; }

/* ---------- Cards / stats ---------- */
.card { background: #fff; border-radius: 12px; padding: 18px; margin-bottom: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,.07); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: #fff; border-radius: 12px; padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.07);
    border-left: 4px solid #94a3b8; }
.stat .num { font-size: 26px; font-weight: 700; }
.stat .lbl { font-size: 13px; color: #64748b; }
.stat.green { border-color: #16a34a; } .stat.red { border-color: #dc2626; }
.stat.amber { border-color: #d97706; } .stat.blue { border-color: #2563eb; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Forms ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: #64748b; }
input[type=text], input[type=date], input[type=month], input[type=time], input[type=number],
input[type=password], input[type=tel], select, textarea {
    padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 7px; font-size: 14px;
    font-family: inherit; background: #fff; min-width: 0;
}
textarea { width: 100%; min-height: 70px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.help { font-size: 12px; color: #64748b; margin-top: 2px; }

.btn { background: #2563eb; color: #fff; border: none; padding: 9px 16px; border-radius: 7px;
    font-size: 14px; cursor: pointer; text-decoration: none; display: inline-block; font-family: inherit; }
.btn:hover { filter: brightness(.93); }
.btn.gray { background: #64748b; } .btn.green { background: #16a34a; }
.btn.red { background: #dc2626; } .btn.amber { background: #d97706; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.link-btn { background: none; border: none; color: #dc2626; cursor: pointer; padding: 0; font-family: inherit; font-size: 14px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-ok { background: #dcfce7; color: #166534; }
.alert-err { background: #fee2e2; color: #991b1b; }
.alert-warn { background: #fef3c7; color: #92400e; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid #e2e8f0; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid #eef2f6; text-align: left; white-space: nowrap; }
th { background: #f8fafc; color: #475569; font-weight: 600; }
tr:hover td { background: #f8fafc; }
td.wrap { white-space: normal; }
.empty { text-align: center; color: #94a3b8; padding: 28px !important; }
.num-cell { text-align: center; }

.badge { padding: 2px 9px; border-radius: 20px; font-size: 12px; display: inline-block; }
.st-present { background: #dcfce7; color: #166534; }
.st-late { background: #fef3c7; color: #92400e; }
.st-absent { background: #fee2e2; color: #991b1b; }
.st-off { background: #e2e8f0; color: #475569; }
.sms-sent { background: #dcfce7; color: #166534; } .sms-failed { background: #fee2e2; color: #991b1b; }
.sms-pending { background: #dbeafe; color: #1e40af; } .sms-test_mode { background: #f3e8ff; color: #6b21a8; }
.sms-skipped { background: #e2e8f0; color: #475569; }

.progress { background: #e2e8f0; border-radius: 10px; height: 8px; overflow: hidden; min-width: 80px; }
.progress > div { background: #16a34a; height: 100%; }

/* Monthly matrix */
.matrix th, .matrix td { padding: 4px 3px; text-align: center; font-size: 12px; }
.matrix td.name-cell, .matrix th.name-cell { text-align: left; padding-left: 8px; }
.m-P { color: #166534; font-weight: 600; } .m-L { color: #b45309; font-weight: 600; }
.m-A { color: #dc2626; font-weight: 600; } .m-H, .m-W { color: #94a3b8; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { background: #fff; padding: 30px; border-radius: 14px; width: 100%; max-width: 360px;
    box-shadow: 0 6px 24px rgba(0,0,0,.1); }
.login-box h2 { text-align: center; }
.login-box input { width: 100%; margin-bottom: 12px; }
.login-box .btn { width: 100%; padding: 11px; }

/* ---------- Print mode ---------- */
.print-toolbar { background: #0f172a; padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; }
.print-toolbar a { color: #cbd5e1; text-decoration: none; }
body.print-mode { background: #e2e8f0; }
.print-page { width: 210mm; min-height: 297mm; margin: 20px auto; background: #fff; padding: 12mm; }
body.landscape .print-page { width: 297mm; min-height: 210mm; }
.letterhead { width: 100%; display: block; margin-bottom: 8px; }
.school-title { text-align: center; margin: 0 0 6px; }
.report-title { text-align: center; font-size: 19px; font-weight: 700; text-decoration: underline; margin: 6px 0 2px; }
.report-meta { text-align: center; font-size: 13px; color: #334155; margin-bottom: 10px; }
.print-page table { font-size: 12px; }
.print-page th, .print-page td { border: 1px solid #94a3b8; padding: 5px 6px; }
.print-page .matrix th, .print-page .matrix td { padding: 2px 1px; font-size: 10px; }
.summary-line { display: flex; justify-content: center; gap: 22px; font-size: 13px; margin-bottom: 10px; flex-wrap: wrap; }
.sign-row { display: flex; justify-content: flex-end; margin-top: 50px; page-break-inside: avoid; }
.sign-block { width: 220px; text-align: center; }
.sign-space { height: 100px; display: flex; align-items: flex-end; justify-content: center; }
.sign-space img { max-height: 95px; max-width: 210px; object-fit: contain; }
.sign-line { border-top: 1px solid #333; padding-top: 5px; font-weight: 600; }
.generated-at { text-align: right; font-size: 11px; color: #94a3b8; margin-top: 16px; }

@media print {
    .no-print { display: none !important; }
    body.print-mode { background: #fff; }
    .print-page { margin: 0; padding: 0; width: auto; min-height: auto; }
    body.landscape .print-page { width: auto; min-height: auto; }
    tr { page-break-inside: avoid; }
    thead { display: table-header-group; }
    .badge { border: 1px solid #ccc; }
}
