/* ==========================================================================
   SIPENA: Sistem Penilaian Akademik SMAN 1 Banjar
   Design System: Swiss & Minimalist Modern Platform Architecture
   Compliant with W3C modern-web-guidance and modern-web-application-hardening
   ========================================================================== */

:root {
  color-scheme: light dark;
  accent-color: #3b66bc;
  interpolate-size: allow-keywords;

  /* shadcn/ui Design Tokens — SIPENA user palette (13-color set, 2026-11) */
  --background: #f5f7fa;
  --foreground: #1a2533;
  --card: #ffffff;
  --card-foreground: #1a2533;
  --popover: #ffffff;
  --popover-foreground: #1a2533;
  --primary: #3b66bc;
  --primary-foreground: #ffffff;
  --primary-hover: #2f55a6;
  --secondary: #e9edf3;
  --secondary-foreground: #1a2533;
  --secondary-hover: #dde3ec;
  --muted: #e9edf3;
  /* AA shade of the palette blue-gray: #8d99a8 = 2.89:1 on white (axe serious).
     #5f6c80 = 4.96:1 on #f5f7fa; dark themes keep #8d99a8 (4.76:1 on dark). */
  --muted-foreground: #5f6c80;
  --accent: #2ec2e6;
  --accent-foreground: #1a2533;
  --destructive: #e74c3c;
  --destructive-foreground: #ffffff;
  --border: #d1d6e0;
  --input: #d1d6e0;
  --ring: #3b66bc;
  --radius: 0.5rem;

  /* ==========================================================================
     Derived token map — user 13-color palette → SIPENA semantics.
     Palette: primary #3B66BC, info/accent #2EC2E6, success #27AE60,
     warning #F5A623, error #E74C3C, slate #2D3A4A, border #D1D6E0,
     surfaces #FFFFFF/#F5F7FA, text #1A2533/#5B6B7F/#8D99A8.
     Rules:
       - *-fill/brand colors keep the exact palette value (buttons, dots, bars).
       - *-text are darkened/lightened variants so text on the matching tinted
         background keeps WCAG AA >= 4.5:1 for small text.
       - --secondary keeps this app's legacy meaning (light hover surface,
         --color-surface-hover); the user's dark slate #2D3A4A lives in
         --color-secondary (solid .btn-secondary/.btn-outline, white text)
         and in the dark-theme surface family.
     Light-theme computed WCAG pairs: #196F3D on #E9F9F0 5.70; #8A5A00 on
     #FEF4E2 5.43; #C0392B on #FDEDEB 4.79; #0E7490 on #E0F6F7 4.77;
     #3B66BC on #E8EEFB 4.74; #2F55A6 on #E8EEFB 6.08; #FFFFFF on #3B66BC
     5.51; #FFFFFF on #2D3A4A 11.57; #5B6B7F on #FFFFFF 5.45.
     --color-danger-strong #C0392B: #FFFFFF on it = 5.44 (AA small text) and is
     the SOLID danger button background in both themes; palette #E74C3C stays
     for non-text accents only (white on it = 3.82, AA large only).
     Gradebook category headers use slate-derived #2D3A4A on #E9EDF3 = 9.84
     (AAA) for the activity column (was violet #6b21a8 on #f5f3ff).
     ========================================================================== */

  /* Backward Compatibility Aliases */
  --color-primary: var(--primary);
  --color-primary-hover: var(--primary-hover);
  --color-primary-light: #e8eefb;
  --color-brand: var(--primary);

  /* User slate #2D3A4A: solid secondary-button surface (white text) */
  --color-secondary: #2d3a4a;
  --color-secondary-hover: #22303e;

  --color-bg: #f5f7fa;
  --color-surface: var(--card);
  --color-surface-hover: var(--secondary);
  --color-border: var(--border);
  --color-border-strong: #b9c1ce;

  --color-text-primary: var(--foreground);
  --color-text-secondary: #5b6b7f;
  --color-text-tertiary: var(--muted-foreground);
  --color-text-muted: #5f6c80;

  --color-success: #27ae60;
  --color-success-text: #196f3d;
  --color-success-bg: #e9f9f0;
  --color-success-border: #bfe8d2;

  --color-warning: #f5a623;
  --color-warning-text: #8a5a00;
  --color-warning-bg: #fef4e2;
  --color-warning-border: #f6d9a8;

  --color-danger: #e74c3c;
  --color-danger-strong: #c0392b; /* white on #C0392B = 5.44:1 AA; solid danger buttons */
  --color-danger-text: #c0392b;
  --color-danger-bg: #fdedeb;
  --color-danger-border: #f5b7b1;

  /* Info family (palette accent #2EC2E6); text variant darkened for AA */
  --color-info: #2ec2e6;
  --color-info-text: #0e7490;
  --color-info-bg: #e0f6f7;
  --color-info-border: #aee7f2;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
  --shadow-focus: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);

  --radius-sm: calc(var(--radius) - 2px);
  --radius-md: var(--radius);
  --radius-lg: calc(var(--radius) + 4px);
  --radius-pill: 9999px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark theme derived from palette slate #2D3A4A / #1A2533 */
    --background: #1a2533;
    --foreground: #f5f7fa;
    --card: #232e3b;
    --card-foreground: #f5f7fa;
    --popover: #232e3b;
    --popover-foreground: #f5f7fa;
    --primary: #8fb0f0;
    --primary-foreground: #ffffff;
    --primary-hover: #a7c2f3;
    --secondary: #2d3a4a;
    --secondary-foreground: #f5f7fa;
    --secondary-hover: #3a4a5c;
    --muted: #2d3a4a;
    --muted-foreground: #8d99a8;
    --accent: #2ec2e6;
    --accent-foreground: #1a2533;
    --destructive: #f1948a;
    --destructive-foreground: #1a2533;
    --border: #33414f;
    --input: #33414f;
    --ring: #8fb0f0;

    --color-bg: #1a2533;
    --color-surface: #232e3b;
    --color-surface-hover: #2d3a4a;
    --color-border: #33414f;
    --color-border-strong: #46586b;

    --color-secondary: #2d3a4a;
    --color-secondary-hover: #3a4a5c;

    --color-text-primary: #f5f7fa;
    --color-text-secondary: #b9c4d2;
    --color-text-tertiary: #8d99a8;
    --color-text-muted: #8d99a8;

    --color-primary-light: rgba(59, 102, 188, 0.3);
    --color-success: #27ae60;
    --color-success-text: #a9dfbf;
    --color-success-bg: rgba(39, 174, 96, 0.18);
    --color-success-border: rgba(39, 174, 96, 0.4);
    --color-warning: #f5a623;
    --color-warning-text: #f8c471;
    --color-warning-bg: rgba(245, 166, 35, 0.15);
    --color-warning-border: rgba(245, 166, 35, 0.4);
    --color-danger: #e74c3c;
    --color-danger-strong: #c0392b; /* solid danger buttons stay AA in dark theme too */
    --color-danger-text: #f5b7b1;
    --color-danger-bg: rgba(231, 76, 60, 0.18);
    --color-danger-border: rgba(245, 183, 177, 0.45);
    --color-info: #2ec2e6;
    --color-info-text: #7dd8ee;
    --color-info-bg: rgba(46, 194, 230, 0.15);
    --color-info-border: rgba(46, 194, 230, 0.4);
  }
}

html[data-theme="light"] {
  color-scheme: light;
  --background: #f5f7fa;
  --foreground: #1a2533;
  --card: #ffffff;
  --card-foreground: #1a2533;
  --popover: #ffffff;
  --popover-foreground: #1a2533;
  --primary: #3b66bc;
  --primary-hover: #2f55a6;
  --ring: #3b66bc;
  --secondary: #e9edf3;
  --secondary-foreground: #1a2533;
  --secondary-hover: #dde3ec;
  --muted: #e9edf3;
  --muted-foreground: #8d99a8;
  --accent: #2ec2e6;
  --accent-foreground: #1a2533;
  --destructive: #e74c3c;
  --destructive-foreground: #ffffff;
  --border: #d1d6e0;
  --input: #d1d6e0;
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-surface-hover: #e9edf3;
  --color-border: #d1d6e0;
  --color-border-strong: #b9c1ce;
  --color-secondary: #2d3a4a;
  --color-secondary-hover: #22303e;
  --color-primary-light: #e8eefb;
  --color-text-primary: #1a2533;
  --color-text-secondary: #5b6b7f;
  /* Light theme uses an AA shade of the palette's blue-gray: #8d99a8 on white
     is 2.89:1 (axe serious). #5f6c80 = 4.96:1 on #f5f7fa. Dark keeps #8d99a8
     (4.76:1 on #232e3b). Same hue family, palette fidelity kept. */
  --color-text-tertiary: #5f6c80;
  --color-text-muted: #8d99a8;
  --color-success: #27ae60;
  --color-success-text: #196f3d;
  --color-success-bg: #e9f9f0;
  --color-success-border: #bfe8d2;
  --color-warning: #f5a623;
  --color-warning-text: #8a5a00;
  --color-warning-bg: #fef4e2;
  --color-warning-border: #f6d9a8;
  --color-danger: #e74c3c;
  --color-danger-strong: #c0392b; /* white on #C0392B = 5.44:1 AA; solid danger buttons */
  --color-danger-text: #c0392b;
  --color-danger-bg: #fdedeb;
  --color-danger-border: #f5b7b1;
  --color-info: #2ec2e6;
  --color-info-text: #0e7490;
  --color-info-bg: #e0f6f7;
  --color-info-border: #aee7f2;
}

html[data-theme="dark"] {
  color-scheme: dark;
  /* Dark surfaces from palette slate: bg #1A2533, surface #232E3B, hover #2D3A4A */
  --background: #1a2533;
  --foreground: #f5f7fa;
  --card: #232e3b;
  --card-foreground: #f5f7fa;
  --popover: #232e3b;
  --popover-foreground: #f5f7fa;
  --primary: #8fb0f0;
  --primary-hover: #a7c2f3;
  --ring: #8fb0f0;
  --secondary: #2d3a4a;
  --secondary-foreground: #f5f7fa;
  --secondary-hover: #3a4a5c;
  --muted: #2d3a4a;
  --muted-foreground: #8d99a8;
  --accent: #2ec2e6;
  --accent-foreground: #1a2533;
  --destructive: #f1948a;
  --destructive-foreground: #1a2533;
  --border: #33414f;
  --input: #33414f;
  --color-bg: #1a2533;
  --color-surface: #232e3b;
  --color-surface-hover: #2d3a4a;
  --color-border: #33414f;
  --color-border-strong: #46586b;
  --color-secondary: #2d3a4a;
  --color-secondary-hover: #3a4a5c;
  --color-primary-light: rgba(59, 102, 188, 0.3);
  --color-text-primary: #f5f7fa;
  --color-text-secondary: #b9c4d2;
  --color-text-tertiary: #8d99a8;
  --color-text-muted: #8d99a8;
  --color-success: #27ae60;
  --color-success-text: #a9dfbf;
  --color-success-bg: rgba(39, 174, 96, 0.18);
  --color-success-border: rgba(39, 174, 96, 0.4);
  --color-warning: #f5a623;
  --color-warning-text: #f8c471;
  --color-warning-bg: rgba(245, 166, 35, 0.15);
  --color-warning-border: rgba(245, 166, 35, 0.4);
  --color-danger: #e74c3c;
  --color-danger-strong: #c0392b; /* solid danger buttons stay AA in dark theme too */
  --color-danger-text: #f5b7b1;
  --color-danger-bg: rgba(231, 76, 60, 0.18);
  --color-danger-border: rgba(245, 183, 177, 0.45);
  --color-info: #2ec2e6;
  --color-info-text: #7dd8ee;
  --color-info-bg: rgba(46, 194, 230, 0.15);
  --color-info-border: rgba(46, 194, 230, 0.4);
}

/* Base resets & typography */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Standard W3C Scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) transparent;
}
@supports not (scrollbar-color: auto) {
  *::-webkit-scrollbar { width: 6px; height: 6px; }
  *::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 4px; }
}

/* Focus visibility & high-contrast */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* App Shell */
.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: inherit;
}

.brand img {
  width: 38px;
  height: auto;
  object-fit: contain;
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-primary);
  line-height: 1.2;
}

.brand-text p {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-quick-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.app-header .brand { min-width: 44px; min-height: 44px; }
.header-account { min-width: 0; }
.app-header .header-account-summary, .app-header .header-theme-label { display: none; }
.header-account-panel { display: flex; align-items: center; gap: 0.75rem; }
.app-header .header-quick-actions > .btn { min-width: 44px; min-height: 44px; }
.app-header .header-actions > .legger-feature-only { min-width: 44px; min-height: 44px; }

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: 0.825rem;
  font-weight: 600;
}

.role-tag {
  background: var(--color-primary);
  color: #ffffff;
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 700;
}

/* Layout Container */
.main-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
  flex: 1;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding: 0 0.875rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
  outline: none;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.btn:disabled {
  pointer-events: none;
  opacity: 0.5;
}

@media (prefers-reduced-motion: no-preference) {
  .btn:active {
    transform: scale(0.98);
  }
}

/* Primary Button: Solid Royal Blue (palette --primary #3B66BC, white 5.51:1) */
.btn-primary {
  background: #3b66bc !important;
  color: #ffffff !important;
  border: 1px solid #2f55a6 !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
}
.btn-primary:hover {
  background: #2f55a6 !important;
  color: #ffffff !important;
}

/* Secondary Button: Solid palette slate #2D3A4A dengan teks Putih (11.57:1) */
.btn-secondary {
  background: #2d3a4a !important;
  color: #ffffff !important;
  border: 1px solid #22303e !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.08);
}
.btn-secondary:hover {
  background: #22303e !important;
  color: #ffffff !important;
}

.btn-outline {
  background: #2d3a4a !important;
  color: #ffffff !important;
  border: 1px solid #22303e !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.btn-outline:hover {
  background: #22303e !important;
  color: #ffffff !important;
}

.btn-ghost {
  background: transparent !important;
  color: #3b66bc !important;
  border-color: transparent !important;
}
.btn-ghost:hover {
  background: #e8eefb !important;
  color: #2f55a6 !important;
}

/* Role tabs (login): active = filled btn-primary; inactive = quiet outline.
   Without this the pair renders as two near-identical dark solids
   (#3B66BC vs #2D3A4A = 2.10:1 background ratio) — hard to tell which tab
   is selected when clicked. Inactive stays quiet in BOTH themes; the
   pressed state also carries aria-pressed. Higher specificity (0,2,0)
   beats the base .btn-secondary (0,1,0) regardless of order. */
.btn-secondary.role-tab-inactive {
  background: #e9edf3 !important;
  color: #1a2533 !important;
  border: 1px solid #d1d6e0 !important;
  box-shadow: none;
}
.btn-secondary.role-tab-inactive:hover {
  background: #dde3ec !important;
  color: #1a2533 !important;
}

@media (prefers-color-scheme: dark) {
  :root .btn-primary {
    background: #3b66bc !important;
    color: #ffffff !important;
    border-color: #2f55a6 !important;
  }
  :root .btn-primary:hover {
    background: #2f55a6 !important;
    color: #ffffff !important;
  }
  :root .btn-secondary {
    background: #2d3a4a !important;
    color: #ffffff !important;
    border-color: #3a4a5c !important;
  }
  :root .btn-secondary:hover {
    background: #3a4a5c !important;
    color: #ffffff !important;
  }
  :root .btn-secondary.role-tab-inactive {
    background: transparent !important;
    color: #b9c4d2 !important;
    border: 1px solid #46586b !important;
    box-shadow: none;
  }
  :root .btn-secondary.role-tab-inactive:hover {
    background: rgba(255, 255, 255, 0.06) !important;
    color: #f5f7fa !important;
  }
  :root .btn-outline {
    background: #2d3a4a !important;
    color: #ffffff !important;
    border-color: #3a4a5c !important;
  }
  :root .btn-outline:hover {
    background: #3a4a5c !important;
    color: #ffffff !important;
  }
}

html[data-theme="dark"] .btn-primary {
  background: #3b66bc !important;
  color: #ffffff !important;
  border-color: #2f55a6 !important;
}
html[data-theme="dark"] .btn-primary:hover {
  background: #2f55a6 !important;
  color: #ffffff !important;
}
html[data-theme="dark"] .btn-secondary {
  background: #2d3a4a !important;
  color: #ffffff !important;
  border-color: #3a4a5c !important;
}
html[data-theme="dark"] .btn-secondary:hover {
  background: #3a4a5c !important;
  color: #ffffff !important;
}
html[data-theme="dark"] .btn-secondary.role-tab-inactive {
  background: transparent !important;
  color: #b9c4d2 !important;
  border: 1px solid #46586b !important;
  box-shadow: none;
}
html[data-theme="dark"] .btn-secondary.role-tab-inactive:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  color: #f5f7fa !important;
}
html[data-theme="dark"] .btn-outline {
  background: #2d3a4a !important;
  color: #ffffff !important;
  border-color: #3a4a5c !important;
}
html[data-theme="dark"] .btn-outline:hover {
  background: #3a4a5c !important;
  color: #ffffff !important;
}

/* Solid Destructive Button: --color-danger-strong #C0392B with white text
   (5.44:1, AA for small text). The palette error #E74C3C (white = 3.82:1, AA
   large only) stays reserved for non-text accents: dots, borders, badges, tints. */
.btn-danger, .btn-destructive, .btn-outline-danger {
  background: var(--color-danger-strong, #c0392b) !important;
  color: #ffffff !important;
  border: 1px solid #a93226 !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
}
.btn-danger:hover, .btn-destructive:hover, .btn-outline-danger:hover {
  background: #a93226 !important;
  border-color: #8f2b21 !important;
  color: #ffffff !important;
}

@media (prefers-color-scheme: dark) {
  :root .btn-danger,
  :root .btn-destructive,
  :root .btn-outline-danger {
    background: var(--color-danger-strong, #c0392b) !important;
    color: #ffffff !important;
    border-color: #a93226 !important;
  }
  :root .btn-danger:hover,
  :root .btn-destructive:hover,
  :root .btn-outline-danger:hover {
    background: #a93226 !important;
    color: #ffffff !important;
  }
}

html[data-theme="dark"] .btn-danger,
html[data-theme="dark"] .btn-destructive,
html[data-theme="dark"] .btn-outline-danger {
  background: var(--color-danger-strong, #c0392b) !important;
  color: #ffffff !important;
  border-color: #a93226 !important;
}
html[data-theme="dark"] .btn-danger:hover,
html[data-theme="dark"] .btn-destructive:hover,
html[data-theme="dark"] .btn-outline-danger:hover {
  background: #a93226 !important;
  color: #ffffff !important;
}

.btn-success {
  background: var(--color-success);
  color: #ffffff;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
.btn-success:hover {
  filter: brightness(0.92);
}

.btn-sm {
  height: 1.875rem;
  padding: 0 0.65rem;
  font-size: 0.78rem;
  border-radius: calc(var(--radius) - 3px);
}

.btn-lg {
  height: 2.75rem;
  padding: 0 1.5rem;
  font-size: 1rem;
  border-radius: var(--radius-md);
}

.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* Cards (shadcn/ui New York card style) */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  border-color: var(--color-border-strong);
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--card-foreground);
}

.card-description {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.card-content {
  padding: 0;
}

/* Forms & Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.form-input, .form-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--background);
  color: var(--foreground);
  font-family: inherit;
  outline: none;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-input:focus, .form-select:focus {
  border-color: var(--ring);
  box-shadow: var(--shadow-focus);
}

.form-input:user-invalid {
  border-color: var(--color-danger);
}
.form-input:user-invalid:focus {
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.15);
}

/* Stats Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  background: var(--color-primary-light);
  color: var(--color-primary);
  flex-shrink: 0;
}

.stat-content h3 {
  font-size: 0.78rem;
  color: var(--color-text-tertiary);
  font-weight: 600;
  text-transform: uppercase;
}

.stat-content p {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--color-text-primary);
  line-height: 1.1;
  margin-top: 0.2rem;
}

/* Weight Badge Strip */
.weights-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}

.weight-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
}

/* Dynamic Gradebook Table Container */
.gradebook-wrapper {
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  position: relative;
  max-height: calc(100vh - 290px);
  min-height: 400px;
}

.gradebook-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Synchronized Two-Tier Sticky Header Architecture */
.gradebook-table thead tr.th-row-1 th {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 36px;
  line-height: 35px;
  padding: 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  border-bottom: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  box-sizing: border-box;
  background: var(--color-surface);
}

.gradebook-table thead tr.th-row-1 th.th-sticky-1 {
  left: 0;
  z-index: 50;
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  text-align: center;
  color: var(--color-text-tertiary);
}

.gradebook-table thead tr.th-row-1 th.th-sticky-2 {
  left: 44px;
  z-index: 50;
  width: 105px;
  min-width: 105px;
  max-width: 105px;
  text-align: center;
  color: var(--color-text-tertiary);
}

.gradebook-table thead tr.th-row-1 th.th-sticky-3 {
  left: 149px;
  z-index: 50;
  width: 220px;
  min-width: 220px;
  max-width: 220px;
  text-align: left !important;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.72rem;
  border-right: 2px solid var(--color-border-strong);
}

.th-cat-att { background: #e8eefb !important; color: #2f55a6; border-top: 3px solid #3b66bc !important; }
/* Activity header: violet #f5f3ff/#6b21a8/#8b5cf6 replaced with slate-derived
   palette tokens. Contrast #2D3A4A on #E9EDF3 = 9.84:1 (WCAG AAA, small text);
   non-color family cue is kept via the 3px top border. */
.th-cat-act { background: #E9EDF3 !important; color: #2D3A4A; border-top: 3px solid #2D3A4A !important; }
.th-cat-assig { background: #e9f9f0 !important; color: #196f3d; border-top: 3px solid #27ae60 !important; }
.th-cat-quiz { background: #fef4e2 !important; color: #8a5a00; border-top: 3px solid #f5a623 !important; }
.th-cat-exam { background: #fdedeb !important; color: #c0392b; border-top: 3px solid #e74c3c !important; }
.th-cat-rapor { background: var(--color-primary-light) !important; color: var(--color-primary); border-top: 3px solid var(--color-primary) !important; }

/* Header Row 2 */
.gradebook-table thead tr.th-row-2 th {
  position: sticky;
  top: 36px;
  z-index: 20;
  height: 36px;
  line-height: 34px;
  padding: 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--color-surface);
  border-bottom: 2px solid var(--color-border-strong);
  border-right: 1px solid var(--color-border);
  box-sizing: border-box;
  vertical-align: middle;
  text-align: center;
}

.gradebook-table thead tr.th-row-2 th.th-sticky-1 {
  left: 0;
  z-index: 50;
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  text-align: center;
}

.gradebook-table thead tr.th-row-2 th.th-sticky-2 {
  left: 44px;
  z-index: 50;
  width: 105px;
  min-width: 105px;
  max-width: 105px;
  text-align: center;
}

.gradebook-table thead tr.th-row-2 th.th-sticky-3 {
  left: 149px;
  z-index: 50;
  width: 220px;
  min-width: 220px;
  max-width: 220px;
  text-align: left !important;
  border-right: 2px solid var(--color-border-strong);
}

.gradebook-table thead tr.th-row-2 th.th-calc {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.col-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
}

.btn-col-del {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.1rem 0.2rem;
  border-radius: 3px;
  transition: all 0.15s ease;
}

.btn-col-del:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

/* Sticky Student Columns with Locked Pixel Geometry */
.sticky-col-1 {
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--color-surface);
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  box-sizing: border-box;
}

.sticky-col-2 {
  position: sticky;
  left: 44px;
  z-index: 10;
  background: var(--color-surface);
  width: 105px;
  min-width: 105px;
  max-width: 105px;
  box-sizing: border-box;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.sticky-col-3 {
  position: sticky;
  left: 149px;
  z-index: 10;
  background: var(--color-surface);
  width: 220px;
  min-width: 220px;
  max-width: 220px;
  text-align: left !important;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-right: 2px solid var(--color-border-strong);
}

/* Table Footer: Summary Row (clean in-flow at table end) */
.gradebook-table tfoot td {
  background: var(--color-surface-hover);
  border-top: 2px solid var(--color-border-strong);
  font-weight: 700;
  padding: 0.75rem 0.65rem;
}

.gradebook-table tbody tr:hover td {
  background-color: var(--color-surface-hover);
}

.gradebook-table tbody tr:hover td.sticky-col-1,
.gradebook-table tbody tr:hover td.sticky-col-2,
.gradebook-table tbody tr:hover td.sticky-col-3 {
  background-color: var(--color-surface-hover);
}

/* Grade Cell Input */
.score-input {
  width: 58px;
  padding: 0.25rem 0.35rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-primary);
  font-family: var(--font-mono);
  outline: none;
  transition: all 0.1s ease;
}

.score-input:focus {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
  background: var(--color-surface);
  color: var(--color-text-primary);
}

.score-input:user-invalid {
  border-color: var(--color-danger);
  background: var(--color-danger-bg);
}

/* Computed Values */
.computed-cell {
  font-family: var(--font-mono);
  font-weight: 700;
}

.grade-badge {
  display: inline-block;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 800;
}
/* Grade badges: palette tints + AA >= 4.5 derived text variants */
.grade-a { background: var(--color-success-bg); color: var(--color-success-text); }
.grade-b { background: var(--color-info-bg); color: var(--color-info-text); }
.grade-c { background: var(--color-warning-bg); color: var(--color-warning-text); }
.grade-d { background: var(--color-danger-bg); color: var(--color-danger-text); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
}
.status-tuntas { background: var(--color-success-bg); color: var(--color-success-text); border: 1px solid var(--color-success-border); }
.status-belum { background: var(--color-danger-bg); color: var(--color-danger-text); border: 1px solid var(--color-danger-border); }

/* Quick Action Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.toolbar-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: modal-fade-in 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-content {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.15), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  animation: modal-scale-in 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-content.modal-content-wide {
  max-width: 980px;
  width: 96vw;
}

.btn-col-att {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e8eefb;
  color: #2f55a6;
  border: 1px solid #b9c1ce;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  transition: all 0.15s ease;
}
.btn-col-att:hover {
  background: #3b66bc;
  color: #ffffff;
  border-color: #3b66bc;
}

@media (prefers-color-scheme: dark) {
  :root .btn-col-att {
    background: rgba(59, 102, 188, 0.25);
    color: #a7c0f0;
    border-color: rgba(59, 102, 188, 0.4);
  }
  :root .btn-col-att:hover {
    background: #3b66bc;
    color: #ffffff;
  }
}

html[data-theme="dark"] .btn-col-att {
  background: rgba(59, 102, 188, 0.25);
  color: #a7c0f0;
  border-color: rgba(59, 102, 188, 0.4);
}
html[data-theme="dark"] .btn-col-att:hover {
  background: #3b66bc;
  color: #ffffff;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-scale-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* Login Fullscreen */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1.5rem;
  background: var(--color-bg);
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  text-align: center;
}

.login-card img {
  width: 72px;
  height: auto;
  margin-bottom: 1rem;
}

.login-role-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.login-role-tabs > .btn { min-width: 0; min-height: 44px; height: auto; padding: 0.5rem 0.25rem; white-space: normal; overflow-wrap: anywhere; line-height: 1.35; }

.print-only {
  display: none !important;
}

/* Print View Override (Official Academic Archive) */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .app-header, .toolbar, .btn, .weights-strip, .theme-toggle-btn, .rare-scroll-progress-track, .rare-status-pill, .filter-chips, .app-footer, #class-summary-bar {
    display: none !important;
  }
  .print-only {
    display: block !important;
  }
  .main-container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .card, .gradebook-wrapper {
    border: none !important;
    box-shadow: none !important;
    max-height: none !important;
    overflow: visible !important;
  }
  .gradebook-table {
    border: 1px solid #000 !important;
    width: 100% !important;
  }
  .gradebook-table th, .gradebook-table td {
    border: 1px solid #000 !important;
    color: #000 !important;
    padding: 4px 6px !important;
    font-size: 8pt !important;
  }
  .gradebook-table thead tr.th-row-1 th,
  .gradebook-table thead tr.th-row-2 th {
    position: static !important;
    background: #f0f0f0 !important;
    color: #000 !important;
    border: 1px solid #000 !important;
  }
  .sticky-col-1, .sticky-col-2, .sticky-col-3 {
    position: static !important;
    box-shadow: none !important;
    border-right: 1px solid #000 !important;
  }
  .score-input {
    border: none !important;
    background: transparent !important;
    font-size: 8pt !important;
    color: #000 !important;
  }
  .btn-col-del, .btn-col-fill, .btn-col-rapor {
    display: none !important;
  }
}

.kbd-shortcuts-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  color: var(--color-text-tertiary);
  background: var(--color-surface-hover);
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.kbd-shortcuts-badge kbd {
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: 3px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.06);
  padding: 0.05rem 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--color-text-secondary);
}

.btn-col-fill {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.78rem;
  line-height: 1;
  padding: 0.1rem 0.2rem;
  border-radius: 3px;
  transition: all 0.15s ease;
}

.btn-col-fill:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
  transform: scale(1.15);
}

/* Accessibility & UI Polish (ui-ux-pro-max & mattpocock guidelines) */
.skip-link {
  position: absolute;
  top: -999px;
  left: 1rem;
  background: var(--color-primary);
  color: #ffffff;
  padding: 0.5rem 1rem;
  z-index: 100;
  border-radius: var(--radius-md);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-md);
}
.skip-link:focus {
  top: 1rem;
}

/* Tabular figures for vertically aligned numbers */
.computed-cell, .score-input, .stat-content p, .grade-badge, .weights-strip {
  font-variant-numeric: tabular-nums;
}

/* Spreadsheet Grid Focus & Active Row Highlighting */
.gradebook-table tbody tr:focus-within td {
  background-color: var(--color-surface-hover);
}

.gradebook-table td:focus-within {
  background-color: var(--color-primary-light) !important;
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.score-input.is-invalid {
  border-color: var(--color-danger) !important;
  background-color: var(--color-danger-bg) !important;
  color: var(--color-danger-text) !important;
}

/* Filter Chips (Tingkat X, XI, XII) */
.filter-chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
}

.filter-chip {
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid #b9c1ce;
  background: #e9edf3;
  color: #1a2533 !important;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-chip:hover {
  background: #dde3ec;
  color: #1a2533 !important;
  border-color: #b9c1ce;
}

.filter-chip.active {
  background: #3b66bc !important;
  color: #ffffff !important;
  border-color: #3b66bc !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.15);
}

@media (prefers-color-scheme: dark) {
  :root .filter-chip {
    background: #232e3b;
    color: #f5f7fa !important;
    border-color: #46586b;
  }
  :root .filter-chip:hover {
    background: #2d3a4a;
    color: #f5f7fa !important;
  }
  :root .filter-chip.active {
    background: #3b66bc !important;
    color: #ffffff !important;
    border-color: #3b66bc !important;
  }
}

html[data-theme="dark"] .filter-chip {
  background: #232e3b;
  color: #f5f7fa !important;
  border-color: #46586b;
}
html[data-theme="dark"] .filter-chip:hover {
  background: #2d3a4a;
  color: #f5f7fa !important;
}
html[data-theme="dark"] .filter-chip.active {
  background: #3b66bc !important;
  color: #ffffff !important;
  border-color: #3b66bc !important;
}

/* Accessible Toast Notification System */
#toast-root {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-primary);
  animation: toast-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-success {
  border-color: var(--color-success-border);
  background: var(--color-success-bg);
  color: var(--color-success-text);
}

.toast-error {
  border-color: var(--color-danger-border);
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
}

.toast-info {
  border-color: var(--color-border);
  background: var(--color-surface);
  color: var(--color-primary);
}

@keyframes toast-in {
  from { transform: translateY(12px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ==========================================================================
   Rare UI Micro-Interactions & Components (swamimalode07/rare-ui)
   Spring physics, animated counters, scroll-progress, and status beacons
   ========================================================================== */

:root {
  --ease-rare: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out-rare: cubic-bezier(0.65, 0, 0.35, 1);
}

/* Rare UI: Scroll Progress Track & Bar */
.rare-scroll-progress-track {
  width: 100%;
  height: 3px;
  background: var(--color-border);
  position: relative;
  overflow: hidden;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

.rare-scroll-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-info));
  transition: width 0.12s var(--ease-rare);
  border-radius: 9999px;
}

/* Rare UI: Status Pill (ai-status & saving beacon) */
.rare-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  transition: all 0.2s var(--ease-rare);
}

.rare-status-dot {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-text-muted);
  display: inline-block;
  flex-shrink: 0;
}

.rare-status-saved .rare-status-dot {
  background: var(--color-success);
  box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.2);
}

.rare-status-saved {
  border-color: var(--color-success-border);
  color: var(--color-success-text);
  background: var(--color-success-bg);
}

.rare-status-saving .rare-status-dot {
  background: var(--color-warning);
}

.rare-status-saving .rare-status-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: var(--color-warning);
  opacity: 0.75;
  animation: rare-ping 1.2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.rare-status-saving {
  border-color: var(--color-warning-border);
  color: var(--color-warning-text);
  background: var(--color-warning-bg);
}

/* Pending-changes counter + immediate save trigger (#4), next to the pill */
.save-pending-counter {
  display: inline-flex;
  align-items: center;
  height: 31px;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  border-radius: 999px;
  border: 1px solid var(--color-warning-border);
  color: var(--color-warning-text);
  background: var(--color-warning-bg);
}
.save-pending-counter[hidden] { display: none; }
#save-pending-now[hidden] { display: none; }

/* Focusable error summaries (#6): login failures and gradebook invalid scores.
   role=alert region; link inside targets the offending field. */
.error-summary {
  border: 1px solid var(--color-danger-border);
  border-left: 4px solid var(--color-danger);
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.85rem;
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
}
.error-summary[hidden] { display: none; }
.error-summary h2 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--color-danger-text);
}
.error-summary ul {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
}
.error-summary a {
  color: var(--color-danger-text);
  font-weight: 600;
  text-decoration: underline;
}
.error-summary:focus {
  outline: 2px solid var(--color-danger);
  outline-offset: 2px;
}

@keyframes rare-ping {
  75%, 100% {
    transform: scale(2.4);
    opacity: 0;
  }
}

/* Rare UI: Button Spring Micro-Interactions */
@media (prefers-reduced-motion: no-preference) {
  .btn {
    transition: background-color 0.2s var(--ease-rare),
                border-color 0.2s var(--ease-rare),
                color 0.2s var(--ease-rare),
                box-shadow 0.2s var(--ease-rare),
                transform 0.15s var(--ease-rare) !important;
  }
  .btn:active {
    transform: scale(0.97) !important;
  }
  .stat-card {
    transition: transform 0.2s var(--ease-rare), box-shadow 0.2s var(--ease-rare), border-color 0.2s var(--ease-rare);
  }
  .stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }
}

/* Rare UI: Delete Micro-Button */
.btn-col-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  transition: all 0.18s var(--ease-rare);
}

.btn-col-del:hover {
  background: var(--color-danger-bg) !important;
  color: var(--color-danger-text) !important;
  transform: scale(1.15);
}

/* Read-only class Legger surfaces; do not change the editable gradebook. */
.legger-feature-only[hidden],
.class-leger-download-feedback[hidden] { display: none !important; }
.class-leger-page { min-width: 0; max-width: 1440px; }
.class-leger-page h2 { font-size: 1.35rem; font-weight: 750; margin-top: 0.45rem; line-height: 1.25; }
.class-leger-toolbar p, .class-leger-entry p, .class-leger-card p,
.class-leger-legacy-card p { color: var(--color-text-secondary); font-size: 0.85rem; margin-top: 0.35rem; }
.class-leger-detail > .class-leger-toolbar { align-items: center; margin-bottom: 0.5rem; }
.class-leger-title-block { min-width: 0; }
.class-leger-title-block > p { font-size: 0.8rem; }
.class-leger-back-link { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 34px; color: var(--color-text-secondary); font-size: 0.8rem; font-weight: 600; text-decoration: none; }
.class-leger-back-link:hover { color: var(--color-primary); }
.class-leger-header .header-container { gap: 0.75rem; }
.class-leger-header .header-actions { gap: 0.45rem; }
.class-leger-header .header-actions > .legger-feature-only { order: 0; }
.class-leger-header .user-badge { order: 1; }
.class-leger-header .header-quick-actions { order: 2; display: flex; align-items: center; gap: 0.4rem; }
.class-leger-header .header-quick-actions > button { min-width: 44px; min-height: 44px; }
.class-leger-header .header-quick-actions .theme-toggle-btn { width: 44px; padding: 0; }
.class-leger-header .header-password-btn { min-width: 44px; min-height: 44px; }
.class-leger-header .header-quick-actions .header-logout-btn { color: var(--color-text-secondary); background: var(--color-surface); border-color: var(--color-border); }
.class-leger-header .header-quick-actions .header-logout-btn:hover { color: var(--color-danger); border-color: var(--color-danger); background: var(--color-danger-bg); }
.class-leger-xlsx-action { min-width: 124px; }
.class-leger-xlsx-action[hidden] { display: none !important; }
.class-leger-xlsx-action > span { display: inline; }
.class-leger-more-actions > summary { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 0.8rem; }
.class-leger-more-actions > summary:focus-visible, .class-leger-back-link:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; border-radius: 4px; }
.class-leger-controls select { min-width: 0; min-height: 40px; width: 100%; color: var(--color-text-primary); background-color: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); padding: 0 0.65rem; font: inherit; }
.class-leger-summary dl > div { border-left: 0; border-bottom: 1px solid var(--color-border); background: transparent; padding: 0.35rem 0.2rem; }
.class-leger-table .class-leger-nisn { min-width: 92px; width: 92px; }
.class-leger-table .class-leger-student-name { min-width: 156px; width: 156px; max-width: 210px; }
.class-leger-table .class-leger-nisn { left: 42px; }
.class-leger-table .class-leger-student-name { left: 134px; }

.class-leger-more-actions { position: relative; }
.class-leger-more-actions > summary { list-style: none; cursor: pointer; }
.class-leger-more-actions > summary::-webkit-details-marker { display: none; }
.class-leger-more-menu { position: absolute; z-index: 60; top: calc(100% + 0.4rem); right: 0; min-width: 190px; padding: 0.45rem; display: grid; gap: 0.35rem; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); box-shadow: var(--shadow-md); }
.class-leger-more-actions:not([open]) .class-leger-more-menu { display: none; }
.class-leger-more-menu > button { width: 100%; justify-content: flex-start; }
.class-leger-more-menu > .btn-outline-danger { color: var(--color-danger-text); background: var(--color-surface); border-color: var(--color-danger-border); }
.class-leger-more-menu > .btn-outline-danger:hover { color: #fff; background: var(--color-danger); }
.class-leger-controls { display: grid; grid-template-columns: auto minmax(180px, 280px) minmax(0,1fr); align-items: center; gap: 0.5rem 0.75rem; max-width: none; margin: 0 0 0.4rem; }
.class-leger-controls .form-label, .class-leger-controls p { margin: 0; }
.class-leger-controls p { font-size: 0.75rem; }
.class-leger-note { font-size: 0.77rem; line-height: 1.4; margin: 0.35rem 0 0.7rem; }
.class-leger-summary dl { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 0.5rem; margin: 0.65rem 0; }
.class-leger-summary dl > div { min-width: 0; padding: 0.5rem 0.65rem; border-left: 2px solid var(--color-border-strong); background: var(--color-surface); }
.class-leger-summary dt { color: var(--color-text-secondary); font-size: 0.72rem; line-height: 1.3; }
.class-leger-summary dd { margin-top: 0.15rem; font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.class-leger-scroll-hint { font-size: 0.74rem; margin: 0.25rem 0; }
.class-leger-entry { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-left: 4px solid var(--color-primary); }
.class-leger-entry h3 { font-size: 1.15rem; font-weight: 800; }
.class-leger-entry .btn { flex-shrink: 0; }
.class-leger-back-links, .class-leger-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.class-leger-actions { justify-content: flex-end; }
.class-leger-filters { display: flex; align-items: end; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.class-leger-grade-filter { border: 0; min-width: 0; }
.class-leger-grade-filter legend { font-weight: 600; font-size: 0.85rem; margin-bottom: 0.5rem; }
.class-leger-grade-tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.class-leger-grade-tabs [aria-pressed="true"] { outline: 2px solid var(--color-text-primary); outline-offset: 2px; }
.class-leger-search { flex: 1; min-width: 180px; max-width: 400px; }
.class-leger-note { color: var(--color-text-secondary); font-size: 0.85rem; line-height: 1.6; margin: 0.75rem 0 1rem; }
.class-leger-result-count { color: var(--color-text-secondary); font-size: 0.85rem; margin: 0.75rem 0; }
.class-leger-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 285px), 1fr)); gap: 1rem; }
.class-leger-card { padding: 1.25rem; margin-bottom: 0; min-width: 0; }
.class-leger-card h3 { font-size: 1.1rem; font-weight: 800; overflow-wrap: anywhere; }
.class-leger-card-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.class-leger-legacy-card { padding: 0.85rem; text-align: center; margin-bottom: 0; }
.class-leger-legacy-card h4 { font-size: 1.1rem; font-weight: 800; }
.class-leger-legacy-card .btn { margin-top: 0.6rem; width: 100%; }
.class-leger-controls { max-width: 400px; margin: 0 0 1rem; }
.class-leger-controls p { font-size: 0.8rem; color: var(--color-text-secondary); margin-top: 0.4rem; }
.class-leger-summary dl { display: flex; flex-wrap: wrap; gap: 1rem 2rem; margin: 1rem 0; }
.class-leger-summary dt { color: var(--color-text-secondary); font-size: 0.78rem; }
.class-leger-summary dd { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.class-leger-download-feedback { font-size: 0.85rem; color: var(--color-text-secondary); margin: 0.75rem 0; overflow-wrap: anywhere; }
.class-leger-error { color: var(--color-danger-text); }
.class-leger-state { padding: 1.5rem; text-align: center; }
.class-leger-state h3, .class-leger-state h2 { margin-bottom: 0.5rem; }
.class-leger-state .btn { margin-top: 0.75rem; }
.class-leger-table-wrap { container-type: inline-size; width: 100%; max-width: 100%; min-width: 0; overflow: auto; max-height: 68vh; overscroll-behavior: contain; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); scrollbar-gutter: stable; }
.class-leger-scroll-hint { display: none; margin: 0.5rem 0; color: var(--color-text-secondary); font-size: 0.78rem; }
.class-leger-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.84rem; font-variant-numeric: tabular-nums; }
.class-leger-table caption { position: sticky; left: 0; width: 100cqi; box-sizing: border-box; text-align: left; padding: 0.75rem; color: var(--color-text-secondary); font-size: 0.8rem; overflow-wrap: anywhere; }
.class-leger-table th, .class-leger-table td { padding: 0.7rem 0.65rem; border-right: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); text-align: center; min-width: 70px; background: var(--color-surface); }
.class-leger-table thead th { position: sticky; top: 0; z-index: 20; background: var(--color-surface-hover); border-bottom: 2px solid var(--color-border-strong); font-weight: 650; vertical-align: middle; }
.class-leger-table thead th:first-child, .class-leger-table tbody td:first-child { min-width: 42px; width: 42px; }
.class-leger-table .class-leger-subject { min-width: 165px; max-width: 220px; }
.class-leger-subject-name { display: block; white-space: normal; line-height: 1.4; overflow-wrap: anywhere; }
.class-leger-subject-code { display: block; font-size: 0.7rem; color: var(--color-text-secondary); margin-top: 0.25rem; font-weight: 500; letter-spacing: 0.035em; }
.class-leger-table .class-leger-nisn { min-width: 92px; width: 92px; max-width: 92px; font-family: var(--font-mono); white-space: nowrap; }
.class-leger-table .class-leger-student-name { min-width: 156px; width: 156px; max-width: 156px; text-align: left; font-weight: 600; overflow-wrap: anywhere; }
.class-leger-table .class-leger-student-name,
.class-leger-table .class-leger-nisn,
.class-leger-table thead th:first-child,
.class-leger-table tbody td:first-child { position: sticky; z-index: 10; }
.class-leger-table thead .class-leger-student-name,
.class-leger-table thead .class-leger-nisn,
.class-leger-table thead th:first-child { z-index: 40; background: var(--color-surface-hover); }
.class-leger-table th:first-child, .class-leger-table td:first-child { left: 0; }
.class-leger-table .class-leger-nisn { left: 42px; }
.class-leger-table .class-leger-student-name { left: 134px; border-right: 2px solid var(--color-border-strong); }
.class-leger-table tbody tr:nth-child(even) td,
.class-leger-table tbody tr:nth-child(even) th { background: var(--color-surface-hover); }
.class-leger-table tbody tr:hover td,
.class-leger-table tbody tr:hover th { background: var(--color-surface-hover); }
.class-leger-table tbody tr:last-child td,
.class-leger-table tbody tr:last-child th { border-bottom: 0; }
.class-leger-score, .class-leger-average { font-weight: 650; }
.class-leger-table .class-leger-average { border-left: 2px solid var(--color-border-strong); }
.class-leger-missing { color: var(--color-text-secondary); }
.class-leger-partial { padding-left: 2px; font-size: 0.75rem; }
.class-leger-conflict { font-size: 0.75rem; font-weight: 700; border: 1px solid var(--color-border-strong); border-radius: 3px; padding: 0.2rem 0.3rem; }
.class-leger-legend { margin-top: 1rem; font-size: 0.8rem; color: var(--color-text-secondary); line-height: 1.6; }
.class-leger-legend p + p { margin-top: 0.25rem; }
.class-leger-print-heading { text-align: center; margin-bottom: 1rem; }
.class-leger-print-heading h1 { font-size: 14pt; margin: 0.4rem 0; }
@media (max-width: 960px) {
  .class-leger-header .header-container { flex-wrap: nowrap; align-items: center; gap: 0.5rem; padding: 0.45rem 0.75rem; }
  .class-leger-header .brand { min-width: 0; gap: 0.5rem; flex: 0 1 auto; }
  .class-leger-header .brand img { width: 32px; }
  .class-leger-header .brand-text h1 { font-size: 1rem; }
  .class-leger-header .brand-text p { font-size: 0.68rem; }
  .class-leger-header .header-actions { width: auto; min-width: 0; margin-left: auto; flex: 0 0 auto; gap: 0.35rem; }
  .class-leger-header .user-badge { padding: 0.25rem 0.4rem; min-width: 0; border-radius: var(--radius-sm); font-size: 0.72rem; }
  .class-leger-header .user-badge .role-tag { font-size: 0.6rem; padding: 0.12rem 0.3rem; }
  .class-leger-header .user-badge > span:last-child { display: none; }
  .class-leger-header .header-password-btn { width: 44px; min-width: 44px; min-height: 44px; padding: 0; }
  .class-leger-header .header-password-btn > span { display: none; }
  .class-leger-header .header-quick-actions { gap: 0.25rem; }
  .class-leger-header .header-quick-actions > button { width: 44px; min-width: 44px; min-height: 44px; padding: 0; white-space: nowrap; }
  .class-leger-header .header-quick-actions .header-logout-btn { width: auto; min-width: 56px; padding: 0 0.55rem; }
  .class-leger-page { padding: 0.9rem 0.75rem; }
  .class-leger-actions > .btn, .class-leger-more-actions > summary, .class-leger-back-link, .class-leger-more-menu > button { min-width: 44px; min-height: 44px; }
  .class-leger-detail > .class-leger-toolbar { gap: 0.35rem; margin-bottom: 0.25rem; }
  .class-leger-detail .class-leger-title-block { flex: 1 1 220px; }
  .class-leger-page h2 { font-size: 1.18rem; }
  .class-leger-controls { grid-template-columns: auto minmax(160px,240px) minmax(0,1fr); }
  .class-leger-controls select { min-height: 44px; }
  .class-leger-table-wrap { max-height: 62vh; }
}
@media (max-width: 640px) {
  .class-leger-header .header-container { padding: 0.45rem 0.65rem; }
  .class-leger-header .brand { gap: 0.35rem; }
  .class-leger-header .brand img { width: 28px; }
  .class-leger-header .user-badge { display: none; }
  .class-leger-header .header-actions { gap: 0.35rem; }
  .class-leger-header .header-password-btn, .class-leger-header .header-quick-actions .theme-toggle-btn { width: 44px; min-width: 44px; min-height: 44px; }
  .class-leger-header .header-quick-actions .header-logout-btn { width: auto; min-width: 54px; min-height: 44px; }
  .class-leger-page { padding: 0.75rem 0.65rem; }
  .class-leger-detail .class-leger-actions .class-leger-xlsx-action,
  .class-leger-detail .class-leger-actions .class-leger-more-actions > summary { min-height: 44px; height: 44px; }
  .class-leger-page .class-leger-back-link { min-height: 44px; }
  .class-leger-controls select { min-height: 44px; }
  .class-leger-header .header-actions { gap: 0.25rem; }
  .class-leger-header .header-quick-actions { gap: 0.15rem; }
  .class-leger-header .header-quick-actions .header-logout-btn { min-width: 52px; padding-inline: 0.45rem; font-size: 0.82rem; }
  .class-leger-header .brand { gap: 0.3rem; }
  .class-leger-header .brand-text h1 { font-size: 0.95rem; }
  .class-leger-header .brand-text p { font-size: 0.62rem; }
  .class-leger-header .brand img { width: 25px; }
  .class-leger-detail > .class-leger-toolbar { align-items: flex-start; }
  .class-leger-detail .class-leger-title-block { flex: 1 1 0; }
  .class-leger-page h2 { font-size: 1.1rem; }
  .class-leger-title-block > p { font-size: 0.74rem; }
  .class-leger-back-link { font-size: 0.75rem; }
  .class-leger-detail .class-leger-actions { flex: 0 0 auto; gap: 0.35rem; }
  .class-leger-xlsx-action { min-width: 44px; width: 44px; height: 44px; padding: 0; }
  .class-leger-xlsx-action > span { display: none; }
  .class-leger-more-actions > summary { min-width: 68px; min-height: 44px; height: 44px; padding: 0 0.6rem; }
  .class-leger-table .class-leger-nisn { min-width: 76px; width: 76px; max-width: 76px; }
  .class-leger-table .class-leger-student-name { min-width: 112px; width: 112px; max-width: 112px; }
  .class-leger-table .class-leger-nisn { left: 0; }
  .class-leger-table .class-leger-student-name { left: 76px; }
  .class-leger-more-menu { min-width: min(220px, calc(100vw - 24px)); }
  .class-leger-controls { grid-template-columns: 1fr; gap: 0.3rem; margin-bottom: 0.25rem; }
  .class-leger-controls select { min-height: 44px; }
  .class-leger-controls p:empty { display: none; }
  .class-leger-note { font-size: 0.72rem; margin: 0.25rem 0 0.4rem; }
  .class-leger-summary dl { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 0.75rem; margin: 0.35rem 0; }
  .class-leger-summary dl > div { padding: 0.35rem 0.1rem; }
  .class-leger-summary dt { font-size: 0.68rem; }
  .class-leger-summary dd { font-size: 0.95rem; }
  .class-leger-table-wrap { max-height: 58vh; }
  .class-leger-scroll-hint { display: block; margin: 0.2rem 0; }
  .class-leger-table { font-size: 0.76rem; }
  .class-leger-table th, .class-leger-table td { padding: 0.55rem 0.4rem; }
  .class-leger-table .class-leger-subject { min-width: 130px; }
  .class-leger-table thead tr > :first-child,
  .class-leger-table tbody tr > :first-child,
  .class-leger-table tr > :nth-child(4) { display: none; }
  .class-leger-table .class-leger-nisn { min-width: 76px; width: 76px; max-width: 76px; font-size: 0.68rem; }
  .class-leger-table .class-leger-student-name { min-width: 112px; width: 112px; max-width: 112px; font-size: 0.75rem; }
  .class-leger-table .class-leger-nisn { left: 0; }
  .class-leger-table .class-leger-student-name { left: 76px; }
  .class-leger-entry { align-items: stretch; flex-direction: column; }
  .class-leger-toolbar { align-items: stretch; }
  .class-leger-page .btn, .class-leger-entry .btn { white-space: normal; height: auto; min-height: 2.5rem; padding-top: 0.45rem; padding-bottom: 0.45rem; }
  .class-leger-detail .class-leger-xlsx-action, .class-leger-more-actions > summary { height: 44px; min-height: 44px; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
  .class-leger-card-actions > * { flex: 1 1 auto; }
  .class-leger-filters { gap: 0.75rem; }
  .class-leger-search { max-width: none; width: 100%; }
  .class-leger-controls { max-width: none; }
}
@media (max-width: 360px) {
  .class-leger-header .brand img { width: 24px; }
  .class-leger-header .brand-text p { display: none; }
  .class-leger-header .header-password-btn, .class-leger-header .header-quick-actions .theme-toggle-btn { width: 44px; min-width: 44px; min-height: 44px; }
  .class-leger-header .header-quick-actions .header-logout-btn { min-width: 52px; min-height: 44px; font-size: 0.78rem; }
  .class-leger-table .class-leger-student-name { min-width: 102px; width: 102px; max-width: 102px; }
}
@media (max-width: 640px) and (orientation: landscape) {
  .class-leger-table-wrap { max-height: 44vh; }
  .class-leger-page { padding-block: 0.55rem; }
}
@media print {
  .class-leger-controls, .class-leger-download-feedback { display: none !important; }
  .class-leger-page { max-width: none !important; color: #000 !important; }
  .class-leger-table-wrap { container-type: normal; overflow: visible !important; max-height: none !important; border: none !important; border-radius: 0; }
  .class-leger-table caption { position: static; width: auto; }
  .class-leger-table { width: 100% !important; table-layout: fixed; border-collapse: collapse; font-size: 6pt; }
  .class-leger-table thead { display: table-header-group; }
  .class-leger-table th, .class-leger-table td { position: static !important; min-width: 0 !important; max-width: none !important; padding: 3px; border: 1px solid #000 !important; color: #000 !important; background: #fff !important; overflow-wrap: anywhere; white-space: normal !important; }
  .class-leger-table .class-leger-student-name { width: 13%; }
  .class-leger-table .class-leger-nisn { width: 9%; }
  .class-leger-subject-code { color: #000; font-size: 5.5pt; }
  .class-leger-table tr { break-inside: avoid; }
  .class-leger-note, .class-leger-legend { font-size: 7pt; color: #000; }
  .class-leger-summary dl { margin: 0.5rem 0; gap: 0.5rem 1.5rem; }
  .class-leger-summary dt, .class-leger-summary dd { font-size: 8pt; color: #000; }
}

/* Authenticated workspaces: keep navigation and wide data inside their own bounds. */
.workspace-page, .workspace-page .toolbar > *, .workspace-page .stats-grid > * { min-width: 0; }
.workspace-header .brand { flex-shrink: 0; }
.workspace-header .user-badge { min-width: 0; }
.workspace-header .user-badge > span:last-child { max-width: clamp(180px, 16vw, 280px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gradebook-toolbar { align-items: flex-start; }
.gradebook-heading { flex: 1 1 100%; }
.gradebook-title-row { flex-wrap: wrap; }
.gradebook-title-row > a { flex-shrink: 0; }
.gradebook-actions { width: 100%; }
.gradebook-page .rare-status-saved { color: var(--color-text-primary); }
.gradebook-more-actions { min-width: 0; }
.gradebook-more-actions > summary { list-style: none; cursor: pointer; }
.gradebook-more-actions > summary::-webkit-details-marker { display: none; }
.gradebook-more-actions > summary::after { content: '+'; margin-left: 0.4rem; }
.gradebook-more-actions[open] > summary::after { content: '−'; }
.gradebook-more-menu { display: flex; flex-wrap: wrap; gap: 0.5rem; padding-top: 0.5rem; }
.gradebook-more-actions:not([open]) > .gradebook-more-menu { display: none; }
.gradebook-more-actions > summary:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.gradebook-scroll-hint, .workspace-table-hint { font-size: 0.78rem; color: var(--color-text-secondary); margin: 0.4rem 0 0.6rem; }
.gradebook-page #table-container .th-row-1 th { height: 36px; line-height: 1.2; }
.gradebook-page #table-container .th-row-2 th { line-height: 1.2; }
.gradebook-page #table-container tbody td { padding: 0.35rem 0.5rem; border-right: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); }
.gradebook-page #table-container .sticky-col-3 { border-right: 2px solid var(--color-border-strong); }
.gradebook-page #table-container tbody tr:nth-child(even) td { background: var(--color-surface-hover); }
.teachers-table-scroll { max-width: 100%; }
#teachers-table th, #teachers-table td { padding: 0.75rem; border-bottom: 1px solid var(--color-border); }
#teachers-table th { text-align: left; color: var(--color-text-secondary); }

@media print {
  .gradebook-page .btn-col-att,
  .gradebook-page .gradebook-scroll-hint { display: none !important; }
}

@media screen and (max-width: 960px) {
  .workspace-header .header-container { min-width: 0; padding: 0.5rem 0.75rem; gap: 0.5rem; }
  .workspace-header .brand { gap: 0.4rem; min-height: 44px; }
  .workspace-header .brand img { width: 28px; }
  .workspace-header .brand-text h1 { font-size: 1rem; }
  .workspace-header .brand-text p { font-size: 0.68rem; }
  .workspace-header .header-actions { min-width: 0; margin-left: auto; gap: 0.5rem; }
  .workspace-header .user-badge > span:last-child { display: none; }
  .workspace-header .header-password-btn { width: 44px; padding: 0; }
  .workspace-header .header-password-btn > span { display: none; }
  .workspace-header .btn { min-width: 44px; min-height: 44px; }
  .workspace-header .header-quick-actions { gap: 0.25rem; }
  .workspace-header .theme-toggle-btn { width: 44px; padding: 0; }
  .workspace-page { padding: 1rem 0.75rem; }
  .workspace-page .btn, .workspace-page .filter-chip, .workspace-page summary.btn,
  .workspace-page .form-input, .workspace-page .form-select { min-width: 44px; min-height: 44px; }
  .workspace-page .btn { height: auto; padding-block: 0.5rem; white-space: normal; }
  .workspace-page .toolbar { gap: 0.75rem; }
  .workspace-page .toolbar-group { min-width: 0; flex-wrap: wrap; }
  .workspace-page .gradebook-actions > .btn-secondary,
  .workspace-page .gradebook-more-actions > summary { background: var(--color-surface) !important; color: var(--color-text-primary) !important; border-color: var(--color-border-strong) !important; box-shadow: none; }
  .workspace-page .form-input, .workspace-page .form-select { max-width: 100%; }
  .gradebook-page .kbd-shortcuts-badge { display: none; }
  .gradebook-page .gradebook-actions { display: flex; gap: 0.5rem; }
  .gradebook-actions .gradebook-more-actions[open] { flex: 1 1 100%; }
  .gradebook-page #class-summary-bar { padding: 0.75rem !important; }
  .gradebook-page .gradebook-wrapper { min-height: 220px; max-height: 65dvh; }
  .gradebook-page #table-container .score-input { min-height: 44px; font-size: 1rem; width: 64px; }
  .gradebook-page #table-container .btn-col-att,
  .gradebook-page #table-container .btn-col-fill,
  .gradebook-page #table-container .btn-col-del { display: inline-flex; align-items: center; justify-content: center; width: 44px; min-width: 44px; height: 44px; padding: 0; }
  .gradebook-page #table-container .col-name-row { display: grid; grid-template-columns: repeat(3,44px); gap: 0.15rem; padding-block: 0.2rem; }
  .gradebook-page #table-container .col-name-row > span { grid-column: 1 / -1; line-height: 1.3; }
}
@media screen and (max-width: 640px) {
  .workspace-header .header-container { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 0.35rem 0.5rem; padding-inline: 0.65rem; }
  .workspace-header .brand { grid-column: 1; grid-row: 1; }
  .workspace-header .header-actions { display: contents; }
  .workspace-header .header-quick-actions { grid-column: 2; grid-row: 1; justify-self: end; }
  .workspace-header .header-actions > .legger-feature-only { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
  .workspace-header .user-badge { display: none; }
  .workspace-header .header-logout-btn { padding-inline: 0.55rem; }
  .workspace-page { padding: 0.85rem 0.65rem; }
  .workspace-page .card { padding: 0.85rem; }
  .workspace-page .toolbar > *, .workspace-page .toolbar-group { width: 100%; }
  .workspace-page .toolbar .form-input { max-width: none !important; }
  .workspace-page .stats-grid { grid-template-columns: minmax(0,1fr); gap: 0.75rem; }
  .workspace-page .class-card-actions { flex-wrap: wrap; }
  .workspace-page .class-card-actions > button { flex: 1 1 100% !important; }
  .guru-page #select-monitor-teacher { width: 100%; min-width: 0; }
  .guru-page main, .guru-page .toolbar h2 { overflow-wrap: anywhere; }
  .gradebook-page .gradebook-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: stretch; }
  .gradebook-actions > #filter-gradebook-students, .gradebook-actions > #btn-filter-remedial,
  .gradebook-actions > #save-status-pill { grid-column: 1 / -1; }
  .gradebook-actions > #save-status-pill { min-height: 32px; justify-content: center; }
  .gradebook-actions .gradebook-more-actions { grid-column: 1 / -1; }
  .gradebook-more-actions > summary { width: 100%; }
  .gradebook-more-menu { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .gradebook-more-menu > .btn { width: 100%; }
  .gradebook-page #class-summary-bar > div:first-child { display: grid !important; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0.75rem !important; width: 100%; }
  .gradebook-page #class-summary-bar > div:first-child > div[style*="width:1px"] { display: none; }
  .gradebook-page #class-summary-bar > div:last-child { text-align: left !important; }
  .gradebook-page #top-grade-distribution { flex-wrap: wrap; }
  .gradebook-page { display: flex; flex-direction: column; }
  .gradebook-page > .gradebook-toolbar { order: 0; margin-bottom: 0.4rem; }
  .gradebook-page > .gradebook-scroll-hint { order: 1; }
  .gradebook-page > .rare-scroll-progress-track { order: 2; }
  .gradebook-page > #table-container { order: 3; }
  .gradebook-page > #weights-container { order: 4; margin-top: 0.75rem; margin-bottom: 0.75rem; }
  .gradebook-page > #class-summary-bar { order: 5; }
  .gradebook-page > .print-only { order: 6; }
  .gradebook-page #table-container .sticky-col-1,
  .gradebook-page #table-container .th-sticky-1 { display: none; }
  .gradebook-page #table-container .sticky-col-2,
  .gradebook-page #table-container .th-sticky-2 { left: 0; width: 88px; min-width: 88px; max-width: 88px; padding-inline: 0.25rem; }
  .gradebook-page #table-container .sticky-col-3,
  .gradebook-page #table-container .th-sticky-3 { left: 88px; width: 104px; min-width: 104px; max-width: 104px; padding-inline: 0.35rem; font-size: 0.75rem; white-space: normal; overflow-wrap: anywhere; line-height: 1.35; }
}
/* Shared mobile shell: brand + optional Legger entry + account, never a second row. */
@media screen and (max-width: 960px) {
  .app-header .header-container { position: relative; min-width: 0; display: flex; flex-wrap: nowrap; align-items: center; padding: 0.5rem 0.65rem; gap: 0.5rem; }
  .app-header .brand { flex: 0 1 auto; gap: 0.4rem; }
  .app-header .brand img { width: 28px; height: 28px; flex-shrink: 0; }
  .app-header .brand-text h1 { font-size: 1rem; }
  .app-header .brand-text p { display: block; font-size: 0.68rem; white-space: nowrap; }
  .app-header .header-actions { display: flex; width: auto; flex: 0 0 auto; min-width: 0; margin-left: auto; gap: 0.5rem; }
  .app-header .header-actions > .legger-feature-only { min-width: 44px; min-height: 44px; }
  .app-header .header-account { position: static; }
  .app-header .header-account-summary { display: inline-flex; width: 44px; min-width: 44px; min-height: 44px; padding: 0; list-style: none; }
  .header-account-summary::-webkit-details-marker { display: none; }
  .app-header .header-account-summary:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
  .app-header .header-account-panel { position: absolute; z-index: 1; right: 0.65rem; top: calc(100% + 0.35rem); width: min(20rem, calc(100vw - 1.3rem)); max-height: calc(100dvh - 4.5rem); overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; align-items: stretch; gap: 0.75rem; padding: 0.75rem; color: var(--color-text-primary); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); }
  .app-header .header-account:not([open]) > .header-account-panel { display: none; }
  .app-header .header-account .user-badge { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; padding: 0.5rem; border-radius: var(--radius-sm); }
  .app-header .header-account .user-badge > span:last-child { display: block; max-width: none; overflow: visible; white-space: normal; overflow-wrap: anywhere; }
  .app-header .header-account .header-quick-actions { display: flex; flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .app-header .header-account .header-quick-actions > button { width: 100%; min-height: 44px; height: auto; padding: 0.65rem 0.75rem; justify-content: flex-start; white-space: normal; }
  .app-header .header-account .header-password-btn > span, .app-header .header-theme-label { display: inline; }
}

@media screen and (max-width: 960px) {
  #modal-root .modal-overlay { padding: 0.65rem; }
  #modal-root .modal-content { min-width: 0; max-width: min(100%,780px); max-height: calc(100dvh - 1.3rem) !important; padding: 1rem !important; }
  #modal-root .modal-content > div:first-child { gap: 0.5rem; }
  #modal-root .modal-content h3 { min-width: 0; overflow-wrap: anywhere; }
  #modal-root .modal-content .btn,
  #modal-root .modal-content .filter-chip { min-width: 44px; min-height: 44px; flex-shrink: 0; height: auto; padding-block: 0.5rem; white-space: normal; }
  #modal-root .modal-content input:not([type=radio]):not([type=checkbox]),
  #modal-root .modal-content select,
  #modal-root .modal-content textarea { min-height: 44px; min-width: 0; max-width: 100%; font-size: 1rem !important; }
  #modal-root .modal-content label:has(input[type=radio]),
  #modal-root .modal-content label:has(input[type=checkbox]) { min-height: 44px; }
  #modal-root .modal-content input[type=radio],
  #modal-root .modal-content input[type=checkbox] { flex-shrink: 0; }
  #change-pwd-form button[title="Lihat/Sembunyikan"] { width: 44px; height: 44px; right: 0 !important; display: grid; place-items: center; }
  #change-pwd-form input.form-input { padding-right: 3rem !important; }
  #modal-root .attendance-modal { display: block !important; }
  .attendance-meeting-presets { flex-wrap: wrap; }
  .attendance-modal .attendance-table-scroll { overflow: auto; max-width: 100%; min-width: 0; min-height: 220px !important; }
  .attendance-modal .attendance-modal-actions { flex-wrap: wrap; }
}
@media screen and (max-width: 640px) {
  #modal-root form > div:last-child:has(> button),
  .attendance-modal .attendance-modal-actions { flex-direction: column; align-items: stretch !important; width: 100%; }
  #modal-root form > div:last-child > button,
  .attendance-modal .attendance-modal-actions > button { width: 100%; }
  .attendance-modal .filter-chips { flex-wrap: wrap; }
  #modal-root .modal-content .form-group { min-width: 0; }
}

/* Print column model: sizes come from the generated <colgroup>, not from guessing. */
.gradebook-print-columns { display: none; }

@media print {
  @page {
    margin: 10mm;
  }
  .gradebook-print-columns { display: table-column-group; }
  .gradebook-table {
    table-layout: fixed !important;
    width: 100% !important;
    max-width: 100% !important;
    border: none !important;
  }
  .gradebook-table col { width: var(--print-width) !important; }
  .gradebook-table th,
  .gradebook-table td {
    min-width: 0 !important;
    max-width: none !important;
    padding: 1px 2px !important;
    font-size: 6.5pt !important;
    line-height: 1.25 !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
  }
  .gradebook-table thead th {
    font-size: 6pt !important;
    line-height: 1.15 !important;
  }
  .gradebook-table .score-input {
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
    padding: 0 !important;
  }
  .gradebook-table thead { display: table-header-group; }
  .gradebook-table tfoot { display: table-row-group; }
  .gradebook-table tbody tr { break-inside: avoid; }
  .gradebook-table tbody tr:nth-last-child(-n+5) { break-after: avoid; }
  .gradebook-table tfoot, .gradebook-wrapper { break-after: avoid; }
  .print-only.print-signatures { break-inside: avoid; }
  .print-header { margin-bottom: 0.6rem !important; }
  .print-header > div:first-child { gap: 0.6rem !important; padding-bottom: 0.4rem !important; margin-bottom: 0.4rem !important; }
  .print-header img { width: 42px !important; height: auto !important; }
  .print-header h2 { font-size: 11pt !important; }
  .print-header h3 { font-size: 8pt !important; }
  .print-header h4 { font-size: 7.5pt !important; }
  .print-header p { font-size: 6.5pt !important; margin: 0 !important; }
  .print-only.print-signatures { display: flex !important; justify-content: space-between; margin-top: 0.75rem !important; }
  .print-signatures > div { width: 45% !important; }
  .print-signatures p:not(:first-child) { margin-bottom: 0 !important; }
  .print-signatures p { margin-bottom: 1.5rem !important; font-size: 8pt !important; }
}

/* ==========================================================================
   WORK 6: multi-tab gradebook conflict banner.
   Token-based colors (warning tokens are redefined in BOTH dark scopes), so no
   extra theme overrides are needed for light + dark readability.
   ========================================================================== */
.gradebook-conflict-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  margin: 0 0 1rem 0;
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
  border: 1px solid var(--color-warning-border);
  border-left: 4px solid var(--color-warning);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.4;
}

/* Per-student rapor action button inside the gradebook identity cell. */
.btn-col-rapor {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  padding: 0.1rem 0.2rem;
  margin-left: 0.25rem;
  border-radius: 3px;
  transition: all 0.15s ease;
  vertical-align: middle;
}

.btn-col-rapor:hover {
  background: var(--color-info-bg);
  color: var(--color-info-text);
}

/* ==========================================================================
   WORK 8: per-student rapor view (#rapor/<assignmentId>/<studentId>).
   ========================================================================== */
.student-rapor-page .rapor-identity {
  margin-bottom: 1rem;
}

.student-rapor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: var(--color-surface);
}

.student-rapor-table th,
.student-rapor-table td {
  border: 1px solid var(--color-border);
  padding: 0.45rem 0.6rem;
  text-align: left;
}

.student-rapor-table thead th {
  background: var(--color-surface-hover);
  font-weight: 700;
  color: var(--color-text-primary);
}

.student-rapor-table .rapor-score {
  font-family: var(--font-mono);
  font-weight: 700;
  text-align: center;
  color: var(--color-text-primary);
}

.student-rapor-error {
  padding: 1.5rem;
  border: 1px solid var(--color-danger-border, var(--color-border));
  border-radius: var(--radius-md);
  color: var(--color-danger-text, var(--color-danger));
  background: var(--color-danger-bg, var(--color-surface));
}

@media print {
  .student-rapor-page .rapor-identity {
    border: none;
    box-shadow: none;
    background: transparent;
    page-break-inside: avoid;
  }
  .student-rapor-table {
    font-size: 9pt;
    border-color: #000;
    width: 100% !important;
    max-width: 100% !important;
  }
  .student-rapor-table th,
  .student-rapor-table td {
    border-color: #000;
    padding: 2px 4px;
    color: #000 !important;
  }
  .student-rapor-table thead th { background: transparent; }
  .student-rapor-note { display: none; }
}
