:root {
  --bg: #f6faf9;
  --text: #122033;
  --muted: #64748b;
  --card: rgba(255, 255, 255, 0.76);
  --line: rgba(100, 116, 139, 0.22);
  --primary: #0f766e;
  --primary-strong: #115e59;
  --gold: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 24px 80px rgba(15, 23, 42, 0.13);
}

[data-theme="dark"] {
  --bg: #0e1726;
  --text: #eef6f5;
  --muted: #a8b5c5;
  --card: rgba(22, 32, 48, 0.78);
  --line: rgba(148, 163, 184, 0.24);
  --primary: #2dd4bf;
  --primary-strong: #14b8a6;
  --gold: #fbbf24;
  --danger: #f87171;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.22), transparent 30rem),
    radial-gradient(circle at top right, rgba(245, 158, 11, 0.18), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.page {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar,
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 20px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  color: white;
  background: var(--primary);
  font-size: 28px;
  font-weight: 900;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(28px, 3vw, 42px);
  letter-spacing: 0;
}

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

.actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 10px 14px;
  font-weight: 800;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
}

.btn.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

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

.grid {
  display: grid;
  gap: 18px;
}

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

.dashboard > *,
.card,
.table-wrap {
  min-width: 0;
}

.dashboard aside {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  align-items: start;
}

.card {
  padding: 20px;
  animation: fade-up 0.45s ease both;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.card h2,
.card h3 {
  margin-bottom: 4px;
}

.profile-grid,
.metrics,
.tools,
.charts,
.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  color: var(--text);
  min-height: 40px;
  padding: 9px 10px;
  font: inherit;
}

[data-theme="dark"] input,
[data-theme="dark"] select {
  background: rgba(15, 23, 42, 0.48);
}

.mode-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(100, 116, 139, 0.14);
}

.mode-toggle button {
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 9px 12px;
  font-weight: 800;
}

.mode-toggle button.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  table-layout: fixed;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  vertical-align: middle;
}

.subject-title {
  font-weight: 900;
  line-height: 1.15;
}

.code {
  color: var(--muted);
  font-size: 12px;
}

.marks-input {
  max-width: 76px;
  padding-left: 10px;
  padding-right: 6px;
}

.total-marks-input {
  max-width: 140px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--primary);
  color: white;
  font-size: 12px;
  font-weight: 900;
}

.badge.fail {
  background: var(--danger);
}

.result-hero {
  background: var(--primary);
  color: white;
  border-radius: 14px;
  padding: 22px;
}

.tgpa {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.tgpa strong {
  font-size: 54px;
  line-height: 1;
}

.result-hero .badge {
  font-size: 20px;
  padding: 8px 18px;
  background: linear-gradient(135deg, rgba(255,255,255,0.3), rgba(255,255,255,0.1));
  color: white;
  border-radius: 16px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.4);
  transform: translateY(-4px);
}

.metric {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.12);
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

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

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

.chart-box {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chart-box canvas {
  display: block;
  width: 100% !important;
  height: 240px !important;
  max-height: 240px !important;
}

.saved-item {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-top: 10px;
  padding: 14px;
}

.notice {
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  padding: 16px;
}

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

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1100px) {
  .dashboard aside,
  .tools,
  .charts {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page {
    width: min(100% - 20px, 1320px);
    padding-top: 10px;
  }

  .topbar,
  .card-header,
  .saved-item {
    align-items: stretch;
    flex-direction: column;
  }

  .profile-grid,
  .metrics,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .tgpa {
    align-items: flex-start;
    flex-direction: column;
  }
}

#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--card);
  color: var(--text);
  padding: 12px 24px;
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border);
  font-weight: 700;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
}

#toast.show {
  transform: translateY(0);
  opacity: 1;
}

.credit-banner {
  background: var(--primary);
  text-align: center;
  padding: 14px 20px;
  width: 100%;
}

.credit-banner a {
  color: white;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-decoration: none;
  transition: opacity 0.2s;
}

.credit-banner a:hover {
  opacity: 0.8;
  text-decoration: underline;
}
