/* UC Degree Checker & Planner. Utilitarian: flat, square, dense, 1px borders. */

:root {
  --uc-red: #c20000;        /* UC brand red (canterbury.ac.nz stylesheet) */
  --uc-red-dark: #9b0000;
  --uc-red-bright: #eb0000;
  --uc-blue: var(--uc-red);        /* accent aliases kept for markup reuse */
  --uc-blue-dark: var(--uc-red-dark);
  --green: #2e7d32;
  --green-fill: #e8f5e9;
  --red: #cc0011;
  --red-fill: #fdecea;
  --gold: #d0bf7d;
  --gold-fill: #fbf6e7;
  --ink: #1a1918;
  --grey: #6b6c6b;
  --line: #999;
  --panel-head: #e8e8e8;
  --bg: #f2f2f2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 13px/1.45 "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 8px 14px;
  background: var(--uc-red);       /* UC primary red */
  color: #fff;
}
header h1 { margin: 0; font-size: 16px; display: inline; }
header .brand .sub { display: block; font-size: 14px; font-weight: 700; }
header .sub { font-size: 11px; margin-left: 10px; }
.health { font-size: 11px; }
.exportbar { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #fff; }
.exportbar label { color: #fff; margin: 0; font-size: 11px; }
/* Draggable bookmarklet install link; dashed border hints it is not a normal button. */
.exportbar .bookmarklet { color: #fff; font-size: 11px; padding: 2px 6px; border: 1px dashed rgba(255, 255, 255, 0.55); text-decoration: none; cursor: grab; margin-right: 8px; }
.exportbar .bookmarklet:hover { background: rgba(255, 255, 255, 0.12); }
.exportbar .filebtn { color: var(--ink); }
.exportbar select { width: auto; margin: 0; font-size: 11px; max-width: 260px; }
.exportbar .filebtn { font-size: 11px; padding: 2px 6px; }
header .right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

main { padding: 10px 14px 20px; max-width: 1500px; margin: 0 auto; }

.setup {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 10px;
}
@media (max-width: 1100px) { .setup { grid-template-columns: 1fr; } }

.card {
  background: #fff;
  border: 1px solid var(--line);
  padding: 0;
}
.card h2 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--panel-head);
  border-bottom: 1px solid var(--line);
  padding: 5px 8px;
}
.card > *:not(h2) { margin-left: 8px; margin-right: 8px; }
.card > *:last-child { margin-bottom: 8px; }

label { display: block; font-size: 11px; color: #333; margin: 8px 8px 2px; }
.checkline {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; margin: 6px 8px 0;
}
.checkline input { margin: 0; }

input[type="search"], input[type="text"], textarea, select {
  width: calc(100% - 16px);
  font: inherit;
  font-size: 12px;
  padding: 3px 5px;
  border: 1px solid var(--line);
  background: #fff;
  margin: 0 8px;
}
textarea { resize: vertical; font-family: Consolas, "Courier New", monospace; }
select[multiple], select[size] { padding: 1px; }
select option { padding: 1px 4px; }

.qual-title { font-weight: 700; margin: 8px 8px 2px; }
.qual-info details { margin: 6px 8px 0; }
.qual-info summary { cursor: pointer; font-size: 12px; color: var(--uc-blue-dark); }
#rules-text {
  font-size: 11px;
  line-height: 1.5;
  font-family: Consolas, "Courier New", monospace;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 6px;
  overflow: auto;
  max-height: 320px;
  white-space: pre-wrap;
  margin: 4px 0 0;
}

.chips {
  display: flex; flex-wrap: wrap; gap: 3px;
  margin: 6px 8px 0; min-height: 18px;
}
.chip {
  font-size: 11px;
  font-family: Consolas, "Courier New", monospace;
  background: var(--gold-fill);
  border: 1px solid var(--gold);
  padding: 0 4px;
}
.chip.bad { background: var(--red-fill); border-color: var(--red); color: var(--red); }
/* Transcript course chips shade by credit weight, matching the graduation
   widget: the standard 15-pt fill, a 0-pt course white with a grey border,
   anything heavier a darker grey. Scoped to #course-chips so the plain gold
   .chip elsewhere (admin, adversarial) is untouched. Invalid stays red. */
#course-chips .chip { background: #eaeef2; border-color: #d0d7de; color: #24292f; }
#course-chips .chip.w0 { background: #fff; border-color: #b1b8c0; }
#course-chips .chip.wbig { background: #c2c8d0; border-color: #aab2bd; }
#course-chips .chip.bad { background: var(--red-fill); border-color: var(--red); color: var(--red); }
/* Virtual courses (transfer credit, CODE:points{equivalents}) and real-code
   points overrides: orange, matching the graduation widget's transfer chip. */
#course-chips .chip.virtual { background: #ffd8a8; border-color: #e8a13c; color: #24292f; }
.chips .count { font-size: 11px; color: var(--grey); align-self: center; }

.row { display: flex; align-items: center; gap: 6px; margin: 8px 8px 0; flex-wrap: wrap; }
.note { font-size: 11px; color: var(--green); margin: 6px 8px 0; }
.note.bad { color: var(--red); }

.dropzone { border: 1px solid var(--line); }
.dropzone.dragging { outline: 2px dashed var(--uc-blue); outline-offset: -4px; }
.drophint { font-size: 11px; color: var(--grey); margin: 4px 8px 0; }

.filebtn {
  display: inline-block;
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--panel-head);
  padding: 3px 8px;
  cursor: pointer;
  margin: 0;
}
.filebtn input { display: none; }

button {
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel-head);
  padding: 3px 8px;
}
button:hover:not(:disabled) { background: #ddd; }
button:disabled { opacity: 0.5; cursor: wait; }
.ghost {
  text-decoration: none; color: var(--ink); display: inline-block;
  border: 1px solid var(--line); background: var(--panel-head);
  padding: 3px 8px; font-size: 13px; line-height: 1.2; cursor: pointer;
}
a.ghost:hover { background: #ddd; }
.row h3 { margin: 0; }

.actions { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 8px 0; }
.act.primary {
  background: var(--uc-blue-dark);
  color: #fff;
  border-color: var(--uc-blue-dark);
  font-weight: 700;
}
.act.primary:hover:not(:disabled) { background: var(--uc-blue); }

.param-row { display: flex; gap: 4px; margin: 6px 8px 0; align-items: stretch; flex-wrap: wrap; }
.param-row input[type="text"] { flex: 1 1 130px; width: auto; margin: 0; }
.param-row select { flex: 1 1 130px; width: auto; margin: 0; }

/* Results */
#results { margin-top: 12px; }

.verdict {
  border: 2px solid var(--line);
  background: #fff;
  padding: 8px 10px;
  font-size: 15px;
  font-weight: 700;
}
.verdict.ok { background: var(--green-fill); border-color: var(--green); color: var(--green); }
.verdict.no { background: var(--red-fill); border-color: var(--red); color: var(--red); }
.verdict.neutral { background: #f2f2f2; border-color: #1a1918; color: #1a1918; }

.summary { margin: 6px 0 0; font-size: 13px; }
.warnings { margin: 4px 0 0; padding-left: 18px; }
.warnings li { font-size: 12px; color: #7a6000; }
.warnings li.error { color: var(--red); font-weight: 600; background: none; border: none; padding: 0; }
.warnings li.approval { color: var(--green); font-weight: 600; background: none; border: none; padding: 0; }

.error {
  margin-top: 8px;
  background: var(--red-fill);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 6px 8px;
  font-size: 13px;
}

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
@media (max-width: 1100px) { .result-grid { grid-template-columns: 1fr; } }

.panel {
  background: #fff;
  border: 1px solid var(--line);
  padding: 8px 10px;
  overflow: auto;
}
.panel h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

#allocation-table { border-collapse: collapse; width: 100%; font-size: 12px; }
#allocation-table td { border: 1px solid #ccc; padding: 2px 6px; vertical-align: top; }
#allocation-table td.ref, #compare-allocation-table td.ref { font-weight: 700; white-space: nowrap; }
#allocation-table td.codes, #compare-allocation-table td.codes { font-family: Consolas, "Courier New", monospace; }

#detail-body { font-size: 12px; }
#detail-body table { border-collapse: collapse; width: 100%; }
#detail-body td, #detail-body th {
  border: 1px solid #ccc;
  padding: 2px 6px;
  text-align: left;
  font-size: 12px;
}
#detail-body th { background: var(--panel-head); }
#detail-body .mono { font-family: Consolas, "Courier New", monospace; }
/* Course codes inside the course-info table are themselves lookups. */
#detail-body button.codelink {
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: Consolas, "Courier New", monospace; font-size: inherit;
  color: var(--uc-blue-dark); text-decoration: underline;
}
#detail-body button.codelink:hover { color: var(--uc-blue); }
/* The truncation control reads as an action, not a course code. */
#detail-body button.morelink {
  font-family: inherit;
  font-style: italic;
  color: var(--uc-grey-text, #727779);
}
#detail-body .yes { color: var(--green); font-weight: 700; }
#detail-body .no { color: var(--red); font-weight: 700; }
#detail-body ul { margin: 0; padding-left: 18px; }

#svg-panel { margin-top: 10px; }
#svg-panel .row { margin: 0 0 6px; }
.svg-scroll { overflow: auto; max-height: 640px; border: 1px solid var(--line); background: #fff; }
.svg-scroll img, .svg-scroll svg { display: block; }
.svg-scroll.fit svg, .svg-scroll.fit img { width: 100%; height: auto; }

footer {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px 14px;
  font-size: 11px;
  color: var(--grey);
  max-width: 1500px;
  margin: 0 auto;
}

/* Solver internals in the footer, beside the solve time. Read from the solve
   that already ran (no extra solve). Amber when a stat likely signals an
   issue (warnings, rule errors, or all parts met but degree-wide short). */
.solver-debug { font-variant-numeric: tabular-nums; }
.solver-debug .solver-flag { color: var(--amber, #9a6700); font-weight: 600; }
.solver-debug.flag { color: var(--amber, #9a6700); }

.addbtn { margin-top: 4px; }

/* Compare mode: a debug capsule's captured result locked beside the live
   one. The pair never stacks; a narrow window scrolls sideways instead,
   because the comparison only works with both columns in view. */
#results-wrap.comparing {
  display: grid;
  grid-template-columns: minmax(430px, 1fr) minmax(430px, 1fr);
  gap: 10px;
  align-items: start;
  overflow-x: auto;
}
#compare-pane, #results-wrap.comparing #results {
  background: #fff;
  border: 1px solid var(--line);
  padding: 8px 10px;
  margin-top: 12px;
}
/* One column per pane, so the panels align with the compare side. */
#results-wrap.comparing .result-grid { grid-template-columns: 1fr; }

.compare-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.compare-head h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.compare-head .mono-title {
  text-transform: none; letter-spacing: 0; font-weight: 400;
  font-family: Consolas, "Courier New", monospace;
}
.compare-meta { font-size: 11px; color: var(--grey); margin-top: 4px; }
.compare-note {
  font-size: 11px;
  background: var(--gold-fill);
  border: 1px solid var(--gold);
  padding: 4px 8px;
  margin: 8px 0 10px;
}
.compare-note.plain { background: var(--bg); border-color: #ccc; color: var(--grey); }
/* The live pane's header strip only exists while comparing. */
#live-head, #live-meta, #live-note { display: none; }
#results-wrap.comparing #live-head { display: flex; }
#results-wrap.comparing #live-meta, #results-wrap.comparing #live-note { display: block; }

/* A compare-pane element that differs from the live result: gold, so it
   cannot be misread as pass green or fail red. */
.cdiff { background: var(--gold-fill); outline: 1px solid var(--gold); }
.verdict.cdiff { outline: 2px dashed var(--gold); outline-offset: 3px; }
tr.cdiff td { background: var(--gold-fill); }

/* Alignment spacers: blank fill where the other pane has an unmatched row;
   "missing" ones (gold, dashed) name a rule the compare result lacks. */
.cmp-spacer { overflow: hidden; box-sizing: border-box; margin: 3px 0; }
.cmp-spacer.missing {
  background: var(--gold-fill);
  border: 1px dashed var(--gold);
  color: var(--grey);
  font-size: 11px;
  font-style: italic;
  padding: 0 6px;
}
tr.cmp-spacer td { border: none; padding: 0 6px; }
tr.cmp-spacer.missing td {
  background: var(--gold-fill);
  border: 1px dashed var(--gold);
  color: var(--grey);
  font-size: 11px;
  font-style: italic;
}

/* Mirror the live side's spacing: its panels sit in .result-grid, which
   carries a 10px top margin and a 10px row gap. */
#compare-line-status, #compare-allocation { margin-top: 10px; }

#compare-allocation-table { border-collapse: collapse; width: 100%; font-size: 12px; }
#compare-allocation-table td { border: 1px solid #ccc; padding: 2px 6px; vertical-align: top; }

/* Course autocomplete popup (transcript textarea). */
.course-ac {
  position: absolute; z-index: 200; max-height: 240px; overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15); font-size: 12px;
}
.course-ac-row {
  display: flex; gap: 8px; padding: 3px 8px; cursor: pointer;
  align-items: baseline;
}
.course-ac-row.sel { background: #eaeef2; }
.course-ac-code {
  font-family: Consolas, "Courier New", monospace; font-weight: 600;
  white-space: nowrap;
}
.course-ac-title {
  color: var(--grey); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 280px;
}

#debug-bundle { margin-top: 12px; }
/* The heading shares a flex row with the buttons; drop the .panel h3 bottom
   margin so its text sits on the buttons' centre line, not above it. */
#debug-bundle .row h3 { margin: 0; }
.filebtn.disabled { opacity: 0.5; cursor: default; }

.hidden { display: none !important; }

/* Degree freedom list (freedom_plan action) */
#detail-body pre.freedom-list {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px; line-height: 1.55; margin: 0 0 8px;
  white-space: pre-wrap; overflow-x: auto;
}

/* Colour legend under the rules tree diagram */
.svg-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 6px; font-size: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-chip {
  width: 13px; height: 13px; border: 1px solid #888; border-radius: 3px;
  display: inline-block;
}

/* Allocation overlap (Venn) panel under the rules tree */
#venn-panel { margin-top: 10px; }
.venn-note { font-size: 11px; color: var(--grey); margin: 0 0 6px; }
#venn-holder { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.venn-diagram { border: 1px solid var(--line); background: #fff; }
.venn-diagram svg { display: block; }
.venn-caption {
  font-size: 11px; color: var(--grey); padding: 2px 6px 4px;
  border-top: 1px solid #ddd; max-width: 100%;
}
/* SVG text wears ink, never the series colour; fills stay translucent so
   every overlap region shows as a visibly darker blend. */
.venn-set-fill { fill-opacity: 0.28; }
.venn-set-outline { fill: none; stroke-width: 1.5; }
.venn-set-label { font-size: 11px; font-weight: 700; fill: var(--ink); }
.venn-set-sub { font-size: 10px; fill: var(--grey); }
.venn-code { font-family: Consolas, "Courier New", monospace; font-size: 10.5px; fill: var(--ink); }
.venn-more { font-family: Consolas, "Courier New", monospace; font-size: 10px; font-style: italic; fill: var(--grey); }
#venn-regions { margin-top: 8px; }
#venn-regions table { border-collapse: collapse; width: 100%; font-size: 12px; }
#venn-regions td { border: 1px solid #ccc; padding: 2px 6px; vertical-align: top; }
#venn-regions th {
  border: 1px solid #ccc; padding: 2px 6px; text-align: left;
  background: var(--panel-head); font-weight: 700;
}
#venn-regions td.groups { white-space: normal; }
#venn-regions td.codes { font-family: Consolas, "Courier New", monospace; }
#venn-regions td.count { white-space: nowrap; text-align: right; }
#venn-regions .venn-key {
  width: 11px; height: 11px; border: 1px solid #888; display: inline-block;
  vertical-align: -1px; margin-right: 4px;
}
#venn-regions .venn-key.dashed { border-style: dashed; }
/* The no-share marker: a prohibition sign between circles the
   cross-crediting rules bar from sharing, plus its text line. */
.venn-noshare-icon circle { fill: #fff; stroke: var(--grey); stroke-width: 2; }
.venn-noshare-icon line { stroke: var(--grey); stroke-width: 2; }
.venn-noshare-line { font-size: 11px; color: var(--grey); margin: 0 0 4px; }

/* Export health check report (the qual card's data-quality scan) */
.health-report {
  margin-top: 8px; border: 1px solid #d0d7de; border-radius: 6px;
  padding: 6px 8px; max-height: 320px; overflow-y: auto;
  font-size: 12px; background: #fafbfc;
}
.health-report .hf-code {
  font-family: Consolas, "Courier New", monospace; font-weight: 700;
  margin: 6px 0 2px; font-size: 12px;
}
.health-report .hf-code:first-child { margin-top: 0; }
.health-report .hf-item {
  display: flex; align-items: baseline; gap: 6px; padding: 1px 0 1px 10px;
}
.health-report .sev {
  flex: none; font-size: 10px; font-weight: 700; text-transform: uppercase;
  border-radius: 3px; padding: 0 4px; border: 1px solid;
}
.health-report .sev.error {
  background: var(--red-fill); border-color: var(--red); color: #1a1918;
}
.health-report .sev.warn,
.health-filters .sev.warn {
  background: #fff8e0; border-color: #b08900; color: #7a6000;
}
.health-report .sev.notice,
.health-filters .sev.notice {
  background: #f2f2f2; border-color: #999; color: #666;
}
/* Notices are routine drift: grey the whole line so real problems pop.
   Error/warn messages stay plain black; the badge alone carries the
   colour. */
.health-report .hf-item.sev-notice .hf-msg { color: #777; }
.health-filters {
  display: flex; gap: 14px; margin-top: 6px; font-size: 12px;
  align-items: center;
}
.health-filters .hf-filter {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
}
.health-filters .sev {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  border-radius: 3px; padding: 0 4px; border: 1px solid;
}
.health-filters .sev.error {
  background: var(--red-fill); border-color: var(--red); color: #1a1918;
}
.health-filters .hf-count { color: #666; }
/* The counts summary is information, not a verdict: plain black, with the
   .bad red kept for a failed request only. */
#health-check-summary { color: #1a1918; }
#health-check-summary.bad { color: var(--red); }
.health-report .hf-part {
  flex: none; font-family: Consolas, "Courier New", monospace;
  color: #555;
}
.health-report .hf-msg { min-width: 0; }
