:root {
  --navy: #00283b; --blue: #1890d7; --blue-d: #0b5f97; --ice: #effafd; --ink: #0f2430; --mut: #5b6f7a;
  --line: #d9e4ea; --bg: #f4f8fa; --red: #a61b1b; --green: #17794a; --amber: #8a5a00;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Poppins, system-ui, -apple-system, 'Segoe UI', sans-serif; color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 22px; }
h3 { font-size: 16px; }
p { margin: 0; }
.mut { color: var(--mut); }
.err { color: var(--red); font-size: 14px; min-height: 1.2em; }

.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 16px; border-radius: 8px; cursor: pointer; min-height: 40px; white-space: nowrap;
}
.btn:hover { border-color: var(--blue); }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(24, 144, 215, .45); outline-offset: 1px; }
.btn.primary { background: var(--blue-d); border-color: var(--blue-d); color: #fff; }
.btn.primary:hover { background: #094f7e; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; color: inherit; border-color: rgba(255, 255, 255, .35); }
.btn.sm { padding: 5px 10px; min-height: 34px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--mut); }
input, textarea, select {
  display: block; width: 100%; margin-top: 4px; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; min-height: 40px;
}
textarea { min-height: 96px; resize: vertical; }
input[type=checkbox] { display: inline-block; width: 18px; height: 18px; min-height: 0; margin: 0 8px 0 0; vertical-align: -3px; }
label.check { font-size: 14px; color: var(--ink); font-weight: 400; }

/* Login */
.login { max-width: 380px; margin: 9vh auto; padding: 32px; background: #fff; border: 1px solid var(--line); border-radius: 14px; display: grid; gap: 14px; }
.login img { width: 190px; margin: 0 auto 4px; }
.login h1 { font-size: 20px; text-align: center; }

/* Encabezado */
.top { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 20px; padding: 10px 24px; flex-wrap: wrap; }
.top img { height: 46px; }
.top nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.top nav button { font: inherit; font-weight: 600; color: #cfe9f7; background: none; border: 0; padding: 9px 14px; border-radius: 8px; cursor: pointer; }
.top nav button:hover { background: rgba(255, 255, 255, .08); }
.top nav button[aria-current=page] { background: #fff; color: var(--navy); }
.top nav button.alert { color: #ffd0d0; }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; }

main { max-width: 1080px; margin: 0 auto; padding: 28px 24px 80px; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.card + .card { margin-top: 16px; }
.stack { display: grid; gap: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Barra de listas */
.plbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.plrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.plrow select { width: auto; min-width: 260px; margin-top: 0; font-weight: 600; font-size: 16px; }
.plmenu { display: flex; gap: 6px; flex-wrap: wrap; }
.onair { color: var(--green); font-weight: 700; font-size: 14px; background: #dff3e8; padding: 7px 14px; border-radius: 99px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.tbtns { display: flex; gap: 8px; }
.seg { display: inline-flex; background: #e6eef2; border-radius: 10px; padding: 4px; }
.seg button { font: inherit; font-weight: 600; border: 0; background: none; padding: 8px 16px; border-radius: 8px; cursor: pointer; color: var(--mut); }
.seg button[aria-selected=true] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.seg b { font-weight: 600; background: rgba(0, 40, 59, .08); border-radius: 99px; padding: 0 8px; margin-left: 4px; font-size: 13px; }
.filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 14px 0; }
.filters input[type=search] { width: 240px; margin-top: 0; }
.tagfilter { display: flex; gap: 6px; flex-wrap: wrap; }
.tf { font: inherit; font-size: 13px; font-weight: 600; border: 1px solid var(--line); background: var(--tc, #fff); color: var(--ink); border-radius: 99px; padding: 5px 12px; cursor: pointer; }
.tf.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.summary { font-size: 14px; color: var(--ink); margin-bottom: 10px; }
.hint { font-size: 13px; color: var(--mut); margin-top: 12px; }
.empty { background: #fff; border: 2px dashed var(--line); border-radius: 12px; padding: 32px; text-align: center; color: var(--mut); }
.empty b { color: var(--ink); display: block; margin-bottom: 6px; }
.link { font: inherit; background: none; border: 0; color: var(--blue-d); text-decoration: underline; cursor: pointer; padding: 0; }

/* Filas de la lista */
.rows { display: grid; gap: 6px; }
.row { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 8px 4px; }
.row.dragging { box-shadow: 0 12px 30px rgba(0, 28, 42, .25); border-color: var(--blue); opacity: .96; }
.row.st-pausado .thumb, .row.st-vencido .thumb, .row.st-programado .thumb { opacity: .45; }
.row.st-pausado h3, .row.st-vencido h3 { color: var(--mut); }
.ph { border: 2px dashed var(--blue); border-radius: 10px; background: var(--ice); }
.handle { font-size: 22px; line-height: 1; color: #8aa0ab; background: none; border: 0; cursor: grab; padding: 10px 8px; touch-action: none; border-radius: 6px; }
.handle:active { cursor: grabbing; }
.handle:hover { color: var(--ink); background: #eef3f6; }
.num { width: 24px; text-align: right; font-weight: 600; color: var(--mut); font-size: 13px; flex: none; }
.thumb { flex: none; position: relative; overflow: hidden; border-radius: 6px; background: var(--navy); }
.thumb.sm { width: 128px; height: 72px; }
.thumb.sm .stage { transform: scale(.06667); }
.thumb.md { width: 100%; aspect-ratio: 16 / 9; }

.info { flex: 1; min-width: 0; }
.info h3, .pc h3 { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { font-size: 13px; color: var(--mut); margin-top: 3px; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 5px; }
.tag { font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 99px; color: var(--ink); }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 99px; margin-right: 6px; }
.chip.al_aire { background: #dff3e8; color: var(--green); }
.chip.activa { background: #e3f1fb; color: var(--blue-d); }
.chip.programado { background: #fdf0d5; color: var(--amber); }
.chip.vencido { background: #fbe6e6; color: var(--red); }
.chip.pausado { background: #e9eef1; color: var(--mut); }

/* Interruptor activa / pausada */
.switch { position: relative; width: 44px; height: 26px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: #c4d0d6; border-radius: 99px; transition: background .2s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid rgba(24, 144, 215, .45); outline-offset: 2px; }

/* Biblioteca */
.selbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 48px; padding: 6px 12px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }
.selbar.on { background: var(--navy); color: #fff; position: sticky; top: 8px; z-index: 5; }
.selbar.on .btn:not(.primary) { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .4); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.pc { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.pc.sel { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue); }
.pc h3 { margin-top: 8px; }
.pick { position: absolute; top: 14px; left: 14px; z-index: 2; background: #fff; border-radius: 6px; padding: 5px; line-height: 0; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); cursor: pointer; }
.pick input { margin: 0; }
.pcbtns { display: flex; gap: 6px; align-items: center; margin-top: auto; padding-top: 10px; }
.inlist { font-size: 13px; font-weight: 600; color: var(--green); flex: 1; }
.pcbtns .btn.primary { flex: 1; }

body.dropping::after { content: 'Suelte los archivos para agregarlos a la lista'; position: fixed; inset: 12px; border: 4px dashed var(--blue); border-radius: 16px; background: rgba(239, 250, 253, .92); display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; color: var(--navy); z-index: 60; pointer-events: none; }

/* Plantillas */
.tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tpl { font: inherit; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; cursor: pointer; }
.tpl:hover { border-color: var(--blue); }
.tpl b { display: block; font-size: 15px; }
.tpl span { font-size: 13px; color: var(--mut); }

/* Diálogo y editor */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(1080px, calc(100vw - 24px)); max-height: calc(100vh - 24px); color: var(--ink); }
dialog::backdrop { background: rgba(0, 28, 42, .6); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--line); }
dialog[open], dialog form { display: flex; flex-direction: column; min-height: 0; }
dialog form { flex: 1; }
.dlg-body { padding: 22px; overflow: auto; flex: 1; min-height: 0; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); }
.editor { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.25fr); gap: 24px; align-items: start; }
.preview { position: sticky; top: 0; }
.pv { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 10px; background: var(--navy); }
.pairs .pair { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 6px; }
.pairs input { margin-top: 0; }
.file { display: flex; gap: 10px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.file .name { font-size: 13px; color: var(--mut); font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin: 0; }
legend { font-size: 13px; font-weight: 600; color: var(--mut); padding: 0 6px; }

/* Pantalla */
.status { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 600; }
.led { width: 14px; height: 14px; border-radius: 50%; background: #b7c3ca; flex: none; }
.led.on { background: #1fa863; box-shadow: 0 0 0 5px rgba(31, 168, 99, .18); }
.led.off { background: var(--red); }
.live { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 10px; background: #000; display: block; }
code.url { background: var(--ice); padding: 3px 8px; border-radius: 6px; font-size: 14px; word-break: break-all; }

.banner { background: #fbe6e6; border: 1px solid #f0bcbc; color: #6d1111; border-radius: 12px; padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--mut); padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid #edf2f5; vertical-align: top; }
.scroll { overflow-x: auto; }

#toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 20px; border-radius: 99px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.bad { background: var(--red); }

@media (max-width: 760px) {
  main { padding: 18px 12px 60px; }
  .top { padding: 10px 12px; gap: 10px; }
  .top img { height: 34px; }
  .top nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .top nav button { padding: 7px 10px; font-size: 14px; white-space: nowrap; }
  .who { margin-left: auto; font-size: 13px; }
  .row { flex-wrap: wrap; padding: 8px; gap: 8px; }
  .row .num { display: none; }
  .row .handle { padding: 8px 4px; }
  .thumb.sm { width: 96px; height: 54px; }
  .thumb.sm .stage { transform: scale(.05); }
  .row .info { flex: 1 1 100px; }
  .row .btn { flex: 1 1 40%; }
  .plrow select { min-width: 0; width: 100%; }
  .filters input[type=search] { width: 100%; }
  .tbtns { width: 100%; }
  .tbtns .btn { flex: 1; }
  .editor, .row2 { grid-template-columns: 1fr; }
  .preview { position: static; order: -1; }
}

.qrhint { font-size: 12.5px; color: var(--mut); margin-top: -8px; word-break: break-all; }
.qrhint.bad { color: var(--red); }

/* Programación de listas */
.onair.wait { color: var(--blue-d); background: #e3f1fb; }
.schedline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #fdf6e3; border: 1px solid #f0dfb0; border-radius: 10px; padding: 10px 14px; margin: -6px 0 16px; font-size: 14px; }
.schedline > span:nth-child(2) { flex: 1; }
.schedrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.bdnote { background: #fff4d6; border-radius: 8px; padding: 8px 12px; font-size: 14px; margin-bottom: 10px; }

/* Cumpleaños */
.upc { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.upi { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.upi b { font-size: 15px; }
.upi.now { background: #fff4d6; border-color: #f0d48a; }
.today { color: var(--amber); }
.face { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; display: block; }
.face.none { background: #e3f1fb; color: var(--blue-d); font-weight: 700; display: flex; align-items: center; justify-content: center; }
tr.off td { color: var(--mut); }
.meter { height: 10px; background: #e6eef2; border-radius: 99px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--blue); border-radius: 99px; }
