@font-face {
  font-family: 'SanzuComic';
  src: url('https://raw.githubusercontent.com/heysanzu/sanzu/main/fonts/product_sans.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #ffffff;
  --bg-dim:      #f5f5f5;
  --border:      #e0e0e0;
  --border-dark: #b0b0b0;
  --text:        #111111;
  --text-mid:    #555555;
  --text-muted:  #999999;
  --accent:      #111111;
  --accent-inv:  #ffffff;

  --clr-present: #2a7a2a;
  --clr-absent:  #b33030;
  --clr-sunday:  #888888;
  --clr-holiday: #5050a0;
  --clr-paid:    #2a7a2a;
  --clr-unpaid:  #b33030;
  --clr-gold:    #b8860b;
  --clr-silver:  #727272;
  --clr-bronze:  #a05a2c;

  --sidebar-w:   220px;
  --topbar-h:    54px;
  --bottomnav-h: 62px;
  --radius:      8px;
  --radius-lg:   12px;

  font-family: 'SanzuComic', 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

html, body { height: 100%; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-5px); }
  80%      { transform: translateX(5px); }
}
.shake { animation: shake 0.45s ease; }

@keyframes blink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0; }
}
.cursor {
  display: inline-block;
  font-weight: 300;
  color: var(--text-muted);
  animation: blink 1s step-end infinite;
  margin-left: 1px;
}

#login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
  position: relative;
}

#login-box {
  background: var(--bg-dim);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-logo {
  display: flex; align-items: center; justify-content: center; margin-bottom: 4px;
}
.login-logo h1 { font-size: 1.7rem; font-weight: 700; letter-spacing: 3px; }

.input-group {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; background: var(--bg);
  transition: border-color 0.15s;
}
.input-group:focus-within { border-color: var(--text); }
.input-group i { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.input-group input {
  border: none; outline: none; font-family: inherit; font-size: 1rem;
  width: 100%; background: transparent; color: var(--text);
}
.input-group input::placeholder { color: var(--text-muted); }

.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-inv);
  border: none; border-radius: var(--radius);
  padding: 11px 18px; font-family: inherit; font-size: 0.95rem;
  cursor: pointer; transition: opacity 0.15s; width: 100%;
}
.btn-primary:hover { opacity: 0.8; }
.btn-primary i { width: 15px; height: 15px; }

.github-link {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.79rem; color: var(--text-muted); text-decoration: none;
  position: absolute; bottom: 20px;
  transition: color 0.15s;
}
.github-link:hover { color: var(--text); }
.github-link i { width: 14px; height: 14px; }

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-dim);
  border-right: 1.5px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0; height: 100vh; overflow-y: auto;
}

.sidebar-header {
  display: flex; align-items: center;
  padding: 18px 16px 14px;
  border-bottom: 1.5px solid var(--border);
  flex-shrink: 0;
}
.sidebar-title { font-size: 0.93rem; font-weight: 700; letter-spacing: 2.5px; }

.sidebar-nav {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 8px; flex: 1; overflow-y: auto;
}

.nav-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: none; background: transparent;
  color: var(--text-mid); font-family: inherit; font-size: 0.86rem;
  border-radius: var(--radius); cursor: pointer; text-align: left;
  transition: background 0.13s, color 0.13s;
  width: 100%;
}
.nav-btn i { width: 16px; height: 16px; flex-shrink: 0; }
.nav-btn:hover  { background: var(--border); color: var(--text); }
.nav-btn.active { background: var(--text); color: var(--bg); }

.sidebar-footer {
  border-top: 1.5px solid var(--border);
  padding: 12px 10px;
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.student-badge {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
}
.student-badge i { width: 18px; height: 18px; flex-shrink: 0; color: var(--text-mid); }
.student-badge div { display: flex; flex-direction: column; min-width: 0; }
.student-badge span {
  font-size: 0.84rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.student-badge small { font-size: 0.7rem; color: var(--text-muted); }

.logout-btn {
  border: none; background: transparent; cursor: pointer;
  color: var(--text-muted); display: flex; align-items: center;
  padding: 5px; border-radius: var(--radius);
  transition: color 0.15s, background 0.15s; flex-shrink: 0;
}
.logout-btn:hover { color: var(--clr-absent); background: #ffeaea; }
.logout-btn i { width: 16px; height: 16px; }

.topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h); background: var(--bg);
  border-bottom: 1.5px solid var(--border);
  align-items: center; justify-content: space-between;
  padding: 0 16px; z-index: 90;
}
.topbar-logo {
  display: flex; align-items: center; gap: 7px;
  font-weight: 700; letter-spacing: 2px; font-size: 0.95rem;
}
.topbar-logo i { width: 18px; height: 18px; }
.topbar-right  { display: flex; align-items: center; gap: 10px; }
.topbar-id {
  font-size: 0.79rem; color: var(--text-muted);
  background: var(--bg-dim); border: 1px solid var(--border);
  padding: 3px 9px; border-radius: 20px;
}

.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-h);
  background: var(--bg); border-top: 1.5px solid var(--border);
  z-index: 90; align-items: center; justify-content: space-around;
  padding: 0 4px;
}

.bnav-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; border: none; background: transparent; cursor: pointer;
  color: var(--text-muted); font-family: inherit; font-size: 0.62rem;
  font-weight: 500; padding: 6px 10px; border-radius: var(--radius);
  transition: color 0.15s; flex: 1; min-width: 0;
}
.bnav-btn i { width: 20px; height: 20px; }
.bnav-btn.active { color: var(--text); }
.bnav-btn.active i { stroke-width: 2.5; }

.main-content {
  flex: 1; height: 100vh; overflow-y: auto;
  padding: 28px 30px; background: var(--bg);
  display: flex; flex-direction: column;
}

.main-content > .section {
  width: 100%; max-width: 900px; margin: 0 auto;
}

.section { display: none; }

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 22px;
}
.section-header h2 { font-size: 1.3rem; font-weight: 700; }
.download-btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1.5px solid var(--border); background: var(--text); color: var(--bg);
  border-radius: var(--radius); padding: 8px 13px;
  font-family: inherit; font-size: 0.8rem; cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}
.download-btn:hover { opacity: 0.82; transform: translateY(-1px); }
.download-btn i { width: 15px; height: 15px; }

.greeting-line { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 2px; }
.greeting-name { font-size: 1.4rem; font-weight: 700; line-height: 1.2; }

.date-chip {
  font-size: 0.78rem; color: var(--text-muted);
  background: var(--bg-dim); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 20px; white-space: nowrap;
}

.card {
  background: var(--bg-dim); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.card-head h3 { font-size: 0.91rem; font-weight: 600; }
.card-head i  { width: 15px; height: 15px; color: var(--text-muted); }

.icon-btn {
  border: 1.5px solid var(--border); background: var(--bg);
  border-radius: var(--radius); padding: 6px 8px;
  cursor: pointer; display: flex; align-items: center; transition: background 0.13s;
}
.icon-btn:hover { background: var(--bg-dim); }
.icon-btn i { width: 15px; height: 15px; }

.fee-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px; border-radius: 20px; font-size: 0.79rem; font-weight: 600;
}
.fee-badge.paid   { background: #e5f5e5; color: var(--clr-paid);   border: 1px solid #aadaaa; }
.fee-badge.unpaid { background: #fdeaea; color: var(--clr-unpaid); border: 1px solid #f0aaaa; }

.stats-grid {
  display: grid; grid-template-columns: repeat(4,1fr);
  gap: 12px; margin-bottom: 16px;
}
.stat-card {
  background: var(--bg-dim); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 14px;
  display: flex; align-items: center; gap: 12px;
}
.stats-animate .stat-card { animation: stat-card-enter 0.55s ease both; }
.stats-animate .stat-card:nth-child(2) { animation-delay: 0.1s; }
.stats-animate .stat-card:nth-child(3) { animation-delay: 0.2s; }
.stats-animate .stat-card:nth-child(4) { animation-delay: 0.3s; }
@keyframes stat-card-enter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.stat-card i   { width: 25px; height: 25px; stroke-width: 1.6; flex-shrink: 0; }
.stat-card div { display: flex; flex-direction: column; }
.stat-num      { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-label    { font-size: 0.71rem; color: var(--text-muted); }

.announcement-banner {
  width: 100%; height: 150px; margin-bottom: 16px;
  border: 1.5px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; background: var(--bg-dim);
  animation: announcement-enter 0.6s ease both;
}
.announcement-media { width: 100%; height: 100%; display: block; object-fit: cover; }
.announcement-changing { animation: announcement-slide 0.6s ease both; }
@keyframes announcement-slide {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes announcement-enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }

.about-card { margin-top: 16px; }
.about-card p { font-size: 0.78rem; color: var(--text-mid); line-height: 1.5; }
.about-card small { display: block; margin-top: 7px; font-size: 0.7rem; color: var(--text-muted); }

.notes-card { margin-bottom: 16px; }
.notes-list { display: flex; flex-direction: column; gap: 8px; }
.notes-empty { color: var(--text-muted); font-size: 0.78rem; }
.note-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.note-info, .note-actions { display: flex; align-items: center; gap: 9px; min-width: 0; }
.note-info { cursor: pointer; }
.note-info > i { width: 17px; height: 17px; color: var(--text-mid); flex-shrink: 0; }
.note-info h4 { font-size: 0.82rem; font-weight: 600; overflow-wrap: anywhere; }
.note-info p { color: var(--text-muted); font-size: 0.7rem; margin-top: 2px; }
.note-actions { display: none; flex-shrink: 0; }
.note-item.is-selected .note-actions { display: flex; }
.note-actions .download-btn {
  height: 30px; padding: 0 8px;
  justify-content: center; text-decoration: none; font-size: 0.72rem;
}
.note-actions .note-view { width: 30px; padding: 0; }
.note-actions .note-view i { width: 12px; height: 12px; }
.note-delete { border: none; background: transparent; color: var(--text-muted); cursor: pointer; padding: 5px; }
.note-delete:hover { color: var(--clr-absent); }
.note-delete i { width: 15px; height: 15px; }

.upcoming-card { background: #000000; border-color: #000000; color: #ffffff; }
.upcoming-card .card-head i { color: #ffffff; }
.upcoming-card .upcoming-list li { color: #ffffff; }

.upcoming-list { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.upcoming-list li {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.83rem; color: var(--text-mid);
}
.upcoming-list { min-height: 24px; }
.upcoming-list.event-changing { animation: upcoming-change 0.45s ease; }
.upcoming-list li i { width: 13px; height: 13px; flex-shrink: 0; }
@keyframes upcoming-change {
  0% { opacity: 0; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); }
}

.dash-fee-status p { font-size: 0.81rem; color: var(--text-muted); margin-top: 6px; }

.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-nav span { font-size: 0.9rem; font-weight: 600; min-width: 130px; text-align: center; }

.legend {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-size: 0.76rem; color: var(--text-mid); margin-bottom: 12px;
}
.legend-dot {
  width: 10px; height: 10px; border-radius: 3px;
  display: inline-block; margin-right: 3px; vertical-align: middle;
}
.legend-dot.present { background: var(--clr-present); }
.legend-dot.absent  { background: var(--clr-absent);  }
.legend-dot.sunday  { background: var(--clr-sunday);  }
.legend-dot.holiday { background: var(--clr-holiday); }

.calendar-grid {
  display: grid; grid-template-columns: repeat(7,1fr);
  gap: 4px; margin-bottom: 16px;
}
.cal-day-header {
  text-align: center; font-size: 0.69rem; font-weight: 600;
  color: var(--text-muted); padding: 5px 0; letter-spacing: 0.3px;
}
.cal-day {
  aspect-ratio: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border-radius: 6px; font-size: 0.79rem; cursor: pointer;
  border: 1.5px solid transparent; background: var(--bg-dim);
  transition: transform 0.1s, border-color 0.13s;
  user-select: none;
}
.cal-day:hover   { transform: scale(1.08); border-color: var(--border-dark); }
.cal-day.empty   { background: transparent; cursor: default; pointer-events: none; }
.cal-day.present { background: #e5f5e5; color: var(--clr-present); border-color: #aadaaa; }
.cal-day.absent  { background: #fdeaea; color: var(--clr-absent);  border-color: #f0aaaa; }
.cal-day.sunday  { background: #f2f2f2; color: var(--clr-sunday);  border-color: var(--border); }
.cal-day.holiday { background: #eeeef7; color: var(--clr-holiday); border-color: #c0c0e0; }
.cal-day:not(.present):not(.absent):not(.sunday):not(.holiday):not(.empty) { background: var(--bg-dim); color: var(--text-muted); border-color: var(--border); }
.cal-day.today   { outline: 2px solid var(--text); outline-offset: 1px; }
.day-num { font-weight: 600; line-height: 1; }
.day-dot { width: 4px; height: 4px; border-radius: 50%; margin-top: 2px; background: currentColor; }

.month-summary h3 { font-size: 0.88rem; font-weight: 600; margin-bottom: 10px; }
.month-stats { display: flex; gap: 22px; font-size: 0.82rem; color: var(--text-mid); flex-wrap: wrap; }
.month-stats b { font-size: 1.05rem; color: var(--text); }

.results-list { display: flex; flex-direction: column; gap: 10px; }
.result-card {
  background: var(--bg-dim); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 15px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.result-info h4 { font-size: 0.92rem; font-weight: 600; }
.result-info p  { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.result-score   { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.score-num      { font-size: 1.3rem; font-weight: 700; }
.score-num small { font-size: 0.74rem; font-weight: 400; color: var(--text-muted); }
.score-grade    { font-size: 0.72rem; padding: 2px 9px; border-radius: 20px; font-weight: 600; }
.grade-A { background: #e5f5e5; color: var(--clr-present); }
.grade-B { background: #e5edf7; color: #2a4fa0; }
.grade-C { background: #fdf6e0; color: #8a6200; }
.grade-D { background: #fdeaea; color: var(--clr-absent); }

.leaderboard-wrap { display: flex; flex-direction: column; gap: 8px; }
.lb-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-dim); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 13px 18px;
}
.lb-row.current-student { border-color: var(--text); }
.lb-row.topper-row {
  border-color: var(--clr-gold);
  animation: topper-fill 2.4s ease-in-out infinite;
}
@keyframes topper-fill {
  0%, 100% { background-color: #fff8d6; }
  50% { background-color: #f6d66b; }
}
.lb-rank       { width: 28px; font-size: 0.84rem; font-weight: 700; text-align: center; flex-shrink: 0; color: var(--text-muted); }
.lb-rank.top-1 { color: var(--clr-gold); }
.lb-rank.top-2 { color: var(--clr-silver); }
.lb-rank.top-3 { color: var(--clr-bronze); }
.lb-name       { font-size: 0.88rem; font-weight: 600; }
.lb-sub        { font-size: 0.73rem; color: var(--text-muted); margin-top: 1px; }
.lb-score      { font-size: 0.88rem; font-weight: 700; min-width: 46px; text-align: right; flex-shrink: 0; }
.lb-bar-mini   { width: 80px; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; flex-shrink: 0; }
.lb-bar-mini-fill { height: 100%; background: var(--text); border-radius: 3px; }

.fees-grid { display: flex; flex-direction: column; gap: 10px; }
.fee-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--bg-dim); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 15px 20px; flex-wrap: wrap;
}
.fee-info h4 { font-size: 0.9rem; font-weight: 600; }
.fee-info p  { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.fee-right   { display: flex; align-items: center; gap: 12px; }

.popup-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
}
.popup {
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px 24px;
  width: 100%; max-width: 340px;
  position: relative; text-align: center;
  box-shadow: 0 8px 28px rgba(0,0,0,0.1);
}
.popup-close {
  position: absolute; top: 10px; right: 10px;
  border: none; background: transparent; cursor: pointer;
  color: var(--text-muted); display: flex; align-items: center;
  padding: 4px; border-radius: var(--radius);
}
.popup-close:hover { background: var(--bg-dim); }
.popup-close i { width: 15px; height: 15px; }
.popup h3      { font-size: 0.96rem; font-weight: 700; margin-bottom: 14px; }
.popup-status {
  display: inline-block; padding: 5px 18px; border-radius: 20px;
  font-size: 0.84rem; font-weight: 600; margin-bottom: 8px;
}
.popup-status.present { background: #e5f5e5; color: var(--clr-present); }
.popup-status.absent  { background: #fdeaea; color: var(--clr-absent);  }
.popup-status.sunday  { background: #f2f2f2; color: var(--clr-sunday);  }
.popup-status.holiday { background: #eeeef7; color: var(--clr-holiday); }
.popup-status.blank { display: none; }
.popup-note { font-size: 0.78rem; color: var(--text-muted); }

.notice-popup { max-width: 380px; text-align: center; }
.notice-welcome { font-size: 0.92rem; color: var(--text-muted); margin-bottom: 16px; }
.notice-welcome b { color: var(--text); font-size: 1.02rem; font-weight: 700; }
.notice-description { font-size: 0.8rem; color: var(--text-mid); line-height: 1.5; }
.notice-list {
  list-style: none; display: flex; flex-direction: column; gap: 11px;
  margin-bottom: 4px;
}
.notice-list li {
  display: flex; gap: 9px; align-items: flex-start;
  font-size: 0.83rem; color: var(--text-mid); line-height: 1.5;
}
.notice-list li i { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; color: var(--text-muted); }
.notice-list b { color: var(--text); font-weight: 600; }
.notice-divider { height: 1px; background: var(--border); margin: 16px 0 0; }
.notice-popup .btn-primary { width: auto; margin: 12px auto 0; padding: 8px 16px; }

@media (max-width: 1024px) {
  .stats-grid       { grid-template-columns: repeat(2,1fr); }
  .perf-overview    { flex-direction: row; gap: 20px; }
  .perf-overview h3 { display: none; }
}

@media (max-width: 768px) {
  .sidebar         { display: none; }
  .topbar          { display: flex; }
  .bottom-nav      { display: flex; }

  .main-content {
    padding: 14px 14px;
    padding-top: calc(var(--topbar-h) + 14px);
    padding-bottom: calc(var(--bottomnav-h) + 14px);
    height: 100vh; overflow-y: auto;
  }

  .dashboard-grid { grid-template-columns: 1fr; }
  .stats-grid     { grid-template-columns: repeat(2,1fr); gap: 10px; }


  .lb-bar-mini { display: none; }
}

@media (max-width: 480px) {
  #login-box { padding: 28px 20px; }
  .login-logo h1 { font-size: 1.5rem; }

  .stats-grid { gap: 8px; }
  .stat-card  { padding: 12px 10px; gap: 8px; }
  .stat-num   { font-size: 1.25rem; }

  .greeting-name { font-size: 1.2rem; }

  .calendar-grid { gap: 3px; }
  .cal-day { font-size: 0.69rem; border-radius: 5px; }

  .result-card  { flex-direction: column; align-items: flex-start; gap: 8px; }
  .result-score { align-items: flex-start; }

  .perf-overview    { flex-direction: column; }

  .section-header { flex-direction: column; align-items: flex-start; }

  .note-item { align-items: flex-start; flex-direction: column; }
  .note-actions { width: 100%; }
}

::-webkit-scrollbar       { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 10px; }
