:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1f24;
  --muted: #6b7280;
  --line: #e3e5e9;
  --primary: #2563eb;
  --primary-text: #ffffff;
  --danger: #dc2626;
  --ok-bg: #e8f6ee;
  --ok-text: #146c3a;
  --err-bg: #fdecec;
  --err-text: #9b1c1c;
  --on: #16a34a;
  --off: #9ca3af;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418;
    --card: #1b1e24;
    --text: #e8eaed;
    --muted: #9aa1ac;
    --line: #2b2f37;
    --primary: #3b82f6;
    --ok-bg: #12301f;
    --ok-text: #7fd8a4;
    --err-bg: #3a1717;
    --err-text: #f4a3a3;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0; display: flex; align-items: center; gap: .6rem; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }

.topbar {
  display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap;
  padding: .8rem 1rem; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); }
.topbar nav { display: flex; gap: .3rem; flex: 1; }
.topbar nav a { padding: .35rem .75rem; border-radius: 8px; color: var(--muted); }
.topbar nav a.active, .topbar nav a:hover { background: var(--bg); color: var(--text); }

.container { max-width: 1040px; margin: 0 auto; padding: 1.4rem 1rem 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }

.card {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem; color: var(--text);
}
a.card:hover { border-color: var(--primary); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.grid .card { margin: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 720px) { .two { grid-template-columns: 1fr; } }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.empty { text-align: center; padding: 2rem 1rem; }

label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .8rem; }
input, select {
  display: block; width: 100%; margin-top: .25rem; padding: .55rem .7rem;
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px;
}
input[type=file] { padding: .5rem; }
input[type=checkbox] { display: inline; width: auto; margin: 0 .4rem 0 0; }
.row { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; }
.row label { flex: 1; min-width: 160px; margin: 0; }

.btn {
  display: inline-block; padding: .55rem 1rem; font: inherit; font-weight: 600; cursor: pointer;
  color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.btn:hover:not(:disabled) { border-color: var(--primary); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn.danger { color: var(--danger); }
.btn.full { width: 100%; }
.btn.sm { padding: .3rem .6rem; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; }
.link.danger { color: var(--danger); }
.logout { margin: 0; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: var(--ok-bg); color: var(--ok-text); }
.flash.error { background: var(--err-bg); color: var(--err-text); }

.badge { font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 99px; color: #fff; }
.badge.on { background: var(--on); }
.badge.off { background: var(--off); }
.tv-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .3rem; }

.auth { max-width: 380px; margin: 8vh auto 0; }
.auth h1 { margin-bottom: .3rem; }

.media-item video, .media-item img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #000; border-radius: 8px; margin-bottom: .5rem;
}
.media-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-item form { margin-top: .4rem; }
progress { width: 100%; margin: .5rem 0; }

.items { list-style: none; margin: 0; padding: 0; }
.items li { display: flex; align-items: center; gap: .8rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.items li:first-child { border-top: 0; }
.thumb { width: 96px; flex: none; }
.thumb video, .thumb img { width: 96px; aspect-ratio: 16 / 9; object-fit: cover; background: #000; border-radius: 6px; display: block; }
.grow { flex: 1; min-width: 0; }
.grow strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); margin-top: .2rem; }
.inline input { width: 80px; margin: 0; padding: .25rem .4rem; }
.item-actions { display: flex; gap: .3rem; flex: none; }
.rename { display: flex; gap: .5rem; flex: 1; max-width: 480px; }
.rename input { margin: 0; font-size: 1.2rem; font-weight: 700; }

.checklist { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: .4rem .8rem; margin-bottom: .8rem; }
.check { display: flex; align-items: center; color: var(--text); font-size: .95rem; margin: .35rem 0; }

.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.info { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; overflow-wrap: anywhere; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .45rem .3rem; border-top: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 500; }

@media (max-width: 560px) {
  .items li { flex-wrap: wrap; }
  .item-actions { width: 100%; justify-content: flex-end; }
}

/* ---------- Telas por TV ---------- */
.grid.tvs { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.shot {
  aspect-ratio: 16 / 9; background: #000; border-radius: 8px; margin-bottom: .7rem;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.shot img { width: 100%; height: 100%; object-fit: contain; display: block; }
.shot.big { margin-bottom: .5rem; }
.shot-meta { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.shot-meta form { margin: 0; }
.badge.idle { background: #d97706; }
h1 .badge { font-size: .75rem; vertical-align: middle; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; }

.tv-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 860px) { .tv-layout { grid-template-columns: minmax(0, 1fr); } }

.queue { list-style: none; margin: 0 0 1rem; padding: 0; border: 1px solid var(--line); border-radius: 8px; }
.queue li { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-top: 1px solid var(--line); background: var(--card); }
.queue li:first-child { border-top: 0; border-radius: 8px 8px 0 0; }
.queue li:last-child { border-radius: 0 0 8px 8px; }
.queue li.dragging { opacity: .6; outline: 2px solid var(--primary); position: relative; z-index: 1; }
.queue form { margin: 0; }
.handle { cursor: grab; color: var(--muted); font-size: 1.1rem; letter-spacing: -2px; padding: .4rem .2rem; touch-action: none; user-select: none; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 1rem; cursor: pointer; padding: .4rem; border-radius: 6px; }
.icon-btn:hover { color: var(--danger); background: var(--bg); }
.note { background: var(--bg); border-radius: 8px; padding: .5rem .7rem; }

.dropzone {
  border: 2px dashed var(--line); border-radius: 10px; padding: 1.3rem 1rem; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--bg); }
.dropzone .dz-idle, .dropzone .dz-busy { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.dropzone [hidden] { display: none; }
.dz-icon { font-size: 1.4rem; color: var(--primary); }
.card.dropzone { margin-bottom: 1rem; }

details > summary { cursor: pointer; color: var(--primary); font-weight: 600; margin: .3rem 0; }
details.library { margin-top: 1rem; }
details.advanced > summary { color: var(--text); margin: 0; }
details.advanced[open] > summary { margin-bottom: .8rem; }

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: 1rem; }
.controls .btn { width: 100%; }
.volume { display: flex; align-items: flex-end; gap: .6rem; margin: 0; }
.volume label { flex: 1; margin: 0; }
.volume input[type=range] { padding: 0; border: 0; background: none; }

.days { width: 100%; border-collapse: collapse; margin: .4rem 0 .8rem; }
.days td { padding: .2rem .2rem; }
.days input[type=time] { margin: 0; padding: .3rem .4rem; }
.days .check { margin: 0; font-size: .9rem; }
.schedule-edit .check { font-size: .9rem; }

/* ---------- Celular ---------- */
.topbar nav a { white-space: nowrap; }
@media (max-width: 560px) {
  .topbar { flex-wrap: nowrap; gap: .5rem; padding: .6rem .7rem; }
  .brand { display: none; }
  .topbar nav { overflow-x: auto; gap: .1rem; }
  .topbar nav a { padding: .35rem .55rem; font-size: .9rem; }
  .container { padding: 1rem .7rem 2.5rem; }
  .card { padding: .9rem; }
  .queue li { gap: .5rem; padding: .5rem; }
  .queue .thumb, .queue .thumb video, .queue .thumb img { width: 64px; }
  .queue .inline { flex-wrap: wrap; }
  .queue .inline input { width: 56px; }
  .controls .btn { padding: .55rem .4rem; font-size: .9rem; }
}
