/* ===== J.S.K Memorial Public School - Panel UI ===== */
:root {
  --primary: #4f46e5; --primary-2: #7c3aed; --primary-soft: #eef2ff;
  --accent: #f59e0b; --success: #10b981; --danger: #ef4444; --info: #0ea5e9; --warn: #f59e0b;
  --bg: #f4f6fb; --card: #ffffff; --text: #1e1b4b; --muted: #6b7280; --border: #e5e7f0;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 6px 24px rgba(16,24,40,.06);
  --radius: 16px; --sidebar: 264px;
  --grad: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
}
[data-theme="dark"] {
  --bg: #0f1020; --card: #181a2e; --text: #e8e9f5; --muted: #9a9cb8; --border: #2a2d48;
  --primary-soft: #23244a; --shadow: 0 6px 24px rgba(0,0,0,.35);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.material-symbols-rounded { font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24; font-size: 22px; vertical-align: middle; }

/* ===== Login ===== */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero {
  background: var(--grad); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-hero::before, .login-hero::after {
  content: ''; position: absolute; border-radius: 50%; background: rgba(255,255,255,.08);
}
.login-hero::before { width: 420px; height: 420px; right: -120px; top: -120px; }
.login-hero::after { width: 300px; height: 300px; left: -80px; bottom: -100px; }
.login-hero h1 { font-size: 40px; line-height: 1.15; font-weight: 800; margin: 18px 0 12px; position: relative; }
.login-hero p { opacity: .85; max-width: 440px; position: relative; }
.hero-feats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; position: relative; max-width: 460px; }
.hero-feats div { background: rgba(255,255,255,.12); padding: 12px 14px; border-radius: 12px; display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: 13px; backdrop-filter: blur(6px); }
.login-box { display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-card { width: 100%; max-width: 400px; }
.login-card h2 { font-size: 26px; font-weight: 800; }
.login-card .sub { color: var(--muted); margin: 4px 0 26px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; }
.logo { width: 44px; height: 44px; border-radius: 12px; background: #fff; color: var(--primary); display: grid; place-items: center; font-weight: 800; font-size: 15px; flex-shrink: 0; }
.logo.sm { width: 38px; height: 38px; font-size: 13px; background: var(--grad); color: #fff; }

/* ===== Layout ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); background: var(--card); border-right: 1px solid var(--border); position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column; z-index: 50; transition: transform .25s ease, width .25s ease;
}
.sidebar .brand { padding: 20px 20px 16px; }
.sidebar .brand small { display: block; font-weight: 500; color: var(--muted); font-size: 11.5px; }
.sidebar .brand span.t { font-size: 14px; line-height: 1.2; }
.nav { flex: 1; overflow-y: auto; padding: 6px 12px 16px; }
.nav .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 12px 6px; font-weight: 700; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--muted); font-weight: 600;
  margin-bottom: 2px; transition: .15s; white-space: nowrap;
}
.nav a:hover { background: var(--primary-soft); color: var(--primary); }
.nav a.active { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.3); }
.side-foot { padding: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; font-size: 14px; }
.user-chip .n { font-weight: 700; font-size: 13.5px; line-height: 1.2; }
.user-chip .r { font-size: 12px; color: var(--muted); text-transform: capitalize; }

.main { flex: 1; margin-left: var(--sidebar); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 66px; display: flex; align-items: center; gap: 12px; padding: 0 28px; position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 19px; font-weight: 800; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); display: grid; place-items: center; cursor: pointer; color: var(--text); flex-shrink: 0; }
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }
#menuBtn { display: none; }
.content { padding: 24px 28px 40px; flex: 1; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== Components ===== */
.grid { display: grid; gap: 18px; }
.g4 { grid-template-columns: repeat(4, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g2 { grid-template-columns: repeat(2, 1fr); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card h3 { font-size: 16px; font-weight: 800; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
.stat { display: flex; align-items: center; gap: 16px; position: relative; overflow: hidden; }
.stat .ic { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; }
.stat .ic .material-symbols-rounded { font-size: 26px; }
.stat .v { font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 13px; font-weight: 600; }
.c-indigo { background: #eef2ff; color: #4f46e5; } .c-green { background: #ecfdf5; color: #059669; }
.c-amber { background: #fffbeb; color: #d97706; } .c-rose { background: #fff1f2; color: #e11d48; }
.c-sky { background: #f0f9ff; color: #0284c7; } .c-violet { background: #f5f3ff; color: #7c3aed; }
[data-theme="dark"] .c-indigo, [data-theme="dark"] .c-green, [data-theme="dark"] .c-amber,
[data-theme="dark"] .c-rose, [data-theme="dark"] .c-sky, [data-theme="dark"] .c-violet { background: rgba(255,255,255,.06); }

.welcome { background: var(--grad); color: #fff; border: 0; position: relative; overflow: hidden; }
.welcome::after { content: ''; position: absolute; width: 260px; height: 260px; border-radius: 50%; background: rgba(255,255,255,.1); right: -60px; top: -90px; }
.welcome h2 { font-size: 22px; font-weight: 800; } .welcome p { opacity: .9; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px; border-radius: 11px;
  border: 1px solid transparent; font-weight: 700; cursor: pointer; transition: .15s; white-space: nowrap; font-size: 14px;
}
.btn .material-symbols-rounded { font-size: 19px; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 4px 14px rgba(79,70,229,.28); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-light { background: var(--card); border-color: var(--border); color: var(--text); }
.btn-light:hover { border-color: var(--primary); color: var(--primary); }
.btn-success { background: var(--success); color: #fff; } .btn-danger { background: var(--danger); color: #fff; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12.5px; border-radius: 9px; }
.btn-block { width: 100%; height: 46px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; font-size: 12.5px; margin-bottom: 6px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; height: 44px; padding: 0 14px; border: 1.5px solid var(--border); border-radius: 11px; background: var(--card); outline: none; transition: .15s;
}
textarea.input { height: auto; min-height: 100px; padding: 12px 14px; resize: vertical; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,70,229,.12); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .input { width: auto; min-width: 160px; height: 40px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.search { position: relative; } .search .material-symbols-rounded { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 20px; }
.search .input { padding-left: 40px; width: 100%; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; margin-right: 16px; padding: 6px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 12px 14px; background: var(--bg); font-weight: 700; white-space: nowrap; }
td { padding: 12px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .material-symbols-rounded { font-size: 46px; opacity: .4; display: block; margin-bottom: 6px; }
.person { display: flex; align-items: center; gap: 10px; }
.person .avatar { width: 34px; height: 34px; font-size: 12.5px; }
.person b { display: block; font-size: 14px; } .person small { color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 30px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.b-green { background: #dcfce7; color: #15803d; } .b-red { background: #fee2e2; color: #b91c1c; } .b-amber { background: #fef3c7; color: #b45309; }
.b-blue { background: #e0e7ff; color: #4338ca; } .b-gray { background: #f1f5f9; color: #475569; } .b-sky { background: #e0f2fe; color: #0369a1; }
[data-theme="dark"] .badge { background: rgba(255,255,255,.08); }

/* Attendance toggles */
.att-btns { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 2px; }
.att-btns button { border: 0; background: transparent; width: 38px; height: 32px; border-radius: 8px; font-weight: 800; cursor: pointer; color: var(--muted); }
.att-btns button.on.P { background: var(--success); color: #fff; } .att-btns button.on.A { background: var(--danger); color: #fff; }
.att-btns button.on.L { background: var(--warn); color: #fff; } .att-btns button.on.H { background: var(--info); color: #fff; }
.att-summary { display: flex; gap: 8px; flex-wrap: wrap; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal div { aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--bg); }
.cal .P { background: #dcfce7; color: #15803d; } .cal .A { background: #fee2e2; color: #b91c1c; } .cal .L { background: #fef3c7; color: #b45309; } .cal .H { background: #e0f2fe; color: #0369a1; }
.cal .hd { background: transparent; color: var(--muted); font-size: 11px; aspect-ratio: auto; }

/* Bars chart */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .b i { width: 100%; max-width: 38px; border-radius: 8px 8px 4px 4px; background: var(--grad); min-height: 4px; transition: height .6s ease; }
.bars .b span { font-size: 11px; color: var(--muted); font-weight: 600; }
.bars .b em { font-style: normal; font-size: 11px; font-weight: 700; }

.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.list-item:last-child { border: 0; }
.list-item .meta { flex: 1; min-width: 0; } .list-item .meta b { display: block; font-size: 13.5px; }
.list-item .meta small { color: var(--muted); }
.notice { border-left: 4px solid var(--primary); padding: 12px 16px; background: var(--bg); border-radius: 10px; margin-bottom: 10px; }
.notice b { display: block; } .notice small { color: var(--muted); }

#map, .map { height: 460px; border-radius: 14px; border: 1px solid var(--border); z-index: 1; }
.tabs { display: flex; gap: 6px; background: var(--card); border: 1px solid var(--border); padding: 5px; border-radius: 13px; margin-bottom: 18px; overflow-x: auto; width: fit-content; max-width: 100%; }
.tabs button { border: 0; background: transparent; padding: 8px 16px; border-radius: 9px; font-weight: 700; cursor: pointer; color: var(--muted); white-space: nowrap; }
.tabs button.on { background: var(--grad); color: #fff; }
.muted { color: var(--muted); } .mt { margin-top: 18px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.money { font-weight: 800; font-variant-numeric: tabular-nums; }
.pill-status { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #cbd5e1; margin-right: 6px; }
.pill-status.on { background: var(--success); box-shadow: 0 0 0 4px rgba(16,185,129,.2); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,16,40,.55); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
.modal { background: var(--card); border-radius: 20px; width: 100%; max-width: 640px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.modal.lg { max-width: 860px; }
.modal-h { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-h h3 { font-size: 17px; font-weight: 800; }
.modal-b { padding: 20px 22px; overflow-y: auto; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* Toast & loader */
#toasts { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--card); padding: 12px 18px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); animation: fade .2s; max-width: 340px; display: flex; gap: 8px; align-items: center; }
.toast.err { background: var(--danger); color: #fff; } .toast.ok { background: var(--success); color: #fff; }
.loader { display: grid; place-items: center; padding: 60px; }
.loader::after { content: ''; width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.bottom-nav { display: none; }
.overlay { display: none; }

/* Receipt print */
.receipt { max-width: 560px; margin: auto; }
.receipt .rh { text-align: center; border-bottom: 2px dashed var(--border); padding-bottom: 12px; margin-bottom: 12px; }
.receipt table td { border: 0; padding: 6px 0; }
@media print {
  body * { visibility: hidden; } .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; inset: 0; padding: 30px; background: #fff; color: #000; }
}

/* ===== Tablet ===== */
@media (max-width: 1180px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1024px) {
  :root { --sidebar: 84px; }
  .sidebar .brand .t, .sidebar .brand small, .nav a span:not(.material-symbols-rounded), .nav .grp, .user-chip .info { display: none; }
  .sidebar .brand { justify-content: center; padding: 18px 0; }
  .nav a { justify-content: center; padding: 12px; }
  .user-chip { justify-content: center; } .side-foot .btn { display: none; }
  .login-wrap { grid-template-columns: 1fr; } .login-hero { display: none; }
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
  :root { --sidebar: 280px; }
  .sidebar { transform: translateX(-100%); box-shadow: 20px 0 60px rgba(0,0,0,.2); }
  .sidebar .brand .t, .sidebar .brand small, .nav a span:not(.material-symbols-rounded), .nav .grp, .user-chip .info { display: revert; }
  .sidebar .brand { justify-content: flex-start; padding: 20px; } .nav a { justify-content: flex-start; padding: 10px 12px; }
  .user-chip { justify-content: flex-start; } .side-foot .btn { display: inline-flex; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
  .main { margin-left: 0; padding-bottom: 72px; }
  #menuBtn { display: grid; }
  .topbar { padding: 0 14px; height: 60px; } .topbar h1 { font-size: 17px; }
  .content { padding: 16px 14px 30px; }
  .g4, .g3, .g2 { grid-template-columns: 1fr 1fr; gap: 12px; }
  .g2.stack, .g3.stack { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; border-radius: 14px; }
  .stat { flex-direction: column; align-items: flex-start; gap: 10px; } .stat .ic { width: 42px; height: 42px; } .stat .v { font-size: 20px; }
  .toolbar .input, .toolbar .btn { flex: 1 1 auto; min-width: 0; }
  .toolbar .grow { flex-basis: 100%; }
  /* tables -> cards */
  .table-wrap { border: 0; overflow: visible; }
  table.rt, table.rt tbody, table.rt tr, table.rt td { display: block; width: 100%; }
  table.rt thead { display: none; }
  table.rt tr { background: var(--card); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 10px; padding: 8px 14px; box-shadow: var(--shadow); }
  table.rt td { border: 0; padding: 7px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  table.rt td::before { content: attr(data-label); font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; text-align: left; }
  table.rt td.first { border-bottom: 1px dashed var(--border); padding-bottom: 10px; margin-bottom: 4px; justify-content: flex-start; text-align: left; }
  table.rt td.first::before { display: none; }
  tr:hover td { background: transparent; }
  .modal-bg { align-items: end; padding: 0; } .modal { border-radius: 20px 20px 0 0; max-height: 94vh; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--border); z-index: 35;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 700; color: var(--muted); padding: 4px 0; border-radius: 10px; }
  .bottom-nav a.active { color: var(--primary); } .bottom-nav a.active .material-symbols-rounded { font-variation-settings: 'FILL' 1; }
  #map, .map { height: 360px; }
  #toasts { left: 12px; right: 12px; } .toast { max-width: none; }
}
@media (max-width: 380px) { .g4, .g3, .g2 { grid-template-columns: 1fr; } }
