:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-soft: #f8f9fc;
  --surface-muted: #f1f3f7;
  --surface-strong: #fafbfc;
  --surface-hover: #fbfcfe;
  --control-bg: #ffffff;
  --control-border: #dfe3eb;
  --control-border-hover: #cfd5e1;
  --ink: #172038;
  --ink-soft: #35405a;
  --ink-control: #34405b;
  --ink-table: #3b465d;
  --ink-neutral: #59647b;
  --muted: #6c758b;
  --subtle: #929aab;
  --placeholder: #a5acba;
  --icon-muted: #8b93a6;
  --table-heading: #7d8699;
  --line: #e4e8f0;
  --line-soft: #edf0f4;
  --neutral-soft: #f0f2f6;
  --progress-track: #eef0f4;
  --navy: #111a32;
  --navy-soft: #1a2542;
  --accent: #445ee9;
  --accent-dark: #3048cb;
  --accent-soft: #edf0ff;
  --success: #168963;
  --success-soft: #e8f7f1;
  --warning: #d8861a;
  --warning-soft: #fff5e5;
  --danger: #d94e5d;
  --danger-soft: #ffedef;
  --chrome-bg: rgba(244, 246, 250, 0.94);
  --mobile-nav-bg: rgba(255, 255, 255, 0.95);
  --mobile-nav-line: rgba(226, 230, 238, 0.9);
  --overlay: rgba(12, 17, 31, 0.58);
  --focus-ring: rgba(68, 94, 233, 0.11);
  --danger-ring: rgba(217, 78, 93, 0.1);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 12px 36px rgba(25, 34, 58, 0.07);
  --shadow-raised: 0 20px 50px rgba(24, 34, 55, 0.16);
  --sidebar-width: 254px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1420;
  --surface: #171e2d;
  --surface-soft: #1c2434;
  --surface-muted: #20293a;
  --surface-strong: #1b2332;
  --surface-hover: #202a3b;
  --control-bg: #141b29;
  --control-border: #344057;
  --control-border-hover: #4a5871;
  --ink: #edf1fb;
  --ink-soft: #cdd5e5;
  --ink-control: #d6ddec;
  --ink-table: #c5cede;
  --ink-neutral: #b7c0d2;
  --muted: #aab3c6;
  --subtle: #7f899e;
  --placeholder: #727d92;
  --icon-muted: #8e99af;
  --table-heading: #929db3;
  --line: #2b3548;
  --line-soft: #242e40;
  --neutral-soft: #222b3c;
  --progress-track: #252f42;
  --navy: #0a1020;
  --navy-soft: #151d30;
  --accent: #8192ff;
  --accent-dark: #6d80ef;
  --accent-soft: #232d52;
  --success: #58cda4;
  --success-soft: #15392f;
  --warning: #f1b456;
  --warning-soft: #3d2f18;
  --danger: #ff7b8b;
  --danger-soft: #42232b;
  --chrome-bg: rgba(15, 20, 32, 0.92);
  --mobile-nav-bg: rgba(23, 30, 45, 0.96);
  --mobile-nav-line: rgba(55, 67, 89, 0.92);
  --overlay: rgba(3, 6, 12, 0.72);
  --focus-ring: rgba(129, 146, 255, 0.2);
  --danger-ring: rgba(255, 123, 139, 0.18);
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
  --shadow-raised: 0 20px 55px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

::selection {
  color: #fff;
  background: var(--accent);
}

button,
input,
select,
textarea {
  min-width: 0;
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button {
  border: 0;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

#print-root {
  display: none;
}

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.icon-sm {
  width: 17px;
  height: 17px;
}

.icon-lg {
  width: 24px;
  height: 24px;
}

.muted {
  color: var(--muted);
}

.text-danger {
  color: var(--danger);
}

.text-success {
  color: var(--success);
}

.sr-only {
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

/* Login */
.login-screen {
  display: grid;
  grid-template-columns: minmax(400px, 0.92fr) minmax(500px, 1.08fr);
  min-height: 100vh;
  background: var(--surface);
}

.login-visual {
  position: relative;
  display: flex;
  min-height: 100vh;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 82% 18%, rgba(112, 132, 255, 0.26), transparent 30%),
    radial-gradient(circle at 15% 78%, rgba(38, 196, 151, 0.14), transparent 29%),
    var(--navy);
}

.login-visual::before,
.login-visual::after {
  position: absolute;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
}

.login-visual::before {
  top: -180px;
  right: -230px;
  width: 560px;
  height: 560px;
}

.login-visual::after {
  right: -90px;
  bottom: -190px;
  width: 430px;
  height: 430px;
}

.login-visual-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1;
  flex-direction: column;
  max-width: 650px;
  padding: 50px clamp(34px, 6vw, 88px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.08em;
  background: var(--accent);
  box-shadow: 0 8px 22px rgba(68, 94, 233, 0.34);
}

.brand-copy small {
  display: block;
  margin-top: 1px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.login-message {
  margin: auto 0 44px;
}

.login-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  color: #9caafc;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-kicker::before {
  width: 26px;
  height: 2px;
  content: "";
  background: currentColor;
}

.login-message h1 {
  max-width: 500px;
  margin: 0;
  font-size: clamp(36px, 4.4vw, 62px);
  font-weight: 750;
  letter-spacing: -0.055em;
  line-height: 1.02;
}

.login-message p {
  max-width: 470px;
  margin: 23px 0 0;
  color: rgba(255, 255, 255, 0.62);
  font-size: 16px;
  line-height: 1.7;
}

.login-preview {
  position: relative;
  max-width: 520px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(12px);
}

.preview-top,
.preview-row,
.preview-score {
  display: flex;
  align-items: center;
}

.preview-top {
  justify-content: space-between;
  margin-bottom: 17px;
}

.preview-label {
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #8ce0c3;
  font-size: 11px;
  font-weight: 700;
  background: rgba(28, 182, 129, 0.13);
}

.live-badge::before {
  width: 6px;
  height: 6px;
  content: "";
  border-radius: 50%;
  background: #3ed5a0;
  box-shadow: 0 0 0 4px rgba(62, 213, 160, 0.12);
}

.preview-row {
  gap: 12px;
  padding: 13px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.preview-time {
  width: 47px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
}

.preview-subject {
  min-width: 0;
  flex: 1;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.preview-subject span {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.42);
  font-size: 11px;
  font-weight: 500;
}

.preview-score {
  width: 31px;
  height: 31px;
  justify-content: center;
  border-radius: 9px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  background: var(--accent);
}

.login-legal {
  margin-top: auto;
  padding-top: 34px;
  color: rgba(255, 255, 255, 0.32);
  font-size: 11px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.login-panel {
  position: relative;
  display: grid;
  min-height: 100vh;
  padding: 48px clamp(32px, 8vw, 120px);
  place-items: center;
  background: var(--surface);
}

.login-box {
  width: 100%;
  max-width: 480px;
}

.mobile-login-brand {
  display: none;
}

.login-box h2 {
  margin: 0 0 10px;
  font-size: 32px;
  letter-spacing: -0.04em;
}

.login-lead {
  margin: 0 0 30px;
  color: var(--muted);
  line-height: 1.6;
}

.role-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-bottom: 28px;
  padding: 5px;
  border-radius: 13px;
  background: var(--surface-muted);
}

.role-tab {
  min-width: 0;
  padding: 11px 8px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
  background: transparent;
  transition: 160ms ease;
}

.role-tab:hover {
  color: var(--ink);
}

.role-tab.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 3px 10px rgba(10, 15, 28, 0.12);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field-full {
  grid-column: 1 / -1;
}

.field label,
.field-label {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.field-hint {
  color: var(--subtle);
  font-size: 11px;
  line-height: 1.45;
}

.input-wrap,
.select-wrap {
  position: relative;
}

.input-wrap > .icon,
.select-wrap > .icon {
  position: absolute;
  top: 50%;
  left: 15px;
  z-index: 1;
  color: var(--icon-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.input,
.select,
.textarea {
  width: 100%;
  outline: 0;
  border: 1px solid var(--control-border);
  border-radius: 11px;
  color: var(--ink);
  background: var(--control-bg);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.input,
.select {
  height: 48px;
  padding: 0 14px;
}

.select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 42px;
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
  background-color: var(--control-bg);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 13px) calc(50% - 2px);
  background-repeat: no-repeat;
  background-size: 5px 5px;
  cursor: pointer;
}

.select:hover {
  border-color: var(--control-border-hover);
  background-color: var(--surface-hover);
}

.select:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.select option,
.select optgroup {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
}

.custom-select {
  position: relative;
  width: 100%;
  min-width: 0;
}

.custom-select-toolbar {
  width: auto;
  min-width: 170px;
}

.custom-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
  opacity: 0 !important;
  clip-path: inset(50%) !important;
  pointer-events: none !important;
}

.custom-select-trigger {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 14px;
  border: 1px solid var(--control-border);
  border-radius: 11px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  background: var(--control-bg);
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.custom-select-trigger:hover {
  border-color: var(--control-border-hover);
  background: var(--surface-hover);
}

.custom-select-trigger:focus-visible,
.custom-select.open .custom-select-trigger {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.custom-select-trigger:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.custom-select-value {
  min-width: 0;
  flex: 1;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.custom-select-arrow {
  display: grid;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface-soft);
  transform: rotate(90deg);
  transition: color 150ms ease, transform 150ms ease, background 150ms ease;
}

.custom-select.open .custom-select-arrow {
  color: var(--accent);
  background: var(--accent-soft);
  transform: rotate(-90deg);
}

.custom-select-options {
  position: fixed;
  z-index: 300;
  display: none;
  align-content: start;
  gap: 3px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
}

.custom-select-options.open {
  display: grid;
  animation: custom-select-in 130ms ease-out;
}

@keyframes custom-select-in {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.custom-select-options.drop-up.open {
  transform-origin: bottom;
}

.custom-select-option {
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  background: transparent;
}

.custom-select-option > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.custom-select-option > .icon {
  flex: 0 0 auto;
  color: var(--accent);
  opacity: 0;
}

.custom-select-option:is(:hover, :focus-visible, .selected) {
  color: var(--accent);
  outline: 0;
  background: var(--accent-soft);
}

.custom-select-option.selected > .icon {
  opacity: 1;
}

.custom-select-option:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.custom-select-options::-webkit-scrollbar {
  width: 8px;
}

.custom-select-options::-webkit-scrollbar-thumb {
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: var(--line);
}

.input-wrap .input,
.select-wrap .select {
  padding-left: 44px;
}

.textarea {
  min-height: 100px;
  padding: 13px 14px;
  line-height: 1.5;
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--placeholder);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-ring);
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  transform: translateY(-50%);
}

.password-toggle:hover {
  background: var(--surface-soft);
}

.login-error {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
}

.login-error:empty {
  margin-top: 0;
}

.btn {
  display: inline-flex;
  max-width: 100%;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 720;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  transition: 150ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled,
.btn:disabled:hover {
  opacity: 0.48;
  transform: none;
  cursor: not-allowed;
}

.btn-primary {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 7px 18px rgba(68, 94, 233, 0.22);
}

.btn-primary:hover {
  background: var(--accent-dark);
}

.btn-secondary {
  border-color: var(--line);
  color: var(--ink-control);
  background: var(--surface);
}

.btn-secondary:hover {
  border-color: var(--control-border-hover);
  background: var(--surface-strong);
}

.btn-danger {
  color: #fff;
  background: var(--danger);
}

.btn-danger-soft {
  color: var(--danger);
  background: var(--danger-soft);
}

.btn-success-soft {
  color: var(--success);
  background: var(--success-soft);
}

.btn-block {
  width: 100%;
  min-height: 50px;
}

.login-submit {
  margin-top: 20px;
}

.preview-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  color: var(--accent);
  background: var(--accent-soft);
}

/* Application shell */
.app-shell {
  min-height: 100vh;
  background: var(--bg);
}

.app-shell.admin-shell {
  --accent: #7551dc;
  --accent-dark: #603dc5;
  --accent-soft: #f0ebff;
  --navy: #181522;
  --navy-soft: #252032;
}

html[data-theme="dark"] .app-shell.admin-shell {
  --accent: #a88af8;
  --accent-dark: #9573ee;
  --accent-soft: #302745;
  --navy: #120f1c;
  --navy-soft: #211b30;
}

.sidebar {
  position: fixed;
  z-index: 40;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  overflow-y: auto;
  padding: 28px 18px 20px;
  color: #fff;
  background: var(--navy);
}

.sidebar .brand {
  padding: 0 8px;
}

.sidebar-section-label {
  margin: 34px 12px 10px;
  color: rgba(255, 255, 255, 0.32);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
}

.nav-link {
  display: flex;
  min-height: 45px;
  align-items: center;
  gap: 12px;
  padding: 0 13px;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 13px;
  font-weight: 650;
  background: transparent;
  transition: 150ms ease;
}

.nav-link > span:not(.nav-count) {
  min-width: 0;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.nav-link:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 8px 24px rgba(30, 40, 100, 0.22);
}

.nav-count {
  min-width: 21px;
  margin-left: auto;
  padding: 2px 6px;
  border-radius: 999px;
  color: inherit;
  font-size: 10px;
  text-align: center;
  background: rgba(255, 255, 255, 0.13);
}

.sidebar-spacer {
  flex: 1;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 14px 6px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.47);
  font-size: 10px;
  line-height: 1.35;
  background: rgba(255, 255, 255, 0.03);
}

.sync-status > span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.sync-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #38cf9a;
  box-shadow: 0 0 0 4px rgba(56, 207, 154, 0.1);
}

.sidebar-profile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 13px 8px 3px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.avatar {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border-radius: 11px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: #7080d7;
}

.avatar.sm {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  font-size: 10px;
}

.avatar.lg {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  font-size: 17px;
}

.avatar.green { background: #36a07e; }
.avatar.orange { background: #d78b42; }
.avatar.purple { background: #8766c7; }
.avatar.blue { background: #5075c6; }
.avatar.red { background: #c96570; }

.profile-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
  overflow: hidden;
}

.profile-name {
  display: block;
  overflow: hidden;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-role {
  display: block;
  margin: 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.36);
  font-size: 9px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  display: inline-flex;
  width: 100%;
  min-height: 36px;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 2px;
  padding: 0 10px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.06);
}

.logout-btn span {
  font-size: 10px;
  font-weight: 700;
}

.logout-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

.app-main {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  height: 78px;
  align-items: center;
  gap: 20px;
  padding: 0 clamp(24px, 3.4vw, 52px);
  border-bottom: 1px solid var(--line);
  background: var(--chrome-bg);
  backdrop-filter: blur(12px);
}

.topbar-heading {
  min-width: 0;
  flex: 1;
}

.topbar-heading h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.025em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.topbar-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.icon-btn {
  position: relative;
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink-neutral);
  background: var(--surface);
  transition: 150ms ease;
}

.icon-btn:hover {
  border-color: var(--control-border-hover);
  color: var(--accent);
}

.notification-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--danger);
}

.topbar-date {
  padding-right: 15px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.topbar-date strong {
  display: block;
  margin-bottom: 3px;
  color: var(--ink-soft);
  font-size: 12px;
}

.page-content {
  width: 100%;
  max-width: 1540px;
  margin: 0 auto;
  padding: 30px clamp(24px, 3.4vw, 52px) 50px;
}

.mobile-header,
.bottom-nav,
.drawer-overlay {
  display: none;
}

/* Common content */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.page-title {
  min-width: 0;
}

.page-title h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.04em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.page-title p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
  max-width: 100%;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 2px 4px rgba(18, 27, 48, 0.015);
}

.card-pad {
  padding: 22px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 19px;
}

.card-header > div {
  min-width: 0;
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 760;
  letter-spacing: -0.02em;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.card-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.card-link {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  padding: 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  background: transparent;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  padding: 20px;
}

.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stat-label {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.stat-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  color: var(--accent);
  background: var(--accent-soft);
}

.stat-icon.green { color: var(--success); background: var(--success-soft); }
.stat-icon.orange { color: var(--warning); background: var(--warning-soft); }
.stat-icon.red { color: var(--danger); background: var(--danger-soft); }

.stat-value {
  margin-top: 14px;
  font-size: 27px;
  font-weight: 790;
  letter-spacing: -0.045em;
  overflow-wrap: anywhere;
}

.stat-note {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 17px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.trend {
  color: var(--success);
  font-weight: 750;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.85fr);
  gap: 20px;
}

.content-grid.equal {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stack {
  display: grid;
  align-content: start;
  gap: 20px;
}

.welcome-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 34px;
  min-height: 186px;
  overflow: hidden;
  padding: 27px 29px;
  color: #fff;
  background: var(--navy);
}

.welcome-card::before {
  position: absolute;
  top: -90px;
  right: -55px;
  width: 270px;
  height: 270px;
  content: "";
  border: 34px solid rgba(255, 255, 255, 0.035);
  border-radius: 50%;
}

.welcome-card::after {
  position: absolute;
  right: 150px;
  bottom: -90px;
  width: 180px;
  height: 180px;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 50%;
}

.welcome-content {
  position: relative;
  z-index: 1;
  min-width: 0;
  max-width: none;
}

.welcome-eyebrow {
  color: rgba(255, 255, 255, 0.52);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.welcome-card h2 {
  margin: 10px 0 9px;
  font-size: 25px;
  letter-spacing: -0.04em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.welcome-card p {
  margin: 0;
  color: rgba(255, 255, 255, 0.59);
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.welcome-next {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding: 8px 12px;
  border-radius: 9px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
}

.welcome-score {
  position: relative;
  z-index: 2;
  display: grid;
  width: 108px;
  height: 108px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
}

.welcome-score > div {
  display: grid;
  place-items: center;
  gap: 7px;
  padding: 12px;
  text-align: center;
}

.welcome-score strong {
  display: block;
  font-size: 29px;
  letter-spacing: -0.05em;
  line-height: 1;
}

.welcome-score span {
  display: block;
  margin: 0;
  color: rgba(255, 255, 255, 0.46);
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
}

.list {
  display: grid;
}

.list-item {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.list-item:first-child {
  padding-top: 0;
  border-top: 0;
}

.list-item:last-child {
  padding-bottom: 0;
}

.list-icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  color: var(--accent);
  background: var(--accent-soft);
}

.list-copy {
  min-width: 0;
  flex: 1;
}

.list-title {
  display: block;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.list-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.list-item > .grade-badge {
  margin-top: 2px;
}

.grade-badge {
  display: inline-grid;
  width: 33px;
  height: 33px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 9px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  background: var(--accent);
}

.grade-badge.g5 { background: #19986b; }
.grade-badge.g4 { background: #4a6de0; }
.grade-badge.g3 { background: #e19a2c; }
.grade-badge.g2 { background: #d95461; }
.grade-badge.clickable { cursor: pointer; transition: transform 140ms ease; }
.grade-badge.clickable:hover { transform: translateY(-2px); }

.subject-progress {
  display: grid;
  gap: 16px;
}

.progress-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  font-size: 12px;
  line-height: 1.4;
}

.progress-row-head span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.progress-row-head strong {
  font-size: 12px;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--progress-track);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.homework-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 13px;
  align-items: start;
  padding: 15px 0;
  border-top: 1px solid var(--line);
}

.homework-item:first-child {
  padding-top: 0;
  border-top: 0;
}

.deadline-box {
  display: grid;
  width: 43px;
  height: 46px;
  place-items: center;
  border-radius: 10px;
  color: var(--warning);
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  background: var(--warning-soft);
}

.deadline-box span {
  margin-top: -11px;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
}

.homework-copy h4 {
  margin: 1px 0 5px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.homework-copy p {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}

.status-badge,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 750;
  max-width: 100%;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
}

.status-badge {
  padding: 5px 8px;
  color: var(--muted);
  background: var(--neutral-soft);
}

.status-badge.success { color: var(--success); background: var(--success-soft); }
.status-badge.warning { color: var(--warning); background: var(--warning-soft); }
.status-badge.danger { color: var(--danger); background: var(--danger-soft); }
.status-badge.accent { color: var(--accent); background: var(--accent-soft); }

.tag {
  padding: 5px 9px;
  color: var(--ink-neutral);
  background: var(--neutral-soft);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}

.segment {
  min-height: 33px;
  padding: 0 13px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: normal;
  background: transparent;
}

.segment.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 17px;
}

.toolbar .search-box {
  min-width: 220px;
  flex: 1;
}

.search-box {
  position: relative;
}

.search-box .icon {
  position: absolute;
  top: 50%;
  left: 13px;
  color: var(--subtle);
  transform: translateY(-50%);
}

.search-box .input {
  padding-left: 41px;
}

.toolbar-select {
  width: auto;
  min-width: 150px;
}

/* Tables */
.table-card {
  overflow: hidden;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

.data-table th {
  padding: 12px 17px;
  border-bottom: 1px solid var(--line);
  color: var(--table-heading);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-align: left;
  text-transform: uppercase;
  background: var(--surface-strong);
}

.data-table td {
  padding: 14px 17px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-table);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: var(--surface-hover);
}

.table-person {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.table-person > span:last-child {
  min-width: 0;
}

.table-person strong {
  display: block;
  max-width: 230px;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}

.table-person span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.table-action {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
}

.table-action:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.table-action.danger:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  flex-wrap: wrap;
  padding: 13px 17px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  background: var(--surface-strong);
}

.grade-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.grade-list .grade-badge {
  width: 27px;
  height: 27px;
  border-radius: 7px;
  font-size: 11px;
}

.average {
  font-size: 13px;
  font-weight: 800;
}

.average.high { color: var(--success); }
.average.mid { color: var(--accent); }
.average.low { color: var(--warning); }

.empty-state {
  display: grid;
  min-height: 250px;
  padding: 35px;
  place-items: center;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  place-items: center;
  border-radius: 16px;
  color: var(--accent);
  background: var(--accent-soft);
}

.empty-state h3 {
  margin: 0 0 7px;
  font-size: 15px;
}

.empty-state p {
  max-width: 320px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

/* Grades and homework */
.grade-summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.5fr);
  gap: 20px;
  margin-bottom: 20px;
}

.distribution {
  display: grid;
  gap: 11px;
}

.distribution-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 25px;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 10px;
}

.distribution-row strong {
  color: var(--ink);
  font-size: 11px;
}

.subject-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.subject-card {
  padding: 18px;
}

.subject-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.subject-card-head > div {
  min-width: 0;
}

.subject-card h3 {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.subject-teacher {
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
}

.subject-average {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.subject-card .grade-list {
  margin-top: 15px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.homework-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}

.homework-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 19px;
}

.homework-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.homework-badges,
.homework-card-controls {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.subject-pill {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.subject-pill::before {
  width: 7px;
  height: 7px;
  content: "";
  border-radius: 50%;
  flex: 0 0 auto;
  background: currentColor;
}

.homework-card h3 {
  margin: 15px 0 8px;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.homework-card-description {
  display: block;
  overflow: visible;
  min-height: 0;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.homework-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: auto;
  padding-top: 17px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.meta-with-icon {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
  overflow-wrap: anywhere;
}

.homework-updated {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.45;
  overflow-wrap: anywhere;
  background: var(--accent-soft);
}

/* Journal and admin */
.journal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 15px;
  padding: 17px;
  border-bottom: 1px solid var(--line);
}

.journal-context {
  display: grid;
  grid-template-columns: minmax(180px, 0.55fr) minmax(360px, 1.45fr);
  width: min(100%, 800px);
  min-width: 0;
  align-items: end;
  gap: 12px;
}

.journal-context .select {
  width: 100%;
  min-width: 0;
}

.journal-filter {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.journal-filter > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.05em;
  line-height: 1.3;
  text-transform: uppercase;
}

.admin-grade-list {
  display: flex;
  min-width: 260px;
  max-width: 720px;
  flex-wrap: wrap;
  gap: 6px;
}

.admin-grade-item {
  display: inline-flex;
  max-width: 250px;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 4px 5px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink-table);
  font-size: 10px;
  line-height: 1.3;
  text-align: left;
  background: var(--surface-soft);
}

.admin-grade-item:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.admin-grade-item > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-grade-item > strong {
  display: grid;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  color: #fff;
  font-size: 11px;
}

.admin-grade-item > strong.g5 { background: #19986b; }
.admin-grade-item > strong.g4 { background: #4a6de0; }
.admin-grade-item > strong.g3 { background: #e19a2c; }
.admin-grade-item > strong.g2 { background: #d95461; }

.student-cell {
  position: sticky;
  z-index: 2;
  left: 0;
  min-width: 230px;
  background: var(--surface);
}

th.student-cell {
  z-index: 3;
  background: var(--surface-strong);
}

.data-table tbody tr:hover .student-cell {
  background: var(--surface-hover);
}

.quick-add-grade {
  display: inline-grid;
  width: 27px;
  height: 27px;
  margin-left: 4px;
  place-items: center;
  border: 1px dashed var(--control-border-hover);
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
}

.quick-add-grade:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.admin-hero {
  display: flex;
  min-height: 130px;
  align-items: center;
  justify-content: space-between;
  gap: 25px;
  margin-bottom: 20px;
  padding: 25px 28px;
  color: #fff;
  background: var(--navy);
}

.admin-hero > div {
  min-width: 0;
}

.admin-hero h2 {
  margin: 0 0 8px;
  font-size: 21px;
  letter-spacing: -0.035em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.admin-hero p {
  max-width: 590px;
  margin: 0;
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.admin-hero .btn {
  border-color: rgba(255, 255, 255, 0.1);
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
}

.chart-area {
  display: flex;
  height: 180px;
  align-items: flex-end;
  gap: 12px;
  padding-top: 15px;
}

.chart-column {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.chart-bar {
  width: min(35px, 75%);
  min-height: 6px;
  border-radius: 7px 7px 3px 3px;
  background: var(--accent);
  opacity: 0.82;
}

.chart-column:nth-child(even) .chart-bar {
  opacity: 0.48;
}

.chart-label {
  color: var(--muted);
  font-size: 8px;
}

.activity-list {
  display: grid;
}

.activity-item {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: start;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.activity-item:first-child {
  padding-top: 0;
  border-top: 0;
}

.activity-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  color: var(--accent);
  background: var(--accent-soft);
}

.activity-copy strong {
  display: block;
  font-size: 10px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.activity-copy span,
.activity-time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;
}

.group-card {
  padding: 19px;
}

.group-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.group-card-head > div {
  min-width: 0;
}

.group-code {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.03em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.group-course {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.group-card-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
  margin-top: 18px;
}

.group-mini-stat {
  padding: 11px;
  border-radius: 10px;
  background: var(--surface-soft);
}

.group-mini-stat strong {
  display: block;
  font-size: 16px;
}

.group-mini-stat span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.group-curator {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 15px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.group-curator > span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.check-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink-control);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.check-option input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 23px;
}

.profile-card > div {
  min-width: 0;
}

.profile-card h2 {
  margin: 0 0 5px;
  font-size: 18px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.profile-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 30px;
}

.detail-row {
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.detail-row span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.detail-row strong {
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* Notifications, modal, toast */
.notification-panel {
  position: absolute;
  z-index: 60;
  top: 65px;
  right: clamp(24px, 3.4vw, 52px);
  width: min(370px, calc(100vw - 32px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
  animation: panel-in 150ms ease-out;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.notification-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 17px;
  border-bottom: 1px solid var(--line);
}

.notification-head strong {
  font-size: 13px;
}

.notification-list {
  max-height: 360px;
  overflow-y: auto;
}

.notification-item {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  gap: 10px;
  padding: 14px 17px;
  border-bottom: 1px solid var(--line);
}

.notification-item:last-child {
  border-bottom: 0;
}

.notification-marker {
  width: 7px;
  height: 7px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.notification-item strong {
  display: block;
  font-size: 10px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.notification-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  padding: 20px;
  place-items: center;
  overflow-y: auto;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  animation: fade-in 150ms ease;
}

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

.modal {
  width: min(570px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border-radius: 19px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(10, 18, 35, 0.24);
  animation: modal-in 180ms ease-out;
}

.modal.modal-lg {
  width: min(760px, 100%);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
  padding: 21px 23px 17px;
  border-bottom: 1px solid var(--line);
}

.modal-head > div {
  min-width: 0;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.03em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.modal-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.modal-close {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  color: var(--muted);
  background: var(--surface-soft);
}

.modal-close:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.modal-body {
  padding: 21px 23px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
  padding: 16px 23px 21px;
  border-top: 1px solid var(--line);
}

.import-guide p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.import-guide code {
  display: block;
  max-width: 100%;
  margin-bottom: 16px;
  padding: 11px 12px;
  overflow-x: auto;
  border-radius: 9px;
  color: var(--accent);
  font-size: 10px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--accent-soft);
}

.import-errors {
  display: grid;
  gap: 7px;
  margin-top: 15px;
}

.import-errors > div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--danger);
  font-size: 10px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  background: var(--danger-soft);
}

.grade-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.grade-option {
  position: relative;
}

.grade-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.grade-option span {
  display: grid;
  height: 46px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.grade-option input:checked + span {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px rgba(68, 94, 233, 0.08);
}

.confirm-content {
  text-align: center;
}

.confirm-icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 2px auto 15px;
  place-items: center;
  border-radius: 17px;
  color: var(--danger);
  background: var(--danger-soft);
}

.confirm-content h3 {
  margin: 0 0 7px;
  font-size: 17px;
  overflow-wrap: anywhere;
}

.confirm-content p {
  max-width: 390px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.toast-root {
  position: fixed;
  z-index: 150;
  right: 22px;
  bottom: 22px;
  display: grid;
  width: min(350px, calc(100vw - 32px));
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink-control);
  font-size: 11px;
  font-weight: 650;
  background: var(--surface);
  box-shadow: 0 15px 40px rgba(19, 28, 48, 0.14);
  animation: toast-in 200ms ease-out;
}

.toast > span:last-child {
  min-width: 0;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.toast-icon {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  color: var(--success);
  background: var(--success-soft);
}

.toast.error .toast-icon {
  color: var(--danger);
  background: var(--danger-soft);
}

.toast.sync .toast-icon {
  color: var(--accent);
  background: var(--accent-soft);
}

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

/* Theme controls */
.theme-toggle.login-theme-toggle {
  position: absolute;
  z-index: 2;
  top: 22px;
  right: 22px;
}

.theme-toggle,
.theme-toggle-btn,
button[data-action="toggle-theme"]:not(.btn) {
  position: relative;
  display: inline-grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink-neutral);
  background: var(--surface);
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.theme-toggle:hover,
.theme-toggle-btn:hover,
button[data-action="toggle-theme"]:not(.btn):hover {
  border-color: var(--control-border-hover);
  color: var(--accent);
  background: var(--surface-hover);
}

.theme-toggle .icon,
.theme-toggle-btn .icon {
  transition: transform 180ms ease, opacity 180ms ease;
}

.theme-toggle:hover .icon,
.theme-toggle-btn:hover .icon {
  transform: rotate(12deg);
}

html[data-theme="light"] :is(.theme-toggle, .theme-toggle-btn, [data-action="toggle-theme"]) :is(.theme-icon-sun, .theme-sun, [data-theme-icon="sun"]),
html[data-theme="dark"] :is(.theme-toggle, .theme-toggle-btn, [data-action="toggle-theme"]) :is(.theme-icon-moon, .theme-moon, [data-theme-icon="moon"]) {
  display: none;
}

.theme-options {
  display: inline-flex;
  max-width: 100%;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.theme-option {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  background: transparent;
}

.theme-option:is(.active, [aria-pressed="true"]) {
  color: var(--accent);
  background: var(--surface);
  box-shadow: 0 3px 10px rgba(10, 15, 28, 0.12);
}

/* Announcements */
.announcements-layout,
.announcement-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.65fr);
  align-items: start;
  gap: 20px;
}

.announcements-feed,
.announcement-feed,
.announcement-list {
  display: grid;
  align-content: start;
  gap: 14px;
}

.announcement-card,
.announcement-item {
  position: relative;
  min-width: 0;
  padding: 20px 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 2px 4px rgba(18, 27, 48, 0.02);
}

.announcement-card:is(.pinned, .is-pinned),
.announcement-item:is(.pinned, .is-pinned) {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent-soft), var(--surface) 48%);
}

.announcement-card:is(.pinned, .is-pinned)::before,
.announcement-item:is(.pinned, .is-pinned)::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 4px;
  content: "";
  background: var(--accent);
}

.announcement-header,
.announcement-head,
.announcement-footer,
.announcement-meta,
.announcement-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.announcement-header,
.announcement-head {
  justify-content: space-between;
  margin-bottom: 12px;
}

.announcement-author {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.announcement-author-copy {
  min-width: 0;
}

.announcement-author strong,
.announcement-author-copy strong {
  display: block;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.announcement-author small,
.announcement-date,
.announcement-meta {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.announcement-kicker,
.announcement-audience,
.announcement-target {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 750;
  line-height: 1.25;
  overflow-wrap: anywhere;
  background: var(--accent-soft);
}

.announcement-title {
  margin: 0 0 8px;
  font-size: 16px;
  letter-spacing: -0.02em;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.announcement-body,
.announcement-text {
  margin: 0;
  color: var(--ink-table);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.announcement-footer {
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.announcement-actions {
  justify-content: flex-end;
  margin-left: auto;
}

.announcement-action {
  display: inline-flex;
  min-height: 31px;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  background: transparent;
}

.announcement-action:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.announcement-form,
.announcement-composer {
  display: grid;
  gap: 17px;
  padding: 21px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.announcement-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.announcement-form-actions,
.announcement-filter-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
}

.announcement-pin {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink-control);
  font-size: 11px;
  line-height: 1.45;
  background: var(--surface-soft);
  cursor: pointer;
}

.announcement-pin input {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin-top: 1px;
  accent-color: var(--accent);
}

/* CSV import */
.csv-import,
.csv-import-flow {
  display: grid;
  gap: 18px;
}

.csv-dropzone,
.csv-drop-zone {
  display: grid;
  min-height: 138px;
  padding: 24px;
  place-items: center;
  border: 1px dashed var(--control-border-hover);
  border-radius: 13px;
  color: var(--muted);
  text-align: center;
  background: var(--surface-soft);
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.csv-dropzone:is(:hover, .is-dragging),
.csv-drop-zone:is(:hover, .is-dragging) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.csv-dropzone strong,
.csv-drop-zone strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 12px;
}

.csv-dropzone small,
.csv-drop-zone small,
.csv-file-meta {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.csv-file,
.csv-file-info {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
}

.csv-file-name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.csv-steps,
.import-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.csv-step,
.import-step {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
  background: var(--surface-soft);
}

.csv-step::before,
.import-step::before {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  content: attr(data-step);
  font-size: 9px;
  background: var(--surface);
}

.csv-step:is(.active, .is-active),
.import-step:is(.active, .is-active) {
  color: var(--accent);
  background: var(--accent-soft);
}

.csv-step:is(.complete, .is-complete)::before,
.import-step:is(.complete, .is-complete)::before {
  border-color: var(--success);
  color: var(--success);
  content: "\2713";
}

.csv-mapping,
.csv-mapping-grid,
.column-mapping {
  display: grid;
  gap: 9px;
}

.csv-mapping-row,
.column-mapping-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
}

.csv-source-column,
.csv-target-column,
.mapping-column {
  min-width: 0;
}

.csv-source-column strong,
.csv-target-column strong,
.mapping-column strong {
  display: block;
  overflow: hidden;
  font-size: 10px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.csv-source-column small,
.csv-target-column small,
.mapping-column small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
}

.csv-mapping-arrow,
.mapping-arrow {
  color: var(--subtle);
  text-align: center;
}

.csv-preview,
.csv-preview-wrap,
.import-preview {
  width: 100%;
  max-height: 330px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.csv-preview-table,
.import-preview-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--ink-table);
  font-size: 10px;
  white-space: nowrap;
}

.csv-preview-table th,
.import-preview-table th {
  position: sticky;
  z-index: 2;
  top: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--table-heading);
  font-size: 8px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
  background: var(--surface-strong);
}

.csv-preview-table td,
.import-preview-table td {
  max-width: 260px;
  padding: 10px 12px;
  overflow: hidden;
  border-bottom: 1px solid var(--line-soft);
  text-overflow: ellipsis;
}

.csv-preview-table tr:last-child td,
.import-preview-table tr:last-child td {
  border-bottom: 0;
}

.csv-preview-table .invalid,
.csv-preview-table .is-invalid,
.csv-cell-error {
  color: var(--danger);
  background: var(--danger-soft);
}

.csv-summary,
.import-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.csv-summary-item,
.csv-summary-card,
.import-summary-item {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
}

.csv-summary-item strong,
.csv-summary-card strong,
.import-summary-item strong {
  display: block;
  font-size: 20px;
  letter-spacing: -0.035em;
}

.csv-summary-item span,
.csv-summary-card span,
.import-summary-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.csv-summary-item.success,
.csv-summary-card.success {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-soft);
}

.csv-summary-item.error,
.csv-summary-card.error {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

.csv-error-controls,
.csv-error-toolbar,
.import-error-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.csv-errors,
.csv-error-list,
.import-error-list {
  display: grid;
  max-height: 230px;
  gap: 7px;
  margin-top: 10px;
  overflow-y: auto;
}

.csv-error-item,
.csv-error-row,
.import-error-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 9px;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--danger);
  font-size: 10px;
  line-height: 1.45;
  background: var(--danger-soft);
}

.csv-error-row-number,
.csv-error-code {
  font-weight: 800;
  white-space: nowrap;
}

/* Analytics */
.analytics-toolbar,
.analytics-filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 17px;
}

.analytics-grid,
.monthly-analytics-grid,
.group-analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.analytics-card,
.monthly-analytics,
.group-analytics {
  min-width: 0;
  padding: 21px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.analytics-card-wide,
.analytics-wide {
  grid-column: 1 / -1;
}

.analytics-heading {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 13px;
  margin-bottom: 18px;
}

.analytics-heading h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.analytics-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.analytics-kpis,
.analytics-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 18px;
}

.analytics-kpi,
.analytics-metric {
  min-width: 0;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-soft);
}

.analytics-kpi strong,
.analytics-metric strong {
  display: block;
  font-size: 18px;
  letter-spacing: -0.035em;
}

.analytics-kpi span,
.analytics-metric span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.35;
}

.monthly-chart,
.monthly-bars,
.analytics-bars {
  display: flex;
  height: 220px;
  align-items: stretch;
  gap: clamp(7px, 1.4vw, 15px);
  padding: 16px 8px 0;
  border-bottom: 1px solid var(--line);
  background-image: linear-gradient(to bottom, var(--line-soft) 1px, transparent 1px);
  background-size: 100% 25%;
}

.month-column,
.monthly-bar,
.analytics-bar-column {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.month-bar-track,
.analytics-bar-track {
  display: flex;
  width: min(38px, 76%);
  height: 100%;
  align-items: flex-end;
  overflow: hidden;
  border-radius: 8px 8px 3px 3px;
  background: var(--surface-soft);
}

.month-bar-fill,
.analytics-bar-fill {
  width: 100%;
  min-height: 3px;
  height: var(--value, 0%);
  border-radius: inherit;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
}

.month-label,
.analytics-bar-label {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.month-column > strong {
  color: var(--ink);
  font-size: 9px;
}

.analytics-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 13px;
  margin-top: 15px;
  color: var(--muted);
  font-size: 9px;
}

.analytics-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.analytics-legend-item::before {
  width: 8px;
  height: 8px;
  content: "";
  border-radius: 3px;
  background: var(--legend-color, var(--accent));
}

.group-comparison,
.group-ranking {
  display: grid;
  gap: 10px;
}

.group-comparison-row,
.group-rank-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.6fr) minmax(120px, 1.4fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  color: var(--ink-table);
  font-size: 10px;
}

.group-comparison-row:first-child,
.group-rank-row:first-child {
  padding-top: 0;
  border-top: 0;
}

.group-comparison-row strong,
.group-rank-row strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-comparison-value,
.group-rank-value {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.analytics-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.analytics-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--ink-table);
  font-size: 10px;
  white-space: nowrap;
}

.analytics-table th,
.analytics-table td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}

.analytics-table th {
  color: var(--table-heading);
  font-size: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--surface-strong);
}

.analytics-table tr:last-child td {
  border-bottom: 0;
}

/* Printable statements */
.print-statement,
.statement,
.individual-statement,
.group-statement {
  width: 100%;
  min-height: 100%;
  padding: 12mm;
  color: #111827;
  font-family: Arial, sans-serif;
  font-size: 10pt;
  line-height: 1.4;
  background: #fff;
}

.statement-header,
.print-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12mm;
  margin-bottom: 8mm;
  padding-bottom: 5mm;
  border-bottom: 1.5px solid #111827;
}

.statement-institution,
.print-institution {
  max-width: 70%;
}

.statement-institution strong,
.print-institution strong {
  display: block;
  font-size: 13pt;
  line-height: 1.25;
}

.statement-institution span,
.print-institution span,
.statement-document-meta {
  display: block;
  margin-top: 2mm;
  color: #4b5563;
  font-size: 8.5pt;
}

.statement-title,
.print-title {
  margin: 0 0 6mm;
  font-size: 16pt;
  letter-spacing: -0.02em;
  line-height: 1.25;
  text-align: center;
}

.statement-subtitle,
.print-subtitle {
  margin: -4mm 0 6mm;
  color: #4b5563;
  font-size: 9pt;
  text-align: center;
}

.statement-meta,
.statement-meta-grid,
.print-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2.5mm 8mm;
  margin-bottom: 6mm;
  padding: 4mm;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
}

.statement-meta-item {
  display: grid;
  grid-template-columns: minmax(28mm, auto) 1fr;
  gap: 3mm;
}

.statement-meta-item span {
  color: #64748b;
}

.statement-table,
.print-table {
  width: 100%;
  margin: 0 0 7mm;
  border-collapse: collapse;
  color: #111827;
  font-size: 8.5pt;
}

.statement-table th,
.statement-table td,
.print-table th,
.print-table td {
  padding: 2.2mm 2.5mm;
  border: 1px solid #94a3b8;
  vertical-align: top;
  text-align: left;
}

.statement-table th,
.print-table th {
  font-size: 7.5pt;
  font-weight: 700;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  background: #e8edf4;
}

.statement-table .number,
.statement-table .grade,
.statement-table .average,
.print-table .number,
.print-table .grade,
.print-table .average {
  text-align: center;
}

.statement-summary,
.print-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3mm;
  margin-bottom: 8mm;
}

.statement-summary-item {
  padding: 3mm;
  border: 1px solid #cbd5e1;
  text-align: center;
  background: #f8fafc;
}

.statement-summary-item strong {
  display: block;
  font-size: 13pt;
}

.statement-summary-item span {
  display: block;
  margin-top: 1mm;
  color: #64748b;
  font-size: 7.5pt;
}

.statement-signatures,
.print-signatures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12mm;
  margin-top: 12mm;
}

.statement-signature {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: end;
  gap: 3mm;
  font-size: 8.5pt;
}

.statement-signature-line {
  min-height: 6mm;
  border-bottom: 1px solid #111827;
}

.statement-footer,
.print-footer {
  display: flex;
  justify-content: space-between;
  gap: 8mm;
  margin-top: 8mm;
  padding-top: 3mm;
  border-top: 1px solid #cbd5e1;
  color: #64748b;
  font-size: 7.5pt;
}

/* Responsive */
@media (max-width: 1180px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .group-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.75fr);
  }
}

@media (max-width: 1023px) {
  :root {
    --sidebar-width: 0px;
  }

  .sidebar {
    width: 270px;
    transform: translateX(-100%);
    transition: transform 220ms ease;
  }

  .app-shell.drawer-open .sidebar {
    transform: translateX(0);
  }

  .drawer-overlay {
    position: fixed;
    z-index: 35;
    inset: 0;
    background: rgba(10, 16, 29, 0.48);
  }

  .app-shell.drawer-open .drawer-overlay {
    display: block;
  }

  .topbar {
    display: none;
  }

  .mobile-header {
    position: sticky;
    z-index: 25;
    top: 0;
    display: flex;
    height: 66px;
    align-items: center;
    gap: 12px;
    padding: 0 18px;
    border-bottom: 1px solid var(--line);
    background: var(--chrome-bg);
    backdrop-filter: blur(12px);
  }

  .mobile-header .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 15px;
  }

  .mobile-title {
    min-width: 0;
    flex: 1;
  }

  .mobile-title strong {
    display: block;
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-title span {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 9px;
  }

  .mobile-menu-btn {
    display: grid;
    width: 37px;
    height: 37px;
    place-items: center;
    border-radius: 10px;
    color: var(--ink);
    background: var(--surface);
  }

  .app-main {
    margin-left: 0;
  }

  .page-content {
    padding: 22px 18px 94px;
  }

  .bottom-nav {
    position: fixed;
    z-index: 30;
    right: 12px;
    bottom: 10px;
    left: 12px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    min-height: 65px;
    padding: 7px;
    border: 1px solid var(--mobile-nav-line);
    border-radius: 18px;
    background: var(--mobile-nav-bg);
    box-shadow: 0 12px 35px rgba(22, 31, 51, 0.13);
    backdrop-filter: blur(14px);
  }

  .bottom-link {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 12px;
    color: var(--subtle);
    font-size: 8px;
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
    background: transparent;
  }

  .bottom-link span {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow-wrap: anywhere;
  }

  .bottom-link.active {
    color: var(--accent);
    background: var(--accent-soft);
  }

  .notification-panel {
    position: fixed;
    top: 58px;
    right: 12px;
  }
}

@media (max-width: 860px) {
  .login-screen {
    grid-template-columns: 1fr;
  }

  .login-visual {
    display: none;
  }

  .login-panel {
    min-height: 100vh;
    padding: 35px 22px;
  }

  .mobile-login-brand {
    display: inline-flex;
    margin-bottom: 46px;
    color: var(--ink);
  }

  .mobile-login-brand .brand-copy small {
    color: var(--muted);
  }

  .content-grid,
  .content-grid.equal,
  .grade-summary-grid,
  .announcements-layout,
  .announcement-layout,
  .analytics-grid,
  .monthly-analytics-grid,
  .group-analytics-grid {
    grid-template-columns: 1fr;
  }

  .analytics-card-wide,
  .analytics-wide {
    grid-column: auto;
  }

  .welcome-content {
    max-width: none;
  }
}

@media (max-width: 680px) {
  .page-header {
    align-items: stretch;
    flex-direction: column;
    margin-bottom: 18px;
  }

  .page-title h2 {
    font-size: 22px;
  }

  .page-actions {
    width: 100%;
    justify-content: stretch;
    overflow: visible;
  }

  .page-actions > .btn {
    min-width: min(150px, 100%);
    flex: 1 1 150px;
  }

  .stats-grid,
  .subject-cards,
  .homework-grid,
  .group-grid,
  .details-grid,
  .announcement-form-grid,
  .csv-summary,
  .import-summary,
  .analytics-kpis,
  .analytics-summary {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    gap: 10px;
  }

  .stat-card {
    padding: 16px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar .search-box,
  .toolbar-select,
  .custom-select-toolbar {
    width: 100%;
    min-width: 0;
  }

  .announcement-card,
  .announcement-item,
  .announcement-form,
  .announcement-composer,
  .analytics-card,
  .monthly-analytics,
  .group-analytics {
    padding: 17px;
  }

  .announcement-footer,
  .announcement-form-actions,
  .announcement-filter-bar,
  .csv-error-controls,
  .csv-error-toolbar,
  .import-error-controls,
  .analytics-toolbar,
  .analytics-filters {
    align-items: stretch;
    flex-direction: column;
  }

  .announcement-actions {
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
  }

  .csv-mapping-row,
  .column-mapping-row {
    grid-template-columns: 1fr;
  }

  .csv-mapping-arrow,
  .mapping-arrow {
    transform: rotate(90deg);
  }

  .monthly-chart,
  .monthly-bars,
  .analytics-bars {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .month-column,
  .monthly-bar,
  .analytics-bar-column {
    flex: 0 0 28px;
  }

  .group-comparison-row,
  .group-rank-row {
    grid-template-columns: minmax(80px, 0.8fr) minmax(90px, 1.2fr) auto;
    gap: 8px;
  }

  .welcome-card {
    grid-template-columns: 1fr;
    gap: 20px;
    min-height: 0;
    padding: 23px;
  }

  .welcome-content {
    max-width: 100%;
  }

  .welcome-score {
    right: auto;
    bottom: auto;
    width: auto;
    height: auto;
    justify-self: start;
    padding: 10px 14px;
    border-radius: 14px;
  }

  .welcome-score > div {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 0;
    text-align: left;
  }

  .welcome-score strong {
    font-size: 24px;
  }

  .welcome-score span {
    margin: 0;
    font-size: 10px;
    text-align: left;
  }

  .welcome-next {
    max-width: 100%;
  }

  .card-pad {
    padding: 18px;
  }

  .journal-head {
    align-items: stretch;
    flex-direction: column;
  }

  .journal-context {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .journal-context .select {
    width: 100%;
    min-width: 0;
    flex: 1 1 180px;
  }

  .admin-hero {
    align-items: flex-start;
    flex-direction: column;
    padding: 22px;
  }

  .form-grid,
  .permission-grid {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
  }

  .modal-head,
  .modal-body {
    padding-right: 18px;
    padding-left: 18px;
  }

  .modal-actions {
    padding-right: 18px;
    padding-left: 18px;
  }

  .modal-actions .btn {
    min-width: min(120px, 100%);
    flex: 1 1 120px;
  }

  .homework-card-controls,
  .homework-badges {
    width: 100%;
    justify-content: flex-start;
  }

  .homework-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .homework-item > .status-badge {
    grid-column: 2;
    justify-self: start;
  }

  .toast-root {
    right: 16px;
    bottom: 88px;
  }
}

@media (max-width: 420px) {
  .role-tab {
    padding-right: 4px;
    padding-left: 4px;
    font-size: 10px;
  }

  .login-box h2 {
    font-size: 27px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .csv-steps,
  .import-steps {
    grid-template-columns: 1fr;
  }

  .stat-value {
    font-size: 23px;
  }

  .stat-note {
    min-height: 29px;
  }

  .segmented {
    width: 100%;
  }

  .segment {
    min-width: 0;
    flex: 1;
    padding-right: 6px;
    padding-left: 6px;
    font-size: 9px;
  }

  .bottom-nav {
    right: 7px;
    bottom: 7px;
    left: 7px;
  }

  .bottom-link {
    font-size: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@page {
  size: A4 portrait;
  margin: 12mm;
}

@page elzhur-portrait {
  size: A4 portrait;
  margin: 12mm;
}

@page elzhur-landscape {
  size: A4 landscape;
  margin: 10mm;
}

@media print {
  html,
  body {
    min-width: 0;
    min-height: 0;
    margin: 0;
    color: #111827;
    background: #fff;
  }

  body > :not(#print-root),
  #app,
  #modal-root,
  #toast-root,
  .no-print,
  .print-actions {
    display: none !important;
  }

  #print-root {
    display: block !important;
    width: 100%;
    min-height: 0;
    color: #111827;
    background: #fff;
    color-scheme: light;
    --bg: #fff;
    --surface: #fff;
    --surface-soft: #f8fafc;
    --surface-strong: #f1f5f9;
    --ink: #111827;
    --ink-table: #1f2937;
    --muted: #4b5563;
    --line: #cbd5e1;
    --line-soft: #e2e8f0;
  }

  #print-root,
  #print-root * {
    box-shadow: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  #print-root.print-portrait,
  #print-root .print-portrait,
  #print-root .statement-portrait,
  body.print-portrait #print-root {
    page: elzhur-portrait;
  }

  #print-root.print-landscape,
  #print-root .print-landscape,
  #print-root .statement-landscape,
  body.print-landscape #print-root {
    page: elzhur-landscape;
  }

  #print-root .print-statement,
  #print-root .statement,
  #print-root .individual-statement,
  #print-root .group-statement {
    min-height: 0;
    padding: 0;
  }

  #print-root .print-landscape,
  #print-root .statement-landscape {
    padding: 0;
  }

  #print-root .print-landscape :is(.statement-table, .print-table),
  #print-root .statement-landscape :is(.statement-table, .print-table) {
    font-size: 7.5pt;
  }

  #print-root :is(.statement-table, .print-table) thead,
  #print-root .print-repeat-header {
    display: table-header-group;
  }

  #print-root :is(.statement-table, .print-table) tfoot,
  #print-root .print-repeat-footer {
    display: table-footer-group;
  }

  #print-root :is(tr, img, .statement-section, .statement-summary, .statement-signatures, .print-avoid-break) {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  #print-root :is(h1, h2, h3, .statement-header, .print-header) {
    break-after: avoid;
    page-break-after: avoid;
  }
}
