/* =====================================================================
   ViewDesktop — Design System (arquivo CSS unico)
   Tema escuro azulado por padrao, tema claro via prefers-color-scheme.
   Sem @import, sem CDN: apenas fontes do sistema.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. RESET
   --------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body,
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd, pre {
  margin: 0;
}

ul[class],
ol[class] {
  margin: 0;
  padding: 0;
  list-style: none;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

/* Controles de formulario herdam a tipografia da pagina */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
}

textarea {
  resize: vertical;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
}

hr {
  height: 1px;
  margin: 20px 0;
  border: 0;
  background: var(--border);
}

[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------------
   2. TOKENS — tema escuro (padrao)
   --------------------------------------------------------------------- */

:root {
  color-scheme: dark;

  --bg: #080b14;
  --surface: #101728;
  --surface-2: #182135;
  --border: #26304a;
  --text: #e8edf9;
  --muted: #93a0bd;
  --accent: #4f7cff;
  --accent-strong: #3a63e8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(3, 6, 14, 0.5), 0 6px 20px rgba(3, 6, 14, 0.36);
  --shadow-lg: 0 24px 60px rgba(2, 5, 12, 0.62);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* Tokens de apoio (derivados dos principais) */
  --font-mono: ui-monospace, 'Cascadia Mono', 'Segoe UI Mono', 'SF Mono', Consolas, 'Liberation Mono', monospace;
  --accent-soft: rgba(79, 124, 255, 0.16);
  --ok-soft: rgba(34, 197, 94, 0.15);
  --warn-soft: rgba(245, 158, 11, 0.15);
  --danger-soft: rgba(239, 68, 68, 0.15);
  --muted-soft: rgba(147, 160, 189, 0.14);
  --overlay: rgba(4, 7, 16, 0.72);
  --glass: rgba(16, 23, 40, 0.86);
  --on-accent: #ffffff;
  --ring: 0 0 0 3px rgba(79, 124, 255, 0.32);
  --hairline: rgba(255, 255, 255, 0.05);
  --shimmer: rgba(255, 255, 255, 0.10);
  --header-h: 64px;
  --sidebar-w: 240px;
  --content-max: 1120px;
  --view-pad: 20px;
  --view-gap: 18px;
}

/* Tema claro — apenas os tokens sao redefinidos */
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;

    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #eef2fa;
    --border: #d6ddec;
    --text: #161d2e;
    --muted: #5d6a85;
    --accent: #2f5ce0;
    --accent-strong: #2246b8;
    --ok: #15803d;
    --warn: #b45309;
    --danger: #c62828;

    --shadow: 0 1px 2px rgba(22, 29, 46, 0.08), 0 6px 20px rgba(22, 29, 46, 0.08);
    --shadow-lg: 0 24px 60px rgba(22, 29, 46, 0.18);

    --accent-soft: rgba(47, 92, 224, 0.12);
    --ok-soft: rgba(21, 128, 61, 0.12);
    --warn-soft: rgba(180, 83, 9, 0.13);
    --danger-soft: rgba(198, 40, 40, 0.12);
    --muted-soft: rgba(93, 106, 133, 0.12);
    --overlay: rgba(22, 29, 46, 0.44);
    --glass: rgba(255, 255, 255, 0.88);
    --ring: 0 0 0 3px rgba(47, 92, 224, 0.24);
    --hairline: rgba(22, 29, 46, 0.06);
    --shimmer: rgba(22, 29, 46, 0.09);
  }
}

/* ---------------------------------------------------------------------
   3. TIPOGRAFIA E BASE
   --------------------------------------------------------------------- */

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 520px at 12% -10%, rgba(79, 124, 255, 0.14), transparent 62%),
    radial-gradient(760px 480px at 92% 0%, rgba(34, 197, 94, 0.07), transparent 58%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.015em;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 0.98rem; }

p {
  margin: 0 0 12px;
}

p:last-child {
  margin-bottom: 0;
}

/* Listas sem classe (textos de termos, privacidade e ajuda) */
ul,
ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

ul:not([class]) > li,
ol:not([class]) > li {
  margin-bottom: 6px;
}

small {
  font-size: 0.82rem;
}

strong, b {
  font-weight: 700;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
}

::selection {
  color: var(--on-accent);
  background: var(--accent);
}

::placeholder {
  color: var(--muted);
  opacity: 1;
}

/* Acessibilidade: foco sempre visivel (o contorno segue o raio do elemento) */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Barra de rolagem discreta e coerente com o tema */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: var(--border);
  background-clip: content-box;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

.section-title {
  margin: 0 0 10px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.divider {
  height: 1px;
  margin: 16px 0;
  border-radius: 1px;
  background: var(--border);
}

.code-block {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

/* ---------------------------------------------------------------------
   4. BOTOES
   --------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: background-color 0.15s ease, border-color 0.15s ease,
    transform 0.12s ease, box-shadow 0.15s ease, color 0.15s ease;
  user-select: none;
}

.btn:hover {
  color: var(--text);
  text-decoration: none;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled='true'] {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  border-color: var(--border);
  background: var(--surface-2);
}

.btn-primary {
  color: var(--on-accent);
  border-color: transparent;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  box-shadow: 0 6px 18px rgba(79, 124, 255, 0.28);
}

.btn-primary:hover {
  color: var(--on-accent);
  border-color: transparent;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent-strong));
}

.btn-primary:disabled,
.btn-primary[aria-disabled='true'] {
  box-shadow: none;
  background: var(--accent);
}

.btn-ghost {
  color: var(--muted);
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--surface-2);
}

.btn-danger {
  color: #fff;
  border-color: transparent;
  background: var(--danger);
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.24);
}

.btn-danger:hover {
  color: #fff;
  border-color: transparent;
  background: #d93b3b;
}

.btn-sm {
  min-height: 32px;
  padding: 0 11px;
  font-size: 0.81rem;
  border-radius: 7px;
}

.btn-block {
  display: flex;
  width: 100%;
}

/* ---------------------------------------------------------------------
   5. FORMULARIOS
   --------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field:last-child {
  margin-bottom: 0;
}

.label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text);
}

.hint {
  font-size: 0.79rem;
  line-height: 1.45;
  color: var(--muted);
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  font-size: 0.95rem;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

select.input {
  cursor: pointer;
  padding-right: 8px;
}

textarea.input {
  min-height: 108px;
  line-height: 1.5;
}

.input:hover:not(:disabled):not([readonly]) {
  border-color: var(--muted);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
  background: var(--surface);
}

.input:disabled,
.input[readonly] {
  cursor: not-allowed;
  opacity: 0.6;
}

.input[aria-invalid='true'] {
  border-color: var(--danger);
}

.input[aria-invalid='true']:focus {
  box-shadow: 0 0 0 3px var(--danger-soft);
}

/* Interruptor (checkbox estilizado) */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.35;
  user-select: none;
}

.switch input[type='checkbox'] {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  margin: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.switch input[type='checkbox']::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s ease, background-color 0.18s ease;
}

.switch input[type='checkbox']:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.switch input[type='checkbox']:checked::after {
  background: var(--on-accent);
  transform: translateX(18px);
}

.switch input[type='checkbox']:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.switch:has(input:disabled) {
  cursor: not-allowed;
  color: var(--muted);
}

/* ---------------------------------------------------------------------
   6. CARDS, ESTATISTICAS E TABELAS
   --------------------------------------------------------------------- */

.card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--hairline), transparent);
}

.card-head h2,
.card-head h3 {
  font-size: 1rem;
  font-weight: 700;
}

.card-body {
  padding: 18px;
}

.card-body > .divider:first-child {
  margin-top: 0;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.table {
  width: 100%;
  font-size: 0.9rem;
  text-align: left;
}

.table th,
.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table th {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  background: var(--surface-2);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover td {
  background: var(--surface-2);
}

/* Tabelas largas rolam dentro do proprio contêiner */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

.id-display {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--text);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
  user-select: all;
}

.metric-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.metric-row > * {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 10px;
  font-size: 0.78rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  white-space: nowrap;
}

.metric-row b,
.metric-row strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------
   7. BADGES E AVATAR
   --------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--muted-soft);
}

.badge::before {
  content: '';
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}

.badge-online {
  color: var(--ok);
  border-color: transparent;
  background: var(--ok-soft);
}

.badge-sharing {
  color: var(--accent);
  border-color: transparent;
  background: var(--accent-soft);
}

.badge-busy {
  color: var(--warn);
  border-color: transparent;
  background: var(--warn-soft);
}

.badge-offline {
  color: var(--muted);
  border-color: var(--border);
  background: transparent;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px;
  height: 40px;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  color: #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  user-select: none;
  overflow: hidden;
}

/* Ponto de transmissao ao vivo */
.live-dot {
  display: inline-block;
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  animation: vd-pulse 1.6s ease-out infinite;
}

@keyframes vd-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
    opacity: 1;
  }
  70% {
    box-shadow: 0 0 0 9px rgba(239, 68, 68, 0);
    opacity: 0.85;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    opacity: 1;
  }
}

/* ---------------------------------------------------------------------
   8. FEEDBACK — toast, modal, alert, spinner, skeleton
   --------------------------------------------------------------------- */

.toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  font-size: 0.9rem;
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: vd-toast-in 0.22s ease-out;
}

.toast-info,
.toast.info {
  border-left-color: var(--accent);
}

.toast-ok,
.toast.ok {
  border-left-color: var(--ok);
}

.toast-warn,
.toast.warn {
  border-left-color: var(--warn);
}

.toast-danger,
.toast.danger {
  border-left-color: var(--danger);
}

@keyframes vd-toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: vd-fade-in 0.18s ease-out;
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(84vh, 720px);
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: vd-modal-in 0.2s ease-out;
}

.modal-card h2,
.modal-card h3 {
  margin-bottom: 10px;
  font-size: 1.15rem;
}

.modal-card p {
  color: var(--muted);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

@keyframes vd-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes vd-modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  font-size: 0.89rem;
  line-height: 1.5;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.alert strong {
  font-weight: 700;
}

.alert-info {
  color: var(--text);
  border-color: rgba(79, 124, 255, 0.35);
  background: var(--accent-soft);
}

.alert-ok {
  border-color: rgba(34, 197, 94, 0.35);
  background: var(--ok-soft);
}

.alert-warn {
  border-color: rgba(245, 158, 11, 0.38);
  background: var(--warn-soft);
}

.alert-danger {
  border-color: rgba(239, 68, 68, 0.38);
  background: var(--danger-soft);
}

.spinner {
  display: inline-block;
  flex: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: vd-spin 0.7s linear infinite;
}

@keyframes vd-spin {
  to { transform: rotate(360deg); }
}

.skeleton {
  min-height: 14px;
  border-radius: var(--radius-sm);
  background-color: var(--surface-2);
  background-image: linear-gradient(
    90deg,
    transparent 0%,
    var(--hairline) 45%,
    var(--shimmer) 50%,
    var(--hairline) 55%,
    transparent 100%
  );
  background-size: 220% 100%;
  animation: vd-shimmer 1.3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes vd-shimmer {
  from { background-position: 130% 0; }
  to { background-position: -30% 0; }
}

/* ---------------------------------------------------------------------
   9. LAYOUT DO APP — shell, sidebar, topbar, listas, vazio
   --------------------------------------------------------------------- */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  height: 100dvh;
  padding: 18px 14px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.sidebar .brand:hover {
  color: var(--text);
  text-decoration: none;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 0.92rem;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.nav-item:hover {
  color: var(--text);
  text-decoration: none;
  background: var(--surface-2);
}

.nav-item.is-active,
.nav-item.active,
.nav-item[aria-current='page'] {
  color: var(--accent);
  border-color: rgba(79, 124, 255, 0.32);
  background: var(--accent-soft);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--header-h);
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.topbar .id-display {
  padding: 5px 12px;
  font-size: 1.02rem;
  letter-spacing: 0.14em;
}

/* Coluna de conteudo do app */
.app-content,
.app-shell > main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* Area util: use <div class="view"> (ou <main>/<section>) dentro da coluna */
.app-content > .view,
.app-content > main,
.app-shell > main > .view,
.app-shell > main > section {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--view-pad);
}

.app-content > .view,
.app-shell > main > .view {
  display: flex;
  flex-direction: column;
  gap: var(--view-gap);
}

.list-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.list-item + .list-item {
  margin-top: 10px;
}

.list-item:hover {
  border-color: var(--accent);
}

.list-item .avatar {
  width: 38px;
  height: 38px;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 18px;
  font-size: 0.9rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.tab {
  flex: 1 1 auto;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  border-radius: 7px;
  background: transparent;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.tab:hover {
  color: var(--text);
  text-decoration: none;
  background: var(--hairline);
}

.tab.is-active,
.tab.active,
.tab[aria-selected='true'] {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------------
   10. VIDEO — palco da transmissao
   --------------------------------------------------------------------- */

.video-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #000;
  box-shadow: var(--shadow-lg);
}

.video-shell video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* Faixa "ao vivo" no canto superior */
.video-shell .video-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  border-radius: 999px;
  background: rgba(9, 12, 20, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Estado de espera enquanto a conexao negocia */
.video-shell .video-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  color: #c9d3e8;
  background: radial-gradient(560px 320px at 50% 40%, rgba(79, 124, 255, 0.16), transparent 70%), #05070d;
}

/* Barra de controles: aparece no hover, no foco e em telas sem hover */
.video-shell .video-overlay {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px;
  opacity: 0;
  transform: translateY(8px);
  background: linear-gradient(0deg, rgba(4, 6, 12, 0.86), rgba(4, 6, 12, 0));
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.video-shell:hover .video-overlay,
.video-shell:focus-within .video-overlay,
.video-shell.is-idle .video-overlay {
  opacity: 1;
  transform: none;
}

.video-shell .video-overlay .btn {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(20, 26, 42, 0.72);
}

.video-shell .video-overlay .btn:hover {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(36, 46, 72, 0.86);
}

.video-shell .video-overlay .btn-danger {
  border-color: transparent;
  background: var(--danger);
}

.video-shell .video-overlay .metric-row > * {
  color: #cfd8ea;
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(12, 16, 26, 0.62);
}

.video-shell .video-overlay .metric-row b,
.video-shell .video-overlay .metric-row strong {
  color: #fff;
}

.video-shell input[type='range'] {
  width: 110px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Tela cheia ocupa toda a viewport */
.video-shell:fullscreen {
  width: 100vw;
  height: 100vh;
  max-height: none;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.video-shell:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
}

.video-shell:fullscreen video {
  height: 100vh;
}

/* Em dispositivos sem hover os controles ficam sempre visiveis */
@media (hover: none) {
  .video-shell .video-overlay {
    opacity: 1;
    transform: none;
  }
}

/* ---------------------------------------------------------------------
   11. LANDING E PAGINAS PUBLICAS
   --------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 20px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  min-height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.site-header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.brand:hover {
  color: var(--text);
  text-decoration: none;
}

.brand .live-dot {
  width: 10px;
  height: 10px;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(79, 124, 255, 0.5);
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 64px 0 48px;
  text-align: center;
}

.hero-title {
  max-width: 18ch;
  font-size: clamp(2rem, 6vw, 3.35rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.035em;
  color: var(--text);
}

/* Degrade no titulo apenas onde o recorte de texto e suportado */
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .hero-title {
    color: transparent;
    background-image: linear-gradient(180deg, var(--text), var(--muted));
    -webkit-background-clip: text;
    background-clip: text;
  }
}

.hero-sub {
  max-width: 62ch;
  font-size: clamp(1rem, 2.4vw, 1.15rem);
  line-height: 1.6;
  color: var(--muted);
}

.hero .row {
  justify-content: center;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  padding: 8px 0 40px;
  counter-reset: passo;
}

.step {
  position: relative;
  padding: 20px 20px 20px 62px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.step::before {
  counter-increment: passo;
  content: counter(passo);
  position: absolute;
  top: 20px;
  left: 20px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--on-accent);
  border-radius: 50%;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
}

.step h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.step p {
  font-size: 0.9rem;
  color: var(--muted);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  padding: 8px 0 56px;
}

.feature {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.feature:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.feature h3 {
  margin-bottom: 6px;
  font-size: 0.98rem;
}

.feature p {
  font-size: 0.89rem;
  color: var(--muted);
}

.site-footer {
  margin-top: auto;
  padding: 28px 0;
  font-size: 0.86rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.site-footer a {
  color: var(--muted);
}

.site-footer a:hover {
  color: var(--accent);
}

/* Conteudo longo de termos de uso e politica de privacidade */
article {
  padding: 28px 0 48px;
  max-width: 76ch;
}

article h1 {
  margin-bottom: 8px;
}

article h2 {
  margin: 30px 0 10px;
}

article h3 {
  margin: 20px 0 8px;
}

article p,
article ul,
article ol {
  color: var(--muted);
}

/* ---------------------------------------------------------------------
   12. AUTENTICACAO — login, cadastro, recuperacao
   --------------------------------------------------------------------- */

.auth-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 32px 20px;
}

.auth-card {
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.auth-card h1 {
  margin-bottom: 6px;
  font-size: 1.45rem;
}

.auth-card > p {
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.auth-logo:hover {
  color: var(--text);
  text-decoration: none;
}

.auth-logo::before {
  content: '';
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--accent), var(--accent-strong));
  box-shadow: 0 6px 16px rgba(79, 124, 255, 0.35);
}

.auth-card .btn-block {
  margin-top: 4px;
}

.auth-card .alert {
  margin-bottom: 16px;
}

/* ---------------------------------------------------------------------
   13. UTILITARIOS
   --------------------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.flex {
  display: flex;
}

.gap {
  gap: 12px;
}

.muted {
  color: var(--muted);
}

/* ---------------------------------------------------------------------
   14. RESPONSIVO — 900px (shell), 720px e 1080px
   --------------------------------------------------------------------- */

/* Sidebar vira barra horizontal fixa no rodape */
@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    height: auto;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    overflow: visible;
    border-top: 1px solid var(--border);
    border-right: 0;
    box-shadow: 0 -8px 24px rgba(2, 5, 12, 0.28);
  }

  .sidebar .brand {
    display: none;
  }

  .sidebar-nav {
    flex: 1;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
  }

  .nav-item {
    flex: 1 0 auto;
    justify-content: center;
    padding: 9px 12px;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .app-content,
  .app-shell > main {
    padding-bottom: 72px;
  }
}

/* Ajustes para telas pequenas */
@media (max-width: 720px) {
  body {
    font-size: 15.5px;
  }

  :root {
    --view-pad: 14px;
    --view-gap: 14px;
  }

  .container {
    padding: 0 16px;
  }

  .topbar {
    padding: 10px 14px;
  }

  .card-head,
  .card-body {
    padding: 14px;
  }

  .hero {
    padding: 40px 0 32px;
  }

  .id-display {
    font-size: 1.3rem;
    letter-spacing: 0.12em;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .modal {
    padding: 12px;
  }

  .modal-card {
    padding: 18px;
  }

  .modal-actions .btn {
    flex: 1 1 140px;
  }

  .toast-host {
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
    align-items: stretch;
  }

  .list-item {
    align-items: flex-start;
  }

  .table th,
  .table td {
    padding: 9px 10px;
  }
}

/* Telas medias/grandes: mais respiro */
@media (min-width: 720px) {
  :root {
    --view-pad: 24px;
    --view-gap: 18px;
  }

  .hero {
    padding: 84px 0 56px;
  }
}

/* Telas amplas: sidebar mais larga e conteudo maior */
@media (min-width: 1080px) {
  :root {
    --sidebar-w: 252px;
    --content-max: 1180px;
    --view-pad: 28px 32px;
    --view-gap: 20px;
  }

  .topbar {
    padding: 12px 32px;
  }
}

/* ---------------------------------------------------------------------
   15. MOVIMENTO REDUZIDO
   --------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  /* O ponto ao vivo fica estatico, sem pulsar */
  .live-dot {
    animation: none !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.22) !important;
  }

  .skeleton {
    animation: none !important;
    background-image: none;
  }

  /* O giro do spinner e essencial: mantido, porem mais lento */
  .spinner {
    animation: vd-spin 1.6s linear infinite !important;
  }
}

/* ------------------------------------------------------------------ */
/* Complementos: classes usadas pelo admin e pelo ui.js                */
/* ------------------------------------------------------------------ */

/* Grade de indicadores do painel de administração. */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

/* Coluna de conteúdo do admin (equivalente a .app-content). */
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.modal-title {
  margin: 0 0 10px;
  font-size: 1.15rem;
  font-weight: 650;
  color: var(--text);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--muted);
}

.modal-danger .modal-card {
  border-color: var(--danger);
}
