/* SmartEdu Portal */
:root {
  --bg: #F1F5F9; --card: #FFFFFF; --text: #0F172A; --muted: #64748B; --border: #E2E8F0;
  --primary: #4F46E5; --primary-d: #4338CA; --green: #059669; --red: #DC2626; --amber: #D97706; --blue: #0284C7;
  --side: #0F172A; --side-text: #CBD5E1;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 20px; }
h3 { font-size: 15px; margin: 18px 0 8px; color: var(--primary-d); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ic { width: 18px; height: 18px; flex: none; }
.ic.big { width: 30px; height: 30px; opacity: .85; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #F8FAFC; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.wide { width: 100%; justify-content: center; padding: 11px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
input, select { font: inherit; color: var(--text); padding: 8px 10px; border: 1px solid #CBD5E1; border-radius: 8px; background: #fff; min-width: 0; }
input:focus, select:focus { outline: 2px solid #C7D2FE; border-color: var(--primary); }
.alert { background: #FEE2E2; color: #991B1B; padding: 10px 12px; border-radius: 8px; margin: 10px 0; }
.alert.info { background: #E0F2FE; color: #075985; }
.keybox { font-family: Consolas, monospace; font-size: 14px; background: #F8FAFC; word-break: break-all; padding: 10px; border-radius: 8px; border: 1px dashed #A5B4FC; }

/* login / install */
.plain { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.loginbox { background: #fff; width: 100%; max-width: 400px; padding: 28px; border-radius: 16px; box-shadow: 0 10px 40px rgba(15,23,42,.08); }
.loginbox.wide { max-width: 560px; }
.loginbox form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand b { display: block; font-size: 16px; }
.brand small { color: var(--muted); }
.brand.big b { font-size: 20px; }
.logo { width: 38px; height: 38px; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 20px; flex: none; }

/* shell */
.navtoggle { display: none; }
.shell { display: flex; min-height: 100vh; }
.side { width: 250px; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex: none; }
.side .brand { padding: 18px 16px; color: #fff; }
.side .brand small { color: #94A3B8; }
.side nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.side nav a { display: flex; align-items: center; gap: 10px; color: var(--side-text); padding: 6px 10px; font-size: 13.5px; border-radius: 8px; margin: 1px 0; }
.side nav a:hover { background: #1E293B; color: #fff; text-decoration: none; }
.side nav a.on { background: var(--primary); color: #fff; }
.navhead { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748B; padding: 10px 10px 2px; }
.sidefoot { border-top: 1px solid #1E293B; padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.sidefoot .who b { color: #fff; display: block; }
.sidefoot .who small { color: #94A3B8; }
.sidefoot .btn { color: #E2E8F0; border-color: #334155; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 12px 22px; position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 18px; flex: 1; }
.topright { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.menubtn { display: none; cursor: pointer; color: var(--text); }
.menubtn .ic { width: 24px; height: 24px; }
.pill { background: #EEF2FF; color: var(--primary-d); padding: 4px 10px; border-radius: 99px; font-weight: 600; font-size: 12px; }
.sync { color: var(--muted); font-size: 12px; }
.content { padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; }
.foot { color: #94A3B8; font-size: 12px; padding: 10px 22px 18px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; min-width: 0; }
.cardhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cardhead h3 { margin: 0 0 10px; }
.grid { display: grid; gap: 14px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.stat { display: flex; justify-content: space-between; align-items: center; border-left: 5px solid var(--primary); }
.stat small { display: block; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.stat b { display: block; font-size: 22px; margin-top: 4px; }
.stat.green { border-left-color: var(--green); } .stat.green .ic { color: var(--green); }
.stat.red { border-left-color: var(--red); } .stat.red .ic { color: var(--red); }
.stat.amber { border-left-color: var(--amber); } .stat.amber .ic { color: var(--amber); }
.stat.blue { border-left-color: var(--blue); } .stat.blue .ic { color: var(--blue); }
.stat.indigo .ic, .stat.primary .ic { color: var(--primary); }
.cardlink, .cardlink:hover { text-decoration: none; color: inherit; }
.cardlink .card:hover { box-shadow: 0 4px 18px rgba(79,70,229,.12); }
.chart { width: 100%; height: 240px; display: block; }
.bar { display: block; }

/* filters / tabs */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; }
.filters .grow { flex: 1; }
.filters .growlabel { flex: 1; min-width: 200px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; align-self: center; }
.chip { background: #EEF2FF; color: var(--primary-d); padding: 5px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.tabs { display: flex; gap: 6px; }
.tabs a { padding: 8px 14px; border-radius: 8px; background: #fff; border: 1px solid var(--border); color: var(--text); font-weight: 600; }
.tabs a.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.stack { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* tables */
.tablewrap { overflow-x: auto; margin: 6px 0; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; background: #F8FAFC; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid #F1F5F9; vertical-align: middle; }
tbody tr:hover td { background: #FAFAFF; }
.r { text-align: right; white-space: nowrap; }
tr.total td { font-weight: 700; background: #EEF2FF; border-top: 2px solid #C7D2FE; }
td.empty { text-align: center; color: var(--muted); padding: 24px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #F1F5F9; }
.tag.green { background: #D1FAE5; color: #065F46; } .tag.amber { background: #FEF3C7; color: #92400E; } .tag.red { background: #FEE2E2; color: #991B1B; }
.tag.indigo { background: #E0E7FF; color: #3730A3; } .tag.gray { background: #F1F5F9; color: #64748B; }

/* statements */
.kv { width: 55%; min-width: 320px; margin: 6px 0; }
.kv.wide { width: 75%; } .kv.full { width: 100%; }
.kv td { padding: 6px 8px; }
.kv tr.head td { font-weight: 700; color: #3730A3; background: #EEF2FF; }
.kv tr.total td { font-weight: 700; border-top: 1px solid #94A3B8; background: transparent; }
.kv tr.grand td { font-weight: 800; font-size: 16px; color: var(--primary); border-top: 2px solid var(--primary); }
.kv tr.sub td:first-child { padding-left: 24px; color: #475569; }
.kv tr.neg td { color: var(--red); } .kv tr.pos td { color: var(--green); font-weight: 700; }
.kv tr.gap td { height: 10px; border: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.rhead { margin-bottom: 8px; }
.printed { color: #94A3B8; font-size: 11px; margin-top: 14px; }
.invhead { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; border-bottom: 2px solid var(--primary); padding-bottom: 10px; margin-bottom: 10px; }
.invtotals { display: flex; justify-content: flex-end; }
.invtotals .kv { width: 340px; min-width: 0; }

/* login checkbox, app page */
.publicwrap { width: 100%; max-width: 620px; display: flex; flex-direction: column; gap: 16px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text); font-size: 13px; }
label.check input { width: 18px; height: 18px; }
.appcard { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.appicon { width: 72px; height: 72px; border-radius: 18px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 36px; flex: none; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.steps li { margin: 6px 0; }
code { background: #EEF2FF; padding: 2px 6px; border-radius: 6px; word-break: break-all; }

/* mobile */
@media (max-width: 900px) {
  .side { position: fixed; left: -270px; z-index: 20; transition: left .2s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .navtoggle:checked + .shell .side { left: 0; }
  .menubtn { display: block; }
  .top { padding: 10px 14px; }
  .content { padding: 14px; }
  .grid.two, .two { grid-template-columns: 1fr; }
  .kv, .kv.wide { width: 100%; min-width: 0; }
  .grid.cards { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .stat b { font-size: 18px; }
  .sync { display: none; }
}

@media (max-width: 480px) {
  .grid.cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px; }
  .stat .ic.big { display: none; }
  .stat b { font-size: 16px; }
  .top h1 { font-size: 16px; }
}

/* print / PDF */
@media print {
  body { background: #fff; font-size: 11px; }
  .noprint, .side, .top, .foot, .filters, .tabs { display: none !important; }
  .content { padding: 0; }
  .card { border: 0; padding: 0; }
  .shell, .main { display: block; }
  .bar, .chart { display: none; }
  th { background: #EEE !important; }
  a { color: inherit; }
}
/* ---- portal v2: parents / students / teachers ---- */
.center { text-align: center; }
.chip.on { background: var(--primary); color: #fff; }
.pre { white-space: normal; line-height: 1.5; }
.card.unread { border-left: 4px solid #F59E0B; }
.chat { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; padding: 6px 2px; }
.msg { display: flex; }
.msg.mine { justify-content: flex-end; }
.msg .bubble { max-width: 80%; padding: 8px 12px; border-radius: 14px; background: #fff; border: 1px solid var(--border); }
.msg.mine .bubble { background: var(--primary); color: #fff; border-color: var(--primary); }
.msg .bubble small { display: block; opacity: .75; font-size: 11px; margin-top: 3px; }
.chatform { display: flex; gap: 8px; margin-top: 10px; align-items: stretch; }
.chatform textarea { flex: 1; min-height: 60px; border: 1px solid var(--border); border-radius: 10px; padding: 8px; font: inherit; }
.stack { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.stack.narrow { max-width: 420px; }
.stack .row { display: flex; flex-wrap: wrap; gap: 10px; }
.stack .row label { flex: 1 1 160px; }
.stack textarea { min-height: 90px; border: 1px solid var(--border); border-radius: 8px; padding: 8px; font: inherit; }
table.tt th.c, table.tt td.c { text-align: center; white-space: normal; min-width: 84px; }
table.tt .brk { background: #FEF3C7; color: #92400E; }
table.tt small.fri { color: #B45309; }
.qrbox { max-width: 260px; margin: 10px auto; }
.qrbox img { width: 100%; border-radius: 10px; image-rendering: pixelated; }
@media print { .chatform, .chip { display: none; } }

/* ---- 2.6: login on small screens, drawer ---- */
.plain { flex-direction: column; }
.regline { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 14px;
  padding-top: 12px; border-top: 1px solid var(--border); }
.navshade { display: none; }
@media (max-width: 900px) {
  .navshade { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 15; }
  .navtoggle:checked + .shell .navshade { display: block; }
}

/* date sheet (v2.9) */
.dslist { display: grid; gap: 10px; }
.dsrow { display: flex; gap: 14px; align-items: flex-start; border: 1px solid var(--line, #E2E8F0); border-radius: 12px; padding: 10px 12px; background: #fff; }
.dsrow.today { border-color: #F59E0B; background: #FFFBEB; }
.dsrow.done { opacity: .6; }
.dsdate { min-width: 64px; text-align: center; border-right: 1px solid var(--line, #E2E8F0); padding-right: 12px; display: flex; flex-direction: column; }
.dsdate b { font-size: 24px; line-height: 1.1; color: #4F46E5; }
.dsdate span { font-size: 12px; color: var(--muted, #64748B); }
.dsdate small { font-size: 12px; font-weight: 600; }
.dsbody { min-width: 0; flex: 1; }
.dssub { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.dssyl { margin-top: 6px; font-size: 13px; overflow-wrap: anywhere; }
@media print { .dsrow { break-inside: avoid; } }

/* live attendance (v2.11) */
.live .liveq { width: 100%; font-size: 20px; padding: 14px 16px; border-radius: 12px; border: 2px solid #C7D2FE; box-sizing: border-box; }
.lres { display: grid; gap: 6px; margin: 10px 0; }
.lhit { text-align: left; padding: 10px 12px; border: 1px solid #E2E8F0; border-radius: 10px; background: #fff; font-size: 15px; cursor: pointer; }
.lhit.on { border-color: #4F46E5; background: #EEF2FF; }
.lhit small { color: #64748B; }
.lcard { display: flex; gap: 14px; align-items: flex-start; padding: 12px; border: 1px solid #E2E8F0; border-radius: 14px; background: #F8FAFC; }
.lpic { width: 96px; height: 120px; border-radius: 10px; background: #E2E8F0; display: flex; align-items: center; justify-content: center; overflow: hidden; color: #64748B; font-size: 12px; flex: none; }
.lpic img { width: 100%; height: 100%; object-fit: cover; }
.linfo { min-width: 0; font-size: 15px; display: grid; gap: 3px; }
.linfo b { font-size: 19px; }
.lbtn { width: 100%; margin-top: 12px; font-size: 20px; padding: 16px; border-radius: 12px; }
.lmsg { margin-top: 12px; font-size: 17px; font-weight: 700; text-align: center; min-height: 1.4em; }
.lmsg.ok { color: #047857; } .lmsg.warn { color: #B45309; } .lmsg.info { color: #1D4ED8; } .lmsg.bad { color: #B91C1C; }
.lrow { padding: 6px 0; border-bottom: 1px solid #F1F5F9; font-size: 14px; }
.lcard[hidden], .lbtn[hidden] { display: none; }
.lnote { margin-top: 8px; }
/* data entry from the phone (v2.13) */
.entrytiles .etile { display: flex; flex-direction: column; gap: 4px; min-height: 96px; }
.entrytiles .etile .ic { width: 26px; height: 26px; color: var(--primary); }
.entrytiles .etile small { color: var(--muted); font-size: 12px; }
.small { font-size: 12px; }
.attform .attlist { display: flex; flex-direction: column; margin: 8px 0 12px; }
.attrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.attrow .who { display: flex; flex-direction: column; min-width: 0; flex: 1 1 160px; }
.attrow .who small { color: var(--muted); font-size: 11.5px; }
.chips { display: flex; gap: 6px; }
.chip { flex-direction: row; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 36px; border-radius: 9px;
  border: 1.5px solid #CBD5E1; font-weight: 700; color: #475569; background: #fff; font-size: 13px; }
.chip.cp input:checked + span { background: #16A34A; border-color: #16A34A; color: #fff; }
.chip.ca input:checked + span { background: #DC2626; border-color: #DC2626; color: #fff; }
.chip.cl input:checked + span { background: #D97706; border-color: #D97706; color: #fff; }
.chip.clv input:checked + span { background: #2563EB; border-color: #2563EB; color: #fff; }
.chip input:disabled + span { opacity: .55; }
.chip input:focus-visible + span { outline: 2px solid #C7D2FE; }
.attrow.staff .srow { display: flex; gap: 6px; align-items: flex-end; flex-wrap: wrap; }
.attrow.staff label.tm { flex-direction: row; align-items: center; gap: 4px; }
.attrow.staff input[type=time] { padding: 6px; width: 112px; }
input.mk { width: 84px; text-align: center; font-weight: 700; font-size: 16px; }
input.big { font-size: 20px; font-weight: 700; }
.btnrow .grow { flex: 1; }
[hidden] { display: none !important; }
.elist { display: flex; flex-direction: column; gap: 8px; }
.eitem { border: 1px solid var(--border); border-left: 4px solid #F59E0B; border-radius: 10px; padding: 8px 10px; }
.eitem.green { border-left-color: #10B981; } .eitem.red { border-left-color: #EF4444; }
.eitem .etop { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.eitem .edet { font-size: 13px; margin-top: 2px; }
.eitem .eres { font-size: 12px; margin-top: 3px; word-break: break-word; }
