/* ============================================================
   KnowledgeTH Attendance — Global Styles (Sidebar Edition)
   ============================================================ */

* { box-sizing: border-box; }

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-soft: #eef0f5;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;

  --primary: #2c5aa0;
  --primary-hover: #1e3f78;
  --primary-soft: #eaf1fb;
  --accent: #fbbf24;          /* yellow */
  --accent-soft: #fef3c7;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #f59e0b;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0ea5e9;
  --info-soft: #e0f2fe;
  --purple: #8b5cf6;
  --purple-soft: #ede9fe;
  --pink: #ec4899;
  --pink-soft: #fce7f3;

  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 2px 10px rgba(15,23,42,.05);
  --shadow-lg: 0 12px 32px rgba(15,23,42,.08);

  --sidebar-w: 240px;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Kanit', 'Prompt', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

/* ===== Sidebar Layout Shell ===== */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

/* Sidebar */
.sidebar {
  background: white;
  border-right: 1px solid var(--border);
  padding: 18px 14px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 4px;
}
.sidebar .brand .logo-wrap {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--info) 100%);
  display: grid; place-items: center;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar .brand .logo-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.sidebar .brand .logo-wrap .alert-dot {
  position: absolute; top: 4px; right: 4px;
  width: 8px; height: 8px;
  background: var(--danger); border-radius: 50%;
  box-shadow: 0 0 0 2px white;
}
.sidebar .brand .name {
  font-weight: 700; font-size: 16px; line-height: 1.1;
  color: var(--text);
}
.sidebar .brand .tagline {
  font-size: 9px; letter-spacing: .14em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 2px;
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar .nav-section {
  font-size: 10px; letter-spacing: .14em;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 12px 12px 4px;
  font-weight: 500;
}
.sidebar .nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
  position: relative;
}
.sidebar .nav-link:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.sidebar .nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.sidebar .nav-link .icon {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 6px;
  background: var(--bg);
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.sidebar .nav-link.active .icon {
  background: white;
  color: var(--primary);
}
.sidebar .nav-link .pill {
  margin-left: auto;
  background: var(--accent);
  color: #78350f;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
}
.sidebar .teacher-card {
  margin-top: auto;
  background: var(--danger-soft);
  border-radius: 14px;
  padding: 12px;
  display: flex; align-items: center; gap: 10px;
}
.sidebar .teacher-card .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--danger); color: white;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.sidebar .teacher-card .name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.sidebar .teacher-card .desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.sidebar .signout-btn {
  margin-top: 6px;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 8px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}
.sidebar .signout-btn:hover { background: var(--bg); color: var(--text); }

/* Main column */
.main-col {
  display: flex;
  flex-direction: column;
  min-width: 0; /* allow children to shrink */
}

/* Header (top bar inside main column) */
.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: transparent;
  position: sticky; top: 0; z-index: 5;
  backdrop-filter: blur(8px);
}
.crumbs {
  font-size: 13px;
  color: var(--text-muted);
  flex: 1;
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
}
.crumbs .sep { opacity: .5; }
.crumbs .current { color: var(--text); font-weight: 600; }
.search-box {
  position: relative;
  width: 280px;
  max-width: 40vw;
}
.search-box input {
  width: 100%;
  padding: 8px 14px 8px 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: inherit;
  background: white;
  font-size: 14px;
  outline: none;
  transition: border .15s, box-shadow .15s;
}
.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44,90,160,.12);
}
.search-box::before {
  content: "🔍";
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 12px; opacity: .6; pointer-events: none;
}
.icon-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: white;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 14px;
  position: relative;
  transition: all .15s;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn .badge-dot {
  position: absolute; top: 5px; right: 5px;
  width: 8px; height: 8px;
  background: var(--danger); border-radius: 50%;
  border: 2px solid white;
}

/* Main content */
.main {
  padding: 0 24px 32px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  min-width: 0;
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

/* ===== Hero card (attendance, index) ===== */
.hero-card {
  background: linear-gradient(135deg, #2c5aa0 0%, #4f7ec8 70%, #6b8fcf 100%);
  color: white;
  border-radius: var(--radius-xl);
  padding: 22px 26px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: relative;
  overflow: hidden;
}
.hero-card::before {
  content: "";
  position: absolute;
  right: 80px; top: -30px;
  width: 200px; height: 200px;
  background: var(--accent);
  border-radius: 50%;
  opacity: .85;
}
.hero-card::after {
  content: "";
  position: absolute;
  right: -30px; bottom: -50px;
  width: 130px; height: 130px;
  background: var(--accent);
  border-radius: 50%;
  opacity: .7;
}
.hero-card > * { position: relative; z-index: 1; }
.hero-card .hero-info { flex: 1; min-width: 0; }
.hero-card .hero-pill {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(255,255,255,.18);
  border-radius: 999px;
  font-size: 12px;
  margin-bottom: 8px;
}
.hero-card h1 {
  color: white;
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}
.hero-card h1 .accent-icon {
  display: inline-block;
  margin-left: 6px;
  font-size: 22px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.1));
}
.hero-card .hero-sub {
  margin-top: 6px;
  font-size: 13px;
  opacity: .9;
}
.hero-card .hero-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  position: relative; z-index: 2;
}

/* ===== Stat cards (attendance summary) ===== */
.stat-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  position: relative;
}
.stat-card .stat-icon {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}
.stat-card .stat-num { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.stat-card.tone-blue   { background: var(--info-soft); border-color: #bae6fd; }
.stat-card.tone-blue   .stat-icon { background: #38bdf8; color: white; }
.stat-card.tone-blue   .stat-num  { color: #075985; }
.stat-card.tone-green  { background: var(--success-soft); border-color: #bbf7d0; }
.stat-card.tone-green  .stat-icon { background: var(--success); color: white; }
.stat-card.tone-green  .stat-num  { color: #14532d; }
.stat-card.tone-yellow { background: var(--warning-soft); border-color: #fde68a; }
.stat-card.tone-yellow .stat-icon { background: #f59e0b; color: white; }
.stat-card.tone-yellow .stat-num  { color: #78350f; }
.stat-card.tone-red    { background: var(--danger-soft); border-color: #fecaca; }
.stat-card.tone-red    .stat-icon { background: var(--danger); color: white; }
.stat-card.tone-red    .stat-num  { color: #7f1d1d; }
.stat-card.tone-purple { background: var(--purple-soft); border-color: #ddd6fe; }
.stat-card.tone-purple .stat-icon { background: var(--purple); color: white; }
.stat-card.tone-purple .stat-num  { color: #4c1d95; }

/* ===== Two-column layout (main + right panels) ===== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
}

/* ===== Lesson title block (inside attendance) ===== */
.lesson-title-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.lesson-title-card .course-tag {
  background: var(--primary);
  color: white;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}
.lesson-title-card .lesson-name {
  flex: 1;
  font-weight: 600;
  font-size: 16px;
}
.lesson-title-card .lesson-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.lesson-title-card .lesson-stats {
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
}
.lesson-title-card .lesson-stats strong {
  color: var(--text);
  font-size: 16px;
  display: block;
}

/* ===== Tabs (มาเรียน / ลา / ขาด / ทั้งหมด) ===== */
.pill-tabs {
  display: flex; gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.pill-tab {
  background: white;
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .15s;
  color: var(--text-muted);
}
.pill-tab .count {
  background: var(--bg);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.pill-tab.tone-green.active { background: var(--success); color: white; border-color: var(--success); }
.pill-tab.tone-green.active .count { background: rgba(255,255,255,.25); color: white; }
.pill-tab.tone-yellow.active { background: var(--warning); color: white; border-color: var(--warning); }
.pill-tab.tone-yellow.active .count { background: rgba(255,255,255,.25); color: white; }
.pill-tab.tone-red.active { background: var(--danger); color: white; border-color: var(--danger); }
.pill-tab.tone-red.active .count { background: rgba(255,255,255,.25); color: white; }
.pill-tab.tone-gray.active { background: var(--text); color: white; border-color: var(--text); }
.pill-tab.tone-gray.active .count { background: rgba(255,255,255,.25); color: white; }
.pill-tab:not(.active):hover { background: var(--bg); }

/* ===== Student card (grid view) ===== */
.student-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.student-grid.cols-1 { grid-template-columns: 1fr; }
.student-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border .15s, box-shadow .15s;
}
.student-card:hover { box-shadow: var(--shadow); }
.student-card.is-attended { border-color: var(--success); background: linear-gradient(90deg, var(--success-soft) 0%, white 35%); }
.student-card.is-late     { border-color: #fbbf24; background: linear-gradient(90deg, #fef3c7 0%, white 35%); }
.student-card.is-online   { border-color: #38bdf8; background: linear-gradient(90deg, var(--info-soft) 0%, white 35%); }
.student-card.is-tape     { border-color: var(--purple); background: linear-gradient(90deg, var(--purple-soft) 0%, white 35%); }
.student-card.is-excused  { border-color: var(--warning); background: linear-gradient(90deg, var(--warning-soft) 0%, white 35%); }
.student-card.is-absent   { border-color: var(--danger); background: linear-gradient(90deg, var(--danger-soft) 0%, white 35%); }
.student-card .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  font-size: 14px;
  overflow: hidden;
}
.student-card .avatar img { width: 100%; height: 100%; object-fit: cover; }
.student-card.is-attended .avatar { background: var(--success); }
.student-card.is-late     .avatar { background: #f59e0b; }
.student-card.is-online   .avatar { background: var(--info); }
.student-card.is-tape     .avatar { background: var(--purple); }
.student-card.is-excused  .avatar { background: var(--warning); }
.student-card.is-absent   .avatar { background: var(--danger); }
.student-card .info { flex: 1; min-width: 0; }
.student-card .info .name {
  font-weight: 600; font-size: 14px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.student-card .info .meta {
  font-size: 11px; color: var(--text-muted); margin-top: 2px;
}
.student-card .quick-actions {
  display: flex; gap: 4px;
}
.student-card .qa-btn {
  width: 28px; height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  display: grid; place-items: center;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
  transition: all .15s;
}
.student-card .qa-btn:hover { background: var(--bg); }
.student-card .qa-btn.is-on.on-attended { background: var(--success); color: white; border-color: var(--success); }
.student-card .qa-btn.is-on.on-late     { background: #f59e0b; color: white; border-color: #f59e0b; }
.student-card .qa-btn.is-on.on-excused  { background: var(--warning); color: white; border-color: var(--warning); }
.student-card .qa-btn.is-on.on-absent   { background: var(--danger); color: white; border-color: var(--danger); }

/* ===== Right panels ===== */
.side-panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
}
.side-panel h3 {
  margin: 0 0 12px;
  font-size: 14px;
  display: flex; align-items: center; gap: 8px;
}
.side-panel h3 .panel-pill {
  background: var(--info-soft);
  color: var(--info);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.side-panel h3 .panel-pill.tone-yellow { background: var(--accent-soft); color: #b45309; }
.side-panel h3 .panel-pill.tone-red    { background: var(--danger-soft); color: var(--danger); }

/* Donut summary panel */
.donut-summary {
  display: flex; align-items: center; gap: 14px;
}
.donut-summary canvas { width: 100px !important; height: 100px !important; flex-shrink: 0; }
.donut-summary .donut-text {
  flex: 1; font-size: 12px;
}
.donut-summary .donut-text .row {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 0;
  font-size: 12px;
  flex-wrap: nowrap;
}
.donut-summary .donut-text .dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.donut-summary .donut-text .label { flex: 1; color: var(--text-muted); }
.donut-summary .donut-text .value { font-weight: 600; color: var(--text); }

/* Upcoming list */
.upcoming-list { display: flex; flex-direction: column; gap: 8px; }
.upcoming-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  background: var(--bg);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
}
.upcoming-item:hover { background: var(--primary-soft); text-decoration: none; }
.upcoming-item .day-tag {
  width: 32px; flex-shrink: 0;
  text-align: center;
  border-radius: 8px;
  padding: 4px 0;
  background: white;
  border: 1px solid var(--border);
  line-height: 1;
}
.upcoming-item .day-tag .num { font-weight: 700; font-size: 14px; }
.upcoming-item .day-tag .day { font-size: 9px; color: var(--text-muted); }
.upcoming-item .info { flex: 1; min-width: 0; }
.upcoming-item .info .title { font-weight: 600; font-size: 13px; line-height: 1.2; }
.upcoming-item .info .meta  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.upcoming-item .arrow { color: var(--text-dim); }

/* Low-attendance alerts */
.low-att-list { display: flex; flex-direction: column; gap: 6px; }
.low-att-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
}
.low-att-item:hover { background: var(--danger-soft); text-decoration: none; }
.low-att-item .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #ddd;
  display: grid; place-items: center;
  font-weight: 700; color: white;
  font-size: 12px; flex-shrink: 0;
  overflow: hidden;
}
.low-att-item .avatar img { width: 100%; height: 100%; object-fit: cover; }
.low-att-item .name { flex: 1; font-size: 13px; font-weight: 500; }
.low-att-item .pct { font-weight: 700; color: var(--danger); font-size: 13px; }
.low-att-item .pct.warn { color: var(--warning); }

/* ===== Bottom save bar ===== */
.save-bar {
  background: var(--text);
  color: white;
  border-radius: 14px;
  padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
  position: sticky;
  bottom: 12px;
  box-shadow: 0 8px 24px rgba(15,23,42,.18);
  z-index: 4;
}
.save-bar .save-status {
  font-size: 13px;
  display: flex; align-items: center; gap: 8px;
  flex: 1;
}
.save-bar .save-status .pulse {
  width: 8px; height: 8px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
}
.save-bar .save-status .pulse.saving { background: var(--accent); animation: pulse 1s infinite; }
.save-bar .save-status .pulse.error { background: var(--danger); }
@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: .35; }
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: white;
  border: 0;
  padding: 9px 16px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-success { background: var(--success); }
.btn-success:hover { background: #15803d; }
.btn-warning { background: var(--accent); color: #78350f; }
.btn-warning:hover { background: #f59e0b; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-light { background: rgba(255,255,255,.18); color: white; border: 1px solid rgba(255,255,255,.3); backdrop-filter: blur(4px); }
.btn-light:hover { background: rgba(255,255,255,.28); }
.btn-yellow { background: var(--accent); color: #78350f; box-shadow: 0 4px 12px rgba(251,191,36,.35); }
.btn-yellow:hover { background: #f59e0b; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

/* ===== Forms ===== */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}
.input, .select, textarea.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  background: white;
  outline: none;
  transition: border .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44,90,160,.12);
}

/* ===== Tables ===== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.table tbody tr:hover { background: var(--bg); }

/* ===== Alerts ===== */
.alert {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  margin-bottom: 12px;
  font-size: 14px;
}
.alert-error   { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }
.alert-success { background: var(--success-soft); border-color: #bbf7d0; color: #14532d; }
.alert-info    { background: var(--info-soft); border-color: #bae6fd; color: #075985; }
.alert-warn    { background: var(--warning-soft); border-color: #fde68a; color: #78350f; }

/* ===== Utility ===== */
.muted { color: var(--text-muted); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.text-center { text-align: center; }
.mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.hidden { display: none !important; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.badge-onsite  { background: var(--success-soft); color: #166534; }
.badge-online  { background: var(--info-soft); color: #075985; }
.badge-tape    { background: var(--purple-soft); color: #6b21a8; }
.badge-excused { background: var(--warning-soft); color: #92400e; }
.badge-absent  { background: var(--danger-soft); color: #991b1b; }
.badge-late    { background: #fed7aa; color: #9a3412; }

/* ===== Auth pages ===== */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #eaf1fb 0%, #f5f3ff 100%);
  padding: 20px;
}
.auth-card {
  background: white;
  border-radius: 20px;
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 50px rgba(0,0,0,.08);
}
.auth-card .auth-logo {
  width: 64px; height: 64px;
  border-radius: 16px;
  margin: 0 auto 16px;
  display: block;
  object-fit: contain;
}
.auth-card h1 { text-align: center; margin-bottom: 4px; font-size: 22px; }
.auth-card .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: 14px; }

/* ===== Filter row ===== */
.filter-row {
  display: grid;
  gap: 12px;
  align-items: end;
}
.filter-row.cols-4 { grid-template-columns: 2fr 1fr 2fr 110px; }
.filter-row.cols-3 { grid-template-columns: 2fr 1fr 1fr; }

/* ===== Quick action grid (index/home) ===== */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.quick-tile {
  background: white;
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  transition: transform .15s, box-shadow .15s, border .15s;
  display: block;
}
.quick-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
  border-color: var(--primary);
}
.quick-tile .icon { font-size: 32px; margin-bottom: 8px; }
.quick-tile .label { font-weight: 600; }
.quick-tile .desc { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.stat-tile {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
.stat-tile .value { font-size: 1.9rem; font-weight: 700; color: var(--primary); margin-top: 4px; }
.stat-tile .label { font-size: 12px; color: var(--text-muted); }

/* ===== Recent activity row (index) ===== */
.recent-item {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.recent-item:last-child { border-bottom: 0; }
.recent-item .when { font-size: 12px; color: var(--text-muted); width: 130px; flex-shrink: 0; }
.recent-item .what { flex: 1; }

/* Sidebar overlay (desktop default: hidden; mobile: shown when sidebar open) */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }
.sidebar-overlay.show { display: block; }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  :root { --sidebar-w: 200px; }
  .two-col { grid-template-columns: 1fr 280px; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: -260px;
    width: 240px;
    height: 100vh;
    z-index: 100;
    box-shadow: 0 0 30px rgba(0,0,0,.15);
    transition: left .25s;
  }
  .sidebar.open { left: 0; }
  .sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
    display: none;
  }
  .sidebar-overlay.show { display: block; }
  .menu-toggle {
    display: grid !important;
    place-items: center;
    width: 36px; height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
  }
  .crumbs { font-size: 12px; }
  .search-box { width: 160px; }
  .stat-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .student-grid { grid-template-columns: 1fr; }
  .filter-row.cols-4 { grid-template-columns: 1fr 1fr; }
  .filter-row.cols-3 { grid-template-columns: 1fr; }
  .hero-card { padding: 18px; flex-direction: column; align-items: flex-start; }
  .hero-card h1 { font-size: 22px; }
  .main { padding: 0 16px 24px; }
  .app-header { padding: 12px 16px; }
}
.menu-toggle { display: none; }

@media (max-width: 700px) {
  /* Hide breadcrumbs + search on small screens, leaves more room */
  .crumbs { display: none; }
  .search-box { display: none; }
  .app-header { padding: 10px 14px; gap: 8px; }
  .icon-btn { width: 32px; height: 32px; }

  /* Hero card: tighter, full-width buttons */
  .hero-card { padding: 16px; gap: 12px; border-radius: 16px; }
  .hero-card::before { width: 130px; height: 130px; right: 30px; top: -20px; }
  .hero-card::after { width: 90px; height: 90px; right: -20px; bottom: -30px; }
  .hero-card h1 { font-size: 18px; }
  .hero-card .hero-pill { font-size: 11px; padding: 3px 10px; }
  .hero-card .hero-sub { font-size: 12px; }
  .hero-card .hero-actions { width: 100%; flex-direction: column; gap: 8px; }
  .hero-card .hero-actions .btn { width: 100%; justify-content: center; padding: 10px; font-size: 13px; }

  /* Stat cards: 2x2 with smaller numbers */
  .stat-grid-4 { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-card .stat-icon { width: 32px; height: 32px; font-size: 16px; border-radius: 10px; }
  .stat-card .stat-num { font-size: 20px; }
  .stat-card .stat-label { font-size: 11px; }

  /* Filter row + view toggle: stack */
  .filter-row.cols-4 { grid-template-columns: 1fr 1fr; gap: 8px; }
  .filter-row .field label { font-size: 12px; }
  .view-toggle { width: 100%; }
  .view-toggle button { flex: 1; }

  /* Lesson title card */
  .lesson-title-card { flex-wrap: wrap; padding: 12px; gap: 8px; }
  .lesson-title-card .lesson-stats { width: 100%; text-align: left; display: flex; gap: 10px; }
  .lesson-title-card .lesson-stats strong { display: inline; font-size: 14px; }

  /* Pill tabs: smaller */
  .pill-tabs { gap: 6px; }
  .pill-tab { padding: 5px 10px; font-size: 12px; }

  /* Bulk action bar wraps */
  .card .row { gap: 4px; }

  /* Table: horizontal scroll on mobile */
  .att-table { font-size: 12px; }
  .att-table th, .att-table td { padding: 4px; }
  .att-table .name { min-width: 110px; }
  .att-table .behavior { min-width: 140px; }
  .att-table .status-cell { width: 38px; }
  .att-table input[type=radio] { transform: scale(1); }
  .att-table input[type=checkbox] { transform: scale(1); }
  .table-wrap { max-height: calc(100vh - 280px); }

  /* Save bar */
  .save-bar { padding: 8px 12px; font-size: 12px; }
  .save-bar .save-status { font-size: 11px; }

  /* Cards padding */
  .card { padding: 14px; border-radius: 12px; }
  .main { padding: 0 12px 20px; gap: 10px; }
  .side-panel { padding: 14px; }
}

@media (max-width: 460px) {
  .stat-grid-4 { grid-template-columns: 1fr 1fr; }
  .hero-card h1 { font-size: 16px; }
  .filter-row.cols-4 { grid-template-columns: 1fr; }
}

/* ===== Print ===== */
@media print {
  .sidebar, .app-header, .save-bar, .pill-tabs, button { display: none !important; }
  .app-shell { display: block; }
  .card, .side-panel { border: 0; box-shadow: none; padding: 0; }
  body { background: white; }
}
