/* ============ Sistema visual del panel ============ */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e5e7ec;
  --line-2: #eef0f4;
  --accent: #f05a1a;
  --accent-2: #d9480f;
  --accent-ink: #ffffff;
  --accent-soft: #fff1ea;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --live: #e11d48;
  --side: #0b0f1a;
  --side-2: #151a28;
  --side-ink: #aab1c2;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-md: 0 10px 30px -12px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .05);
  --shadow-lg: 0 30px 80px -20px rgba(15, 23, 42, .35);
  --side-w: 248px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "cv11", "ss01";
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.45; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
code { font-family: "JetBrains Mono", Consolas, "Courier New", monospace; background: var(--line-2); padding: 2px 6px; border-radius: 6px; font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ic { width: 18px; height: 18px; flex: 0 0 auto; display: inline-block; vertical-align: middle; }
.ic-sm { width: 15px; height: 15px; }
.ic-lg { width: 22px; height: 22px; }

/* ============ Estructura ============ */
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 6;
  background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; }
.side .brand { padding: 4px 8px 22px; }
.brand b { font-size: 15px; font-weight: 700; display: block; }
.brand small { display: block; font-size: 11.5px; color: var(--side-ink); margin-top: 1px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 auto;
  background: var(--accent); position: relative; box-shadow: 0 6px 18px -6px rgba(240, 90, 26, .7);
}
.brand-mark:before { content: ''; position: absolute; left: 8px; top: 9px; width: 18px; height: 12px; border: 2.5px solid #fff; border-radius: 3px; }
.brand-mark:after { content: ''; position: absolute; left: 13px; top: 24px; width: 8px; height: 2.5px; background: #fff; border-radius: 2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: 0; color: var(--side-ink); font: inherit; font-weight: 500;
  padding: 10px 12px; border-radius: 10px; cursor: pointer; text-align: left;
  transition: background .15s, color .15s;
}
.nav button:hover { background: var(--side-2); color: #fff; }
.nav button.active { background: rgba(240, 90, 26, .14); color: #fff; }
.nav button.active .ic { color: var(--accent); }
.nav .count { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.nav .count.live { background: var(--live); animation: pulse 1.6s infinite; }
.side-cta {
  margin-top: 18px; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff; border: 0; font: inherit; font-weight: 600;
  padding: 11px 12px; border-radius: 12px; cursor: pointer; transition: transform .15s var(--ease), background .15s;
  box-shadow: 0 10px 24px -10px rgba(240, 90, 26, .8);
}
.side-cta:hover { background: var(--accent-2); transform: translateY(-1px); }
.side-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--side-2); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--side-2); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: 0 0 auto;
}
.side-user .who { min-width: 0; flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user button, .topbar-user button { background: none; border: 0; color: var(--side-ink); cursor: pointer; padding: 6px; border-radius: 8px; }
.side-user button:hover, .topbar-user button:hover { background: var(--side-2); color: #fff; }

main { margin-left: var(--side-w); padding: 32px 40px 60px; max-width: calc(1360px + var(--side-w)); animation: fade .3s var(--ease); }
.topbar, .tabbar { display: none; }

body.fuera .side, body.fuera .topbar, body.fuera .tabbar { display: none !important; }
body.fuera main { margin: 0 auto; }

/* ============ Encabezados ============ */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; font-weight: 800; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 720px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sec { margin-top: 28px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.sec-head h2 { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.sec-head .hint { margin: 0; }

/* ============ Botones y campos ============ */
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 13px; border-radius: var(--radius-sm); display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
button:hover, .btn:hover { border-color: #cfd3db; background: var(--surface-2); }
button:active, .btn:active { transform: scale(.98); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 16px -8px rgba(240, 90, 26, .7); }
button.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
button.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
button.dark:hover { background: #1e293b; }
button.danger { color: var(--danger); }
button.danger:hover { border-color: #fca5a5; background: #fff5f5; }
button.ghost { background: none; border-color: transparent; }
button.ghost:hover { background: var(--line-2); }
button:disabled { opacity: .5; cursor: default; transform: none; }
.icon-btn { padding: 7px; border-radius: 9px; background: none; border: 1px solid transparent; color: var(--ink-2); }
.icon-btn:hover { background: var(--line-2); border-color: transparent; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

input, select, textarea {
  font: inherit; color: var(--ink); width: 100%;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: #d3d7df; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(240, 90, 26, .14); }
input[type=color] { padding: 3px; height: 40px; cursor: pointer; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
input[type=range] { padding: 0; accent-color: var(--accent); box-shadow: none; }
textarea { resize: vertical; min-height: 84px; }
.field { margin-bottom: 14px; }
.field > label, .label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 6px; color: var(--ink-2); }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 4px; margin: 0 0 16px; }
legend { font-weight: 700; padding: 0 6px; font-size: 13px; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 36px; }

/* Segmentado (pastillas) */
.chips { display: inline-flex; gap: 4px; background: var(--line-2); padding: 4px; border-radius: 12px; flex-wrap: wrap; }
.chips button { border: 0; background: none; padding: 6px 12px; border-radius: 9px; font-weight: 600; color: var(--muted); font-size: 13px; }
.chips button:hover { color: var(--ink); background: none; }
.chips button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .grow { flex: 1; }

/* Interruptor */
.switch { position: relative; width: 38px; height: 22px; flex: 0 0 auto; border: 0; padding: 0; border-radius: 999px; background: #cbd2dc; cursor: pointer; transition: background .2s; }
.switch:after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch.on { background: var(--ok); }
.switch.on:after { transform: translateX(16px); }
.switch:hover { background: #b8c0cc; }
.switch.on:hover { background: #15803d; }

/* Etiquetas */
.tag { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); }
.tag.live { background: var(--live); color: #fff; }
.tag.live:before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: pulse 1.4s infinite; }
.tag.on { background: var(--ok-soft); color: #15803d; }
.tag.off { background: var(--line-2); color: var(--muted); }
.tag.accent { background: var(--accent-soft); color: var(--accent-2); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #c4cad4; flex: 0 0 auto; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.warn { color: var(--warn); font-size: 12px; display: flex; gap: 6px; align-items: flex-start; }

/* ============ Tarjetas base ============ */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.empty {
  text-align: center; padding: 48px 20px; color: var(--muted); background: var(--surface);
  border: 1.5px dashed var(--line); border-radius: var(--radius);
}
.empty .ic { width: 34px; height: 34px; color: #c3c9d3; margin-bottom: 10px; }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.empty button { margin-top: 14px; }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, #eceef2 25%, #f5f6f8 50%, #eceef2 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }

/* Estadísticas */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px; text-align: left; cursor: pointer; box-shadow: var(--shadow-sm);
  font-weight: 400; transition: transform .15s var(--ease), box-shadow .15s, border-color .15s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); background: var(--surface); }
.stat .stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12.5px; font-weight: 600; width: 100%; }
.stat .stat-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--line-2); color: var(--ink-2); }
.stat.hot .stat-ic { background: var(--accent-soft); color: var(--accent); }
.stat.ok .stat-ic { background: var(--ok-soft); color: var(--ok); }
.stat.live .stat-ic { background: #ffe4e8; color: var(--live); }
.stat .stat-val { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.stat .stat-val small { font-size: 15px; color: var(--muted); font-weight: 600; letter-spacing: 0; }

/* Aviso en vivo */
.live-banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(90deg, #fff1f3, #fff); border: 1px solid #fecdd3; border-radius: var(--radius);
  padding: 14px 16px; margin-top: 18px;
}
.live-banner .grow { flex: 1; min-width: 200px; }
.live-banner b { display: block; }

/* ============ Pantallas (muro en vivo) ============ */
.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; align-items: start; }
.scard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm); transition: box-shadow .2s, transform .2s var(--ease); display: flex; flex-direction: column;
  animation: rise .35s var(--ease) both;
}
.scard:hover { box-shadow: var(--shadow-md); }
.pv-wrap { position: relative; background: #05070d; display: flex; justify-content: center; }
.pv-wrap .pv { width: 100%; }
.scard.vert .pv-wrap { padding: 0; }
.scard.vert .pv-wrap .pv { width: auto; height: 300px; aspect-ratio: 9 / 16; }
.pv-badges { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; gap: 6px; pointer-events: none; z-index: 2; }
.pv-badges .tag { box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.pv-badges .tag.state { background: rgba(15, 23, 42, .78); color: #fff; backdrop-filter: blur(6px); }
.pv-badges .tag.state .dot { box-shadow: none; }
.prog { height: 3px; background: var(--line-2); }
.prog i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }
.scard-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.scard-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.scard-title b { font-size: 15px; display: block; }
.scard-title .sub { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; margin-top: 2px; flex-wrap: wrap; }
.now { display: flex; align-items: center; gap: 10px; padding: 9px 11px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; font-size: 12.5px; }
.now .ic { color: var(--muted); }
.now .now-name { font-weight: 600; color: var(--ink); }
.now .now-src { color: var(--muted); }
.scard-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.scard-edit input { padding: 7px 10px; font-size: 13px; }
.orient { display: flex; gap: 4px; grid-column: 1 / -1; }
.orient button { flex: 1; justify-content: center; padding: 6px 8px; font-size: 12.5px; color: var(--muted); }
.orient button.on { border-color: var(--accent); color: var(--accent-2); background: var(--accent-soft); }
.scard-actions { display: flex; gap: 2px; border-top: 1px solid var(--line-2); padding-top: 8px; margin-top: 2px; }
.scard-actions .spacer { flex: 1; }

/* Elegir varios contenidos dentro de otro (banda lateral / publicidad) */
.multi-list { display: flex; flex-wrap: wrap; gap: 6px; }
.mc { padding: 6px 11px; font-size: 13px; font-weight: 500; border-radius: 999px; }
.mc b { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; }
.mc small { color: var(--muted); }
.mc.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); }

/* Contenido elegido para la pantalla */
.asig { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.asig-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 12.5px; color: var(--ink-2); }
.asig-head span { display: inline-flex; align-items: center; gap: 6px; }
.asig-list { display: flex; flex-wrap: wrap; gap: 6px; }
.asig-btn { justify-content: center; }
.pick .pick-rol { position: absolute; top: 8px; left: 8px; z-index: 2; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.pub { margin-top: 16px; border: 1.5px solid var(--accent); background: var(--accent-soft); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.pub-head { font-size: 13px; line-height: 1.5; color: var(--ink-2); }
.pub-lista { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; font-weight: 600; }
.pub .field { margin-bottom: 0; }
.pick .pick-warn { display: block; padding: 0 10px 8px; font-size: 11px; color: var(--warn); font-weight: 600; }

/* Acciones siempre visibles en tarjetas de contenidos y plantillas */
.card-acts { display: flex; align-items: center; gap: 6px; padding: 0 12px 12px; margin-top: auto; }
.card-acts > button:not(.icon-btn) { padding: 6px 11px; font-size: 13px; }
.card-acts .spacer { flex: 1; }

/* Por aprobar */
.pending { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.pending-item {
  background: var(--surface); border: 1px solid #fed7aa; border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 6px; box-shadow: 0 0 0 4px var(--accent-soft); animation: rise .35s var(--ease) both;
}
.pending-item .code { font-family: "JetBrains Mono", Consolas, monospace; font-size: 30px; font-weight: 800; letter-spacing: .14em; }
.pending-item .acts { display: flex; gap: 8px; margin-top: 6px; }
.pending-item .acts button { flex: 1; justify-content: center; }
.pending-item .same { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.pending-item .same-row { display: flex; gap: 6px; }
.pending-item .same-row select { flex: 1; min-width: 0; padding: 7px 9px; font-size: 13px; }

/* Conectar */
.connect {
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap;
  background: var(--side); color: var(--side-ink); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 22px;
}
.connect .grow { flex: 1; min-width: 240px; }
.connect b { color: #fff; font-size: 15px; display: block; margin-bottom: 4px; }
.connect p { margin: 0; font-size: 13px; }
.url-pill { display: flex; align-items: center; gap: 8px; background: var(--side-2); border-radius: 10px; padding: 8px 8px 8px 14px; color: #fff; font-family: "JetBrains Mono", Consolas, monospace; font-size: 13.5px; }
.url-pill button { background: var(--accent); border: 0; color: #fff; padding: 6px 10px; }
.url-pill button:hover { background: var(--accent-2); }

/* ============ Contenidos y plantillas ============ */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; box-shadow: var(--shadow-sm); transition: box-shadow .2s, transform .2s var(--ease);
  animation: rise .35s var(--ease) both;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card .pv-wrap { cursor: pointer; }
.card .overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: rgba(8, 11, 20, .55); opacity: 0; transition: opacity .2s; z-index: 2;
}
.card .pv-wrap:hover .overlay { opacity: 1; }
.card .overlay button { background: #fff; border: 0; box-shadow: var(--shadow-md); }
.card .overlay button.primary { background: var(--accent); }
.card-body { padding: 12px 14px; display: flex; align-items: flex-start; gap: 8px; }
.card-body .grow { flex: 1; min-width: 0; }
.card-body strong { font-size: 14.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-body .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 180px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-md); padding: 6px;
  animation: pop .15s var(--ease);
}
.menu-list button { width: 100%; border: 0; background: none; justify-content: flex-start; padding: 8px 10px; font-weight: 500; }
.menu-list button:hover { background: var(--line-2); }
.menu-list button.danger:hover { background: var(--danger-soft); }
.pv { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #05070d; overflow: hidden; }
.pv .stage { transition: none; }
.ed-preview .pv.vert { aspect-ratio: 9 / 16; width: auto; height: min(72vh, 680px); margin: 0 auto; }

/* ============ Programación ============ */
.rules { display: flex; flex-direction: column; gap: 10px; }
.rule {
  display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow-sm); animation: rise .3s var(--ease) both; border-left: 4px solid var(--rc, var(--line));
}
.rule.paused { opacity: .65; }
.rule-main { min-width: 0; }
.rule-main b { font-size: 14.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rule-meta { display: flex; gap: 6px 14px; flex-wrap: wrap; margin-top: 6px; color: var(--muted); font-size: 12.5px; }
.rule-meta span { display: inline-flex; align-items: center; gap: 5px; }
.rule-acts { display: flex; gap: 2px; }

.week { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 12px; box-shadow: var(--shadow-sm); overflow-x: auto; }
.week-grid { min-width: 720px; }
.week-hours, .week-row { display: grid; grid-template-columns: 52px 1fr; }
.week-hours .hours { display: grid; grid-template-columns: repeat(12, 1fr); font-size: 11px; color: var(--muted); padding-bottom: 6px; }
.week-row { border-top: 1px solid var(--line-2); }
.week-row .day { font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 10px 0; }
.week-row.today .day { color: var(--accent); }
.week-track {
  position: relative; min-height: 38px;
  background-image: repeating-linear-gradient(90deg, var(--line-2) 0 1px, transparent 1px calc(100% / 12));
}
.week-row.today .week-track { background-color: #fffaf6; }
.bar {
  position: absolute; height: 18px; border-radius: 6px; background: var(--rc); color: #fff; font-size: 11px; font-weight: 600;
  padding: 0 7px; line-height: 18px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer;
  box-shadow: 0 2px 6px -2px rgba(0,0,0,.3); transition: filter .15s, transform .15s;
}
.bar:hover { filter: brightness(1.08); transform: translateY(-1px); }
.bar.ranged { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.18) 0 6px, transparent 6px 12px); }
.now-line { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--live); border-radius: 2px; z-index: 3; }
.now-line:before { content: ''; position: absolute; top: -3px; left: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--live); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--rc); }

/* ============ Enviar ahora ============ */
.send-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.step { margin-bottom: 22px; }
.step-title { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 12px; }
.step-title .n { width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 12px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.pick {
  position: relative; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; background: var(--surface);
  padding: 0; display: block; text-align: left; font-weight: 500; transition: border-color .15s, transform .15s var(--ease), box-shadow .15s;
}
.pick:hover { border-color: #cfd3db; transform: translateY(-1px); background: var(--surface); }
.pick.on { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.pick .pick-name { padding: 8px 10px; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.pick .order { position: absolute; top: 8px; right: 8px; z-index: 2; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; box-shadow: var(--shadow-md); animation: pop .2s var(--ease); }
.send-box { position: sticky; top: 24px; }
.send-box .big { width: 100%; justify-content: center; padding: 13px; font-size: 15px; margin-top: 6px; }
.send-summary { font-size: 13px; color: var(--ink-2); margin: 10px 0 4px; }
.live-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.live-item { border: 1px solid #fecdd3; background: #fff7f8; border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.live-item .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--live); }

/* Selector de contenidos con arrastrar */
.picked { list-style: none; margin: 0 0 8px; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; counter-reset: pick; }
.picked li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line-2); background: var(--surface); counter-increment: pick; transition: background .15s; }
.picked li:last-child { border-bottom: none; }
.picked li .grip { cursor: grab; color: #a0a8b6; display: flex; }
.picked li .num:before { content: counter(pick); font-weight: 800; color: var(--accent); }
.picked li .name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picked li.none { color: var(--muted); justify-content: center; padding: 14px; }
.touch-only { display: none; }
@media (pointer: coarse) { .touch-only { display: inline-flex; } .picked li .grip { display: none; } }
.picked li.dragging { opacity: .4; }
.picked li.over { background: var(--accent-soft); }

.seg { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.seg label { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; font-weight: 600; background: var(--surface); transition: border-color .15s, background .15s; }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 12px; border: 1px dashed var(--line); border-radius: 12px; background: var(--surface-2); }
.checks label { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.days label { border: 1px solid var(--line); border-radius: 10px; padding: 7px 11px; cursor: pointer; display: flex; gap: 6px; align-items: center; font-weight: 600; transition: border-color .15s, background .15s; }
.days label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.quick { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.quick button { font-size: 12px; padding: 4px 10px; }

/* ============ Modal, confirmación y avisos ============ */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(8, 11, 20, .5); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 32px 16px; overflow-y: auto; animation: fade .2s; }
.modal-box { background: var(--surface); border-radius: 18px; width: 100%; max-width: 1180px; box-shadow: var(--shadow-lg); animation: pop .25s var(--ease); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 18px; font-weight: 700; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 18px 18px; }
.modal-box.narrow { max-width: 760px; }
.modal-box.tiny { max-width: 420px; }
.editor { display: grid; grid-template-columns: minmax(320px, 440px) 1fr; gap: 26px; align-items: start; }
.ed-preview { position: sticky; top: 0; }
.ed-preview .pv { border-radius: 12px; box-shadow: var(--shadow-md); }
.upl { display: flex; gap: 8px; }
.upl input[type=text] { flex: 1; }
.upl .btn { white-space: nowrap; }
.upl input[type=file] { display: none; }
.copy { display: flex; gap: 8px; }
.copy input { flex: 1; font-family: "JetBrains Mono", Consolas, monospace; font-size: 12.5px; }

.toasts { position: fixed; bottom: 24px; right: 24px; z-index: 40; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  display: flex; align-items: center; gap: 10px; background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px;
  box-shadow: var(--shadow-lg); font-weight: 500; max-width: 420px; animation: slide .3s var(--ease);
}
.toast .ic { color: #4ade80; }
.toast.err { background: #7f1d1d; }
.toast.err .ic { color: #fca5a5; }
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; }

/* ============ Ingreso ============ */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 32px; box-shadow: var(--shadow-lg); animation: rise .4s var(--ease);
}
.login .brand { color: var(--ink); margin-bottom: 26px; }
.login .brand small { color: var(--muted); }
.login h2 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.login form { margin-top: 20px; }
.login button.primary { width: 100%; justify-content: center; padding: 12px; margin-top: 4px; }
.login .err { color: var(--danger); background: var(--danger-soft); font-size: 13px; padding: 9px 12px; border-radius: 10px; margin: 0 0 14px; }

/* ============ Animaciones ============ */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes slide { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ============ Celular y tableta ============ */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .send-layout { grid-template-columns: 1fr; }
  .send-box { position: static; }
}
@media (max-width: 860px) {
  .side { display: none; }
  main { margin-left: 0; padding: 76px 16px 100px; }
  .topbar {
    display: flex; position: fixed; inset: 0 0 auto 0; z-index: 6; height: 60px; align-items: center; justify-content: space-between;
    padding: 0 16px; background: rgba(11, 15, 26, .96); backdrop-filter: blur(10px);
  }
  .topbar .brand-mark { width: 30px; height: 30px; }
  .topbar .brand-mark:before { left: 6px; top: 8px; width: 16px; height: 10px; }
  .topbar .brand-mark:after { left: 11px; top: 21px; }
  .topbar-user { display: flex; align-items: center; gap: 6px; color: var(--side-ink); }
  .tabbar {
    display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; inset: auto 0 0 0; z-index: 6;
    background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar button { position: relative; flex-direction: column; gap: 3px; border: 0; background: none; padding: 6px 2px; font-size: 10.5px; font-weight: 600; color: var(--muted); border-radius: 10px; }
  .tabbar button.active { color: var(--accent); }
  .tabbar button .count { position: absolute; top: 2px; right: calc(50% - 20px); background: var(--accent); color: #fff; font-size: 10px; padding: 0 5px; border-radius: 999px; }
  .tabbar button .count.live { background: var(--live); }
  .page-head h1 { font-size: 23px; }
  .editor { grid-template-columns: 1fr; }
  .ed-preview { position: static; order: -1; }
  .ed-preview .pv.vert { height: 52vh; }
  .row3 { grid-template-columns: 1fr 1fr; }
  .rule { grid-template-columns: auto 1fr; }
  .rule-acts { grid-column: 1 / -1; justify-content: flex-end; border-top: 1px solid var(--line-2); padding-top: 8px; }
  .toasts { left: 16px; right: 16px; bottom: 84px; align-items: stretch; }
  .modal { padding: 0; }
  .modal-box { border-radius: 0; min-height: 100%; }
  .modal-foot { position: sticky; bottom: 0; border-radius: 0; }
  .search { max-width: none; }
}
@media (max-width: 520px) {
  .stats { gap: 10px; }
  .stat { padding: 13px; }
  .stat .stat-val { font-size: 24px; }
  .row2 { grid-template-columns: 1fr; }
  .wall, .grid { grid-template-columns: 1fr; }
  .pick-grid { grid-template-columns: 1fr 1fr; }
}
