/* ==========================================================================
   VOD Sync — design system (herdado do Painel de Revendas)
   ========================================================================== */

:root {
  --bg: #0b0f19;
  --bg-2: #0e1322;
  --surface: #121829;
  --surface-2: #182036;
  --surface-3: #1f2942;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #e7ebf3;
  --text-strong: #ffffff;
  --muted: #8d97ab;
  --muted-2: #667085;
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --primary-soft: rgba(99, 102, 241, 0.16);
  --primary-text: #a5b4fc;
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.16);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.16);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.16);
  --info: #06b6d4;
  --info-soft: rgba(6, 182, 212, 0.16);
  --iptv: #3b82f6;
  --iptv-soft: rgba(59, 130, 246, 0.16);
  --p2p: #a855f7;
  --p2p-soft: rgba(168, 85, 247, 0.16);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 268px;
  --topbar-h: 64px;
  --shadow: 0 12px 32px rgba(2, 6, 23, 0.45);
  --shadow-sm: 0 4px 14px rgba(2, 6, 23, 0.3);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="light"] {
  --bg: #f2f4f8;
  --bg-2: #eaedf3;
  --surface: #ffffff;
  --surface-2: #f6f7fa;
  --surface-3: #eef0f5;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #1e293b;
  --text-strong: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --primary-soft: rgba(99, 102, 241, 0.1);
  --primary-text: #4f46e5;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger-soft: rgba(239, 68, 68, 0.12);
  --info-soft: rgba(6, 182, 212, 0.12);
  --iptv-soft: rgba(59, 130, 246, 0.12);
  --p2p-soft: rgba(168, 85, 247, 0.12);
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  background-image: radial-gradient(1200px 600px at 10% -10%, rgba(99, 102, 241, 0.12), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(139, 92, 246, 0.08), transparent 55%);
  background-attachment: fixed;
  min-height: 100vh;
}
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; color: var(--text-strong); font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }
code, .mono { font-family: var(--mono); font-size: 13px; }
::selection { background: rgba(99, 102, 241, 0.35); }
svg.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; vertical-align: -3px; }
svg.icon.sm { width: 15px; height: 15px; }
svg.icon.lg { width: 22px; height: 22px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: transform 0.25s ease;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
}
.brand-name { font-weight: 800; font-size: 15px; color: var(--text-strong); line-height: 1.15; }
.brand-tag { font-size: 11.5px; color: var(--muted); }
.nav { padding: 14px 12px; overflow-y: auto; flex: 1; }
.nav-section { font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-2); padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--muted);
  font-weight: 500; font-size: 14px; transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text-strong); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.nav a .badge { margin-left: auto; }
.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.user-card .avatar { flex-shrink: 0; }
.user-card .name { font-weight: 600; font-size: 13.5px; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .role { font-size: 12px; color: var(--muted); }
.user-card form { margin-left: auto; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; overflow-x: clip; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .title { font-size: 17px; font-weight: 700; color: var(--text-strong); }
.topbar .spacer { flex: 1; }
.credits-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; font-weight: 700; font-size: 13.5px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(139, 92, 246, 0.25)); color: var(--text-strong); border: 1px solid rgba(139, 92, 246, 0.35);
}
.credits-pill .num { font-size: 15px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); cursor: pointer; transition: 0.15s;
}
.icon-btn:hover { color: var(--text-strong); border-color: var(--border-strong); }
.menu-btn { display: none; }
.content { padding: 24px; max-width: 1480px; width: 100%; }
.impersonation-bar {
  display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--warning-soft); color: var(--warning);
  border-bottom: 1px solid rgba(245, 158, 11, 0.35); font-weight: 600; font-size: 13.5px;
}
.impersonation-bar form { margin-left: auto; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header .sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { display: flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 18px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-header h2, .card-header h3 { display: flex; align-items: center; gap: 9px; }
.card-header .sub { color: var(--muted); font-size: 13px; font-weight: 400; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid .card + .card { margin-top: 0; }
.mt { margin-top: 18px; }
.mb { margin-bottom: 18px; }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { position: relative; overflow: hidden; display: flex; gap: 14px; align-items: center; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.stat::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--accent, var(--primary)); opacity: 0.08; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; background: color-mix(in srgb, var(--accent, var(--primary)) 18%, transparent); color: var(--accent, var(--primary)); }
.stat-icon svg.icon { width: 22px; height: 22px; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 24px; font-weight: 800; color: var(--text-strong); line-height: 1.15; letter-spacing: -0.02em; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-sub b { color: var(--text); }
.stat.compact { padding: 14px 16px; }
.stat.compact .stat-value { font-size: 20px; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 20px; font-weight: 800; color: var(--text-strong); }
.kpi .value.money { color: var(--success); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions-cell { text-align: right; white-space: nowrap; }
.table .actions-cell .btn { margin-left: 4px; }
.table .primary-cell { font-weight: 600; color: var(--text-strong); }
.table .sub-cell { font-size: 12px; color: var(--muted); }
.table tr.row-link { cursor: pointer; }
.pos { color: var(--success); font-weight: 700; }
.neg { color: var(--danger); font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty svg.icon { width: 40px; height: 40px; opacity: 0.4; margin-bottom: 10px; }
.empty b { display: block; color: var(--text); margin-bottom: 4px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; background: var(--surface-3); color: var(--text); border: 1px solid transparent; }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.primary { background: var(--primary-soft); color: var(--primary-text); }
.badge.iptv { background: var(--iptv-soft); color: var(--iptv); }
.badge.p2p { background: var(--p2p-soft); color: var(--p2p); }
.badge.muted { background: var(--surface-3); color: var(--muted); }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.lg { font-size: 12.5px; padding: 5px 12px; }
.plan-chip { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.plan-chip .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  transition: transform 0.05s, background 0.15s, border-color 0.15s, box-shadow 0.15s; text-decoration: none !important; line-height: 1.2;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); border-color: transparent; color: #fff; box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35); }
.btn-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.btn-success { background: var(--success); border-color: transparent; color: #fff; }
.btn-success:hover { background: #0ea371; }
.btn-danger { background: var(--danger-soft); border-color: rgba(239, 68, 68, 0.35); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning-soft); border-color: rgba(245, 158, 11, 0.35); color: var(--warning); }
.btn-warning:hover { background: var(--warning); color: #111; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-strong); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-xs { padding: 4px 8px; font-size: 12px; border-radius: 7px; }
.btn-icon { padding: 7px; width: 32px; height: 32px; }
.btn-icon.btn-sm { width: 30px; height: 30px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
form.inline { display: inline; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.field label .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg-2); color: var(--text-strong);
  font: inherit; font-size: 14px; transition: border-color 0.15s, box-shadow 0.15s; outline: none;
}
[data-theme="light"] .input, [data-theme="light"] .select, [data-theme="light"] .textarea { background: #fff; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input::placeholder { color: var(--muted-2); }
.select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238d97ab' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px; }
.textarea { min-height: 110px; resize: vertical; font-family: inherit; }
.textarea.mono { font-family: var(--mono); font-size: 13px; min-height: 220px; }
.help { font-size: 12px; color: var(--muted); margin-top: 5px; }
.input-group { display: flex; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0; }
.check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 13.5px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; transition: 0.2s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: 0.2s; }
.switch input:checked + .track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .track::after { left: 21px; }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.radio-card { position: relative; }
.radio-card input { position: absolute; opacity: 0; }
.radio-card > span { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--bg-2); cursor: pointer; transition: 0.15s; }
[data-theme="light"] .radio-card > span { background: #fff; }
.radio-card span b { color: var(--text-strong); display: flex; align-items: center; gap: 8px; }
.radio-card span small { color: var(--muted); font-size: 12px; }
.radio-card input:checked + span { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary-soft); }
.radio-card.iptv input:checked + span { border-color: var(--iptv); background: var(--iptv-soft); box-shadow: 0 0 0 3px var(--iptv-soft); }
.radio-card.p2p input:checked + span { border-color: var(--p2p); background: var(--p2p-soft); box-shadow: 0 0 0 3px var(--p2p-soft); }
.plan-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.plan-card input { position: absolute; opacity: 0; }
.plan-card { position: relative; }
.plan-card > span { display: block; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--bg-2); cursor: pointer; transition: 0.15s; border-left-width: 4px; }
[data-theme="light"] .plan-card > span { background: #fff; }
.plan-card .pc-name { font-weight: 700; color: var(--text-strong); display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.plan-card .pc-meta, .plan-card .pc-cost { display: block; }
.plan-card .pc-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.plan-card .pc-cost { font-size: 12.5px; font-weight: 700; color: var(--primary-text); margin-top: 6px; }
.plan-card input:checked + span { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 20px; }
.filters { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.filters .field { min-width: 150px; margin: 0; }
.filters .field.grow { flex: 1; min-width: 200px; }
.filters .input, .filters .select { padding: 8px 11px; font-size: 13.5px; }
.filters .btn { padding: 8px 13px; }

/* ---------- Alerts / toasts ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid; font-size: 13.5px; margin-bottom: 16px; }
.alert.info { background: var(--info-soft); border-color: rgba(6, 182, 212, 0.35); color: var(--info); }
.alert.success { background: var(--success-soft); border-color: rgba(16, 185, 129, 0.35); color: var(--success); }
.alert.warning { background: var(--warning-soft); border-color: rgba(245, 158, 11, 0.35); color: var(--warning); }
.alert.danger { background: var(--danger-soft); border-color: rgba(239, 68, 68, 0.35); color: var(--danger); }
.alert b { font-weight: 700; }
.toasts { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: 420px; }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-size: 13.5px; animation: toast-in 0.25s ease; }
.toast.success { border-left: 4px solid var(--success); }
.toast.error, .toast.danger { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--info); }
.toast .close { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Modal ---------- */
dialog.modal { border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface); color: var(--text); padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog.modal::backdrop { background: rgba(2, 6, 23, 0.6); backdrop-filter: blur(3px); }
dialog.modal.wide { width: min(760px, calc(100vw - 32px)); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ---------- Misc ---------- */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); flex-shrink: 0; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex.between { justify-content: space-between; }
.flex.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.pagination .pages { display: flex; gap: 4px; }
.pagination .pages a, .pagination .pages span { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border); color: var(--text); }
.pagination .pages span.current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.pagination .pages a:hover { background: var(--surface-2); text-decoration: none; }
.pagination .pages .disabled { opacity: 0.4; pointer-events: none; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 20px; overflow-x: auto; }
.tabs a, .tabs button { padding: 12px 14px; font-weight: 600; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; border-top: 0; border-left: 0; border-right: 0; cursor: pointer; font-family: inherit; white-space: nowrap; }
.tabs a.active, .tabs button.active { color: var(--primary-text); border-bottom-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--text-strong); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--primary-2)); }
.progress.success > span { background: var(--success); }
.progress.warning > span { background: var(--warning); }
.progress.danger > span { background: var(--danger); }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; color: var(--text-strong); font-weight: 500; word-break: break-word; }
.copy-box { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--border); font-family: var(--mono); font-size: 13px; }
[data-theme="light"] .copy-box { background: #f6f7fa; }
.copy-box .val { flex: 1; min-width: 0; overflow: clip; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: left; color: var(--text-strong); }
.copy-box.wrap { align-items: flex-start; }
.copy-box.wrap .val { white-space: normal; word-break: break-all; overflow-wrap: anywhere; text-overflow: clip; line-height: 1.45; font-size: 12.5px; padding: 2px 0; }
.copy-box.wrap .btn { flex-shrink: 0; }
.credential { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; align-items: center; }
.credential .k { color: var(--muted); font-size: 12.5px; }
.tpl-card { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.tpl-card + .tpl-card { margin-top: 12px; }
.tpl-card .tpl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; }
.tpl-card pre { margin: 0; padding: 14px; white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 13.5px; line-height: 1.55; color: var(--text); background: var(--bg-2); max-height: 380px; overflow: auto; }
[data-theme="light"] .tpl-card pre { background: #fff; }
.code-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.code-list .code { padding: 10px 12px; border-radius: 10px; background: var(--bg-2); border: 1px dashed var(--border-strong); font-family: var(--mono); font-weight: 700; letter-spacing: 0.05em; text-align: center; color: var(--text-strong); }
.hero-result { padding: 22px; border-radius: var(--radius); background: linear-gradient(135deg, rgba(16, 185, 129, 0.16), rgba(99, 102, 241, 0.16)); border: 1px solid rgba(16, 185, 129, 0.3); margin-bottom: 18px; display: flex; gap: 16px; align-items: center; }
.hero-result .hero-icon { width: 52px; height: 52px; border-radius: 14px; background: var(--success); color: #fff; display: grid; place-items: center; }
.hero-result .hero-icon svg.icon { width: 26px; height: 26px; }
.hero-result h2 { margin-bottom: 2px; }

/* ---------- Charts (CSS) ---------- */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding: 10px 4px 0; }
.chart .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 6px; min-width: 0; }
.chart .bar .fill { width: 100%; max-width: 40px; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, var(--primary-2), var(--primary)); min-height: 3px; position: relative; transition: filter 0.15s; }
.chart .bar .fill.success { background: linear-gradient(180deg, #34d399, var(--success)); }
.chart .bar .fill.info { background: linear-gradient(180deg, #22d3ee, var(--info)); }
.chart .bar:hover .fill { filter: brightness(1.2); }
.chart .bar .fill .tip { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--surface-3); color: var(--text-strong); font-size: 11.5px; font-weight: 700; padding: 3px 7px; border-radius: 6px; white-space: nowrap; opacity: 0; pointer-events: none; transition: 0.15s; border: 1px solid var(--border-strong); }
.chart .bar:hover .fill .tip { opacity: 1; }
.chart .bar:first-child .fill .tip { left: 0; transform: none; }
.chart .bar:last-child .fill .tip { left: auto; right: 0; transform: none; }
.chart .bar .lbl { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.chart.dense .bar .lbl { display: none; }
.chart.dense .bar:nth-child(5n+1) .lbl { display: block; }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); padding: 8px 4px 0; flex-wrap: wrap; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; background: var(--primary); }
.chart-legend i.success { background: var(--success); }
.chart-legend i.info { background: var(--info); }
.bars-h { display: flex; flex-direction: column; gap: 9px; }
.bars-h .row { display: grid; grid-template-columns: minmax(90px, 1.2fr) 3fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bars-h .row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.bars-h .row .val { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.donut { display: flex; align-items: center; gap: 18px; }
.donut .ring { width: 110px; height: 110px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.donut .ring > div { width: 76px; height: 76px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; font-weight: 800; font-size: 18px; color: var(--text-strong); line-height: 1; }
.donut .ring > div small { display: block; font-size: 10.5px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.donut ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.donut ul li { display: flex; align-items: center; gap: 8px; }
.donut ul li i { width: 10px; height: 10px; border-radius: 3px; }
.donut ul li b { margin-left: auto; }

/* ---------- Tree ---------- */
.tree ul { list-style: none; margin: 0; padding-left: 26px; border-left: 1px dashed var(--border-strong); }
.tree > ul { padding-left: 0; border-left: 0; }
.tree li { margin: 6px 0; }
.tree .node { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.tree .node:hover { border-color: var(--border-strong); }
.tree .node .n-name { font-weight: 600; color: var(--text-strong); }
.tree .node .n-user { color: var(--muted); font-size: 12.5px; }
.tree .node .n-meta { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.tree details > summary { list-style: none; cursor: pointer; }
.tree details > summary::-webkit-details-marker { display: none; }
.tree .caret { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 6px; color: var(--muted); transition: transform 0.15s; }
.tree details[open] > summary .caret { transform: rotate(90deg); }
.tree .leaf .caret { opacity: 0.25; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.login-hero {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 36px 44px; color: #fff;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 30%, #4f46e5 70%, #7c3aed 100%);
}
.login-hero::before, .login-hero::after { content: ""; position: absolute; border-radius: 50%; filter: blur(10px); opacity: 0.55; pointer-events: none; }
.login-hero::before { width: 520px; height: 520px; right: -180px; top: -160px; background: radial-gradient(circle at 30% 30%, rgba(167, 139, 250, 0.9), rgba(99, 102, 241, 0) 70%); }
.login-hero::after { width: 460px; height: 460px; left: -160px; bottom: -200px; background: radial-gradient(circle at 60% 40%, rgba(34, 211, 238, 0.55), rgba(99, 102, 241, 0) 70%); }
.login-hero > * { position: relative; z-index: 1; }
.login-hero .brand { padding: 0; border: 0; }
.login-hero .brand-logo { background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.28); box-shadow: none; backdrop-filter: blur(6px); }
.login-hero .brand-name { color: #fff; }
.login-hero .brand-tag { color: rgba(255, 255, 255, 0.7); }
.login-hero-body { max-width: 640px; margin: 28px 0; }
.login-hero .eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.22); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 18px; }
.login-hero h1 { color: #fff; font-size: 34px; line-height: 1.12; letter-spacing: -0.02em; margin-bottom: 14px; }
.login-hero h1 span { background: linear-gradient(90deg, #c7d2fe, #a5f3fc); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-hero p.lead { color: rgba(255, 255, 255, 0.78); font-size: 15.5px; line-height: 1.6; margin-bottom: 26px; }
.login-features { display: grid; gap: 12px; }
@media (min-width: 1200px) { .login-features { grid-template-columns: 1fr 1fr; } }
.login-feature { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.14); backdrop-filter: blur(6px); }
.login-feature .fi { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: rgba(255, 255, 255, 0.16); }
.login-feature b { display: block; font-size: 14px; }
.login-feature small { color: rgba(255, 255, 255, 0.72); font-size: 12.5px; }
.login-hero-foot { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: rgba(255, 255, 255, 0.65); align-items: center; }
.login-panel { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px 32px; background: var(--surface); position: relative; }
.login-panel .theme-btn { position: absolute; top: 18px; right: 18px; }
.login-form { width: 100%; max-width: 400px; }
.login-form .mobile-brand { display: none; }
.login-form h2 { font-size: 26px; letter-spacing: -0.02em; margin-bottom: 6px; }
.login-form .sub { color: var(--muted); margin-bottom: 26px; font-size: 14px; }
.login-form .field + .field { margin-top: 16px; }
.input-icon { position: relative; }
.input-icon > svg.icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon .input { padding-left: 40px; height: 46px; }
.input-icon .btn-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.input-icon .btn-eye:hover { background: var(--surface-2); color: var(--text-strong); }
.login-form .btn-primary { margin-top: 24px; padding: 13px; font-size: 15px; width: 100%; }
.login-form .login-footer { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 22px; line-height: 1.7; }
.login-form .alert { margin-bottom: 18px; }
@media (max-width: 960px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-panel { min-height: 100vh; padding: 32px 20px; background: var(--bg); }
  .login-form { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 30px 26px; box-shadow: var(--shadow); }
  .login-form .mobile-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
}

/* ---------- Dropdown ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 50; display: none; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 11px; border-radius: 8px; background: none; border: 0; color: var(--text); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-menu .danger { color: var(--danger); }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow); }
  body.sidebar-open::before { content: ""; position: fixed; inset: 0; background: rgba(2, 6, 23, 0.55); z-index: 35; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-grid; }
}
@media (max-width: 720px) {
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .topbar .title { font-size: 15px; }
  .form-grid, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; }
  .credential { grid-template-columns: 1fr; }
  .stat-value { font-size: 21px; }
  .card-body { padding: 16px; }
  .credits-pill .lbl { display: none; }
}
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main { margin: 0; }
  body { background: #fff; color: #000; }
}

/* ==========================================================================
   VOD Sync — complementos
   ========================================================================== */
:root {
  --xui: #f97316;
  --xui-soft: rgba(249, 115, 22, 0.16);
  --sr: #06b6d4;
  --sr-soft: rgba(6, 182, 212, 0.16);
  --m3u: #10b981;
  --m3u-soft: rgba(16, 185, 129, 0.16);
  --xtream: #8b5cf6;
  --xtream-soft: rgba(139, 92, 246, 0.16);
}
[data-theme="light"] {
  --xui-soft: rgba(249, 115, 22, 0.12);
  --sr-soft: rgba(6, 182, 212, 0.12);
  --m3u-soft: rgba(16, 185, 129, 0.12);
  --xtream-soft: rgba(139, 92, 246, 0.12);
}
.badge.xui { background: var(--xui-soft); color: var(--xui); }
.badge.streamroute { background: var(--sr-soft); color: var(--sr); }
.badge.m3u { background: var(--m3u-soft); color: var(--m3u); }
.badge.xtream { background: var(--xtream-soft); color: var(--xtream); }
.badge.movie { background: var(--iptv-soft); color: var(--iptv); }
.badge.series { background: var(--p2p-soft); color: var(--p2p); }

/* log ao vivo das execuções */
.log-box { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word; color: var(--text); }
[data-theme="light"] .log-box { background: #f6f7fa; }
.log-box .err { color: var(--danger); font-weight: 700; }
.job-bar { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--radius); background: var(--info-soft); border: 1px solid rgba(6, 182, 212, 0.35); margin-bottom: 18px; flex-wrap: wrap; }
.job-bar .spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid rgba(6, 182, 212, 0.25); border-top-color: var(--info); animation: spin 0.8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.job-bar .phase { font-weight: 700; color: var(--text-strong); }
.job-bar .counters { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.job-bar .counters b { color: var(--text-strong); }
.job-bar form { margin-left: auto; }

/* mapeamento de categorias */
.map-table .select { padding: 7px 10px; font-size: 13px; min-width: 240px; }
.map-table td.state { width: 60px; }
.map-row.off td { opacity: 0.55; }
.map-row .saved { color: var(--success); font-size: 12px; margin-left: 6px; opacity: 0; transition: opacity 0.2s; }
.map-row .saved.show { opacity: 1; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.checks .check { padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-2); }
[data-theme="light"] .checks .check { background: #fff; }

/* passos (fonte) */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.step { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.step .n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); flex-shrink: 0; }
.step.done .n { background: var(--success); }
.step b { display: block; color: var(--text-strong); font-size: 13.5px; }
.step small { color: var(--muted); font-size: 12px; }
.info-list { margin: 0; padding-left: 18px; line-height: 1.8; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }
.mono-small { font-family: var(--mono); font-size: 12px; }

/* execução em andamento */
.job-card { border-color: rgba(6, 182, 212, 0.35); }
.job-card .job-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.job-card .spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid rgba(6, 182, 212, 0.25); border-top-color: var(--info); animation: spin 0.8s linear infinite; flex-shrink: 0; }
.job-card .phase { font-weight: 700; color: var(--text-strong); font-size: 15px; }
.job-card .progress { height: 12px; }
.job-card .progress > span { transition: width 0.6s ease; background: linear-gradient(90deg, var(--info), var(--primary)); }
.job-card .counters { display: flex; gap: 16px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.job-card .counters b { color: var(--text-strong); }
.run-pct { font-variant-numeric: tabular-nums; }

/* Interruptores e caixas dentro de .field
   `.field label { display: block }` tem especificidade maior que `.switch` /
   `.check`, então o trilho virava inline (largura 0) e só a bolinha branca
   aparecia, sobreposta ao texto. */
.field label.switch { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 0; font-weight: 600; font-size: 13.5px; }
.field label.check { display: flex; align-items: center; gap: 9px; margin-bottom: 0; font-weight: 500; font-size: 13.5px; }
.switch .track { display: inline-block; flex: 0 0 auto; }
.switch input:checked + .track { background: var(--primary); border-color: var(--primary); }

/* listas de bouquet por tipo (filmes / séries / +18) */
.bq-groups { display: grid; gap: 12px; }
.bq-group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface-2); }
.bq-group .bq-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.bq-group .bq-head b { color: var(--text-strong); font-size: 13.5px; }
.bq-group .bq-head span:last-child { margin-left: auto; }
.bq-group .checks { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.bq-group .check { padding: 6px 9px; font-size: 12.5px; }

/* ---- revenda: tokens, preços e faturamento ---- */

/* O token aparece uma única vez; a caixa existe para copiar sem errar. */
.token-box { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.token-box code { flex: 1; overflow-x: auto; white-space: nowrap; padding: 8px 10px; border-radius: 8px;
  background: var(--surface-2, rgba(0,0,0,.05)); border: 1px solid var(--border); font-size: 12.5px; }

/* Campo de dinheiro com o "R$" grudado na frente. */
.input-prefix { display: flex; align-items: stretch; }
.input-prefix > span { display: flex; align-items: center; padding: 0 10px; font-size: 13px; color: var(--muted);
  background: var(--surface-2, rgba(0,0,0,.04)); border: 1px solid var(--border); border-right: 0; border-radius: 10px 0 0 10px; }
.input-prefix > .input { border-radius: 0 10px 10px 0; }

.total-line { display: flex; align-items: center; height: 38px; font-size: 14px; color: var(--muted); }
.total-line b { color: var(--text); margin-left: 6px; font-size: 16px; }

.row-actions { text-align: right; white-space: nowrap; }

/* Gerenciar um usuário sem sair da lista: <details> nativo, sem JS. */
details.dropdown > summary { list-style: none; cursor: pointer; }
details.dropdown > summary::-webkit-details-marker { display: none; }
details.dropdown .dropdown-body { position: absolute; right: 0; top: calc(100% + 6px); width: 300px; text-align: left;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow);
  padding: 12px; z-index: 60; }
details.dropdown .dropdown-body hr { border: 0; border-top: 1px solid var(--border); margin: 10px 0; }
details.dropdown .dropdown-body .form-grid { margin-bottom: 8px; }

tr.off { opacity: .55; }
.table tfoot th { border-top: 2px solid var(--border-strong); font-weight: 600; }
