/* ============ Tokens ============ */
:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', var(--font);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 284px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  --bg: #f5f4fa;
  --bg-grad: radial-gradient(1200px 500px at 85% -10%, #ece6ff 0%, transparent 60%), radial-gradient(900px 400px at -10% 20%, #e3f6f2 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f3f2f8;
  --surface-3: #eae8f2;
  --border: #e5e3ee;
  --border-strong: #d4d1e0;
  --text: #1c1a26;
  --text-2: #4a4759;
  --muted: #777389;
  --primary: #6d28d9;
  --primary-ink: #ffffff;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #d97706;
  --warn-bg: #fff7e6;
  --warn-border: #f5b54a;
  --shadow-sm: 0 1px 2px rgba(30, 20, 60, .05), 0 1px 3px rgba(30, 20, 60, .06);
  --shadow: 0 2px 6px rgba(30, 20, 60, .05), 0 10px 24px -8px rgba(30, 20, 60, .10);
  --shadow-lg: 0 18px 50px -12px rgba(30, 20, 60, .28);
  --chip-bg: #f6f5fb;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0e0d14;
  --bg-grad: radial-gradient(1200px 500px at 85% -10%, rgba(124, 58, 237, .16) 0%, transparent 60%), radial-gradient(900px 400px at -10% 20%, rgba(15, 159, 143, .10) 0%, transparent 55%);
  --surface: #17161f;
  --surface-2: #1f1e29;
  --surface-3: #292735;
  --border: #2a2836;
  --border-strong: #3a3749;
  --text: #eeedf5;
  --text-2: #c4c1d4;
  --muted: #9895ab;
  --primary: #a78bfa;
  --primary-ink: #160d2b;
  --danger: #f87171;
  --ok: #34d399;
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, .09);
  --warn-border: rgba(251, 191, 36, .55);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 2px 6px rgba(0, 0, 0, .3), 0 12px 28px -10px rgba(0, 0, 0, .55);
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .7);
  --chip-bg: #22212d;
  color-scheme: dark;
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s var(--ease), color .25s var(--ease);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

.ico {
  display: inline-block;
  width: 1.1em; height: 1.1em;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat;
  mask: var(--ico) center / contain no-repeat;
  vertical-align: -0.18em;
}
.ico-theme { --ico: url(/vendor/lucide/moon.svg); }
:root[data-theme="dark"] .ico-theme { --ico: url(/vendor/lucide/sun.svg); }

/* ============ Layout ============ */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); }

/* ============ Sidebar ============ */
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  z-index: 40;
  transition: transform .3s var(--ease), background-color .25s;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px 14px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center;
  color: #fff; font-size: 22px;
  background: linear-gradient(135deg, #7c3aed, #0f9f8f 55%, #f0700f);
  box-shadow: 0 6px 16px -6px rgba(124, 58, 237, .6);
}
.brand-title { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.brand-sub { color: var(--muted); font-size: 12.5px; }
.brand .icon-btn { margin-left: auto; }

.nav { flex: 1; overflow-y: auto; padding: 6px 12px 16px; scrollbar-width: thin; }
.nav-fn { margin-bottom: 10px; }
.nav-fn-link {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 10px;
  border: 0; background: transparent; text-align: left;
  border-radius: 12px;
  font-family: var(--font-display); font-weight: 700; font-size: 14.5px; letter-spacing: .02em;
  color: var(--fc);
  transition: background-color .15s;
}
.nav-fn-link:hover { background: color-mix(in srgb, var(--fc) 10%, transparent); }
.nav-fn-link .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--fc);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--fc) 20%, transparent);
}
.nav-fn-link .badge, .nav-link .count {
  margin-left: auto; font-family: var(--font); font-size: 11.5px; font-weight: 600;
  color: var(--muted); background: var(--surface-2); padding: 1px 8px; border-radius: 99px;
}
.nav-sub { margin: 2px 0 0 15px; padding-left: 10px; border-left: 2px solid color-mix(in srgb, var(--fc) 25%, transparent); }
.nav-link {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 6px 10px;
  border: 0; background: transparent; text-align: left;
  border-radius: 9px; font-size: 13.5px; color: var(--text-2);
  transition: background-color .15s, color .15s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: color-mix(in srgb, var(--fc) 12%, transparent); color: var(--text); font-weight: 600; }
.nav-link .fi, .flag { width: 1.33em; height: 1em; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .08); background-size: cover; flex: none; }
.nav-link .ico { color: var(--muted); }
.nav-link .warn-count { margin-left: auto; color: var(--warn); font-weight: 700; font-size: 12px; display: inline-flex; gap: 3px; align-items: center; }
.nav-sep { height: 1px; background: var(--border); margin: 12px 8px; }
.nav-extra .nav-link.on { background: var(--warn-bg); color: var(--warn); font-weight: 600; }

.sidebar-foot { padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.estado { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.estado .ico { color: var(--ok); }
.estado.saving .ico { color: var(--primary); animation: spin 1s linear infinite; }
.estado.error .ico { color: var(--danger); }

.scrim { display: none; }

/* ============ Topbar ============ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  padding: 12px 28px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.topbar-row { display: flex; align-items: center; gap: 10px; }
.topbar-row + .topbar-row { margin-top: 10px; }
.spacer { flex: 1; }

.segmented {
  display: inline-flex; padding: 4px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px;
}
.segmented button {
  display: inline-flex; align-items: center; gap: 7px;
  border: 0; background: transparent; padding: 7px 13px; border-radius: 10px;
  font-weight: 600; font-size: 13.5px; color: var(--muted);
  transition: all .2s var(--ease);
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.search {
  flex: 1 1 220px; max-width: 340px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 40px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 15%, transparent); }
.search .ico { color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; height: 100%; font-size: 14px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  box-shadow: var(--shadow-sm);
  transition: all .15s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.icon-btn .ico { width: 18px; height: 18px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 12px;
  border: 1px solid transparent; font-weight: 600; font-size: 14px;
  transition: all .15s var(--ease);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: var(--primary-ink); box-shadow: 0 6px 16px -8px var(--primary); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text-2); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn-edit { background: var(--surface); border-color: var(--border); color: var(--text-2); box-shadow: var(--shadow-sm); }
body.editing .btn-edit { background: linear-gradient(135deg, #7c3aed, #6d28d9); color: #fff; border-color: transparent; box-shadow: 0 6px 18px -8px #7c3aed; }

/* dropdowns */
.dropdown { position: relative; }
.menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 50;
  min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(-6px) scale(.98); pointer-events: none;
  transition: opacity .15s var(--ease), transform .15s var(--ease);
}
.menu-right { left: auto; right: 0; }
.dropdown.open .menu { opacity: 1; transform: none; pointer-events: auto; }
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 11px; border: 0; background: transparent; border-radius: 9px;
  text-align: left; font-size: 14px; color: var(--text-2);
}
.menu button:hover { background: var(--surface-2); color: var(--text); }
.menu button.sel { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--text); font-weight: 600; }
.menu .menu-title { padding: 8px 11px 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.menu-profes { max-height: 60vh; overflow-y: auto; min-width: 240px; }
.menu-profes .cnt { margin-left: auto; color: var(--muted); font-size: 12px; }
body:not(.editing) .needs-edit { display: none; }
.btn-profe .pdot, .menu .pdot { width: 12px; height: 12px; border-radius: 4px; background: var(--pc); flex: none; }

/* filtros activos */
.filtros-activos { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 14px 28px 0; }
.filtros-activos:empty { display: none; }
.fa-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 6px 5px 11px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--border); font-size: 13px; box-shadow: var(--shadow-sm);
}
.fa-chip button { border: 0; background: var(--surface-2); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.fa-chip button:hover { color: var(--text); }
.fa-count { color: var(--muted); font-size: 13px; }
.fa-clear { border: 0; background: none; color: var(--primary); font-weight: 600; font-size: 13px; }

/* ============ Contenido ============ */
.contenido { padding: 18px 28px 80px; max-width: 1500px; }
.cargando, .vacio { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 80px 20px; color: var(--muted); text-align: center; }
.vacio .ico { width: 40px; height: 40px; opacity: .5; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.funcion { margin-bottom: 44px; scroll-margin-top: 130px; }
.fn-hero {
  position: relative; overflow: hidden;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 22px 26px; margin-bottom: 18px;
  border-radius: 22px; color: #fff;
  background:
    radial-gradient(500px 200px at 100% 0%, rgba(255, 255, 255, .22), transparent 60%),
    linear-gradient(120deg, var(--fc), color-mix(in srgb, var(--fc) 70%, #111));
  box-shadow: 0 16px 36px -18px var(--fc);
}
.fn-hero::after {
  content: ''; position: absolute; right: -30px; bottom: -50px; width: 220px; height: 220px;
  background: rgba(255, 255, 255, .10);
  -webkit-mask: url(/vendor/lucide/music.svg) center / contain no-repeat; mask: url(/vendor/lucide/music.svg) center / contain no-repeat;
  transform: rotate(-12deg); pointer-events: none;
}
.fn-hero .eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .14em; opacity: .85; font-weight: 600; }
.fn-hero h1 { margin: 2px 0 4px; font-family: var(--font-display); font-size: 34px; line-height: 1.05; letter-spacing: -.01em; font-weight: 800; }
.fn-hero .stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13.5px; opacity: .92; }
.fn-hero .stats span { display: inline-flex; gap: 6px; align-items: center; }
.fn-hero .hero-actions { display: flex; gap: 8px; position: relative; z-index: 1; flex-wrap: wrap; }
.fn-hero .btn-hero { background: rgba(255, 255, 255, .18); color: #fff; border: 1px solid rgba(255, 255, 255, .3); backdrop-filter: blur(6px); }
.fn-hero .btn-hero:hover { background: rgba(255, 255, 255, .28); }

.pais { margin: 0 0 28px; scroll-margin-top: 130px; }
.pais-head { display: flex; align-items: center; gap: 12px; margin: 0 4px 12px; flex-wrap: wrap; }
.pais-head .flag { width: 30px; height: 22px; border-radius: 5px; box-shadow: var(--shadow-sm), 0 0 0 1px rgba(0, 0, 0, .06); }
.pais-head .flag.globe { display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.pais-head h2 { margin: 0; font-family: var(--font-display); font-size: 21px; font-weight: 700; letter-spacing: .01em; }
.pais-head .count { color: var(--muted); font-size: 13px; }
.pais-head .line { flex: 1; height: 1px; background: linear-gradient(90deg, var(--border), transparent); min-width: 20px; }
.pais-actions { display: flex; gap: 6px; }

.col-editor {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: -2px 4px 14px; padding: 10px 12px;
  border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--surface-2);
  font-size: 13px;
}
.col-editor .lbl { color: var(--muted); font-weight: 600; margin-right: 4px; }
.col-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); }
.col-pill .x { border: 0; background: none; color: var(--muted); display: grid; place-items: center; padding: 2px; border-radius: 50%; }
.col-pill .x:hover { color: var(--danger); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 470px), 1fr)); gap: 16px; }

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px 16px 22px;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s;
  scroll-margin-top: 140px;
  animation: aparecer .35s var(--ease) both;
}
.card::before {
  content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--fc);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow), 0 18px 34px -18px color-mix(in srgb, var(--fc) 50%, transparent); }
.card.flash { animation: flash 1.6s var(--ease); }
@keyframes aparecer { from { opacity: 0; transform: translateY(6px); } }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--fc) 45%, transparent), var(--shadow); } }

.card-head { display: flex; align-items: flex-start; gap: 12px; }
.num {
  flex: none; display: grid; place-items: center;
  min-width: 30px; height: 30px; padding: 0 6px; border-radius: 10px;
  font-family: var(--font-display); font-weight: 700; font-size: 14px;
  color: var(--fc); background: color-mix(in srgb, var(--fc) 12%, transparent);
}
.tema-wrap { flex: 1; min-width: 0; }
.tema { margin: 2px 0 0; font-family: var(--font-display); font-weight: 600; font-size: 17.5px; line-height: 1.25; word-wrap: break-word; }
.tema .artista { color: var(--fc); font-weight: 700; }
:root[data-theme="dark"] .tema .artista { color: color-mix(in srgb, var(--fc) 60%, #fff); }
.tema .sep { color: var(--muted); margin: 0 1px; }
.tono {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 10px;
  font-weight: 700; font-size: 14px; letter-spacing: .01em;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
}
.tono .ico { color: var(--fc); }
.tono.vacio-tono { color: var(--muted); font-weight: 500; font-size: 12.5px; border-style: dashed; padding: 5px 9px; }
.card-del { flex: none; }

.ribbon {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 10px 0 0; padding: 7px 10px; border-radius: 10px;
  background: var(--warn-bg); border: 1px dashed var(--warn-border); color: var(--warn);
  font-size: 13px; font-weight: 500;
}
.ribbon .btn { margin-left: auto; }

.cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px 12px; margin-top: 14px; }
.col { min-width: 0; padding: 9px 10px 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid transparent; transition: opacity .2s; }
.col.empty { background: transparent; border: 1px dashed var(--border); }
body:not(.editing) .col.empty { opacity: .55; }
.col-head {
  display: flex; align-items: center; gap: 6px; margin-bottom: 7px;
  font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
}
.col-head .ico { width: 15px; height: 15px; color: var(--tone); }
.col-head .warn { color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.none { color: var(--muted); font-size: 13px; opacity: .6; }

.chip {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; max-width: 100%;
  padding: 3px 4px 3px 10px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: inset 3px 0 0 var(--pc, var(--border-strong));
  font-size: 13px; font-weight: 600; line-height: 1.4;
  cursor: pointer; user-select: none;
  transition: transform .15s var(--ease), box-shadow .15s, opacity .2s, background-color .15s;
}
.chip:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.chip-name { overflow-wrap: anywhere; }
.chip-note {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  padding: 1px 6px; border-radius: 6px; color: var(--text-2); background: var(--surface-3);
}
.chip-prof {
  font-size: 10.5px; font-weight: 800; letter-spacing: .03em;
  padding: 2px 7px; border-radius: 99px; color: #fff; background: var(--pc);
}
.chip.sin-profe { padding-right: 10px; }
.chip.revisar { border: 1.5px dashed var(--warn-border); background: var(--warn-bg); }
.chip .chip-warn { color: var(--warn); width: 14px; height: 14px; }
.chip.hit { background: color-mix(in srgb, var(--pc, var(--primary)) 16%, var(--surface)); border-color: var(--pc, var(--primary)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc, var(--primary)) 22%, transparent); }
.chip.dim { opacity: .35; }
.chip.conflicto { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.add-chip {
  display: inline-grid; place-items: center; width: 28px; height: 26px; border-radius: 99px;
  border: 1px dashed var(--border-strong); background: transparent; color: var(--muted);
}
.add-chip:hover { color: var(--primary); border-color: var(--primary); }

/* edición en línea */
[contenteditable] { outline: none; border-radius: 6px; transition: background-color .15s, box-shadow .15s; }
body.editing [contenteditable]:hover { background: color-mix(in srgb, var(--primary) 7%, transparent); }
body.editing [contenteditable]:focus { background: var(--surface); box-shadow: 0 0 0 2px var(--primary); }
[contenteditable]:empty::before { content: attr(data-ph); color: var(--muted); font-weight: 500; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.add-card {
  display: grid; place-items: center; min-height: 120px;
  border: 2px dashed var(--border-strong); border-radius: var(--radius); background: transparent; color: var(--muted);
  font-weight: 600; gap: 6px; transition: all .15s;
}
.add-card:hover { color: var(--primary); border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, transparent); }

/* ============ Resumen alumno ============ */
#resumen-alumno { padding: 0 28px; max-width: 1500px; }
.resumen {
  margin-top: 16px; padding: 16px 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.resumen h3 { margin: 0 0 4px; font-family: var(--font-display); font-size: 16px; display: flex; gap: 8px; align-items: center; }
.resumen .sub { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.res-grupo + .res-grupo { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.res-nombre { font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.res-nombre .cnt { color: var(--muted); font-weight: 500; font-size: 13px; }
.res-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 6px; }
.res-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); text-align: left; font-size: 13px; min-width: 0;
}
.res-item:hover { border-color: var(--fc); }
.res-item .fn-tag { flex: none; font-size: 10px; font-weight: 800; letter-spacing: .05em; padding: 2px 6px; border-radius: 6px; color: #fff; background: var(--fc); }
.res-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.res-item .ins { flex: none; display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.res-item .ins .ico { color: var(--tone); }

/* ============ Orden del show ============ */
.orden-hint { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; margin: -6px 4px 12px; }
.orden-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.orden-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 11px 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: opacity .2s, box-shadow .2s, transform .2s;
}
.orden-item.dim { opacity: .35; }
.orden-item .handle { color: var(--muted); cursor: grab; display: none; padding: 4px; margin: -4px; }
body.editing .orden-item .handle { display: inline-grid; }
.orden-item .left { display: flex; align-items: center; gap: 10px; }
.orden-item .oi-tema { font-family: var(--font-display); font-weight: 600; font-size: 15.5px; line-height: 1.25; }
.orden-item .oi-tema .artista { color: var(--fc); font-weight: 700; }
:root[data-theme="dark"] .orden-item .oi-tema .artista { color: color-mix(in srgb, var(--fc) 60%, #fff); }
.orden-item .oi-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.orden-item .oi-parts { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 7px; font-size: 12.5px; color: var(--text-2); }
.orden-item .oi-part { display: inline-flex; align-items: center; gap: 4px; }
.orden-item .oi-part .ico { width: 13px; height: 13px; color: var(--tone); }
.orden-item .oi-part.conflicto { color: var(--danger); font-weight: 700; }
.orden-item .tono { font-size: 13px; padding: 4px 9px; }
.orden-item.has-conflict { border-color: color-mix(in srgb, var(--danger) 55%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 12%, transparent); }
.orden-item .aviso {
  grid-column: 1 / -1; display: flex; gap: 7px; align-items: center;
  margin: -2px 0 2px; padding: 6px 10px; border-radius: 9px;
  background: color-mix(in srgb, var(--danger) 9%, transparent); color: var(--danger); font-size: 12.5px; font-weight: 600;
}
.sortable-ghost { opacity: .4; }
.sortable-chosen { box-shadow: var(--shadow-lg); transform: scale(1.01); }

/* ============ Diálogos y toasts ============ */
.dlg {
  width: min(480px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 20px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.dlg[open] { animation: dlgIn .2s var(--ease); }
.dlg::backdrop { background: rgba(14, 10, 30, .45); backdrop-filter: blur(3px); }
@keyframes dlgIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.dlg form { padding: 22px 22px 18px; }
.dlg h3 { margin: 0 0 4px; font-family: var(--font-display); font-size: 20px; }
.dlg .dlg-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }
.dlg .field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.dlg label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.dlg input[type=text], .dlg input[type=password], .dlg select {
  height: 42px; padding: 0 12px; border-radius: 11px;
  border: 1px solid var(--border-strong); background: var(--surface-2); outline: none;
}
.dlg input:focus, .dlg select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 15%, transparent); }
.dlg .check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; margin: 6px 0; }
.dlg .alerta { padding: 10px 12px; border-radius: 11px; background: var(--warn-bg); border: 1px dashed var(--warn-border); color: var(--warn); font-size: 13px; margin-bottom: 12px; }
.dlg .alerta code { font-family: ui-monospace, monospace; color: var(--text); }
.dlg .error { color: var(--danger); font-size: 13px; min-height: 18px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.dlg-actions .left { margin-right: auto; }
.prof-sug { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.prof-sug button { border: 0; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 99px; color: #fff; background: var(--pc); opacity: .85; }
.prof-sug button:hover { opacity: 1; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 380px;
  padding: 11px 14px; border-radius: 13px; font-size: 14px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg);
  animation: dlgIn .25s var(--ease);
}
.toast.err { background: var(--danger); color: #fff; }

/* menú por tarjeta, avisos de cambio, estado en barra superior */
.card-menu { flex: none; }
.card-menu .icon-btn { width: 34px; height: 34px; border-radius: 10px; }
.card:has(.dropdown.open) { z-index: 25; }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
.col-pill .x.warn { color: var(--warn); }
.icon-btn:disabled { opacity: .4; cursor: default; transform: none; }
.estado-mini { display: none; }
.toast-cambio { padding: 9px 9px 9px 14px; }
.toast-cambio .ico { color: #6ee7b7; flex: none; }
:root[data-theme="dark"] .toast-cambio .ico, :root[data-theme="dark"] .toast-cambio .t-estado.ok { color: #047857; }
.toast-cambio .t-msg { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.toast-cambio .t-estado { opacity: .7; font-size: 12px; }
.toast-cambio .t-estado.ok { opacity: 1; color: #6ee7b7; font-weight: 600; }
.t-undo {
  margin-left: auto; flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 9px; border: 1px solid color-mix(in srgb, var(--bg) 35%, transparent);
  background: transparent; color: inherit; font-weight: 600; font-size: 13px;
}
.t-undo:hover { background: color-mix(in srgb, var(--bg) 15%, transparent); }

/* ============ Responsive ============ */
.only-mobile { display: none; }
@media (max-width: 960px) {
  .main { margin-left: 0; }
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); background: var(--surface); }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 8, 25, .4); z-index: 35; }
  .only-mobile { display: inline-grid; }
  .estado-mini { display: inline-flex; font-size: 0; gap: 0; width: 28px; justify-content: center; }
  .estado-mini .ico { width: 18px; height: 18px; }
  .topbar { padding: 10px 14px; }
  .topbar-row { gap: 6px; }
  .filtros-activos, #resumen-alumno { padding-left: 14px; padding-right: 14px; }
  .contenido { padding: 14px 14px 80px; }
}
@media (max-width: 640px) {
  .segmented button span:not(.ico) { display: none; }
  .segmented button { padding: 7px 11px; }
  .btn-edit .lbl { display: none; }
  .btn-edit { padding: 0 12px; }
  .filtros { flex-wrap: wrap; }
  .search { max-width: none; flex: 1 1 calc(50% - 6px); }
  .dropdown#dd-profe { flex: 1 1 100%; }
  .btn-profe { width: 100%; justify-content: flex-start; }
  #dd-profe .menu { left: 0; right: 0; }
  .fn-hero { padding: 18px; border-radius: 18px; }
  .fn-hero h1 { font-size: 27px; }
  .card { padding: 14px 14px 14px 18px; }
  .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .orden-item { grid-template-columns: auto 1fr; }
  .orden-item .tono { grid-column: 2; justify-self: start; }
  .toasts { left: 14px; right: 14px; }
}

/* ============ Impresión ============ */
.print-root { display: none; }
@media print {
  @page { size: A4 landscape; margin: 11mm; }
  body { background: #fff !important; background-image: none !important; color: #000; font-size: 10.5pt; }
  .app, .toasts, .dlg { display: none !important; }
  .print-root { display: block; }
  .pr-fn { break-after: page; }
  .pr-fn:last-child { break-after: auto; }
  .pr-fn h1 {
    font-family: var(--font-display); font-size: 20pt; margin: 0 0 4mm; padding-bottom: 2mm;
    border-bottom: 3px solid var(--fc); color: #000;
  }
  .pr-fn h1 small { font-size: 10pt; color: #555; font-weight: 500; margin-left: 8px; }
  .pr-table { width: 100%; max-width: 100%; table-layout: fixed; border-collapse: collapse; margin-bottom: 5mm; break-inside: avoid; overflow-wrap: anywhere; }
  .pr-table th, .pr-table td { border: 1px solid #999; padding: 3px 6px; vertical-align: top; text-align: left; }
  .pr-table .pr-pais th { background: color-mix(in srgb, var(--fc) 18%, #fff); text-align: center; font-size: 11pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pr-table thead tr:last-child th { background: #f1f1f1; font-size: 9pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pr-table.pr-largo { break-inside: auto; }
  .pr-table tr { break-inside: avoid; }
  .pr-table td.n { width: 8mm; text-align: center; font-weight: 700; }
  .pr-table td.tema { font-weight: 600; }
  .pr-part { display: block; }
  .pr-part small { color: #555; }
  .pr-ins { display: block; }
  .pr-ins b { font-size: 8pt; color: #555; }
  .pr-rev { color: #b45309; }
  .pr-foot { margin-top: 3mm; font-size: 8pt; color: #666; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
