:root {
  --bg: #07080d;
  --bg-2: #0c0e16;
  --panel: #11131d;
  --panel-2: #161927;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f5fa;
  --text-dim: #b8bccb;
  --muted: #7d8296;
  --teal: #2ee6c5;
  --violet: #7b5cff;
  --pink: #ff4d8d;
  --amber: #ffc94d;
  --red: #ff4d6a;
  --red-1: #FF6A4D;
  --red-2: #E50914;
  --red-3: #9E0B1F;
  /* Degradê da marca Powerflix (o mesmo do ícone) */
  --brand: linear-gradient(120deg, var(--red-1), var(--red-2) 55%, var(--red-3));
  --radius: 16px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
code { background: rgba(255,255,255,0.08); padding: 1px 6px; border-radius: 6px; font-size: 12px; }
a { color: var(--teal); }
.hidden { display: none !important; }
.muted { color: var(--muted); margin: 0; }
.mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; letter-spacing: 0.3px; }

/* ---------- Botões e campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  transition: transform .12s, background .15s, border-color .15s, box-shadow .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); background: #1c2031; }
.btn:active { transform: scale(0.98); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--red-1); outline-offset: 2px; }
.btn-brand { background: var(--brand); border: 0; color: #fff; box-shadow: 0 8px 24px rgba(229, 9, 20, 0.35); }
.btn-brand:hover { background: var(--brand); filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-sm { height: 32px; padding: 0 12px; border-radius: 10px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn { width: 34px; height: 34px; padding: 0; border-radius: 10px; display: inline-grid; place-items: center; border: 1px solid var(--border); background: transparent; color: var(--text-dim); cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--panel-2); }
.icon-btn.danger:hover { color: var(--red); border-color: rgba(255,77,106,.4); }

label { display: grid; gap: 6px; color: var(--text-dim); font-weight: 600; font-size: 13px; }
input, select, textarea {
  width: 100%; height: 42px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text); font: inherit; font-weight: 500;
}
textarea { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; }
input[type="color"] { padding: 4px; height: 42px; cursor: pointer; }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
.req { color: var(--red, #ff4d6a); font-weight: 800; margin-left: 3px; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 46px; }
.pw-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 34px;
  display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer;
}
.pw-eye:hover { color: var(--text); background: var(--panel-2); }
.pw-eye svg { width: 18px; height: 18px; }
.hint { font-weight: 500; color: var(--muted); font-size: 12px; }
.form-error { background: rgba(255, 77, 106, 0.12); border: 1px solid rgba(255, 77, 106, 0.35); color: #ffb3c0; padding: 10px 12px; border-radius: 12px; font-weight: 600; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.switch:last-child { border-bottom: 0; }
.switch strong { display: block; color: var(--text); }
.switch input { appearance: none; width: 44px; height: 26px; border-radius: 13px; padding: 0; background: #2a2e40; position: relative; cursor: pointer; border: 0; flex-shrink: 0; transition: background .2s; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked { background: var(--teal); }
.switch input:checked::after { transform: translateX(18px); }

/* ---------- Entrada ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; overflow: hidden; background: #0b1020; }
.login-bg {
  position: absolute; inset: -20px;
  background:
    radial-gradient(1200px 700px at 20% 15%, rgba(229, 9, 20, 0.30), transparent 60%),
    radial-gradient(1000px 800px at 85% 90%, rgba(123, 20, 40, 0.35), transparent 55%),
    linear-gradient(160deg, #14060a, #1a0710 55%, #050507);
  animation: drift 40s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: scale(1.04) translate(0, 0); } to { transform: scale(1.1) translate(-1.5%, -1%); } }
.login-shade { position: absolute; inset: 0; background: radial-gradient(ellipse at 30% 40%, rgba(7,8,13,0.15), rgba(7,8,13,0.75) 70%), linear-gradient(90deg, rgba(7,8,13,0.55), rgba(7,8,13,0.1)); }
.login-wrap { position: relative; width: min(440px, calc(100% - 32px)); display: grid; gap: 22px; }
.login-brand { display: flex; align-items: center; gap: 12px; font-size: 26px; font-weight: 800; letter-spacing: -0.5px; text-shadow: 0 2px 20px rgba(0,0,0,.5); }
.login-brand em, .side-brand em { font-style: normal; font-weight: 500; color: var(--text-dim); }
.login-card {
  display: grid; gap: 16px; padding: 32px; border-radius: 24px;
  background: rgba(12, 14, 22, 0.62); border: 1px solid rgba(255,255,255,0.14);
  backdrop-filter: blur(22px) saturate(1.3); -webkit-backdrop-filter: blur(22px) saturate(1.3);
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0; font-size: 24px; letter-spacing: -0.4px; }
.login-card input { background: rgba(7, 8, 13, 0.55); }
.logo-mark { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; box-shadow: 0 8px 24px rgba(229,9,20,.4); }
.logo-mark svg { width: 22px; height: 22px; stroke: none; }
.logo-mark.sm { width: 36px; height: 36px; border-radius: 11px; }
.logo-mark.sm svg { width: 18px; height: 18px; }

/* ---------- Estrutura ---------- */
.app { display: flex; min-height: 100vh; background: radial-gradient(1200px 600px at 80% -10%, rgba(229,9,20,0.12), transparent), radial-gradient(900px 500px at 10% 0%, rgba(255,106,77,0.05), transparent), var(--bg); }
.sidebar { width: 268px; flex-shrink: 0; background: rgba(12, 14, 22, 0.85); border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 20px 14px; }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; }
.side-brand strong { display: block; font-size: 17px; letter-spacing: -0.3px; }
.side-version { display: inline-block; margin-top: 2px; font-size: 11px; font-weight: 700; letter-spacing: 0.4px; color: #FF8A73; background: rgba(229,9,20,0.12); border: 1px solid rgba(255,106,77,0.3); padding: 1px 8px; border-radius: 999px; }
.nav-section { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); padding: 16px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 12px; border: 0; background: none; color: var(--text-dim); font: inherit; font-weight: 600; cursor: pointer; text-align: left; position: relative; }
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-item.active { background: linear-gradient(90deg, rgba(229,9,20,0.24), rgba(229,9,20,0.04)); color: #fff; }
.nav-item.active::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--brand); }
.nav-item .chev { margin-left: auto; width: 14px; height: 14px; transition: transform .2s; }
.nav-item.open .chev { transform: rotate(180deg); }
.nav-sub { display: grid; gap: 2px; padding: 2px 0 6px 30px; }
.nav-sub .nav-item { padding: 8px 12px; font-size: 13px; }
.nav-sub .nav-item.active::before { display: none; }
.badge-count { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--text-dim); background: rgba(255,255,255,0.07); padding: 1px 8px; border-radius: 999px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 22px 32px 6px; }
.topbar h2 { margin: 0; font-size: 26px; letter-spacing: -0.6px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.greeting { color: var(--text-dim); font-weight: 600; font-size: 14px; margin-right: 6px; white-space: nowrap; }
.my-expiry { font-size: 12px; font-weight: 700; color: var(--text-dim); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; margin-right: 6px; white-space: nowrap; }
.my-expiry.soon { color: #FF8AB3; border-color: rgba(255,77,141,.45); background: rgba(255,77,141,.12); }
.greeting::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); margin-right: 8px; vertical-align: middle; }
.menu-btn { display: none; }
.view { padding: 18px 32px 40px; display: grid; gap: 20px; align-content: start; }

/* ---------- Cartões ---------- */
.view > *, .grid-2 > *, .grid-3 > * { min-width: 0; }
.card { background: linear-gradient(180deg, rgba(22,25,39,0.9), rgba(17,19,29,0.9)); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 16px; }
.card-head .muted { font-size: 13px; }
.card-head .spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 6px; }

/* 6 → 3 → 2 colunas, para nunca ficar um cartão sozinho numa linha */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1500px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { position: relative; overflow: hidden; padding: 18px 20px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--border); }
.stat::after { content: ''; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--glow, rgba(123,92,255,.18)); filter: blur(10px); }
.stat-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--chip, rgba(123,92,255,.16)); color: var(--ink, #b9a8ff); margin-bottom: 14px; }
.stat-value { font-size: 30px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; }
.stat-label { color: var(--muted); font-weight: 600; font-size: 13px; }
.stat-trend { position: absolute; right: 18px; top: 20px; font-size: 12px; font-weight: 700; color: var(--teal); }
.chart-box { position: relative; height: 290px; }
.chart-box.sm { height: 230px; }
.legend { display: grid; gap: 10px; margin-top: 14px; }
.legend-row { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text-dim); }
.legend-row b { margin-left: auto; color: var(--text); }
.dot { width: 10px; height: 10px; border-radius: 50%; }

/* ---------- Tabelas ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search { position: relative; flex: 1; min-width: 220px; }
.search svg { position: absolute; left: 12px; top: 12px; color: var(--muted); }
.search input { padding-left: 40px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: transparent; color: var(--text-dim); font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; }
.chip.active { background: #fff; color: #07080d; border-color: #fff; }
.table-wrap { overflow-x: auto; margin: 0 -22px -22px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 12px 22px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 13px 22px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,0.025); }
td .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.cell-main { font-weight: 700; }
.cell-sub { color: var(--muted); font-size: 12px; }
.acc-rows { display: flex; flex-direction: column; gap: 8px; }
.acc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-2); }
.acc-row .row-actions { display: flex; gap: 6px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty svg { width: 34px; height: 34px; margin-bottom: 8px; opacity: .6; }

.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 3px 10px; line-height: 1.3; border-radius: 12px; font-size: 12px; font-weight: 700; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill.active, .pill.ok { color: var(--teal); background: rgba(46,230,197,0.12); }
.pill.demo { color: var(--amber); background: rgba(255,201,77,0.12); }
.pill.expired { color: #ff8a9c; background: rgba(255,77,106,0.12); }
.pill.blocked { color: var(--muted); background: rgba(255,255,255,0.07); }
.pill.used { color: var(--muted); background: rgba(255,255,255,0.07); }
.pill.info { color: #9fb4ff; background: rgba(123,140,255,0.14); }
.pill.warning { color: var(--amber); background: rgba(255,201,77,0.12); }
.pill.success { color: var(--teal); background: rgba(46,230,197,0.12); }

/* ---------- Partes específicas ---------- */
.dns-card { display: flex; align-items: center; gap: 16px; padding: 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--bg-2); }
.dns-card.on { border-color: rgba(46,230,197,.45); background: linear-gradient(90deg, rgba(46,230,197,.08), transparent); }
.dns-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: rgba(123,92,255,.14); color: #b9a8ff; }
.dns-card.on .dns-icon { background: rgba(46,230,197,.14); color: var(--teal); }
.dns-list { display: grid; gap: 10px; }

.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.code-card { padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--bg-2); display: grid; gap: 8px; }
.code-card .mono { font-size: 19px; font-weight: 700; }
.code-card.used { opacity: .55; }

.period-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.period { padding: 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--bg-2); color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.period strong { display: block; font-size: 18px; }
.period span { color: var(--muted); font-size: 12px; font-weight: 600; }
.period.active { border-color: var(--violet); background: rgba(123,92,255,.14); box-shadow: inset 0 0 0 1px var(--violet); }

.device-pick { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--border); }
.device-pick .avatar, .avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(123,92,255,.16); color: #c8bbff; font-weight: 800; }

.notif { display: flex; gap: 14px; padding: 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--bg-2); }
.notif-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.notif-icon.info { background: rgba(123,140,255,0.14); color: #9fb4ff; }
.notif-icon.warning { background: rgba(255,201,77,0.12); color: var(--amber); }
.notif-icon.success { background: rgba(46,230,197,0.12); color: var(--teal); }
.notif-body { flex: 1; min-width: 0; }
.notif-body p { margin: 4px 0 0; color: var(--text-dim); }

.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.theme-card { border-radius: 14px; border: 2px solid var(--border); padding: 0; overflow: hidden; background: var(--bg-2); cursor: pointer; color: var(--text); font: inherit; text-align: left; }
.theme-card.active { border-color: #fff; }
.theme-swatch { height: 74px; display: flex; align-items: flex-end; gap: 6px; padding: 10px; }
.theme-swatch i { width: 18px; height: 18px; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.theme-card div:last-child { padding: 10px 12px; font-weight: 700; }

/* Pré-visualização da app (ecrã de TV) */
.tv-preview { aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; position: relative; border: 6px solid #1a1c25; box-shadow: var(--shadow); background-size: cover; background-position: center; }
.tv-preview .shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.82), rgba(0,0,0,.25)); }
.tv-preview .content { position: absolute; inset: 0; padding: 7% 8%; display: flex; flex-direction: column; justify-content: center; gap: 10px; max-width: 70%; }
.tv-preview h4 { margin: 0; font-size: clamp(16px, 2.3vw, 30px); letter-spacing: -0.5px; }
.tv-preview p { margin: 0; color: rgba(255,255,255,.75); font-size: clamp(11px, 1.1vw, 15px); }
.tv-preview .fake-input { height: 34px; border-radius: 10px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); max-width: 300px; }
.tv-preview .fake-btn { height: 34px; border-radius: 17px; max-width: 160px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; }
.tv-preview .mac { font-family: ui-monospace, monospace; font-size: 12px; color: rgba(255,255,255,.6); }



.version-hero { display: flex; align-items: center; gap: 20px; padding: 24px; border-radius: var(--radius); background: linear-gradient(120deg, rgba(46,230,197,.14), rgba(123,92,255,.16) 50%, rgba(255,77,141,.12)); border: 1px solid var(--border); }
.version-hero .big { font-size: 40px; font-weight: 800; letter-spacing: -1.5px; }

.callout { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: rgba(123,140,255,0.08); border: 1px solid rgba(123,140,255,0.25); color: var(--text-dim); }
.callout svg { color: #9fb4ff; margin-top: 2px; }
.callout.warn { background: rgba(255,201,77,0.08); border-color: rgba(255,201,77,0.3); }
.callout.warn svg { color: var(--amber); }

/* ---------- Janela modal e avisos ---------- */
.modal { position: fixed; inset: 0; background: rgba(4, 5, 9, 0.7); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel); border: 1px solid var(--border-strong); border-radius: 20px; padding: 26px; box-shadow: var(--shadow); display: grid; gap: 16px; }
.modal-card h3 { margin: 0; font-size: 20px; }
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 60; }
.toast { min-width: 260px; max-width: 380px; padding: 12px 16px; border-radius: 12px; background: #1b1f30; border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-weight: 600; display: flex; gap: 10px; align-items: center; animation: pop .2s ease-out; }
.toast.ok svg { color: var(--teal); }
.toast.err svg { color: var(--red); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Ecrãs pequenos ---------- */
@media (max-width: 1100px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 16px 16px 4px; }
  .topbar h2 { font-size: 21px; }
  .top-actions .btn span, #logout-btn { font-size: 0; gap: 0; }
  .greeting { display: none; }
  .view { padding: 14px 16px 32px; }
  .form-grid { grid-template-columns: 1fr; }
  .table-wrap { margin: 0 -22px -22px; }
}

/* Os filhos das grelhas e dos cartões não podem crescer além do ecrã (tabelas e textos compridos). */
.grid-2 > *, .grid-3 > *, .card, .adm-item, .adm-body > *, .dns-list > * { min-width: 0; }
p .mono, .hint .mono, .muted .mono { overflow-wrap: anywhere; }
/* Telemóvel: cada linha das tabelas passa a cartão (nome da coluna à esquerda, valor à direita),
   para as colunas e os botões não ficarem fora do ecrã. Os nomes vêm de labelTables() em app.js. */
@media (max-width: 760px) {
  .table-wrap { overflow-x: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: auto; }
  .table-wrap thead { display: none; }
  .table-wrap tr { padding: 12px 22px; border-bottom: 1px solid var(--border); }
  .table-wrap tr:last-child { border-bottom: 0; }
  .table-wrap td { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 10px; padding: 5px 0; border: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }
  .table-wrap td::before { content: attr(data-label); flex: none; margin-right: auto; max-width: 45%; text-align: left; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; font-weight: 700; color: var(--muted); }
  .table-wrap td:first-child { display: block; text-align: left; padding-bottom: 8px; }
  .table-wrap td:first-child::before, .table-wrap td[data-label=""]::before { display: none; }
  .table-wrap td:empty { display: none; }
  .table-wrap td[data-label=""] { justify-content: flex-end; }
  .table-wrap td .row-actions { flex-wrap: wrap; justify-content: flex-end; }
}
@media (max-width: 760px) {
  .dns-card { flex-wrap: wrap; gap: 12px; }
  .dns-card > div[style] { flex-basis: calc(100% - 60px) !important; }
  .dns-card > button:first-of-type { margin-left: auto; }
  .topbar { gap: 10px; }
  .top-actions { gap: 6px; flex: none; }
  .top-actions .btn { padding-left: 10px; padding-right: 10px; }
}

/* Administradores › o que cada admin tem */
.adm-data { display: grid; gap: 10px; }
.adm-item { border: 1px solid var(--border); border-radius: 14px; background: var(--bg-2); }
.adm-item > summary { display: flex; align-items: center; gap: 14px; padding: 14px 16px; cursor: pointer; list-style: none; }
.adm-item > summary::-webkit-details-marker { display: none; }
.adm-item > summary .chev { width: 18px; height: 18px; transition: transform .2s; color: var(--muted); }
.adm-item[open] > summary .chev { transform: rotate(180deg); }
.adm-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.adm-counts span { font-size: 12px; font-weight: 700; color: var(--text-dim); background: var(--panel-2); border-radius: 999px; padding: 3px 10px; }
.adm-body { padding: 0 16px 16px; display: grid; gap: 16px; }
.adm-block h4 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.adm-block + .adm-block { border-top: 1px solid var(--border); padding-top: 14px; }
.adm-block .table-wrap { margin-bottom: 4px; }
@media (max-width: 720px) { .adm-counts { display: none; } }

.link-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--red-1); font: inherit; font-weight: 700; font-size: 13px; cursor: pointer; padding: 4px 2px; }
.link-btn:hover { text-decoration: underline; }
.link-btn svg { width: 16px; height: 16px; }

/* Enviar MAC: escolha entre "só o MAC" e "com tudo" */
.transfer-opts { display: grid; gap: 10px; }
.transfer-opts .opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-2); cursor: pointer; color: var(--text); }
.transfer-opts .opt:has(input:checked) { border-color: var(--red-1); background: rgba(255,106,77,.08); }
.transfer-opts .opt input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--red-1); }
.transfer-opts .opt > span { display: grid; gap: 4px; }

/* ---------- Tickets de apoio ---------- */
.badge-count.hot { background: var(--red-2); color: #fff; }
.bell-wrap { position: relative; }
.bell-btn { position: relative; width: 40px; height: 40px; border-radius: 12px; }
.bell-btn svg { width: 20px; height: 20px; }
.bell-btn.ring { color: var(--text); border-color: rgba(255,106,77,.5); }
.bell-btn.ring svg { animation: bell-ring 2.4s ease-in-out infinite; transform-origin: 50% 10%; }
@keyframes bell-ring { 0%, 70%, 100% { transform: rotate(0); } 75% { transform: rotate(14deg); } 80% { transform: rotate(-12deg); } 85% { transform: rotate(8deg); } 90% { transform: rotate(-5deg); } }
.bell-count { position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; background: var(--red-2); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg-2); }
.bell-menu { position: absolute; right: 0; top: 48px; z-index: 50; width: min(360px, calc(100vw - 32px)); background: var(--panel-2); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.55); padding: 8px; }
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px 10px; font-size: 14px; }
.bell-head .muted { font-size: 12px; }
.bell-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.bell-item:hover { background: rgba(255,255,255,.06); }
.bell-empty { padding: 18px 10px; color: var(--muted); font-size: 13px; text-align: center; }
.bell-all { width: 100%; margin-top: 6px; padding: 10px; border: 0; border-top: 1px solid var(--border); background: transparent; color: var(--red-1); font: inherit; font-weight: 700; cursor: pointer; border-radius: 0 0 10px 10px; }
.bell-all:hover { background: rgba(255,255,255,.04); }
.dot-new { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--red-1); box-shadow: 0 0 0 3px rgba(255,106,77,.2); margin-right: 8px; flex: none; vertical-align: middle; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.click-row { cursor: pointer; }
tr.unread td .cell-main { color: #fff; }
.ticket-list { display: flex; flex-direction: column; gap: 8px; }
.ticket-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-2); color: var(--text); font: inherit; cursor: pointer; }
.ticket-item:hover { border-color: rgba(255,255,255,.22); }
.ticket-item.unread { border-color: rgba(255,106,77,.45); }
.ticket-modal { min-width: 0; }
.modal-card:has(.ticket-modal) { width: min(720px, 100%); }
.ticket-from { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border); font-size: 14px; margin-bottom: 12px; }
.ticket-from svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--text-dim); }
.ticket-thread { display: flex; flex-direction: column; gap: 10px; max-height: 46vh; overflow-y: auto; padding-right: 4px; }
.msg { max-width: 88%; align-self: flex-start; padding: 10px 14px; border-radius: 14px 14px 14px 4px; background: var(--bg-2); border: 1px solid var(--border); }
.msg.super { align-self: flex-end; border-radius: 14px 14px 4px 14px; background: rgba(229,9,20,.14); border-color: rgba(255,106,77,.35); }
.msg-head { display: flex; gap: 12px; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.msg-head span { color: var(--muted); white-space: nowrap; }
.msg-body { font-size: 14px; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
.actions .spacer { flex: 1; }
.danger-text { color: var(--red); }
@media (max-width: 760px) {
  .bell-menu { position: fixed; right: 16px; left: 16px; top: 64px; width: auto; }
  .msg { max-width: 100%; }
}

/* Online agora: o que o aparelho está a ver */
.watching { display: flex; align-items: flex-start; gap: 6px; margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--text); }
.watching svg { width: 13px; height: 13px; flex: none; margin-top: 3px; fill: var(--teal); stroke: none; }
.watching .muted { font-weight: 500; }

/* Menu no telemóvel: botão X, fundo escuro por trás e a página não desliza enquanto está aberto */
.side-close { display: none; margin-left: auto; width: 38px; height: 38px; flex: none; }
.side-close svg { width: 20px; height: 20px; }
.side-backdrop { display: none; }
@media (max-width: 860px) {
  .side-close { display: inline-grid; }
  .sidebar { height: 100vh; height: 100dvh; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  html.menu-open, html.menu-open body { overflow: hidden; height: 100%; overscroll-behavior: none; }
  html.menu-open .side-backdrop { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(4, 5, 9, 0.6); }
}

/* Barras de qualidade (tipo sinal de rede) */
.signal { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.signal svg { width: 18px; height: 16px; stroke: none; }
.signal svg rect { stroke: none; }
.signal rect { fill: rgba(255,255,255,.16); }
.signal.bad rect.on { fill: #FF4D5E; }
.signal.mid rect.on { fill: #FFC94D; }
.signal.good rect.on { fill: #2EE6C5; }
.signal.bad b { color: #FF8A95; }
.signal.mid b { color: #FFC94D; }
.signal.good b { color: #2EE6C5; }
.signal.none { color: var(--muted); }

/* Pré-visualização do formato da imagem (MAC Logins › Editar) */
.fit-preview { display: flex; gap: 14px; align-items: center; margin-top: 8px; font-weight: 500; }
.fit-tv { box-sizing: content-box; flex: 0 0 auto; width: 192px; aspect-ratio: 16 / 9; background: #000; border: 6px solid #1f2230; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.fit-tv svg { display: block; width: 100%; height: 100%; }
.fit-tv .fit-box43 { height: 100%; aspect-ratio: 4 / 3; margin: 0 auto; }
.fit-cap { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); min-width: 0; }
.fit-cap b { color: var(--text); font-size: 13px; }
@media (max-width: 520px) { .fit-preview { flex-direction: column; align-items: flex-start; } .fit-tv { width: calc(100% - 12px); max-width: 280px; } }

/* Grupos (MAC Logins e menu Grupos) */
.mac-group { border-top: 1px solid var(--border); }
.mac-group:first-of-type { border-top: 0; }
.mac-group > summary { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; row-gap: 6px; padding: 12px 6px; cursor: pointer; font-weight: 600; }
.mac-group > summary::-webkit-details-marker { display: none; }
.mac-group-count { margin-left: auto; flex: none; display: inline-flex; align-items: center; gap: 10px; font-weight: 500; white-space: nowrap; }
.mac-group-count > * { white-space: nowrap; }
.mac-group-name { display: inline-flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; }
.mac-group-name svg { width: 18px; height: 18px; }
.mac-group:not([open]) > summary { opacity: .75; }
.modal-card:has(.gd-modal) { width: min(860px, 100%); }
.gd-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.gd-all { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.gd-all input, .gd-row input { width: 18px; height: 18px; accent-color: var(--red-1); }
.gd-table { max-height: 52vh; overflow: auto; margin-bottom: 14px; }
.gd-row { cursor: pointer; }
.gd-row:has(input:checked) td { background: rgba(255,106,77,.08); }
.gd-row.hidden { display: none; }

/* ---------- Telemóvel: afinações gerais ---------- */
@media (max-width: 760px) {
  /* Título da página mais compacto (a descrição fica em 2 linhas no máximo) */
  .topbar h2 { font-size: 19px; line-height: 1.2; }
  #page-sub { font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  /* Filtros (chips) numa só linha que desliza, em vez de 2–3 linhas */
  .chips { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; white-space: nowrap; }
  .toolbar { min-width: 0; width: 100%; }
  .card-head > .toolbar { flex: 1 1 100% !important; }
  .card-head > .toolbar + .btn { margin-left: auto; }
  .toolbar > .chips, .card-head > .chips { min-width: 0; flex: 1 1 100%; }
  .toolbar .search { min-width: 0; flex-basis: 100%; }
  .pill { white-space: nowrap; }
  .table-wrap td .mono { font-size: 12px; }
  /* Cartões das estatísticas (Painel) mais baixos; "+N esta semana" deixa de tapar o ícone */
  .stats { gap: 10px; }
  .stat { padding: 14px; display: flex; flex-direction: column; }
  .stat-icon { width: 32px; height: 32px; margin-bottom: 10px; }
  .stat-value { font-size: 24px; }
  .stat-label { font-size: 12px; }
  .stat-trend { position: static; order: 3; margin-top: 4px; font-size: 11px; }
  /* Janelas: usam mais largura; os botões ficam sempre à vista no fundo; textos compridos partem */
  .modal { padding: 10px; }
  .modal-card { padding: 20px 16px; max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); border-radius: 18px; overflow-wrap: anywhere; }
  .modal-card .actions { position: sticky; bottom: -20px; z-index: 2; background: var(--panel); padding: 12px 0 6px; margin-bottom: -6px; }
  /* MAC Logins: cabeçalho dos grupos (nome numa linha, "online" e total por baixo) */
  .mac-group .table-wrap { margin-bottom: 0; }
  /* Imagens de fundo / desenhos: 2 por linha */
  .themes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .themes .theme-swatch { height: 72px !important; }
  /* Grupos › Aparelhos: cada MAC numa linha compacta (caixa, MAC e grupo; nome; conta) */
  .gd-table { max-height: none; overflow: visible; margin: 0 0 12px; }
  .gd-table .gd-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; column-gap: 10px; row-gap: 2px; padding: 10px 6px; align-items: center; border-radius: 10px; }
  .gd-table .gd-row td { display: block; padding: 0; text-align: left; border: 0; background: none !important; }
  .gd-table .gd-row td::before { display: none; }
  .gd-table .gd-row td:nth-child(1) { grid-column: 1; grid-row: 1 / span 3; padding: 0; }
  .gd-table .gd-row td:nth-child(2) { grid-column: 2; grid-row: 1; font-size: 13px; }
  .gd-table .gd-row td:nth-child(5) { grid-column: 3; grid-row: 1; }
  .gd-table .gd-row td:nth-child(3) { grid-column: 2 / 4; grid-row: 2; font-weight: 600; }
  .gd-table .gd-row td:nth-child(4) { grid-column: 2 / 4; grid-row: 3; font-size: 12.5px; color: var(--muted); }
  .gd-table .gd-row:has(input:checked) { background: rgba(255,106,77,.08); }
  .gd-table .gd-row.hidden { display: none; }
}

/* MAC Logins: em ecrãs estreitos o "N online · N aparelhos" passa para a linha de baixo, inteiro */
@media (max-width: 860px) {
  .mac-group > summary { padding: 12px 2px; }
  .mac-group-count { flex: 1 0 100%; margin-left: 0; padding-left: 26px; gap: 8px; font-size: 13px; }
}

/* Pastas coloridas dos grupos (a cor vem de cada grupo) */
.g-folder { display: inline-grid; place-items: center; flex: none; color: var(--gc); }
.g-folder svg { width: 18px; height: 18px; fill: color-mix(in srgb, var(--gc) 28%, transparent); }
.dns-icon.g-tile { color: var(--gc); background: color-mix(in srgb, var(--gc) 16%, transparent); }
.dns-icon.g-tile svg { fill: color-mix(in srgb, var(--gc) 30%, transparent); }
@media (max-width: 760px) { .dns-card > .dns-icon.g-tile { flex: none !important; flex-basis: auto !important; } }

/* MAC Logins: a tabela de cada grupo não "puxa" o grupo seguinte para cima (antes, a margem negativa
   do fundo fazia a última linha ficar por baixo do título do grupo seguinte) */
.mac-group .table-wrap { margin-bottom: 0; }
.mac-group[open] { padding-bottom: 6px; }
.mac-group .table-wrap tbody tr:last-child td { border-bottom: 0; }

/* Passos numerados (Atualizar, TMDB, MAC Logins): o texto fica num bloco que quebra linha, em vez de cada
   pedaço (negrito, código) virar uma coluna e sair do ecrã no telemóvel. */
.legend-row.step { align-items: flex-start; }
.legend-row.step .avatar { flex: 0 0 auto; }
.legend-row.step > div { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.45; padding-top: 4px; }
.legend-row.step b { margin-left: 0; }

@media (max-width: 760px) {
  /* Atualizar: o cartão da versão publicada passa a empilhar (o botão vai para baixo, a toda a largura). */
  .version-hero { flex-wrap: wrap; gap: 14px; padding: 18px; }
  .version-hero > div[style*="flex:1"] { min-width: 0; flex: 1 1 160px; }
  .version-hero .big { font-size: 30px; }
  .version-hero > .btn { width: 100%; justify-content: center; }
  .pin-row input[type=file] { max-width: 100%; }
}

/* Powerflix News */
.news-list { display: grid; gap: 10px; }
.news-card { padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.03); border: 1px solid var(--border); }
.news-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.news-body { margin-top: 6px; color: var(--text-dim, #c9cbd6); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.5; }

/* Política de palavras-passe (caixa obrigatória e listas de regras) */
.pw-box { max-width: 620px; }
.pw-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.pw-head h3 { margin: 0 0 4px; }
.pw-head p { margin: 0; }
.pw-badge { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,77,141,.14); color: #FF8AB3; }
.pw-badge svg { width: 22px; height: 22px; }
.pw-info { border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; background: rgba(255,255,255,.03); }
.pw-info ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.pw-info li { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.45; color: var(--text-dim); }
.pw-info li svg { flex: none; width: 16px; height: 16px; margin-top: 2px; color: var(--teal); }
.pw-info li b { color: var(--text); }
.pw-rules { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.pw-rules + .pw-rules { margin-top: 6px; grid-template-columns: 1fr; }
.pw-rules li { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-dim); }
.pw-rules li svg { width: 15px; height: 15px; padding: 2px; border-radius: 50%; border: 1px solid var(--border); color: transparent; }
.pw-rules li.ok { color: var(--text); }
.pw-rules li.ok svg { color: #fff; background: var(--teal); border-color: var(--teal); }
@media (max-width: 640px) { .pw-rules { grid-template-columns: 1fr; } }

/* Sistema do aparelho (APK / Windows / TV) em MAC Logins */
.plat { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .3px; padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: 1px; border: 1px solid var(--border); color: var(--text-dim); }
.plat-apk { color: #7ee2a8; border-color: rgba(126,226,168,.4); background: rgba(126,226,168,.08); }
.plat-windows { color: #7fb6ff; border-color: rgba(127,182,255,.4); background: rgba(127,182,255,.08); }
.plat-tv { color: #f5c76b; border-color: rgba(245,199,107,.4); background: rgba(245,199,107,.08); }
