/* TV das Lojas — painel. Sistema: Manrope, hairlines, cor só nos destaques. */
:root {
  --bg: #fafaf9; --panel: #ffffff; --line: #e7e7e4; --line-2: #d9d9d5;
  --t1: #161616; --t2: #5a5a57; --t3: #9a9a95;
  --acc: #c8102e; --acc-soft: #fdeef0; --ok: #1f9d55; --ok-soft: #e8f6ee; --warn: #b7791f; --warn-soft: #fbf3e4;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px -16px rgba(0,0,0,.18);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111110; --panel: #19191a; --line: #2a2a2b; --line-2: #343436;
    --t1: #f2f2f0; --t2: #a9a9a4; --t3: #6c6c68; --acc: #ff4d5a; --acc-soft: #3a1a1e; --ok: #39c26f; --ok-soft: #14301f; --warn: #e0a84a; --warn-soft: #33270f;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
body { font-family: Manrope, system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--t1); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; font-weight: 700; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
.muted { color: var(--t2); } .faint { color: var(--t3); } .small { font-size: 13px; } .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.hidden { display: none !important; }

/* progresso no topo */
#progress { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: var(--acc); z-index: 50; transition: width .25s ease, opacity .4s; opacity: 0; }
#progress.on { opacity: 1; }

/* topo */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--acc); }
.nav { display: flex; gap: 2px; margin-left: 8px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav button { background: none; border: 0; padding: 8px 12px; border-radius: 8px; color: var(--t2); cursor: pointer; position: relative; white-space: nowrap; }
.nav button:hover { color: var(--t1); }
.nav button.active { color: var(--t1); font-weight: 700; }
.nav button.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--acc); border-radius: 2px; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--t2); font-size: 13px; white-space: nowrap; }
/* Celular: marca e usuário na 1ª linha, menu rolável ocupando a 2ª */
@media (max-width: 720px) {
  .topbar-in { height: auto; flex-wrap: wrap; padding: calc(10px + env(safe-area-inset-top)) 16px 0; gap: 8px 12px; }
  .input, select.input { font-size: 16px; } /* iOS não dá zoom em campo com 16px */
  .brand { order: 1; } .topbar .spacer { order: 2; } .topbar .who { display: none; } #btnSair { order: 3; }
  .nav { order: 4; flex-basis: 100%; margin: 0 -16px; padding: 0 10px; }
  .nav button { padding: 10px 10px 12px; }
  .nav button.active::after { bottom: 0; }
}

main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 80px; }
.view { animation: fade .25s ease; }
@keyframes fade { from { opacity: .3; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view { animation: none; } }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head p { margin: 4px 0 0; color: var(--t2); max-width: 640px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* botões */
.btn { border: 1px solid var(--line-2); background: var(--panel); border-radius: 9px; padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; transition: transform .12s, border-color .12s, background .12s; }
.btn:hover { border-color: var(--t3); transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--t2); }
.btn.ghost:hover { background: var(--panel); border-color: var(--line); color: var(--t1); }
.btn.danger { color: var(--acc); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.icon { padding: 6px 8px; }

/* campos */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; color: var(--t2); font-weight: 600; }
.input, select.input, textarea.input { border: 1px solid var(--line-2); background: var(--panel); border-radius: 9px; padding: 8px 11px; outline: none; width: 100%; min-width: 0; }
.input:focus { border-color: var(--t2); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--t3) 50%), linear-gradient(135deg, var(--t3) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.inline { display: inline-flex; align-items: center; gap: 8px; }
.switch { position: relative; width: 36px; height: 20px; border-radius: 20px; background: var(--line-2); border: 0; cursor: pointer; transition: background .15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch.on { background: var(--ok); } .switch.on::after { transform: translateX(16px); }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card h3 { display: flex; align-items: center; gap: 8px; }
.card .meta { color: var(--t2); font-size: 13px; margin-top: 2px; }
.card .foot { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 20px; letter-spacing: .02em; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.on { color: var(--ok); background: var(--ok-soft); } .status.on::before { animation: pulse 1.6s infinite; }
.status.off { color: var(--t3); background: var(--bg); }
.status.pend { color: var(--warn); background: var(--warn-soft); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 8px; border-radius: 20px; border: 1px solid var(--line-2); color: var(--t2); }
.chip.acc { border-color: transparent; background: var(--acc-soft); color: var(--acc); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin-top: 10px; }
.kv dt { color: var(--t3); } .kv dd { margin: 0; }

/* resumo */
.stats { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 20px; }
.stat b { font-size: 24px; font-weight: 800; letter-spacing: -.03em; display: block; line-height: 1.1; }
.stat span { font-size: 12.5px; color: var(--t2); }
.stat.on b { color: var(--ok); }

/* lista vazia */
.empty { border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 32px; text-align: center; color: var(--t2); }
.empty b { color: var(--t1); display: block; margin-bottom: 4px; }

/* pendentes */
.pend-list { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.pend { border: 1px solid var(--warn); background: var(--warn-soft); border-radius: 10px; padding: 8px 12px; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.pend .code { font-family: ui-monospace, Menlo, monospace; font-weight: 800; letter-spacing: .12em; font-size: 15px; color: var(--t1); }

/* upload */
.drop { border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--t2); cursor: pointer; transition: border-color .15s, background .15s; margin-bottom: 18px; }
.drop.over, .drop:hover { border-color: var(--acc); background: var(--acc-soft); }
.drop b { color: var(--t1); }
.queue { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.q-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.q-bar { grid-column: 1 / -1; height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.q-bar i { display: block; height: 100%; background: var(--acc); width: 0; transition: width .2s; }
.q-item.err { border-color: var(--acc); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.media { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.thumb { aspect-ratio: 16 / 9; background: #0e0e0e; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb .dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 5px; font-weight: 700; }
.thumb .kind { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.thumb .ph { color: #555; font-size: 12px; }
.media .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.media .name { font-weight: 700; font-size: 14px; border: 0; background: transparent; width: 100%; padding: 2px 0; border-bottom: 1px solid transparent; outline: none; }
.media .name:focus { border-bottom-color: var(--line-2); }
.media .uses { font-size: 12px; color: var(--t3); }
.media .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }

/* playlists */
.split { display: grid; grid-template-columns: 280px 1fr; gap: 18px; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-item { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; transition: padding-left .15s; }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { padding-left: 18px; }
.list-item.active { background: var(--bg); box-shadow: inset 3px 0 0 var(--acc); }
.list-item .sub { font-size: 12px; color: var(--t3); }
.items { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.item { display: grid; grid-template-columns: 28px 84px 1fr auto; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.item.off { opacity: .5; }
.item .n { color: var(--t3); font-size: 12px; font-weight: 700; text-align: center; }
.item .th { width: 84px; aspect-ratio: 16/9; background: #0e0e0e; border-radius: 6px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.item .th img { width: 100%; height: 100%; object-fit: contain; }
.item .info b { display: block; font-size: 14px; }
.item .info span { font-size: 12px; color: var(--t2); }
.item .ctl { display: flex; align-items: center; gap: 4px; }
.item .ctl input { width: 58px; padding: 4px 6px; font-size: 13px; }
@media (max-width: 600px) { .item { grid-template-columns: 24px 64px 1fr; } .item .ctl { grid-column: 1 / -1; justify-content: flex-end; } }
.sticky-bar { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); padding: 12px 0; margin-top: 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sticky-bar .spacer { flex: 1; }

/* regras */
.rule { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; }
.rule .when { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.days { display: flex; gap: 4px; flex-wrap: wrap; }
.days button { border: 1px solid var(--line-2); background: var(--panel); border-radius: 7px; padding: 5px 9px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--t2); }
.days button.on { background: var(--t1); color: var(--bg); border-color: var(--t1); }
.pri { font-size: 12px; color: var(--t3); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; animation: fade .15s; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 20px; box-shadow: 0 30px 80px -30px rgba(0,0,0,.5); }
.modal.wide { max-width: 860px; }
.modal h2 { margin-bottom: 4px; }
.modal .form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.pick { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--bg); }
.pick.sel { outline: 2px solid var(--acc); }
.pick .thumb { aspect-ratio: 16/9; }
.pick .t { font-size: 12.5px; padding: 6px 8px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* busca e filtros */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { max-width: 260px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn { border: 1px solid var(--line-2); background: var(--panel); border-radius: 20px; padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--t2); cursor: pointer; transition: background .12s, color .12s; }
.chip-btn:hover { color: var(--t1); }
.chip-btn.on { background: var(--t1); color: var(--bg); border-color: var(--t1); }
.chip.warn { border-color: transparent; background: var(--warn-soft); color: var(--warn); }
.chip.proc { border-color: transparent; background: var(--acc-soft); color: var(--acc); align-self: flex-start; }
.chip.proc::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.2s infinite; }
@media (prefers-reduced-motion: reduce) { .chip.proc::before, .status.on::before { animation: none; } }
.warnText { color: var(--warn); }
.thumb video.hover { position: absolute; inset: 0; }

/* validade do item */
.item .val { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--t2); padding-top: 6px; border-top: 1px dashed var(--line); }
.item .val input { width: 150px; padding: 4px 6px; font-size: 13px; }
.chip.ok { border-color: transparent; background: var(--ok-soft); color: var(--ok); }
.btn.acc { color: var(--acc); }

/* arrastar na playlist */
.item[draggable="true"] { cursor: grab; }
.item.dragging { opacity: .4; }
.item.over { outline: 2px solid var(--acc); outline-offset: -2px; }

/* teclado */
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 6px; }
.nav button:focus-visible { outline-offset: -2px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--t1); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; opacity: 0; transition: all .25s; z-index: 60; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--acc); color: #fff; }

/* login */
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login .form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.login .err { color: var(--acc); font-size: 13px; min-height: 18px; }
.login a { color: var(--t2); text-decoration: none; border-bottom: 1px solid var(--line-2); }
.login a:hover { color: var(--t1); border-bottom-color: var(--t1); }

/* instalação */
.steps { counter-reset: s; display: flex; flex-direction: column; gap: 12px; }
.step { display: grid; grid-template-columns: 32px 1fr; gap: 12px; align-items: start; }
.step::before { counter-increment: s; content: counter(s); width: 28px; height: 28px; border-radius: 50%; background: var(--acc-soft); color: var(--acc); font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.step b { display: block; }
.step span { color: var(--t2); font-size: 14px; }
.codebox { font-family: ui-monospace, Menlo, monospace; font-size: 18px; font-weight: 700; letter-spacing: .02em; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 12px 14px; display: inline-flex; align-items: center; gap: 12px; user-select: all; }
.install-grid { display: grid; grid-template-columns: 1fr 240px; gap: 24px; align-items: start; }
@media (max-width: 760px) { .install-grid { grid-template-columns: 1fr; } }
#qr { background: #fff; padding: 12px; border-radius: 12px; border: 1px solid var(--line); display: inline-block; }
#qr canvas, #qr img { display: block; }
