body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, #eef6ff 0%, #f8fbff 100%);
  margin: 0;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: 270px;
  background: linear-gradient(180deg, #0f3f8a 0%, #135bc0 45%, #1769db 100%);
  color: #fff;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 1045;
  box-shadow: 0 12px 30px rgba(11, 37, 79, 0.28);
  transition: width 0.2s ease, transform 0.22s ease;
}

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
}

.sidebar-brand:hover {
  color: #dceafe;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  padding-right: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #e8f0ff;
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 10px;
  font-weight: 500;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.sidebar-link i {
  font-size: 1.1rem;
  min-width: 20px;
}

.sidebar-user {
  margin-top: auto;
}

.sidebar-user .btn {
  border-color: rgba(255, 255, 255, 0.42);
}

.sidebar-user .btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.75);
}

.app-content {
  flex: 1;
  margin-left: 270px;
  min-width: 0;
  transition: margin-left 0.2s ease;
}

.app-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 0;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 23, 49, 0.52);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1040;
}

.app-shell.sidebar-collapsed .app-sidebar {
  width: 78px;
}

.app-shell.sidebar-collapsed .app-content {
  margin-left: 78px;
}

.app-shell.sidebar-collapsed .sidebar-label {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding-left: 8px;
  padding-right: 8px;
}

.app-shell.sidebar-collapsed .sidebar-brand {
  justify-content: center;
}

.app-shell.sidebar-collapsed .sidebar-user .btn i {
  margin-right: 0;
}

@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: 270px;
  }

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

  .app-topbar {
    padding: 12px 12px 0;
  }

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

  .app-shell.sidebar-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}

.inline { display: inline; }

.marks-entry-meta {
  background: #ffffff;
  border: 1px solid #dbe6f3;
  border-radius: 0.75rem;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 0.25rem 0.75rem rgba(26, 47, 77, 0.08);
}

.marks-entry-title {
  font-weight: 600;
  margin-bottom: 10px;
}

.marks-entry-title-line {
  font-weight: 600;
  margin-bottom: 10px;
  font-size: 1.05rem;
}

.marks-entry-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid #e7edf5;
  border-bottom: 1px solid #e7edf5;
}

.marks-entry-primary-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 12px;
  border-right: 1px solid #e7edf5;
}

.marks-entry-subject-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.marks-entry-subject-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  min-width: 0;
  flex: 0 0 auto;
}

.marks-entry-subject-form label {
  margin: 0;
  font-weight: 600;
}

.marks-entry-subject-form select {
  min-width: 0;
  width: 320px;
}

.marks-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.marks-entry-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  flex-wrap: wrap;
}

.marks-entry-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.marks-entry-filters label {
  margin: 0;
}

#marks-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #ffffff;
}

.status.saving { color: #1d4ed8; }
.status.saved { color: #15803d; }
.status.failed { color: #b91c1c; }
.row-inline-error {
  color: #b91c1c;
  font-size: 12px;
  margin-top: 4px;
}

.mark-row.has-row-error td {
  border-color: #ef4444;
  background: #fff5f5;
}

.finalize-feedback {
  margin-top: 8px;
  font-size: 14px;
}

.finalize-feedback.error {
  color: #b91c1c;
}

.finalize-feedback.success {
  color: #166534;
}

.marks-entry-lock {
  margin-top: 8px;
  color: #4b5563;
  font-weight: 600;
}

@media (max-width: 768px) {
  .marks-entry-title-line {
    font-size: 0.96rem;
  }

  .marks-entry-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .marks-entry-primary-actions {
    border-right: 0;
    padding-right: 0;
    justify-content: space-between;
  }

  .marks-entry-subject-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .marks-entry-subject-form {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 8px;
    width: 100%;
    grid-column: 1 / -1;
    max-width: none;
    order: 1;
  }

  .marks-entry-subject-form select {
    width: 100%;
    min-width: 0;
  }

  .marks-nav-prev {
    order: 2;
  }

  .marks-nav-next {
    order: 3;
  }

  .marks-nav-btn {
    width: 100%;
    justify-content: center;
  }

  .marks-entry-status-row {
    align-items: flex-start;
  }

  .marks-entry-filters {
    width: 100%;
  }

  .marks-entry-filters #roll-search {
    width: 100%;
  }

  .table th:nth-child(2), .table td:nth-child(2) {
    min-width: 120px;
  }

  input[type='number'] {
    width: 80px;
  }
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.division-card {
  background: #ffffff;
  border: 1px solid #dbe6f3;
  border-radius: 0.85rem;
  padding: 14px;
  box-shadow: 0 0.2rem 0.6rem rgba(26, 47, 77, 0.06);
}

.division-card h2 {
  margin: 0 0 10px 0;
  font-size: 16px;
}

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

.kpi-tile {
  border: 0;
  border-radius: 0.9rem;
  color: #fff;
  box-shadow: 0 0.6rem 1rem rgba(26, 47, 77, 0.15);
}

.kpi-primary { background: linear-gradient(135deg, #0d6efd 0%, #3f8cff 100%); }
.kpi-success { background: linear-gradient(135deg, #198754 0%, #3daf78 100%); }
.kpi-warning { background: linear-gradient(135deg, #fd7e14 0%, #ffad5c 100%); }
.kpi-danger { background: linear-gradient(135deg, #dc3545 0%, #f26c79 100%); }
.kpi-info { background: linear-gradient(135deg, #0dcaf0 0%, #55d9f5 100%); }

.kpi-icon {
  font-size: 1.5rem;
  opacity: 0.9;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
}

.quick-links a {
  text-decoration: none;
}

.quick-links a:hover {
  text-decoration: underline;
}

.login-shell {
  min-height: calc(100vh - 2rem);
  display: grid;
  place-items: center;
  padding: 1rem 0;
}

.login-wrap {
  width: min(100%, 440px);
}

.result-wrap {
  width: min(100%, 980px);
}

.login-brand {
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  color: #0f3f8a;
  margin: 0 0 0.9rem;
}

.login-card {
  background: #ffffff;
  border: 1px solid #dbe6f3;
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: 0 0.9rem 2rem rgba(16, 37, 68, 0.14);
}

.login-title {
  margin: 0;
  font-size: 1.35rem;
  text-align: center;
}

.login-subtitle {
  color: #52627b;
  margin: 0.35rem 0 1rem;
  text-align: center;
}

.result-shell {
  min-height: calc(100vh - 2rem);
  display: grid;
  place-items: center;
  padding: 1rem 0;
  background:
    radial-gradient(1200px 380px at 15% 10%, rgba(255, 255, 255, 0.5), transparent 60%),
    radial-gradient(1200px 380px at 85% 90%, rgba(181, 207, 242, 0.55), transparent 55%),
    linear-gradient(180deg, #eef4fb 0%, #e5edf8 100%);
  border-radius: 1rem;
}

.result-header-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #d5e3f4;
  border-radius: 1rem;
  padding: 0.9rem 1.25rem;
  box-shadow: 0 0.9rem 2rem rgba(16, 37, 68, 0.12);
}

.result-title {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.2;
  font-weight: 600;
  text-align: center;
  color: #27364d;
}

.result-subtitle {
  color: #4a607f;
  margin: 0.25rem 0 0;
  text-align: center;
  font-size: 1rem;
}

.result-method-card {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #d6e2f3;
  border-radius: 1rem;
  box-shadow: 0 0.9rem 1.8rem rgba(15, 35, 66, 0.1);
}

.result-label {
  font-weight: 600;
  color: #2f3f57;
}

.result-input {
  border-radius: 0.65rem;
  border-color: #cad7ea;
  background-color: #f9fbff;
}

.result-input:focus {
  border-color: #6c9ae2;
  box-shadow: 0 0 0 0.18rem rgba(45, 112, 214, 0.15);
}

.result-btn {
  border-radius: 0.65rem;
  font-weight: 600;
  padding-top: 0.62rem;
  padding-bottom: 0.62rem;
}

.result-download-btn {
  border-radius: 0.65rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
}

.result-metric-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.result-metric {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 0.35rem 0.7rem rgba(23, 38, 63, 0.1);
}

.result-metric.metric-total {
  background: #1f5aa3;
  border-color: #174882;
  color: #ffffff;
}

.result-metric.metric-max {
  background: #e9f0fb;
  border-color: #c7d9f5;
  color: #22406e;
}

.result-metric.metric-percentage {
  background: #0d7f9f;
  border-color: #0b6780;
  color: #ffffff;
}

.result-metric.metric-pass {
  background: #1e8f4f;
  border-color: #186f3d;
  color: #ffffff;
}

.result-metric.metric-fail {
  background: #bc3d3d;
  border-color: #992f2f;
  color: #ffffff;
}

.result-metric.metric-rank {
  background: #2f3646;
  border-color: #232938;
  color: #ffffff;
}

@media (max-width: 768px) {
  .result-shell {
    min-height: auto;
  }
  .result-title {
    font-size: 1.25rem;
  }
  .result-subtitle {
    font-size: 1rem;
  }
  .result-metric {
    font-size: 0.82rem;
    padding: 0.32rem 0.62rem;
  }
}
