:root {
  color-scheme: dark;
  font-family: "Avenir Next", "Avenir", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --bg-0: #0a0d14;
  --bg-1: #0f1726;
  --surface-0: rgba(15, 23, 38, 0.78);
  --surface-1: rgba(20, 30, 48, 0.88);
  --surface-2: rgba(28, 41, 66, 0.92);
  --border-soft: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text-strong: #f5f7fb;
  --text-main: #d7deea;
  --text-muted: #94a3b8;
  --accent-primary: #ec4899;
  --accent-primary-2: #8b5cf6;
  --accent-secondary: #6c7ce8;
  --accent-success: #22c55e;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --gradient-brand: linear-gradient(135deg, #6c7ce8 0%, #a855f7 52%, #ec4899 100%);
  --gradient-success: linear-gradient(135deg, #22c55e 0%, #16a34a 52%, #15803d 100%);
  background: var(--bg-0);
  color: var(--text-main);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text-main);
  background:
    radial-gradient(circle at 12% 18%, rgba(124, 58, 237, 0.2), transparent 26%),
    radial-gradient(circle at 88% 10%, rgba(56, 189, 248, 0.14), transparent 24%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 60%, #0b1120 100%);
}

a {
  color: var(--accent-secondary);
}

button {
  font-family: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

/* Login */
.login-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: 0 24px 80px rgba(2, 6, 23, 0.45);
}

.login-logo {
  display: block;
  height: 34px;
  width: auto;
  margin: 0 0 16px;
}

.login-subtitle {
  color: var(--text-muted);
  margin: 0 0 28px;
  font-size: 0.92rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.field input,
.field select {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text-strong);
  font-size: 0.95rem;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 0.92rem;
  color: #fff;
  background: var(--gradient-brand);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-main);
  border: 1px solid var(--border-soft);
}

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

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

.btn-block {
  width: 100%;
}

.form-message {
  min-height: 20px;
  font-size: 0.85rem;
  margin-top: 12px;
}

.form-message.error {
  color: var(--accent-danger);
}

.form-message.success {
  color: var(--accent-success);
}

/* Dashboard shell */
.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  background: var(--surface-1);
  border-right: 1px solid var(--border-soft);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-brand-logo {
  display: block;
  height: 22px;
  width: auto;
  margin: 0 8px 24px;
}

.nav-item {
  background: transparent;
  border: none;
  color: var(--text-muted);
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.92rem;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--surface-2);
  color: var(--text-strong);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-soft);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-chip {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.user-chip strong {
  display: block;
  color: var(--text-strong);
  font-size: 0.9rem;
}

.main-area {
  padding: 32px 40px;
  overflow-y: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.panel-header h1 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--text-strong);
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 24px;
  align-items: start;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 20px;
}

.card h2 {
  margin: 0 0 16px;
  font-size: 1rem;
  color: var(--text-strong);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.drawing-canvas {
  display: block;
  max-width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  cursor: crosshair;
  touch-action: none;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tr.active-row {
  background: rgba(79, 70, 229, 0.08);
}

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

.row-actions {
  display: flex;
  gap: 8px;
}

.row-actions button {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  color: var(--text-main);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.78rem;
}

.row-actions button.danger {
  color: var(--accent-danger);
  border-color: rgba(239, 68, 68, 0.35);
}

.row-actions button.review-mark.btn-success {
  background: var(--gradient-success);
  color: #fff;
  border-color: transparent;
}

.row-actions button.review-mark.btn-danger {
  background: var(--accent-danger);
  color: #fff;
  border-color: transparent;
}

.attendance-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attendance-option {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  color: var(--text-main);
  font-size: 0.78rem;
  cursor: pointer;
  user-select: none;
}

.attendance-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.attendance-option:has(input:checked) {
  background: var(--gradient-brand);
  color: #fff;
  border-color: transparent;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
}

.badge.role-admin { color: #c4b5fd; }
.badge.role-director { color: #7dd3fc; }
.badge.role-teacher { color: #86efac; }
.badge.role-student { color: #fde68a; }
.badge.role-parent { color: #fca5a5; }

.badge-success {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.4);
  background: rgba(74, 222, 128, 0.1);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.kpi-card {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-strong);
}

.kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 16px 0;
  text-align: center;
}

.field-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: 0 0 12px;
  line-height: 1.4;
}

.color-input {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  overflow: hidden;
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 50%;
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.color-input::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}

.select-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
}

.select-row .btn {
  height: 42px;
}

.select-row .field {
  flex: 1;
  min-width: 160px;
  margin-bottom: 0;
}

.logo-preview {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
}
