:root {
  --ink:        #08192C;
  --surface:    #0E2740;
  --surface-2:  #123453;
  --line:       #1D4A72;
  --line-soft:  #16395A;

  --teal:       #1F9A8F;
  --teal-lit:   #54D2C4;
  --teal-dim:   rgba(84, 210, 196, 0.14);

  --paper:      #F6F9FB;
  --text:       #E7EFF5;
  --text-dim:   #93AEC4;
  --text-faint: #62809A;

  --warn:       #E0A63C;
  --warn-dim:   rgba(224, 166, 60, 0.13);
  --alert:      #E4695F;
  --alert-dim:  rgba(228, 105, 95, 0.15);
  --good:       #57B894;

  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --display: "Bricolage Grotesque", "IBM Plex Sans", sans-serif;

  --row-h: 78px;
  --break-h: 26px;
  --radius: 5px;
}

* { box-sizing: border-box; }

/* El atributo hidden debe ganarle a cualquier display de clase
   (si no, los modales aparecen al cargar la página). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; letter-spacing: -0.01em; }

/* ---------- Barra superior ---------- */

.bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 20px 28px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--ink) 100%);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.bar__id h1 { font-size: 25px; line-height: 1.1; }
.bar__id p { margin: 4px 0 0; font-size: 13px; color: var(--text-dim); }
.bar__actions { display: flex; gap: 9px; flex-wrap: wrap; }

.btn {
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 15px;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover { border-color: var(--teal-lit); color: #fff; }
.btn:focus-visible { outline: 2px solid var(--teal-lit); outline-offset: 2px; }
.btn--primary { background: var(--teal); border-color: var(--teal); color: #04202A; font-weight: 600; }
.btn--primary:hover { background: var(--teal-lit); border-color: var(--teal-lit); color: #04202A; }
.btn--danger { border-color: var(--alert); color: var(--alert); }
.btn--danger:hover { border-color: var(--alert); background: var(--alert-dim); color: var(--alert); }
.btn--sm { padding: 6px 11px; font-size: 12.5px; }
.btn[disabled] { opacity: .38; cursor: default; }
.btn[disabled]:hover { border-color: var(--line); color: var(--text); }

/* ---------- Contenedor ---------- */

.wrap { max-width: 1360px; margin: 0 auto; padding: 26px 28px 80px; }

.welcome { max-width: 560px; padding: 46px 0 20px; }
.welcome h2 { font-size: 30px; line-height: 1.15; margin-bottom: 12px; }
.welcome p { color: var(--text-dim); margin: 0 0 22px; }
.welcome--tight { padding: 18px 0; }
.welcome--tight p { margin: 0; }
.welcome__actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Avisos y paneles ---------- */

.notice {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 13.5px;
  border: 1px solid var(--line);
}
.notice--error { background: var(--alert-dim); border-color: var(--alert); }
.notice--info { background: var(--teal-dim); border-color: var(--teal); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 15px 18px;
  margin-bottom: 18px;
}
.panel h3 { font-size: 14.5px; color: var(--teal-lit); font-weight: 600; margin-bottom: 9px; }
.panel--warn h3 { color: var(--warn); }
.panel__hint { margin: -4px 0 11px; font-size: 12.5px; color: var(--text-faint); }
.panel ul { margin: 0; padding-left: 18px; font-size: 13.5px; }
.panel li { margin-bottom: 4px; color: var(--text-dim); }
.panel li b { color: var(--text); font-weight: 500; }

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  border-radius: 3px;
  padding: 1px 6px;
  margin-right: 7px;
  vertical-align: 1px;
}
.tag--hard { background: var(--alert-dim); color: var(--alert); }
.tag--soft { background: var(--warn-dim); color: var(--warn); }

.tier-row { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.tier-row__label { font-weight: 600; color: var(--teal-lit); min-width: 58px; font-size: 13px; }
.tier-row span.who { font-size: 13px; color: var(--text-dim); }
.tier-row span.who b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: var(--sans);
  font-size: 12.5px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 5px 13px;
  cursor: pointer;
}
.chip:hover { border-color: var(--warn); }
.chip b { color: var(--warn); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Métricas ---------- */

.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.stat {
  display: flex; align-items: baseline; gap: 9px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--teal);
  border-radius: var(--radius);
  padding: 9px 15px;
}
.stat__n { font-family: var(--display); font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat__l { font-size: 12.5px; color: var(--text-dim); }
.stat--alert { border-left-color: var(--alert); }
.stat--alert .stat__n { color: var(--alert); }
.stat--warn { border-left-color: var(--warn); }
.stat--warn .stat__n { color: var(--warn); }
.stat--good .stat__n { color: var(--good); }

/* ---------- Selectores de vista ---------- */

.views { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.tab {
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 13px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: var(--sans);
}
.tab.is-active { background: var(--teal); border-color: var(--teal); color: #04202A; font-weight: 600; }
.tab--select { display: inline-flex; align-items: center; gap: 8px; padding: 3px 5px 3px 13px; }
.tab--select span { color: var(--text-dim); font-size: 12.5px; }
.tab--select select {
  background: var(--ink);
  color: var(--text);
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  padding: 5px 7px;
  font-family: var(--sans);
  font-size: 12.5px;
  max-width: 210px;
}
.tab--select.is-active { background: var(--teal); border-color: var(--teal); }
.tab--select.is-active span { color: #04202A; font-weight: 600; }

.hint { font-size: 12.5px; color: var(--text-faint); margin: 0 0 12px; }

/* ---------- Rejilla del horario ---------- */

.grid-scroll {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
}
.grid { min-width: 940px; }

.grid__head { display: flex; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.grid__head-time { width: 96px; flex: 0 0 96px; padding: 9px 12px; font-size: 12.5px; color: var(--text-dim); }
.grid__head-day { flex: 1; padding: 9px 12px; font-size: 13.5px; font-weight: 600; border-left: 1px solid var(--line-soft); }

.grid__body { display: flex; position: relative; }
.grid__times { width: 96px; flex: 0 0 96px; position: relative; }
.grid__day { flex: 1; position: relative; border-left: 1px solid var(--line-soft); }

.slot-label {
  position: absolute; left: 0; right: 0;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.slot-label.is-extra { color: var(--warn); background: var(--warn-dim); }

.slot-cell {
  position: absolute; left: 0; right: 0;
  border-bottom: 1px solid var(--line-soft);
  cursor: copy;
}
.slot-cell.is-extra { background: rgba(224, 166, 60, 0.05); }
.slot-cell.is-drop { background: var(--teal-dim); box-shadow: inset 0 0 0 1px var(--teal-lit); }

.gap-band {
  position: absolute; left: 0; right: 0;
  background: var(--ink);
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  font-size: 11px;
  color: var(--text-faint);
  padding: 5px 12px;
  pointer-events: none;
  white-space: nowrap;
}
.gap-band--extra { border-top: 1px dashed var(--warn); color: var(--warn); }

.klass {
  position: absolute;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--teal);
  border-radius: 4px;
  padding: 7px 9px;
  overflow: hidden;
  cursor: grab;
  z-index: 2;
  transition: border-color .12s;
}
.klass:hover { border-color: var(--teal-lit); border-left-color: var(--teal-lit); }
.klass:focus-visible { outline: 2px solid var(--teal-lit); outline-offset: 1px; }
.klass.is-dragging { opacity: .35; }
.klass.is-locked { cursor: pointer; }
.klass.is-extra { border-left-color: var(--warn); background: rgba(224, 166, 60, 0.08); }
.klass.has-conflict { border-color: var(--alert); border-left-color: var(--alert); background: var(--alert-dim); }

.klass__name { font-size: 12.5px; font-weight: 600; line-height: 1.25; padding-right: 34px; }
.klass__meta { font-size: 11.5px; color: var(--text-dim); line-height: 1.4; }
.klass__time { font-size: 11.5px; color: var(--teal-lit); font-variant-numeric: tabular-nums; }
.klass.is-extra .klass__time { color: var(--warn); }
.klass__marks {
  position: absolute; top: 5px; right: 7px;
  display: flex; gap: 5px; align-items: center;
  font-size: 11px; color: var(--text-faint);
}
.klass__marks .h { color: var(--teal-lit); font-variant-numeric: tabular-nums; }
.klass.is-extra .klass__marks .h { color: var(--warn); }

/* ---------- Modales ---------- */

.modal {
  position: fixed; inset: 0;
  background: rgba(4, 12, 22, 0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 60;
}
.modal__box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  width: 440px;
  max-width: 100%;
  max-height: 88vh;
  overflow-y: auto;
}
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 17px 20px 12px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky; top: 0; background: var(--surface);
}
.modal__head h2 { font-size: 18px; }
.modal__close {
  background: none; border: none; color: var(--text-dim);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.modal__close:hover { color: var(--text); }
.modal__body { padding: 16px 20px 20px; }

.field { margin-bottom: 13px; }
.field > label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; }
.field select, .field input[type=text] {
  width: 100%;
  background: var(--ink);
  color: var(--text);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 8px 9px;
  font-family: var(--sans);
  font-size: 13.5px;
}
.field select:focus, .field input:focus { outline: 2px solid var(--teal); outline-offset: -1px; }
.row { display: flex; gap: 11px; }
.row .field { flex: 1; }
.row .field.narrow { flex: 0 0 84px; }

.stepper { display: flex; align-items: center; gap: 11px; }
.stepper__v { font-family: var(--display); font-size: 17px; font-weight: 600; min-width: 46px; text-align: center; }
.stepper__note { font-size: 11.5px; color: var(--text-faint); }

.status { border-radius: 4px; padding: 10px 12px; font-size: 12.5px; line-height: 1.6; margin: 14px 0 4px; }
.status--ok { background: rgba(87,184,148,.12); border: 1px solid var(--good); color: var(--good); }
.status--warn { background: var(--warn-dim); border: 1px solid var(--warn); color: var(--warn); }
.status div + div { margin-top: 3px; }

.modal__foot { display: flex; gap: 9px; margin-top: 18px; }
.modal__foot .btn { flex: 1; justify-content: center; text-align: center; }

.subhead { font-size: 12.5px; color: var(--text-dim); margin: 0 0 14px; }
.subhead b { color: var(--text); font-weight: 600; }

.checklist { max-height: 230px; overflow-y: auto; border: 1px solid var(--line-soft); border-radius: 4px; padding: 4px; }
.checkrow { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 3px; font-size: 13px; cursor: pointer; }
.checkrow:hover { background: var(--surface-2); }
.checkrow input { accent-color: var(--teal); width: 15px; height: 15px; }
.checkrow span.count { margin-left: auto; color: var(--text-faint); font-size: 12px; font-variant-numeric: tabular-nums; }

.pickall { display: flex; gap: 8px; margin: 9px 0 13px; }

#printRoot { display: none; }

@media (max-width: 720px) {
  .wrap { padding: 20px 16px 60px; }
  .bar { padding: 16px; }
  .welcome h2 { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
