:root {
  --bg: #111214;
  --surface: #18191c;
  --surface-2: #212226;
  --border: #2c2d32;
  --text: #f1f4f2;
  --muted: #9ca6a1;
  --accent: #e5252a;
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --danger: #ff8a3d;
  --danger-soft: rgba(255, 138, 61, 0.14);
  --ok: #3dd68c;
  --ok-soft: rgba(61, 214, 140, 0.14);
  --warn: #ffb224;
  --warn-soft: rgba(255, 178, 36, 0.14);
  --gray-soft: rgba(160, 160, 171, 0.14);
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 22px; font-weight: 600; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #5a5a66; }
textarea { min-height: 72px; resize: vertical; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
label > input, label > select, label > textarea { color: var(--text); font-size: 15px; }
.help { font-size: 12px; color: var(--muted); }

.btn {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: 9px 16px;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #4a4a55; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: default; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; }
.error { color: var(--danger); margin: 0; font-size: 14px; white-space: pre-line; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand-dot { width: 14px; height: 14px; border-radius: 4px; background: var(--accent); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 16px; }

/* Estrutura */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 24px;
  position: sticky; top: 0; height: 100vh;
}
.side-logo { display: grid; justify-items: start; gap: 6px; padding: 4px 10px; font-weight: 700; }
.side-logo img { width: 52px; height: 52px; object-fit: contain; }
.sidebar nav { display: grid; gap: 4px; }
.nav-group { margin: 0 0 6px; padding: 0 10px; color: var(--muted); font-size: 13px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px; text-decoration: none; padding: 10px 12px;
  border-radius: 8px; color: var(--text); font-size: 15px;
}
.sidebar nav a svg {
  width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.sidebar nav a:hover { background: var(--surface); }
.sidebar nav a.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.sidebar nav a.active svg { color: var(--accent); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.dash-grid .list-item { cursor: pointer; }
.dash-grid .list-item:hover { outline: 1px solid var(--border); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 14px; }
.content { padding: 28px; min-width: 0; }
.page { display: grid; gap: 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.code-form { display: flex; gap: 8px; width: min(420px, 100%); }
.code-form input { text-transform: uppercase; letter-spacing: 1px; }
.code-form input::placeholder { text-transform: none; letter-spacing: 0; }

/* Números */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  cursor: pointer; text-align: left;
}
.stat:hover { border-color: #4a4a55; }
.stat.selected { border-color: var(--accent); }
.stat b { display: block; font-size: 24px; font-weight: 600; }
.stat span { color: var(--muted); font-size: 13px; }

.toolbar input { max-width: 460px; }

/* Tabela */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 720px; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.code { font-family: ui-monospace, Consolas, monospace; letter-spacing: 1px; font-weight: 600; }
.empty { padding: 32px; text-align: center; color: var(--muted); margin: 0; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.active { background: var(--ok-soft); color: var(--ok); }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.expired, .badge.blocked { background: var(--danger-soft); color: var(--danger); }

/* Gaveta de detalhes */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 10; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--bg);
  border-left: 1px solid var(--border); z-index: 11; overflow-y: auto; padding: 24px; display: grid; gap: 18px; align-content: start;
}
.drawer-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.drawer-head .code { font-size: 24px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.row > label { flex: 1; min-width: 140px; }
.list { display: grid; gap: 8px; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.list-item small { color: var(--muted); display: block; overflow-wrap: anywhere; }
.log { font-size: 13px; color: var(--muted); display: grid; gap: 4px; }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; }

/* Aparência */
.appearance { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 24px; align-items: start; }
.form-grid { display: grid; gap: 16px; }
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field input[type="color"] { width: 48px; height: 40px; padding: 2px; flex: none; }
.logo-field { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.logo-field img { max-height: 56px; max-width: 180px; background: #fff1; border-radius: 6px; padding: 4px; }
.preview-wrap { position: sticky; top: 24px; display: grid; gap: 8px; }
.phone { border-radius: 22px; border: 6px solid #2a2a33; overflow: hidden; height: 520px; display: grid; align-content: start; gap: 10px; padding-bottom: 12px; }
.phone-top { display: flex; align-items: center; gap: 8px; padding: 12px 12px 0; font-weight: 700; }
.phone-top img { height: 24px; max-width: 110px; object-fit: contain; }
.phone-notice { margin: 0 12px; padding: 8px 10px; border-radius: 8px; font-size: 12px; }
.phone-hero { margin: 0 12px; height: 170px; border-radius: 10px; background: linear-gradient(#ffffff10, #00000060); display: flex; align-items: end; justify-content: center; padding: 12px; }
.phone-btn { background: #fff; color: #111; font-size: 12px; font-weight: 700; padding: 6px 14px; border-radius: 6px; }
.phone-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0 12px; }
.phone-row i { height: 84px; border-radius: 6px; }

.narrow { max-width: 420px; display: grid; gap: 14px; }
.dns-form { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; align-items: end; }
.dns-form .row, .dns-form .error { grid-column: 1 / -1; }
.table td.actions { text-align: right; white-space: nowrap; }
@media (max-width: 800px) { .dns-form { grid-template-columns: 1fr; } }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface-2);
  border: 1px solid var(--border); padding: 10px 18px; border-radius: 10px; z-index: 20;
}

/* Celular */
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; gap: 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar nav { display: flex; overflow-x: auto; order: 3; width: 100%; }
  .nav-group { display: none; }
  .side-logo { grid-auto-flow: column; align-items: center; }
  .side-logo img { width: 32px; height: 32px; }
  .sidebar-foot { margin: 0 0 0 auto; }
  .content { padding: 16px; }
  .appearance { grid-template-columns: 1fr; }
  .preview-wrap { position: static; }
  .kv { grid-template-columns: 110px 1fr; }
}

/* Pedido de vínculo aguardando aprovação */
.card.highlight { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
#dash-pending .list-item { cursor: pointer; }
#dash-pending .list-item:hover { outline: 1px solid var(--border); }

/* Prévia da aparência (TV 16:9) */
.pv-tabs { display: flex; gap: 8px; }
.tv { --p-accent: #e5252a; --p-bg: #111214; --p-surface: #1c1d21; aspect-ratio: 16 / 9; border-radius: 14px; border: 8px solid #26262d; overflow: hidden;
  background: var(--p-bg); color: #f2f2f4; position: relative; width: 100%; container-type: inline-size; }
.tv > div { font-size: 1.75cqw; }
.tv [hidden] { display: none !important; }
.tv-home { display: flex; height: 100%; }
.tv-rail { width: 11%; display: flex; flex-direction: column; align-items: center; gap: 9%; padding: 4% 0; background: linear-gradient(90deg, #000a, #0000); }
.tv-rail img { width: 58%; }
.tv-rail i { width: 34%; aspect-ratio: 1; border-radius: 6px; background: #ffffff30; }
.tv-rail i.on { background: var(--p-accent); }
.tv-rail span { flex: 1; }
.tv-main { flex: 1; position: relative; overflow: hidden; }
.tv-notice { position: absolute; top: 5%; right: 3%; max-width: 55%; z-index: 2; padding: .6em .9em; border-radius: .5em; background: #111214e0; border-left: 3px solid var(--p-accent); font-size: .9em; }
.tv-hero { height: 52%; background: linear-gradient(90deg, var(--p-bg) 30%, transparent), linear-gradient(135deg, #3a3f55, #6b4a3a); display: flex; align-items: flex-end; padding: 0 0 5% 4%; }
.tv-hero-info { display: grid; gap: .4em; justify-items: start; }
.tv-hero-info b { font-size: 1.6em; }
.tv-hero-info small { color: #c9cad0; }
.tv-btn { background: #fff; color: #111; font-weight: 700; padding: .4em 1em; border-radius: 5px; }
.tv-row-title { margin: 3% 0 1.5% 4%; font-weight: 700; }
.tv-row { display: flex; gap: 2%; padding-left: 4%; }
.tv-row i { width: 17%; aspect-ratio: 16 / 10; border-radius: 5px; background: var(--p-surface); position: relative; overflow: hidden; }
.tv-row i.on { outline: 2px solid #fff; }
.tv-row i em { position: absolute; left: 0; bottom: 0; height: 3px; width: 55%; background: var(--p-accent); }
@font-face { font-family: 'ArchivoBlack'; src: url('/ArchivoBlack-Regular.ttf') format('truetype'); font-display: swap; }
.tv-login { height: 100%; position: relative; overflow: hidden; background: var(--p-bg); }
.tvl-posters { position: absolute; left: -6%; top: -12%; width: 70%; display: flex; flex-wrap: wrap; gap: 1.4%; transform: rotate(-9deg); opacity: .45; }
.tvl-posters i { width: 18%; aspect-ratio: 2 / 3; border-radius: .5em; background: #2a2b31; }
.tvl-shade { position: absolute; inset: 0; background: linear-gradient(90deg, #0008 0%, #0005 35%, var(--p-bg) 62%), linear-gradient(0deg, var(--p-bg) 6%, transparent 45%); }
.tvl-arc { position: absolute; left: -32%; top: 70%; width: 92%; height: 90%; border-radius: 50%; border-top: 2px solid var(--p-accent); box-shadow: 0 -4px 14px color-mix(in srgb, var(--p-accent) 40%, transparent); }
.tvl-left { position: absolute; left: 7%; top: 24%; width: 42%; display: flex; flex-direction: column; gap: .2em; }
.tvl-biglogo { width: 34%; margin-left: 22%; }
.tvl-left small { color: #e8e8ea; font-size: 1.15em; font-weight: 500; }
.tvl-left h3 { margin: 0; font-family: 'ArchivoBlack', Arial, sans-serif; font-weight: 400; font-size: 4.2em; line-height: 1.05; color: #f4f4f6; }
.tvl-left h3 span { color: var(--p-accent); }
.tvl-left p { margin: .45em 0 0; color: #ffffffd9; line-height: 1.5; white-space: pre-line; font-size: .88em; font-weight: 400; overflow: hidden; }
.tvl-support { font-size: .8em !important; }
.tvl-support b { color: var(--p-accent); }
.tv-login { font-family: 'Inter', system-ui, sans-serif; }
.tvl-panel { position: absolute; right: 6%; top: 14%; width: 40%; padding: 3.4% 3.4% 3%; display: flex; flex-direction: column; gap: .62em; border-radius: 1.1em;
  background: linear-gradient(180deg, color-mix(in srgb, var(--p-card, #1d1e23) 95%, transparent) 0%, color-mix(in srgb, color-mix(in srgb, var(--p-card, #1d1e23) 62%, #000) 95%, transparent) 100%);
  border: 1px solid color-mix(in srgb, var(--p-accent) 70%, transparent);
  box-shadow: 0 0 0 1px #ffffff08 inset, 0 0 1.6em color-mix(in srgb, var(--p-accent) 32%, transparent), 0 1.2em 2.4em #0009; }
.tvl-panel img { width: 24%; align-self: center; margin: 0 0 .45em; filter: drop-shadow(0 .3em .6em #0008); }
.tvl-field { display: flex; align-items: center; gap: .75em; padding: 0 1em; height: 2.75em; border-radius: .55em;
  background: #0b0c0fcc; border: 1px solid #ffffff4d; color: #b9bac0; font-weight: 500; }
.tvl-field:first-of-type { border-color: color-mix(in srgb, var(--p-accent) 85%, #fff 0%); box-shadow: 0 0 0 1px color-mix(in srgb, var(--p-accent) 35%, transparent); }
.tvl-field svg, .tvl-ghost svg { width: 1.25em; height: 1.25em; fill: none; stroke: #d9dade; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.tvl-btn { margin-top: .25em; height: 2.8em; display: flex; align-items: center; justify-content: center; border-radius: .55em; font-weight: 700; font-size: 1.08em; letter-spacing: .02em;
  background: linear-gradient(180deg, color-mix(in srgb, var(--p-accent) 88%, #fff 12%) 0%, var(--p-accent) 55%, color-mix(in srgb, var(--p-accent) 82%, #000 18%) 100%);
  box-shadow: 0 .35em .9em color-mix(in srgb, var(--p-accent) 40%, transparent), 0 1px 0 #ffffff40 inset; }
.tvl-ghost { height: 2.6em; display: flex; align-items: center; justify-content: center; gap: .55em; border-radius: .55em; border: 1px solid #ffffff4d; color: #fff; font-weight: 500; background: #ffffff08; }
.tvl-foot { position: absolute; left: 5%; right: 5%; bottom: 4%; display: flex; gap: .6em; color: #a7a9b0; font-size: .85em; }
.tvl-foot b { color: #fff; letter-spacing: 1px; }
.tvl-foot span { margin-left: auto; }

.preview-wrap { width: 100%; }

/* Capas abstratas do fundo (originais, sem imagem de filme): parecem pôsteres desfocados. */
.tvl-posters i:nth-child(1) { background: radial-gradient(60% 45% at 50% 30%, #e8a86a 0%, #8a3b1d 35%, transparent 70%), radial-gradient(80% 60% at 40% 90%, #3a1208, transparent 70%), linear-gradient(180deg, #2b1a14, #0e0a09); }
.tvl-posters i:nth-child(2) { background: radial-gradient(50% 40% at 55% 35%, #9fd3ff 0%, #2b5d8f 40%, transparent 72%), radial-gradient(70% 50% at 30% 85%, #0d2238, transparent 70%), linear-gradient(180deg, #13263a, #070b12); }
.tvl-posters i:nth-child(3) { background: radial-gradient(45% 35% at 50% 38%, #ffd9b0 0%, #b5542e 38%, transparent 70%), radial-gradient(90% 60% at 60% 100%, #5a0f14, transparent 70%), linear-gradient(180deg, #3a1016, #0d0507); }
.tvl-posters i:nth-child(4) { background: radial-gradient(55% 45% at 45% 40%, #b7f0c7 0%, #2f7a4b 40%, transparent 72%), linear-gradient(180deg, #11261a, #050b07); }
.tvl-posters i:nth-child(5) { background: radial-gradient(40% 30% at 60% 25%, #fff2c4 0%, #c78a2c 40%, transparent 70%), radial-gradient(80% 55% at 40% 80%, #3b2408, transparent 70%), linear-gradient(180deg, #2a1d0c, #0b0703); }
.tvl-posters i:nth-child(6) { background: radial-gradient(60% 50% at 50% 45%, #d4b3ff 0%, #5a2d8f 42%, transparent 72%), linear-gradient(180deg, #1e1030, #08050e); }
.tvl-posters i:nth-child(7) { background: radial-gradient(50% 35% at 40% 30%, #ff9a8a 0%, #a3262b 40%, transparent 70%), radial-gradient(70% 50% at 70% 90%, #1a1a2e, transparent 70%), linear-gradient(180deg, #2a0f14, #07060a); }
.tvl-posters i:nth-child(8) { background: radial-gradient(55% 40% at 55% 55%, #a9f1ff 0%, #1f6f80 42%, transparent 72%), linear-gradient(180deg, #0b2228, #04090b); }
.tvl-posters i:nth-child(9) { background: radial-gradient(45% 40% at 50% 35%, #ffe0a3 0%, #8f5a1c 45%, transparent 72%), radial-gradient(60% 40% at 50% 95%, #551a0c, transparent 70%), linear-gradient(180deg, #24160b, #090604); }
.tvl-posters i:nth-child(10) { background: radial-gradient(60% 45% at 40% 40%, #c6c9d6 0%, #4b4f63 40%, transparent 72%), linear-gradient(180deg, #1b1d26, #07080b); }
.tvl-posters i:nth-child(11) { background: radial-gradient(50% 40% at 60% 35%, #ffb3d1 0%, #8f2d5a 40%, transparent 72%), linear-gradient(180deg, #2a0f1f, #0a0409); }
.tvl-posters i:nth-child(12) { background: radial-gradient(55% 45% at 50% 40%, #f0e68c 0%, #6b6a1f 42%, transparent 72%), radial-gradient(80% 50% at 50% 100%, #1e2a0c, transparent 70%), linear-gradient(180deg, #1d200c, #070803); }

.check { display: flex; align-items: center; gap: 10px; flex-direction: row; }
.check input { width: auto; }
