/* HotelTV backoffice — sem dependências externas (funciona numa rede sem Internet). */
:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --ink: #1b2333;
  --ink-2: #5b6474;
  --ink-3: #8a92a0;
  --line: #e4e0d8;
  --nav: #0e1b30;
  --nav-ink: #c9d2e3;
  --nav-active: #1b2c4a;
  --accent: #b88a3e;
  --accent-ink: #ffffff;
  --accent-soft: #f5ecdc;
  --ok: #2f8a4c;
  --ok-soft: #e3f3e8;
  --warn: #b36b00;
  --warn-soft: #fbf0dc;
  --err: #c0392b;
  --err-soft: #fbe5e2;
  --info: #2c6cb0;
  --info-soft: #e3eefa;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Estrutura ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--nav); color: var(--nav-ink); display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; color: #fff; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; font-weight: 700; color: #fff; }
.brand-name { font-weight: 700; line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--nav-ink); opacity: .75; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: var(--nav-ink); padding: 9px 12px; border-radius: 8px; display: flex; align-items: center; gap: 10px; }
.nav a:hover { background: var(--nav-active); text-decoration: none; color: #fff; }
.nav a.active { background: var(--nav-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav .sep { height: 1px; background: rgba(255, 255, 255, .08); margin: 10px 6px; }
.nav .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 13px; }
.sidebar-foot a, .sidebar-foot button { color: var(--nav-ink); }
.linklike { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.linklike:hover { text-decoration: underline; }

.main { padding: 28px 32px 48px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cartões e grelhas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.grid > div > .card + .card { margin-top: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.kpi-value { font-size: 30px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-note { font-size: 12px; color: var(--ink-2); }
.kpi.is-alert .kpi-value { color: var(--err); }
.kpi.is-warn .kpi-value { color: var(--warn); }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-muted td { color: var(--ink-3); }
.logo-thumb { width: 64px; height: 36px; object-fit: contain; background: #17223a; border-radius: 4px; display: block; }
.logo-thumb.empty { display: grid; place-items: center; color: #8a96ad; font-size: 11px; font-weight: 700; }

/* ---------- Etiquetas de estado ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.err { background: var(--err-soft); color: var(--err); border-color: transparent; }
.pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill.gold { background: var(--accent-soft); color: #8a6420; border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--ink-3); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.off { background: #c8ccd3; }
.badge { background: var(--err); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 700; }

/* ---------- Botões ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(184, 138, 62, .35); outline-offset: 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #a57a33; }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: var(--err-soft); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
form.inline { display: inline; }

/* ---------- Formulários ---------- */
.form { display: grid; gap: 16px; max-width: 760px; }
.field { display: grid; gap: 6px; }
.field label, .label { font-weight: 600; font-size: 14px; }
.hint { font-size: 13px; color: var(--ink-2); }
.form .card { display: grid; gap: 16px; }
.form .card + .card { margin-top: 0; }
.form .card > h2 { margin: 0; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input[type=text] { width: 260px; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #d5d0c6; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
select { height: 42px; padding-top: 0; padding-bottom: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0; }
legend { font-weight: 700; padding: 0 6px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { width: 240px; }
.filters select { width: auto; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.segmented a { padding: 6px 12px; color: var(--ink-2); font-size: 13px; font-weight: 600; border-right: 1px solid var(--line); }
.segmented a:last-child { border-right: 0; }
.segmented a.active { background: var(--nav); color: #fff; }
.segmented a:hover { text-decoration: none; }

.logo-editor { display: grid; grid-template-columns: 200px 1fr; gap: 16px; align-items: start; }
.logo-preview { width: 200px; height: 113px; border-radius: 8px; background: repeating-conic-gradient(#1f2b45 0% 25%, #17223a 0% 50%) 50% / 16px 16px; display: grid; place-items: center; overflow: hidden; }
.logo-preview img { max-width: 100%; max-height: 100%; }

/* ---------- Alertas ---------- */
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid transparent; }
.flash.ok { background: var(--ok-soft); color: #1f5e33; }
.flash.error { background: var(--err-soft); color: #8d2a1f; }
.flash.warn { background: var(--warn-soft); color: #7a4a00; }
.flash.info { background: var(--info-soft); color: #1e4c7d; }
.errors { background: var(--err-soft); color: #8d2a1f; border-radius: 8px; padding: 10px 14px 10px 30px; margin: 0 0 14px; }

/* ---------- Painel ---------- */
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.live .dot { animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.chart { width: 100%; height: 140px; display: block; }
.chart .bar { fill: var(--accent); }
.chart .bar:hover { fill: #8a6420; }
.chart .axis { fill: var(--ink-3); font-size: 10px; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: 0; }
.empty-state { color: var(--ink-3); padding: 16px 0; text-align: center; }
pre.json { background: #0e1b30; color: #dfe6f3; padding: 14px; border-radius: 8px; overflow: auto; font-size: 12px; max-height: 420px; }

/* ---------- Ecrãs de login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, #1b2c4a, var(--nav)); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 14px; padding: 30px 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.auth-card .brand { color: var(--ink); padding: 0 0 18px; }
.auth-card .brand-sub { color: var(--ink-2); }
.auth-card .btn.primary { width: 100%; justify-content: center; padding: 11px; }

/* ---------- Responsivo ---------- */
@media (max-width: 980px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 12px 16px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav .sep { display: none; }
  .sidebar-foot { display: flex; gap: 14px; flex-wrap: wrap; }
  .main { padding: 20px 16px 40px; }
  .logo-editor { grid-template-columns: 1fr; }
  .filters input[type=search], .inline-form input[type=text] { width: 100%; }
}
th.col-guest { min-width: 170px; }

/* ---------- Painel Astra ---------- */
.page-head.compact { margin-bottom: 12px; align-items: center; }
.page-head.compact h2 { margin: 0; }
.page-head.compact p { margin: 2px 0 0; }
.filters.tight { margin: 0; }
table.compact th, table.compact td { padding: 7px 10px; }
td.right, th.right { text-align: right; }
td.center { text-align: center; }
td .btn + .btn, td .btn + a.btn { margin-left: 4px; }
td .pill + .pill { margin-left: 4px; }
.t-err { color: var(--err); font-weight: 600; }
.t-warn { color: var(--warn); font-weight: 600; }
.spark { width: 120px; height: 26px; display: block; }
.spark-line { fill: none; stroke: var(--info); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark-low { fill: var(--err-soft); }
.verdict { min-width: 220px; max-width: 380px; line-height: 1.35; }
.verdict.v-source { color: #8d2a1f; }
.verdict.v-astra { color: #8a6420; font-weight: 600; }
.verdict.v-ok, .verdict.v-config { color: var(--ink-3); }
.legend { margin: 12px 0 0; line-height: 2; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 14px; }
dl.kv dt { color: var(--ink-3); font-size: 13px; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
dl.kv dd .pill { margin-left: 6px; }
pre.log { background: #0e1b30; color: #c9d2e3; padding: 14px; border-radius: 8px; overflow: auto; font-size: 12px; max-height: 70vh; margin: 0; white-space: pre-wrap; }
pre.log .l-err { color: #ff9b8f; }
pre.log .l-ok { color: #8fd8a6; }
.edit-table input[type=text], .edit-table input[type=number], .edit-table select { padding: 6px 8px; height: 36px; }
.edit-table .w-num { width: 96px; }
details.adv summary { cursor: pointer; color: var(--info); font-size: 13px; white-space: nowrap; }
details.adv[open] { display: grid; gap: 6px; min-width: 240px; }
details.adv label { display: grid; gap: 2px; }
.task-load { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 14px 0; margin-top: 16px; border-top: 1px solid var(--line); }

/* ---------- Línguas ---------- */
.form.wide { max-width: 1100px; }
.tr-list { display: grid; gap: 14px; }
.tr-item { display: grid; gap: 4px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.tr-item:last-child { border-bottom: 0; padding-bottom: 0; }
.tr-item label { font-weight: 600; font-size: 14px; }
.tr-ref { background: var(--surface-2); border-radius: 6px; padding: 4px 8px; }

/* ---------- Rede ---------- */
.net-card h2 .pill { margin-left: 6px; vertical-align: middle; }
.net-card details > summary { list-style: none; display: inline-flex; margin-bottom: 4px; }
.net-card details > summary::-webkit-details-marker { display: none; }
.net-card details[open] > summary { margin-bottom: 14px; }
.net-live { text-align: right; max-width: 60%; }
.net-form { max-width: 900px; }
.net-pending .actions { margin-top: 10px; }
.net-extra { margin-top: 16px; }
.net-inactive { margin-top: 16px; }
.net-inactive > summary { cursor: pointer; }
.net-inactive[open] > summary { margin-bottom: 14px; }
.t-ok { color: var(--ok); font-weight: 600; }
select.w-auto { width: auto; }

/* ---------- Atualizações ---------- */
.release-actions { min-width: 150px; }
.release-actions form { display: inline-block; margin: 2px 0 2px 4px; }
