/* Pathshala mobile: phone-first app UI. One accent gradient per role (set on <body data-role>). */
:root {
  --g1: #4f46e5; --g2: #7c3aed;                /* role gradient (overridden per role) */
  --ink: #111827; --ink2: #374151; --muted: #6b7280; --line: #eceef3;
  --bg: #f4f5fb; --card: #ffffff;
  --good: #059669; --good-bg: #d1fae5; --warn: #d97706; --warn-bg: #fef3c7; --bad: #dc2626; --bad-bg: #fee2e2;
  --info: #2563eb; --info-bg: #dbeafe;
  --r: 20px; --nav-h: 66px;
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
body[data-role="owner"]     { --g1: #4338ca; --g2: #7c3aed; }
body[data-role="principal"] { --g1: #0f766e; --g2: #0891b2; }
body[data-role="teacher"]   { --g1: #ea580c; --g2: #db2777; }
body[data-role="student"]   { --g1: #2563eb; --g2: #7c3aed; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 8px); font-size: 14.5px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--g1); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- hero header ---------- */
.hero { background: linear-gradient(135deg, var(--g1), var(--g2)); color: #fff; position: relative; overflow: hidden;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 18px 64px; border-radius: 0 0 28px 28px; }
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.09); }
.hero::before { width: 220px; height: 220px; right: -70px; top: -90px; }
.hero::after { width: 140px; height: 140px; left: -50px; bottom: -70px; }
.hero .top { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.hero .back { background: rgba(255,255,255,.18); border: 0; color: #fff; width: 38px; height: 38px; border-radius: 12px; font-size: 20px; cursor: pointer; }
.hero .who { flex: 1; min-width: 0; }
.hero .hi { font-size: 12.5px; opacity: .85; }
.hero .name { font-size: 19px; font-weight: 700; line-height: 1.25; }
.hero .avatar { width: 42px; height: 42px; border-radius: 14px; background: rgba(255,255,255,.22); display: grid; place-items: center; font-weight: 800; font-size: 17px; border: 0; color: #fff; cursor: pointer; }
.hero h1 { margin: 18px 0 0; font-size: 24px; font-weight: 800; position: relative; z-index: 1; letter-spacing: -.3px; }
.hero .sub { font-size: 13px; opacity: .88; position: relative; z-index: 1; margin-top: 2px; }
.hero .chips { margin-top: 14px; position: relative; z-index: 1; }

main { padding: 0 14px; margin-top: -44px; position: relative; z-index: 2; max-width: 720px; margin-left: auto; margin-right: auto; }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--r); padding: 16px; margin-bottom: 14px; box-shadow: 0 4px 18px rgba(17, 24, 39, .06); }
.card h3 { margin: 0 0 10px; font-size: 15.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card h3 .hin { font-weight: 500; color: var(--muted); font-size: 12.5px; }
.card h3 .act { margin-left: auto; }
.sec { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 18px 4px 8px; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: 0 4px 18px rgba(17, 24, 39, .06); position: relative; overflow: hidden; }
.kpi .ic { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; margin-bottom: 8px; }
.kpi .v { font-size: 21px; font-weight: 800; letter-spacing: -.3px; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .d { font-size: 11.5px; font-weight: 600; margin-top: 2px; }
.ic.indigo { background: #e0e7ff; color: #4338ca; } .ic.green { background: var(--good-bg); color: var(--good); }
.ic.amber { background: var(--warn-bg); color: var(--warn); } .ic.rose { background: var(--bad-bg); color: var(--bad); }
.ic.sky { background: var(--info-bg); color: var(--info); } .ic.violet { background: #ede9fe; color: #6d28d9; }
.up { color: var(--good); } .down { color: var(--bad); }

/* ---------- lists ---------- */
.li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: 0; padding-bottom: 2px; }
.av { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; font-weight: 700; flex: none; font-size: 15px; }
.li .t { font-weight: 600; }
.li .s { font-size: 12.5px; color: var(--muted); }
.av.c0 { background: #e0e7ff; color: #4338ca; } .av.c1 { background: #fce7f3; color: #be185d; } .av.c2 { background: #dcfce7; color: #15803d; }
.av.c3 { background: #fef3c7; color: #b45309; } .av.c4 { background: #e0f2fe; color: #0369a1; } .av.c5 { background: #f3e8ff; color: #7e22ce; }
.amt { font-weight: 800; white-space: nowrap; text-align: right; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: #f1f5f9; color: #334155; white-space: nowrap; }
.pill.good { background: var(--good-bg); color: var(--good); } .pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.info { background: var(--info-bg); color: var(--info); }

/* ---------- chips / segmented ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; background: #fff; color: var(--ink2); box-shadow: 0 2px 8px rgba(17,24,39,.06); }
.chip.on { background: linear-gradient(135deg, var(--g1), var(--g2)); color: #fff; }
.hero .chip { background: rgba(255,255,255,.18); color: #fff; box-shadow: none; }
.hero .chip.on { background: #fff; color: var(--g1); }
.seg { display: flex; background: #eef0f6; border-radius: 14px; padding: 4px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px 4px; border-radius: 11px; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 2px 6px rgba(17,24,39,.08); }

/* ---------- buttons / forms ---------- */
.btn { border: 0; border-radius: 14px; padding: 13px 18px; font-weight: 700; cursor: pointer; color: #fff; background: linear-gradient(135deg, var(--g1), var(--g2)); box-shadow: 0 6px 16px -6px var(--g1); }
.btn:disabled { opacity: .5; }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 13px; border-radius: 11px; font-size: 13px; box-shadow: none; }
.btn.ghost { background: #eef0ff; color: var(--g1); box-shadow: none; }
.btn.light { background: #fff; color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; }
.btn.ok { background: linear-gradient(135deg, #059669, #10b981); box-shadow: 0 6px 16px -6px #059669; }
label.f { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink2); margin-bottom: 12px; }
label.f input, label.f select, label.f textarea { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 13px; border: 1.5px solid var(--line); background: #fafbff; font-size: 15px; font-weight: 400; }
label.f textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--g1) !important; background: #fff; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.err { background: var(--bad-bg); color: var(--bad); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 12px; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 6px; }

/* ---------- bottom nav ---------- */
.nav { position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); height: var(--nav-h); z-index: 40;
  background: rgba(255,255,255,.96); backdrop-filter: blur(12px); border-radius: 22px; box-shadow: 0 10px 30px rgba(17,24,39,.14);
  display: flex; justify-content: space-around; align-items: center; padding: 0 6px; max-width: 700px; margin: 0 auto; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: #9ca3af; text-decoration: none; position: relative; padding: 6px 0; }
.nav a .i { font-size: 20px; line-height: 1; transition: transform .2s; }
.nav a.on { color: var(--g1); }
.nav a.on .i { transform: translateY(-2px); }
.nav a.on::after { content: ""; position: absolute; bottom: 0; width: 18px; height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--g1), var(--g2)); }
.nav .dot { position: absolute; top: 2px; right: calc(50% - 16px); background: var(--bad); color: #fff; font-size: 9.5px; min-width: 16px; height: 16px; border-radius: 8px; display: grid; place-items: center; padding: 0 4px; }

/* ---------- progress ring / bars ---------- */
.ring { position: relative; width: 74px; height: 74px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .lbl { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 16px; }
.bar { height: 8px; border-radius: 6px; background: #eef0f6; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--g1), var(--g2)); }
.bar.good i { background: linear-gradient(90deg, #059669, #34d399); } .bar.warn i { background: linear-gradient(90deg, #d97706, #fbbf24); }
.bar.bad i { background: linear-gradient(90deg, #dc2626, #f87171); }
.chart svg { width: 100%; height: auto; display: block; }
.chart .gl { stroke: #eef0f6; } .chart .tk { fill: #9ca3af; font-size: 10px; }
.chart .vl { fill: var(--ink); font-size: 10.5px; font-weight: 700; }

/* ---------- attendance marking ---------- */
.mark { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.mark:last-child { border-bottom: 0; }
.pal { display: flex; gap: 6px; flex: none; }
.pal button { width: 38px; height: 38px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-weight: 800; cursor: pointer; color: var(--muted); font-size: 13px; }
.pal button.on.p { background: var(--good); border-color: var(--good); color: #fff; }
.pal button.on.a { background: var(--bad); border-color: var(--bad); color: #fff; }
.pal button.on.l { background: var(--warn); border-color: var(--warn); color: #fff; }
.pal button.on.v { background: var(--info); border-color: var(--info); color: #fff; }
.dots { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 4px; }
.dots i { width: 9px; height: 9px; border-radius: 3px; background: #e5e7eb; }
.dots i.present { background: #34d399; } .dots i.absent { background: #f87171; } .dots i.late { background: #fbbf24; } .dots i.leave { background: #60a5fa; }
.stickybar { position: fixed; left: 14px; right: 14px; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom, 0px)); z-index: 35; max-width: 692px; margin: 0 auto; }

/* ---------- assignments / marks ---------- */
.hw { border-left: 4px solid var(--g1); }
.hw .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.exam { border-radius: 16px; background: #fafbff; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); }
.subj { display: grid; grid-template-columns: 1fr 48px; gap: 4px 10px; align-items: center; margin-top: 8px; font-size: 13px; }
.stars { display: flex; gap: 6px; justify-content: center; margin: 6px 0 12px; }
.stars button { border: 0; background: none; font-size: 34px; cursor: pointer; filter: grayscale(1); opacity: .35; transition: transform .15s; }
.stars button.on { filter: none; opacity: 1; transform: scale(1.08); }
.reply { background: var(--good-bg); color: #065f46; border-radius: 12px; padding: 9px 11px; font-size: 13px; margin-top: 8px; }

/* ---------- sheet / toast ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(17,24,39,.5); z-index: 60; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet { background: #fff; width: 100%; max-width: 620px; border-radius: 26px 26px 0 0; padding: 10px 18px calc(20px + env(safe-area-inset-bottom, 0px)); max-height: 90vh; overflow-y: auto; animation: up .25s ease-out; }
.sheet::before { content: ""; display: block; width: 42px; height: 5px; border-radius: 3px; background: #d1d5db; margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 12px; font-size: 18px; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 30px); transform: translateX(-50%); background: #111827; color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 14px; z-index: 80; max-width: 88vw; text-align: center; box-shadow: 0 10px 24px rgba(0,0,0,.25); }

/* ---------- login ---------- */
.login { min-height: 100vh; background: linear-gradient(160deg, #4338ca 0%, #7c3aed 55%, #db2777 100%); padding: calc(36px + env(safe-area-inset-top, 0px)) 18px 30px; color: #fff; }
.login .brand { text-align: center; margin-bottom: 22px; }
.login .logo { width: 84px; height: 84px; border-radius: 26px; background: #fff; display: grid; place-items: center; margin: 0 auto 14px; font-size: 42px; box-shadow: 0 14px 30px rgba(0,0,0,.25); }
.login h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.login .tag { opacity: .9; font-size: 14px; margin-top: 4px; }
.login .card { color: var(--ink); max-width: 440px; margin: 0 auto 14px; }
.roles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role { border: 0; border-radius: 18px; padding: 14px 10px; text-align: left; cursor: pointer; color: #fff; box-shadow: 0 8px 18px -8px rgba(0,0,0,.4); }
.role b { display: block; font-size: 15px; } .role span { font-size: 11.5px; opacity: .9; } .role .e { font-size: 24px; display: block; margin-bottom: 6px; }
.role.owner { background: linear-gradient(135deg, #4338ca, #7c3aed); } .role.principal { background: linear-gradient(135deg, #0f766e, #0891b2); }
.role.teacher { background: linear-gradient(135deg, #ea580c, #db2777); } .role.student { background: linear-gradient(135deg, #2563eb, #7c3aed); }

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

/* ---------- school portal screens (mobile/edu.js) ---------- */
body[data-role="vice_principal"] { --g1: #7c2d12; --g2: #c2410c; }
.role.vp { background: linear-gradient(135deg, #7c2d12, #c2410c); }
.bus-m { position: relative; display: flex; overflow-x: auto; margin: 16px 0 6px; padding-top: 16px; }
.bus-m > div { flex: 1; min-width: 64px; position: relative; text-align: center; font-size: 11px; padding-top: 16px; color: var(--muted); }
.bus-m > div::before { content: ""; position: absolute; top: 6px; left: 0; right: 0; height: 3px; background: var(--line); }
.bus-m i { position: absolute; top: 2px; left: calc(50% - 6px); width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid #cbd5e1; }
.bus-m .mine i { background: var(--g1); border-color: var(--g1); } .bus-m .mine span { color: var(--g1); font-weight: 700; }
.bus-m .here span { color: var(--ink); font-weight: 700; }
.bus-m em { position: absolute; top: -16px; left: calc(50% - 9px); font-style: normal; font-size: 16px; }
.mcal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.mcal > b { font-size: 11px; color: var(--muted); }
.mcal button { border: 0; background: #f6f7fb; border-radius: 10px; padding: 7px 0 9px; font-weight: 600; position: relative; cursor: pointer; }
.mcal button.today { box-shadow: inset 0 0 0 2px var(--g1); } .mcal button.sel { background: var(--g1); color: #fff; }
.mcal span { position: absolute; bottom: 3px; width: 6px; height: 6px; border-radius: 50%; } .mcal span.g { left: calc(50% - 7px); background: var(--info); } .mcal span.u { left: calc(50% + 1px); background: var(--warn); }
.dotg, .dotu { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--info); } .dotu { background: var(--warn); }
input[type=range] { width: 100%; accent-color: var(--g1); }
@media print {
  body > *:not(.sheet-bg) { display: none !important; }
  .sheet-bg { position: static; background: none; display: block; }
  .sheet { max-height: none; border-radius: 0; animation: none; } .sheet::before, .noprint { display: none !important; }
}

/* login steps: 1. the school, 2. the person */
.steps2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 14px; }
.steps2 span { text-align: center; font-size: 12.5px; font-weight: 700; color: rgba(255,255,255,.7); padding-bottom: 8px; border-bottom: 3px solid rgba(255,255,255,.25); }
.steps2 span.on { color: #fff; border-color: #fff; } .steps2 span.done { color: #a7f3d0; border-color: #34d399; }
