/* =========================================================
   School ERP - Modern teal theme
   Change colours here: --brand is the main colour.
   ========================================================= */
:root {
  --brand: #0F6E56; --brand-2: #1D9E75; --brand-soft: #E1F5EE; --brand-ink: #04342C;
  --bg: #F3F5F4; --card: #FFFFFF; --ink: #17201D; --ink-2: #5B6662; --line: #E3E8E6;
  --amber: #B7791F; --amber-soft: #FDF3E1; --red: #C53030; --red-soft: #FDECEC; --green: #2F7D32; --green-soft: #E8F5E9;
  --blue: #1E5FA8; --blue-soft: #E7F0FB; --purple: #5B4BC4; --purple-soft: #EEEDFE;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,40,32,.06), 0 4px 16px rgba(16,40,32,.05);
  --font: 'Plus Jakarta Sans', 'Noto Sans Kannada', system-ui, sans-serif;
}
[data-theme="dark"] {
  --bg: #0F1513; --card: #18211E; --ink: #E6EEEB; --ink-2: #9AA8A3; --line: #26332F;
  --brand-soft: #123B31; --brand-ink: #CFF3E6; --amber-soft: #3A2C12; --red-soft: #3D1A1A; --green-soft: #173018; --blue-soft: #14283F; --purple-soft: #25214A;
  --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 14.5px; line-height: 1.55; }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 22px; margin: 0; font-weight: 700; display: flex; align-items: center; gap: 8px; }
h2 { font-size: 17px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 15px; margin: 0 0 8px; font-weight: 600; }
.muted, small.help { color: var(--ink-2); }
small.help { display: block; font-size: 12px; margin-top: 4px; }
img { max-width: 100%; }

/* ---------- Layout ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; background: var(--card); border-right: 1px solid var(--line); overflow-y: auto; z-index: 30; padding-bottom: 30px; transition: transform .2s; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 12px; font-weight: 700; color: var(--ink); font-size: 15px; }
.brand img { width: 36px; height: 36px; object-fit: contain; border-radius: 8px; }
.brand-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 20px; flex: none; }
.menu-search { margin: 4px 14px 8px; width: calc(100% - 28px); }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); padding: 14px 20px 4px; font-weight: 600; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 8px 14px; margin: 1px 10px; border-radius: 10px; color: var(--ink); font-size: 14px; }
.sidebar nav a i { font-size: 18px; color: var(--ink-2); }
.sidebar nav a:hover { background: var(--bg); }
.sidebar nav a.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.sidebar nav a.active i { color: var(--brand); }
.pill { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; border-radius: 20px; padding: 0 7px; }
.main { margin-left: 250px; min-height: 100vh; display: flex; flex-direction: column; }
.main.no-sidebar { margin-left: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 10px 24px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-search { flex: 1; display: flex; align-items: center; gap: 6px; max-width: 460px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
.top-search input { border: 0 !important; background: transparent !important; box-shadow: none !important; }
.icon-btn { position: relative; width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; font-size: 18px; font-weight: 700; font-family: var(--font); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; background: var(--red); border-radius: 50%; }
.user-menu { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }
.user-info { display: flex; flex-direction: column; line-height: 1.2; }
.user-info small { color: var(--ink-2); }
.menu-toggle { display: none; }
.content { padding: 22px 24px; flex: 1; width: 100%; max-width: 1400px; }
.foot { padding: 14px 24px; color: var(--ink-2); font-size: 12px; }
.emergency { background: var(--red); color: #fff; padding: 10px 24px; }
.backdrop { display: none; }

/* ---------- Cards and grids ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.count { font-size: 13px; font-weight: 600; background: var(--brand-soft); color: var(--brand-ink); padding: 2px 10px; border-radius: 20px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow); }
.stat .ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; flex: none; background: var(--brand-soft); color: var(--brand); }
.stat .ic.amber { background: var(--amber-soft); color: var(--amber); } .stat .ic.red { background: var(--red-soft); color: var(--red); }
.stat .ic.blue { background: var(--blue-soft); color: var(--blue); } .stat .ic.purple { background: var(--purple-soft); color: var(--purple); }
.stat .lbl { color: var(--ink-2); font-size: 12.5px; }
.stat .num { font-size: 22px; font-weight: 700; line-height: 1.2; }
.hint { background: var(--brand-soft); color: var(--brand-ink); padding: 10px 14px; border-radius: 10px; margin: -4px 0 14px; font-size: 13.5px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 9px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 10px; align-items: center; }
.list li:last-child { border-bottom: 0; }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.quick a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; border-radius: 12px; border: 1px solid var(--line); color: var(--ink); text-align: center; font-size: 13px; background: var(--card); }
.quick a i { font-size: 24px; color: var(--brand); }
.quick a:hover { border-color: var(--brand); background: var(--brand-soft); }

/* ---------- Forms ---------- */
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand); }
label { font-size: 13px; font-weight: 600; color: var(--ink-2); display: block; margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 18px; }
.field.wide { grid-column: 1 / -1; }
.req { color: var(--red); }
.readonly { padding: 9px 0; }
.switch { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--ink); padding-top: 8px; }
.current-file { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.current-file label { font-weight: 400; margin: 0; display: flex; gap: 4px; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.toolbar > input, .toolbar > select { width: auto; min-width: 160px; flex: 0 1 220px; }
.inline { display: inline; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); color: #fff; }
.btn-sm { padding: 4px 9px; font-size: 12.5px; border-radius: 8px; }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger-ghost:hover { color: var(--red); border-color: var(--red); }
.btn-wa { background: #25D366; border-color: #25D366; color: #fff; }

/* ---------- Tables ---------- */
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); background: color-mix(in srgb, var(--bg) 60%, var(--card)); padding: 11px 14px; font-weight: 600; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: color-mix(in srgb, var(--brand-soft) 35%, transparent); }
.table .empty { text-align: center; color: var(--ink-2); padding: 34px; }
.table tfoot td { font-weight: 700; background: var(--bg); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn, .row-actions form { margin-left: 3px; }
.thumb { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--ink-2); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.pager { display: flex; gap: 6px; flex-wrap: wrap; }
.pager a { padding: 5px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.pager a.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Alerts ---------- */
.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.alert-success { background: var(--green-soft); color: var(--green); }
.alert-danger { background: var(--red-soft); color: var(--red); }
.alert-warning { background: var(--amber-soft); color: var(--amber); }
.alert-info { background: var(--blue-soft); color: var(--blue); }

/* ---------- Attendance buttons ---------- */
.att-row { display: flex; gap: 4px; }
.att-row input { display: none; }
.att-row label { margin: 0; width: 36px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; font-weight: 700; color: var(--ink-2); }
.att-row input:checked + label.P { background: var(--green); color: #fff; border-color: var(--green); }
.att-row input:checked + label.A { background: var(--red); color: #fff; border-color: var(--red); }
.att-row input:checked + label.L { background: var(--amber); color: #fff; border-color: var(--amber); }
.att-row input:checked + label.H { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---------- Timetable ---------- */
.tt td { text-align: center; min-width: 110px; font-size: 13px; }
.tt td b { display: block; }
.tt td small { color: var(--ink-2); }

/* ---------- Progress bar ---------- */
.bar { height: 8px; background: var(--bg); border-radius: 10px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 10px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 14px; color: var(--ink-2); font-weight: 600; white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--brand); border-color: var(--brand); }

/* ---------- Chat ---------- */
.chat { display: grid; grid-template-columns: 260px 1fr; gap: 0; padding: 0; min-height: 520px; }
.chat-list { border-right: 1px solid var(--line); overflow-y: auto; max-height: 620px; }
.chat-list a { display: flex; gap: 10px; align-items: center; padding: 11px 14px; color: var(--ink); border-bottom: 1px solid var(--line); }
.chat-list a.active { background: var(--brand-soft); }
.chat-box { display: flex; flex-direction: column; }
.msgs { flex: 1; padding: 16px; overflow-y: auto; max-height: 520px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 75%; padding: 8px 12px; border-radius: 14px; background: var(--bg); }
.msg.me { align-self: flex-end; background: var(--brand); color: #fff; }
.msg small { display: block; opacity: .7; font-size: 11px; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: var(--brand); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h2 { font-size: 34px; line-height: 1.2; margin: 0 0 12px; }
.login-art ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.login-art li { display: flex; gap: 10px; align-items: center; opacity: .95; }
.login-box { display: grid; place-items: center; padding: 30px; }
.login-box form { width: 100%; max-width: 360px; }

/* ---------- Printable documents (receipt, report card, certificates) ---------- */
.doc { background: #fff; color: #111; max-width: 820px; margin: 0 auto 20px; padding: 28px 34px; border: 1px solid #ddd; border-radius: 6px; }
.doc .lh { display: flex; align-items: center; gap: 16px; border-bottom: 3px double #0F6E56; padding-bottom: 10px; margin-bottom: 16px; }
.doc .lh img { width: 70px; height: 70px; object-fit: contain; }
.doc .lh h2 { margin: 0; font-size: 22px; color: #0F6E56; }
.doc .lh p { margin: 2px 0 0; font-size: 12.5px; color: #444; }
.doc table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.doc th, .doc td { border: 1px solid #ccc; padding: 6px 9px; text-align: left; font-size: 13.5px; }
.doc th { background: #f1f7f4; }
.doc .sign { display: flex; justify-content: space-between; margin-top: 50px; font-size: 13px; }
.doc-title { text-align: center; letter-spacing: .15em; text-transform: uppercase; margin: 8px 0 16px; font-size: 17px; }
.idcards { display: grid; grid-template-columns: repeat(auto-fill, 220px); gap: 14px; justify-content: center; }
.idcard { width: 220px; height: 340px; border-radius: 12px; overflow: hidden; background: #fff; color: #111; border: 1px solid #ccc; text-align: center; font-size: 12px; page-break-inside: avoid; }
.idcard .top { background: #0F6E56; color: #fff; padding: 8px; font-weight: 700; font-size: 13px; }
.idcard img.ph { width: 80px; height: 90px; object-fit: cover; border-radius: 8px; margin: 8px auto 4px; display: block; background: #eee; }
.idcard .qr { display: flex; justify-content: center; margin-top: 4px; }

/* ---------- Mobile ---------- */
@media (max-width: 1000px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .sidebar { transform: translateX(-100%); }
  body.menu-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  body.menu-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-grid; }
  .topbar { padding: 10px 12px; }
  .content { padding: 16px 12px; }
  .user-info, .user-menu .avatar, .top-search { display: none; }
  .user-menu { margin-left: auto; }
  .topbar { gap: 6px; }
  .icon-btn { width: 36px; height: 36px; }
  .stat { padding: 12px; gap: 10px; }
  .stat .ic { width: 38px; height: 38px; font-size: 19px; }
  .stat .num { font-size: 18px; }
  .page-head h1 { font-size: 19px; }
  .g2 { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { padding: 28px; }
  .login-art ul { display: none; }
  .chat { grid-template-columns: 1fr; }
  .chat-list { max-height: 180px; border-right: 0; border-bottom: 1px solid var(--line); }
  /* tables turn into cards on phones */
  .table.stack thead { display: none; }
  .table.stack tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  .table.stack td { display: flex; justify-content: space-between; border: 0; padding: 4px 14px; }
  .table.stack td::before { content: attr(data-label); color: var(--ink-2); font-size: 12px; }
  .doc { padding: 16px; }
}
@media print {
  .sidebar, .topbar, .no-print, .foot, .toolbar, .page-head .actions, .row-actions, .pager, .hint, .backdrop { display: none !important; }
  .main { margin: 0; } .content { padding: 0; max-width: none; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .doc { border: 0; margin: 0 auto; padding: 0 10px; page-break-after: always; }
  .doc:last-child { page-break-after: auto; }
}

/* ---------- Attendance tiles (tap to change) ---------- */
.att-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 14px; position: sticky; top: 60px; z-index: 6; }
.att-bar-actions { margin-left: auto; display: flex; gap: 6px; }
.chip { padding: 5px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; }
.chip.P { background: var(--green-soft); color: var(--green); } .chip.A { background: var(--red-soft); color: var(--red); }
.chip.L { background: var(--amber-soft); color: var(--amber); } .chip.E { background: var(--purple-soft); color: var(--purple); }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; margin-bottom: 18px; }
.att-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px 10px; border-radius: 16px; border: 2px solid var(--green);
  background: var(--card); color: var(--ink); font: inherit; cursor: pointer; transition: transform .08s, background .15s; -webkit-tap-highlight-color: transparent; user-select: none; }
.att-tile:active { transform: scale(.96); }
.att-tile:disabled { cursor: default; opacity: .8; }
.att-tile img, .att-tile .ini { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; }
.att-tile .ini { display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); font-weight: 700; font-size: 19px; }
.att-tile .ini.f { background: var(--purple-soft); color: var(--purple); }
.att-tile .nm { font-weight: 600; font-size: 13px; text-align: center; line-height: 1.25; min-height: 32px; display: flex; align-items: center; }
.att-tile .st { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 20px; background: var(--green-soft); color: var(--green); }
.att-tile .roll { position: absolute; top: 8px; left: 10px; font-size: 11px; color: var(--ink-2); font-weight: 600; }
.att-tile .flag { position: absolute; top: 6px; right: 8px; color: var(--red); font-size: 16px; }
.att-tile .lv { font-size: 10.5px; color: var(--purple); }
.att-tile.A { border-color: var(--red); background: var(--red-soft); } .att-tile.A .st { background: var(--red); color: #fff; }
.att-tile.L { border-color: var(--amber); background: var(--amber-soft); } .att-tile.L .st { background: var(--amber); color: #fff; }
.att-tile.E { border-color: var(--purple); background: var(--purple-soft); } .att-tile.E .st { background: var(--purple); color: #fff; }
.att-tile.H { border-color: var(--blue); background: var(--blue-soft); } .att-tile.H .st { background: var(--blue); color: #fff; }
.dots { display: inline-flex; gap: 3px; min-height: 8px; }
.dots .d { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dots .d.P { background: var(--green); } .dots .d.A { background: var(--red); } .dots .d.L { background: var(--amber); } .dots .d.E { background: var(--purple); } .dots .d.H { background: var(--blue); }
.att-row input:checked + label.E { background: var(--purple); color: #fff; border-color: var(--purple); }
.att-save { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: space-between; position: sticky; bottom: 10px; z-index: 6; }
@media (max-width: 800px) {
  .att-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .att-tile { padding: 12px 4px 8px; border-radius: 14px; }
  .att-tile img, .att-tile .ini { width: 46px; height: 46px; font-size: 16px; }
  .att-tile .nm { font-size: 12px; }
  .att-bar { top: 56px; }
  .att-bar-actions { margin-left: 0; width: 100%; }
}
