/* clev3r.app Tvarkaraštis — CMS admin theme
   Design tokens: Bootstrap 5 + Inter, 4px grid, #2E5B9A primary.
   Accessibility-first: large hit targets, strong contrast, visible focus. */

:root {
  --bs-primary: #2E5B9A;
  --bs-primary-rgb: 46, 91, 154;

  --c-primary: #2E5B9A;
  --c-primary-700: #1d3f73;
  --c-primary-50: #eaf1fb;
  --c-primary-100: #d4e3f6;

  --c-bg: #f3f5f8;
  --c-surface: #ffffff;
  --c-surface-alt: #f8fafc;
  --c-border: #d8dde5;
  --c-border-strong: #b6c0cf;

  --c-text: #131a26;
  --c-text-muted: #5a6573;

  --c-success: #197d52;
  --c-success-bg: #e3f5ec;
  --c-warning: #9c5a00;
  --c-warning-bg: #fdf2dc;
  --c-danger: #b32525;
  --c-danger-bg: #fbe4e4;
  --c-info: #0c5d8a;
  --c-info-bg: #e2f1fa;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --hit: 44px;

  --font-base: 17px;
  --line-base: 1.5;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: var(--font-base);
  line-height: var(--line-base);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

[data-density="compact"] { --font-base: 15px; --hit: 40px; }
[data-density="cozy"]    { --font-base: 17px; --hit: 44px; }
[data-density="comfy"]   { --font-base: 19px; --hit: 48px; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Focus ---- */
:focus-visible {
  outline: 3px solid #ffb547;
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---- Layout ---- */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: 0 var(--s-6);
  height: 64px;
  background: var(--c-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.topbar__brand .dot {
  width: 28px; height: 28px; border-radius: 6px;
  background: linear-gradient(135deg, #f8c34c, #f17642);
  display: grid; place-items: center;
  font-weight: 700; color: #1d2433; font-size: 14px;
}

.topbar__nav {
  display: flex; gap: var(--s-1);
  margin-left: var(--s-6);
}

.topbar__nav a {
  color: rgba(255,255,255,0.85);
  padding: 8px 14px;
  border-radius: var(--r-md);
  font-weight: 500;
  min-height: var(--hit);
  display: inline-flex; align-items: center;
}
.topbar__nav a:hover { color: #fff; background: rgba(255,255,255,0.1); text-decoration: none; }
.topbar__nav a.active { background: rgba(255,255,255,0.18); color: #fff; }

.topbar__user {
  margin-left: auto;
  display: flex; align-items: center; gap: var(--s-2);
  padding: 6px 10px 6px 6px;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  font-size: 0.95em;
}
.topbar__user .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #f8c34c; color: #1d2433;
  display: grid; place-items: center; font-weight: 700;
}

/* ---- Breadcrumbs ---- */
.crumbs {
  padding: var(--s-4) var(--s-6);
  font-size: 0.95em;
  color: var(--c-text-muted);
  display: flex; align-items: center; gap: var(--s-2);
  flex-wrap: wrap;
}
.crumbs a { color: var(--c-text-muted); }
.crumbs a:hover { color: var(--c-primary); }
.crumbs .sep { opacity: 0.5; }
.crumbs .current { color: var(--c-text); font-weight: 500; }

/* ---- Page ---- */
.page {
  padding: var(--s-2) var(--s-6) var(--s-8);
  max-width: 1640px;
  margin: 0 auto;
  width: 100%;
}

.page__head {
  display: flex; align-items: flex-start; gap: var(--s-4);
  margin-bottom: var(--s-5);
}
.page__head h1 {
  margin: 0;
  font-size: 1.65rem;
  letter-spacing: -0.015em;
  font-weight: 600;
}
.page__head p {
  margin: 4px 0 0;
  color: var(--c-text-muted);
}
.page__actions {
  margin-left: auto;
  display: flex; gap: var(--s-2);
}

/* Compact editor header — single row, inline meta + crumb. */
.editor__head {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-6) var(--s-4);
  flex-wrap: wrap;
}
.editor__head-title { flex: 1; min-width: 240px; }
.editor__head-title h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.editor__head-meta {
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--c-text-muted);
  flex-wrap: wrap;
}
.editor__head-meta a { color: var(--c-text-muted); }
.editor__head-meta a:hover { color: var(--c-primary); }
.editor__head-meta .sep { opacity: 0.5; }
.editor__head-actions {
  display: flex;
  gap: var(--s-2);
  align-items: center;
}

/* ---- Mokinio (gimnazisto) tvarkaraščio ekranas ---- */
.stud-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--s-4);
  padding: 0 var(--s-6) var(--s-6);
  align-items: start;
}
.stud-side {
  background: var(--c-surface, #fff);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  overflow: hidden;
  position: sticky; top: var(--s-4);
  max-height: calc(100vh - 100px);
  display: flex; flex-direction: column;
}
.stud-side__filter {
  padding: var(--s-3);
  border-bottom: 1px solid var(--c-border);
  display: flex; flex-direction: column; gap: 8px;
}
.tabs--small button {
  padding: 4px 8px; font-size: 0.78rem; min-height: 26px;
}
.input--sm { padding: 6px 10px; font-size: 0.85rem; }
.stud-side__list { overflow-y: auto; flex: 1; padding: 4px; }
.stud-side__group-head {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  color: var(--c-text-muted); padding: 8px 8px 4px; letter-spacing: 0.05em;
}
.stud-side__item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  background: transparent; border: 0; cursor: pointer;
  padding: 7px 8px; border-radius: 6px;
  font: inherit; color: inherit; font-size: 0.88rem;
}
.stud-side__item:hover { background: var(--c-bg-hover, #f4f4f2); }
.stud-side__item.active { background: var(--c-primary-bg, #e6edfb); color: var(--c-primary, #264fbb); font-weight: 500; }
.stud-side__item .nm { flex: 1; }
.avatar--sm {
  width: 26px; height: 26px; font-size: 0.7rem; border-radius: 50%;
  background: var(--c-primary, #264fbb); color: white;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600;
  flex-shrink: 0;
}
.avatar--lg {
  width: 48px; height: 48px; font-size: 1rem; border-radius: 50%;
  background: var(--c-primary, #264fbb); color: white;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600;
}

.stud-main { min-width: 0; }
.stud-profile {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4); margin-bottom: var(--s-3);
  background: var(--c-surface, #fff); border: 1px solid var(--c-border); border-radius: 8px;
  flex-wrap: wrap;
}
.stud-profile__id { display: flex; align-items: center; gap: 14px; }
.stud-profile__id h2 { margin: 0; font-size: 1.1rem; font-weight: 600; }
.stud-profile__stats { display: flex; gap: var(--s-4); margin-left: auto; flex-wrap: wrap; }
.stud-stat { text-align: right; }
.stud-stat .lbl { font-size: 0.7rem; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stud-stat .val { font-size: 1.15rem; font-weight: 600; }
.stud-stat .val.success { color: var(--c-success, #197d52); }
.stud-stat .val.warning { color: var(--c-warning, #b8860b); }
.stud-stat .val.danger { color: var(--c-danger, #b32525); }

.stud-grid {
  background: var(--c-surface, #fff);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  overflow: hidden;
}
.stud-grid__header, .stud-grid__row {
  display: grid;
  grid-template-columns: 70px repeat(5, 1fr);
}
.stud-grid__header {
  background: var(--c-bg-soft, #f7f6f1);
  border-bottom: 2px solid var(--c-border-strong);
  position: sticky; top: 0; z-index: 1;
}
.stud-grid__corner { padding: 10px; font-size: 0.78rem; color: var(--c-text-muted); }
.stud-grid__day {
  padding: 10px; border-left: 1px solid var(--c-border);
  text-align: center;
}
.stud-grid__day .day { font-weight: 600; font-size: 0.92rem; }
.stud-grid__day .sub { font-size: 0.72rem; color: var(--c-text-muted); margin-top: 2px; }
.stud-grid__row { border-bottom: 1px solid var(--c-border); }
.stud-grid__row:last-child { border-bottom: 0; }
.stud-grid__time {
  padding: 8px 10px; font-size: 0.78rem;
  display: flex; flex-direction: column; gap: 1px; align-items: center;
  border-right: 1px solid var(--c-border);
  background: var(--c-bg-soft, #f7f6f1);
}
.stud-grid__time .num { font-weight: 600; font-size: 0.95rem; }
.stud-grid__time .t { color: var(--c-text-muted); }
.stud-grid__time .t.muted { opacity: 0.6; }
.stud-cell {
  border-left: 1px solid var(--c-border);
  min-height: 64px; padding: 4px;
  position: relative;
  display: flex; flex-direction: column; gap: 3px;
}
.stud-cell--window {
  background: repeating-linear-gradient(45deg, transparent 0 6px, rgba(184, 134, 11, 0.08) 6px 12px);
}
.stud-cell--conflict {
  background: rgba(179, 37, 37, 0.08);
  outline: 1.5px dashed var(--c-danger, #b32525);
  outline-offset: -2px;
}
.stud-window {
  display: flex; align-items: center; justify-content: center;
  height: 100%; min-height: 56px;
  font-size: 0.7rem; color: var(--c-warning, #b8860b);
  font-style: italic; opacity: 0.7;
}
.stud-chip {
  background: var(--bg);
  border-left: 3px solid var(--c);
  padding: 5px 7px; border-radius: 4px;
  font-size: 0.8rem;
  cursor: default;
  display: flex; flex-direction: column; gap: 2px;
}
.stud-chip[data-kind="elective"] {
  border-left-style: dashed;
}
.stud-chip .row1 { display: flex; align-items: center; gap: 5px; }
.stud-chip .lbl { font-weight: 600; color: var(--c); }
.stud-chip .lvl {
  font-size: 0.65rem; padding: 1px 5px; border-radius: 3px;
  background: var(--c); color: white; font-weight: 600;
}
.stud-chip .meta { font-size: 0.7rem; color: var(--c-text-muted); }

.stud-legend {
  display: flex; gap: var(--s-4); padding: 12px 4px;
  font-size: 0.78rem; color: var(--c-text-muted); flex-wrap: wrap;
}
.stud-legend i.dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
  margin-right: 6px; vertical-align: middle;
}
.stud-legend i.dot--core { background: var(--c-primary, #264fbb); }
.stud-legend i.dot--elective { background: transparent; border: 2px dashed var(--c-primary, #264fbb); }
.stud-legend i.dot--window { background: repeating-linear-gradient(45deg, transparent 0 2px, rgba(184, 134, 11, 0.5) 2px 4px); }
.stud-legend i.dot--conflict { background: var(--c-danger, #b32525); }

.stud-iup {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4);
  margin-top: var(--s-4);
}
.stud-iup__col {
  background: var(--c-surface, #fff); border: 1px solid var(--c-border); border-radius: 8px;
  padding: var(--s-3) var(--s-4);
}
.stud-iup h3 { margin: 0 0 8px; font-size: 0.95rem; font-weight: 600; }
.stud-iup ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.stud-iup li {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.85rem; padding: 4px 0;
}
.stud-iup li .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.stud-iup li .nm { flex: 1; }
.stud-iup li .lvl {
  font-size: 0.7rem; padding: 1px 6px; border-radius: 3px;
  background: var(--c-bg-soft, #f7f6f1); border: 1px solid var(--c-border); font-weight: 600;
}
.stud-iup li .muted { font-size: 0.78rem; color: var(--c-text-muted); }

@media (max-width: 900px) {
  .stud-layout { grid-template-columns: 1fr; }
  .stud-iup { grid-template-columns: 1fr; }
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s-2);
  padding: 10px 18px;
  min-height: var(--hit);
  border-radius: var(--r-md);
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 120ms, border 120ms, transform 80ms;
  white-space: nowrap;
  background: var(--c-surface);
  color: var(--c-text);
  border-color: var(--c-border-strong);
}
.btn:hover { background: var(--c-surface-alt); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.btn-primary:hover { background: var(--c-primary-700); border-color: var(--c-primary-700); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--c-text); }
.btn-ghost:hover { background: rgba(46,91,154,0.08); }

.btn-danger { background: #fff; color: var(--c-danger); border-color: #e6b8b8; }
.btn-danger:hover { background: var(--c-danger-bg); }

.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 0.92em; }
.btn-icon { padding: 0; width: var(--hit); height: var(--hit); }

/* ---- Card / Panel ---- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card__head {
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: var(--s-3);
}
.card__head h2, .card__head h3 {
  margin: 0; font-size: 1.05rem; font-weight: 600;
}
.card__body { padding: var(--s-5); }
.card__foot {
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--c-border);
  background: var(--c-surface-alt);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ---- Badge / Pill ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.85em;
  font-weight: 500;
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
  color: var(--c-text-muted);
}
.badge--success { background: var(--c-success-bg); color: var(--c-success); border-color: transparent; }
.badge--warning { background: var(--c-warning-bg); color: var(--c-warning); border-color: transparent; }
.badge--danger  { background: var(--c-danger-bg);  color: var(--c-danger);  border-color: transparent; }
.badge--info    { background: var(--c-info-bg);    color: var(--c-info);    border-color: transparent; }
.badge--primary { background: var(--c-primary-50); color: var(--c-primary); border-color: transparent; }

.dot-status {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}

/* ---- Inputs ---- */
.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  min-height: var(--hit);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  background: #fff;
  color: var(--c-text);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--c-primary);
  outline: 3px solid rgba(46,91,154,0.2);
  outline-offset: 0;
}
.label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  font-size: 0.95em;
}
.help {
  font-size: 0.85em;
  color: var(--c-text-muted);
  margin-top: 4px;
}

/* ---- Table ---- */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.97em;
}
.table th, .table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
}
.table thead th {
  background: var(--c-surface-alt);
  font-weight: 600;
  font-size: 0.92em;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table tbody tr:hover { background: var(--c-primary-50); }
.table tbody tr.row-link { cursor: pointer; }

/* ---- Stepper ---- */
.stepper {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) 0;
}
.stepper__step {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-text-muted);
  font-weight: 500;
  font-size: 0.95em;
  cursor: pointer;
}
.stepper__step.active {
  background: var(--c-primary);
  color: #fff;
  border-color: var(--c-primary);
}
.stepper__step.done {
  background: var(--c-success-bg);
  color: var(--c-success);
  border-color: transparent;
}
.stepper__num {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  background: rgba(0,0,0,0.06);
  border-radius: 50%;
  font-size: 0.8em;
  font-weight: 700;
}
.stepper__step.active .stepper__num { background: rgba(255,255,255,0.25); }
.stepper__line { flex: 0 0 24px; height: 2px; background: var(--c-border); }

/* ---- Editor layout ---- */
.editor {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--s-5);
}

@media (max-width: 1280px) { .editor { grid-template-columns: 1fr; } }

.editor__main { min-width: 0; }

.statusbar {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-3) var(--s-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
}
.statusbar__metric {
  display: flex; flex-direction: column;
  padding: 0 var(--s-3);
  border-left: 1px solid var(--c-border);
}
.statusbar__metric:first-child { border-left: none; padding-left: 0; }
.statusbar__metric .lbl { font-size: 0.78em; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.statusbar__metric .val { font-size: 1.2rem; font-weight: 600; }
.statusbar__metric .val.success { color: var(--c-success); }
.statusbar__metric .val.warning { color: var(--c-warning); }
.statusbar__metric .val.danger  { color: var(--c-danger); }

/* ---- Tabs ---- */
.tabs {
  display: inline-flex;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 4px;
  gap: 2px;
}
.tabs button {
  background: transparent;
  border: none;
  padding: 8px 16px;
  min-height: 40px;
  border-radius: var(--r-md);
  cursor: pointer;
  font-weight: 500;
  color: var(--c-text-muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.tabs button:hover { color: var(--c-text); }
.tabs button.active { background: var(--c-primary); color: #fff; }

/* ---- Timetable grid ---- */
.tt {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: auto;
  box-shadow: var(--shadow-sm);
}

.tt__grid {
  display: grid;
  font-size: 0.92em;
  min-width: 100%;
}

.tt__day-head, .tt__period-head, .tt__row-head {
  background: var(--c-surface-alt);
  font-weight: 600;
  color: var(--c-text-muted);
  position: sticky;
  z-index: 2;
}
.tt__day-head {
  top: 0;
  padding: 8px 6px;
  text-align: center;
  border-bottom: 1px solid var(--c-border);
  border-right: 1px solid var(--c-border);
  font-size: 0.92em;
}
.tt__period-head {
  top: 36px;
  padding: 6px 4px;
  text-align: center;
  border-bottom: 2px solid var(--c-border-strong);
  border-right: 1px solid var(--c-border);
  font-size: 0.78em;
  color: var(--c-text-muted);
  font-weight: 500;
}
.tt__period-head .num { font-size: 1.1em; font-weight: 700; color: var(--c-text); }
.tt__row-head {
  left: 0;
  padding: 8px 12px;
  border-right: 2px solid var(--c-border-strong);
  border-bottom: 1px solid var(--c-border);
  font-weight: 600;
  color: var(--c-text);
  text-align: left;
  display: flex; align-items: center; gap: var(--s-2);
}
.tt__corner {
  position: sticky; left: 0; top: 0;
  z-index: 3;
  background: var(--c-surface);
  border-right: 2px solid var(--c-border-strong);
  border-bottom: 2px solid var(--c-border-strong);
}

.tt__cell {
  border-bottom: 1px solid var(--c-border);
  border-right: 1px solid var(--c-border);
  padding: 4px;
  min-height: 64px;
  position: relative;
  vertical-align: top;
  background: #fff;
  display: flex;
  align-items: stretch;
  flex-direction: column;
  gap: 3px;
}

.tt__cell.day-end { border-right: 2px solid var(--c-border-strong); }

.tt__cell--drop-ok { background: #e3f5ec; outline: 2px dashed #197d52; outline-offset: -3px; }
.tt__cell--drop-bad { background: #fbe4e4; outline: 2px dashed #b32525; outline-offset: -3px; }

/* Chess-style move suggestions: legal target cells when a chip is selected. */
.tt__cell--legal { cursor: pointer; }
.tt__cell--legal::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(25, 125, 82, 0.32);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: background 0.12s, width 0.12s, height 0.12s;
}
.tt__cell--legal:hover::after {
  background: rgba(25, 125, 82, 0.55);
  width: 26px; height: 26px;
}
.tt__cell--legal-occupied {
  cursor: pointer;
  box-shadow: inset 0 0 0 3px rgba(25, 125, 82, 0.55);
}
.tt__cell--legal-occupied:hover {
  box-shadow: inset 0 0 0 3px rgba(25, 125, 82, 0.85);
}
.tt__cell--selected-origin {
  background: repeating-linear-gradient(45deg, transparent 0 6px, rgba(25, 125, 82, 0.10) 6px 12px);
  outline: 2px solid rgba(25, 125, 82, 0.55);
  outline-offset: -3px;
}
.tt__chip[data-selected="true"] {
  outline: 2px solid var(--c-primary, #264fbb);
  outline-offset: 2px;
  z-index: 3;
  box-shadow: 0 4px 14px rgba(38, 79, 187, 0.25);
}

.tt__chip {
  border-radius: var(--r-sm);
  padding: 5px 7px;
  font-size: 0.92em;
  line-height: 1.25;
  cursor: grab;
  border: 1px solid transparent;
  position: relative;
  background: #fff;
  user-select: none;
  font-weight: 500;
  display: flex; flex-direction: column; gap: 1px;
}
.tt__chip:active { cursor: grabbing; }
.tt__chip:focus-visible { outline: 3px solid #ffb547; outline-offset: 1px; }
.tt__chip .row1 { display: flex; gap: 6px; align-items: baseline; }
.tt__chip .label { font-weight: 600; }
.tt__chip .meta { color: var(--c-text-muted); font-size: 0.86em; }
.tt__chip[data-conflict="hard"] {
  outline: 2px solid var(--c-danger);
  outline-offset: -2px;
  background: #ffd5d5 !important;
  color: #7a0000;
  box-shadow: 0 0 0 4px rgba(214, 40, 40, 0.18), 0 4px 10px rgba(214, 40, 40, 0.25);
  animation: chip-conflict-pulse 1.6s ease-in-out infinite;
  z-index: 2;
}
.tt__chip[data-conflict="hard"]::after {
  content: "⚠";
  position: absolute;
  top: -8px; left: -8px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--c-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
@keyframes chip-conflict-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(214, 40, 40, 0.18), 0 4px 10px rgba(214, 40, 40, 0.25); }
  50%      { box-shadow: 0 0 0 8px rgba(214, 40, 40, 0.30), 0 4px 14px rgba(214, 40, 40, 0.40); }
}
.tt__chip[data-conflict="soft"] {
  outline: 2px dashed var(--c-warning);
}
.tt__chip[data-locked="true"]::before {
  content: "🔒"; position: absolute; top: 2px; right: 4px; font-size: 0.7em;
}

.tt__chip[data-dimmed="true"] {
  opacity: 0.25;
  filter: saturate(0.4);
  pointer-events: none;
}

.tt__chip[data-pulse] {
  animation: chip-pulse 0.55s ease-out;
}
.tt__chip[data-pulse="lock"] { box-shadow: 0 0 0 3px var(--c-primary); }
.tt__chip[data-pulse="unlock"] { box-shadow: 0 0 0 3px var(--c-text-muted); }

/* Drag origin cell highlight */
.tt__cell[data-drag-origin="true"] {
  background: repeating-linear-gradient(45deg, transparent 0 6px, rgba(38, 79, 187, 0.08) 6px 12px);
  outline: 2px dashed var(--c-primary);
  outline-offset: -3px;
}
.tt__cell-origin-label {
  position: absolute;
  top: 4px; left: 50%;
  transform: translateX(-50%);
  background: var(--c-primary);
  color: #fff;
  font-size: 0.72em;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 3;
}
.tt__cell { position: relative; }

/* Inline unassigned tray under a row */
.tt__tray-toggle {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff7e0;
  border: 1px dashed var(--c-warning);
  color: #8a5a00;
  font-size: 0.75em;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  cursor: pointer;
}
.tt__tray-toggle:hover { background: #ffeec2; }
.tt__tray-toggle.open { background: var(--c-warning); color: #fff; border-style: solid; }

.tt__tray {
  background: #fffbe6;
  border-top: 1px dashed var(--c-warning);
  border-bottom: 1px dashed var(--c-warning);
  padding: 8px 12px;
}
.tt__tray-inner {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.tt__tray-inner .tt__chip {
  background: #fff !important;
  border: 1px solid var(--c-warning);
}
.tt__tray-inline {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 6px;
  padding: 6px;
  background: #fffbe6;
  border: 1px dashed var(--c-warning);
  border-radius: 6px;
}
.tt__tray-inline .tt__chip {
  background: #fff !important;
  border: 1px solid var(--c-warning);
  cursor: grab;
}

/* ============ Teachers screen ============ */
.t-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 8px;
}
.t-stat {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 14px 18px;
}
.t-stat__num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.t-stat__lbl { font-size: 0.85em; color: var(--c-text-muted); margin-top: 2px; }

.t-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 16px;
}
.t-card {
  display: flex; flex-direction: column; gap: 10px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  font: inherit;
  color: var(--c-text);
  transition: box-shadow 0.12s, transform 0.06s;
}
.t-card:hover { box-shadow: 0 6px 16px rgba(0,0,0,0.08); transform: translateY(-1px); }
.t-card:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.t-card__head { display: flex; align-items: center; gap: 10px; }
.t-card__id { flex: 1; min-width: 0; }
.t-card__name { font-weight: 600; line-height: 1.2; }
.t-card__sub { font-size: 0.85em; color: var(--c-text-muted); margin-top: 2px; }
.t-card__subjects { display: flex; flex-wrap: wrap; gap: 4px; }

.t-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.92em;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
  flex-shrink: 0;
}

.t-subj-chip {
  display: inline-block;
  font-size: 0.75em; font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid;
  white-space: nowrap;
}

.t-load { display: flex; align-items: center; gap: 8px; }
.t-load__bar {
  flex: 1; height: 6px;
  background: var(--c-surface-alt);
  border-radius: 3px; overflow: hidden;
}
.t-load__fill {
  height: 100%;
  background: var(--c-success);
  transition: width 0.2s;
}
.t-load[data-tone="warning"] .t-load__fill { background: var(--c-warning); }
.t-load[data-tone="danger"] .t-load__fill { background: var(--c-danger); }
.t-load[data-tone="low"] .t-load__fill { background: var(--c-text-muted); }
.t-load__num { font-size: 0.8em; white-space: nowrap; }

.t-status { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.t-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 420px; max-width: 100vw;
  background: #fff;
  border-left: 1px solid var(--c-border);
  box-shadow: -8px 0 24px rgba(0,0,0,0.08);
  z-index: 60;
  display: flex; flex-direction: column;
  animation: drawer-in 0.2s ease-out;
}
@keyframes drawer-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.t-drawer__head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--c-border);
}
.t-drawer__body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}
.t-rules { list-style: disc; padding-left: 18px; margin: 0; font-size: 0.9em; }
.t-rules li { margin: 4px 0; }
.modal-scrim {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 59;
}
@keyframes chip-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}
.tt__chip-pulse {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: var(--c-text);
  color: #fff;
  font-size: 0.78em;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
  animation: chip-pulse-fade 0.6s ease-out forwards;
}
@keyframes chip-pulse-fade {
  0%   { opacity: 0; transform: translate(-50%, -30%); }
  20%  { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -70%); }
}

/* ⋯ menu trigger inside chip */
.tt__chip-menu {
  margin-left: auto;
  border: none;
  background: rgba(255,255,255,0.7);
  border-radius: 4px;
  width: 20px; height: 18px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  color: var(--c-text-muted);
  opacity: 0;
  transition: opacity 0.12s;
}
.tt__chip:hover .tt__chip-menu,
.tt__chip:focus-within .tt__chip-menu { opacity: 1; }
.tt__chip-menu:hover { background: #fff; color: var(--c-text); }
.tt__chip[data-locked="true"] .tt__chip-menu { right: 22px; }

/* Generic popover menu (chip ⋯ + list ⋯) */
.popover-scrim {
  position: fixed; inset: 0; z-index: 40; background: transparent;
}
.popover-menu {
  position: absolute; z-index: 41;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.18);
  padding: 4px;
  display: flex; flex-direction: column;
}
.popover-menu__item {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: var(--c-text);
}
.popover-menu__item:hover { background: var(--c-primary-50); }
.popover-menu__item--danger { color: var(--c-danger); }
.popover-menu__item--danger:hover { background: #fbe4e4; }
.popover-menu__hint {
  font-size: 0.78em;
  color: var(--c-text-muted);
  font-weight: 400;
}
.popover-menu__sep {
  height: 1px;
  background: var(--c-border);
  margin: 4px 0;
}

.tt__chip--ghost { opacity: 0.5; }

/* ---- Sidebar ---- */
.side {
  display: flex; flex-direction: column;
  gap: var(--s-4);
}
.side__filter { display: flex; gap: var(--s-2); }
.side__list { max-height: 60vh; overflow-y: auto; padding: 0; margin: 0; list-style: none; }
.side__list li {
  padding: var(--s-3);
  border-bottom: 1px solid var(--c-border);
  cursor: pointer;
}
.side__list li:hover { background: var(--c-primary-50); }
.side__list li:last-child { border-bottom: none; }

.unassigned-tray {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: var(--s-3);
  background: #fffbe6;
  border-top: 1px solid var(--c-border);
}

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: grid; place-items: center;
  z-index: 100;
  padding: var(--s-5);
}
.modal {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  max-width: 640px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  max-height: 92vh;
  display: flex; flex-direction: column;
}
.modal--lg { max-width: 880px; }
.modal__head {
  padding: var(--s-5);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: var(--s-3);
}
.modal__head h2 { margin: 0; font-size: 1.2rem; font-weight: 600; }
.modal__body { padding: var(--s-5); overflow-y: auto; }
.modal__foot {
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--c-border);
  display: flex; justify-content: flex-end; gap: var(--s-2);
  background: var(--c-surface-alt);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ---- Progress ---- */
.progress {
  height: 8px;
  background: var(--c-border);
  border-radius: 999px;
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  background: var(--c-primary);
  transition: width 200ms;
}

/* ---- Empty state ---- */
.empty {
  text-align: center;
  padding: var(--s-8) var(--s-5);
  color: var(--c-text-muted);
}

/* ---- Conflict cards in sidebar ---- */
.conflict {
  padding: 12px 14px;
  border-radius: var(--r-md);
  display: flex; gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
  cursor: pointer;
}
.conflict--hard { background: var(--c-danger-bg); border-left: 4px solid var(--c-danger); }
.conflict--soft { background: var(--c-warning-bg); border-left: 4px solid var(--c-warning); }
.conflict__icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1em;
  flex-shrink: 0;
}
.conflict--hard .conflict__icon { background: var(--c-danger); color: #fff; }
.conflict--soft .conflict__icon { background: var(--c-warning); color: #fff; }
.conflict__body { flex: 1; }
.conflict__code { font-size: 0.78em; font-weight: 600; opacity: 0.75; }
.conflict__text { font-size: 0.92em; line-height: 1.35; }

/* ---- Subject color blocks (use as left border on chips) ---- */
.tt__chip[data-color] {
  background: var(--chip-bg, #fff);
  border-left: 4px solid var(--chip-color, var(--c-border));
}

/* ---- Wizard layout ---- */
.wiz {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--s-5);
}
@media (max-width: 1024px) { .wiz { grid-template-columns: 1fr; } }
.wiz__nav {
  position: sticky; top: 80px; align-self: start;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--s-2);
}
.wiz__nav button {
  display: flex; width: 100%;
  align-items: center; gap: 10px;
  padding: 10px 12px;
  min-height: var(--hit);
  border: none;
  background: transparent;
  border-radius: var(--r-md);
  text-align: left;
  cursor: pointer;
  color: var(--c-text);
  font-weight: 500;
}
.wiz__nav button:hover { background: var(--c-primary-50); }
.wiz__nav button.active { background: var(--c-primary); color: #fff; }
.wiz__nav button.done .num { background: var(--c-success); color: #fff; }
.wiz__nav .num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--c-border); color: var(--c-text-muted);
  display: grid; place-items: center; font-size: 0.85em; font-weight: 700;
  flex-shrink: 0;
}
.wiz__nav button.active .num { background: rgba(255,255,255,0.25); color: #fff; }

/* ---- Skip link ---- */
.skip {
  position: absolute; left: -10000px;
  background: var(--c-primary); color: #fff;
  padding: 12px 16px; border-radius: 0 0 6px 0;
  z-index: 200;
}
.skip:focus { left: 0; top: 0; }

/* ---- Utility ---- */
.flex { display: flex; }
.gap-1 { gap: var(--s-1); }
.gap-2 { gap: var(--s-2); }
.gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); }
.center { align-items: center; }
.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; }
.muted { color: var(--c-text-muted); }
.mt-1 { margin-top: var(--s-1); } .mt-2 { margin-top: var(--s-2); } .mt-3 { margin-top: var(--s-3); } .mt-4 { margin-top: var(--s-4); }
.mb-1 { margin-bottom: var(--s-1); } .mb-2 { margin-bottom: var(--s-2); } .mb-3 { margin-bottom: var(--s-3); } .mb-4 { margin-bottom: var(--s-4); }
.text-sm { font-size: 0.9em; }
.text-lg { font-size: 1.1rem; }
.bold { font-weight: 600; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---- Compact density tweaks ---- */
[data-density="compact"] .tt__cell { min-height: 48px; padding: 3px; }
[data-density="compact"] .tt__chip { font-size: 0.85em; padding: 3px 5px; }
[data-density="compact"] .table th, [data-density="compact"] .table td { padding: 8px 10px; }

[data-density="comfy"] .tt__cell { min-height: 80px; padding: 5px; }
[data-density="comfy"] .tt__chip { font-size: 1em; padding: 7px 9px; }
