/* Institute Manager web app — same look as the Android app (emerald + gold). */
:root {
  --primary: #0B6E4F;
  --primary-2: #0F8A63;
  --primary-dark: #074733;
  --on-primary: #fff;
  --primary-soft: #C6EEDB;
  --gold: #B7791F;
  --gold-soft: #FFE2A8;
  --bg: #F5F8F6;
  --card: #FFFFFF;
  --card-2: #EFF4F1;
  --text: #171D1A;
  --muted: #5B655F;
  --line: #DBE5DE;
  --present: #2E9E5B;
  --absent: #D64545;
  --leave: #D99A00;
  --late: #3D7BD9;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(11,110,79,.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #6BDBAE;
    --primary-2: #3FBF8E;
    --primary-dark: #0B6E4F;
    --on-primary: #00382A;
    --primary-soft: #0F5038;
    --gold: #F0BF5E;
    --gold-soft: #4A3500;
    --bg: #0F1512;
    --card: #18201C;
    --card-2: #1F2924;
    --text: #DEE5E0;
    --muted: #9AA59F;
    --line: #2D3832;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
#app { min-height: 100%; }

/* ---------- splash / logo ---------- */
.splash, .hero-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; flex-direction: column;
  background: linear-gradient(180deg, #0B6E4F, #074733); color: #fff; padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
}
.logo {
  width: 88px; height: 88px; border-radius: 50%; background: rgba(255,255,255,.16);
  display: flex; align-items: center; justify-content: center;
}
.logo::after {
  content: ""; width: 70px; height: 70px; border-radius: 50%; background: #fff center/40px no-repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%230B6E4F' d='M5 13.18v4L12 21l7-3.82v-4L12 17l-7-3.82zM12 3 1 9l11 6 9-4.91V17h2V9L12 3z'/%3E%3C/svg%3E");
}
.splash .logo { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.93); opacity: .8; } }

/* ---------- sign in ---------- */
.auth-card {
  width: 100%; max-width: 420px; background: var(--card); color: var(--text); border-radius: 26px;
  padding: 26px 22px; margin-top: 26px; box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.auth-title { font-size: 26px; font-weight: 700; margin: 14px 0 2px; text-align: center; }
.auth-sub { opacity: .85; text-align: center; margin: 0; }
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.input {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--card);
  outline: none; font-size: 16px; /* 16px stops iPhone zooming */
}
.input:focus { border-color: var(--primary); }
textarea.input { min-height: 120px; resize: vertical; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 64px; }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--primary); font-weight: 600; padding: 8px; }
.hint { font-size: 13px; color: var(--muted); }
.error-text { color: var(--absent); font-size: 14px; margin: 0 0 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px;
  padding: 12px 20px; font-weight: 600; background: var(--primary); color: var(--on-primary); cursor: pointer; min-height: 46px;
  text-decoration: none;
}
.btn:disabled { opacity: .55; }
.btn.block { width: 100%; }
.btn.tonal { background: var(--primary-soft); color: var(--text); }
.btn.outline { background: transparent; color: var(--primary); border: 1.5px solid var(--line); }
.btn.danger { background: transparent; color: var(--absent); border: 1.5px solid var(--line); }
.btn.small { min-height: 36px; padding: 7px 14px; font-size: 14px; }
.btn.ghost { background: transparent; color: var(--primary); padding: 8px 10px; min-height: 36px; }
.icon-btn { border: 0; background: transparent; width: 42px; height: 42px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--text); position: relative; cursor: pointer; }
.icon-btn:active { background: var(--card-2); }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- app frame ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--bg); background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
  padding: calc(8px + var(--safe-top)) 8px 8px 16px; display: flex; align-items: center; gap: 6px; border-bottom: 1px solid transparent;
}
.topbar.back { padding-left: 4px; }
.topbar .titles { flex: 1; min-width: 0; }
.topbar h1 { font-size: 20px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--absent); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: var(--on-primary);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex: none;
}
.avatar.big { width: 64px; height: 64px; font-size: 24px; }
main.page { padding: 12px 16px calc(96px + var(--safe-bottom)); max-width: 760px; margin: 0 auto; }
main.page.no-tabs { padding-bottom: calc(32px + var(--safe-bottom)); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-bottom));
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--muted);
  font-size: 11.5px; font-weight: 600; padding: 4px 0;
}
.tabbar a .pill { width: 56px; height: 30px; border-radius: 15px; display: flex; align-items: center; justify-content: center; }
.tabbar a.on { color: var(--text); }
.tabbar a.on .pill { background: var(--primary-soft); color: var(--primary); }
@media (prefers-color-scheme: dark) { .tabbar a.on .pill { color: var(--primary); } }

/* ---------- cards & lists ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin: 0 0 14px; overflow: hidden; }
.card.pad { padding: 16px; }
.card-title { font-size: 13px; font-weight: 700; color: var(--primary); text-transform: none; margin: 18px 4px 8px; letter-spacing: .2px; }
.hero {
  background: linear-gradient(160deg, var(--primary-2), var(--primary-dark)); color: #fff; border-radius: 22px; padding: 20px; margin: 0 0 14px;
}
@media (prefers-color-scheme: dark) { .hero { background: linear-gradient(160deg, #0F6B4E, #08402F); } }
.hero .k { opacity: .82; font-size: 13px; font-weight: 600; }
.hero .t { font-size: 22px; font-weight: 700; line-height: 1.25; margin-top: 2px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.stat { background: rgba(255,255,255,.14); border-radius: 14px; padding: 10px; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; opacity: .88; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.row:last-child { border-bottom: 0; }
.row.tap { cursor: pointer; }
.row.tap:active { background: var(--card-2); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .meta { font-size: 13px; color: var(--muted); }
.chev { color: var(--muted); flex: none; }
.ico { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.pill-tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--card-2); color: var(--muted); white-space: nowrap; }
.pill-tag.ok { background: color-mix(in srgb, var(--present) 16%, transparent); color: var(--present); }
.pill-tag.bad { background: color-mix(in srgb, var(--absent) 16%, transparent); color: var(--absent); }
.pill-tag.warn { background: color-mix(in srgb, var(--leave) 18%, transparent); color: var(--leave); }
.pill-tag.info { background: color-mix(in srgb, var(--late) 16%, transparent); color: var(--late); }
.pill-tag.gold { background: var(--gold-soft); color: var(--gold); }
.empty { text-align: center; color: var(--muted); padding: 40px 24px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.empty h3 { color: var(--text); margin: 0 0 6px; font-size: 18px; }
.error-box { text-align: center; padding: 36px 20px; }
.notice { background: var(--gold-soft); color: var(--text); border-radius: 14px; padding: 12px 14px; font-size: 14px; margin: 0 0 14px; }
.notice.green { background: var(--primary-soft); }

/* chips, segmented */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--text); }
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chip .d { display: block; font-size: 11px; font-weight: 600; opacity: .75; }
.seg { display: flex; background: var(--card-2); border-radius: 999px; padding: 4px; margin: 0 0 14px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 6px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.datenav { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--card); border-radius: 999px; padding: 4px; margin: 0 0 14px; box-shadow: var(--shadow); }
.datenav .label { font-weight: 700; text-align: center; flex: 1; }
.datenav .label small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }

/* timetable */
.lesson { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.lesson:last-child { border-bottom: 0; }
.lesson .time { width: 64px; flex: none; font-size: 12.5px; color: var(--muted); padding-top: 2px; }
.lesson .time b { display: block; color: var(--text); font-size: 15px; }
.lesson .what { flex: 1; min-width: 0; }
.lesson .subject { font-weight: 700; }
.lesson.now { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.lesson.break { background: var(--card-2); color: var(--muted); font-weight: 600; justify-content: center; font-size: 13px; padding: 8px; }
.lesson.free .subject { color: var(--muted); font-weight: 500; }
.cover { background: var(--gold-soft); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 14px; }
.cover h4 { margin: 0 0 6px; font-size: 15px; }
.cover div { font-size: 14px; }

/* diary */
.work { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.work:last-child { border-bottom: 0; }
.work .subj { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.work .wt { font-weight: 600; margin-top: 6px; }
.work .body { white-space: pre-wrap; margin-top: 4px; }
.work .none { color: var(--muted); font-size: 14px; margin-top: 4px; }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.file { display: inline-flex; align-items: center; gap: 6px; background: var(--card-2); border-radius: 10px; padding: 7px 10px; font-size: 13px; text-decoration: none; color: var(--text); max-width: 100%; }
.file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* attendance */
.reg-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.reg-row:last-child { border-bottom: 0; }
.reg-row .roll { width: 34px; color: var(--muted); font-size: 13px; flex: none; }
.reg-row .name { flex: 1; min-width: 0; font-weight: 600; }
.marks { display: flex; gap: 5px; flex: none; }
.mark { width: 38px; height: 38px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--card); font-weight: 700; font-size: 13px; cursor: pointer; color: var(--muted); }
.mark.on.present { background: var(--present); border-color: var(--present); color: #fff; }
.mark.on.absent { background: var(--absent); border-color: var(--absent); color: #fff; }
.mark.on.leave { background: var(--leave); border-color: var(--leave); color: #fff; }
.mark.on.late { background: var(--late); border-color: var(--late); color: #fff; }
.savebar { position: sticky; bottom: calc(76px + var(--safe-bottom)); z-index: 10; display: flex; gap: 10px; padding: 10px 0; }
main.no-tabs .savebar { bottom: calc(8px + var(--safe-bottom)); }
.counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 14px; }
.count { background: var(--card); border-radius: 14px; padding: 10px; text-align: center; box-shadow: var(--shadow); }
.count b { display: block; font-size: 20px; }
.count span { font-size: 12px; color: var(--muted); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 14px; }
.cal .h { text-align: center; font-size: 11px; color: var(--muted); font-weight: 700; }
.cal .d { aspect-ratio: 1; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }
.cal .d.present { background: color-mix(in srgb, var(--present) 20%, transparent); color: var(--present); }
.cal .d.absent { background: var(--absent); color: #fff; }
.cal .d.leave { background: color-mix(in srgb, var(--leave) 25%, transparent); color: var(--leave); }
.cal .d.late { background: color-mix(in srgb, var(--late) 20%, transparent); color: var(--late); }

/* results */
.grade { width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; background: var(--gold-soft); color: var(--gold); flex: none; }
.bar { height: 6px; border-radius: 3px; background: var(--card-2); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--primary); border-radius: 3px; }

/* master timetable */
.master-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin: 0 0 12px; }
table.master { border-collapse: collapse; font-size: 11.5px; min-width: 100%; }
table.master th, table.master td { border: 1px solid var(--line); padding: 5px 6px; text-align: center; vertical-align: middle; }
table.master th { background: var(--primary-soft); position: sticky; top: 0; }
table.master th small { display: block; font-weight: 500; color: var(--muted); font-size: 10px; }
table.master td.lbl { font-weight: 700; min-width: 86px; background: var(--card); position: sticky; left: 0; }
table.master td.cell { min-width: 112px; }
table.master td.cell div { margin: 1px 0; }
table.master td.recess, table.master th.recess { background: var(--card-2); min-width: 22px; width: 22px; padding: 2px; font-size: 9px; color: var(--muted); writing-mode: vertical-rl; text-orientation: upright; letter-spacing: -1px; }
.master-heading { text-align: center; font-weight: 700; margin: 4px 0 10px; }

/* notifications */
.note { display: flex; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.note:last-child { border-bottom: 0; }
.note.unread { background: color-mix(in srgb, var(--primary) 7%, transparent); }
.note .grow { flex: 1; min-width: 0; }
.note .nt { font-weight: 700; display: flex; gap: 8px; align-items: center; }
.note .nt .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); flex: none; margin-left: auto; }
.note .nb { white-space: pre-wrap; color: var(--muted); font-size: 14px; margin-top: 2px; }
.note .nm { font-size: 12px; color: var(--muted); margin-top: 4px; }
.status-ok { color: var(--present); }
.status-bad { color: var(--absent); }

/* install banner */
.install { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; box-shadow: var(--shadow); border: 1.5px dashed var(--primary); }
.install .grow { flex: 1; font-size: 14px; }
.share-ico { display: inline-block; vertical-align: -3px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%); z-index: 99;
  background: #222; color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 14px; max-width: calc(100% - 32px);
  box-shadow: 0 6px 24px rgba(0,0,0,.3); animation: toast .25s ease-out;
}
@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } }
.fade-in { animation: fadein .18s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }
.svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.svg.sm { width: 18px; height: 18px; }
