/* NUSTAS – NUST Attendance System */
:root {
  color-scheme: light;
  --navy: #173c63; --navy-2: #24527d; --gold: #c89b32; --gold-2: #c89b32;
  --bg: #f6f6f3; --card: #fff; --card-2: #f1f2ef; --text: #242925; --muted: #626b64; --line: #daddd7;
  --ok: #286242; --ok-bg: #eaf3ec; --err: #a13632; --err-bg: #f9ece9; --warn: #825b19; --warn-bg: #fbf2df; --info: #2c5275; --info-bg: #edf2f6;
  --link: #24527d; --shadow: none; --shadow-lg: 0 8px 24px #00000014;
  --radius: 6px; --ease: ease;
}
[data-theme="dark"] {
  color-scheme: dark;
  --navy: #21496d; --navy-2: #2d5c85;
  --bg: #191c1b; --card: #202422; --card-2: #272c29; --text: #edf0eb; --muted: #a8b0a9; --line: #39413b;
  --ok: #9accab; --ok-bg: #22392b; --err: #f0aca3; --err-bg: #412927; --warn: #e2c17e; --warn-bg: #3b3424; --info: #aac9e6; --info-bg: #253442;
  --link: #aac9e6; --shadow-lg: 0 8px 24px #00000033;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; padding-bottom: env(safe-area-inset-bottom); }
html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after { transition: background-color .4s, color .4s, border-color .4s, box-shadow .4s !important; }
h1 { font-size: 28px; line-height: 1.15; margin: 0 0 4px; letter-spacing: -.3px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
a { color: var(--link); }
.muted { color: var(--muted); } .small { font-size: 13px; } .hide { display: none !important; } .mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.mt { margin-top: 14px; } .tight { margin: 0; } h2.section { margin-top: 28px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 20px 0 14px; }

/* header */
.site-header { position: sticky; top: 0; z-index: 30; background: var(--card); color: var(--text); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); box-shadow: none; }
.site-header .inner { max-width: 1120px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand .logo { width: 40px; height: 40px; border-radius: 6px; background: var(--gold); color: var(--navy); display: grid; place-items: center; font-weight: 650; font-size: 21px; transition: transform .4s var(--ease); }
.brand:hover .logo { transform: none; }
.brand b { display: block; font-size: 18px; letter-spacing: .4px; line-height: 1.1; }
.brand small { display: block; font-size: 11px; opacity: .8; letter-spacing: .4px; }
.spacer { flex: 1; }
.nav { display: flex; gap: 4px; margin-left: 14px; }
.nav a { color: var(--muted); text-decoration: none; padding: 7px 12px; border-radius: 6px; font-weight: 600; font-size: 14px; transition: background .2s, color .2s; }
.nav a:hover, .nav a.on { background: var(--card-2); color: var(--text); }
.userbox { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.userbox .who { text-align: right; line-height: 1.2; } .userbox .who small { display: block; opacity: .75; font-size: 12px; }
.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 6px; border: 1px solid var(--line); background: transparent; color: var(--text); cursor: pointer; display: grid; place-items: center; transition: background .2s, transform .2s; }
.icon-btn:hover { background: var(--card-2); } .icon-btn:active { transform: none; }
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-btn .sun, .theme-btn .moon { position: absolute; transition: transform .6s var(--ease), opacity .4s; }
[data-theme="light"] .theme-btn .moon { transform: rotate(-90deg) scale(.3); opacity: 0; }
[data-theme="dark"] .theme-btn .sun { transform: rotate(90deg) scale(.3); opacity: 0; }
.badge-dot { position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 4px; background: var(--gold); color: #251a00; font-size: 11px; font-weight: 650; display: grid; place-items: center;  }
.badge-dot.ring {  }
.bell-wrap { position: relative; }
.panel { position: absolute; right: 0; top: 48px; width: min(360px, 92vw); background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow-lg); padding: 14px;  transform-origin: top right; z-index: 40; }
.panel h3 { margin: 0 0 8px; }
.note-item { display: flex; gap: 10px; padding: 10px; border-radius: 6px; margin-bottom: 6px; background: var(--card-2); }
.note-item.soon { background: var(--warn-bg); }
.note-item .when { margin-left: auto; font-weight: 700; white-space: nowrap; font-size: 13px; }
.site-header .btn.ghost { color: var(--text); border-color: var(--line); }
.site-header .btn.ghost:hover { background: var(--card-2); }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 26px 20px 48px; flex: 1; }
.site-footer { text-align: center; color: var(--muted); font-size: 12px; padding: 14px; }
.page {  }
.stagger > * {   }

/* cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.grid .card { margin: 0; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; } .row > .field { flex: 1 1 170px; } .row.center { align-items: center; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.back { display: inline-block; margin-bottom: 8px; font-size: 14px; text-decoration: none; }
.course-card { display: block; text-decoration: none; color: inherit; position: relative; overflow: hidden; transition: transform .25s var(--ease), box-shadow .25s, border-color .25s; }
.course-card::before { display: none; content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line); }
.course-card:hover { transform: none; box-shadow: var(--shadow-lg); border-color: var(--navy-2); }
.course-card .code { font-size: 21px; font-weight: 650; color: var(--link); letter-spacing: .3px; }
.stat-row { display: flex; gap: 22px; margin-top: 12px; flex-wrap: wrap; }
.stat b { display: block; font-size: 23px; line-height: 1.1; } .stat span { font-size: 12px; color: var(--muted); letter-spacing: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }

/* forms */
.field { display: flex; flex-direction: column; gap: 5px; }
label { font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; width: 100%; transition: border-color .2s, box-shadow .2s, background .2s; }
textarea { min-height: 110px; resize: vertical; font-size: 14px; }
textarea.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 2px color-mix(in srgb, var(--link) 18%, transparent); background: var(--card); }
.hint { font-size: 12px; color: var(--muted); }
.code-input { text-transform: uppercase; letter-spacing: .25em; font: 700 20px ui-monospace, Menlo, Consolas, monospace; text-align: center; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-weight: 700; border-radius: 6px; padding: 11px 18px; border: 1px solid var(--line); cursor: pointer; text-decoration: none; background: var(--card); color: var(--text); white-space: nowrap; transition: transform .15s var(--ease), box-shadow .2s, filter .2s, background .2s; }
.btn:hover { box-shadow: none; transform: none; } .btn:active { transform: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.primary { background: var(--navy); color: #fff; border-color: transparent; }
.btn.gold { background: var(--gold); color: #251a00; border-color: transparent; }
.btn.ok { background: var(--ok); color: #fff; border-color: transparent; } [data-theme="dark"] .btn.ok { color: #06220f; }
.btn.danger { background: var(--err-bg); color: var(--err); border-color: transparent; }
.btn.ghost { background: transparent; } .btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 6px; } .btn.block { width: 100%; } .btn.lg { padding: 16px 22px; font-size: 17px; border-radius: 6px; }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; width: 18px; height: 18px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%;  }

/* alerts, badges */
.alert { padding: 12px 15px; border-radius: 6px; font-size: 14px; margin: 0 0 14px;  }
.alert.error { background: var(--err-bg); color: var(--err); } .alert.ok { background: var(--ok-bg); color: var(--ok); } .alert.warn { background: var(--warn-bg); color: var(--warn); } .alert.info { background: var(--info-bg); color: var(--info); }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 4px; background: var(--info-bg); color: var(--info); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.err { background: var(--err-bg); color: var(--err); } .badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.plain { background: var(--card-2); color: var(--muted); }
.badge.live { background: var(--ok-bg); color: var(--ok); } .badge.live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px;  }

/* tabs & segmented */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 11px 16px; text-decoration: none; color: var(--muted); font-weight: 700; border-bottom: 3px solid transparent; white-space: nowrap; transition: color .2s, border-color .25s; display: flex; gap: 8px; align-items: center; }
.tabs a:hover { color: var(--text); } .tabs a.active { color: var(--link); border-bottom-color: var(--link); }
.seg { display: inline-flex; background: var(--card-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 7px 14px; font: inherit; font-weight: 700; border-radius: 6px; cursor: pointer; transition: background .2s, color .2s; }
.seg button.on { background: var(--navy); color: #fff; box-shadow: none; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; letter-spacing: 0; font-weight: 600; color: var(--muted); background: var(--card-2); }
tbody tr { transition: background .15s; } tbody tr:hover { background: var(--card-2); } tr:last-child td { border-bottom: 0; }
td.empty { text-align: center; color: var(--muted); padding: 30px; } td.wrap { white-space: normal; min-width: 220px; }
.matrix td.c, .matrix th.c { text-align: center; padding: 9px 10px; } .yes { color: var(--ok); font-weight: 650; } .no { color: var(--muted); }
tr.low td.pct { color: var(--err); font-weight: 650; }
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; } .toolbar input[type=search] { max-width: 280px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; }

/* progress */
.progress { height: 5px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; width: 0; border-radius: 4px; background: var(--ok); transition: width 1.1s var(--ease); }
.progress.low > div { background: var(--err); } .progress.rot > div { background: var(--gold); transition: width .25s linear; }
.need { position: relative; }

/* lecture list (student) */
.lec { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); margin-bottom: 10px; transition: transform .2s var(--ease), box-shadow .2s; }
.lec:hover { transform: none; box-shadow: var(--shadow); }
.lec .num { width: 44px; height: 44px; border-radius: 6px; display: grid; place-items: center; font-weight: 650; background: var(--info-bg); color: var(--info); flex: none; }
.lec.present .num { background: var(--ok-bg); color: var(--ok); } .lec.absent .num { background: var(--err-bg); color: var(--err); }
.lec .grow { flex: 1; min-width: 0; } .lec .title { font-weight: 700; }
.reason-box { margin-top: 12px; padding: 14px; border-radius: 6px; background: var(--card-2);  width: 100%; }
.lec-wrap { margin-bottom: 10px; } .lec-wrap .lec { margin-bottom: 0; }
.quote { border-left: 3px solid var(--gold); padding: 8px 12px; background: var(--card-2); border-radius: 0 10px 10px 0; font-size: 14px; white-space: pre-wrap; }
.open-lecture { border-left: 3px solid var(--gold);  }

/* result / success */
.result { text-align: center; padding: 34px 22px; }
.mark { width: 92px; height: 92px; margin: 0 auto 16px; }
.mark svg { width: 100%; height: 100%; } .mark circle { fill: none; stroke-width: 4; stroke-dasharray: 189; stroke-dashoffset: 0;  }
.mark path { fill: none; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; stroke-dashoffset: 0;  }
.mark.ok circle, .mark.ok path { stroke: var(--ok); } .mark.err circle, .mark.err path { stroke: var(--err); } .mark.info circle, .mark.info path { stroke: var(--info); } .mark.warn circle, .mark.warn path { stroke: var(--warn); }
.result h1 { font-size: 25px;  }
.result dl { display: inline-grid; grid-template-columns: auto auto; gap: 7px 20px; text-align: left; margin: 18px 0 8px; font-size: 14px;  }
.result dt { color: var(--muted); } .result dd { margin: 0; font-weight: 700; }
.spinner { width: 36px; height: 36px; border: 4px solid var(--line); border-top-color: var(--navy-2); border-radius: 50%; margin: 10px auto;  }
.skeleton { height: 18px; border-radius: 8px; background: var(--card-2); background-size: 200% 100%;  margin: 10px 0; }

/* Sign in */
.auth-layout { max-width: 420px; margin: clamp(24px, 7vh, 72px) auto 24px; }
.auth-intro { margin-bottom: 24px; }
.auth-intro h1 { font-size: 28px; margin-bottom: 8px; }
.auth-intro p { margin: 0; color: var(--muted); }
.auth-card { padding: 24px; }
.auth-card .seg { width: 100%; }
.auth-card .seg button { flex: 1; }
.auth-card .btn.lg { font-size: 15px; padding: 11px 16px; }
.dashboard-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 6px; margin: 0 0 28px; background: var(--card); }
.dashboard-summary .stat { padding: 20px 24px; }
.dashboard-summary .stat + .stat { border-left: 1px solid var(--line); }
.dashboard-summary .stat b { font-size: 28px; font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.dashboard-summary .stat span { font-size: 13px; }
.empty-state { padding: 28px 24px; border: 1px dashed var(--line); border-radius: 6px; }
.empty-state h3 { margin-bottom: 6px; }
.empty-state p { margin: 0; max-width: 54ch; }

/* live */
.live-grid { display: grid; grid-template-columns: minmax(280px, 520px) 1fr; gap: 24px; align-items: start; }
.qr-card { text-align: center; }
.qr-box { background: #fff; border-radius: 6px; padding: 10px; display: inline-block; width: 100%; max-width: 500px; line-height: 0; box-shadow: var(--shadow); } .qr-box svg { width: 100%; height: auto; display: block;  }
.bigcode { font: 800 clamp(30px, 6vw, 52px)/1.1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .22em; margin: 16px 0 4px; padding-left: .22em; }
.lecnum { display: inline-block; font-weight: 650; font-size: 20px; padding: 6px 18px; border-radius: 4px; background: var(--gold); color: #251a00; margin-bottom: 14px; }
.counter { font-size: 68px; font-weight: 650; line-height: 1; } .counter small { font-size: 22px; color: var(--muted); font-weight: 700; }
.recent { list-style: none; margin: 0; padding: 0; } .recent li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px;  } .recent li:last-child { border-bottom: 0; }
body.present .site-header, body.present .site-footer { display: none; }

/* toasts */
.toasts { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; z-index: 100; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--navy); color: #fff; padding: 13px 16px; border-radius: 6px; box-shadow: var(--shadow-lg); border-left: 3px solid var(--gold);  font-size: 14px; }
.toast.out {  } .toast.ok { border-left-color: #39c26b; } .toast.err { border-left-color: #ff7a6e; } .toast b { display: block; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(5,12,30,.55); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 90; padding: 16px;  }
.modal { background: var(--card); border-radius: 6px; padding: 22px; width: min(460px, 100%); box-shadow: var(--shadow-lg);  max-height: 90vh; overflow: auto; }

/* keyframes */
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 800px) {
  .live-grid { grid-template-columns: 1fr; } h1 { font-size: 23px; } .container { padding: 18px 14px 36px; }
  .site-header .inner { padding: 9px 12px; } .userbox .who, .brand small { display: none; } .nav { margin-left: 4px; } .hero h1 { font-size: 28px; }
  .lec { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important;  transition-duration: .001ms !important; } html { scroll-behavior: auto; } }

/* Functional feedback stays visible without decorative motion. */
.spinner, .btn.loading::after { animation: spin .8s linear infinite; }
.toast.out { opacity: 0; transition: opacity .2s; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.stat b, .counter, .bigcode, td { font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .dashboard-summary .stat { padding: 14px 10px; }
  .dashboard-summary .stat b { font-size: 23px; }
  .dashboard-summary .stat span { font-size: 11px; }
  .auth-layout { margin-top: 20px; }
  .auth-card { padding: 20px 16px; }
  .site-header .inner { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; margin: 0; border-top: 1px solid var(--line); padding-top: 6px; }
  .brand .logo { width: 32px; height: 32px; font-size: 18px; }
  .result dl { grid-template-columns: 1fr; gap: 3px; }
  .result dd { margin-bottom: 10px; }
}

/* Course enrollment and reminder lists */
.attendance-note { margin: 0 0 20px; }
.panel { max-height: min(480px, 70vh); overflow-y: auto; }
.note-item { border-radius: 0; background: transparent; border-bottom: 1px solid var(--line); padding: 12px 0; margin: 0; }
.note-item > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.note-item:last-of-type { border-bottom: 0; }
.note-item .when { color: var(--muted); font-weight: 500; font-size: 12px; }
.request-list { border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
.request-row { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.request-row + .request-row { border-top: 1px solid var(--line); }
.invite-card { display: flex; gap: 18px; align-items: center; padding: 20px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 24px; background: var(--card); }
.invite-card > div { flex: 1; }
.invite-code { color: var(--text); font: 600 20px ui-monospace, monospace; letter-spacing: .12em; user-select: all; }
.invite-input { text-transform: uppercase; letter-spacing: .15em; }
.section-heading { margin-bottom: 18px; }
.section-heading h2 { margin-bottom: 4px; }
.section-heading p { margin: 0; }
@media (max-width: 560px) {
  .request-row, .invite-card { flex-wrap: wrap; gap: 12px; }
  .invite-card > div { flex-basis: 100%; }
  .request-row .badge { white-space: normal; }
  .panel { right: -44px; width: min(340px, calc(100vw - 24px)); }
}

.update-notice { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 110; display: flex; gap: 16px; align-items: center; width: max-content; max-width: calc(100vw - 24px); padding: 12px 16px; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow-lg); font-size: 14px; }
@media (max-width: 560px) { .update-notice { width: calc(100vw - 24px); } }
