/* HUVIS Tunniplaan — kujundus vastab Schedule Module v2 maketile.
   Süsteemsed fondid: null välist päringut, kohene renderdus ka võrguta. */

:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --ink: #1b1a18;
  --ink-2: #77736b;
  --ink-3: #8b877f;
  --ink-4: #a8a49c;
  --ink-5: #b5b1a9;

  --line: #e5e2dc;
  --line-2: #ece9e3;
  --line-3: #f4f2ee;
  --line-4: #d8d4cd;

  --accent: #5b3df5;
  --accent-dark: #4326d6;
  --accent-soft: #efeaff;
  --accent-line: #d9cfff;
  --accent-tint: #f8f6ff;

  --err: #a3123f;
  --err-bg: #fde8e6;
  --err-bg-2: #fbeae8;
  --err-line: #f0b4ae;

  --warn: #8a5a00;
  --warn-bg: #fff4d6;
  --warn-bg-2: #fdf4dd;
  --warn-line: #f0dda6;
  --warn-line-2: #eddaa6;
  --warn-accent: #d99a00;

  --ok: #1d6b34;
  --ok-bg: #e8f6ec;
  --ok-bg-2: #e9f7ec;
  --ok-line: #b9dfc4;

  --mute: #f2f0ec;
  --hatch: repeating-linear-gradient(45deg, #f7f5f1 0 4px, #efece5 4px 8px);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb {
  background: #c9c6c0;
  border-radius: 6px;
  border: 3px solid var(--bg);
}

.mono { font-family: var(--mono); }

#app { height: 100vh; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 18px; min-height: 54px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex: 0 0 auto; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 10px; flex: 0 0 auto; }
.brand b { font-weight: 700; font-size: 14px; letter-spacing: .08em; color: var(--accent); }
.brand span { font-size: 13px; color: var(--ink-3); }
.vr { width: 1px; height: 22px; background: var(--line); flex: 0 0 1px; }

.sched-id { display: flex; align-items: center; gap: 10px; min-width: 260px; flex: 1 1 auto; overflow: hidden; }
.sched-id .name {
  display: block; flex: 1 1 130px; font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.sched-id .year { font-family: var(--mono); font-size: 11px; color: var(--ink-3); flex: 0 0 auto; }

.badge {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 4px; flex: 0 0 auto; white-space: nowrap;
}
.badge.draft { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); }
.badge.active { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok-line); }
.badge.archived { background: var(--mute); color: var(--ink-2); border: 1px solid var(--line); }

.segmented { display: flex; gap: 2px; background: var(--mute); padding: 3px; border-radius: 8px; flex: 0 0 auto; }
.segmented > button {
  display: flex; align-items: baseline; gap: 6px;
  font: inherit; font-size: 13px; font-weight: 500;
  padding: 5px 11px; border: 0; border-radius: 6px;
  cursor: pointer; white-space: nowrap;
  color: var(--ink-3); background: transparent;
}
.segmented > button:hover { color: var(--ink); }
.segmented > button[aria-selected="true"] {
  color: var(--ink); background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.09);
}
.segmented .count { font-family: var(--mono); font-size: 10px; color: var(--ink-4); }
.segmented > button[aria-selected="true"] .count { color: var(--accent); }

.spacer { flex: 1; }

/* --- "Lisa uus" menüü: peab olema igalt ekraanilt nähtav --- */

.addwrap { position: relative; flex: 0 0 auto; }
.addbtn {
  display: flex; align-items: center; gap: 6px;
  font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 7px 13px; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  white-space: nowrap;
}
.addbtn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.addbtn .plus { font-size: 15px; line-height: 1; margin-top: -1px; }

.addmenu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  min-width: 230px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 26px rgba(0,0,0,.14);
}
.addmenu button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  font: inherit; font-size: 13px; font-weight: 500; text-align: left;
  padding: 9px 10px; border: 0; border-radius: 7px;
  background: none; color: var(--ink); cursor: pointer;
}
.addmenu button:hover { background: var(--accent-tint); color: var(--accent-dark); }
.addmenu .ico {
  width: 22px; height: 22px; flex: 0 0 22px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.addmenu .hint {
  padding: 7px 10px 4px; font-size: 10.5px; color: var(--ink-3);
  line-height: 1.35; border-top: 1px solid var(--line-3); margin-top: 4px;
}

.search {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 0 10px; height: 32px; background: var(--bg);
  flex: 0 1 250px; min-width: 150px;
}
.search input {
  border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 13px; width: 100%; color: var(--ink);
}
.search .ico { font-size: 13px; color: var(--ink-4); }
.search .clear { cursor: pointer; font-size: 14px; color: var(--ink-3); background: none; border: 0; }

.toast {
  padding: 8px 18px; background: var(--ok-bg); border-bottom: 1px solid var(--ok-line);
  font-size: 13px; font-weight: 600; color: var(--ok); flex: 0 0 auto;
}
.toast.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.toast.err { background: var(--err-bg); border-color: var(--err-line); color: var(--err); }

/* ------------------------------------------------------------------ layout */

.screen { flex: 1; min-height: 0; display: flex; }
.scroll { flex: 1; min-height: 0; overflow: auto; }
.pad { padding: 22px 26px 60px; }
.narrow { max-width: 1080px; margin: 0 auto; }
.wide { max-width: 1180px; margin: 0 auto; }

h1.title { font-size: 20px; font-weight: 700; margin: 0; }
.meta { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.intro { font-size: 13px; color: var(--ink-2); line-height: 1.45; margin: 6px 0 18px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.baseline { align-items: baseline; }
.eyebrow {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-3);
}

/* ------------------------------------------------------------------ buttons */

.btn {
  font: inherit; font-size: 12px; font-weight: 600;
  padding: 7px 12px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #faf9f6; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-dark); }
.btn.ghost { background: var(--surface); border-color: var(--accent-line); color: var(--accent-dark); }
.btn.danger { color: var(--err); border-color: var(--err-line); }
.btn.danger:hover { background: var(--err-bg); }
.btn.sm { padding: 4px 10px; font-size: 11.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------------------------ day grid */

.gridbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px; border-bottom: 1px solid var(--line);
  background: var(--surface); flex-wrap: wrap; overflow: hidden;
}
.daytabs { display: flex; gap: 4px; flex-wrap: wrap; }
.daytab {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 54px; padding: 5px 9px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); font: inherit;
}
.daytab .d { font-size: 12px; font-weight: 600; color: var(--ink); }
.daytab .n { font-family: var(--mono); font-size: 10px; color: var(--ink-4); }
.daytab.empty .d { color: var(--ink-5); }
.daytab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); }
.daytab[aria-selected="true"] .d { color: #fff; }
.daytab[aria-selected="true"] .n { color: #cfc4ff; }

.legend { display: flex; align-items: center; gap: 14px; font-size: 11px; color: var(--ink-3); flex-shrink: 1; overflow: hidden; }
.legend span { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.swatch { width: 10px; height: 10px; border-radius: 3px; border: 1px solid var(--line); }
.swatch.free { background: repeating-linear-gradient(45deg, #f4f2ee 0 3px, #eae7e0 3px 6px); }
.swatch.conflict { background: var(--err-bg); border-color: var(--err-line); }

.movingbar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 18px; background: var(--accent-soft); border-bottom: 1px solid var(--accent-line);
}
.movingbar .lbl {
  font-size: 12px; font-weight: 700; color: var(--accent-dark);
  text-transform: uppercase; letter-spacing: .06em;
}
.movingbar .what { font-size: 13px; font-weight: 600; }
.movingbar .hint { font-size: 12px; color: #6b5fa8; }

.gridwrap { flex: 1; min-height: 0; overflow: auto; background: var(--bg); }
.grid { min-width: 1180px; }

.grid-head {
  display: flex; position: sticky; top: 0; z-index: 6;
  background: var(--surface); border-bottom: 1px solid var(--line-4);
}
.grid-head .corner {
  width: 232px; flex: 0 0 232px; position: sticky; left: 0; z-index: 7;
  background: var(--surface); border-right: 1px solid var(--line-4);
  padding: 8px 12px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3);
}
.grid-head .col {
  flex: 1 1 0; min-width: 132px; padding: 7px 10px;
  border-right: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 1px;
}
.grid-head .col b { font-size: 12px; font-weight: 700; }
.grid-head .col span { font-family: var(--mono); font-size: 10px; color: var(--ink-3); }

.grid-row { display: flex; border-bottom: 1px solid var(--line-2); background: var(--surface); }
.grid-row .rowhead {
  width: 232px; flex: 0 0 232px; position: sticky; left: 0; z-index: 5;
  background: var(--surface); border-right: 1px solid var(--line-4);
  padding: 8px 12px; display: flex; align-items: center; gap: 8px;
}
.grid-row .rowhead .lbl { font-size: 12px; font-weight: 600; line-height: 1.25; }
.grid-row .rowhead .load { font-family: var(--mono); font-size: 10px; color: var(--ink-4); }
.grid-row.noroom .rowhead { background: #fff8f7; }
.grid-row.noroom .rowhead .lbl { color: var(--err); }
.grid-row .rowhead.ph .lbl { color: var(--ink-3); }

.cell {
  flex: 1 1 0; min-width: 132px; border-right: 1px solid var(--line-2);
  padding: 4px; display: flex; flex-direction: column; gap: 3px;
  background: var(--hatch);
}
.cell.filled { background: var(--surface); }
.cell.ok { background: var(--ok-bg-2); cursor: pointer; }
.cell.warn { background: var(--warn-bg-2); cursor: pointer; }
.cell.blocked { background: var(--err-bg-2); cursor: not-allowed; }
.cell.cursor { box-shadow: inset 0 0 0 2px var(--accent); }
.cell .reason { font-size: 9.5px; font-weight: 600; line-height: 1.15; }
.cell.warn .reason { color: var(--warn); }
.cell.blocked .reason { color: var(--err); }

.card {
  border: 1px solid var(--t-line, var(--line)); border-left: 3px solid var(--t-edge, #c9c6c0);
  border-radius: 5px; padding: 4px 6px; background: var(--t-bg, var(--surface));
  display: flex; flex-direction: column; gap: 2px; cursor: grab; text-align: left;
  font: inherit; user-select: none; -webkit-user-select: none;
}
.card:active { cursor: grabbing; }
.card .t { font-size: 11px; font-weight: 600; line-height: 1.2; color: var(--ink); }
.card .s { font-family: var(--mono); font-size: 9.5px; color: var(--ink-2); line-height: 1.2; }
.card .b { font-size: 9px; font-weight: 700; letter-spacing: .04em; color: var(--err); }
.card.conflict { border-color: var(--err-line); background: var(--err-bg); border-left-color: var(--err); }
.card.selected { background: var(--accent-soft); border-color: var(--accent-line); border-left-color: var(--accent); }
.card.hover { border-color: var(--accent); background: #f6f3ff; }
.card.dim { opacity: .45; }
.card.outpool { border-left-color: var(--warn-accent); }

/* ------------------------------------------------------------------ pastelltoonid
   Iga aine oma püsiv toon (js/tone.js). Ilma selleta on ruudustik sadu ühesuguseid
   valgeid ristkülikuid ja midagi ei leia. Taust on tahtlikult kahvatu: peal olev
   --ink tekst peab jääma loetavaks ja konflikti punane peab silma torkama. */
.tone-0  { --t-bg: #e9eefc; --t-line: #c3d1ee; --t-edge: #7d9fdc; }
.tone-1  { --t-bg: #fdeaef; --t-line: #f2c6d2; --t-edge: #dd8ba5; }
.tone-2  { --t-bg: #e9f5ea; --t-line: #c4e0c6; --t-edge: #79b47e; }
.tone-3  { --t-bg: #fdf1e0; --t-line: #f0d7b2; --t-edge: #d9a65c; }
.tone-4  { --t-bg: #f1eafb; --t-line: #d8c8f0; --t-edge: #a486d9; }
.tone-5  { --t-bg: #e4f3f5; --t-line: #bcdde2; --t-edge: #6cb0bc; }
.tone-6  { --t-bg: #fdece7; --t-line: #f5cec3; --t-edge: #e08e77; }
.tone-7  { --t-bg: #f0f5e1; --t-line: #d6e2b6; --t-edge: #a3bd63; }
.tone-8  { --t-bg: #e4f2fb; --t-line: #bfdcf0; --t-edge: #6faed9; }
.tone-9  { --t-bg: #f8eaf7; --t-line: #e8c8e5; --t-edge: #c084ba; }
.tone-10 { --t-bg: #e5f6ef; --t-line: #bee2d3; --t-edge: #6fbd9d; }
.tone-11 { --t-bg: #f5eee7; --t-line: #e0d0be; --t-edge: #b39371; }

/* ------------------------------------------------------------------ lohistamine
   Kummitus elab <body> küljes, seega ta ei kao ruudustiku uuestirenderdamisel. */
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 100; margin: 0;
  pointer-events: none; opacity: .96; cursor: grabbing;
  box-shadow: 0 10px 24px rgba(27, 26, 24, .24);
  outline: 2px solid var(--ok); outline-offset: 1px;
  transform: translate(-9999px, -9999px);
}
.drag-ghost.warn { outline-color: var(--warn-accent); }
.drag-ghost.bad { outline-color: var(--err-line); opacity: .55; }

body.dragging { cursor: grabbing; }
/* Lähtekaart jääb paistma, aga kahvatuna — on näha, kust tund liigub. */
body.dragging .card.selected { opacity: .4; border-style: dashed; }
/* Vabad lahtrid saavad punktiirpiirde: kuhu üldse tohib kukutada. */
body.dragging .cell.ok, body.dragging .cell.warn {
  outline: 1px dashed var(--ok-line); outline-offset: -3px;
}
body.dragging .cell.warn { outline-color: var(--warn-line-2); }

/* Kursori all olev lahter. Peab tulema .cell.cursor järel, et üle kirjutada.
   NB: klass on `drop-here`, mitte `drop` — `.drop` on impordiekraani failitsoon
   (padding 34px) ja see venitas ruudustiku rea lohistamise ajal kõrgemaks. */
.cell.drop-here { box-shadow: inset 0 0 0 2px var(--accent); }
.cell.ok.drop-here { box-shadow: inset 0 0 0 2px var(--ok); background: var(--ok-bg); }
.cell.warn.drop-here { box-shadow: inset 0 0 0 2px var(--warn-accent); background: var(--warn-bg); }
.cell.blocked.drop-here { box-shadow: inset 0 0 0 2px var(--err); background: var(--err-bg); }

/* Põhjus ainult sihtlahtris. Kõigis lahtrites korraga oli see punase teksti müür,
   millest ei saanud aru, milline neist praegu kehtib. */
/* Lahtris hoiab põhjus alati ruumi kinni, aga nähtav on ta ainult klaviatuuriga
   liikudes. Lohistades näitab põhjust kummituse silt (.drag-note), mis ei nihuta
   ridu. Kõigis lahtrites korraga oli see punase teksti müür, millest ei saanud
   aru, milline neist praegu kehtib. */
.cell .reason { display: none; }
.cell.cursor .reason { display: block; }

.drag-note {
  position: absolute; top: 100%; left: 0; margin-top: 5px;
  max-width: 260px; padding: 3px 7px; border-radius: 4px;
  background: var(--ink); color: #fff;
  font-family: var(--sans); font-size: 10px; font-weight: 600; line-height: 1.3;
}
.drag-note:empty { display: none; }
.drag-note.bad { background: var(--err); }

/* Riba "Liigutan" on klõpsuga valimise ja klaviatuuri jaoks. Lohistamise ajal
   see ainult nihutaks ruudustikku kursori alt ära — tagasiside annavad niigi
   kummitus ja värvitud lahtrid. */
body.dragging .movingbar { display: none; }

.empty { padding: 40px; text-align: center; font-size: 13px; color: var(--ink-3); }

/* ------------------------------------------------------------------ side panels */

.side {
  width: 296px; flex: 0 0 296px; border-left: 1px solid var(--line);
  background: var(--surface); display: flex; flex-direction: column; min-height: 0;
}
.side.left { border-left: 0; border-right: 1px solid var(--line); }
.side-head { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.side-head .hint { font-size: 11px; color: var(--ink-3); margin-top: 3px; line-height: 1.35; }
.side-body { flex: 1; overflow: auto; padding: 8px; }

.chip {
  border: 1px solid var(--t-line, var(--line)); border-left: 3px solid var(--t-edge, var(--line-4));
  border-radius: 7px; padding: 8px 10px;
  margin-bottom: 6px; background: var(--t-bg, var(--bg)); cursor: grab;
  display: flex; flex-direction: column; gap: 3px; width: 100%; text-align: left; font: inherit;
  user-select: none; -webkit-user-select: none;
}
.chip:hover { filter: brightness(.985); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); }
.chip .t { font-size: 12px; font-weight: 600; line-height: 1.25; }
.chip .s { font-family: var(--mono); font-size: 10px; color: var(--ink-2); }
.chip .gap { font-family: var(--mono); font-size: 10px; font-weight: 500; color: var(--err); }
.chip .rooms { font-size: 10px; color: var(--ink-4); }

/* ------------------------------------------------------------------ worklist */

.buckets { display: flex; gap: 6px; flex-wrap: wrap; }
.bucket {
  display: flex; align-items: baseline; gap: 6px;
  padding: 6px 10px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); font: inherit;
}
.bucket[aria-selected="true"] { background: var(--mute); border-color: #c9c6c0; }
.bucket .lbl { font-size: 12px; font-weight: 600; }
.bucket .n { font-family: var(--mono); font-size: 11px; color: var(--ink-4); }
.bucket.has .n { color: var(--warn); }
.bucket.clash.has .n { color: var(--err); }

.qitem {
  border: 1px solid var(--line); border-left: 3px solid #e0c98a;
  border-radius: 7px; padding: 9px 11px; margin-bottom: 6px;
  background: var(--bg); cursor: pointer; display: flex; flex-direction: column; gap: 3px;
  width: 100%; text-align: left; font: inherit;
}
.qitem:hover { background: #faf9f6; }
.qitem.active { background: var(--accent-soft); border-color: var(--accent); border-left-color: var(--accent); }
.qitem.clash { border-left-color: var(--err); }
.qitem .t { font-size: 12.5px; font-weight: 600; line-height: 1.25; flex: 1; }
.qitem .tag { font-family: var(--mono); font-size: 10px; font-weight: 500; color: var(--warn); }
.qitem.clash .tag { color: var(--err); }
.qitem .s { font-family: var(--mono); font-size: 10px; color: var(--ink-2); }

.facts { display: flex; gap: 22px; margin: 16px 0 22px; flex-wrap: wrap; }
.fact { display: flex; flex-direction: column; gap: 2px; }
.fact .k {
  font-size: 10px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-4);
}
.fact .v { font-size: 13px; font-weight: 500; }

.panel { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.panel + .panel { margin-top: 12px; }

.sugg {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px; border-bottom: 1px solid var(--line-3); min-width: 0;
}
.sugg:last-child { border-bottom: 0; }
.sugg .d { font-size: 13px; font-weight: 600; flex: 0 0 74px; }
.sugg .tm { font-family: var(--mono); font-size: 12px; flex: 0 0 104px; color: var(--ink-2); }
.sugg .rm { font-size: 12.5px; flex: 1 1 120px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sugg .nt { font-size: 12px; flex: 1 1 110px; min-width: 0; line-height: 1.3; color: var(--ink-2); }
.sugg .nt.warn { color: var(--warn); }

.matrix { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 10px; }
.matrix .hrow { display: flex; gap: 4px; margin-bottom: 4px; }
.matrix .hrow .sp { width: 46px; flex: 0 0 46px; }
.matrix .hrow .h { flex: 1 1 0; text-align: center; font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.matrix .mrow { display: flex; gap: 4px; margin-bottom: 4px; align-items: stretch; }
.matrix .mrow .d { width: 46px; flex: 0 0 46px; font-size: 11px; font-weight: 600; display: flex; align-items: center; }
.mcell {
  flex: 1 1 0; min-height: 42px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); padding: 4px 5px; display: flex; flex-direction: column;
  justify-content: center; gap: 1px; overflow: hidden; font: inherit; text-align: left;
}
.mcell .l { font-size: 10px; font-weight: 600; line-height: 1.15; }
.mcell .s { font-size: 9px; line-height: 1.15; }
.mcell.ok { background: var(--ok-bg-2); border-color: var(--ok-line); cursor: pointer; }
.mcell.ok .l { color: var(--ok); } .mcell.ok .s { color: #5d9370; }
.mcell.warn { background: var(--warn-bg-2); border-color: var(--warn-line-2); cursor: pointer; }
.mcell.warn .l { color: var(--warn); } .mcell.warn .s { color: #a08348; }
.mcell.bad { background: var(--err-bg-2); border-color: var(--err-line); cursor: not-allowed; }
.mcell.bad .l { color: var(--err); } .mcell.bad .s { color: #b8746c; }
.mcell.here { background: var(--accent-soft); border-color: var(--accent); cursor: default; }
.mcell.here .l { color: var(--accent-dark); } .mcell.here .s { color: #6b5fa8; }

/* ------------------------------------------------------------------ resource week */

.reslist { flex: 1; overflow: auto; }
.resitem {
  padding: 8px 12px; border-bottom: 1px solid var(--line-3); cursor: pointer;
  background: var(--surface); display: flex; flex-direction: column; gap: 5px;
  width: 100%; text-align: left; font: inherit;
}
.resitem:hover { background: #faf9f6; }
.resitem[aria-selected="true"] { background: var(--accent-tint); }
.resitem .l { font-size: 12.5px; font-weight: 600; line-height: 1.25; flex: 1; }
.resitem.idle .l { color: var(--ink-3); }
.resitem .n { font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.bar { height: 4px; border-radius: 2px; background: var(--mute); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 2px; }

.statcard { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 13px 15px; margin-bottom: 18px; }
.stats { display: flex; align-items: flex-end; gap: 26px; flex-wrap: wrap; margin-bottom: 11px; }
.stat { display: flex; flex-direction: column; gap: 1px; }
.stat .k { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-4); }
.stat .v { font-size: 19px; font-weight: 700; line-height: 1.1; }
.split { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--mute); }
.split i { display: block; height: 100%; }
.keys { display: flex; gap: 16px; margin-top: 7px; font-size: 11px; color: var(--ink-3); flex-wrap: wrap; }
.keys span { display: flex; align-items: center; gap: 5px; }
.key { width: 9px; height: 9px; border-radius: 2px; }

.hrow { display: flex; align-items: center; gap: 12px; min-width: 0; }
.hrow .t { font-size: 12px; font-weight: 600; flex: 2 1 130px; min-width: 0; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hrow .s { font-size: 11px; color: var(--ink-3); flex: 1 1 90px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hrow .barwrap { flex: 1 1 60px; min-width: 40px; height: 6px; border-radius: 3px; background: var(--mute); overflow: hidden; }
.hrow .h { font-family: var(--mono); font-size: 11.5px; font-weight: 500; flex: 0 0 78px; text-align: right; }
.hrow .fix { font-size: 11px; font-weight: 600; color: var(--accent); cursor: pointer; flex: 0 0 56px; text-align: right; white-space: nowrap; background: none; border: 0; font-family: inherit; }

.wgrid-head { display: flex; gap: 4px; margin-bottom: 6px; }
.wgrid-head .sp { width: 92px; flex: 0 0 92px; }
.wgrid-head .c { flex: 1 1 0; text-align: center; padding-bottom: 2px; }
.wgrid-head .c b { font-size: 12px; font-weight: 700; display: block; }
.wgrid-head .c span { font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.wrow { display: flex; gap: 4px; margin-bottom: 4px; align-items: stretch; }
.wrow .lbl { width: 92px; flex: 0 0 92px; display: flex; flex-direction: column; justify-content: center; padding-right: 6px; }
.wrow .lbl b { font-size: 12px; font-weight: 600; }
.wrow .lbl span { font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.wcell {
  flex: 1 1 0; min-height: 62px; border-radius: 8px; border: 1px solid #e9e6e0;
  background: var(--hatch); padding: 6px 7px; display: flex; flex-direction: column; gap: 3px;
  font: inherit; text-align: left;
}
.wcell.filled { background: var(--surface); }
.wcell.ok { background: var(--ok-bg-2); border-color: var(--ok-line); cursor: pointer; }
.wcell.bad { background: var(--err-bg-2); border-color: var(--err-line); cursor: not-allowed; }
.wcell .note { font-size: 10px; font-weight: 600; line-height: 1.2; }
.wcell.ok .note { color: var(--ok); }
.wcell.bad .note { color: var(--err); }
.wcard {
  border-radius: 5px; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  background: var(--surface); padding: 4px 6px; display: flex; flex-direction: column; gap: 1px;
  cursor: pointer; font: inherit; text-align: left;
}
.wcard.selected { background: var(--accent-soft); border-color: var(--accent); }
.wcard.noroom { border-left-color: var(--err); }
.wcard.outpool { border-left-color: var(--warn-accent); }
.wcard .t { font-size: 11.5px; font-weight: 600; line-height: 1.2; }
.wcard .s { font-family: var(--mono); font-size: 9.5px; color: var(--ink-2); line-height: 1.2; }

.heat { display: flex; gap: 4px; margin-bottom: 4px; }
.heat .lbl { width: 92px; flex: 0 0 92px; font-family: var(--mono); font-size: 10px; color: var(--ink-3); display: flex; align-items: center; }
.heat .h { flex: 1 1 0; height: 26px; border-radius: 5px; display: flex; align-items: center; justify-content: center; }
.heat .h span { font-family: var(--mono); font-size: 11px; font-weight: 500; }

/* ------------------------------------------------------------------ problems */

.pgroup { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-bottom: 12px; overflow: hidden; }
.phead {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  cursor: pointer; background: var(--surface); width: 100%; font: inherit; border: 0; text-align: left;
}
.phead[aria-expanded="true"] { background: #faf9f6; }
.plevel { font-size: 10px; font-weight: 700; letter-spacing: .06em; padding: 3px 7px; border-radius: 4px; }
.plevel.error { background: var(--err-bg); color: var(--err); }
.plevel.warning { background: var(--warn-bg); color: var(--warn); }
.plevel.info { background: var(--mute); color: var(--ink-2); }
.pcode { font-family: var(--mono); font-size: 12px; font-weight: 500; }
.ptitle { font-size: 13px; color: var(--ink-2); }
.pcount { font-family: var(--mono); font-size: 12px; font-weight: 500; }
.pchev { font-size: 11px; color: var(--ink-4); }
.pbody { border-top: 1px solid var(--line-2); }
.pitem {
  display: flex; align-items: center; gap: 12px; padding: 8px 14px;
  border-bottom: 1px solid var(--line-3); cursor: pointer; width: 100%; font: inherit;
  text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0;
}
.pitem:hover { background: #faf9f6; }
.pitem .t { font-size: 12px; font-weight: 600; width: 260px; flex: 0 0 260px; line-height: 1.25; }
.pitem .w { font-family: var(--mono); font-size: 11px; color: var(--accent); width: 132px; flex: 0 0 132px; }
.pitem .d { font-size: 12px; color: var(--ink-2); line-height: 1.3; }
.pmore { padding: 8px 14px; font-size: 11px; color: var(--ink-4); }

/* ------------------------------------------------------------------ schedules list */

.table { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.thead {
  display: flex; padding: 8px 14px; border-bottom: 1px solid var(--line-2);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-4);
}
.trow {
  display: flex; align-items: center; padding: 12px 14px;
  border-bottom: 1px solid var(--line-3); cursor: pointer; background: var(--surface);
}
.trow:hover { background: #faf9f6; }
.trow.current { background: var(--accent-tint); }
.trow .nm { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.trow .nm b { font-size: 13px; font-weight: 600; }
.trow .nm span { font-size: 11px; color: var(--ink-3); }
.c-status { width: 100px; flex: 0 0 100px; }
.c-slots { width: 80px; flex: 0 0 80px; text-align: right; font-family: var(--mono); font-size: 12px; }
.c-prob { width: 96px; flex: 0 0 96px; text-align: right; font-family: var(--mono); font-size: 12px; }
.c-prob.hot { color: var(--err); }
.c-changed { width: 108px; flex: 0 0 108px; text-align: right; font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.c-act { width: 190px; flex: 0 0 190px; display: flex; gap: 6px; justify-content: flex-end; }

.foot { margin-top: 14px; font-size: 12px; color: var(--ink-3); line-height: 1.5; }

.cellinput {
  font: inherit; font-size: 13px; padding: 5px 8px; width: 100%;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--ink); outline: none;
}
.cellinput:focus { border-color: var(--accent); }
.cellinput.mono { font-family: var(--mono); }

/* ------------------------------------------------------------------ directory */

.dirgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
@media (max-width: 1100px) { .dirgrid { grid-template-columns: 1fr; } }

.dirpanel { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; display: flex; flex-direction: column; }
.dirpanel.open { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.dirhead { display: flex; align-items: center; gap: 8px; padding: 11px 13px; border-bottom: 1px solid var(--line-2); }
.dirhead .t { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.dirhead .n { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }

.form { padding: 12px 13px; border-bottom: 1px solid var(--line-2); background: var(--accent-tint); display: flex; flex-direction: column; gap: 9px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); }
.field input, .field select {
  font: inherit; font-size: 13px; padding: 6px 8px;
  border: 1px solid var(--accent-line); border-radius: 6px;
  background: var(--surface); color: var(--ink); outline: none; width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field .hint { font-size: 10.5px; color: var(--ink-3); line-height: 1.35; }
.formerr { font-size: 11.5px; font-weight: 600; color: var(--err); }
.formbtns { display: flex; gap: 7px; margin-top: 2px; }

.dirlist { max-height: 460px; overflow: auto; }
.diritem {
  display: flex; align-items: center; gap: 10px; padding: 8px 13px;
  border-bottom: 1px solid var(--line-3); background: var(--surface);
}
.diritem:hover { background: #faf9f6; }
.diritem.new { background: var(--accent-tint); }
.diritem .main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; cursor: pointer; }
.diritem .main .t { font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.diritem .main .s { font-size: 10.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diritem.ph .main .t { color: var(--ink-3); }
.diritem .h { font-family: var(--mono); font-size: 11px; text-align: right; white-space: nowrap; }
.diritem .h.gap { color: var(--err); }
.diritem .h.done { color: var(--ok); }
.diritem .h.idle { color: var(--ink-4); }
.diritem .del {
  border: 0; background: none; color: var(--ink-4); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 2px 4px; border-radius: 4px; opacity: 0;
}
.diritem:hover .del { opacity: 1; }
.diritem .del:hover { color: var(--err); background: var(--err-bg); }

/* ------------------------------------------------------------------ import */

.drop {
  display: block;
  border: 2px dashed var(--accent-line); border-radius: 12px; background: var(--accent-tint);
  padding: 34px 20px; text-align: center; cursor: pointer;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .big { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.drop .sm { font-size: 12px; color: var(--ink-3); }

.istats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.istat { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface); }
.istat .k { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-4); }
.istat .v { font-size: 18px; font-weight: 700; }
.istat .s { font-size: 11px; color: var(--ink-3); }

.daybars { display: flex; gap: 8px; align-items: flex-end; height: 90px; margin-top: 6px; }
.daybar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; justify-content: flex-end; }
.daybar i { display: block; width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.daybar b { font-size: 11px; font-weight: 600; }
.daybar span { font-family: var(--mono); font-size: 10px; color: var(--ink-3); }

.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------ muutmisaken */

.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(27, 26, 24, .34);
  display: flex; align-items: center; justify-content: center;
  padding: 26px;
}
.modal {
  width: 100%; max-width: 620px; max-height: 88vh;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.24);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--line-2);
}
.modal-body { flex: 1; overflow: auto; padding: 16px; }
.modal-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--line-2); background: var(--bg);
}

.frow { display: flex; gap: 10px; flex-wrap: wrap; }
.frow > .field { flex: 1 1 150px; min-width: 0; }
.modal .field { margin-bottom: 11px; }
.modal .field input, .modal .field select { border-color: var(--line); }
.modal .field input:focus, .modal .field select:focus { border-color: var(--accent); }
.modal .hint { font-size: 10.5px; color: var(--ink-3); line-height: 1.35; }

.loadbar {
  margin: 4px 0 6px; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}

.picklist {
  border: 1px solid var(--line); border-radius: 10px;
  max-height: 260px; overflow: auto; background: var(--surface);
}
.picklist.short { max-height: 168px; }
.pick {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 11px; border-bottom: 1px solid var(--line-3); cursor: pointer;
}
.pick:last-child { border-bottom: 0; }
.pick:hover { background: #faf9f6; }
.pick.on { background: var(--accent-tint); }
.pick input { width: 15px; height: 15px; accent-color: var(--accent); flex: 0 0 15px; cursor: pointer; }
.pick .pt { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.pick .pt b { font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.pick .pt span {
  font-size: 10.5px; color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pick .ph { font-family: var(--mono); font-size: 11px; color: var(--ink-3); white-space: nowrap; }

/* ---------------------------------------------- LAUR import ja võrdlus */

.bar.laur > i { background: var(--accent); transition: width .2s ease; }

.steps { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-2); line-height: 1.55; }
.steps li { margin-bottom: 3px; }

/* Filtriribad võrdluse aruandes. Erinevad `.chip`-ist: siin on ainult
   silt + arv, ja aktiivne olek peab olema kaugelt näha. */
.fchip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); font-size: 11.5px; font-weight: 600;
  color: var(--ink-2); cursor: pointer;
}
.fchip:hover { border-color: var(--ink-4); }
.fchip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.fchip .count {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: 999px; background: var(--mute); color: var(--ink-3);
}
.fchip.on .count { background: rgba(255, 255, 255, .22); color: #fff; }
.fchip.error:not(.on) { border-color: var(--err-line); color: var(--err); }
.fchip.error:not(.on) .count { background: var(--err-bg); color: var(--err); }

.table.cmp .thead, .table.cmp .trow { align-items: flex-start; gap: 10px; }
.table.cmp .trow { cursor: default; }
.table.cmp .c-lvl { flex: 0 0 68px; }
.table.cmp .c-kind { flex: 0 0 190px; font-size: 11.5px; font-weight: 600; }
.table.cmp .c-course { flex: 1 1 200px; min-width: 0; font-size: 12.5px; }
.table.cmp .c-side { flex: 1 1 170px; min-width: 0; font-size: 12px; font-family: var(--mono); }
.table.cmp .c-side.laur { color: var(--ink); }
.table.cmp .c-side.sys { color: var(--ink-2); }
.table.cmp .c-note { flex: 1 1 180px; min-width: 0; font-size: 11px; color: var(--ink-3); }

.inline { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; cursor: pointer; }
.inline input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
