:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1f2733;
  --muted: #6b7688;
  --line: #e3e8f0;
  --accent: #4f6ef7;
  --accent-ink: #ffffff;
  --danger: #e05353;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(31, 39, 51, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.4;
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 34px; }
.app-header h1 { margin: 0; font-size: 22px; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.header-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: #eef1f8;
  color: var(--ink);
  transition: transform .05s ease, background .15s ease, box-shadow .15s ease;
}
.btn:hover { background: #e3e8f5; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #3f5ce8; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: #f0f3fa; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c94444; }
.btn-danger-ghost { background: transparent; border-color: #f1cccc; color: var(--danger); }
.btn-danger-ghost:hover { background: #fceaea; }

main { padding: 24px; }

.grid-wrapper { overflow-x: auto; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; }

.timetable {
  display: grid;
  min-width: 720px;
  gap: 4px;
}

.tt-cell {
  border-radius: 8px;
  min-height: 30px;
}

.tt-corner { background: transparent; }

.tt-dayhead {
  background: #eef1f8;
  font-weight: 700;
  text-align: center;
  padding: 10px 4px;
  border-radius: 8px;
  font-size: 14px;
}

.tt-timehead {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  padding: 4px 8px 0 0;
  font-variant-numeric: tabular-nums;
}

.tt-slot {
  background: #fafbfe;
  border: 1px dashed transparent;
  cursor: pointer;
  transition: background .12s ease;
  position: relative;
}
.tt-slot:hover { background: #eef2ff; border-color: #cdd7fb; }
.tt-slot::after {
  content: "+";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b9c2d6;
  font-size: 18px;
  opacity: 0;
  transition: opacity .12s ease;
}
.tt-slot:hover::after { opacity: 1; }

.tt-course {
  border-radius: 8px;
  padding: 6px 8px;
  color: #12203d;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05);
}
.tt-course:hover { filter: brightness(0.97); }
.tt-course .c-title { font-weight: 700; font-size: 13px; line-height: 1.2; }
.tt-course .c-room { font-size: 11px; opacity: 0.8; margin-top: 2px; }

.hint { color: var(--muted); font-size: 13px; text-align: center; margin-top: 16px; }

/* Modales */
.modal-backdrop[hidden] { display: none !important; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 27, 45, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  width: 100%;
  max-width: 440px;
  padding: 24px;
  animation: pop .15s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h2 { margin: 0 0 16px; font-size: 19px; }

.modal label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.modal input[type=text],
.modal input[type=number],
.modal select {
  width: 100%;
  margin-top: 5px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
}
.modal input:focus, .modal select:focus { outline: 2px solid var(--accent); border-color: transparent; }

.field-row { display: flex; gap: 12px; }
.field-row label { flex: 1; }

.color-palette { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 18px; }
.swatch {
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
}
.swatch.selected { border-color: var(--ink); box-shadow: 0 0 0 2px #fff inset; }

.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.spacer { flex: 1; }

.days-toggle { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 18px; }
.day-chip {
  padding: 7px 12px;
  border-radius: 20px;
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  user-select: none;
  background: #fff;
}
.day-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.ed-note { font-size: 12px; color: var(--muted); background: #f4f6fb; border-radius: 8px; padding: 8px 10px; margin: 4px 0 8px; }
.ed-question { font-weight: 600; margin: 4px 0 10px; }
.ed-propositions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.ed-propositions .btn { text-align: left; }
.ed-message { font-size: 13px; padding: 8px 10px; border-radius: 8px; margin: 4px 0; }
.ed-message.error { background: #fceaea; color: var(--danger); }
.ed-message.info { background: #eef2ff; color: var(--accent); }

@media (max-width: 640px) {
  .app-header { padding: 14px 16px; }
  .app-header h1 { font-size: 18px; }
  main { padding: 14px; }
  .header-actions .btn { padding: 7px 10px; font-size: 13px; }
}

@media print {
  .app-header, .hint { display: none; }
  body { background: #fff; }
  .grid-wrapper { box-shadow: none; overflow: visible; }
  .tt-slot::after { display: none; }
  .tt-slot:hover { background: #fafbfe; border-color: transparent; }
}
