/* ===== RESET & VARIABLES ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:      #2563eb;
  --blue-dk:   #1d4ed8;
  --blue-lt:   #eff6ff;
  --green:     #16a34a;
  --green-lt:  #f0fdf4;
  --red:       #dc2626;
  --red-lt:    #fef2f2;
  --amber:     #d97706;
  --amber-lt:  #fffbeb;
  --g50:  #f9fafb;
  --g100: #f3f4f6;
  --g200: #e5e7eb;
  --g300: #d1d5db;
  --g400: #9ca3af;
  --g500: #6b7280;
  --g600: #4b5563;
  --g700: #374151;
  --g800: #1f2937;
  --g900: #111827;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--g50);
  color: var(--g800);
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-size: .85em; background: var(--g100); padding: 2px 5px; border-radius: 4px; }

/* ===== TOPBAR ===== */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--g200);
  height: 54px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--g900);
  letter-spacing: -.01em;
}
.topbar-brand:hover { text-decoration: none; }

.brand-dot {
  width: 28px;
  height: 28px;
  background: var(--blue);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: .8rem;
  font-weight: 800;
  flex-shrink: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
  color: var(--g600);
}

.avatar {
  width: 28px;
  height: 28px;
  background: var(--blue-lt);
  color: var(--blue);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .75rem;
  flex-shrink: 0;
}

.btn-logout {
  font-size: .78rem;
  color: var(--g500);
  border: 1px solid var(--g200);
  border-radius: 6px;
  padding: 4px 10px;
  transition: all .15s;
}
.btn-logout:hover {
  color: var(--red);
  border-color: #fca5a5;
  background: var(--red-lt);
  text-decoration: none;
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
  background: #fff;
  border-bottom: 1px solid var(--g100);
  padding: 9px 28px;
  font-size: .78rem;
  color: var(--g400);
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--g500); }
.breadcrumb a:hover { color: var(--blue); text-decoration: none; }
.breadcrumb .bc-sep { color: var(--g300); user-select: none; }
.breadcrumb .bc-cur { color: var(--g700); font-weight: 500; }

/* ===== PAGE SHELL ===== */
.page-shell {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 24px 56px;
}

/* ===== PAGE HEADER ===== */
.page-hd {
  margin-bottom: 22px;
}
.page-hd h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--g900);
  letter-spacing: -.02em;
  margin: 0 0 3px;
}
.page-hd p {
  font-size: .82rem;
  color: var(--g500);
  margin: 0;
}

/* ===== FLASH MESSAGES ===== */
.flash-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: .845rem;
  border: 1px solid transparent;
  animation: fadeSlide .2s ease;
}
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.flash.success { background: var(--green-lt); color: #14532d; border-color: #bbf7d0; }
.flash.danger  { background: var(--red-lt);   color: #7f1d1d; border-color: #fecaca; }
.flash.info    { background: var(--blue-lt);  color: #1e3a8a; border-color: #bfdbfe; }
.flash-x {
  background: none; border: none; cursor: pointer;
  color: inherit; opacity: .45; font-size: .95rem;
  padding: 0; line-height: 1; flex-shrink: 0;
}
.flash-x:hover { opacity: 1; }

/* ===== CARD ===== */
.card {
  background: #fff;
  border: 1px solid var(--g200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card + .card { margin-top: 16px; }

.card-hd {
  padding: 14px 20px;
  border-bottom: 1px solid var(--g100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 52px;
}
.card-hd h2 {
  font-size: .9rem;
  font-weight: 600;
  color: var(--g900);
  margin: 0;
}
.card-body { padding: 18px 20px; }

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--g200);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat-lbl {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--g500);
  font-weight: 600;
  margin-bottom: 6px;
}
.stat-val {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1;
  color: var(--g900);
}
.stat-card.c-green .stat-val { color: var(--green); }
.stat-card.c-red   .stat-val { color: var(--red); }
.stat-card.c-blue  .stat-val { color: var(--blue); }
.stat-card.c-amber .stat-val { color: var(--amber); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  font-size: .8rem;
  font-weight: 500;
  font-family: inherit;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all .14s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn-sm { padding: 4px 10px; font-size: .76rem; border-radius: 6px; }
.btn-lg { padding: 10px 20px; font-size: .88rem; }

.btn-primary   { background: var(--blue);    color: #fff;          border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-dk); border-color: var(--blue-dk); color:#fff; }

.btn-secondary { background: #fff;           color: var(--g700);   border-color: var(--g300); }
.btn-secondary:hover { background: var(--g50); color: var(--g900); border-color: var(--g400); }

.btn-danger    { background: var(--red-lt);  color: var(--red);    border-color: #fecaca; }
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }

.btn-success   { background: var(--green-lt); color: var(--green); border-color: #bbf7d0; }
.btn-success:hover { background: var(--green); color: #fff; border-color: var(--green); }

/* ===== FORMS ===== */
input[type="text"],
input[type="password"],
input[type="date"],
input[type="search"],
select {
  font-family: inherit;
  font-size: .845rem;
  color: var(--g800);
  background: #fff;
  border: 1px solid var(--g300);
  border-radius: 7px;
  padding: 7px 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  max-width: 100%;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="search"]:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
input[type="checkbox"] {
  width: 16px; height: 16px;
  cursor: pointer;
  accent-color: var(--blue);
  flex-shrink: 0;
}

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .845rem; }
thead th {
  background: var(--g50);
  color: var(--g500);
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 9px 16px;
  text-align: left;
  border-bottom: 1px solid var(--g200);
  white-space: nowrap;
}
thead th.tc { text-align: center; }
tbody tr { border-bottom: 1px solid var(--g100); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--g50); }
tbody td { padding: 10px 16px; color: var(--g700); vertical-align: middle; }
tbody td.tc { text-align: center; }

/* ===== BADGE ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-green  { background: var(--green-lt); color: var(--green); }
.badge-red    { background: var(--red-lt);   color: var(--red); }
.badge-amber  { background: var(--amber-lt); color: var(--amber); }
.badge-blue   { background: var(--blue-lt);  color: var(--blue); }
.badge-gray   { background: var(--g100);     color: var(--g600); }

/* ===== PROGRESS BAR ===== */
.pct-bar { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.pct-track {
  flex: 1; height: 6px;
  background: var(--g200); border-radius: 99px; overflow: hidden;
}
.pct-fill { height: 100%; border-radius: 99px; }
.pct-fill.hi  { background: var(--green); }
.pct-fill.mid { background: var(--amber); }
.pct-fill.lo  { background: var(--red); }
.pct-lbl { font-size: .78rem; font-weight: 600; color: var(--g600); min-width: 34px; }

/* ===== EMPTY STATE ===== */
.empty {
  padding: 52px 24px;
  text-align: center;
  color: var(--g400);
}
.empty-ico { font-size: 2.2rem; margin-bottom: 10px; opacity: .7; }
.empty p { font-size: .875rem; color: var(--g500); margin: 0; }

/* ===== LOGIN PAGE ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #eff6ff 0%, var(--g50) 60%);
}
.login-card {
  background: #fff;
  border: 1px solid var(--g200);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 34px 34px 28px;
  width: 100%;
  max-width: 370px;
}
.login-icon {
  width: 46px; height: 46px;
  background: var(--blue);
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
  font-size: 1.3rem;
}
.login-hd { text-align: center; margin-bottom: 24px; }
.login-hd h1 { font-size: 1.1rem; font-weight: 700; color: var(--g900); margin: 0 0 3px; }
.login-hd p  { font-size: .8rem; color: var(--g500); margin: 0; }
.login-field { margin-bottom: 14px; }
.login-field label { display: block; font-size: .78rem; font-weight: 500; color: var(--g700); margin-bottom: 5px; }
.login-field input { width: 100%; max-width: 100%; padding: 9px 12px; }
.login-btn { width: 100%; justify-content: center; padding: 10px; font-size: .88rem; margin-top: 6px; }

/* ===== CLASS GRID ===== */
.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}
.class-card {
  background: #fff;
  border: 1px solid var(--g200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  transition: box-shadow .15s, border-color .15s, transform .15s;
}
.class-card:hover { box-shadow: var(--shadow-md); border-color: var(--g300); transform: translateY(-1px); }
.class-card-name { font-size: .95rem; font-weight: 600; color: var(--g900); margin-bottom: 3px; }
.class-card-meta { font-size: .78rem; color: var(--g400); margin-bottom: 14px; }
.class-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== ATTENDANCE MARK ===== */
.att-meta {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  font-size: .82rem;
  color: var(--g500);
  padding: 10px 0 14px;
}
.att-meta strong { font-weight: 700; }
.att-meta .c-green { color: var(--green); }
.att-meta .c-red   { color: var(--red); }

.row-click { cursor: pointer; }
.row-click:hover { background: var(--blue-lt) !important; }

/* ===== FOOTER BAR ===== */
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--g100);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .topbar { padding: 0 16px; }
  .breadcrumb { padding: 8px 16px; }
  .page-shell { padding: 18px 14px 40px; }
  .class-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  thead th { font-size: .68rem; padding: 8px 10px; }
  tbody td { padding: 9px 10px; font-size: .8rem; }
  .btn { font-size: .77rem; }
  .login-card { padding: 24px 20px 20px; }
}
