/* ── NKW Bright Theme ────────────────────────────────────────────────────────
   Blues: #2C5EAD #1591DC #4BB8FA #C4E2F5
   Warm:  #FF5A5A #FF8B5A #FFA95A #FFD45A
─────────────────────────────────────────────────────────────────────────────*/
:root {
  --blue-900: #2C5EAD;
  --blue-600: #1591DC;
  --blue-400: #4BB8FA;
  --blue-100: #C4E2F5;
  --red:      #FF5A5A;
  --orange:   #FF8B5A;
  --amber:    #FFA95A;
  --yellow:   #FFD45A;

  --brand:        #1591DC;   /* primary accent       */
  --brand-dark:   #2C5EAD;   /* darker / headers     */
  --brand-light:  #4BB8FA;
  --brand-text:   #ffffff;

  --bg-base:    #eef6fc;     /* very light blue page bg */
  --bg-soft:    #dcecf9;     /* (overridden below)      */
  --bg-soft:    #e3f0fa;
  --bg-card:    #ffffff;
  --bg-input:   #ffffff;
  --bg-sidebar: #2C5EAD;

  --border-color: #cfe4f3;
  --text-main:    #1f3a52;
  --text-muted:   #6b8299;
  --shadow:       0 4px 16px rgba(21,145,220,.12);
  --shadow-lg:    0 8px 28px rgba(44,94,173,.20);
}

/* ── Base ──────────────────────────────────────────────────────────────────── */
html { background-color: var(--bg-base); }
body {
  background-color: var(--bg-base) !important;
  color: var(--text-main) !important;
  font-family: 'Inter', 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-feature-settings: 'cv05' 1, 'ss01' 1;   /* Inter's open-tail letterforms — cleaner, less generic */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.006em;
  min-height: 100vh;
}
/* Headings: tighter tracking + balanced wrapping → professional/editorial feel */
h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6 { letter-spacing: -0.018em; text-wrap: balance; }
.fw-bold,.fw-semibold,b,strong { letter-spacing: -0.01em; }
/* Tabular numerals everywhere numbers matter (scores, stats, tables) read aligned */
.stat-val,.cw-stat .num,.table,.badge,.score-input,.score-cell { font-variant-numeric: tabular-nums; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }
hr { border-color: var(--border-color); opacity: 1; }

/* ── Navbar ─────────────────────────────────────────────────────────────────── */
.app-navbar {
  background: linear-gradient(90deg, #2C5EAD 0%, #1591DC 100%);
  border-bottom: 3px solid var(--yellow);
  box-shadow: var(--shadow);
}
.app-navbar .navbar-brand { color: #fff !important; font-weight: 700; }
.app-navbar .navbar-toggler { border-color: rgba(255,255,255,.5); }
.app-navbar .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23ffffff' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
.app-navbar .nav-link {
  color: rgba(255,255,255,.92) !important;
  font-weight: 500;
  border-radius: 10px;
  padding: 6px 14px;
  margin: 0 2px;
  transition: .2s;
  position: relative;
}
.app-navbar .nav-link:hover { color: #fff !important; background: rgba(255,255,255,.16); }
.app-navbar .nav-link.active {
  color: #fff !important;
  background: rgba(255,255,255,.22);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
.app-navbar .nav-link.active::after {
  content: '';
  position: absolute;
  left: 14px; right: 14px; bottom: 2px;
  height: 3px;
  border-radius: 3px;
  background: var(--yellow);
}
.app-navbar .dropdown-menu,
.app-navbar .dropdown-menu-dark {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: var(--shadow-lg);
}
.app-navbar .dropdown-item,
.dropdown-menu-dark .dropdown-item { color: var(--text-main) !important; }
.app-navbar .dropdown-item:hover,
.dropdown-menu-dark .dropdown-item:hover { background: var(--bg-soft) !important; color: var(--brand-dark) !important; }
.dropdown-divider { border-color: var(--border-color); opacity: 1; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: var(--shadow);
  color: var(--text-main);
}
.card-header {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  color: var(--brand-dark);
  border-radius: 14px 14px 0 0 !important;
}
.card-footer {
  background: rgba(196,226,245,.35);
  border-top: 1px solid var(--border-color);
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn-brand { background: var(--btn); color: #fff; border: none; font-weight: 600; }
.btn-brand:hover { background: var(--btn-dark); color: #fff; }
.btn-brand:focus { box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--btn) 40%, transparent); }

.btn-outline-brand { border: 2px solid var(--btn); color: var(--btn); background: transparent; font-weight: 600; }
.btn-outline-brand:hover { background: var(--btn); color: #fff; }

/* ── b2 star buttons — applied to all .btn except back/close (stars injected by main.js, ref b2.html/css) ── */
.btn-star { position: relative; transition: box-shadow .3s ease-in-out, transform .15s ease, background .2s, color .2s; }
.btn-star:hover { box-shadow: 0 0 16px color-mix(in srgb, var(--b2, var(--btn, var(--brand))) 45%, transparent); transform: translateY(-1px); }
.btn-star .b2star { position: absolute; height: auto; z-index: -5; pointer-events: none; line-height: 0; opacity: 0; transition: opacity .2s;
  filter: drop-shadow(0 0 0 #fffdef); transition: all .8s cubic-bezier(0,.4,0,1.01); }
.btn-star .b2star svg { display: block; width: 100%; height: auto; }
.btn-star .b2star path { fill: var(--b2, var(--btn, var(--brand))); }
.btn-star .b2s1 { top:20%; left:18%; width:16px; transition: all 1s cubic-bezier(.05,.83,.43,.96); }
.btn-star .b2s2 { top:45%; left:45%; width:11px; }
.btn-star .b2s3 { top:40%; left:38%; width:5px; }
.btn-star .b2s4 { top:20%; left:40%; width:7px; }
.btn-star .b2s5 { top:28%; left:48%; width:11px; }
.btn-star .b2s6 { top:8%;  left:52%; width:5px; }
.btn-star:hover .b2s1 { top:-70%; left:-25%; filter: drop-shadow(0 0 8px #fffdef); z-index:2; }
.btn-star:hover .b2s2 { top:-20%; left:12%;  filter: drop-shadow(0 0 8px #fffdef); z-index:2; }
.btn-star:hover .b2s3 { top:55%;  left:22%;  filter: drop-shadow(0 0 8px #fffdef); z-index:2; }
.btn-star:hover .b2s4 { top:30%;  left:82%;  filter: drop-shadow(0 0 8px #fffdef); z-index:2; }
.btn-star:hover .b2s5 { top:22%;  left:108%; filter: drop-shadow(0 0 8px #fffdef); z-index:2; }
.btn-star:hover .b2s6 { top:5%;   left:62%;  filter: drop-shadow(0 0 8px #fffdef); z-index:2; }
/* Reveal sparkles only on real-hover devices — prevents sticky fly-out on phones/tablets */
@media (hover: hover) and (pointer: fine) { .btn-star:hover .b2star { opacity: 1; } }
@media (hover: none), (pointer: coarse) { .btn-star:hover { box-shadow: none; transform: none; } }
.btn-star.btn-success { --b2:#03a65a; }
.btn-star.btn-danger, .btn-star.btn-outline-danger { --b2:#db3056; }
.btn-star.btn-warning { --b2:#fc8621; }
.btn-star.btn-light, .btn-star.btn-secondary, .btn-star.btn-outline-secondary { --b2: var(--brand); }

.btn-primary   { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-success   { background: #2bb673; border-color: #2bb673; }
.btn-success:hover { background: #239d62; border-color: #239d62; }
.btn-warning   { background: var(--amber); border-color: var(--amber); color: #5a3000; }
.btn-warning:hover { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-danger    { background: var(--red); border-color: var(--red); }
.btn-danger:hover { background: #e84545; border-color: #e84545; }
.btn-outline-secondary { color: var(--text-muted); border-color: var(--border-color); }
.btn-outline-secondary:hover { background: var(--bg-soft); color: var(--brand-dark); border-color: var(--brand); }
.btn-outline-danger { color: var(--red); border-color: var(--red); }
.btn-outline-danger:hover { background: var(--red); color: #fff; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-control, .form-select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.form-control:focus, .form-select:focus {
  background: var(--bg-input);
  border-color: var(--brand);
  color: var(--text-main);
  box-shadow: 0 0 0 .2rem rgba(21,145,220,.25);
}
.form-control::placeholder { color: var(--text-muted); }
.input-group-text { background: var(--bg-soft); border-color: var(--border-color); color: var(--brand-dark); }
.form-label { color: var(--text-main); font-weight: 500; }
.form-text  { color: var(--text-muted); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table { color: var(--text-main); --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { background-color: transparent; color: var(--text-main); border-bottom-color: var(--border-color); }
/* a card wrapping a table clips the rounded corners cleanly */
.card > .table-responsive { border-radius: inherit; }
.card > .table-responsive:not(:first-child) { border-top-left-radius: 0; border-top-right-radius: 0; }

/* ── Modern light-header table (redesigned — airy, brand-underline, accent hover) ── */
.table-dark-custom thead th {
  background: color-mix(in srgb, var(--bg-soft) 60%, var(--bg-card));
  color: var(--brand-dark);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--brand);
  white-space: nowrap;
  padding: .82rem .9rem;
  vertical-align: middle;
}
html.dark .table-dark-custom thead th { color: var(--brand-light, #7ec8f7); }
/* dense grids (gradebook) keep light column separators for structure */
.gradebook-table thead th:not(:last-child),
.gradebook-table tbody td:not(:last-child) { border-right: 1px solid color-mix(in srgb, var(--border-color) 55%, transparent); }

/* normal tables: clean white rows, thin dividers, brand left-accent + tint on hover (NOT gradebook — its sticky cells need opaque bg) */
.table-dark-custom:not(.gradebook-table) tbody td {
  padding: .85rem .95rem; vertical-align: middle;
  border-bottom: 1px solid color-mix(in srgb, var(--border-color) 55%, transparent);
  background: var(--bg-card);
  box-shadow: inset 0 0 0 0 var(--brand); transition: box-shadow .15s ease, background .15s ease;
}
.table-dark-custom:not(.gradebook-table) tbody tr:hover td { background: color-mix(in srgb, var(--brand) 7%, var(--bg-card)); }
.table-dark-custom:not(.gradebook-table) tbody tr:hover td:first-child { box-shadow: inset 4px 0 0 var(--brand); }
.table-dark-custom:not(.gradebook-table) tbody tr:last-child td { border-bottom: none; }
/* accent the first column (the row's identity — name / no. / title) */
.table-dark-custom:not(.gradebook-table) tbody td:first-child { font-weight: 700; color: var(--brand-dark); }
html.dark .table-dark-custom:not(.gradebook-table) tbody td:first-child { color: var(--brand-light, #7ec8f7); }
.gradebook-table tbody tr:hover td { background: color-mix(in srgb, var(--brand) 8%, var(--bg-card)); }
/* round the header's outer corners when the table sits at the top of a card */
.card > .table-responsive > .table-dark-custom thead tr:first-child th:first-child { border-top-left-radius: var(--bs-border-radius, .5rem); }
.card > .table-responsive > .table-dark-custom thead tr:first-child th:last-child  { border-top-right-radius: var(--bs-border-radius, .5rem); }

/* generic (non-dark) tables: lightweight hover */
.table:not(.table-dark-custom) tbody tr:hover td { background: rgba(75,184,250,.08); }

/* ── Gradebook ──────────────────────────────────────────────────────────────── */
.gradebook-wrapper { overflow: auto; max-height: 75vh; border-radius: 10px; border: 1px solid var(--border-color); }
.gradebook-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--brand-dark); color: #fff; white-space: nowrap;
}
.gradebook-table .col-sticky { position: sticky; left: 0; z-index: 1; background: var(--bg-card); }
.gradebook-table thead th:first-child { z-index: 3; background: #244c8c; }

.score-input {
  width: 64px; text-align: center;
  background: var(--bg-input); border: 1px solid var(--border-color);
  color: var(--text-main); border-radius: 6px; padding: 2px 4px;
}
.score-input:focus { border-color: var(--brand); outline: none; }
.score-input.saving { border-color: var(--amber); }
.score-input.saved  { border-color: #2bb673; }
.score-input.error  { border-color: var(--red); }

/* ── Attendance ──────────────────────────────────────────────────────────────── */
.att-btn { min-width: 48px; font-size: .75rem; padding: 3px 6px; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.grade-badge { font-size: 1rem; font-weight: 700; min-width: 40px; display: inline-block; text-align: center; }
.badge.bg-secondary { background-color: var(--blue-100) !important; color: var(--blue-900) !important; }
.badge.bg-primary   { background-color: var(--blue-600) !important; }
.badge.bg-success   { background-color: #2bb673 !important; }
.badge.bg-info      { background-color: var(--blue-400) !important; color: #fff !important; }
.badge.bg-warning   { background-color: var(--amber) !important; color: #5a3000 !important; }
.badge.bg-danger    { background-color: var(--red) !important; }
.badge.bg-brand     { background: var(--brand) !important; color: #fff !important; }

/* ── Auth cards ─────────────────────────────────────────────────────────────── */
.auth-card { max-width: 420px; margin: 80px auto; }
.auth-card .card { background: #fff; border: 2px solid var(--border-color); }
.auth-card .card-body { padding: 2rem; }

/* ── Leaderboard ranks ─────────────────────────────────────────────────────── */
.lb-rank-1 { background: linear-gradient(135deg, #FFD45A 0%, #FFA95A 100%); color: #5a3000; }
.lb-rank-2 { background: linear-gradient(135deg, #4BB8FA 0%, #1591DC 100%); color: #fff; }
.lb-rank-3 { background: linear-gradient(135deg, #C4E2F5 0%, #4BB8FA 100%); color: #143b5c; }

/* ── Code cards ─────────────────────────────────────────────────────────────── */
.code-card { border: 2px dashed var(--border-color); border-radius: 10px; padding: 12px 16px; margin-bottom: 8px; background: #fff; }
.code-text { font-family: 'Courier New', monospace; font-size: 1.4rem; font-weight: 700; letter-spacing: .15em; color: var(--brand-dark); }

/* ── Group cards ─────────────────────────────────────────────────────────────── */
.group-card { border: 2px solid var(--brand); border-radius: 14px; padding: 16px; text-align: center; background: #fff; }
.group-img { width: 80px; height: 80px; object-fit: cover; border-radius: 50%; border: 3px solid var(--brand); }
.group-placeholder {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--bg-soft);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 2rem; color: var(--brand); border: 3px solid var(--brand);
}

/* ── Modals ──────────────────────────────────────────────────────────────────── */
.modal-content { background: #fff; border: 1px solid var(--border-color); color: var(--text-main); border-radius: 14px; }
.modal-header  { background: var(--bg-soft); border-bottom: 1px solid var(--border-color); border-radius: 14px 14px 0 0; }
.modal-header .modal-title { color: var(--brand-dark); }
.modal-footer  { border-top: 1px solid var(--border-color); background: rgba(196,226,245,.2); }

/* ── List groups ─────────────────────────────────────────────────────────────── */
.list-group-item { background: transparent; color: var(--text-main); border-color: var(--border-color); }
.list-group-item-action:hover { background: rgba(75,184,250,.12); color: var(--text-main); }
.list-group-item.active { background: var(--brand) !important; border-color: var(--brand) !important; color: #fff !important; }
/* keep list rows readable regardless of stray text-light/text-muted */
.list-group-item-action:not(.active) { color: var(--text-main); }
.list-group-item.active .text-muted,
.list-group-item.active small { color: rgba(255,255,255,.85) !important; }

/* ── Nav tabs ──────────────────────────────────────────────────────────────── */
.nav-tabs { border-bottom-color: var(--border-color); }
.nav-tabs .nav-link { color: var(--text-muted); border: none; }
.nav-tabs .nav-link:hover { color: var(--brand-dark); }
.nav-tabs .nav-link.active { background: transparent; border-bottom: 3px solid var(--brand); color: var(--brand-dark); font-weight: 600; }

/* ── Alerts ──────────────────────────────────────────────────────────────────── */
.alert { border-radius: 10px; border: 1px solid transparent; }
.alert-success { background: #e3f7ee; color: #1b7a4f; border-color: #b9e8d2; }
.alert-danger  { background: #ffe7e7; color: #c43030; border-color: #ffc9c9; }
.alert-warning { background: #fff3e0; color: #a85b1a; border-color: #ffdcae; }
.alert-info    { background: #e3f2fc; color: #1c5e8a; border-color: #c0e2f7; }
.alert-secondary { background: var(--bg-soft); color: var(--text-main); border-color: var(--border-color); }

/* ── Pagination ──────────────────────────────────────────────────────────────── */
.page-link { background: var(--bg-card); border-color: var(--border-color); color: var(--brand); }
.page-link:hover { background: var(--bg-soft); }
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ── Utilities ───────────────────────────────────────────────────────────────── */
.text-brand   { color: var(--brand) !important; }
.bg-brand     { background: var(--brand) !important; }
.border-brand { border-color: var(--brand) !important; }
.text-success { color: #2bb673 !important; }
.text-danger  { color: var(--red) !important; }
.text-warning { color: #d6841f !important; }
.text-muted   { color: var(--text-muted) !important; }

/* ── School logo ─────────────────────────────────────────────────────────────── */
.school-logo-nav { height: 38px; width: auto; object-fit: contain; margin-right: 8px; border-radius: 6px; background:#fff; padding:2px; }

/* ── Dashboard ──────────────────────────────────────────────────────────────── */
.dash-hero {
  background: linear-gradient(120deg, #2C5EAD 0%, #1591DC 60%, #4BB8FA 100%);
  color: #fff;
  border-radius: 18px;
  padding: 28px 32px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.dash-hero::after { content: ''; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; background: rgba(255,255,255,.12); border-radius: 50%; }
.dash-hero h3 { font-weight: 700; margin: 0; }
.dash-hero .sub { opacity: .9; font-size: .9rem; }

.stat-card { border: none; border-radius: 16px; color: #fff; box-shadow: var(--shadow); overflow: hidden; position: relative; transition: transform .2s, box-shadow .2s; }
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
a.stat-card { cursor: pointer; display: block; }
a.stat-card:hover { text-decoration: none; }
a.stat-card .stat-label { text-decoration: none; }
.stat-card .stat-icon { font-size: 2.4rem; opacity: .35; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); }
.stat-card .stat-val { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-card .stat-label { font-size: .82rem; opacity: .95; }
.stat-1 { background: linear-gradient(135deg, #1591DC, #2C5EAD); }
.stat-2 { background: linear-gradient(135deg, #4BB8FA, #1591DC); }
.stat-3 { background: linear-gradient(135deg, #FF8B5A, #FF5A5A); }
.stat-4 { background: linear-gradient(135deg, #FFD45A, #FFA95A); color: #5a3000; }

.course-tile { border-radius: 16px; border: 1px solid var(--border-color); background: #fff; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s; overflow: hidden; }
.course-tile:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.course-tile .tile-top { height: 8px; background: linear-gradient(90deg, var(--blue-600), var(--blue-400)); }

/* ════════════════════════════════════════════════════════════════════════════
   APP SHELL (ex2-inspired: topbar + sidebar + scrollable content)
════════════════════════════════════════════════════════════════════════════ */
html, body { height: 100%; }
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-base);
}

/* ── Topbar ──────────────────────────────────────────────────────────────────── */
.app-topbar {
  flex-shrink: 0;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 2px 10px rgba(21,145,220,.06);
  z-index: 30;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.app-topbar .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.app-topbar .brand img { height: 38px; width: auto; object-fit: contain; border-radius: 6px; }
.app-topbar .brand-name { font-weight: 800; color: var(--brand-dark); font-size: 1.05rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
html.dark .app-topbar .brand-name { color: var(--brand-light); }
/* mobile topbar: keep the school name on ONE line, tighter spacing */
@media (max-width: 600px) {
  .app-topbar { padding: 0 10px; }
  .topbar-left, .topbar-right { gap: 6px; }
  .app-topbar .brand img { height: 32px; }
  .app-topbar .brand-name { font-size: .95rem; max-width: 38vw; }
}
@media (max-width: 400px) { .app-topbar .brand-name { display: none; } }
.sidebar-toggle {
  display: none; border: none; background: transparent; font-size: 1.4rem;
  color: var(--brand-dark); cursor: pointer; padding: 4px 8px;
}
.topbar-icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border-color); background: var(--bg-soft);
  color: var(--brand-dark); display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem; cursor: pointer; transition: .2s;
}
.topbar-icon-btn:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.topbar-icon-btn .theme-icon-moon { display: none; }
html.dark .topbar-icon-btn .theme-icon-sun  { display: none; }
html.dark .topbar-icon-btn .theme-icon-moon { display: inline; }
.profile-chip {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border-color); background: var(--bg-soft);
  border-radius: 24px; padding: 4px 12px 4px 4px; cursor: pointer;
  color: var(--text-main); font-weight: 600;
}
.profile-chip:hover { background: var(--bg-card); }

/* ── Body + Sidebar ──────────────────────────────────────────────────────────── */
.app-body { flex: 1; display: flex; overflow: hidden; min-height: 0; }
.app-sidebar {
  flex-shrink: 0;
  width: 92px;
  background: var(--bg-card);
  border-right: 1px solid var(--border-color);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  overflow-y: auto;
  z-index: 20;
}
.sidebar-spacer { flex: 1; }
.sidebar-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 10px 4px; border-radius: 14px;
  color: var(--text-muted); text-decoration: none; transition: .18s;
  text-align: center;
}
.sidebar-link i { font-size: 1.35rem; }
.sidebar-link .sidebar-label { font-size: .68rem; line-height: 1.1; font-weight: 600; }
.sidebar-link:hover { background: var(--bg-soft); color: var(--brand-dark); }
.sidebar-link.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; box-shadow: 0 6px 16px rgba(21,145,220,.35);
}
html.dark .sidebar-link.active { box-shadow: 0 6px 16px rgba(0,0,0,.5); }

/* ── Page content ────────────────────────────────────────────────────────────── */
.page-main { flex: 1; overflow-y: auto; min-width: 0; }
.page-inner { max-width: 1400px; margin: 0 auto; padding: 22px 26px 40px; }
.page-footer {
  text-align: center; color: var(--text-muted); font-size: .8rem;
  padding-top: 24px; margin-top: 24px; border-top: 1px solid var(--border-color);
}

/* ── Responsive sidebar (off-canvas on mobile) ───────────────────────────────── */
@media (max-width: 820px) {
  .sidebar-toggle { display: inline-flex; }
  .app-sidebar {
    position: fixed; top: 62px; left: 0; bottom: 0;
    width: 200px; align-items: stretch;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 6px 0 24px rgba(0,0,0,.18);
  }
  .app-sidebar.open { transform: translateX(0); }
  .app-sidebar .sidebar-link { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 12px 14px; }
  .app-sidebar .sidebar-link i { font-size: 1.2rem; }
  .app-sidebar .sidebar-label { font-size: .9rem; }
  .page-inner { padding: 16px 14px 32px; }
}

/* ── ex2 Project-box course cards ────────────────────────────────────────────── */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 18px; }
.proj-box {
  border-radius: 22px;
  padding: 18px 18px 14px;
  background: var(--pb, #dbeafe);
  color: #1f2a44;
  transition: transform .2s, box-shadow .2s;
  display: flex; flex-direction: column; min-height: 190px;
  border: 1px solid rgba(0,0,0,.04);
}
.proj-box:hover { transform: translateY(-5px); box-shadow: 0 14px 30px rgba(0,0,0,.14); }
.proj-box .pb-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.proj-box .pb-code {
  font-weight: 700; font-size: .72rem; letter-spacing: .04em;
  background: rgba(255,255,255,.65); padding: 3px 10px; border-radius: 20px; color: #2c3e50;
}
.proj-box .pb-title { font-weight: 800; font-size: 1.05rem; line-height: 1.25; margin: 2px 0 2px; }
.proj-box .pb-sub { font-size: .78rem; opacity: .82; }
.proj-box .pb-progress-label { display:flex; justify-content:space-between; font-size:.72rem; font-weight:700; opacity:.8; margin-bottom:4px; }
.proj-box .pb-bar { height: 6px; border-radius: 6px; background: rgba(255,255,255,.6); overflow: hidden; }
.proj-box .pb-bar > span { display: block; height: 100%; border-radius: 6px; background: var(--pb-accent, #2563eb); }
.proj-box .pb-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 12px; }
.proj-box .pb-chip {
  background: rgba(255,255,255,.7); border-radius: 20px; padding: 5px 12px;
  font-size: .72rem; font-weight: 700; color: var(--pb-accent, #2563eb);
}
.proj-box .pb-grade {
  width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.8);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.1rem;
  color: var(--pb-accent, #2563eb);
}
/* palette */
.pb-c1 { --pb:#fee4cb; --pb-accent:#ff942e; }
.pb-c2 { --pb:#e9e7fd; --pb-accent:#4f3ff0; }
.pb-c3 { --pb:#dbf6fd; --pb-accent:#096c86; }
.pb-c4 { --pb:#ffd3e2; --pb-accent:#df3670; }
.pb-c5 { --pb:#c8f7dc; --pb-accent:#34c471; }
.pb-c6 { --pb:#d5deff; --pb-accent:#4067f9; }
html.dark .proj-box { color: #11161f; }   /* keep pastel cards readable in dark */
/* pastel cards are always light-bg → force readable dark text on muted/inner bits in dark mode */
html.dark .proj-box .text-muted, .proj-box .text-muted { color: #57637a !important; }
html.dark .course-tile, html.dark .course-tile .text-muted { color: var(--text-main); }

/* teacher action row under a project box */
.proj-actions { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; margin-top: 10px; }

/* ── Classwork hub stat cards (white + emoji) ───────────────────────────────── */
.cw-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 24px; }
.cw-stat {
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 16px;
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.cw-stat::after { content:""; position:absolute; right:-20px; top:-20px; width:70px; height:70px; border-radius:50%; background: var(--bg-soft); opacity:.6; }
.cw-stat .ic  { font-size: 1.4rem; display: block; margin-bottom: 6px; position: relative; z-index: 1; }
.cw-stat .num { font-weight: 800; font-size: 1.9rem; line-height: 1; color: var(--text-main); }
.cw-stat .lb  { font-size: .82rem; color: var(--text-muted); margin-top: 4px; }
a.cw-stat-link { display: block; text-decoration: none; transition: transform .15s, box-shadow .15s, border-color .15s; }
a.cw-stat-link:hover { transform: translateY(-3px); box-shadow: 0 .6rem 1.4rem rgba(26,31,67,.18); border-color: var(--brand); }
.cw-stat-go { position: absolute; right: 12px; bottom: 12px; color: var(--text-muted); opacity: .55; font-size: .9rem; z-index: 1; }
a.cw-stat-link:hover .cw-stat-go { color: var(--brand); opacity: 1; }
a.cw-stat-link.cw-stat-on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand) inset; }
a.cw-stat-link.cw-stat-on .cw-stat-go { color: var(--brand); opacity: 1; }
@media (max-width: 760px) { .cw-stats { grid-template-columns: 1fr 1fr; } }

/* summary: clickable student name → per-individual report */
.sg-name-link { border-bottom: 1px dashed transparent; transition: color .15s, border-color .15s; }
.sg-name-link:hover { color: var(--brand) !important; border-bottom-color: var(--brand); }
.indiv-hero { border-left: 4px solid var(--brand); }
.indiv-subject .card-header { background: var(--bg-soft); }

/* ── Confirm popup (pop.css style) — for score/grade-affecting actions ── */
.sg-pop-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; z-index: 4000; opacity: 0; transition: opacity .16s; padding: 16px; }
.sg-pop-overlay.show { opacity: 1; }
.sg-pop { width: 330px; max-width: 100%; background: var(--bg-card); border-radius: 20px;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px; padding: 30px 28px 26px;
  position: relative; box-shadow: 0 24px 60px rgba(0,0,0,.28); transform: translateY(10px) scale(.97); transition: transform .16s; }
.sg-pop-overlay.show .sg-pop { transform: none; }
.sg-pop-ic { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.7rem; }
.sg-pop-ic.is-brand  { background: var(--bg-soft); }
.sg-pop-ic.is-danger { background: rgba(255,114,109,.16); }
.sg-pop-content { width: 100%; display: flex; flex-direction: column; gap: 5px; }
.sg-pop-heading { font-size: 1.18rem; font-weight: 700; color: var(--text-main); margin: 0; }
.sg-pop-desc { font-weight: 400; color: var(--text-muted); font-size: .92rem; margin: 0; line-height: 1.5; }
.sg-pop-btns { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 4px; }
.sg-pop-btn { width: 50%; height: 40px; border-radius: 10px; border: none; cursor: pointer; font-weight: 600; transition: filter .15s, background .15s; }
.sg-pop-btn:hover { filter: brightness(.94); }
.sg-pop-primary { background: var(--brand); color: #fff; }
.sg-pop-danger  { background: rgb(255,114,109); color: #fff; }
.sg-pop-secondary { background: var(--bg-soft); color: var(--text-main); }
.sg-pop-exit { display: flex; align-items: center; justify-content: center; border: none; background: transparent;
  position: absolute; top: 16px; right: 16px; cursor: pointer; padding: 4px; }
.sg-pop-exit svg { fill: var(--text-muted); transition: fill .15s; }
.sg-pop-exit:hover svg { fill: var(--text-main); }

/* ── Group management cards (assignment_groups + self-organize panel) ── */
.grp-card { border: 1px solid var(--border-color); border-radius: 14px; overflow: hidden;
  transition: transform .15s, box-shadow .15s; }
.grp-card:hover { transform: translateY(-2px); box-shadow: 0 .5rem 1.2rem rgba(26,31,67,.10); }
.grp-card > .card-header { background: linear-gradient(180deg, var(--bg-soft), var(--bg-card)); border-bottom: 1px solid var(--border-color); font-size: .95rem; }
.grp-card.is-full > .card-header { background: linear-gradient(180deg, rgba(244,63,94,.10), var(--bg-card)); }
.grp-card .list-group-item { border: none; border-top: 1px solid color-mix(in srgb, var(--border-color) 60%, transparent); transition: background .12s; }
.grp-card .list-group-item:first-child { border-top: none; }
.grp-card .list-group-item:hover { background: var(--bg-soft); }
/* member chip used in the student self-organize panel */
.grp-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-soft); border: 1px solid var(--border-color);
  border-radius: 999px; padding: 3px 12px 3px 4px; font-size: .85rem; font-weight: 500; color: var(--text-main); }
.grp-mine-banner { border-left: 4px solid var(--brand); }

/* ── Accumulating multi-file input chips ── */
.sg-file-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sg-file-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  background: var(--bg-soft); color: var(--text-main); border: 1px solid var(--border-color);
  border-radius: 8px; padding: 3px 6px 3px 9px; font-size: .82rem; }
.sg-file-chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.sg-file-x { border: none; background: transparent; color: var(--text-muted); cursor: pointer;
  font-size: 1.05rem; line-height: 1; padding: 0 2px; border-radius: 50%; }
.sg-file-x:hover { color: #fff; background: rgb(255,114,109); }

/* ── Mobile hardening (keep layout from breaking on phones) ──────────────────── */
@media (max-width: 575px) {
  /* never let wide content force horizontal page scroll */
  .page-inner { padding: 14px 12px 28px; overflow-x: hidden; }
  .proj-grid { grid-template-columns: 1fr; }
  .cw-stats { gap: 10px; }
  .cw-stat .num { font-size: 1.5rem; }
  .dash-hero { padding: 18px 16px; }
  .dash-hero h3 { font-size: 1.25rem; }
  .stat-card .stat-val { font-size: 1.25rem; }
  /* compact calendar on phones */
  .cal-table td { height: 64px !important; }
  .cal-ev { font-size: .6rem; padding: 1px 3px; }
  .cal-table th { font-size: .72rem; }
  /* announcements + summary boxes wrap nicely */
  .summary-box .box { flex: 1 1 45%; }
  /* modals: full-width comfortable padding */
  .modal-dialog { margin: .5rem; }
}

/* ── Classwork hub (assignments) cards ───────────────────────────────────────── */
.cw-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.cw-task {
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 16px;
  padding: 18px 20px; box-shadow: var(--shadow); transition: .18s; position: relative;
  display: flex; flex-direction: column;
}
.cw-task:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--brand); }
.cw-task .cw-top { display: flex; align-items: flex-start; gap: 12px; justify-content: space-between; }
.cw-subj {
  display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 700;
  color: var(--brand-dark); background: var(--bg-soft); padding: 3px 11px; border-radius: 7px; margin-bottom: 7px;
}
html.dark .cw-subj { color: var(--brand-light); }
.cw-title { font-size: 1.06rem; font-weight: 800; line-height: 1.3; color: var(--text-main); }
.cw-desc { color: var(--text-muted); font-size: .9rem; margin: 6px 0 12px; white-space: pre-wrap; }
.cw-meta { display: flex; flex-wrap: wrap; gap: 14px; font-size: .82rem; color: var(--text-muted); }
.cw-meta b { color: var(--text-main); font-weight: 700; }
.cw-prog { height: 7px; border-radius: 999px; background: var(--border-color); overflow: hidden; margin-top: 11px; }
.cw-prog > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--blue-400)); transition: width .5s; }
.cw-actions { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; border-top: 1px dashed var(--border-color); padding-top: 13px; }
.cw-actions.notop { border-top: 0; padding-top: 8px; }
.cw-feedback {
  background: #e6f5ee; border: 1px solid #c9ebd8; border-radius: 12px;
  padding: 11px 14px; margin-top: 12px; font-size: .88rem; color: #1f5b3f;
}
.cw-feedback .gr { font-weight: 800; color: #1f8a5b; font-size: 1.02rem; }
.cw-feedback.wait { background: #fff6e0; border-color: #f0e3bf; color: #7a5a13; }
html.dark .cw-feedback { background: rgba(31,138,91,.14); border-color: rgba(31,138,91,.3); color: #9be6bf; }
html.dark .cw-feedback .gr { color: #6fe6a6; }
html.dark .cw-feedback.wait { background: rgba(200,140,0,.14); border-color: rgba(200,140,0,.3); color: #e8c980; }
/* classwork due/status badges */
.cw-badge { font-size: .72rem; font-weight: 700; padding: 4px 11px; border-radius: 999px; white-space: nowrap; }
.cw-b-ok   { background: #e6f5ee; color: #1f8a5b; }
.cw-b-wait { background: #fbf3dd; color: #9a6b00; }
.cw-b-warn { background: #fdeee5; color: #c2410c; }
.cw-b-grey { background: var(--bg-soft); color: var(--text-muted); }
.cw-b-group{ background: #e7eefc; color: #2c5ead; }
html.dark .cw-b-ok   { background: rgba(31,138,91,.2);  color: #6fe6a6; }
html.dark .cw-b-wait { background: rgba(154,107,0,.22);  color: #e8c980; }
html.dark .cw-b-warn { background: rgba(194,65,12,.2);   color: #f0a07a; }
html.dark .cw-b-group{ background: rgba(44,94,173,.3);   color: #9fc0f5; }

/* ── Calendar ───────────────────────────────────────────────────────────────── */
.cal-table th { background: var(--bg-soft); color: var(--maroon, var(--brand-dark)); font-size:.85rem; }
.cal-table td { border-color: var(--border-color); vertical-align: top; }
.cal-today { background: rgba(21,145,220,.08); }
.cal-today-num { display:inline-flex; align-items:center; justify-content:center; width:22px; height:22px; border-radius:50%; background: var(--brand); color:#fff; }
.cal-ev { display:block; font-size:.68rem; padding:1px 5px; margin-bottom:2px; border-radius:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; text-decoration:none; }
.cal-ev-asg { background:#e7f0fd; color:#1c4f9c; } .cal-ev-asg:hover { background:#d3e4fb; }
.cal-ev-ses { background:#e4f5ec; color:#1f7a4d; } .cal-ev-ses:hover { background:#d2eede; }
.cal-ev-class { background:#ece8ff; color:#5a3fd6; } .cal-ev-class:hover { background:#ddd6fb; }

/* ── EduCalendar-style redesign (.ecal-*) ───────────────────────────────────── */
.ecal-card { border:1px solid var(--border-color); border-radius:16px; }
.ecal-legend span { display:inline-flex; align-items:center; gap:4px; margin-left:8px; color:var(--text-muted); }
.ecal-dot { width:9px; height:9px; border-radius:50%; display:inline-block; }
.ecal-dot-class{ background:#6366f1; } .ecal-dot-ses{ background:#10b981; } .ecal-dot-asg{ background:#f43f5e; }
.ecal-filter { display:inline-flex; align-items:center; gap:5px; border:1px solid var(--border-color); background:var(--bg-card);
  color:var(--text-muted); border-radius:999px; padding:3px 10px; font-size:.78rem; cursor:pointer; transition:.15s; }
.ecal-filter:hover { border-color:var(--brand); }
.ecal-filter.is-on { color:var(--text-main); border-color:var(--brand); background:var(--bg-soft); font-weight:600; }
.ecal-filter:not(.is-on) { opacity:.55; }
.ecal-filter:not(.is-on) .ecal-dot { filter:grayscale(1); }
.ecal-nav { border:1px solid var(--border-color); }
.ecal-grid { display:grid; grid-template-columns:repeat(7,1fr); }
.ecal-dow { text-align:center; padding:10px 0; font-weight:800; font-size:.72rem; letter-spacing:.06em;
  color:var(--text-muted); background:var(--bg-soft); border-bottom:1px solid var(--border-color); }
.ecal-cell { min-height:96px; padding:6px; border-right:1px solid var(--border-color); border-bottom:1px solid var(--border-color);
  cursor:pointer; transition:background .12s; display:flex; flex-direction:column; gap:3px; overflow:hidden; }
.ecal-cell:nth-child(7n){ border-right:0; }
.ecal-cell:hover { background:color-mix(in srgb, var(--brand) 8%, transparent); }
.ecal-out { background:var(--bg-soft); opacity:.5; cursor:default; }
.ecal-today { background:color-mix(in srgb, var(--brand) 6%, transparent); }
.ecal-cell.sel { box-shadow:inset 0 0 0 2px var(--brand); border-radius:6px; }
.ecal-daynum-wrap { display:flex; align-items:center; justify-content:space-between; }
.ecal-daynum { font-weight:800; font-size:.82rem; width:24px; height:24px; display:inline-flex; align-items:center; justify-content:center; border-radius:50%; }
.ecal-daynum.is-today { background:var(--brand); color:#fff; }
.ecal-hasdot { width:6px; height:6px; border-radius:50%; background:var(--brand); }
.ecal-evs { display:flex; flex-direction:column; gap:2px; overflow:hidden; }
.ecal-pill { font-size:.66rem; font-weight:600; padding:1px 5px; border-radius:5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; border:1px solid transparent; }
.ecal-pill b { font-weight:800; }
.ecal-more { font-size:.62rem; font-weight:800; color:var(--text-muted); text-align:right; padding-right:2px; }
.ecal-class { background:#eef0ff; color:#4338ca; border-color:#dfe2ff; }
.ecal-ses   { background:#e6f7ef; color:#11815a; border-color:#cfeede; }
.ecal-asg   { background:#fdeaf0; color:#c81e54; border-color:#f9d3e0; }
html.dark .ecal-class { background:rgba(99,102,241,.22); color:#c3b6ff; border-color:transparent; }
html.dark .ecal-ses   { background:rgba(16,185,129,.22); color:#7fe0aa; border-color:transparent; }
html.dark .ecal-asg   { background:rgba(244,63,94,.22); color:#ffabc4; border-color:transparent; }
/* agenda (dark panel) */
.ecal-agenda { background:#1b2440; border:0; color:#e8ecff; border-radius:16px; }
.ecal-agenda-label { font-size:.7rem; letter-spacing:.08em; text-transform:uppercase; color:#8ea0d8; font-weight:700; }
.ecal-empty { color:#8ea0d8; }
.ecal-ag-item { display:flex; align-items:stretch; gap:10px; padding:10px 12px; border-radius:12px; background:rgba(255,255,255,.05);
  margin-bottom:8px; text-decoration:none; color:#e8ecff; transition:background .12s; }
.ecal-ag-item:hover { background:rgba(255,255,255,.1); color:#fff; }
.ecal-ag-bar { width:4px; border-radius:4px; flex-shrink:0; }
.ecal-ag-item.ecal-class .ecal-ag-bar{ background:#818cf8; } .ecal-ag-item.ecal-ses .ecal-ag-bar{ background:#34d399; } .ecal-ag-item.ecal-asg .ecal-ag-bar{ background:#fb7185; }
.ecal-ag-tags { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:3px; }
.ecal-ag-tag { font-size:.68rem; font-weight:700; padding:1px 8px; border-radius:20px; background:rgba(255,255,255,.12); color:#cdd6f8; }
.ecal-ag-tag2 { font-size:.68rem; font-weight:700; padding:1px 8px; border-radius:20px; background:rgba(0,0,0,.22); color:#aeb9e0; }
.ecal-ag-title { font-weight:700; font-size:.92rem; }
.ecal-ag-time { font-size:.74rem; color:#aeb9e0; margin-top:2px; }
.ecal-ag-go { align-self:center; color:#8ea0d8; }
@media (max-width:575px){ .ecal-cell{ min-height:72px; } .ecal-pill{ font-size:.6rem; } }

/* ── Smart-Attendance-style check-in panel (.att-*) ──────────────────────────── */
.att-chips { display:grid; grid-template-columns:repeat(5,1fr); gap:10px; }
.att-chip { border:1px solid var(--border-color); border-radius:14px; padding:10px 12px; text-align:center; background:var(--bg-card); }
.att-chip .n { display:block; font-weight:800; font-size:1.4rem; line-height:1; }
.att-chip .l { display:block; font-size:.72rem; color:var(--text-muted); margin-top:3px; font-weight:600; }
.att-c-total  .n { color:#6366f1; } .att-c-total  { background:color-mix(in srgb,#6366f1 8%,var(--bg-card)); }
.att-c-present .n { color:#10b981; } .att-c-present { background:color-mix(in srgb,#10b981 8%,var(--bg-card)); }
.att-c-late   .n { color:#f59e0b; } .att-c-late   { background:color-mix(in srgb,#f59e0b 8%,var(--bg-card)); }
.att-c-absent .n { color:#f43f5e; } .att-c-absent { background:color-mix(in srgb,#f43f5e 8%,var(--bg-card)); }
.att-c-leave  .n { color:#0ea5e9; } .att-c-leave  { background:color-mix(in srgb,#0ea5e9 8%,var(--bg-card)); }
.att-bar { display:flex; height:14px; border-radius:10px; overflow:hidden; background:var(--bg-soft); box-shadow:inset 0 1px 3px rgba(0,0,0,.12); }
.att-bar .seg { height:100%; transition:width .3s; }
.att-bar .seg-present { background:#10b981; } .att-bar .seg-late { background:#f59e0b; }
.att-bar .seg-absent { background:#f43f5e; } .att-bar .seg-leave { background:#0ea5e9; }
@media (max-width:575px){ .att-chips { grid-template-columns:repeat(2,1fr); } .att-chip .n{ font-size:1.2rem; } }
html.dark .cal-ev-asg { background:rgba(28,79,156,.3); color:#9fc0f5; }
html.dark .cal-ev-ses { background:rgba(31,122,77,.3); color:#7fe0aa; }
html.dark .cal-ev-class { background:rgba(90,63,214,.32); color:#c3b6ff; }

/* ── Announcements ──────────────────────────────────────────────────────────── */
.ann-wrap { display:flex; flex-direction:column; gap:10px; }
.ann-item { border-left:4px solid var(--brand); background:var(--bg-soft); border-radius:8px; padding:12px 16px; }
.ann-item.ann-pinned { border-left-color:#FFA95A; background:rgba(255,169,90,.08); }
.ann-title { font-weight:700; font-size:1rem; }
.ann-body { font-size:.9rem; margin-top:4px; color:var(--text-muted, #555); }
.ann-meta { font-size:.75rem; color:var(--text-muted, #888); margin-top:6px; }
html.dark .ann-item { background:rgba(255,255,255,.04); }
html.dark .ann-item.ann-pinned { background:rgba(255,169,90,.12); }

/* ── Toast notifications (Notification2-style card: white, colored bar + icon) ── */
.sg-toast-wrap { position: fixed; top: 1rem; right: 1rem; z-index: 1090; display: flex;
  flex-direction: column; gap: .7rem; max-width: calc(100% - 2rem); width: 23rem; pointer-events: none; }
.sg-toast { --tclr: var(--brand); pointer-events: auto; position: relative; display: flex; align-items: center;
  gap: .8rem; background: var(--bg-card); border: .12rem solid color-mix(in srgb, var(--tclr) 18%, transparent);
  border-radius: 1rem; box-shadow: 0 .55rem 1.6rem rgba(26,31,67,.30); padding: .8rem 1rem .8rem 1.4rem; cursor: pointer;
  animation: sgToastIn .4s cubic-bezier(.2,.9,.3,1.3); transition: transform .2s, opacity .2s, box-shadow .2s; }
.sg-toast::before { content: ""; position: absolute; left: .5rem; top: .7rem; bottom: .7rem; width: .42rem;
  border-radius: 1rem; background: var(--tclr); }
.sg-toast:hover { transform: translateX(-4px); box-shadow: 0 .7rem 2rem rgba(26,31,67,.38); }
.sg-toast.out { animation: sgToastOut .3s ease forwards; }
.sg-toast-ic { flex-shrink: 0; width: 2.6rem; height: 2.6rem; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.25rem; color: #fff; background: radial-gradient(circle at 50% 45%, var(--tclr), color-mix(in srgb, var(--tclr) 70%, #000) 130%);
  box-shadow: 0 .2rem .5rem color-mix(in srgb, var(--tclr) 45%, transparent); }
.sg-toast.t-success { --tclr: #03a65a; }
.sg-toast.t-warning { --tclr: #fc8621; }
.sg-toast.t-danger  { --tclr: #db3056; }
.sg-toast.t-info    { --tclr: #0070e0; }
.sg-toast-body { flex-grow: 1; min-width: 0; line-height: 1.32; }
.sg-toast-title { font-weight: 700; font-size: .9rem; color: var(--tclr); }
.sg-toast-sub { font-size: .78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sg-toast-x { flex-shrink: 0; width: 1.5rem; height: 1.5rem; border: 0; border-radius: 50%; background: transparent;
  color: var(--text-muted); font-size: 1.25rem; line-height: 1; cursor: pointer; display: grid; place-items: center;
  transition: background .15s, color .15s; }
.sg-toast-x:hover { background: var(--tclr); color: #fff; }
@keyframes sgToastIn  { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes sgToastOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(120%); opacity: 0; } }
@media (max-width: 575px) { .sg-toast-wrap { width: calc(100% - 1.5rem); top: .6rem; right: .75rem; } }

/* ── Attendance tabs (เช็คชื่อ/สแกน/เรียกชื่อ/สถิติ) ──────────────────────────── */
.att-tabs { list-style:none; display:flex; gap:8px; flex-wrap:wrap; padding:0; margin:0; }
.att-tab { border:1px solid var(--border-color); background:var(--bg-card); color:var(--text-main);
  border-radius:12px; padding:8px 16px; font-weight:600; font-size:.9rem; cursor:pointer; text-decoration:none;
  display:inline-flex; align-items:center; transition:all .15s; }
.att-tab:hover { border-color:var(--brand); color:var(--brand); }
.att-tab.active { background:var(--brand); border-color:var(--brand); color:#fff; box-shadow:0 .3rem .8rem color-mix(in srgb, var(--brand) 30%, transparent); }

/* ── Overdue (เลยกำหนด) teacher view ─────────────────────────────────────────── */
.overdue-card { border: 1px solid var(--border-color); border-radius: 14px; overflow: hidden; }
.overdue-card > .card-header { border-bottom: 2px solid color-mix(in srgb, #db3056 20%, transparent); }
.overdue-miss-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.overdue-chip { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border-color);
  border-radius: 10px; background: var(--bg-soft); }
.overdue-chip .nm { flex-grow: 1; font-size: .82rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.dark .overdue-card > .card-header.bg-white { background: var(--bg-card) !important; }

.file-code-preview { margin: 0; padding: 1rem 1.1rem; height: 70vh; overflow: auto; white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; line-height: 1.5;
  background: #1e1e1e; color: #e6e6e6; border-radius: 0; tab-size: 4; }

.bg-brand-subtle { background: color-mix(in srgb, var(--brand) 15%, transparent); }
html.dark .bg-brand-subtle { background: color-mix(in srgb, var(--brand) 22%, transparent); }

/* ── Submission preview (assignment grading) ─────────────────────────────────── */
.sub-thumb { max-height: 90px; max-width: 140px; border-radius: 8px; border: 1px solid var(--border-color);
  object-fit: cover; cursor: pointer; transition: transform .15s; display: block; }
.sub-thumb:hover { transform: scale(1.04); box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.sub-text { max-height: 80px; overflow: auto; margin-bottom: 4px; }
#previewBody img { object-fit: contain; }

/* ── Notification bell ───────────────────────────────────────────────────────── */
.notif-badge {
  position: absolute; top: -3px; right: -3px; min-width: 17px; height: 17px;
  padding: 0 4px; border-radius: 9px; background: #e53935; color: #fff;
  font-size: .62rem; font-weight: 700; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg-card);
}
.notif-menu { box-shadow: var(--shadow-lg); border: 1px solid var(--border-color); }
.notif-item { border-bottom: 1px solid var(--border-color); transition: background .15s; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-soft); }
.notif-item.unread { background: rgba(21,145,220,.07); }
.notif-item.unread .fw-semibold::after { content:''; display:inline-block; width:7px; height:7px; border-radius:50%; background: var(--brand); margin-left:6px; vertical-align: middle; }
html.dark .notif-item .text-dark { color: var(--text-main) !important; }

/* ── Jelly checkboxes (1.css) — global, excludes .btn-check ──────────────────── */
.form-check-input[type="checkbox"]:not(.btn-check) {
  width: 1.25em; height: 1.25em;
  border: 1px solid #c8ccd4;
  border-radius: 4px;
  cursor: pointer;
  transition: background .1s ease;
}
.form-check-input[type="checkbox"]:not(.btn-check):checked {
  background-color: var(--brand);
  border-color: transparent;
  animation: cbxJelly .55s ease;
}
.form-check-input[type="checkbox"]:not(.btn-check):focus {
  box-shadow: 0 0 0 .2rem rgba(21,145,220,.25);
}
html.dark .form-check-input[type="checkbox"]:not(.btn-check) { border-color: var(--border-color); background-color: var(--bg-input); }
html.dark .form-check-input[type="checkbox"]:not(.btn-check):checked { background-color: var(--brand); }
@keyframes cbxJelly {
  from { transform: scale(1,1); }
  30%  { transform: scale(1.25,.75); }
  40%  { transform: scale(.75,1.25); }
  50%  { transform: scale(1.15,.85); }
  65%  { transform: scale(.95,1.05); }
  75%  { transform: scale(1.05,.95); }
  to   { transform: scale(1,1); }
}

/* ── Folder file-upload (3.css) ──────────────────────────────────────────────── */
.folder-upload {
  --fu-w: 70px; --fu-h: 46px; --fu-t: 300ms;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: 10px; gap: 6px;
  background: linear-gradient(135deg, #6dd5ed, #2193b0);
  border-radius: 12px; box-shadow: 0 8px 18px rgba(0,0,0,.15);
  position: relative; min-height: 96px; cursor: pointer;
}
.folder-upload .fu-folder { position: absolute; top: -6px; left: calc(50% - var(--fu-w)/2);
  animation: fuFloat 2.5s infinite ease-in-out; transition: transform var(--fu-t) ease; }
.folder-upload:hover .fu-folder { transform: scale(1.05); }
.folder-upload .fu-front, .folder-upload .fu-back { position: absolute; transition: transform var(--fu-t); transform-origin: bottom center; }
.folder-upload .fu-back::before, .folder-upload .fu-back::after { content:""; display:block; background:#fff; opacity:.5;
  width: var(--fu-w); height: var(--fu-h); position:absolute; transform-origin:bottom center; border-radius:10px; transition: transform 350ms; }
.folder-upload:hover .fu-back::before { transform: rotateX(-5deg) skewX(5deg); }
.folder-upload:hover .fu-back::after  { transform: rotateX(-15deg) skewX(12deg); }
.folder-upload .fu-front { z-index: 1; }
.folder-upload:hover .fu-front { transform: rotateX(-40deg) skewX(15deg); }
.folder-upload .fu-tip { background: linear-gradient(135deg,#ff9a56,#ff6f56); width: 46px; height: 12px;
  border-radius: 8px 8px 0 0; position:absolute; top:-7px; z-index:2; }
.folder-upload .fu-cover { background: linear-gradient(135deg,#ffe563,#ffc663); width: var(--fu-w); height: var(--fu-h);
  box-shadow: 0 10px 20px rgba(0,0,0,.25); border-radius: 8px; }
.folder-upload .fu-text { color:#fff; font-weight:600; font-size:.85rem; text-align:center; margin-top: 2px;
  background: rgba(255,255,255,.2); border-radius: 8px; padding: 6px 14px; width: 100%; }
.folder-upload:hover .fu-text { background: rgba(255,255,255,.35); }
.folder-upload .fu-name { color:#fff; font-size:.72rem; opacity:.9; max-width: 160px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.folder-upload input[type="file"] { display:none; }
@keyframes fuFloat { 0%{transform:translateY(0)} 50%{transform:translateY(-14px)} 100%{transform:translateY(0)} }

/* ── Folder download button (2.css, compact) ─────────────────────────────────── */
.btn-folder { position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 2.6em; height: 2.6em; border: none; cursor: pointer; border-radius: .4em; background: rgba(235,252,254,.9); }
html.dark .btn-folder { background: var(--bg-soft); }
.btn-folder .bf-box { position: relative; width: 1.7em; height: 1.5em; overflow: hidden; }
.btn-folder .bf-f { position: absolute; }
.btn-folder .bf-1 { bottom:0; width:100%; height:88%; border-radius:2px; border-top:2px solid rgb(206,167,39);
  background: linear-gradient(-35deg, rgb(238,194,47) 5%, rgb(255,223,118)); }
.btn-folder .bf-2 { top:5%; width:38%; height:19%; border-radius:2px 2px 2px 0; background: rgb(206,167,39); }
.btn-folder .bf-3 { left:.25em; bottom:0; width:1.2em; height:.45em; border-radius:3px 3px 0 0;
  background: linear-gradient(-35deg, rgb(25,102,218), rgb(109,165,249)); }
.btn-folder:hover .bf-box { animation: bfWow .8s forwards; }
@keyframes bfWow { 20%{scale:.8} 30%{scale:1;transform:translateY(0)} 50%{transform:translateY(-4px)} 65%{transform:translateY(3px)} 80%{transform:translateY(0)} 100%{scale:1} }

/* ── Back buttons (5.css neumorphic, applied via :has) ───────────────────────── */
.btn:has(> .bi-arrow-left:only-child),
.btn.btn-back {
  background: #fff;
  border: none;
  border-radius: 8px;
  color: var(--text-main);
  transition: all .2s linear;
  box-shadow: 3px 3px 10px rgba(0,0,0,.08);
}
.btn:has(> .bi-arrow-left:only-child):hover,
.btn.btn-back:hover {
  box-shadow: 6px 6px 18px #d1d1d1, -6px -6px 18px #ffffff;
  transform: translateY(-2px);
  color: var(--brand-dark);
}
.btn:has(> .bi-arrow-left:only-child) .bi-arrow-left { transition: transform .3s ease; }
.btn:has(> .bi-arrow-left:only-child):hover .bi-arrow-left { transform: translateX(-4px); }
html.dark .btn:has(> .bi-arrow-left:only-child),
html.dark .btn.btn-back { background: var(--bg-soft); color: var(--text-main); box-shadow: 3px 3px 10px rgba(0,0,0,.4); }
html.dark .btn:has(> .bi-arrow-left:only-child):hover,
html.dark .btn.btn-back:hover { box-shadow: 5px 5px 16px #0b1119, -5px -5px 16px #20303f; color: var(--brand-light); }

/* ── Theme toggle button ─────────────────────────────────────────────────────── */
.theme-toggle-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.4);
  background: rgba(255,255,255,.15);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem; cursor: pointer; transition: .2s;
}
.theme-toggle-btn:hover { background: rgba(255,255,255,.3); }
.theme-toggle-btn .theme-icon-moon { display: none; }
html.dark .theme-toggle-btn .theme-icon-sun  { display: none; }
html.dark .theme-toggle-btn .theme-icon-moon { display: inline; }

/* ── Contrast fixes (light) ──────────────────────────────────────────────────── */
.btn-outline-secondary { color: var(--brand-dark); border-color: var(--border-color); }
.btn-outline-secondary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color:#fff; }
.dash-hero .badge.bg-light { background:#fff !important; color: var(--brand-dark) !important; font-weight:600; }
.btn-light, .badge.bg-light { color: var(--brand-dark) !important; }
.text-muted { color: var(--text-muted) !important; }
.card-footer .btn-outline-secondary { color: var(--brand-dark); }

/* ── DARK MODE ───────────────────────────────────────────────────────────────── */
html.dark {
  --brand:        #4BB8FA;
  --brand-dark:   #1591DC;
  --brand-light:  #6fc7fb;
  --bg-base:    #0f1722;
  --bg-soft:    #1b2736;
  --bg-card:    #18222f;
  --bg-input:   #1f2c3c;
  --border-color: #2c3e54;
  --text-main:    #e3edf6;
  --text-muted:   #94a8bd;
  --shadow:       0 4px 16px rgba(0,0,0,.4);
  --shadow-lg:    0 8px 28px rgba(0,0,0,.55);
}
html.dark body { background-color: var(--bg-base) !important; color: var(--text-main) !important; }
html.dark .app-navbar { background: linear-gradient(90deg,#13243b 0%,#16344e 100%); border-bottom-color: var(--brand); }
html.dark .card { background: var(--bg-card); border-color: var(--border-color); color: var(--text-main); }
html.dark .card-header { background: var(--bg-soft); color: var(--brand-light); border-color: var(--border-color); }
html.dark .card-footer { background: rgba(255,255,255,.02); border-color: var(--border-color); }
html.dark .form-control,
html.dark .form-select,
html.dark .score-input { background: var(--bg-input); border-color: var(--border-color); color: var(--text-main); }
html.dark .form-control::placeholder { color: #6b8299; }
html.dark .input-group-text { background: var(--bg-soft); border-color: var(--border-color); color: var(--brand-light); }
html.dark .modal-content { background: var(--bg-card); color: var(--text-main); }
html.dark .modal-header { background: var(--bg-soft); border-color: var(--border-color); }
html.dark .modal-header .modal-title { color: var(--brand-light); }
html.dark .modal-footer { border-color: var(--border-color); }
html.dark .dropdown-menu,
html.dark .dropdown-menu-dark { background: var(--bg-card) !important; border-color: var(--border-color) !important; }
html.dark .dropdown-item { color: var(--text-main) !important; }
html.dark .dropdown-item:hover { background: var(--bg-soft) !important; color: var(--brand-light) !important; }
html.dark .table { color: var(--text-main); }
html.dark .table > :not(caption) > * > * { color: var(--text-main); border-bottom-color: var(--border-color); }
html.dark .table-dark-custom:not(.gradebook-table) tbody td { border-bottom-color: var(--border-color); }
html.dark .table-dark-custom:not(.gradebook-table) tbody tr:nth-child(odd)  td { background: rgba(255,255,255,.012); }
html.dark .table-dark-custom:not(.gradebook-table) tbody tr:nth-child(even) td { background: rgba(255,255,255,.035); }
html.dark .table-dark-custom:not(.gradebook-table) tbody tr:hover td { background: rgba(75,184,250,.16); }
html.dark .table-dark-custom:not(.gradebook-table) tbody tr:hover { box-shadow: 0 6px 14px -8px rgba(0,0,0,.6); }
html.dark .gradebook-table tbody tr:hover td { background: rgba(75,184,250,.10); }
html.dark .list-group-item { background: transparent; color: var(--text-main); border-color: var(--border-color); }
html.dark .nav-tabs .nav-link { color: var(--text-muted); }
html.dark .nav-tabs .nav-link.active { color: var(--brand-light); }
html.dark .gradebook-table .col-sticky { background: var(--bg-card); }
html.dark .alert-secondary { background: var(--bg-soft); color: var(--text-main); border-color: var(--border-color); }
html.dark a { color: var(--brand-light); }
html.dark .text-dark { color: var(--text-main) !important; }
html.dark .course-tile, html.dark .group-card, html.dark .code-card, html.dark .pin-card { background: var(--bg-card); }
html.dark .bg-light, html.dark .badge.bg-light { background: var(--bg-soft) !important; color: var(--brand-light) !important; }

/* ── Smart Attendance (checkin result + attendance overview) ───────────────────── */
/* Premium check-in result "ticket" */
.att-wrap { min-height: 72vh; display: flex; align-items: center; justify-content: center; padding: 18px 0; }
.att-wrap::before { content:""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vw 40vh at 15% 0%, color-mix(in srgb, var(--brand) 16%, transparent), transparent 70%),
    radial-gradient(55vw 40vh at 100% 100%, color-mix(in srgb, var(--accent, var(--brand-light)) 16%, transparent), transparent 70%); }
.att-ticket { width: 100%; max-width: 440px; background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: 26px; overflow: hidden; box-shadow: 0 24px 60px rgba(44,94,173,.22);
  animation: attPop .5s cubic-bezier(.18,.9,.3,1.2) both; }
@keyframes attPop { from { opacity: 0; transform: translateY(22px) scale(.96); } to { opacity: 1; transform: none; } }
.att-head { position: relative; padding: 34px 24px 26px; text-align: center; color: #fff; overflow: hidden; }
.att-head::after { content:""; position: absolute; left: 0; right: 0; bottom: -1px; height: 26px;
  background: var(--bg-card); border-radius: 50% 50% 0 0 / 100% 100% 0 0; }
.att-head.ok   { background: linear-gradient(135deg,#1f9d57,#34c77b); }
.att-head.late { background: linear-gradient(135deg,#e8920a,#ffb43c); }
.att-head.bad  { background: linear-gradient(135deg,#d9344f,#ff6b6b); }
.att-emblem { width: 92px; height: 92px; margin: 0 auto 14px; border-radius: 50%;
  background: rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 10px rgba(255,255,255,.10); position: relative; z-index: 1; }
.att-emblem i { font-size: 3rem; color: #fff; }
.att-emblem.pulse { animation: attPulse 1.8s ease-out infinite; }
@keyframes attPulse { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.35); } 70%,100% { box-shadow: 0 0 0 22px rgba(255,255,255,0); } }
.att-head h4 { font-weight: 800; margin: 0; position: relative; z-index: 1; }
.att-head p  { margin: 4px 0 0; opacity: .92; font-size: .9rem; position: relative; z-index: 1; }
.att-body { padding: 8px 22px 24px; }
.att-info { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--border-color); }
.att-info:last-child { border-bottom: 0; }
.att-info .ic { width: 40px; height: 40px; min-width: 40px; border-radius: 12px; display: flex; align-items: center;
  justify-content: center; font-size: 1.15rem; background: var(--bg-soft); color: var(--brand); }
.att-info .lb { font-size: .72rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.att-info .vl { font-weight: 700; color: var(--text-main); line-height: 1.25; }
.att-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 14px; border-radius: 999px;
  font-weight: 800; font-size: .82rem; }
.att-chip.ok   { background: color-mix(in srgb,#1f9d57 16%,transparent); color: #1f9d57; }
.att-chip.late { background: color-mix(in srgb,#e8920a 18%,transparent); color: #c9780a; }
.att-foot { padding: 4px 22px 24px; }

/* Premium stat cards + section grid for attendance_overview */
.att-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 18px; }
.att-stat { position: relative; background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: 20px; padding: 18px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); }
.att-stat .ico { width: 50px; height: 50px; min-width: 50px; border-radius: 15px; display: flex; align-items: center;
  justify-content: center; font-size: 1.4rem; color: #fff; box-shadow: 0 6px 16px rgba(44,94,173,.22); }
.att-stat .ico.c1 { background: linear-gradient(135deg,var(--brand),var(--brand-light)); }
.att-stat .ico.c2 { background: linear-gradient(135deg,#1f9d57,#34c77b); }
.att-stat .ico.c3 { background: linear-gradient(135deg,#d9344f,#ff7a7a); }
.att-stat .ico.c4 { background: linear-gradient(135deg,var(--accent,#FF8B5A),#ffb37a); }
.att-stat .num { font-weight: 800; font-size: 1.65rem; line-height: 1; color: var(--text-main); }
.att-stat .lb  { font-size: .78rem; color: var(--text-muted); margin-top: 4px; font-weight: 600; }
@media (max-width: 760px) { .att-stats { grid-template-columns: 1fr 1fr; } }

.att-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(300px,1fr)); gap: 14px; }
.att-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 20px; padding: 18px;
  box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s; display: flex; flex-direction: column; gap: 12px; }
.att-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--brand); }
.att-card .ac-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.att-card .ac-code { font-weight: 800; color: var(--brand-dark); }
.att-card .ac-name { color: var(--text-main); font-weight: 600; font-size: .95rem; }
.att-card .ac-meta { font-size: .76rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 10px; }
.att-card .ac-meta i { color: var(--brand); margin-right: 3px; }
.att-prog { height: 10px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.08); }
.att-prog > span { display: block; height: 100%; border-radius: 999px; transition: width .4s; }
.att-prog.good > span { background: linear-gradient(90deg,#1f9d57,#34c77b); }
.att-prog.bad  > span { background: linear-gradient(90deg,#d9344f,#ff7a7a); }
.att-card .ac-pct { font-weight: 800; font-variant-numeric: tabular-nums; }
.att-card .ac-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.att-risk { display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.att-risk.has { background: color-mix(in srgb,#d9344f 14%,transparent); color: #d9344f; }
.att-risk.none { background: color-mix(in srgb,#1f9d57 14%,transparent); color: #1f9d57; }

/* QR scanner camera viewport (Mode 2) */
.att-scanbox { position: relative; max-width: 320px; margin: 0 auto; aspect-ratio: 1/1; border-radius: 20px;
  background: #0b1220; overflow: hidden; border: 1px solid #1e293b; box-shadow: inset 0 0 40px rgba(0,0,0,.5); }
.att-scanbox #qrReader { width: 100%; height: 100%; }
.att-scanbox #qrReader video { object-fit: cover; border-radius: 20px; }
.att-scanbox .scan-hint { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; color: #94a3b8; text-align: center; padding: 18px; }
.att-scanbox .scan-hint i { font-size: 2.4rem; }
.att-scanbox .scan-frame { position: absolute; inset: 18%; border-radius: 16px; pointer-events: none; z-index: 5;
  box-shadow: 0 0 0 2px rgba(255,255,255,.18); }
.att-scanbox .scan-frame::before, .att-scanbox .scan-frame::after { content:""; position: absolute; left: 8%; right: 8%;
  height: 2px; background: linear-gradient(90deg,transparent,var(--brand),transparent); }
.att-scanbox .scan-frame::before { top: 8%; animation: scanLine 2.2s ease-in-out infinite alternate; }
.att-scanbox .scan-frame::after { display: none; }
@keyframes scanLine { from { transform: translateY(0); } to { transform: translateY(900%); } }
.att-scanbox.live .scan-hint { display: none; }
.att-scanlog { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.att-scanlog .sl-row { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 12px; background: var(--bg-soft); border: 1px solid var(--border-color);
  animation: attPop .3s ease both; }

/* Pure-CSS mini bar chart (gradebook grade distribution — no JS dependency) */
.gb-bars { display: flex; align-items: flex-end; gap: 14px; height: 200px; padding: 6px 4px 0; }
.gb-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.gb-bar-val { font-weight: 800; font-size: .85rem; color: var(--text-main); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.gb-bar-track { flex: 1; width: 100%; max-width: 56px; display: flex; align-items: flex-end; }
.gb-bar-fill { width: 100%; border-radius: 9px 9px 0 0; min-height: 3px; box-shadow: 0 2px 6px rgba(0,0,0,.12); transition: height .5s cubic-bezier(.2,.8,.3,1); }
.gb-bar-lb { margin-top: 7px; font-weight: 700; font-size: .82rem; color: var(--text-main); }

/* ── Print ───────────────────────────────────────────────────────────────────── */
@media print {
  body { background: #fff; color: #000; }
  .app-navbar, .btn, footer, .no-print { display: none !important; }
  .card { border: 1px solid #ccc; background: #fff; color: #000; box-shadow: none; }
  .code-card { background: #fff; border: 1.5px dashed #888; }
  .code-text { color: #000; }
  .pin-card  { background: #fff; border: 1.5px dashed #666; color: #000; }
  .table-dark-custom thead th { background: #eee !important; color: #000 !important; }
}
