:root {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #f8fafc;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;

  /* Brand Deep Emerald-700 */
  --accent: #047857;
  --accent-hover: #065f46;
  --accent-soft: rgba(4, 120, 87, 0.12);

  --orange: #d97706;
  --orange-soft: rgba(217, 119, 6, 0.14);

  /* Fixed Semantic Colors */
  --success: #15803d;
  --success-soft: rgba(21, 128, 61, 0.12);
  --warning: #b45309;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger: #be123c;
  --danger-soft: rgba(225, 29, 72, 0.11);
  --excused: #0369a1;
  --excused-soft: rgba(14, 165, 233, 0.14);
  --info: #0369a1;
  --info-soft: rgba(3, 105, 161, 0.12);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-soft: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 10px 25px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"],
.dark {
  --bg-page: #020617;
  --bg-surface: #0f172a;
  --bg-subtle: #1e293b;
  --bg-hover: #1e293b;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --border-color: #1e293b;
  --border-strong: #334155;

  --accent: #34d399;
  --accent-hover: #6ee7b7;
  --accent-soft: rgba(52, 211, 153, 0.15);

  --orange: #fbbf24;
  --orange-soft: rgba(251, 191, 36, 0.16);

  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.15);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.16);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.15);
  --excused: #38bdf8;
  --excused-soft: rgba(56, 189, 248, 0.16);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.15);

  --shadow-soft: 0 2px 12px rgba(0, 0, 0, 0.32);
  --shadow-hover: 0 8px 20px rgba(0, 0, 0, 0.42);
}

[hidden] {
  display: none !important;
}

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

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: "Vazirmatn", Tahoma, Arial, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.65;
  background: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Custom sleek scrollbar */
.custom-scrollbar,
.shell-main,
.sidebar-tree {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.45) transparent;
}
.custom-scrollbar::-webkit-scrollbar,
.shell-main::-webkit-scrollbar,
.sidebar-tree::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track,
.shell-main::-webkit-scrollbar-track,
.sidebar-tree::-webkit-scrollbar-track {
  background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb,
.shell-main::-webkit-scrollbar-thumb,
.sidebar-tree::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.45);
  border-radius: 999px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover,
.shell-main::-webkit-scrollbar-thumb:hover,
.sidebar-tree::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.65);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Fix browser autofill blue tint */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--bg-surface) inset !important;
  -webkit-text-fill-color: var(--text-main) !important;
  transition: background-color 5000s ease-in-out 0s;
}

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

.container {
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: 1.25rem;
}

/* Topbar */
.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 54px;
  padding-inline: 1.25rem;
}

.topbar-right,
.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.02rem;
  color: var(--text-main);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-logo { width: 28px; height: 28px; object-fit: contain; display: block; }

.nav-links { display: flex; align-items: center; gap: 0.35rem; }
.nav-link {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
}
.nav-link.is-active,
.nav-link:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
  text-decoration: none;
}

.autosave-pill {
  font-size: 0.78rem;
  font-weight: 700;
  transition: opacity 0.28s ease, transform 0.28s ease, background-color 0.2s ease, border-color 0.2s ease;
  backdrop-filter: blur(8px);
}
.autosave-pill.is-saving {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}
.autosave-pill.is-saved {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
  animation: pulse-save 0.35s ease;
}
.autosave-pill.is-error {
  background: #fff1f2;
  color: #be123c;
  border-color: #fecdd3;
}
[data-theme="dark"] .autosave-pill.is-saving,
.dark .autosave-pill.is-saving {
  background: rgba(69, 26, 3, 0.92);
  color: #fcd34d;
  border-color: rgba(217, 119, 6, 0.5);
}
[data-theme="dark"] .autosave-pill.is-saved,
.dark .autosave-pill.is-saved {
  background: rgba(6, 78, 59, 0.92);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.5);
}
[data-theme="dark"] .autosave-pill.is-error,
.dark .autosave-pill.is-error {
  background: rgba(76, 5, 25, 0.92);
  color: #fda4af;
  border-color: rgba(225, 29, 72, 0.5);
}

@keyframes pulse-save {
  0% { transform: scale(0.95); }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* App Shell: Sidebar + Main */
.app-shell {
  display: flex;
  flex: 1 1 0%;
  width: 100%;
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: 260px;
  flex-shrink: 0;
  padding: 0.5rem 0 0;
  position: sticky;
  top: 3.5rem;
  height: calc(100vh - 3.5rem);
  overflow-y: auto;
}

.course-node.is-collapsed .btn-tree-toggle svg {
  transform: rotate(-90deg);
}

.auth-field-group input,
.auth-field-group select {
  width: 100%;
  min-height: 38px;
  padding: 0.45rem 0.8rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-field-group input:focus,
.auth-field-group select:focus {
  outline: none;
  border-color: #1d7868;
  box-shadow: 0 0 0 3px rgba(29, 120, 104, 0.16);
}

.password-field-wrap input {
  padding-left: 2.6rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 0.4rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.75rem;
}

.sidebar-tree {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.course-node-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius-sm);
  padding: 0.38rem 0.55rem;
}
.course-node-head:hover,
.course-node-head.is-active { background: var(--bg-subtle); }
.course-node-head.is-active .course-node-link { color: var(--accent); }

.course-node-link {
  display: flex;
  flex-direction: column;
  color: var(--text-main);
  font-weight: 800;
  font-size: 0.88rem;
  flex: 1;
}
.course-node-link:hover { text-decoration: none; color: var(--accent); }
.course-sem { font-size: 0.72rem; font-weight: 400; color: var(--text-muted); }

.btn-tree-toggle {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem 0.45rem;
}

.course-node-children {
  padding-inline-start: 0.75rem;
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  border-inline-start: 1px solid var(--border-color);
  margin-inline-start: 0.6rem;
}
.course-node.is-collapsed .course-node-children { display: none; }

.section-node-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.36rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 600;
}
.section-node-link:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
  text-decoration: none;
}
.section-node-link.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}
.sidebar-sec-count {
  font-size: 0.74rem;
  padding: 0.05rem 0.42rem;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.btn-add-section-inline {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: right;
  padding: 0.28rem 0.6rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.btn-add-section-inline:hover { background: var(--bg-subtle); color: var(--accent); }

.sidebar-footer { padding-top: 0.75rem; border-top: 1px solid var(--border-color); }
.shell-main { flex: 1 1 0%; min-width: 0; padding: 1.35rem 1.5rem 2.75rem; }
.mobile-only { display: none !important; }
.sidebar-backdrop { display: none; }

@media (max-width: 1023px) {
  .mobile-only { display: inline-flex !important; }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    width: 276px;
    height: 100dvh;
    z-index: 85;
    transform: translateX(105%);
    transition: transform 0.22s ease;
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 80;
  }
  .shell-main { padding: 1rem 1rem 2rem; }
}

.main-content { padding-block: 1.35rem 2.5rem; }

/* Headers & Typography Hierarchy */
.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.section-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.section-title,
.class-title,
.page-title {
  margin: 0.15rem 0 0;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
}
.page-subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.section-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.45rem;
}
.header-count-muted {
  font-size: 0.84rem;
  color: var(--text-muted);
  font-weight: 600;
}

.badge,
.badge-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.65rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
  border: none;
  font-family: inherit;
}
.badge-strong {
  padding: 0.22rem 0.8rem;
  font-size: 0.8rem;
}
.badge-btn { cursor: pointer; }
.badge-primary { background: var(--accent-soft); color: var(--accent); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--orange-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-excused { background: var(--excused-soft); color: var(--excused); }
.badge-neutral { background: var(--bg-subtle); color: var(--text-muted); }

.main-mode-tabs {
  display: inline-flex;
  gap: 0.35rem;
  border-bottom: 1px solid var(--border-color);
  width: 100%;
  margin-bottom: 1rem;
}

.mode-tab {
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  cursor: pointer;
}
.mode-tab:hover { color: var(--text-main); }
.mode-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 800;
}

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}
.toolbar-search { max-width: 280px; flex: 1; min-width: 170px; }

/* Surfaces, Cards, Rounded Shadows */
.surface,
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  min-width: 0;
}
.card { padding: 1.35rem; border-radius: var(--radius-lg); }

.surface-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}
.surface-title { margin: 0; font-size: 0.98rem; font-weight: 800; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.48rem 0.95rem;
  min-height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn.is-disabled { opacity: 0.45; pointer-events: none; }
.btn-sm { min-height: 36px; padding: 0.32rem 0.75rem; font-size: 0.82rem; }
.btn-xs { min-height: 30px; padding: 0.2rem 0.55rem; font-size: 0.76rem; }

.btn-primary { background: var(--accent); color: #ffffff; }
.btn-primary:hover { background: var(--accent-hover); color: #ffffff; }
.btn-outline,
.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-strong);
}
.btn-outline:hover,
.btn-secondary:hover { background: var(--bg-subtle); color: var(--text-main); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text-main); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #ffffff; }
.btn-group { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

@media (max-width: 640px) {
  .btn, .btn-sm, .mode-tab, .tab-btn, .att-seg-item span { min-height: 44px; }
}

/* Student Panel: Welcome Card, Course Cards, Progress Bars, Circular Ring */
.welcome-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.35rem 1.5rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(29, 120, 104, 0.14), rgba(29, 120, 104, 0.04));
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-soft);
}
.welcome-title { margin: 0; font-size: 1.35rem; font-weight: 800; color: var(--text-main); }
.welcome-sub { margin: 0.25rem 0 0; font-size: 0.88rem; color: var(--text-muted); }

.student-course-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}
.student-course-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.student-course-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.student-section-list { display: flex; flex-direction: column; }
.student-section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  text-decoration: none;
  transition: background-color 0.15s ease;
}
.student-section-row:last-child { border-bottom: none; }
.student-section-row:hover { background: var(--bg-hover); text-decoration: none; }

.mini-progress-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}
.mini-progress-bar {
  width: 84px;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
}
.mini-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.3s ease;
}
.mini-progress-text {
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
}

.student-detail-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.35rem 1.5rem;
  border-radius: var(--radius-lg);
}

.circular-progress {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--bg-subtle) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
}
.circular-progress.is-empty {
  background: var(--bg-subtle);
}
.circular-progress-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}
.circular-progress-inner strong { font-size: 1.05rem; font-weight: 800; }
.circular-progress-inner small { font-size: 0.7rem; color: var(--text-muted); }

.criteria-cards-grid {
  display: grid;
  gap: 1.15rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.criterion-card {
  padding: 1.15rem 1.25rem;
  border-radius: var(--radius);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.criterion-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.criterion-card.is-ungraded {
  opacity: 0.72;
  box-shadow: none;
}
.criterion-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.criterion-card-title { font-weight: 800; font-size: 0.94rem; }
.criterion-card-score { font-size: 0.88rem; color: var(--text-muted); }
.criterion-card-score strong { font-size: 1.02rem; font-weight: 800; color: var(--text-main); }
.criterion-card-note { font-size: 0.86rem; color: var(--text-main); }
.criterion-teacher-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-top: 0.45rem;
  border-top: 1px dashed var(--border-color);
}

.att-summary-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  border-radius: var(--radius);
}
.att-summary-counters { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.att-counter {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}
.att-rate-pill { font-size: 0.9rem; font-weight: 600; }

.student-att-list { display: flex; flex-direction: column; }
.student-att-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}
.student-att-row:last-child { border-bottom: none; }

/* Course Section Cards (Teacher) */
.section-cards-grid {
  display: grid;
  gap: 1.15rem;
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
}
.section-card {
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.section-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.section-card-head,
.section-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.section-card-title { font-weight: 800; font-size: 0.98rem; color: var(--text-main); }
.section-card-meta { font-size: 0.84rem; color: var(--text-muted); }
.invite-code-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.55rem;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}

/* Excel-like Spreadsheet Table */
.sheet-surface { overflow: hidden; border-radius: var(--radius); }
.sheet-scroll { width: 100%; overflow-x: auto; max-height: 70vh; }

.sheet-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.86rem;
}
.sheet-table th,
.sheet-table td {
  border-bottom: 1px solid var(--border-color);
  border-inline-end: 1px solid var(--border-color);
  padding: 0.45rem 0.65rem;
  text-align: right;
  vertical-align: middle;
}
.sheet-table thead th {
  position: sticky;
  top: 0;
  z-index: 15;
  background: var(--bg-subtle);
  font-weight: 600;
  padding: 0.52rem 0.6rem;
}
.sheet-table thead th.z-20,
.sheet-table thead th.z-30 { z-index: 30; }

.col-idx { width: 44px; min-width: 44px; max-width: 44px; text-align: center !important; }
.col-name { width: 176px; min-width: 176px; max-width: 176px; }
.col-code { width: 128px; min-width: 128px; max-width: 128px; white-space: nowrap; }
.col-crit { min-width: 112px; text-align: center !important; }
.col-total { min-width: 90px; text-align: center !important; }
.col-del { width: 42px; min-width: 42px; max-width: 42px; text-align: center !important; }

.partial-tag {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--warning);
}

.crit-header-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  border: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
  padding: 0.14rem 0.3rem;
  border-radius: 6px;
}
.crit-header-btn:hover { background: var(--border-color); }
.crit-title { font-size: 0.83rem; font-weight: 800; }
.crit-sub { font-size: 0.72rem; color: var(--text-muted); }

.sheet-cell { padding: 0.22rem 0.28rem !important; }
.sheet-num-input {
  width: 100%;
  min-width: 0;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.84rem;
  text-align: center;
}
.sheet-num-input:hover,
.sheet-num-input:focus {
  border-color: var(--accent);
  background: var(--bg-page);
  outline: none;
}
.sheet-num-input.is-invalid { border-color: var(--danger) !important; background: var(--danger-soft); }

.sheet-text-input {
  width: 100%;
  min-width: 0;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.8rem;
  padding-inline: 0.35rem;
}
.sheet-text-input:hover,
.sheet-text-input:focus {
  border-color: var(--accent);
  background: var(--bg-page);
  outline: none;
}

.sheet-check-label { display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 34px; cursor: pointer; }
.sheet-checkbox { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.sheet-summary-row td { background: var(--bg-subtle); font-weight: 800; color: var(--text-muted); }

.btn-row-more {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 1rem;
}
.btn-row-more:hover { background: var(--bg-subtle); color: var(--text-main); }

/* Attendance Navigation & Semantic Segmented Control */
.att-nav-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.85rem; }
.att-date-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.att-current-date {
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 0.86rem;
}

.att-segmented {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-surface);
}
.att-seg-item { position: relative; }
.att-seg-item + .att-seg-item { border-inline-start: 1px solid var(--border-color); }
.att-seg-item input { position: absolute; opacity: 0; pointer-events: none; }
.att-seg-item span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.28rem 0.65rem;
  min-height: 32px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.att-seg-item input:checked + span[data-status="present"] { background: var(--success-soft); color: var(--success); }
.att-seg-item input:checked + span[data-status="absent"] { background: var(--danger-soft); color: var(--danger); }
.att-seg-item input:checked + span[data-status="late"] { background: var(--warning-soft); color: var(--warning); }
.att-seg-item input:checked + span[data-status="excused"] { background: var(--excused-soft); color: var(--excused); }

.att-note-cell { display: flex; align-items: center; gap: 0.4rem; }
.btn-note-toggle.has-note { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* Drawers, Modals, Popovers */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  justify-content: flex-end;
}
.drawer-panel {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  height: 100%;
  border-inline-start: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}
.drawer-title { margin: 0; font-size: 1.02rem; font-weight: 800; }
.drawer-body { flex: 1; overflow-y: auto; padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: 1.15rem; }
.drawer-section { padding-bottom: 1rem; border-bottom: 1px solid var(--border-color); }
.drawer-section:last-child { border-bottom: none; }
.drawer-section-title { margin: 0 0 0.6rem; font-size: 0.84rem; font-weight: 800; color: var(--text-muted); }

.override-row { display: flex; align-items: center; gap: 0.45rem; font-size: 0.84rem; margin-bottom: 0.35rem; cursor: pointer; }
.override-row input { accent-color: var(--accent); }
.sd-crit-row { display: flex; align-items: center; justify-content: space-between; gap: 0.65rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border-color); }
.history-group { border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 0.5rem 0.7rem; margin-bottom: 0.45rem; font-size: 0.82rem; }
.history-group summary { cursor: pointer; font-weight: 600; }
.history-group-list { margin: 0.4rem 0 0; padding-inline-start: 1.1rem; color: var(--text-muted); }

@media (max-width: 640px) {
  .drawer-backdrop { align-items: flex-end; }
  .drawer-panel {
    max-width: 100%;
    height: auto;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    border-inline-start: none;
    border-top: 1px solid var(--border-color);
  }
}

.popover-anchor { position: relative; }
.popover-box,
.popover-menu {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  z-index: 95;
  min-width: 235px;
  padding: 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
}
.popover-menu { padding: 0.35rem; min-width: 190px; }
.popover-title { font-weight: 800; font-size: 0.86rem; margin-bottom: 0.45rem; }

.menu-item {
  display: block;
  width: 100%;
  text-align: right;
  padding: 0.48rem 0.7rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.84rem;
  cursor: pointer;
  text-decoration: none;
}
.menu-item:hover { background: var(--bg-subtle); text-decoration: none; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-dialog {
  width: 100%;
  max-width: 440px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-hover);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.85rem; }
.modal-title { margin: 0; font-size: 1.02rem; font-weight: 800; }

@media (max-width: 640px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-dialog { max-width: 100%; border-radius: 16px 16px 0 0; padding-bottom: 1.75rem; }
}

[hidden] { display: none !important; }

/* Segmented & Password Toggle */
.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
}
.seg-btn.is-active { background: var(--bg-surface); color: var(--text-main); box-shadow: var(--shadow-soft); }

.password-field-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.password-field-wrap input { flex: 1; }
.btn-pass-toggle {
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.7rem;
  min-height: 38px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.backup-list { display: flex; flex-direction: column; gap: 0.6rem; }
.backup-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

/* Forms, Auth, Toast, Skeleton, Utilities */
.form-group { margin-bottom: 0.9rem; }
.form-label { display: block; margin-bottom: 0.3rem; font-size: 0.84rem; font-weight: 600; }
.form-control, .form-select {
  width: 100%;
  min-height: 38px;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.86rem;
}
.form-control-sm, .form-select-sm { min-height: 34px; padding: 0.25rem 0.55rem; font-size: 0.83rem; }
.form-help { margin-top: 0.2rem; font-size: 0.76rem; color: var(--text-muted); }
.form-error { margin-top: 0.2rem; font-size: 0.78rem; color: var(--danger); }

.grid { display: grid; gap: 0.85rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.weekday-pills { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.weekday-pill { position: relative; }
.weekday-pill input { position: absolute; opacity: 0; pointer-events: none; }
.weekday-pill input:checked + span {
  background: #047857;
  border-color: #047857;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(4, 120, 87, 0.25);
}

.invite-code-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.45rem 0.7rem; background: var(--bg-subtle); border-radius: var(--radius-sm); }
.join-code-display { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; letter-spacing: 0.08em; }
.btn-copy-inline { border: none; background: var(--bg-surface); color: var(--text-main); border-radius: 6px; padding: 0.16rem 0.55rem; font-family: inherit; font-size: 0.76rem; cursor: pointer; }

.empty-hero { text-align: center; padding: 2.5rem 1.35rem; }
.empty-code-row { display: flex; align-items: center; justify-content: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }
.empty-join-form { display: flex; align-items: center; justify-content: center; gap: 0.5rem; flex-wrap: wrap; }
.big-join-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.45rem; font-weight: 800; letter-spacing: 0.1em; padding: 0.5rem 1.1rem; border-radius: var(--radius); background: var(--bg-subtle); border: 1px dashed var(--border-strong); }

.toast-container { position: fixed; bottom: 1.25rem; inset-inline-start: 1.25rem; z-index: 100; display: flex; flex-direction: column; gap: 0.45rem; }
.toast { display: inline-flex; align-items: center; gap: 0.65rem; padding: 0.55rem 0.95rem; border-radius: var(--radius-sm); background: var(--text-main); color: var(--bg-surface); font-size: 0.84rem; font-weight: 600; box-shadow: var(--shadow-hover); }
.toast-undo-btn { border: 1px solid rgba(255,255,255,0.35); background: transparent; color: inherit; border-radius: 6px; padding: 0.15rem 0.55rem; font-family: inherit; font-size: 0.78rem; font-weight: 600; cursor: pointer; }

.skeleton {
  height: 16px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border-color) 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.2s infinite;
}
@keyframes skel-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th, .table td { padding: 0.65rem 0.85rem; border-bottom: 1px solid var(--border-color); text-align: right; }
.table th { background: var(--bg-subtle); color: var(--text-muted); font-size: 0.8rem; }
.alerts { display: flex; flex-direction: column; gap: 0.45rem; margin-bottom: 0.9rem; }
.alert { padding: 0.65rem 1rem; border-radius: var(--radius-sm); font-size: 0.86rem; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-error, .alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-warning { background: var(--orange-soft); color: var(--warning); }
.alert-info { background: var(--info-soft); color: var(--info); }

.auth-wrapper { max-width: 420px; margin: 1.75rem auto; }
.tabs { display: flex; gap: 0.25rem; padding: 0.25rem; background: var(--bg-subtle); border-radius: var(--radius-sm); margin-bottom: 1.1rem; }
.tab-btn { flex: 1; padding: 0.45rem; border: none; border-radius: 6px; background: transparent; color: var(--text-muted); font-family: inherit; font-weight: 600; cursor: pointer; }
.tab-btn.is-active { background: var(--bg-surface); color: var(--text-main); box-shadow: var(--shadow-soft); }

.compact-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.85rem; margin-bottom: 1.1rem; }
.breadcrumb { display: flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: var(--text-muted); }

.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.fw-600 { font-weight: 600; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.35rem; }
