:root {
  --kit: #009682;
  --kit-dark: #00705f;
  --kit-light: #e5f4f2;
  --bg: #f4f6f8;
  --card: #fff;
  --text: #1d2733;
  --muted: #6b7785;
  --line: #dde3e9;
  --err: #c62828;
  --warn: #d48806;
  --info: #3a7bd5;
  --ok: #2e7d32;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--kit-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 20px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
h4 { font-size: 14px; margin: 12px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.r { text-align: right; }
.c { text-align: center; }
.spacer { flex: 1; }
select, input[type=search], input[type=number], input[type=text] {
  font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: inherit; min-width: 0;
}
select:focus, input:focus { outline: 2px solid var(--kit); outline-offset: -1px; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; padding: 10px 22px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 16px; }
.brand small { color: var(--muted); }
.logo { background: var(--kit); color: #fff; font-weight: 800; letter-spacing: 1px; padding: 6px 9px; border-radius: 6px; }
#tabs { display: flex; gap: 4px; flex-wrap: wrap; }
#tabs button { border: 0; background: none; font: inherit; padding: 8px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; }
#tabs button:hover { background: var(--bg); color: var(--text); }
#tabs button.active { background: var(--kit-light); color: var(--kit-dark); }
main { padding: 18px 22px 40px; max-width: 1700px; margin: 0 auto; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 0 0 24px; }

/* ---------- generic ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--kit); background: var(--kit); color: #fff; font: inherit; font-weight: 600; padding: 6px 12px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--kit-dark); }
.btn.ghost { background: #fff; color: var(--kit-dark); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--kit); }
.btn.danger { color: var(--err); }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn.danger.small { background: #fff; border-color: #f0c4c4; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: #e8edf2; color: #455; margin-right: 3px; }
.badge.k-V { background: #e3eefc; color: #1f5fbf; }
.badge.k-S { background: #fdf0dc; color: #a66300; }
.badge.k-P { background: #f3e5f5; color: #7b1fa2; }
.badge.k-MA { background: #222; color: #fff; }
.badge.k-Q { background: #e7f6ee; color: #0d6b45; }
.badge.stamm { background: #fff3c4; color: #8a6d00; }
.chip { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #eef1f4; color: var(--muted); margin: 1px 3px 1px 0; }
.chip.on { background: var(--kit-light); color: var(--kit-dark); font-weight: 600; }
.chip i { font-style: normal; opacity: .75; }
.ok-tag { background: #e6f4ea; color: var(--ok); font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.conflict-tag { background: #fdecea; color: var(--err); font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.warn-text { color: var(--warn); }
.conflict-text { color: var(--err); }
.empty { color: var(--muted); padding: 18px; text-align: center; }
.hint { background: #fff8e1; border: 1px solid #ffe08a; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }
table { border-collapse: collapse; width: 100%; }
table.mini th, table.mini td, table.catalog th, table.catalog td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
table.mini th, table.catalog th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; }
table.mini th.r, table.mini td.r, table.catalog td.r, table.catalog th.r { text-align: right; }
tr.grp td { background: #f6f8fa; font-weight: 600; font-size: 12px; }
tr.planned td { background: #f2faf8; }

/* ---------- setup ---------- */
.setup-grid { display: grid; grid-template-columns: 140px 90px repeat(3, minmax(180px, 1fr)); gap: 10px; }
.setup-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); }
.setup-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.setup-actions:first-child { margin-top: 0; }

/* ---------- plan board ---------- */
.plan-layout { display: grid; grid-template-columns: 1fr 340px; gap: 14px; align-items: start; }
.sem-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.sem-col { background: #eaeef2; border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 200px; transition: background .15s; }
.sem-col.drop-over { background: var(--kit-light); outline: 2px dashed var(--kit); }
.sem-col header { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.lp-pill { font-weight: 700; font-size: 12px; background: #fff; padding: 2px 8px; border-radius: 10px; }
.lp-pill.good { color: var(--ok); }
.lp-pill.bad { color: var(--err); }
.cards { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.btn.add { background: transparent; color: var(--kit-dark); border: 1px dashed #b9c4ce; justify-content: center; }
.btn.add:hover { background: #fff; border-color: var(--kit); }
.mcard { background: #fff; border-radius: 8px; padding: 8px 10px; box-shadow: var(--shadow); border-left: 4px solid hsl(var(--h) 55% 50%); }
.mcard.dragging { opacity: .4; }
.drag { cursor: grab; color: #b0bac4; font-weight: 700; letter-spacing: -1px; padding: 0 4px 0 0; user-select: none; }
.drag:active { cursor: grabbing; }
.mcard select, .mcard input, .mcard button, .mcard a, .mcard label { position: relative; z-index: 1; }
.mcard.has-error { box-shadow: 0 0 0 1.5px var(--err); }
.mcard.has-warn { box-shadow: 0 0 0 1.5px #f0b84a; }
.mcard.done { background: #f3faf4; }
.mc-top { display: flex; gap: 6px; align-items: flex-start; }
.mc-name { font-weight: 600; flex: 1; color: var(--text); line-height: 1.3; }
.x { border: 0; background: none; font-size: 17px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 2px; }
.x:hover { color: var(--err); }
.mc-meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin: 4px 0 6px; flex-wrap: wrap; }
.lp-in { width: 46px; padding: 1px 4px !important; }
.mc-field { width: 100%; font-size: 12px; padding: 4px 6px; }
.mc-issues { list-style: none; margin: 6px 0 0; padding: 0; font-size: 11.5px; }
.mc-issues li, .issues li { padding-left: 16px; position: relative; margin-bottom: 2px; }
.mc-issues li::before, .issues li::before { position: absolute; left: 0; font-weight: 700; }
li.error { color: var(--err); } li.error::before { content: "✖"; }
li.warn { color: #9a6300; } li.warn::before { content: "⚠"; }
li.info { color: var(--info); } li.info::before { content: "ℹ"; }
.mc-exam { font-size: 11.5px; color: #8a6d00; background: #fff8e1; border-radius: 5px; padding: 2px 6px; margin-top: 6px; }
.mc-grade { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.suggest { margin: 8px 0 12px; }
.suggest-why { font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.suggest-row { display: flex; gap: 8px; align-items: center; font-size: 12.5px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.suggest-row a { flex: 1; }
#ex-q { width: 100%; margin-top: 10px; }
.mc-grade input[type=number] { width: 64px; padding: 2px 6px; font-size: 12px; }

.req-panel { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; }
.req-panel h3:first-child { margin-top: 0; display: flex; justify-content: space-between; align-items: center; }
.req { margin-bottom: 9px; }
.req.sub { margin-left: 14px; font-size: 12.5px; }
.req-top { display: flex; justify-content: space-between; gap: 8px; }
.req.ok .req-top span:first-child { color: var(--ok); }
.req.nok .req-top span:first-child { color: var(--err); }
.req-val { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; font-size: 12px; }
.bar { height: 5px; border-radius: 3px; background: #e7ebef; margin-top: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: #f0a64a; }
.req.ok .bar i { background: var(--kit); }
.req-note { font-size: 11.5px; color: var(--warn); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 6px; }
.stats div { background: var(--bg); border-radius: 8px; padding: 8px; text-align: center; }
.stats b { display: block; font-size: 20px; }
.stats span { font-size: 11px; color: var(--muted); }
.issues { list-style: none; padding: 0; margin: 0; font-size: 12px; }

/* ---------- catalog ---------- */
.filters .target { background: var(--kit-light); padding: 8px 10px; border-radius: 8px; margin-bottom: 10px; }
.filter-grid { display: grid; grid-template-columns: 2fr 1.4fr repeat(4, 1fr); gap: 8px; }
.filter-checks { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; align-items: center; font-size: 13px; }
.table-scroll { overflow: auto; max-height: min(70vh, 720px); }
.table-scroll.tall { max-height: 480px; }
.table-scroll thead th { position: sticky; top: 0; z-index: 1; }
table.catalog td { font-size: 13px; }
tr.cat-row { cursor: pointer; }
tr.cat-row:hover td { background: #f7fbfa; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 10px; }
.mname { font-weight: 600; }
.ok-dot { color: var(--kit); font-size: 15px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 50; display: flex; justify-content: center; align-items: flex-start; padding: 40px 16px; overflow: auto; }
.modal.hidden { display: none; }
.modal-box { position: relative; background: #fff; border-radius: 12px; width: min(980px, 100%); padding: 22px 26px 26px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal-close { position: absolute; top: 10px; right: 14px; border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--muted); }
.detail-head { border-left: 5px solid hsl(var(--h) 55% 50%); padding-left: 12px; margin-bottom: 12px; }
.detail-head h2 { margin: 2px 0 6px; padding-right: 30px; }
.facts { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 4px; }
.planbox { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; background: var(--bg); border-radius: 8px; padding: 10px; }
.planbox.in { background: var(--kit-light); }
.prereq ul { margin: 4px 0 8px; padding-left: 18px; }
.prereq li.notStarted { color: #8a4b00; }
details { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin: 6px 0; }
details summary { cursor: pointer; font-weight: 600; }
details summary:hover { color: var(--kit-dark); }
.txt p { margin: 4px 0; }
.txt ul { margin: 4px 0; padding-left: 20px; }
.tl-block { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 8px; }
.exam-dates { background: #fff8e1; padding: 4px 8px; border-radius: 6px; margin-top: 4px; }
.checklist { display: flex; flex-direction: column; gap: 6px; }

/* ---------- timetable ---------- */
.sem-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.sem-tabs button { border: 1px solid var(--line); background: #fff; font: inherit; padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.sem-tabs button.active { background: var(--kit); color: #fff; border-color: var(--kit); }
.tt-layout { display: grid; grid-template-columns: 1fr 340px; gap: 14px; align-items: start; }
.tt-grid { display: grid; gap: 0; }
.tt-dh { height: 28px; font-weight: 700; text-align: center; font-size: 13px; }
.tt-day .tt-body { position: relative; border-left: 1px solid var(--line); }
.tt-hours .tt-body { position: relative; }
.tt-hours span { position: absolute; right: 6px; font-size: 11px; color: var(--muted); transform: translateY(-6px); }
.tt-hline { position: absolute; left: 0; right: 0; border-top: 1px solid #edf0f3; }
.tt-block { position: absolute; background: hsl(var(--h) 70% 93%); border-left: 3px solid hsl(var(--h) 55% 45%); border-radius: 5px; padding: 3px 5px; font-size: 11.5px; line-height: 1.25; overflow: hidden; color: hsl(var(--h) 50% 20%); }
.tt-block.clickable { cursor: pointer; }
.tt-block.biweekly { background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255, 255, 255, .55) 6px 12px); }
.tt-block.conflict { outline: 2px solid var(--err); z-index: 2; }
.tt-room { font-size: 10.5px; opacity: .8; }
.tt-hide { position: absolute; top: 1px; right: 2px; border: 0; background: none; cursor: pointer; opacity: 0; font-size: 14px; color: inherit; }
.tt-block:hover .tt-hide { opacity: .7; }
.tt-side { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; }
.tt-side h3:first-child { margin-top: 0; }
.tt-group { border-left: 4px solid hsl(var(--h) 55% 50%); padding: 4px 0 4px 8px; margin-bottom: 10px; }
.tt-gh { font-weight: 600; margin-bottom: 4px; display: flex; justify-content: space-between; }
.tt-item { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; margin-bottom: 4px; cursor: pointer; }
.tt-item.once { opacity: .85; }
#tt-search { width: 100%; }
.tt-res { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }

/* ---------- rules ---------- */
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.links li { margin-bottom: 4px; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: #1d2733; color: #fff; padding: 9px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 60; }
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 1100px) {
  .plan-layout, .tt-layout, .rules-grid { grid-template-columns: 1fr; }
  .req-panel, .tt-side { position: static; max-height: none; }
  .setup-grid { grid-template-columns: 1fr 1fr; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
}
