/* ==========================================================================
   CSD Degree Tracker — styles.css
   White surface, committed blue identity. Mobile-first, no frameworks.
   Color in OKLCH; neutrals tinted toward the brand blue.
   ========================================================================== */

/* ----------------------------- Design tokens ----------------------------- */
:root {
  /* Blue identity scale */
  --blue-50:  oklch(0.972 0.013 255);
  --blue-100: oklch(0.936 0.032 255);
  --blue-200: oklch(0.888 0.058 255);
  --blue-300: oklch(0.800 0.095 256);
  --blue-500: oklch(0.620 0.175 256);
  --blue-600: oklch(0.552 0.193 257);
  --blue-700: oklch(0.482 0.176 258);
  --blue-800: oklch(0.405 0.142 261);
  --blue-900: oklch(0.320 0.102 263);

  /* Neutrals, tinted toward the brand hue */
  --bg:            oklch(0.976 0.010 255);
  --surface:       oklch(0.996 0.003 255);
  --surface-2:     oklch(0.967 0.011 255);
  --text:          oklch(0.262 0.031 262);
  --muted:         oklch(0.520 0.030 262);
  --faint:         oklch(0.655 0.028 262);
  --border:        oklch(0.918 0.014 255);
  --border-strong: oklch(0.856 0.021 255);

  --primary:      var(--blue-600);
  --primary-dark: var(--blue-700);
  --primary-soft: var(--blue-100);

  --ok:          oklch(0.555 0.140 150);
  --ok-soft:     oklch(0.948 0.042 150);
  --ok-border:   oklch(0.860 0.070 150);
  --warn:        oklch(0.560 0.118 72);
  --warn-soft:   oklch(0.950 0.055 82);
  --warn-border: oklch(0.860 0.082 80);
  --danger:      oklch(0.560 0.205 26);
  --danger-soft: oklch(0.950 0.042 26);

  --header-h: 62px;

  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(23, 37, 84, .05), 0 8px 24px rgba(23, 37, 84, .07);
  --shadow-sm: 0 1px 2px rgba(23, 37, 84, .06);
  --shadow-blue: 0 6px 18px oklch(0.552 0.193 257 / .28);
  --ring: 0 0 0 3px var(--blue-200);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Ensure [hidden] always wins over class-set display. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1100px 480px at 100% -8%, var(--blue-100), transparent 60%),
    radial-gradient(900px 420px at -10% 0%, oklch(0.95 0.03 230), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.22; letter-spacing: -.01em; }
button { font-family: inherit; }
.muted { color: var(--muted); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* -------------------------------- Buttons -------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s, color .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--lg { padding: 13px 22px; font-size: 16px; }
.btn--icon { padding: 6px 10px; border-radius: 9px; }

.btn--primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-blue); }
.btn--primary:hover { background: var(--primary-dark); }
.btn--primary:focus-visible { box-shadow: var(--shadow-blue), var(--ring); }

.btn--ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--blue-300); color: var(--primary-dark); }

.btn--danger-ghost { background: var(--surface); border-color: oklch(0.86 0.07 26); color: var(--danger); }
.btn--danger-ghost:hover { background: var(--danger-soft); }

.btn--google { background: #fff; border-color: var(--border-strong); color: oklch(0.30 0.02 262); }
.btn--google:hover { background: var(--surface-2); box-shadow: var(--shadow-sm); }

/* -------------------------------- Header --------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  color: oklch(0.96 0.02 255);
  background:
    radial-gradient(420px 180px at 88% -40%, oklch(0.62 0.17 250 / .55), transparent 70%),
    linear-gradient(110deg, var(--blue-800), var(--blue-600));
  box-shadow: 0 1px 0 oklch(0.50 0.18 257 / .6), var(--shadow);
}
.app-header__inner {
  max-width: 1120px;
  margin: 0 auto;
  min-height: var(--header-h);
  padding: 8px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand__mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  overflow: hidden;
  background: #fff;
  padding: 3px;
  flex: none;
  box-shadow: 0 2px 8px rgba(23, 37, 84, .25);
}
.brand__mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand__text { display: flex; flex-direction: column; min-width: 0; }
.brand__title { font-weight: 700; font-size: 16px; color: #fff; letter-spacing: -.01em; }
.brand__sub { font-size: 12px; color: oklch(0.86 0.05 255); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.app-header__actions { display: flex; align-items: center; gap: 10px; }

.sync { font-size: 12px; color: oklch(0.85 0.05 255); white-space: nowrap; }
.sync--saving { color: oklch(0.86 0.12 90); }
.sync--saved  { color: oklch(0.85 0.14 150); }
.sync--error  { color: oklch(0.80 0.13 25); }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 4px 4px 10px;
  background: oklch(1 0 0 / .12);
  border: 1px solid oklch(1 0 0 / .18);
  border-radius: 999px;
}
.user-chip__photo { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: var(--blue-800); border: 1px solid oklch(1 0 0 / .35); }
.user-chip__name { font-size: 13px; color: #fff; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-header .btn--ghost {
  background: oklch(1 0 0 / .10);
  color: #fff;
  border-color: oklch(1 0 0 / .42);
}
.app-header .btn--ghost:hover {
  background: oklch(1 0 0 / .20);
  border-color: #fff;
  color: #fff;
}

/* ----------------------------- Config banner ----------------------------- */
.config-banner {
  background: var(--warn-soft);
  color: oklch(0.42 0.10 70);
  font-size: 13px;
  padding: 10px 16px;
  text-align: center;
  border-bottom: 1px solid var(--warn-border);
}
.config-banner code { background: oklch(0.40 0.08 70 / .12); padding: 1px 5px; border-radius: 4px; }

/* ------------------------------- Auth gate ------------------------------- */
.auth-gate { min-height: calc(100vh - var(--header-h)); display: grid; place-items: center; padding: 24px; }
.auth-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 40px 30px 34px;
  max-width: 430px;
  text-align: center;
  overflow: hidden;
}
.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: linear-gradient(90deg, var(--blue-500), var(--blue-700));
}
.auth-card__mark {
  font-size: 40px;
  width: 78px; height: 78px;
  margin: 6px auto 14px;
  display: grid; place-items: center;
  border-radius: 22px;
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
}
.auth-card h1 { font-size: 25px; margin-bottom: 10px; }
.auth-card p { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.auth-card__actions { display: flex; flex-direction: column; gap: 10px; }
.auth-card__actions .btn { width: 100%; }
.auth-note { font-size: 12.5px; color: var(--muted); margin: 18px 0 0; text-align: left; line-height: 1.55; }
.auth-note strong { color: var(--text); }
.config-banner .btn { margin-left: 8px; vertical-align: middle; }

/* -------------------------------- Layout --------------------------------- */
.container { max-width: 1120px; margin: 0 auto; padding: 18px 18px 56px; }
.section { margin-top: 32px; }
.section__title { font-size: 19px; font-weight: 700; }
.section__hint { color: var(--muted); font-size: 13px; margin: 5px 0 16px; max-width: 68ch; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.section__count { color: var(--muted); font-size: 13px; }
.section .section__title + * { margin-top: 16px; }

/* --------------------------- Sticky summary bar -------------------------- */
.summary {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  background: oklch(0.996 0.003 255 / .85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.summary__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
}
.summary__item { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.summary__label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--faint); font-weight: 700; }
.summary__value { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.summary__value--sm { font-size: 14px; font-weight: 700; }
#sumEctsBar { display: block; margin-top: 2px; }
.summary__status { font-size: 14px; font-weight: 700; padding: 4px 11px; border-radius: 999px; align-self: flex-start; }
.summary__status.is-ok { background: var(--ok-soft); color: var(--ok); }
.summary__status.is-pending { background: var(--blue-50); color: var(--primary-dark); border: 1px solid var(--blue-200); }

.subnav {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 12px 11px;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.subnav__btn {
  flex: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.subnav__btn:hover { color: var(--primary); border-color: var(--blue-300); background: var(--blue-50); }

/* --------------------------------- Bars ---------------------------------- */
.bar { height: 8px; background: var(--blue-50); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.bar__fill { height: 100%; background: linear-gradient(90deg, var(--blue-500), var(--blue-600)); border-radius: 999px; transition: width .35s cubic-bezier(.22,1,.36,1); }
.bar__fill--ok { background: linear-gradient(90deg, oklch(0.66 0.14 150), var(--ok)); }

/* --------------------------------- Cards --------------------------------- */
.cards { display: grid; grid-template-columns: 1fr; gap: 14px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 11px;
  transition: box-shadow .18s, border-color .18s, transform .18s;
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.card--ok { border-color: var(--ok-border); background: linear-gradient(180deg, var(--ok-soft), var(--surface) 46%); }
.card--pending { border-color: var(--border); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card__title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.card__value { font-size: 32px; font-weight: 800; line-height: 1; letter-spacing: -.03em; color: var(--blue-900); }
.card__sub { font-size: 14px; font-weight: 600; color: var(--faint); margin-left: 6px; letter-spacing: 0; }
.card__foot { font-size: 12.5px; color: var(--muted); margin-top: auto; }
.card__detail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: -2px;
}
.card-course {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
}
.card-course__code {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.card-course__title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 650;
}
.card-course__meta {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11.5px;
}

.grade-band { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.grade-band--arista { color: var(--ok); }
.grade-band--lian-kalos { color: var(--blue-600); }
.grade-band--kalos { color: var(--warn); }
.grade-band--none, .grade-band--fail { color: var(--muted); }

/* --------------------------------- Pills --------------------------------- */
.pill { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill--ok { background: var(--ok-soft); color: var(--ok); }
.pill--pending { background: var(--blue-50); color: var(--primary-dark); border: 1px solid var(--blue-200); }

/* -------------------------------- Badges --------------------------------- */
/* Harmonized categorical palette: equal lightness/chroma, distinct hue. */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 7px;
  letter-spacing: .3px;
  white-space: nowrap;
}
.badge--core { background: var(--blue-100); color: var(--blue-800); }
.badge--e1 { background: oklch(0.93 0.05 256); color: oklch(0.42 0.13 258); }
.badge--e2 { background: oklch(0.93 0.05 195); color: oklch(0.42 0.10 200); }
.badge--e3 { background: oklch(0.93 0.05 225); color: oklch(0.42 0.12 232); }
.badge--e4 { background: oklch(0.93 0.06 85);  color: oklch(0.44 0.10 75); }
.badge--e5 { background: oklch(0.93 0.05 20);  color: oklch(0.45 0.14 24); }
.badge--e6 { background: oklch(0.93 0.05 295); color: oklch(0.44 0.14 296); }
.badge--e7 { background: oklch(0.93 0.06 150); color: oklch(0.42 0.12 152); }
.badge--e8 { background: oklch(0.93 0.06 55);  color: oklch(0.45 0.12 50); }
.badge--e9 { background: oklch(0.93 0.05 350); color: oklch(0.45 0.13 352); }
.badge--free { background: var(--surface-2); color: oklch(0.40 0.02 262); border: 1px solid var(--border); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--custom { background: var(--blue-50); color: var(--primary-dark); border: 1px solid var(--blue-200); }

/* ------------------------- "What do I still need" ------------------------ */
.needs { display: grid; grid-template-columns: 1fr; gap: 14px; }
.need {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 15px 17px;
  box-shadow: var(--shadow-sm);
}
.need--todo { background: linear-gradient(180deg, var(--warn-soft), var(--surface) 60%); border-color: var(--warn-border); }
.need--ok   { background: linear-gradient(180deg, var(--ok-soft), var(--surface) 60%); border-color: var(--ok-border); }
.need--info { background: linear-gradient(180deg, var(--blue-50), var(--surface) 60%); border-color: var(--blue-200); }
.need__title { font-size: 14px; font-weight: 700; margin-bottom: 9px; }
.need__list { margin: 0; padding-left: 19px; display: flex; flex-direction: column; gap: 6px; }
.need__list li { font-size: 13.5px; color: oklch(0.36 0.03 262); }
.needs-done {
  background: linear-gradient(180deg, var(--ok-soft), var(--surface) 70%);
  color: var(--ok);
  border: 1px solid var(--ok-border);
  border-radius: var(--radius-sm);
  padding: 20px;
  font-weight: 700;
  text-align: center;
}

/* ------------------------------ Simulator -------------------------------- */
.sim-controls { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 16px; }
.sim-controls #simGrade {
  flex: 0 0 96px;
  height: 40px;
  border-radius: 999px;
  text-align: center;
  font-weight: 750;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.sim-controls #simGrade::placeholder {
  color: var(--muted);
  font-weight: 600;
}
.sim-controls #simGrade::-webkit-outer-spin-button,
.sim-controls #simGrade::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}
.sim-controls #simGrade {
  appearance: textfield;
  -moz-appearance: textfield;
}
.combo {
  position: relative;
  min-width: 260px;
}
.combo__input { width: 100%; }
.combo__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 35;
  max-height: 300px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 6px;
}
.combo__option {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  padding: 8px 9px;
  text-align: left;
}
.combo__option:hover,
.combo__option.is-active {
  background: var(--blue-50);
}
.combo__code {
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
  white-space: nowrap;
}
.combo__title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.combo__meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.combo__empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}
.sim-results { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-bottom: 16px; }
.sim-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  box-shadow: var(--shadow-sm);
}
.sim-stat__label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--faint); font-weight: 700; }
.sim-stat__value { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.sim-stat__value--band { font-size: 14px; font-weight: 700; }
.sim-stat__delta { font-size: 12px; font-weight: 700; }
.sim-stat__delta.up { color: var(--ok); }
.sim-stat__delta.down { color: var(--danger); }

.sim-list { display: flex; flex-direction: column; gap: 9px; }
.sim__empty { padding: 8px 0; }
.sim-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  flex-wrap: wrap;
}
.sim-item__info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.sim-item__code { font-weight: 700; font-size: 13px; }
.sim-item__title { font-size: 13px; color: oklch(0.36 0.03 262); }
.sim-item__grade { display: flex; align-items: center; gap: 6px; }
.sim-item__grade .js-sim-grade {
  width: 74px;
  height: 34px;
  border-radius: 999px;
  padding: 6px 10px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 750;
  box-shadow: inset 0 0 0 1px oklch(0.55 0.19 257 / .06);
}
.sim-item__grade .js-sim-grade::-webkit-outer-spin-button,
.sim-item__grade .js-sim-grade::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}
.sim-item__grade .js-sim-grade {
  appearance: textfield;
  -moz-appearance: textfield;
}

/* -------------------------------- Toolbar -------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar__spacer { flex: 1 1 100%; }
.input {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text);
  min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input--grow { flex: 1 1 180px; }
.input--grade { width: 90px; }

/* --------------------------- Excel help disclosure ----------------------- */
.excel-help {
  margin-top: 12px;
  border: 1px solid var(--blue-200);
  border-radius: var(--radius-sm);
  background: var(--blue-50);
  padding: 0 14px;
}
.excel-help[open] { padding-bottom: 6px; }
.excel-help summary {
  cursor: pointer;
  list-style: none;
  padding: 11px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}
.excel-help summary::-webkit-details-marker { display: none; }
.excel-help summary::before {
  content: "›";
  font-size: 17px;
  line-height: 1;
  transition: transform .15s;
  color: var(--primary);
}
.excel-help[open] summary::before { transform: rotate(90deg); }
.excel-help__steps {
  margin: 2px 0 8px;
  padding-left: 26px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  color: oklch(0.36 0.03 262);
}
.excel-help__steps a { color: var(--primary); font-weight: 700; }
.excel-help__steps a:hover { color: var(--primary-dark); }

/* ---------------------------- Course "table" ----------------------------- */
.course-head {
  display: none;
  grid-template-columns: 46px 1fr 96px;
  gap: 12px;
  padding: 0 14px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--faint);
  font-weight: 700;
}
.course-head__grade { text-align: center; }

.course-list { display: flex; flex-direction: column; gap: 9px; }

.course {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.course:hover { border-color: var(--blue-300); box-shadow: var(--shadow-sm), 0 4px 14px rgba(23, 37, 84, .05); }
.course--passed { border-color: var(--ok-border); background: linear-gradient(180deg, var(--ok-soft), var(--surface) 55%); }
.course--attention { border-color: var(--warn-border); background: linear-gradient(180deg, var(--warn-soft), var(--surface) 55%); }

/* custom checkbox — green keeps the "passed" semantic */
.course__check { position: relative; display: grid; place-items: center; cursor: pointer; }
.course__check input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.course__checkbox {
  width: 24px; height: 24px;
  border: 2px solid var(--border-strong);
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--surface);
  transition: background .15s, border-color .15s;
}
.course__checkbox::after {
  content: "✓";
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  transform: scale(0);
  transition: transform .12s cubic-bezier(.22,1,.36,1);
}
.course__check input:checked + .course__checkbox { background: var(--ok); border-color: var(--ok); }
.course__check input:checked + .course__checkbox::after { transform: scale(1); }
.course__check input:focus-visible + .course__checkbox { outline: none; box-shadow: var(--ring); }

.course__main { min-width: 0; }
.course__titleline { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.course__code { font-weight: 700; font-size: 14px; color: var(--blue-900); }
.course__title { font-size: 14px; color: oklch(0.36 0.03 262); }
.course__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.course__ects { font-size: 12px; color: var(--muted); font-weight: 600; }
.course__req { color: var(--faint); cursor: help; font-size: 13px; }
.course__warn { font-size: 12px; font-weight: 600; }
.course__cat-edit { display: inline-flex; align-items: center; }
.course__cat-select {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 800;
  padding: 3px 22px 3px 8px;
  height: 24px;
  cursor: pointer;
}
.course__cat-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}
.course__cat-note {
  color: var(--warn);
  font-size: 11.5px;
  font-weight: 700;
}
.warn--info { color: var(--warn); }
.warn--fail { color: var(--danger); }

.course__grade { display: flex; justify-content: flex-end; align-items: center; gap: 6px; }
.course__grade input {
  width: 72px;
  text-align: center;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 8px 6px;
  font-size: 14px;
  font-weight: 600;
  transition: border-color .15s, box-shadow .15s;
}
.course__grade input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.course__grade input.invalid { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.course__delete {
  color: var(--danger);
  border-color: oklch(0.86 0.07 26);
}
.course__delete:hover { background: var(--danger-soft); }

/* -------------------------------- Footer --------------------------------- */
.app-footer { margin-top: 44px; padding-top: 20px; border-top: 1px solid var(--border); }
.app-footer p { color: var(--faint); font-size: 12px; text-align: center; margin: 0; max-width: 80ch; margin-inline: auto; }
.app-footer__credit { margin-top: 8px; font-weight: 600; color: var(--muted); }
.app-footer__credit a { color: var(--primary); font-weight: 700; text-decoration: none; }
.app-footer__credit a:hover { color: var(--primary-dark); text-decoration: underline; }

/* ------------------------------ Breakpoints ------------------------------ */
@media (min-width: 560px) {
  .summary__inner { grid-template-columns: repeat(4, 1fr); }
  .sim-results { grid-template-columns: repeat(4, 1fr); }
  .custom-form { grid-template-columns: 1fr 1fr; }
  .check-row,
  .custom-plan,
  .form-error { grid-column: 1 / -1; }
}

@media (min-width: 720px) {
  body { font-size: 15px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .needs { grid-template-columns: repeat(2, 1fr); }
  .course-head { display: grid; }
  .container { padding-top: 24px; }
}

@media (min-width: 1024px) {
  .cards { grid-template-columns: repeat(4, 1fr); }
}

/* Hide chrome on very small screens to keep the header on one line. */
@media (max-width: 460px) {
  .brand__sub { display: none; }
  .user-chip__name { display: none; }
  .sync { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; animation: none !important; }
}

/* ----------------------------- ECTS distribution ------------------------- */
.distribution {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.donut-wrap { position: relative; width: 180px; height: 180px; margin: 0 auto; }
.donut { width: 180px; height: 180px; display: block; }
.donut__seg { transition: stroke-dasharray .45s cubic-bezier(.22,1,.36,1), stroke-dashoffset .45s cubic-bezier(.22,1,.36,1); }
.donut__center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.donut__total { font-size: 32px; font-weight: 800; letter-spacing: -.03em; color: var(--blue-900); line-height: 1; }
.donut__sub { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 4px; }
.legend { display: grid; gap: 9px; }
.legend__row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; }
.legend__dot { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.legend__label { font-size: 13px; font-weight: 600; }
.legend__val { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (min-width: 640px) {
  .distribution { grid-template-columns: 180px 1fr; gap: 30px; padding: 22px 26px; }
}

/* ------------------------------ Grade target ----------------------------- */
.target {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.target__controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 18px; margin-bottom: 16px; }
.target__field { display: flex; flex-direction: column; gap: 5px; }
.target__field span { font-size: 12px; font-weight: 700; color: var(--muted); }
.target__field .input { width: 150px; }
.target__hint { font-size: 12.5px; flex: 1 1 240px; }
.target__results { display: grid; gap: 10px; }
.target-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.target-row--secured { background: linear-gradient(180deg, var(--ok-soft), var(--surface) 70%); border-color: var(--ok-border); }
.target-row--impossible { background: linear-gradient(180deg, var(--danger-soft), var(--surface) 70%); border-color: oklch(0.88 0.06 26); }
.target-row__band { font-size: 14px; font-weight: 800; }
.target-row__th { font-size: 12px; font-weight: 600; color: var(--muted); }
.target-row__sub { font-size: 11.5px; color: var(--muted); font-weight: 600; margin-top: 3px; }
.target-row__need { font-size: 14px; font-weight: 800; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.target-row__need.is-ok { color: var(--ok); }
.target-row__need.is-bad { color: var(--danger); }

/* ------------------------------ Per-semester ----------------------------- */
.semester { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 720px) { .semester { grid-template-columns: repeat(2, 1fr); } }
.sem-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.sem-card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.sem-card__title { font-size: 15px; font-weight: 700; }
.sem-card__stats { font-size: 12.5px; color: var(--muted); font-weight: 600; text-align: right; }
.sem-list { display: flex; flex-direction: column; gap: 7px; }
.sem-course {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
}
.sem-course__code { font-size: 12px; font-weight: 800; color: var(--blue-800); white-space: nowrap; }
.sem-course__title { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sem-course__grade { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.sem-empty {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* ==========================================================================
   Excel import — modal, preview table, stat chips, toasts
   ========================================================================== */

/* Overlay + modal shell */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: oklch(0.30 0.07 262 / .55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal {
  background: var(--surface);
  width: 100%;
  max-width: 960px;
  max-height: 92vh;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px oklch(0.30 0.07 262 / .30);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-up .22s cubic-bezier(.22,1,.36,1);
}
.modal--narrow { max-width: 560px; }
@keyframes modal-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }

.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.modal__title { font-size: 16px; font-weight: 700; }
.modal__close {
  border: none; background: var(--surface-2); color: var(--muted);
  width: 32px; height: 32px; border-radius: 9px; font-size: 15px; cursor: pointer;
  transition: background .15s, color .15s;
}
.modal__close:hover { background: var(--blue-100); color: var(--primary-dark); }

.modal__body { padding: 16px 18px; overflow: auto; -webkit-overflow-scrolling: touch; }

.custom-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 13px;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.form-field span,
.check-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.form-field--wide { grid-column: 1 / -1; }
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}
.check-row input { width: 16px; height: 16px; accent-color: var(--primary); }
.custom-plan {
  display: grid;
  grid-template-columns: minmax(140px, 180px) 1fr;
  align-items: end;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--blue-200);
  border-radius: var(--radius-sm);
  background: var(--blue-50);
}
.custom-plan p { margin: 0 0 4px; font-size: 12.5px; }
.form-error {
  margin: 0;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid oklch(0.88 0.06 26);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
}

.modal__foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.modal__foot-actions { display: flex; gap: 8px; }
.btn.is-loading { opacity: .75; cursor: progress; }

/* Warnings */
.xls-warnings { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.xls-warn {
  background: var(--warn-soft); color: oklch(0.42 0.10 70);
  border: 1px solid var(--warn-border); border-radius: 9px;
  padding: 8px 12px; font-size: 13px;
}

/* Stat chips */
.xls-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.xls-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px 13px;
  display: flex; flex-direction: column; gap: 1px;
}
.xls-stat--ok { background: var(--ok-soft); border-color: var(--ok-border); }
.xls-stat--warn { background: var(--warn-soft); border-color: var(--warn-border); }
.xls-stat__value { font-size: 18px; font-weight: 800; line-height: 1.1; }
.xls-stat__label { font-size: 11px; color: var(--muted); font-weight: 600; }

/* Preview table */
.xls-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 11px; -webkit-overflow-scrolling: touch; }
.xls-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
.xls-table th, .xls-table td { padding: 9px 11px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.xls-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2);
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted);
}
.xls-table tbody tr:last-child td { border-bottom: none; }
.xls-row--passed { background: var(--ok-soft); }
.xls-row--unmatched { background: var(--danger-soft); }
.xls-code { font-weight: 700; white-space: nowrap; }
.xls-title { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xls-grade .g-pass { color: var(--ok); font-weight: 700; }
.xls-grade .g-fail { color: var(--danger); font-weight: 700; }
.xls-grade .g-was { color: var(--warn); font-size: 11px; }

.m-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 7px; white-space: nowrap; }
.m-badge.m-ok { background: var(--ok-soft); color: var(--ok); }
.m-badge.m-no { background: var(--danger-soft); color: var(--danger); }

.xls-action {
  border: 1px solid var(--border-strong);
  border-radius: 9px; padding: 5px 8px; font-size: 12.5px; background: var(--surface);
  max-width: 200px;
}
.xls-action:disabled { background: var(--surface-2); color: var(--muted); }

/* Toasts */
.toast-container {
  position: fixed; left: 0; right: 0; bottom: 16px; z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 12px;
}
.toast {
  pointer-events: auto;
  max-width: 460px; width: fit-content;
  background: var(--blue-900); color: #fff;
  padding: 11px 16px; border-radius: 11px;
  font-size: 13.5px; font-weight: 500;
  box-shadow: 0 8px 24px oklch(0.32 0.10 263 / .35);
  opacity: 0; transform: translateY(12px);
  transition: opacity .25s, transform .25s;
}
.toast--show { opacity: 1; transform: none; }
.toast--success { background: oklch(0.42 0.12 150); }
.toast--error { background: oklch(0.45 0.18 26); }
.toast--warn { background: oklch(0.45 0.11 70); }

@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 24px; }
  .modal { border-radius: 20px; }
  .xls-stats { grid-template-columns: repeat(4, 1fr); }
}
