/* Admin CSS v3 — blue theme */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=Sora:wght@400;600;700&display=swap');

:root {
  --blue-50: #eff6ff; --blue-100: #dbeafe; --blue-200: #bfdbfe;
  --blue-500: #3b82f6; --blue-600: #2563eb; --blue-700: #1d4ed8;
  --blue-800: #1e40af; --blue-900: #1e3a8a;
  --brand: #2563eb; --brand-dark: #1d4ed8; --brand-pale: #eff6ff;
  --bg: #f0f4f8; --surface: #ffffff; --surface-2: #f8fafc;
  --text: #0f172a; --text-mid: #334155; --text-muted: #64748b; --text-hint: #94a3b8;
  --border: #e2e8f0; --border-mid: #cbd5e1;
  --gray-50: #f8fafc; --gray-100: #f1f5f9; --gray-200: #e2e8f0;
  --gray-500: #64748b; --gray-800: #1e293b;
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-xl: 24px;
  --sh-xs: 0 1px 3px rgba(15,23,42,0.06); --sh-sm: 0 2px 8px rgba(15,23,42,0.08);
  --sh-md: 0 4px 20px rgba(15,23,42,0.10); --sh-lg: 0 8px 40px rgba(15,23,42,0.14);
  --ease: cubic-bezier(0.4,0,0.2,1);
  --topbar-h: 60px; --botnav-h: 68px; --botnav-safe: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; min-height: 100dvh; font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; overscroll-behavior: none; }

::-webkit-scrollbar { width: 4px; } ::-webkit-scrollbar-track { background: transparent; } ::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 2px; }

/* ── LOGIN ── */
.login-wrap {
  min-height: 100vh; min-height: 100dvh;
  background: linear-gradient(145deg, var(--blue-900) 0%, var(--brand) 60%, #0ea5e9 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 40px 36px;
  width: 100%; max-width: 400px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.30);
  text-align: center;
}

.login-logo {
  width: 60px; height: 60px;
  background: var(--brand);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(37,99,235,0.35);
}

.login-logo svg { width: 28px; height: 28px; fill: #fff; }
.login-title { font-family: 'Sora', sans-serif; font-size: 1.7rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.login-sub { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 28px; }

.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; text-align: left; }
.form-label { font-size: 0.73rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid var(--border-mid); border-radius: var(--r-sm);
  font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.88rem;
  color: var(--text); background: var(--gray-50); outline: none; transition: border-color 0.18s;
}
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 32px; cursor: pointer; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px rgba(37,99,235,0.10); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media(max-width:560px){ .form-row { grid-template-columns: 1fr; } }

.login-error { font-size: 0.82rem; color: #dc2626; background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--r-sm); padding: 8px 12px; margin-bottom: 10px; display: none; }
.login-error.show { display: block; }

.back-link { display: inline-flex; align-items: center; gap: 5px; margin-top: 18px; color: var(--text-muted); font-size: 0.80rem; text-decoration: none; transition: color 0.15s; }
.back-link:hover { color: var(--brand); }

/* ── APP SHELL ── */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

/* ── TOPBAR ── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--brand);
  display: flex; align-items: center; padding: 0 18px; gap: 12px;
  box-shadow: 0 2px 12px rgba(37,99,235,0.35);
}

.topbar-logo { width: 32px; height: 32px; background: rgba(255,255,255,0.18); border-radius: 9px; display: flex; align-items: center; justify-content: center; border: 1px solid rgba(255,255,255,0.22); flex-shrink: 0; }
.topbar-logo svg { width: 16px; height: 16px; fill: #fff; }
.topbar-name { font-family: 'Sora', sans-serif; font-size: 1rem; font-weight: 700; color: #fff; }
.topbar-sub { font-size: 0.66rem; color: rgba(255,255,255,0.60); margin-top: -1px; }
.topbar-left { display: flex; align-items: center; gap: 10px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.admin-pill { background: rgba(239,68,68,0.20); border: 1px solid rgba(239,68,68,0.35); color: #fca5a5; padding: 3px 10px; border-radius: 20px; font-size: 0.70rem; font-weight: 700; white-space: nowrap; }

/* ── PAGE BODY ── */
.page-body { flex: 1; overflow-y: auto; padding: 18px 16px; padding-bottom: calc(var(--botnav-h) + var(--botnav-safe) + 16px); }

/* ── PAGE ── */
.page { display: none; }
.page.active { display: block; animation: fadeUp 0.22s var(--ease); }
@keyframes fadeUp { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

.section-head { margin-bottom: 14px; }
.section-head h1 { font-family: 'Sora', sans-serif; font-size: 1.4rem; font-weight: 700; color: var(--text); letter-spacing: -0.3px; margin-bottom: 2px; }
.section-head p { font-size: 0.80rem; color: var(--text-muted); }

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--botnav-h) + var(--botnav-safe));
  padding-bottom: var(--botnav-safe);
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px rgba(15,23,42,0.10);
  display: flex; align-items: stretch; z-index: 200;
}

.nav-tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 8px 2px 0; cursor: pointer; border: none; background: none; color: var(--text-hint); font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.62rem; font-weight: 500; transition: color 0.18s var(--ease); position: relative; -webkit-tap-highlight-color: transparent; }
.tab-icon { width: 42px; height: 28px; border-radius: 18px; display: flex; align-items: center; justify-content: center; transition: background 0.2s var(--ease); }
.nav-tab svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; transition: stroke 0.18s; }
.nav-tab.active { color: var(--brand); }
.nav-tab.active .tab-icon { background: var(--blue-50); }
.nav-tab.active svg { stroke: var(--brand); stroke-width: 2.1; }
.nav-tab-label { line-height: 1; margin-bottom: 4px; }

/* ── TOOLBAR ── */
.toolbar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px; flex-wrap: wrap;
}

.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  background: var(--brand); color: #fff; border: none; border-radius: var(--r-sm);
  font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.85rem; font-weight: 700;
  cursor: pointer; transition: background 0.18s var(--ease); white-space: nowrap; text-decoration: none;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary.full { width: 100%; justify-content: center; padding: 12px; }
.btn-primary svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.2; }

.btn-secondary { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; background: var(--gray-100); color: var(--text-mid); border: 1.5px solid var(--border-mid); border-radius: var(--r-sm); font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all 0.18s; white-space: nowrap; }
.btn-secondary:hover { background: var(--blue-50); border-color: var(--blue-200); color: var(--brand); }

.upload-btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; background: var(--gray-100); color: var(--text-muted); border: 1.5px dashed var(--border-mid); border-radius: var(--r-sm); font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.83rem; font-weight: 600; cursor: pointer; transition: all 0.18s; white-space: nowrap; }
.upload-btn:hover { background: var(--blue-50); border-color: var(--blue-300); border-style: solid; color: var(--brand); }
.upload-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.9; }

.sample-link { font-size: 0.76rem; color: var(--brand); text-decoration: none; font-weight: 600; }
.sample-link:hover { text-decoration: underline; }

/* ── FORM CARD ── */
.form-card {
  background: var(--surface); border: 1px solid var(--border);
  border-top: 3px solid var(--brand); border-radius: var(--r-lg);
  padding: 20px; margin-bottom: 16px;
  animation: slideDown 0.2s var(--ease); box-shadow: var(--sh-xs);
}
@keyframes slideDown { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }

.form-card-title { font-family: 'Sora', sans-serif; font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

.form-actions { display: flex; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border); margin-top: 14px; }

.file-input { width: 100%; padding: 10px 12px; background: var(--gray-50); border: 1.5px dashed var(--border-mid); border-radius: var(--r-sm); font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.83rem; color: var(--text-muted); cursor: pointer; transition: all 0.18s; }
.file-input:hover { border-color: var(--brand); background: var(--blue-50); }

.file-hint { font-size: 0.72rem; color: var(--text-hint); margin-top: 4px; }

/* ── DATA TABLE ── */
.data-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--sh-xs); }
.data-wrap-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; min-width: 480px; }
.data-table thead th { background: var(--brand); color: rgba(255,255,255,0.82); padding: 10px 14px; text-align: left; font-weight: 600; font-size: 0.72rem; letter-spacing: 0.6px; text-transform: uppercase; white-space: nowrap; }
.data-table tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--blue-50); }
.td-actions { display: flex; gap: 5px; justify-content: flex-end; }

/* ── BADGES ── */
.badge-dept { display: inline-block; padding: 2px 8px; background: var(--blue-50); color: var(--blue-800); border-radius: 5px; font-size: 0.71rem; font-weight: 700; border: 1px solid var(--blue-200); }
.badge-term { display: inline-block; padding: 2px 8px; background: #fffbeb; color: #92400e; border-radius: 5px; font-size: 0.71rem; font-weight: 700; border: 1px solid #fde68a; }

.day-chip { display: inline-flex; padding: 2px 7px; border-radius: 5px; font-size: 0.70rem; font-weight: 700; }
.day-Sunday    { background: #fef9c3; color: #713f12; }
.day-Monday    { background: #dbeafe; color: #1e40af; }
.day-Tuesday   { background: #dcfce7; color: #14532d; }
.day-Wednesday { background: #f3e8ff; color: #581c87; }
.day-Thursday  { background: #e0f2fe; color: #0c4a6e; }
.day-Friday    { background: #ffe4e6; color: #881337; }

/* ── BUTTONS IN TABLE ── */
.btn-del { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; background: none; color: #dc2626; border: 1px solid #fecaca; border-radius: 6px; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.76rem; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.btn-del:hover { background: #fef2f2; border-color: #f87171; }
.btn-del svg { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 2; }

.btn-edit { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; background: none; color: #1d4ed8; border: 1px solid #bfdbfe; border-radius: 6px; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.76rem; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.btn-edit:hover { background: var(--blue-50); border-color: var(--blue-300); }
.btn-edit svg { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: calc(var(--botnav-h) + 12px); right: 16px;
  background: var(--gray-800); color: rgba(255,255,255,0.92);
  padding: 11px 18px 11px 14px; border-radius: var(--r-md);
  font-size: 0.84rem; font-weight: 500;
  box-shadow: var(--sh-lg); display: flex; align-items: center; gap: 9px;
  transform: translateY(16px); opacity: 0; transition: all 0.26s var(--ease);
  z-index: 999; max-width: 300px; pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-left: 3px solid #4ade80; }
.toast.error   { border-left: 3px solid #f87171; }
.toast-ic { flex-shrink: 0; font-size: 0.9rem; }

/* ── RESPONSIVE ── */
@media(max-width:480px) { .login-card { padding: 28px 20px; } .toolbar { gap: 6px; } }

/* ── ROUTINE MULTI-ROW BUILDER ── */

/* Column layout: Class | Subject | Days | Period | Del */
.routine-entry-headers {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.8fr 72px 36px;
  gap: 8px;
  padding: 6px 10px;
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-radius: var(--r-sm);
  margin-bottom: 4px;
}

.routine-entry-headers span {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--blue-800);
}

@keyframes rowFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.routine-entry-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.8fr 72px 36px;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  animation: rowFadeIn 0.18s ease;
}

.routine-entry-row:last-child { border-bottom: none; }

/* Selects and period input */
.routine-entry-row select,
.routine-entry-row input[type="number"] {
  width: 100%;
  padding: 7px 10px;
  border: 1.5px solid var(--border-mid);
  border-radius: var(--r-sm);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--gray-50);
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
}

.routine-entry-row select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  padding-right: 24px;
  cursor: pointer;
}

.routine-entry-row select:focus,
.routine-entry-row input[type="number"]:focus {
  border-color: var(--brand);
  background-color: var(--surface);
}

.routine-entry-row input[type="number"] {
  text-align: center;
  padding: 7px 4px;
}

/* ── DAY PILLS MULTI-SELECT ── */
.r-days-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.day-pill-btn {
  padding: 3px 7px;
  border-radius: 5px;
  border: 1.5px solid var(--border-mid);
  background: var(--gray-50);
  color: var(--text-muted);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.70rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.day-pill-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--blue-50);
}

.day-pill-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 1px 5px rgba(37,99,235,0.30);
}

/* Remove button */
.btn-remove-row {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #dc2626;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s;
  flex-shrink: 0;
  padding: 0;
  align-self: flex-start;
  margin-top: 2px;
}

.btn-remove-row:hover { background: #fef2f2; border-color: #f87171; }

/* Add row button */
.btn-add-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 14px;
  background: var(--blue-50);
  border: 1.5px dashed var(--blue-300);
  border-radius: var(--r-sm);
  color: var(--brand);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
  justify-content: center;
}

.btn-add-row:hover { background: var(--blue-100); border-style: solid; }

/* ── RESPONSIVE ── */
@media (max-width: 700px) {
  .routine-entry-headers { display: none; }

  .routine-entry-row {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 6px;
    padding: 10px 0 10px;
    align-items: start;
  }

  /* Class spans col 1, Subject spans col 2 */
  .routine-entry-row .r-class   { grid-column: 1; }
  .routine-entry-row .r-subject { grid-column: 2; }

  /* Day pills span full width */
  .routine-entry-row .r-days-wrap {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  /* Period + delete on last row */
  .routine-entry-row input[type="number"] { grid-column: 1; }
  .routine-entry-row .btn-remove-row      { grid-column: 2; justify-self: end; margin-top: 0; }
}

/* ── ROUTINE EDIT MODAL ── */
.r-edit-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

.r-edit-overlay.open { opacity: 1; }

.r-edit-modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: 0 24px 80px rgba(15,23,42,0.28);
  width: 100%;
  max-width: 560px;
  overflow: hidden;
  transform: translateY(16px) scale(0.98);
  transition: transform 0.22s var(--ease);
}

.r-edit-overlay.open .r-edit-modal {
  transform: translateY(0) scale(1);
}

.r-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--brand);
  color: #fff;
}

.r-edit-title {
  font-family: 'Sora', sans-serif;
  font-size: 0.96rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.r-edit-close {
  width: 30px; height: 30px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 7px;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.r-edit-close:hover { background: rgba(255,255,255,0.30); }

.r-edit-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.r-edit-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 480px) {
  .r-edit-row { grid-template-columns: 1fr; }
  .r-edit-row[style*="120px"] { grid-template-columns: 100px 1fr; }
}

.r-edit-entry-id {
  font-size: 0.75rem;
  color: var(--text-hint);
  background: var(--gray-100);
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 500;
  white-space: nowrap;
}

.r-edit-footer {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--gray-50);
}

/* On mobile, sheet from bottom */
@media (max-width: 600px) {
  .r-edit-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .r-edit-modal {
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-width: 100%;
    transform: translateY(40px);
  }

  .r-edit-overlay.open .r-edit-modal {
    transform: translateY(0);
  }
}

/* ── ROUTINE IMAGE MANAGEMENT (Admin) ── */
.routine-admin-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 700px) {
  .routine-admin-cols { grid-template-columns: 1fr; }
}

.routine-admin-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--sh-xs);
}

.routine-admin-col-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 16px;
  background: var(--brand);
  color: #fff;
  font-family: 'Sora', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
}

.routine-admin-col-head svg {
  width: 16px; height: 16px;
  stroke: rgba(255,255,255,0.85);
  fill: none;
  flex-shrink: 0;
}

.routine-admin-cards {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Each grade category card */
.rim-card {
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color 0.2s;
  background: var(--gray-50);
}

.rim-card--has {
  border-color: var(--blue-300);
  background: var(--surface);
}

.rim-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.rim-icon { font-size: 1.4rem; flex-shrink: 0; }

.rim-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.rim-status {
  font-size: 0.72rem;
  font-weight: 600;
}

.rim-status--ok  { color: #16a34a; }
.rim-status--none { color: var(--text-hint); }

/* Image preview */
.rim-preview-wrap {
  position: relative;
  overflow: hidden;
  max-height: 160px;
  background: var(--gray-100);
  cursor: zoom-in;
}

.rim-preview {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
  transition: transform 0.25s var(--ease);
}

.rim-preview-wrap:hover .rim-preview { transform: scale(1.03); }

.rim-preview-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,0);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.rim-preview-wrap:hover .rim-preview-overlay {
  background: rgba(15,23,42,0.35);
}

.rim-preview-hint {
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.2s;
  background: rgba(0,0,0,0.5);
  padding: 4px 12px;
  border-radius: 20px;
}

.rim-preview-wrap:hover .rim-preview-hint { opacity: 1; }

/* Empty slot */
.rim-empty-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 18px 12px;
  color: var(--text-hint);
  background: var(--gray-50);
}

.rim-empty-slot svg {
  width: 32px; height: 32px;
  opacity: 0.3;
}

.rim-empty-slot span {
  font-size: 0.77rem;
  font-weight: 500;
}

/* Actions row */
.rim-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--gray-50);
  border-top: 1px solid var(--border);
}

.rim-upload-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 0.80rem;
}

/* ── SUBJECT IMAGE ADMIN GRID ── */
.subj-img-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

@media (max-width: 500px) {
  .subj-img-admin-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}

/* ── TEACHER ROLES ── */
.role-class-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.role-class-check {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--gray-50);
  border: 1.5px solid var(--border-mid);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-mid);
  transition: all 0.15s;
  user-select: none;
}

.role-class-check input[type="checkbox"] { accent-color: var(--brand); width:14px; height:14px; cursor:pointer; }
.role-class-check:has(input:checked) { background: var(--blue-50); border-color: var(--brand); color: var(--brand); font-weight: 700; }

.role-auth-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  color: var(--text-mid);
  margin-top: 4px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.role-badge-class  { background: #dbeafe; color: #1e40af; }
.role-badge-lead   { background: #fce7f3; color: #9d174d; }
