/* Vitorinos TV · Backoffice — alinhado com o portal.vitorinos */
:root {
  --brand: #2E1A4F;
  --teal: #0FA3AE;
  --teal-dark: #0B8A93;
  --bg: #EEF0F6;
  --panel: #FFFFFF;
  --text: #2B2B3A;
  --muted: #7A7C8C;
  --line: #E4E6EE;
  --ok: #1F9D55;
  --warn: #C27803;
  --err: #D23C3C;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 Poppins, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { margin: 0; font-weight: 500; }
a { color: var(--teal-dark); }
[hidden] { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.warn { color: var(--warn); }
.ok-text { color: var(--ok); }
.i { width: 16px; height: 16px; flex: none; }

/* Cabeçalho */
.bar { max-width: 1240px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; }
.topbar { background: var(--brand); color: #fff; }
.topbar .bar { height: 60px; gap: 16px; }
.brand img { height: 32px; display: block; }
.product { font-size: 14px; color: rgba(255,255,255,.75); padding-left: 16px; border-left: 1px solid rgba(255,255,255,.25); }
.logout { color: rgba(255,255,255,.85); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.logout:hover { color: #fff; }

.subnav { background: var(--panel); border-bottom: 1px solid var(--line); }
.subnav .bar { gap: 28px; }
.tab { color: var(--muted); text-decoration: none; padding: 14px 0 12px; border-bottom: 2px solid transparent; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--teal); }
.count { font-size: 12px; color: var(--muted); background: var(--bg); border-radius: 4px; padding: 0 6px; font-weight: 400; }
.count-warn { color: var(--warn); background: #FDF3E1; }

/* Layout */
.wrap { max-width: 1240px; margin: 0 auto; padding: 24px; }
.panel { background: var(--panel); border-radius: 4px; box-shadow: 0 1px 2px rgba(20, 20, 40, .06); margin-bottom: 20px; }
.pad { padding: 20px 22px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h1 { font-size: 20px; }
.summary { margin: 4px 0 0; color: var(--muted); display: flex; flex-wrap: wrap; gap: 18px; font-size: 13px; }
.summary span { display: inline-flex; align-items: center; gap: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Estado */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #B5B7C3; flex: none; }
.dot-ok { background: var(--ok); } .dot-bg { background: #E5A00D; } .dot-off { background: var(--err); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* Cartão de TV */
.tv { display: flex; flex-direction: column; margin: 0; }
.tv.highlight { outline: 2px solid var(--teal); outline-offset: 2px; }
.shot { margin: 0; position: relative; aspect-ratio: 16/9; background: #1B1726; border-radius: 4px 4px 0 0; overflow: hidden; }
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.noshot { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: rgba(255,255,255,.45); font-size: 12.5px; }
.noshot .i { width: 28px; height: 28px; }
.shot figcaption { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 11.5px; padding: 1px 7px; border-radius: 3px; }
.shot figcaption:empty { display: none; }
.shot-alert { display: none; position: absolute; inset: 0; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 2px; color: #fff; font-weight: 500; background: rgba(27, 23, 38, .6); }
.shot-alert small { font-weight: 400; font-size: 12px; opacity: .8; }
.state-bg .alert-bg, .state-off .alert-off { display: flex; }
.state-bg img, .state-off img { filter: grayscale(1) brightness(.75); }

.tv-body { padding: 16px 18px 4px; flex: 1; }
.tv-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.tv-title h3 { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.props { display: grid; grid-template-columns: 74px 1fr; gap: 6px 10px; margin: 0; font-size: 13px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-actions { display: flex; gap: 8px; padding: 14px 18px 16px; border-top: 1px solid var(--line); margin-top: 14px; }

/* Botões */
.btn { font: 500 13.5px Poppins, "Segoe UI", sans-serif; border-radius: 4px; padding: 8px 14px; cursor: pointer; border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: none; color: var(--text); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.btn-outline { border-color: #D3D6E0; background: #fff; }
.btn-outline:hover { border-color: var(--teal); color: var(--teal-dark); }
.btn-link-danger { color: var(--err); padding-left: 0; padding-right: 0; }
.btn-link-danger:hover { text-decoration: underline; }
.btn-link-danger:disabled { color: #B5B7C3; cursor: not-allowed; text-decoration: none; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 4px; display: inline-flex; }
.icon-btn:hover { color: var(--text); background: var(--bg); }
.icon-btn .i { width: 20px; height: 20px; }

/* Formulários */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.field input:not([type=radio]):not([type=file]), .field select {
  width: 100%; padding: 9px 11px; font: 14px Poppins, "Segoe UI", sans-serif; color: var(--text);
  border: 1px solid #D3D6E0; border-radius: 4px; background: #fff;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15, 163, 174, .15); }
input[type=file] { font: 13px Poppins, "Segoe UI", sans-serif; max-width: 100%; }
input[type=file]::file-selector-button { font: 500 13px Poppins, sans-serif; border: 1px solid #D3D6E0; background: #fff; border-radius: 4px; padding: 6px 12px; margin-right: 10px; cursor: pointer; }
.radios { display: flex; gap: 22px; padding: 4px 0; }
.radios label { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.radios input { accent-color: var(--teal); width: 16px; height: 16px; margin: 0; }
.help { display: block; color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.form-row { display: flex; gap: 14px; }
.grow { flex: 1; } .narrow { width: 110px; }

/* Janela */
.dlg { border: 0; border-radius: 6px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(20, 20, 40, .25); color: var(--text); }
.dlg::backdrop { background: rgba(20, 18, 32, .45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { font-size: 16px; }
.dlg-body { padding: 18px 20px 6px; }
.dlg-foot { display: flex; align-items: center; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: #FAFBFD; border-radius: 0 0 6px 6px; }

/* Tabelas (como no portal) */
.table { width: 100%; border-collapse: collapse; }
.table th { background: var(--teal); color: #fff; font-weight: 500; text-align: left; padding: 11px 14px; font-size: 13px; white-space: nowrap; }
.table th:first-child { border-top-left-radius: 4px; } .table th:last-child { border-top-right-radius: 4px; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.th-thumb { width: 104px; }
.thumb { width: 88px; aspect-ratio: 16/9; object-fit: cover; background: #1B1726; border-radius: 3px; display: block; }

/* Vídeos / App */
.upload-row { display: flex; align-items: center; gap: 18px; padding: 16px 20px; }
.upload-info { display: flex; flex-direction: column; flex: 1; }
.upload-info .help { margin: 0; }
.app-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 20px; }
.app-grid .panel { margin-bottom: 0; }
.app-grid + .panel { margin-top: 20px; }
.app-grid h2 { font-size: 15px; margin-bottom: 12px; }
.version { font-size: 34px; font-weight: 600; color: var(--brand); margin: 0; line-height: 1.2; }
code { font: 12.5px ui-monospace, Consolas, monospace; background: #fff; padding: 2px 6px; border-radius: 3px; }

/* Mensagens */
.notice { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 4px; margin: 0 0 18px; border: 1px solid; font-size: 13.5px; }
.notice span { flex: 1; }
.notice-ok { background: #EAF6EF; border-color: #BFE3CD; color: #17663A; }
.notice-err { background: #FBECEC; border-color: #F1C4C4; color: #9B2C2C; }
.notice-x { background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; display: inline-flex; }
.notice-x:hover { opacity: 1; }

/* Login */
.login { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
.login h1 { font-size: 18px; margin-bottom: 18px; }

/* Ecrãs pequenos */
@media (max-width: 760px) {
  .bar, .wrap { padding-left: 16px; padding-right: 16px; }
  .product { display: none; }
  .subnav .bar { gap: 18px; overflow-x: auto; }
  .grid, .app-grid { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .upload-row, .form-row { flex-direction: column; align-items: stretch; }
  .narrow { width: auto; }
  .th-thumb, .table td:first-child:has(video) { display: none; }
}

/* Ações remotas */
.cmd-status { font-size: 12.5px; margin: 10px 18px 0; }
.more { position: relative; margin-left: auto; }
.btn-icon { padding: 8px 12px; font-size: 16px; line-height: 1; }
.menu { position: absolute; right: 0; bottom: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 6px 24px rgba(20,20,40,.15); min-width: 210px; z-index: 5; padding: 4px 0; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 14px; font: 13.5px Poppins, "Segoe UI", sans-serif; color: var(--text); cursor: pointer; }
.menu button:hover { background: var(--bg); }

/* Utilizadores */
.me { font-size: 13px; color: rgba(255,255,255,.85); }
.tab-right { order: 9; margin-left: auto; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
form.inline { display: inline; }

/* Imagem */
.img-preview { display: block; width: 100%; aspect-ratio: 16/9; object-fit: contain; background: #1B1726; border-radius: 4px; margin: -6px 0 14px; }
.radios { flex-wrap: wrap; }
.fallback-pane { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }

/* Grupos */
.groupbar { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.group-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { font: 500 13px Poppins, "Segoe UI", sans-serif; border: 1px solid #D3D6E0; background: #fff; color: var(--text); border-radius: 999px; padding: 5px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip-btn:hover { border-color: var(--teal); }
.chip-btn.active { background: var(--teal); border-color: var(--teal); color: #fff; }
.chip-btn.active .count { background: rgba(255,255,255,.25); color: #fff; }
.chip-new { border-style: dashed; color: var(--muted); }
.chip-new .i { width: 14px; height: 14px; }
.group-actions { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.group-actions .btn .i { width: 14px; height: 14px; }
.tv-groups { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 10px; }
.tv-groups .chip { background: #E3F6F7; color: #0B8A93; font-size: 11.5px; border-radius: 4px; padding: 1px 8px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; padding-top: 2px; color: var(--text); font-size: 14px; }
.checks label { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.checks input { accent-color: var(--teal); width: 16px; height: 16px; margin: 0; }
.checks-col { flex-direction: column; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; }
article.tv[hidden] { display: none !important; }
.menu .danger-item { color: var(--err); }
