:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #cbd5e1;
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --success: #15803d;
  --danger: #b91c1c;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

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

.topbar {
  background: #0f172a;
  color: #ffffff;
  border-bottom: 3px solid var(--primary);
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-badge {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.brand p {
  margin: 2px 0 0;
  font-size: 13px;
  color: #cbd5e1;
}

.container {
  max-width: 1400px;
  margin: 24px auto;
  padding: 0 18px 40px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
}

/* Login */
.login-wrapper {
  display: flex;
  justify-content: center;
  padding-top: 24px;
}
.login-card {
  width: 100%;
  max-width: 460px;
  padding: 24px;
}
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: #f1f5f9;
  padding: 5px;
  border-radius: 10px;
  margin-bottom: 20px;
}
.tab-btn {
  border: none;
  background: transparent;
  padding: 10px 12px;
  border-radius: 7px;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}
.tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.form-group input:focus,
.form-group select:focus {
  outline: 2px solid rgba(29, 78, 216, 0.25);
  border-color: var(--primary);
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}
.topbar .btn-outline {
  background: transparent;
  color: #fff;
  border-color: rgba(255,255,255,0.35);
}
.btn-full { width: 100%; padding: 11px; }

.error-msg {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

.scale-box {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
  text-align: center;
}
.scale-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.scale-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
}
.scale-pills span {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 4px 9px;
  border-radius: 6px;
}

/* Welcome Banner */
.welcome-banner {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
  border-left: 5px solid var(--primary);
}
.welcome-kicker {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.6px;
}
.welcome-banner h2 {
  margin: 4px 0 2px;
  font-size: 20px;
}
.welcome-lesson {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}
.teacher-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.save-status {
  font-size: 13px;
  font-weight: 600;
  color: var(--success);
  padding: 5px 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
}
.save-status.saving {
  color: #b45309;
  background: #fffbeb;
  border-color: #fde68a;
}

.scale-bar {
  padding: 12px 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
}
.badge-scale {
  display: inline-block;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  padding: 2px 8px;
  border-radius: 5px;
  margin-left: 5px;
  font-weight: 600;
}
.scale-hint { color: var(--muted); }

/* Teacher Grading Table */
.table-card { overflow-x: auto; }
.grading-table {
  width: 100%;
  border-collapse: collapse;
}
.grading-table th,
.grading-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  font-size: 14px;
}
.grading-table th {
  background: #f8fafc;
  font-weight: 700;
  color: #334155;
  font-size: 13px;
}
.grading-table tbody tr:hover { background: #f8fafc; }
.student-name { font-weight: 600; }
.group-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #e2e8f0;
  color: #334155;
}
.quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.qbtn {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.qbtn:hover { background: #eff6ff; border-color: var(--primary); }
.qbtn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.grade-input {
  width: 90px;
  padding: 6px 8px;
  border: 1.5px solid #94a3b8;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
}
.grade-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Admin Status Grid */
.status-card {
  padding: 14px 18px;
  margin-bottom: 16px;
}
.status-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #334155;
}
.status-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.status-pill {
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
}
.status-pill.done {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}
.status-pill.partial {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}

/* Admin Matrix Table */
.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.matrix-table th,
.matrix-table td {
  border: 1px solid #cbd5e1;
  padding: 6px 5px;
  text-align: center;
}
.matrix-table thead th {
  background: #f1f5f9;
  font-weight: 700;
  color: #0f172a;
  vertical-align: bottom;
}
.matrix-table th.col-name,
.matrix-table td.col-name {
  text-align: left;
  padding-left: 8px;
  white-space: nowrap;
  font-weight: 600;
}
.matrix-table th.col-subj {
  font-size: 11px;
  line-height: 1.2;
  min-width: 52px;
}
.matrix-table tbody tr:nth-child(even) { background: #f8fafc; }

.g-badge {
  display: inline-block;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
}
.g-A { color: #166534; background: #dcfce7; }
.g-B { color: #1e40af; background: #dbeafe; }
.g-G { color: #92400e; background: #fef3c7; }
.g-D { color: #9a3412; background: #ffedd5; }
.g-E { color: #991b1b; background: #fee2e2; }

/* Print Styles */
@media print {
  @page {
    size: A4 landscape;
    margin: 7mm;
  }
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .no-print { display: none !important; }
  .print-only { display: block !important; }
  .container {
    max-width: 100%;
    margin: 0;
    padding: 0;
  }
  .card, .table-card {
    border: none !important;
    box-shadow: none !important;
    overflow: visible !important;
  }
  .print-header {
    text-align: center;
    margin-bottom: 6px;
  }
  .print-header h2 {
    margin: 0;
    font-size: 13px;
    font-weight: 800;
  }
  .print-meta {
    font-size: 9.5px;
    color: #333;
    margin-top: 2px;
  }
  .matrix-table {
    width: 100%;
    font-size: 9.5px;
  }
  .matrix-table th,
  .matrix-table td {
    border: 1px solid #444 !important;
    padding: 3px 3px !important;
  }
  .matrix-table th.col-subj {
    font-size: 8.5px;
    min-width: 0;
  }
  .matrix-table th.col-name,
  .matrix-table td.col-name {
    font-size: 9.5px;
    padding-left: 5px !important;
  }
  .g-badge {
    background: transparent !important;
    color: #000 !important;
    padding: 0 !important;
  }
}
