/* ============================================================
   JUPAS Score Calculator — styles
   ============================================================ */

:root {
  --bg: #0e1117;
  --bg-2: #161b22;
  --bg-3: #1d242c;
  --card: #ffffff;
  --card-2: #f7f8fa;
  --text: #1c1f24;
  --text-muted: #5b6470;
  --border: #e3e6ea;
  --border-strong: #cdd3d9;
  --accent: #0e6c41;
  --accent-2: #0b5634;
  --danger: #b3261e;
  --warn: #c47800;
  --safe: #1f7a3a;
  --likely: #0e6c41;
  --possible: #c47800;
  --reach: #aa4b1f;
  --ineligible: #6c7280;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.12);

  --maxw: 1180px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: #f3f5f8;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ---------------- header ---------------- */
.app-header {
  background: linear-gradient(135deg, #0e6c41 0%, #0b5634 100%);
  color: white;
  padding: 28px 24px 24px;
  margin-bottom: 24px;
}
.app-header .brand {
  max-width: var(--maxw);
  margin: 0 auto;
}
.app-header h1 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: -0.01em;
}
.app-header .tagline {
  margin: 0;
  opacity: 0.85;
  font-size: 14px;
  max-width: 700px;
}
.header-meta {
  max-width: var(--maxw);
  margin: 12px auto 0;
  font-size: 12px;
  opacity: 0.85;
}
.header-meta .loading { font-style: italic; }
.header-meta strong { font-weight: 600; }

/* ---------------- cards ---------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.005em;
}
.card-head .hint {
  flex-basis: 100%;
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}
.card-head .actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ---------------- buttons ---------------- */
.btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  font-family: inherit;
}
.btn:hover { background: var(--accent-2); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover { background: var(--card-2); }
.btn-small { padding: 6px 10px; font-size: 12px; }

/* ---------------- inputs ---------------- */
.grade-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
@media (min-width: 768px) {
  .grade-grid { grid-template-columns: 1fr 1fr; }
}
.grade-group h3 {
  margin: 0 0 4px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}
.grade-group .hint {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.grade-row, .elective-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.grade-cell {
  display: flex;
  flex-direction: column;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  position: relative;
}
.grade-cell .grade-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  line-height: 1.2;
}
.grade-select {
  border: none;
  background: transparent;
  font-size: 16px;
  font-weight: 600;
  padding: 2px 0;
  color: var(--text);
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
  width: 100%;
}
.subject-select {
  border: none;
  background: transparent;
  font-size: 11px;
  color: var(--text-muted);
  padding: 0;
  margin-bottom: 4px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  width: 100%;
}
.elective-cell .btn-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 3px;
}
.elective-cell .btn-remove:hover { background: rgba(0,0,0,0.05); }
.filter-toggle {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.search-box {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  width: 220px;
}
.filter-select {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  background: white;
}

/* ---------------- uni summary cards ---------------- */
.uni-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.uni-card {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.uni-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.uni-card-head .uni-short {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.uni-card-head .uni-name {
  font-size: 11px;
  color: var(--text-muted);
}
.uni-card-stats {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.uni-card-stat {
  font-size: 12px;
  color: var(--text-muted);
}
.uni-card-stat strong {
  display: block;
  font-size: 18px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.uni-card-stat.safe strong { color: var(--safe); }
.uni-card-stat.likely strong { color: var(--likely); }
.uni-card-stat.possible strong { color: var(--possible); }
.uni-card-stat.reach strong { color: var(--reach); }
.uni-card-note {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* ---------------- programme list ---------------- */
.programmes-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.programme-uni-group {
  border-bottom: 1px solid var(--border);
}
.programme-uni-group:last-child { border-bottom: none; }
.programme-uni-header {
  background: var(--card-2);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.programme-uni-header .chev::before { content: "▾"; margin-right: 6px; }
.programme-uni-header.collapsed .chev::before { content: "▸"; }
.programme-row {
  display: grid;
  grid-template-columns: 90px 1fr 200px 130px;
  gap: 14px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  align-items: center;
  font-size: 13px;
}
.programme-row:hover { background: rgba(14,108,65,0.03); }
.programme-row .p-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--text-muted);
}
.programme-row .p-name {
  font-weight: 500;
}
.programme-row .p-faculty {
  font-size: 11px;
  color: var(--text-muted);
}
.programme-row .p-formula {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.programme-row .p-score {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.programme-row .p-score .score-big {
  font-size: 18px;
  font-weight: 700;
  display: block;
}
.programme-row .p-score .threshold {
  font-size: 11px;
  color: var(--text-muted);
}
.programme-row .p-status {
  justify-self: end;
}
.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.status-safe { background: #e1f4e9; color: var(--safe); }
.status-likely { background: #d6ecdf; color: var(--likely); }
.status-possible { background: #fff2d8; color: var(--possible); }
.status-reach { background: #fce0d2; color: var(--reach); }
.status-ineligible { background: #ebecee; color: var(--ineligible); }
.status-no-ger { background: #f8d7d4; color: #8a1a16; }
.status-no-prereq { background: #ffe2c2; color: #8a4a0c; }

.p-prereq {
  font-size: 11px;
  color: #8a4a0c;
  margin-top: 2px;
  line-height: 1.3;
  font-style: italic;
}

.ger-banner {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid var(--border);
}
.ger-banner.ger-ok {
  background: #e1f4e9;
  border-color: #b8e0c6;
  color: var(--safe);
}
.ger-banner.ger-fail {
  background: #fff0ee;
  border-color: #f4c8c2;
  color: #8a1a16;
}

@media (max-width: 700px) {
  .programme-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .programme-row .p-status { justify-self: start; }
}

/* ---------------- what-if ---------------- */
.whatif-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.whatif-cell {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 12px;
}
.whatif-cell .whatif-subject {
  font-weight: 600;
  margin-bottom: 6px;
}
.whatif-cell .whatif-current {
  color: var(--text-muted);
  margin-bottom: 6px;
  font-size: 11px;
}
.whatif-bumps {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.whatif-bump {
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 11px;
  font-family: ui-monospace, Menlo, monospace;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.whatif-bump:hover { background: var(--card-2); }
.whatif-bump.positive { color: var(--safe); }
.whatif-bump.negative { color: var(--reach); }
.whatif-bump.neutral { color: var(--text-muted); }

.whatif-summary {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------------- modals ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: white;
  border-radius: var(--radius);
  padding: 22px;
  width: min(440px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg);
}
.modal h3 { margin: 0 0 8px; }
.modal p { margin: 0 0 12px; color: var(--text-muted); font-size: 13px; }
.modal input[type="text"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}
.load-list {
  max-height: 360px;
  overflow-y: auto;
}
.load-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.load-item:last-child { border-bottom: none; }
.load-item-meta {
  font-size: 11px;
  color: var(--text-muted);
}
.load-item-actions { display: flex; gap: 6px; }
.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  font-family: inherit;
}
.btn-link.danger { color: var(--danger); }
.btn-link:hover { text-decoration: underline; }

/* ---------------- export ---------------- */
.export-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.saved-profiles {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------------- footer ---------------- */
.app-footer {
  margin-top: 28px;
  padding: 20px 0;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.app-footer p { margin: 0 0 6px; }
.app-footer code {
  background: var(--card-2);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}
.app-footer a { color: var(--accent); }
.app-footer .disclaimer { color: var(--text-muted); }
.app-footer .meta { font-size: 11px; opacity: 0.8; }

/* ---------------- print ---------------- */
@media print {
  body { background: white; }
  .app-header { background: white; color: black; border-bottom: 2px solid black; }
  .app-header h1, .app-header .tagline { color: black; }
  .card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
  .actions, #whatif-section, #export-section, #save-modal, #load-modal { display: none; }
  .programme-uni-header { background: #f0f0f0; }
}
