/* =====================================================================
   School ERP: responsive UI (mobile, tablet, desktop)
   ===================================================================== */
:root {
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-soft: #e6f4f1;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f4f6f9;
  --card: #ffffff;
  --sb-bg: #0b1f2a;
  --sb-ink: #b6c4cf;
  --sb-w: 264px;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .05);
  --bs-primary: var(--brand);
  --bs-primary-rgb: 15, 118, 110;
  --bs-link-color: var(--brand);
  --bs-link-hover-color: var(--brand-dark);
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: .94rem;
  min-height: 100vh;
}

/* ---------- Buttons / forms ---------- */
.btn { border-radius: 10px; font-weight: 500; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark); --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand); }
.form-control, .form-select { border-radius: 10px; border-color: #cbd5e1; padding: .6rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .22rem rgba(15, 118, 110, .16); }
.form-label { font-weight: 600; font-size: .85rem; color: #334155; margin-bottom: .3rem; }
.form-text { color: var(--muted); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-switch .form-check-input { width: 2.6em; height: 1.35em; }

/* ---------- Layout ---------- */
.app { min-height: 100vh; }
.sidebar {
  --bs-offcanvas-width: 280px;
  --bs-offcanvas-bg: var(--sb-bg);
  --bs-offcanvas-color: var(--sb-ink);
  background: var(--sb-bg);
  color: var(--sb-ink);
}
.sidebar .offcanvas-body { padding: 0; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; -ms-overflow-style: none; }
.sidebar .offcanvas-body::-webkit-scrollbar { width: 0; height: 0; display: none; }
.sb-nav { flex: 1 0 auto; }
.sb-brand { display: flex; align-items: center; gap: .75rem; padding: 1.15rem 1.2rem; border-bottom: 1px solid rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.sb-brand .logo { width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(135deg, #14b8a6, #0f766e); display: grid; place-items: center; font-size: 1.25rem; color: #fff; flex: none; overflow: hidden; }
.sb-brand .logo img { width: 100%; height: 100%; object-fit: cover; }
.sb-brand .name { font-weight: 700; line-height: 1.15; font-size: .98rem; }
.sb-brand .sub { font-size: .72rem; color: var(--sb-ink); opacity: .8; }
.sb-nav { padding: .6rem .75rem 1rem; flex: 1; }
.sb-group { display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: 0; text-align: left; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: #8aa0b2; padding: .7rem .75rem; margin-top: .15rem; font-weight: 600; border-radius: 8px; cursor: pointer; }
.sb-group:hover { color: #fff; background: rgba(255,255,255,.05); }
.sb-group > i { font-size: .8rem; transition: transform .2s; }
.sb-group .sb-gi { font-size: .95rem; transition: none; }
.sb-sec.open > .sb-group { color: #fff; }
.sb-sec.open > .sb-group > i { transform: rotate(180deg); }
.sb-items { display: none; padding-bottom: .25rem; }
.sb-sec.open > .sb-items { display: block; }
.sb-link { display: flex; align-items: center; gap: .7rem; padding: .62rem .75rem; border-radius: 10px; color: var(--sb-ink); text-decoration: none; font-weight: 500; transition: background .15s, color .15s; }
.sb-link i { font-size: 1.08rem; width: 1.3rem; text-align: center; opacity: .9; }
.sb-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sb-link.active { background: linear-gradient(90deg, rgba(20,184,166,.28), rgba(20,184,166,.10)); color: #fff; box-shadow: inset 3px 0 0 #2dd4bf; }
.sb-foot { padding: .9rem 1.1rem; border-top: 1px solid rgba(255,255,255,.07); font-size: .75rem; color: #6f8394; }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 1020; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: .6rem 1rem; display: flex; align-items: center; gap: .75rem; }
.topbar .burger { border: 0; background: transparent; font-size: 1.6rem; line-height: 1; padding: .1rem .4rem; color: var(--ink); }
.topbar .ctx { min-width: 0; flex: 1; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.ctx-school { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-weight: 700; flex: none; }
.content { padding: 1.1rem; max-width: 1400px; margin: 0 auto; }

@media (min-width: 992px) {
  .sidebar { position: fixed !important; top: 0; bottom: 0; left: 0; width: var(--sb-w) !important; transform: none !important; visibility: visible !important; z-index: 1030; border: 0; }
  .main { margin-left: var(--sb-w); }
  .content { padding: 1.6rem 1.8rem 3rem; }
  .topbar { padding: .7rem 1.8rem; }
}

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1.1rem; }
.page-title { font-size: 1.45rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-sub { margin: .15rem 0 0; color: var(--muted); font-size: .85rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--card); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); font-weight: 600; padding: .9rem 1.1rem; }
.card-body { padding: 1.1rem; }

.stat { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.1rem; height: 100%; }
.stat .ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; flex: none; background: var(--brand-soft); color: var(--brand-dark); }
.stat .ic.blue { background: #e8f0fe; color: #1d4ed8; }
.stat .ic.amber { background: #fef3c7; color: #b45309; }
.stat .ic.violet { background: #efe9fe; color: #6d28d9; }
.stat .ic.rose { background: #ffe4e6; color: #be123c; }
.stat .num { font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .8rem; }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #f8fafc; border-bottom: 1px solid var(--line); white-space: nowrap; padding: .75rem 1rem; }
.table > tbody td { padding: .8rem 1rem; vertical-align: middle; border-color: var(--line); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f8fafc; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline; }
.badge-soft { padding: .35em .65em; border-radius: 999px; font-weight: 600; font-size: .72rem; }
.badge-soft.on { background: #dcfce7; color: #166534; }
.badge-soft.off { background: #f1f5f9; color: #64748b; }
.badge-soft.warn { background: #fef3c7; color: #92400e; }
.badge-soft.bad { background: #fee2e2; color: #991b1b; }
.badge-soft.info { background: #e0f2fe; color: #075985; }

/* Mobile: har row ek card ban jata hai */
@media (max-width: 767.98px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tbody tr { border: 1px solid var(--line); border-radius: 12px; margin: .75rem; width: auto; padding: .35rem 0; background: #fff; }
  .table-stack tbody td { display: flex; justify-content: space-between; gap: 1rem; align-items: center; border: 0; padding: .4rem .9rem; text-align: right; }
  .table-stack tbody td::before { content: attr(data-label); font-weight: 600; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; text-align: left; flex: none; }
  .table-stack tbody td.row-actions { justify-content: flex-end; border-top: 1px dashed var(--line); margin-top: .3rem; padding-top: .6rem; }
  .table-stack tbody td.row-actions::before { display: none; }
  .table-stack tbody td.no-label::before { display: none; }
  .table-stack tbody td.no-label { justify-content: center; }
}

/* ---------- Alerts ---------- */
.alert { border: 0; border-radius: 12px; box-shadow: var(--shadow); }
.alert-success { background: #dcfce7; color: #14532d; }
.alert-danger { background: #fee2e2; color: #7f1d1d; }
.alert ul { margin: 0; padding-left: 1.1rem; }

/* ---------- Checklist / misc ---------- */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: .7rem; padding: .65rem 0; border-bottom: 1px dashed var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist .dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .85rem; flex: none; background: #f1f5f9; color: #94a3b8; }
.checklist .done .dot { background: #dcfce7; color: #166534; }
.checklist .done span.t { color: var(--muted); text-decoration: line-through; }
.progress { height: 8px; border-radius: 999px; background: #e2e8f0; }
.progress-bar { background: var(--brand); }

.pager .page-link { border-radius: 8px; margin: 0 .15rem; color: var(--ink); border-color: var(--line); }
.pager .active .page-link { background: var(--brand); border-color: var(--brand); color: #fff; }

.matrix th, .matrix td { text-align: center; white-space: nowrap; }
.matrix th:first-child, .matrix td:first-child { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; }
.matrix thead th:first-child { background: #f8fafc; }
.matrix .grp td { background: #f8fafc; font-weight: 700; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: left; }

details.json > summary { cursor: pointer; color: var(--brand); font-weight: 500; }
details.json pre { background: #0f172a; color: #e2e8f0; padding: .75rem; border-radius: 10px; font-size: .75rem; margin: .5rem 0 0; white-space: pre-wrap; word-break: break-word; }

/* ---------- Auth / installer pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.auth-hero { display: none; background: radial-gradient(1200px 600px at 10% 0%, #14b8a6 0%, transparent 60%), linear-gradient(160deg, #0b1f2a, #0f3a45); color: #e6fffb; padding: 3rem; }
.auth-hero h2 { font-weight: 700; letter-spacing: -.02em; }
.auth-hero li { margin-bottom: .6rem; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 420px; }
@media (min-width: 992px) {
  .auth-wrap { grid-template-columns: 1.1fr 1fr; }
  .auth-hero { display: flex; flex-direction: column; justify-content: center; }
}
.pw-toggle { cursor: pointer; }

@media print {
  .sidebar, .topbar, .page-actions, .no-print { display: none !important; }
  .main { margin: 0 !important; }
  body { background: #fff; }
}

/* ---------- Student pages ---------- */
.stu-photo { width: 96px; height: 96px; border-radius: 18px; object-fit: cover; background: var(--brand-soft); border: 1px solid var(--line); flex: none; }
.stu-photo.ph { display: grid; place-items: center; font-size: 2.2rem; font-weight: 700; color: var(--brand-dark); }
.stu-photo.sm { width: 40px; height: 40px; border-radius: 12px; font-size: 1.05rem; }
.cam-box { width: 100%; max-width: 260px; aspect-ratio: 1 / 1; border-radius: 18px; background: #0f172a; overflow: hidden; position: relative; display: grid; place-items: center; color: #94a3b8; text-align: center; }
.cam-box video, .cam-box img, .cam-box canvas { width: 100%; height: 100%; object-fit: cover; display: block; position: absolute; inset: 0; }
.cam-box .msg { position: relative; padding: 1rem; font-size: .85rem; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: .45rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-weight: 500; font-size: .82rem; }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }
@media (max-width: 575.98px) { .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: .6rem; } }
.nav-tabs .nav-link { color: var(--muted); font-weight: 600; border: 0; border-bottom: 2px solid transparent; }
.nav-tabs .nav-link.active { color: var(--brand-dark); border-bottom-color: var(--brand); background: transparent; }
.nav-tabs { border-bottom: 1px solid var(--line); flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
.nav-tabs .nav-link { white-space: nowrap; }

/* ---------- Student 360 ---------- */
.s360-hero { display: flex; flex-wrap: wrap; gap: 1.1rem 1.4rem; align-items: center; padding: 1.25rem; border-radius: 18px; background: linear-gradient(120deg, #0f766e 0%, #115e59 55%, #134e4a 100%); color: #fff; box-shadow: 0 8px 24px rgba(15,118,110,.18); }
.s360-photo { width: 104px; height: 104px; border-radius: 22px; object-fit: cover; border: 3px solid rgba(255,255,255,.55); background: rgba(255,255,255,.15); flex: none; }
.s360-photo.ph { display: grid; place-items: center; font-size: 2.6rem; font-weight: 700; }
.s360-main { flex: 1 1 280px; min-width: 0; }
.s360-name { font-size: 1.5rem; font-weight: 700; margin: 0 0 .5rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.s360-name .badge-soft { font-size: .7rem; }
.s360-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.s360-chips span { background: rgba(255,255,255,.14); border-radius: 999px; padding: .2rem .7rem; font-size: .8rem; display: inline-flex; gap: .35rem; align-items: center; }
.s360-guard { font-size: .88rem; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.s360-guard .text-muted { color: rgba(255,255,255,.7) !important; }
.s360-guard .btn { --bs-btn-color: #fff; --bs-btn-border-color: rgba(255,255,255,.5); --bs-btn-hover-bg: rgba(255,255,255,.18); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: #fff; }
.s360-kpis { display: flex; gap: .75rem; }
.s360-kpi { background: #fff; color: var(--ink, #0f172a); border-radius: 14px; padding: .65rem 1rem; min-width: 104px; text-align: center; }
.s360-kpi .v { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.s360-kpi .l { font-size: .72rem; color: #64748b; text-transform: uppercase; letter-spacing: .05em; }
.s360-tabs { flex-wrap: nowrap; overflow-x: auto; gap: .35rem; padding-bottom: .25rem; border: 0; scrollbar-width: thin; }
.s360-tabs .nav-link { white-space: nowrap; display: inline-flex; align-items: center; gap: .4rem; border-radius: 999px; border: 1px solid var(--line, #e2e8f0); background: #fff; color: #475569; font-weight: 500; padding: .45rem .95rem; }
.s360-tabs .nav-link:hover { border-color: #0f766e; color: #0f766e; }
.s360-tabs .nav-link.active { background: #0f766e; border-color: #0f766e; color: #fff; }
.s360-tabs .nav-link.active .badge { color: #0f172a; }
@media (max-width: 575.98px) { .s360-hero { padding: 1rem; } .s360-photo { width: 80px; height: 80px; } .s360-kpis { width: 100%; } .s360-kpi { flex: 1; } }

/* Step 12: enquiry follow-up calendar */
.enq-cal{width:100%;table-layout:fixed;border-collapse:separate;border-spacing:3px}
.enq-cal th{font-size:.72rem;font-weight:600;color:#6b7280;text-align:center;padding:2px 0}
.enq-cal td{padding:0;height:46px;border-radius:8px;background:#f8fafc;vertical-align:top}
.enq-cal td.off{background:transparent}
.enq-cal td a{display:flex;flex-direction:column;align-items:center;justify-content:space-between;height:100%;padding:4px 2px;text-decoration:none;color:inherit;border-radius:8px}
.enq-cal td a:hover{background:#e0f2fe}
.enq-cal .dn{font-size:.82rem}
.enq-cal .cnt{font-size:.68rem;font-weight:700;color:#fff;background:#2563eb;border-radius:10px;min-width:18px;text-align:center;padding:0 5px;line-height:16px}
.enq-cal td.late .cnt{background:#dc2626}
.enq-cal td.today{outline:2px solid #2563eb}
.enq-cal td.sel{background:#dbeafe}
.enq-cal.mini td{height:38px}

/* Step 13: dashboard class-wise bars */
.dash-bar{display:flex;align-items:center;gap:10px;padding:4px 6px;border-radius:8px;font-size:.85rem}
.dash-bar:hover,.dash-bar.sel{background:#eff6ff}
.dash-bar .dl{width:90px;flex:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.dash-bar .db{flex:1;height:14px;border-radius:7px;background:#e5e7eb;display:flex;overflow:hidden}
.dash-bar .db .p{background:#16a34a}
.dash-bar .db .a{background:#dc2626}
.dash-bar .dn{width:64px;flex:none;text-align:right;color:#6b7280}

/* Step 16: dashboard redesign */
.dash-hero { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.4rem 1.5rem; border-radius: 18px; color: #fff;
  background: radial-gradient(900px 260px at 100% -40%, rgba(255,255,255,.18), transparent 60%), linear-gradient(120deg, #0f766e 0%, #115e59 55%, #134e4a 100%); box-shadow: 0 8px 24px rgba(15,118,110,.25); }
.dh-hi { font-size: 1.45rem; font-weight: 700; line-height: 1.2; } .dh-sub { opacity: .85; font-size: .9rem; margin-top: .2rem; }
.dh-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.dh-actions a { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem; border-radius: 999px; background: rgba(255,255,255,.16); color: #fff; text-decoration: none; font-size: .85rem; font-weight: 500; backdrop-filter: blur(4px); border: 1px solid rgba(255,255,255,.25); transition: background .15s; }
.dh-actions a:hover { background: rgba(255,255,255,.3); color: #fff; }
.kpi-tile { --kc: #0f766e; --kb: #e6f4f1; display: flex; flex-direction: column; gap: .15rem; height: 100%; padding: 1rem 1.1rem; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s; border: 1px solid transparent; }
.kpi-tile::after { content: ""; position: absolute; right: -22px; top: -22px; width: 84px; height: 84px; border-radius: 50%; background: var(--kb); opacity: .7; }
.kpi-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(15,23,42,.1); border-color: var(--kb); color: var(--ink); }
.kpi-tile .kt-ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--kb); color: var(--kc); font-size: 1.2rem; position: relative; z-index: 1; margin-bottom: .35rem; }
.kpi-tile .kt-v { font-size: 1.5rem; font-weight: 700; line-height: 1.1; position: relative; z-index: 1; }
.kpi-tile .kt-l { font-size: .78rem; color: var(--muted); position: relative; z-index: 1; }
.k-blue { --kc: #1d4ed8; --kb: #e8f0fe; } .k-violet { --kc: #6d28d9; --kb: #efe9fe; } .k-amber { --kc: #b45309; --kb: #fef3c7; } .k-teal { --kc: #0f766e; --kb: #dcf5ef; } .k-rose { --kc: #be123c; --kb: #ffe4e6; }
.dcard { border: 0; box-shadow: var(--shadow); border-radius: 16px; }
.dcard .dhead { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; padding: 1rem 1.15rem .6rem; }
.dcard .dt { font-weight: 650; font-size: .98rem; } .dcard .ds { font-size: .78rem; color: var(--muted); margin-top: .1rem; }
.chart { width: 100%; height: auto; display: block; } .chart .bar:hover rect:first-of-type { opacity: 1; filter: brightness(1.08); }
.funnel-row { display: flex; align-items: center; gap: .7rem; padding: .42rem .3rem; border-radius: 8px; text-decoration: none; color: var(--ink); font-size: .85rem; }
.funnel-row:hover { background: #f1f5f9; } .funnel-row .fl { width: 130px; flex: none; } .funnel-row .hbar { flex: 1; height: 10px; background: #eef2f6; border-radius: 6px; overflow: hidden; }
.funnel-row .hbar > span { display: block; height: 100%; border-radius: 6px; } .funnel-row .fv { width: 32px; text-align: right; font-weight: 650; }
.legend2 { display: flex; flex-wrap: wrap; justify-content: center; gap: .3rem 1rem; font-size: .82rem; } .legend2 i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
@media (max-width: 575.98px) { .dash-hero { padding: 1.1rem; } .dh-hi { font-size: 1.2rem; } .funnel-row .fl { width: 105px; } }
