/* ==========================================================================
   REMOTO PRO DESIGN SYSTEM (Modern Sleek Slate / Linear-Inspired Aesthetic)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  color-scheme: dark;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Palette */
  --bg-base: #070a10;
  --bg-sidebar: #0b0f17;
  --bg-surface: #101622;
  --bg-surface-elevated: #161e2e;
  --bg-surface-hover: #1c263a;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-active: rgba(56, 189, 248, 0.4);

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --primary: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.25);
  --primary-hover: #7dd3fc;
  --primary-dark: #0284c7;

  --success: #34d399;
  --success-glow: rgba(52, 211, 153, 0.25);
  --warning: #fbbf24;
  --danger: #f87171;
  --danger-glow: rgba(248, 113, 113, 0.25);

  --sidebar-w: 240px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

/* Scrollbar Personalizada */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Ícones SVG */
.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.icon-library {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  background: var(--primary);
  color: #000;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  z-index: 999;
  transform: translateY(-200%);
  transition: transform 0.2s;
}
.skip-link:focus {
  transform: translateY(0);
}

/* ==========================================================================
   ESTRUTURA GERAL (LAYOUT)
   ========================================================================== */

.layout-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  padding: 20px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: grid;
  place-items: center;
  color: #050a12;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.brand-mark svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
}
.brand-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.brand-dot {
  color: var(--primary);
}
.brand-subtitle {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 700;
}

.navigation {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 24px;
}
.nav-section-title {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 1px;
  padding: 4px 12px 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  position: relative;
}
.nav-link:hover {
  background: var(--bg-surface);
  color: var(--text-main);
}
.nav-link.active {
  background: var(--bg-surface-elevated);
  border-color: var(--border-medium);
  color: var(--primary);
}
.nav-active-pill {
  position: absolute;
  right: 10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
}

.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.button-sidebar-settings {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.button-sidebar-settings:hover {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-medium);
}

.operator-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1e293b;
  border: 1px solid var(--border-medium);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 11px;
  color: var(--primary);
}
.operator-info {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.operator-info strong {
  font-size: 12px;
  color: var(--text-main);
}
.operator-tag {
  font-size: 10px;
  color: var(--success);
}

/* Área de Trabalho (Main Wrapper) */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.topbar {
  height: 60px;
  padding: 0 28px;
  background: rgba(11, 15, 23, 0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.session-status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.device-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}
.device-pill .icon {
  width: 14px;
  height: 14px;
  color: var(--primary);
}

.session-timer-box {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
}
.session-timer-box .icon {
  width: 14px;
  height: 14px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.15s;
}
.icon-button:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border-color: var(--border-medium);
}

/* Banner de Conexão Rápida */
.connect-banner {
  margin: 18px 28px 0;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(22, 30, 46, 0.9), rgba(11, 15, 23, 0.9));
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.connect-banner-info {
  display: flex;
  align-items: center;
  gap: 14px;
}
.connect-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--primary-glow);
  color: var(--primary);
  display: grid;
  place-items: center;
}
.connect-banner-info h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
.connect-banner-info p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.connection-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.code-input-wrap input {
  height: 44px;
  width: 160px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 3px;
  background: var(--bg-base);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-main);
  outline: none;
  transition: all 0.2s;
}
.code-input-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Botões */
.button {
  height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.button-primary {
  background: var(--primary);
  color: #030812;
  box-shadow: 0 2px 10px var(--primary-glow);
}
.button-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 4px 16px var(--primary-glow);
}
.button-secondary {
  background: var(--bg-surface-elevated);
  border-color: var(--border-medium);
  color: var(--text-main);
}
.button-secondary:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.2);
}
.button-small {
  height: 32px;
  padding: 0 12px;
  font-size: 11px;
  border-radius: var(--radius-sm);
}
.button-full {
  width: 100%;
}
.button-end {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  width: 100%;
}
.button-end:hover:not(:disabled) {
  background: var(--danger);
  color: #000;
}
.stop-icon {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
}

/* Barra de Status */
.status-strip {
  padding: 10px 28px;
}
.status-strip-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 12px;
}
.status-strip-inner .icon {
  color: var(--primary);
  width: 16px;
  height: 16px;
}

/* Área Central de Conteúdo e Abas */
.workspace-area {
  padding: 0 28px 28px;
  flex: 1;
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Painel Padrão */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.panel-title h2, .panel-title h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.panel-title .icon {
  color: var(--primary);
}

/* ==========================================================================
   ABA 1: TELA & CONTROLE REMOTO (DIMENSÕES TRAVADAS E ESTÁVEIS)
   ========================================================================== */

.remote-viewport-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
}

/* Screen Panel */
.screen-panel {
  display: flex;
  flex-direction: column;
}

.screen-controls-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-status-subtle {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 3px 8px;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-sm);
}

.stream-toolbar {
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: rgba(0, 0, 0, 0.2);
}
.quality-select-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.quality-select-group select,
#video-quality {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 6px 10px;
  font-size: 12px;
  outline: none;
}
.toolbar-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
}

.stream-telemetry {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 18px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}
.telemetry-item span {
  color: var(--text-dim);
  margin-right: 4px;
}
.telemetry-item strong {
  color: var(--primary);
  font-family: var(--font-mono);
}
.telemetry-item.align-right {
  margin-left: auto;
}

/* PALCO DO CANVAS FIXO (NUNCA ALTERA DE TAMANHO COM FRAMES DIFERENTES) */
.screen-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 580px;
  min-height: 320px;
  background: #04060a;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 20px 20px;
}

#screen {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain;
  opacity: 0;
  cursor: crosshair;
  margin: auto;
}

body[data-state="active"] #screen {
  opacity: 1;
}

.screen-empty {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
  background: rgba(4, 6, 10, 0.85);
}
.empty-screen-graphic {
  position: relative;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  display: grid;
  place-items: center;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.empty-screen-graphic .icon {
  width: 32px;
  height: 32px;
}
.pulse-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px dashed var(--primary-glow);
  animation: rotateSlow 20s linear infinite;
}
@keyframes rotateSlow {
  to { transform: rotate(360deg); }
}

.screen-empty h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}
.screen-empty p {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  max-width: 380px;
}
.empty-caption {
  margin-top: 18px;
  font-size: 10px;
  letter-spacing: 1.5px;
  font-weight: 700;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.screen-footer {
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-muted);
}
.gesture-status {
  display: flex;
  align-items: center;
  gap: 8px;
}
.gesture-status .icon {
  width: 14px;
  height: 14px;
  color: var(--text-dim);
}
.resolution-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.resolution-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

.stream-details-accordion {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
}
.stream-details-accordion summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
}
.stream-stages {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 12px 0;
}
.stage-metric {
  padding: 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stage-metric span {
  font-size: 10px;
  color: var(--text-dim);
}
.stage-metric strong {
  font-size: 16px;
  color: var(--text-main);
  font-family: var(--font-mono);
}
.stream-notes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  color: var(--text-muted);
  font-size: 11px;
}

/* Modo Tela Cheia com Enquadramento Impecável */
.screen-stage:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  aspect-ratio: auto !important;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.screen-stage:fullscreen #screen {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}

/* Controle Remoto (Hardware Mockup) */
.remote-hardware-shell {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.remote-instruction {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 16px;
}

.dpad-container {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: linear-gradient(145deg, #182234, #0f1624);
  border: 2px solid var(--border-medium);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), inset 0 2px 4px rgba(255, 255, 255, 0.1);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  position: relative;
  padding: 6px;
  margin-bottom: 20px;
}

.dpad-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.dpad-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}
.dpad-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.dpad-up { grid-area: 1 / 2; }
.dpad-up .icon { transform: rotate(180deg); }
.dpad-left { grid-area: 2 / 1; }
.dpad-left .icon { transform: rotate(90deg); }
.dpad-right { grid-area: 2 / 3; }
.dpad-right .icon { transform: rotate(-90deg); }
.dpad-down { grid-area: 3 / 2; }

.dpad-center {
  grid-area: 2 / 2;
  border-radius: 50%;
  background: linear-gradient(145deg, #233148, #182335);
  border: 1px solid var(--border-medium);
  color: var(--primary);
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}
.dpad-center:hover:not(:disabled) {
  background: var(--primary);
  color: #000;
}

.system-nav-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-bottom: 14px;
}
.button-nav-hardware {
  flex: 1;
  height: 40px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.button-nav-hardware:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.2);
}
.button-nav-hardware:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.remote-footer-action {
  width: 100%;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   ABA 2: APLICATIVOS
   ========================================================================== */

.apps-management-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}

.apps-toolbar {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.search-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 38px;
}
.search-field .icon {
  color: var(--text-dim);
}
.search-field input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 12px;
}

.apps-filter-options {
  display: flex;
  gap: 8px;
}
.apps-filter-options select {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 0 10px;
  height: 38px;
  font-size: 12px;
  outline: none;
}

.apps-status-note {
  margin: 10px 18px 0;
  font-size: 11px;
  color: var(--text-muted);
}

.app-list-container {
  padding: 10px 18px;
  max-height: 580px;
  overflow-y: auto;
}

.app-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.app-row:last-child {
  border-bottom: none;
}
.app-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: #1a2232;
  flex-shrink: 0;
}
.app-meta {
  flex: 1;
  min-width: 0;
}
.app-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-pkg {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-storage {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.app-storage strong {
  color: var(--primary);
}

.app-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.app-act {
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.app-act:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}
.app-uninstall {
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--danger);
}
.app-uninstall:hover:not(:disabled) {
  background: var(--danger);
  color: #000;
}

.apps-empty {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.apps-empty .icon {
  width: 32px;
  height: 32px;
  color: var(--text-dim);
}

.apps-sidebar-tools {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.tool-card-body {
  padding: 16px;
  font-size: 12px;
  color: var(--text-muted);
}
.install-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.install-form label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-main);
}
.install-form input {
  height: 40px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0 12px;
  color: var(--text-main);
  font-size: 12px;
  outline: none;
}
.install-form input:focus {
  border-color: var(--primary);
}

.tool-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0 10px;
}
.subtle-status {
  font-size: 11px;
  color: var(--text-dim);
  margin: 0;
}
.highlight-info {
  font-size: 11px;
  color: var(--primary);
  margin: 4px 0 0;
  font-family: var(--font-mono);
}

/* ==========================================================================
   ABA 3: ARQUIVOS
   ========================================================================== */

.files-content {
  padding: 18px;
}

.path-prefix {
  color: var(--text-dim);
  margin-right: 6px;
}
.files-path {
  color: var(--primary);
  font-family: var(--font-mono);
}

.files-filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  flex-wrap: wrap;
}
.files-search-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 38px;
}
.files-search-field input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 12px;
}
.files-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.files-filter-group select {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0 10px;
  height: 38px;
  color: var(--text-main);
  font-size: 12px;
  outline: none;
}
.files-checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

.files-selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid var(--primary);
  margin-bottom: 14px;
}
.files-selection-bar strong {
  color: var(--primary);
}
.files-selection-actions {
  display: flex;
  gap: 8px;
}

.files-feedback {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 14px;
}
.files-feedback-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.files-list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.files-text-button {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.files-text-button:hover:not(:disabled) {
  text-decoration: underline;
}

.files-folders-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.files-table-container {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.files-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12px;
}
.files-table th {
  background: var(--bg-surface-elevated);
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
}
.files-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.files-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}
.th-check { width: 36px; }
.th-size { width: 120px; text-align: right; }
.th-actions { width: 110px; text-align: right; }

.files-table td:nth-child(3) {
  text-align: right;
  font-family: var(--font-mono);
  color: var(--text-muted);
}
.files-table td:nth-child(4) {
  text-align: right;
}

.file-menu summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
}
.file-menu summary:hover {
  color: var(--text-main);
}
.file-menu-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 6px;
}

.files-empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.files-empty-state .icon {
  width: 32px;
  height: 32px;
  color: var(--text-dim);
}

.files-pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.files-help-accordion {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-dim);
}

/* ==========================================================================
   ABA 3: ARQUIVOS
   ========================================================================== */

.files-content {
  padding: 18px;
}

.files-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.files-nav-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

/* Padroniza a altura e alinhamento dos botões das barras */
.files-header-actions .button,
.files-nav-bar .button {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Caixa do caminho (breadcrumb) alinhada e nivelada com os botões */
.files-breadcrumb-box {
  flex: 1;
  min-width: 0;
  height: 34px;
  display: flex;
  align-items: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0 14px;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.path-prefix {
  color: var(--text-dim);
  margin-right: 6px;
}

.files-path {
  color: var(--primary);
  font-family: var(--font-mono);
}

.files-filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.files-search-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 38px;
}

.files-search-field input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 12px;
}

.files-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.files-filter-group select {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0 10px;
  height: 38px;
  color: var(--text-main);
  font-size: 12px;
  outline: none;
}

.files-checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

.files-selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid var(--primary);
  margin-bottom: 14px;
}

.files-selection-bar strong {
  color: var(--primary);
}

.files-selection-actions {
  display: flex;
  gap: 8px;
}

.files-feedback {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 14px;
}

.files-feedback-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.files-list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.files-text-button {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.files-text-button:hover:not(:disabled) {
  text-decoration: underline;
}

.files-folders-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.files-table-container {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.files-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12px;
}

.files-table th {
  background: var(--bg-surface-elevated);
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
}

.files-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.files-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.th-check { width: 36px; }
.th-size { width: 120px; text-align: right; }
.th-actions { width: 110px; text-align: right; }

.files-table td:nth-child(3) {
  text-align: right;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.files-table td:nth-child(4) {
  text-align: right;
}

.file-menu summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
}

.file-menu summary:hover {
  color: var(--text-main);
}

.file-menu-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 6px;
}

.files-empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.files-empty-state .icon {
  width: 32px;
  height: 32px;
  color: var(--text-dim);
}

.files-pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.files-help-accordion {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-dim);
}

/* ==========================================================================
   ABA 4: DIAGNÓSTICO & BENTO GRID
   ========================================================================== */

.diagnostics-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.diagnostics-header-row h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}
.diagnostics-header-row p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.device-bento-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

.bento-card {
  padding: 18px;
}
.bento-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.bento-card-title h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}
.bento-card-title .icon {
  color: var(--primary);
}

.data-pairs {
  margin: 0;
  display: grid;
  gap: 8px;
}
.data-pairs > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.data-pairs dt {
  color: var(--text-dim);
  font-size: 12px;
}
.data-pairs dd {
  margin: 0;
  color: var(--text-main);
  font-weight: 600;
  font-size: 12px;
  font-family: var(--font-mono);
}

.hardware-gauge-row {
  margin-bottom: 16px;
}
.gauge-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 6px;
}
.gauge-header strong {
  font-family: var(--font-mono);
  color: var(--primary);
}
.hardware-gauge-row progress {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  border: none;
  background: var(--bg-surface-elevated);
}
.hardware-gauge-row progress::-webkit-progress-bar {
  background: var(--bg-surface-elevated);
  border-radius: 4px;
}
.hardware-gauge-row progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 4px;
}
.gauge-sub {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

.cores-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 14px;
}

.memory-actions {
  display: flex;
  gap: 10px;
}
.memory-actions button {
  flex: 1;
}

.diag-result-tag, .ram-result-tag {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
}
.ram-result-tag {
  color: var(--primary);
}

.network-action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.network-details-accordion {
  margin-top: 14px;
  font-size: 12px;
}
.network-details-accordion summary {
  cursor: pointer;
  color: var(--primary);
}
.nested-pairs {
  margin-top: 10px;
}

/* Tabela de Consumo em Tempo Real */
.resources-panel-full {
  margin-top: 20px;
}
.resources-content {
  padding: 18px;
}
.resources-filters-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 14px 0;
}
.badge-count {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
}
.resources-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  max-height: 400px;
}
.resources-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.resources-table th {
  background: var(--bg-surface-elevated);
  padding: 10px 14px;
  color: var(--text-muted);
}
.resources-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.resources-table .text-right {
  text-align: right;
  font-family: var(--font-mono);
}

/* ==========================================================================
   ABA 5: OPERAÇÕES (FEED)
   ========================================================================== */

.operations-panel-full {
  min-height: 500px;
}
.operations-intro {
  padding: 14px 18px;
  color: var(--text-muted);
  font-size: 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin: 0;
}
.operations-feed {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.operation-row {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.operation-heading {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 13px;
}
.operation-state {
  font-size: 11px;
  color: var(--primary);
}
.operation-row[data-status="done"] .operation-state { color: var(--success); }
.operation-row[data-status="failed"] .operation-state { color: var(--danger); }
.operation-detail {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==========================================================================
   RODAPÉ E MODAL
   ========================================================================== */

.app-footer {
  margin-top: auto;
  padding: 20px 28px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
  font-size: 11px;
}

dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  color: var(--text-main);
  padding: 24px;
  width: min(440px, calc(100vw - 32px));
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}
.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.dialog-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dialog-title-group h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.dialog-description {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.settings-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.settings-field input {
  height: 40px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0 12px;
  color: var(--text-main);
  font-size: 12px;
  outline: none;
}
.settings-field input:focus {
  border-color: var(--primary);
}
.settings-notice {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.02);
  padding: 10px;
  border-radius: var(--radius-sm);
  margin: 16px 0;
}

/* ==========================================================================
   RESPONSIVIDADE
   ========================================================================== */

@media (max-width: 1200px) {
  .remote-viewport-grid {
    grid-template-columns: 1fr;
  }
  .device-bento-grid {
    grid-template-columns: 1fr;
  }
  .apps-management-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  :root {
    --sidebar-w: 68px;
  }
  .brand-text, .nav-link span, .nav-section-title, .operator-info, .button-sidebar-settings span {
    display: none;
  }
  .nav-link {
    justify-content: center;
    padding: 12px 0;
  }
  .operator-profile {
    justify-content: center;
    padding: 6px;
  }
  .topbar {
    padding: 0 16px;
  }
  .connect-banner {
    flex-direction: column;
    align-items: stretch;
    margin: 14px 16px 0;
  }
  .connection-form {
    flex-direction: column;
  }
  .code-input-wrap input {
    width: 100%;
  }
  .workspace-area {
    padding: 0 16px 16px;
  }
}

/* Oculta o banner de conexão quando a sessão estiver ativa */
body[data-state="active"] .connect-banner {
  display: none;
}

/* ==========================================================================
   MINIATURA FLUTUANTE ARRASTÁVEL & PÍLULA (PiP PRO)
   ========================================================================== */

body.screen-pip #view-remote {
  display: block !important;
}

body.screen-pip .remote-viewport-grid {
  display: block !important;
}

body.screen-pip .remote-viewport-grid > *:not(.screen-panel) {
  display: none !important;
}

/* Painel da miniatura flutuante */
body.screen-pip .screen-panel {
  position: fixed !important;
  bottom: 24px;
  right: 24px;
  width: var(--pip-width, 480px) !important;
  max-width: calc(100vw - 32px);
  z-index: 1000 !important;
  background: #000 !important;
  border: 2px solid var(--primary) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.8), 0 0 16px var(--primary-glow) !important;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  animation: pipSlideIn 0.25s ease-out;
}

/* Barra de título e botões da miniatura */
.pip-floating-bar {
  display: none;
}

body.screen-pip .pip-floating-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(11, 15, 23, 0.96);
  border-bottom: 1px solid var(--border-medium);
  font-size: 11px;
  font-weight: 700;
  cursor: grab;
}

body.screen-pip .pip-floating-bar:active {
  cursor: grabbing;
}

.pip-drag-handle {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
}

.pip-actions {
  display: flex;
  gap: 4px;
}

.pip-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  transition: all 0.15s;
}

.pip-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
}

/* Oculta os itens normais da tela de controle */
body.screen-pip .screen-panel .panel-header,
body.screen-pip .screen-panel .stream-toolbar,
body.screen-pip .screen-panel .stream-telemetry,
body.screen-pip .screen-panel .screen-footer,
body.screen-pip .screen-panel .stream-details-accordion {
  display: none !important;
}

body.screen-pip .screen-stage {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: 16 / 9 !important;
  border-radius: 0 !important;
  cursor: grab;
}

body.screen-pip #screen {
  pointer-events: none; /* Permite arrastar clicando direto sobre o vídeo */
}

/* Pílula recolhida */
.pip-pill {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 10px var(--primary-glow);
  border-radius: 30px;
  padding: 8px 16px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  animation: pipSlideIn 0.2s ease-out;
  transition: transform 0.15s, box-shadow 0.15s;
}

.pip-pill:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.8), 0 0 16px var(--primary-glow);
}

.live-dot {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

.pip-pill .icon {
  width: 14px;
  height: 14px;
  color: var(--primary);
}

/* Quando estiver recolhido em pílula */
body.screen-pip-minimized .screen-panel {
  display: none !important;
}

@keyframes pipSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==========================================================================
   TOQUE, ESTADOS DE OPERAÇÃO E CELULAR
   ========================================================================== */

/* Sem isto, no celular o dedo rola a página em vez de tocar na TV, o navegador
   cancela o gesto no meio e segurar abre o menu de salvar imagem. */
#screen {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Marcador da aba ativa: acompanha a aba em vez de ficar preso em "Tela & Controle". */
.nav-active-pill {
  display: none;
}
.nav-link.active::after {
  content: "";
  position: absolute;
  right: 10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
}

/* Ação de app em andamento: spinner no botão até a resposta do aparelho. */
.app-act.is-running {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 1;
  border-color: var(--primary);
  color: var(--primary);
}
.op-spin {
  width: 10px;
  height: 10px;
  border: 2px solid rgba(56, 189, 248, 0.3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: op-spin 0.7s linear infinite;
  flex: 0 0 auto;
}
@keyframes op-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .op-spin { animation-duration: 2s; }
}

.apps-empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
}

/* Celular: a barra lateral vira uma barra de abas no rodapé e o conteúdo usa a largura toda. */
@media (max-width: 640px) {
  :root {
    --sidebar-w: 0px;
    --bottom-nav-h: 58px;
  }
  body {
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  }
  .main-wrapper {
    margin-left: 0;
  }
  .sidebar {
    inset: auto 0 0 0;
    width: auto;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    flex-direction: row;
    align-items: stretch;
    gap: 2px;
    padding: 4px max(6px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(6px, env(safe-area-inset-left, 0px));
    border-right: 0;
    border-top: 1px solid var(--border-subtle);
  }
  .brand,
  .nav-section-title,
  .operator-profile {
    display: none;
  }
  .navigation {
    flex: 1;
    flex-direction: row;
    gap: 2px;
    margin-top: 0;
  }
  .nav-link,
  .button-sidebar-settings {
    flex: 1;
    min-width: 0;
    justify-content: center;
    padding: 0;
    border: 0;
  }
  .nav-link.active::after {
    right: auto;
    top: 4px;
  }
  .sidebar-bottom {
    margin-top: 0;
    flex: 0 0 52px;
    flex-direction: row;
  }
  .nav-link .icon,
  .button-sidebar-settings .icon {
    width: 22px;
    height: 22px;
  }

  .topbar {
    height: auto;
    min-height: 52px;
    padding: max(8px, env(safe-area-inset-top, 0px)) 16px 8px;
    gap: 8px;
  }
  .topbar-left {
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
    gap: 6px;
  }
  .device-pill {
    min-width: 0;
    max-width: 100%;
  }
  #session-device {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .connect-banner {
    margin: 12px 16px 0;
  }
  .status-strip {
    padding: 10px 16px;
  }
  .workspace-area {
    padding: 0 16px 16px;
  }
  .stream-toolbar {
    padding: 10px 12px;
  }
  .quality-select-group {
    flex: 1 1 100%;
    min-width: 0;
  }
  .quality-select-group select {
    flex: 1;
    min-width: 0;
    width: 100%;
  }
  .screen-stage {
    min-height: 0;
    max-height: none;
  }

  /* Miniatura menor e acima da barra de abas, com botões do tamanho do dedo. */
  body.screen-pip .screen-panel {
    width: min(62vw, 300px) !important;
    right: 12px;
    bottom: calc(var(--bottom-nav-h) + 12px + env(safe-area-inset-bottom, 0px));
  }
  .pip-pill {
    right: 12px;
    bottom: calc(var(--bottom-nav-h) + 12px + env(safe-area-inset-bottom, 0px));
  }
  .pip-btn {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  /* iPhone amplia a página ao focar campos com fonte menor que 16 px. */
  input:not(#code),
  select,
  textarea {
    font-size: 16px;
  }
}

/* Linhas de cabeçalho e ferramentas quebram em vez de passar da borda do painel. */
.panel-header,
.apps-toolbar,
.files-nav-bar {
  flex-wrap: wrap;
}
.panel-title,
.files-breadcrumb-box {
  min-width: 0;
}
.files-path {
  overflow-wrap: anywhere;
}
@media (max-width: 640px) {
  .apps-toolbar .search-field,
  .apps-filter-options,
  .files-breadcrumb-box {
    flex: 1 1 100%;
    min-width: 0;
  }
  .apps-filter-options select {
    flex: 1;
    min-width: 0;
  }
}

/* Tablet: miniatura menor para não cobrir o conteúdo da aba. */
@media (min-width: 641px) and (max-width: 1024px) {
  body.screen-pip .screen-panel {
    width: var(--pip-width, 360px) !important;
  }
}

/* ==========================================================================
   STATUS NO TOPO E BARRA ÚNICA DA TRANSMISSÃO
   ========================================================================== */

/* Último comando enviado ou resposta recebida, ao lado do relógio. */
.topbar-right {
  min-width: 0;
  flex: 1;
  justify-content: flex-end;
}
.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: min(560px, 100%);
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 12px;
}
.topbar-status .icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  color: var(--primary);
}
#status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Qualidade e modo estável à esquerda; modo, taxa e situação à direita. */
.stream-toolbar .toolbar-hint {
  margin-left: 0;
}
.stream-summary {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 11px;
  color: var(--text-dim);
}
.stream-summary strong {
  color: var(--primary);
  font-family: var(--font-mono);
  font-weight: 600;
  white-space: nowrap;
}
#stream-status {
  white-space: nowrap;
}

@media (max-width: 640px) {
  /* Status e relógio descem para uma linha própria, sem sobrepor os indicadores. */
  .topbar {
    flex-wrap: wrap;
  }
  .topbar-right {
    flex: 1 1 100%;
  }
  .topbar-status {
    flex: 1;
    max-width: none;
  }
  .stream-toolbar #video-quality {
    flex: 1 1 100%;
    min-width: 0;
  }
  /* Resumo em linha própria, dividida só com o botão de tela cheia (34 px + 12 px de espaço). */
  .stream-summary {
    flex: 1 1 calc(100% - 46px);
    min-width: 0;
    margin-left: 0;
    flex-wrap: wrap;
  }
}

/* Em telas largas a barra fica numa linha: o aviso de qualidade encolhe com "…".
   Em telas menores o resumo desce para uma segunda linha, sem cortes. */
@media (min-width: 1400px) {
  .stream-toolbar {
    flex-wrap: nowrap;
  }
  .stream-toolbar .toolbar-hint {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .stream-toolbar > select,
  .stream-toolbar > button {
    flex-shrink: 0;
  }
  .stream-summary {
    flex: 0 1 auto;
    overflow: hidden;
  }
  #stream-status {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ==========================================================================
   BARRAS DE PROGRESSO E TABELA DE ARQUIVOS
   ========================================================================== */

/* Barras de carregamento (arquivos, consumo, feed de operações) com a cara do painel.
   Sem valor, a barra fica "indeterminada" e mostra um trecho correndo. */
progress {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 6px;
  margin: 8px 0 12px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-surface-elevated);
  color: var(--primary);
}
progress[hidden] {
  display: none;
}
progress::-webkit-progress-bar {
  background: var(--bg-surface-elevated);
  border-radius: 999px;
}
progress::-webkit-progress-value {
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.2s ease;
}
progress::-moz-progress-bar {
  background: var(--primary);
  border-radius: 999px;
}
progress:indeterminate {
  background: linear-gradient(90deg, transparent 0%, var(--primary) 50%, transparent 100%) var(--bg-surface-elevated);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: progress-indeterminate 1.2s ease-in-out infinite;
}
progress:indeterminate::-webkit-progress-bar {
  background: transparent;
}
progress:indeterminate::-moz-progress-bar {
  background: transparent;
}
@keyframes progress-indeterminate {
  from { background-position: -40% 0; }
  to { background-position: 140% 0; }
}
@media (prefers-reduced-motion: reduce) {
  progress:indeterminate { animation-duration: 3s; }
}

/* Linhas da tabela de arquivos alinhadas ao centro. */
.files-table td {
  vertical-align: middle;
}
.file-selection input {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* "Opções" abre os botões lado a lado, alinhados à direita. */
.file-menu summary {
  padding: 4px 0;
}
.file-menu-items {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.file-menu-items .button {
  margin: 0;
}

/* Celular: cada arquivo vira um cartão (nome e tamanho à esquerda, opções à direita). */
@media (max-width: 640px) {
  .files-table thead {
    display: none;
  }
  .files-table,
  .files-table tbody {
    display: block;
  }
  .files-table tr {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    gap: 2px 10px;
    align-items: center;
    padding: 12px 0;
    border-top: 1px solid var(--border-subtle);
  }
  .files-table td {
    border: 0;
    padding: 0;
    min-width: 0;
    text-align: left;
  }
  .files-table .file-selection {
    grid-column: 1;
    grid-row: 1 / 3;
  }
  .files-table td:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
    overflow-wrap: anywhere;
  }
  .files-table td:nth-child(2) .button {
    max-width: 100%;
    text-align: left;
    white-space: normal;
  }
  .files-table td:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
    font-size: 11px;
  }
  .files-table .file-actions {
    grid-column: 3;
    grid-row: 1 / 3;
    text-align: right;
  }
  .file-menu-items {
    flex-direction: column;
    align-items: stretch;
  }
}
/* Barras de RAM e armazenamento mantêm o espaçamento original. */
.hardware-gauge-row progress {
  margin: 0;
}

/* A coluna "Ações" tinha 110 px fixos: os botões não cabiam lado a lado. */
@media (min-width: 641px) {
  .th-actions {
    width: 240px;
  }
  .file-menu-items {
    flex-wrap: nowrap;
  }
  .file-menu-items .button {
    white-space: nowrap;
  }
}

/* Computador e tablet: os botões de arquivo ficam abertos e o "Opções" some. */
@media (min-width: 641px) {
  .file-menu summary {
    display: none;
  }
  .file-menu-items {
    padding-top: 0;
  }
}

/* ==========================================================================
   CONSUMO DOS APLICATIVOS (PROCESSOS)
   ========================================================================== */

#resources-status {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}
.resources-warning-note {
  margin: 0 0 10px;
  font-size: 11px;
  color: var(--warning, #fbbf24);
}
.resources-warning-note:empty {
  display: none;
}

/* Busca ocupa o espaço livre; filtros com o mesmo visual dos outros seletores. */
.resources-filters-bar {
  flex-wrap: wrap;
}
.resources-filters-bar .search-field {
  flex: 1 1 260px;
  min-width: 0;
}
.select-group {
  display: flex;
  gap: 8px;
}
.select-group select {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 7px 10px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}
.select-group select:focus-visible {
  border-color: var(--primary);
}

/* Cabeçalho alinhado com as colunas e fixo ao rolar a lista. */
.resources-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-subtle);
}
.resources-table th.text-right {
  text-align: right;
  font-family: inherit;
}
.resources-table th:not(:first-child),
.resources-table td:not(:first-child) {
  width: 130px;
  text-align: right;
}
.resources-table td {
  vertical-align: middle;
}
.resources-table td:not(:first-child) {
  font-family: var(--font-mono);
  color: var(--text-main);
  white-space: nowrap;
}
.resources-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Nome do app numa linha, pacote e número de processos embaixo. */
.resources-table td:first-child strong {
  display: block;
  color: var(--text-main);
  font-weight: 600;
}
.resources-table td:first-child small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

.table-empty-note {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* "Como funcionam estas medições" no mesmo estilo discreto do painel. */
.resources-help {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
}
.resources-help summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}
.resources-help summary:hover {
  color: var(--text-main);
}
.resources-help p {
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-dim);
}
.resources-help p:empty {
  display: none;
}

@media (max-width: 640px) {
  .select-group {
    flex: 1 1 100%;
  }
  .select-group select {
    flex: 1;
    min-width: 0;
  }
  .resources-table th:not(:first-child),
  .resources-table td:not(:first-child) {
    width: auto;
    padding-left: 6px;
    padding-right: 10px;
  }
}

/* ==========================================================================
   REDE & HORÁRIO MAIS LEVE
   ========================================================================== */

/* Valores sem negrito e quebrando linha (IPs e DNS longos não são mais cortados). */
.data-pairs > div {
  gap: 16px;
}
.data-pairs dt {
  flex: 0 0 auto;
}
.data-pairs dd {
  min-width: 0;
  font-weight: 500;
  text-align: right;
  overflow-wrap: anywhere;
}

/* Os dois botões lado a lado, em vez de duas faixas de largura inteira. */
.network-action-buttons {
  flex-direction: row;
  flex-wrap: wrap;
}
.network-action-buttons .button {
  flex: 1 1 160px;
  width: auto;
}

.diag-result-tag:empty {
  display: none;
}

.network-details-accordion summary {
  font-weight: 600;
}

/* O resultado substitui o rótulo do botão, ao lado do ajuste de horário. */
.network-action-buttons { flex-wrap: nowrap; gap: 8px; }
.network-action-buttons .button {
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
  font-family: var(--font-sans);
}
.speed-test-result {
  font-size: 10px;
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 600px) {
  .network-action-buttons .button { padding: 7px 4px; font-size: 10px; }
  #test-conn, #test-conn .speed-test-result { font-size: 9px; }
}

/* Conexão e identificação do aparelho compartilham o mesmo espaço no topo. */
.topbar { height:auto;min-height:72px;padding:12px 28px;gap:20px; }
.topbar-left { flex:1 1 auto;min-width:0; }
.topbar-right { flex:0 1 32%; }
.topbar .connect-banner {
  flex:1;min-width:0;margin:0;padding:0;gap:16px;
  border:0;border-radius:0;background:none;box-shadow:none;
  flex-direction:row;align-items:center;
}
.topbar .connect-banner-info { flex:1;min-width:0;gap:10px; }
.topbar .connect-banner-info>div { min-width:0; }
.topbar .connect-banner-info h3 { font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.topbar .connect-banner-info p { font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.topbar .connect-icon { width:34px;height:34px;flex:0 0 34px; }
.topbar .connection-form { flex:0 0 auto;flex-direction:row;gap:8px; }
.topbar .code-input-wrap input { width:132px;height:38px;font-size:18px; }
.topbar .connection-form .button { height:38px;padding:0 12px; }
.session-summary { display:none;align-items:center;gap:10px;min-width:0;max-width:100%; }
.session-summary .session-status-badge { flex-shrink:0; }
.session-summary .device-pill { min-width:0; }
.session-summary #session-device { overflow:hidden;text-overflow:ellipsis;white-space:nowrap; }
body[data-state="active"] .topbar .connect-banner,
body[data-state="waiting"] .topbar .connect-banner { display:none; }
body[data-state="active"] .session-summary,
body[data-state="waiting"] .session-summary { display:flex; }
body[data-state="active"] .session-status-badge { color:var(--primary);border-color:rgba(56,189,248,.3); }
body[data-state="active"] #session-indicator { background:var(--primary);box-shadow:0 0 8px var(--primary-glow); }
.workspace-area { padding-top:20px; }
@media(max-width:1280px) {
  .topbar .connect-banner-info p { display:none; }
}
@media(max-width:820px) {
  .topbar { padding:10px 16px;gap:12px; }
}
@media(max-width:640px) {
  .topbar { padding:max(10px,env(safe-area-inset-top,0px)) 16px 10px;gap:8px; }
  .topbar-left { flex:1 1 100%; }
  .topbar-right { flex:1 1 100%; }
  .topbar .connect-banner { gap:10px; }
  .topbar .connect-banner-info { flex:0 0 auto; }
  .topbar .connect-banner-info>div { display:none; }
  .topbar .connection-form { flex:1;min-width:0; }
  .topbar .code-input-wrap { flex:1;min-width:0; }
  .topbar .code-input-wrap input { width:100%;min-width:0; }
  .session-summary { flex-wrap:wrap;gap:6px; }
}

/* Cantos de redimensionamento visíveis somente na miniatura. */
.pip-resize-handle { display:none; }
body.screen-pip .screen-panel { max-width:calc(100vw - 16px); }
body.screen-pip .pip-floating-bar { padding-left:28px;padding-right:28px; }
body.screen-pip .pip-resize-handle {
  display:block;position:absolute;z-index:5;width:24px;height:24px;
  padding:0;border:0;background:transparent;color:var(--primary);touch-action:none;
}
.pip-resize-handle::after { content:"";position:absolute;width:8px;height:8px;border-right:2px solid currentColor;border-bottom:2px solid currentColor;top:7px;left:7px;opacity:.65; }
.pip-resize-handle:hover,.pip-resize-handle:focus-visible { background:var(--primary-glow);outline:2px solid var(--primary);outline-offset:-3px; }
.pip-resize-nw { top:0;left:0;cursor:nwse-resize; }
.pip-resize-ne { top:0;right:0;cursor:nesw-resize; }
.pip-resize-sw { bottom:0;left:0;cursor:nesw-resize; }
.pip-resize-se { bottom:0;right:0;cursor:nwse-resize; }
.pip-resize-nw::after { transform:rotate(180deg); }
.pip-resize-ne::after { transform:rotate(270deg); }
.pip-resize-sw::after { transform:rotate(90deg); }
