:root {
  --bg: #E6EBF3;
  --card: #FFFFFF;
  --ink: #1F2A3C;
  --muted: #667085;
  --line: #DDE3EE;
  --primary: #F28A1E;
  --primary-dark: #D97706;
  --teal: #0E4A57;
  --teal-dark: #0A3943;
  --sun: #FFC93C;
  --danger: #D92D3A;
  --ok: #1E9E62;
  --radius: 14px;
  --shadow: 0 2px 8px rgba(31, 42, 60, .08);
  --side: 92px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 16px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 24px; padding: 28px 24px; box-shadow: var(--shadow); text-align: center; }
.logo { width: 76px; height: 76px; margin: 0 auto 10px; }
.login-card h1 { font-size: 26px; font-weight: 800; }
.login-card p.sub { color: var(--muted); margin: 6px 0 22px; }
.field { text-align: left; margin-bottom: 14px; }
.field label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; background: #F7F9FC;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); }
.field textarea { min-height: 96px; resize: vertical; }
.hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.err { color: var(--danger); font-weight: 600; font-size: 14px; min-height: 20px; margin: 4px 0 8px; }
.setup-box { text-align: left; background: #FFF3CD; color: #5c4600; border-radius: 12px; padding: 14px; font-size: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; cursor: pointer; font-weight: 800;
  padding: 12px 18px; border-radius: 12px; background: var(--primary); color: #fff; }
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--ink); border: 2px solid var(--line); }
.btn.ghost:hover { background: var(--line); }
.btn.small { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn.danger { background: var(--danger); }

/* ---------- Shell (eduTinker-style) ---------- */
body { background: var(--bg); }
.login-wrap { background: linear-gradient(160deg, var(--teal-dark), var(--teal) 55%, #12687a); }
.login-card { border-radius: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.28); }
.login-card h1 { color: var(--teal); }
.topbar { position: sticky; top: 0; z-index: 30; background: #fff; color: var(--ink); padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 10px; box-shadow: 0 1px 0 var(--line); }
.topbar .logo-s { width: 38px; height: 38px; border-radius: 10px; flex: none; }
.topbar .brand { font-weight: 800; font-size: 19px; flex: 1; min-width: 0; color: var(--ink); }
.topbar .brand small { display: block; font-weight: 600; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .tb { display: flex; flex-direction: column; align-items: center; gap: 1px; background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 11px; font-weight: 700; padding: 0 4px; }
.topbar .tb i { font-style: normal; width: 34px; height: 34px; border-radius: 50%; background: #FDE9D2; display: grid; place-items: center; font-size: 17px; }
.tabs { position: sticky; top: calc(58px + env(safe-area-inset-top)); z-index: 25; display: flex; gap: 2px; overflow-x: auto; padding: 8px 8px; background: var(--teal);
  scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; width: 74px; border: 0; background: transparent; color: #fff; border-radius: 12px; padding: 6px 2px 5px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tab .ico { width: 38px; height: 38px; border-radius: 50%; background: var(--primary); display: grid; place-items: center; font-size: 18px; }
.tab .lbl { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; line-height: 1.1; text-align: center; }
.tab.on { background: rgba(255,255,255,.16); }
.tab.on .ico { box-shadow: 0 0 0 3px rgba(255,255,255,.55); }
main { max-width: 980px; margin: 0 auto; padding: 14px 12px 110px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { border-radius: 12px; color: #fff; display: flex; overflow: hidden; box-shadow: var(--shadow); cursor: pointer; border: 0; text-align: left; padding: 0; }
.stat .a { padding: 12px; font-weight: 800; font-size: 15px; flex: 1; display: flex; align-items: center; }
.stat .b { padding: 10px 12px; background: rgba(0,0,0,.2); min-width: 64px; display: flex; flex-direction: column; justify-content: center; }
.stat .b small { font-size: 11px; opacity: .85; }
.stat .b strong { font-size: 22px; line-height: 1.1; }
.stat.c1 { background: #1E88E5; } .stat.c2 { background: #00796B; } .stat.c3 { background: #6A3FB5; } .stat.c4 { background: #C2410C; }
.greet { font-size: 13px; color: var(--muted); margin: 0 2px 10px; font-weight: 600; }

@media (min-width: 900px) {
  body { padding-left: var(--side); }
  .tabs { position: fixed; left: 0; top: 0; bottom: 0; width: var(--side); flex-direction: column; overflow-y: auto; padding: 14px 6px; gap: 6px; }
  .tab { width: 100%; }
  .topbar { position: sticky; }
  main { padding-bottom: 60px; }
}

.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filters select { padding: 9px 12px; border-radius: 10px; border: 2px solid var(--line); background: var(--card); }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 12px; border-top: 4px solid var(--c, var(--primary)); }
.card.past { opacity: .6; }
.card .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--c, #888) 16%, transparent); color: var(--c, var(--ink)); }
.chip.plain { --c: var(--muted); }
.card h3 { font-size: 18px; margin: 8px 0 2px; }
.card .when { color: var(--muted); font-size: 14px; font-weight: 600; }
.card .body { white-space: pre-wrap; margin-top: 8px; word-break: break-word; }
.card .meta { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; color: var(--muted); font-size: 13px; gap: 8px; }
.card .del { background: none; border: 0; color: var(--danger); font-weight: 700; cursor: pointer; padding: 4px 6px; }
.media { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.media img, .media video { width: 100%; height: 150px; object-fit: cover; border-radius: 12px; background: #000; display: block; }
.media video { grid-column: span 2; height: auto; max-height: 320px; }
.media a.file { display: flex; align-items: center; gap: 8px; padding: 12px; border: 2px dashed var(--line); border-radius: 12px; color: var(--ink); text-decoration: none; font-weight: 700; word-break: break-all; }
.empty { text-align: center; color: var(--muted); padding: 50px 16px; }
.empty .big { font-size: 46px; }
.section-title { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 800; margin: 18px 4px 8px; }

.fab { position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 35; background: var(--primary); color: #fff; border: 0; border-radius: 999px; padding: 15px 22px;
  font-weight: 800; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); cursor: pointer; }

/* ---------- Modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(20, 20, 30, .55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--card); border-radius: 22px 22px 0 0; padding: 20px 18px calc(22px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .overlay { align-items: center; } .sheet { border-radius: 22px; } }
.sheet h2 { font-size: 21px; margin-bottom: 14px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 6px; }
.sheet .actions .btn { flex: 1; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checks { display: grid; gap: 6px; }
.checks .grp { font-weight: 800; font-size: 13px; color: var(--muted); margin-top: 6px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; margin-right: 12px; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.progress > i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .2s; }

/* ---------- Admin tables ---------- */
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.panel h2 { font-size: 18px; margin-bottom: 4px; }
.panel p.sub { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.bad { color: var(--danger); font-weight: 700; }
code { background: var(--bg); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.pill { font-size: 12px; font-weight: 800; padding: 2px 9px; border-radius: 99px; background: var(--line); }
.pill.ok { background: #D8F3E6; color: #0F6B3F; }
.pill.off { background: #FDE0E2; color: #A41B27; }

#toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg);
  padding: 11px 18px; border-radius: 999px; font-weight: 700; opacity: 0; pointer-events: none; transition: .25s; z-index: 80; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Attendance / fees / leave ---------- */
.att-sum { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.att-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.att-name { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.att-btns { display: flex; gap: 6px; flex: none; }
.att-b { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--c); background: #fff; color: var(--c); font-weight: 800; cursor: pointer; }
.att-b.on { background: var(--c); color: #fff; }
.fee-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.fee-item > div:last-child { display: flex; gap: 6px; align-items: center; flex: none; }

/* ---------- Easier navigation ---------- */
.hidden { display: none !important; }
.topbar .tb.back i { background: var(--teal); color: #fff; font-size: 24px; line-height: 1; padding-bottom: 3px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 8px; border-radius: 14px; border: 2px solid var(--line); background: #fff; font-weight: 800; font-size: 15px; cursor: pointer; }
.tile .ico { width: 54px; height: 54px; border-radius: 50%; background: var(--primary); display: grid; place-items: center; font-size: 26px; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.quick .q { display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: 14px; border: 0; background: #fff; box-shadow: var(--shadow); font-weight: 800; font-size: 15px; text-align: left; cursor: pointer; }
.quick .q span { width: 38px; height: 38px; border-radius: 50%; background: var(--primary); display: grid; place-items: center; font-size: 19px; flex: none; }
.pick { margin-bottom: 10px; }
.pick-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.pk { padding: 10px 16px; border-radius: 999px; border: 2px solid var(--line); background: #fff; font-weight: 800; font-size: 15px; cursor: pointer; }
.pk.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn { min-height: 44px; }
@media (max-width: 899px) {
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 40; justify-content: space-around; overflow: visible; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -2px 10px rgba(0,0,0,.2); }
  .tab { width: auto; flex: 1; min-width: 0; padding: 3px 0; }
  .tab .ico { width: 34px; height: 34px; font-size: 17px; }
  .tab .lbl { font-size: 10px; }
  main { padding-bottom: 130px; }
  .fab { bottom: calc(86px + env(safe-area-inset-bottom)); }
  #toast { bottom: calc(150px + env(safe-area-inset-bottom)); }
}

.fee-block { border-bottom: 1px solid var(--line); }
.fee-block .fee-item { border-bottom: 0; }
.pay-line { font-size: 13px; color: var(--muted); padding: 0 0 8px 12px; }
.linkbtn { background: none; border: 0; color: var(--teal); font-weight: 800; cursor: pointer; text-decoration: underline; padding: 0 4px; }

/* ---------- Chat, badges ---------- */
.chat { max-height: 52vh; min-height: 160px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 6px 2px; }
.bub { max-width: 85%; align-self: flex-start; background: #EEF1F7; border-radius: 14px 14px 14px 4px; padding: 8px 12px; overflow-wrap: anywhere; }
.bub small { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.bub.me { align-self: flex-end; background: #DDF1EE; border-radius: 14px 14px 4px 14px; }
.chat-in { display: flex; gap: 8px; margin-top: 10px; }
.chat-in input { flex: 1; min-width: 0; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; }
.dot { position: absolute; top: -4px; right: -6px; min-width: 18px; height: 18px; border-radius: 9px; background: #D92D3A; color: #fff; font-size: 11px; font-style: normal; display: grid; place-items: center; padding: 0 4px; }
.tab .ico, .tile .ico { position: relative; }
