/* ==========================================================
   X-Mirror · UI Profissional v21 — Painel SaaS Moderno
   Design system: tokens, espaçamentos consistentes, hierarquia.
   ========================================================== */

:root {
  /* Paleta neutra — tons de grafite, não preto puro */
  --bg-app:        #0B0F17;
  --bg-surface:    #111827;
  --bg-surface-2:  #18202E;
  --bg-elevated:   #1F2937;
  --bg-hover:      #273244;
  --bg-active:     #374151;
  --bg-input:      #0F172A;

  --border:        #1F2937;
  --border-strong: #374151;
  --border-focus:  #3B82F6;

  --text:          #E5E7EB;
  --text-muted:    #9CA3AF;
  --text-subtle:   #6B7280;
  --text-invert:   #0B0F17;

  /* Acentos — tons pasteis acessíveis */
  --accent:        #3B82F6;
  --accent-hover:  #60A5FA;
  --success:       #10B981;
  --success-bg:    rgba(16,185,129,0.12);
  --warning:       #F59E0B;
  --warning-bg:    rgba(245,158,11,0.12);
  --danger:        #EF4444;
  --danger-bg:     rgba(239,68,68,0.14);
  --purple:        #8B5CF6;
  --purple-bg:     rgba(139,92,246,0.12);

  /* Tipografia */
  --font-ui:       -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  --font-mono:     "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, Menlo, monospace;

  --fs-xs:         11px;
  --fs-sm:         12px;
  --fs-md:         13px;
  --fs-lg:         14px;
  --fs-xl:         16px;
  --fs-2xl:        18px;

  /* Espaçamentos escala 4 */
  --sp-1: 4px;   --sp-2: 8px;   --sp-3: 12px;  --sp-4: 16px;
  --sp-5: 20px;  --sp-6: 24px;  --sp-8: 32px;

  /* Raios */
  --r-sm: 6px;   --r-md: 8px;   --r-lg: 12px;  --r-xl: 16px;

  /* Sombras suaves */
  --sh-sm: 0 1px 2px rgba(0,0,0,.25);
  --sh-md: 0 4px 12px rgba(0,0,0,.35);
  --sh-lg: 0 12px 32px rgba(0,0,0,.5);

  /* Layout shell */
  --topbar-h:     48px;
  --sidebar-w:    56px;
  --rightpanel-w: 288px;
  --toolbar-h:    44px;

  /* Transições consistentes */
  --t-fast:   120ms cubic-bezier(.2,.8,.2,1);
  --t-base:   180ms cubic-bezier(.2,.8,.2,1);
  --t-slow:   280ms cubic-bezier(.2,.8,.2,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg-app);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.45;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.militar-theme { /* mantemos classe por compatibilidade JS, sem estilos "militar" gritantes */
  background: var(--bg-app);
}

/* ============================================================
   1) APP SHELL
   ============================================================ */

.app-container {
  display: grid !important;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: auto 1fr;     /* ← RESPONSIVO: row topbar = AUTO (expande p/ 2 linhas quando wrap) */
  grid-template-areas:
    "topbar  topbar"
    "sidebar main";
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* Quando painel direito está aberto, main fica colapsado para dar espaço */
.app-container.rightpanel-open {
  grid-template-columns: var(--sidebar-w) 1fr var(--rightpanel-w);
  grid-template-rows: auto 1fr;     /* ← RESPONSIVO: topbar AUTO quando wrap 2 linhas */
  grid-template-areas:
    "topbar  topbar  topbar"
    "sidebar main    rightpanel";
}

/* ------- POSICIONAMENTO EXPLÍCITO (fallback se grid-template-areas for quebrado) ------- */
#app-topbar {
  grid-area: topbar;
  grid-row: 1 / 2 !important;      /* SEMPRE LINHA 1 — NÚMERO FIXO, NÃO PODE FALHAR */
  grid-column: 1 / -1 !important;   /* SEMPRE TODAS COLUNAS (1 até final = -1), PEGA 100% LARGURA */
}
.module-nav  { grid-area: sidebar;   grid-row: 2 / -1 !important; grid-column: 1 / 2 !important; }
#app-main    { grid-area: main;      grid-row: 2 / -1 !important; }
#app-rightpanel { grid-area: rightpanel; grid-row: 2 / -1 !important; }

/* ---------- TOPBAR ---------- */
#app-topbar {
  background: linear-gradient(180deg, #0E1422 0%, #0B0F17 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  flex-wrap: wrap;                 /* ← Responsivo: se não couber, quebra para linha 2 */
  gap: var(--sp-3);
  padding: 6px var(--sp-3);       /* ← Aumenta padding vertical p/ quando wrap */
  min-height: var(--topbar-h);    /* ← Altura mínima = tamanho normal, expande se wrap 2 linhas */
  z-index: 40;
  backdrop-filter: blur(8px);
  overflow: hidden;                /* ← NUNCA scroll-x na topbar */
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 170px;
}
.topbar-logo-badge {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 100%);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: var(--fs-md);
  box-shadow: 0 0 0 1px rgba(59,130,246,.25), var(--sh-sm);
}
.topbar-logo-text {
  display: flex; flex-direction: column; line-height: 1.15;
}
.topbar-logo-title { font-weight: 700; font-size: var(--fs-md); letter-spacing: 0.2px; }
.topbar-logo-sub   { font-size: 10px; color: var(--text-subtle); }

.topbar-divider {
  width: 1px; height: 22px; background: var(--border);
}

/* Selector de PC — grande, visível, sempre acessível */
.topbar-pc-selector {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 1 1 240px;              /* ← RESPONSIVO: cresce 100%, não deixa menos de 240px para não esmagar; wrap natural */
  min-width: 240px;              /* ← Largura mínima confortável para selector não virar micro-pequeno */
  max-width: 100%;               /* ← Nunca ultrapassa a largura do container da topbar (evita scroll-x!) */
  flex-wrap: wrap;               /* ← RESPONSIVO: label | select | refresh quebram p/ linha 2 se n couberem 1 linha */
}
.pc-selector-main {
  flex: 1;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 6px 10px;
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-base);
  min-width: 0;
}
.pc-selector-main:hover  { border-color: #4B5563; }
.pc-selector-main:focus  {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,.2);
  background: var(--bg-input);
}
.icon-btn {
  width: 30px; height: 30px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 13px;
  transition: all var(--t-base);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); border-color: #4B5563; }
.icon-btn:active { transform: translateY(1px); }
.icon-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Ações à direita da topbar — RESPONSIVO: quebra p/ linha 2 se n couber 1 linha (selector+logo ocuparam demais) */
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;               /* ← RESPONSIVO: botões quebram p/ linha 2 se não couberem juntos */
  justify-content: flex-end;     /* ← Sempre alinhados à direita, mesmo em linha 2 */
  flex: 0 1 auto;                /* ← Permite encolher se precisar, mas não cresce */
  min-width: 0;
  max-width: 100%;               /* ← Nunca ultrapassa a topbar (evita scroll-x!) */
}

.connection-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--warning);
  display: inline-block;
  margin-right: 6px;
  box-shadow: 0 0 0 3px var(--warning-bg);
}
.connection-dot.ok {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-bg);
}
.connection-dot.err {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-bg);
}
.connection-label { font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------- SIDEBAR ESQUERDA (módulos) ---------- */
.module-nav {
  grid-area: sidebar;
  background: #0E1422;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 6px;
  gap: 2px;
  z-index: 30;
  overflow-y: auto;
  overflow-x: hidden;
}

.module-card {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-subtle);
  border: 1px solid transparent;
  position: relative;
  transition: all var(--t-base);
  user-select: none;
}
.module-card::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 50%; transform: translateY(-50%);
  width: 2px; height: 18px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  opacity: 0;
  transition: opacity var(--t-base);
}
.module-card:hover {
  background: var(--bg-surface-2);
  color: var(--text);
}
.module-card.active {
  background: rgba(59,130,246,.12);
  color: var(--accent-hover);
  border-color: rgba(59,130,246,.25);
}
.module-card.active::before { opacity: 1; }

.module-card span { font-size: 17px; line-height: 1; display: block; filter: saturate(0.9); }
.module-card.active span { filter: saturate(1.1); }
.module-card p {
  font-size: 9px;
  font-family: var(--font-ui);
  font-weight: 500;
  margin: 0;
  color: inherit;
  opacity: 0.9;
  line-height: 1;
}

/* Tooltip no hover dos cards do menu */
.module-card[data-module]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%; transform: translateY(-50%);
  background: #111827;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 5px 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--sh-md);
  z-index: 100;
  opacity: 0;
  animation: tooltipIn var(--t-base) 120ms forwards;
}
@keyframes tooltipIn { to { opacity: 1; } }

/* ---------- ÁREA PRINCIPAL ---------- */
.module-content {
  grid-area: main;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-app);
}
.module-pane { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* ---------- PAINEL LATERAL DIREITO (controles) ---------- */
#app-rightpanel {
  grid-area: rightpanel;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: none;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  z-index: 20;
  overflow: hidden;
}
.app-container.rightpanel-open #app-rightpanel { display: flex; }

.rpanel-tabs {
  display: flex;
  flex-wrap: wrap;                 /* ← Responsivo: 6 abas quebram p/ linha 2 se n couber */
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border);
  padding: 4px 2px;
  overflow: hidden;                /* ← NUNCA scroll-x nas tabs do painel */
  overflow-y: auto;                /* ← Scroll vertical APENAS se > 3 fileiras */
  align-content: flex-start;
  max-height: 96px;                /* ← LIMITE MÁXIMO ~3 fileiras (3*26 + gaps + padding ≈ 96px) */
  min-height: 32px;                /* ← 1 fileira mínima */
  flex-shrink: 0;
  scrollbar-width: thin;
  gap: 2px;
}
.rpanel-tab {
  padding: 7px 8px;
  flex: 0 0 auto;                  /* ← não cresce, mantém tamanho conteúdo; wrap natural */
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 4px 4px 0 0;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--t-base);
}
.rpanel-tab:hover { color: var(--text); background: var(--bg-hover); border-bottom-color: transparent; }
.rpanel-tab.active {
  color: var(--accent-hover);
  border-bottom-color: var(--accent);
  background: rgba(59,130,246,.06);
}

.rpanel-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;              /* ← NUNCA scroll-x no corpo do painel direito (wrap automático) */
  padding: 10px;
  min-height: 0;
  min-width: 0;
}
.rpanel-pane { display: none; }
.rpanel-pane.active {
  display: block;
  min-width: 0;
  max-width: 100%;                 /* ← Nunca ultrapassa 100% da largura do painel (evita scroll-x!) */
  overflow: hidden;
}

/* Grupos de controles — cartões organizados (RESPONSIVOS: nunca quebram scroll-x) */
.ctrl-group {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px;
  margin-bottom: 10px;
  min-width: 0;
  max-width: 100%;                 /* ← Nunca ultrapassa largura do painel direito */
  overflow: hidden;
}
.ctrl-group:last-child { margin-bottom: 0; }
.ctrl-group-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.15px;
}
.ctrl-group-title .emoji { font-size: 12px; }
.ctrl-group-desc {
  font-size: 10px;
  color: var(--text-subtle);
  margin: -4px 0 8px;
  line-height: 1.35;
}

/* ============================================================
   2) MÓDULO MIRROR — layout profissional
   ============================================================ */

.main-layout {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  grid-template-areas:
    "tabsbar"
    "viewport"
    "toolbar"
    "logpanel";
  height: 100%;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

/* Barra de tabs — RESPONSIVA: quebra p/ linha 2 se n couber, SEM SCROLL-X.
   LIMITE MÁXIMO 3 FILEIRAS (104px) + SCROLL VERTICAL APENAS! → NUNCA engole mirror viewport */
.tabs-bar {
  grid-area: tabsbar;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;                 /* ← RESPONSIVO: tabs quebram p/ linha de baixo se n couber */
  align-content: flex-start;       /* ← EVITA espaçamento vertical indevido com poucas tabs (1~2 linhas) */
  gap: 3px;
  padding: 4px 6px;
  min-height: 32px;                /* ← 1 fileira: ~32px */
  max-height: 104px;               /* ← LIMITA MÁXIMO 3 FILEIRAS (3*28 + gaps + padding ≈ 104px) */
  overflow: hidden;                /* ← NUNCA scroll-x; apenas scroll vertical acima de 3 linhas */
  overflow-y: auto;                /* ← Scroll vertical para ver abas adicionais além de 3 fileiras */
  align-items: center;
  scrollbar-width: thin;
  flex-shrink: 0;
}
.window-header {
  font-size: 10px;
  color: var(--text-subtle);
  padding: 1px 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  flex-shrink: 0;
}
.tab-item {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 11px;
  font-family: var(--font-ui);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: all var(--t-fast);
  display: flex;
  align-items: center;
  gap: 5px;
}
.tab-item:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); }
.tab-item.active {
  background: rgba(59,130,246,.14);
  color: #93C5FD;
  border-color: rgba(59,130,246,.45);
  box-shadow: inset 0 -2px 0 var(--accent);
  font-weight: 500;
}

/* Viewport — máximo aproveitamento (agora é o HERO da interface!) */
.mirror-viewport {
  grid-area: viewport;
  background:
    radial-gradient(1200px 800px at 50% 30%, rgba(59,130,246,.06) 0%, transparent 60%),
    radial-gradient(circle at center, #0A0E16 0%, #05070B 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  min-height: 0;
  min-width: 0;
  padding: 6px;
}
#mirrorImage {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  cursor: crosshair;
  display: block;
  image-rendering: auto;
  background: transparent;
  user-select: none;
  -webkit-user-drag: none;
  flex-shrink: 0;
  transition: opacity var(--t-fast);
  border-radius: 8px;
  box-shadow: 0 6px 28px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.04);
}
.placeholder-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  color: var(--text-subtle);
  padding: var(--sp-5);
  text-align: center;
}
.placeholder-center .big {
  font-size: 40px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}
.radar {
  width: 52px; height: 52px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  animation: radar-pulse 1.6s ease-in-out infinite;
  box-shadow: 0 0 24px rgba(59,130,246,.2);
}
@keyframes radar-pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1.05); }
}

/* Toolbar principal do mirror — RESPONSIVA: grupos quebram p/ linha 2 se n couber, sem scroll-x */
.mirror-toolbar {
  grid-area: toolbar;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 4px 8px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;                 /* ← RESPONSIVO: grupos quebram p/ linha de baixo se n couber */
  gap: 8px;
  min-height: var(--toolbar-h);    /* ← altura mínima = 1 linha; expande naturalmente com wrap 2+ */
  flex-shrink: 0;
  overflow: hidden;                /* ← NUNCA scroll-x */
  overflow-y: auto;                /* ← Apenas scroll vertical (caso 3+ linhas em tela minúscula) */
  scrollbar-width: thin;
}
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;                 /* ← RESPONSIVO: botões DENTRO do grupo também quebram se n couber */
}
.toolbar-group.sep {
  padding-left: 8px;
  margin-left: 2px;
  border-left: 1px solid var(--border-strong);
}
.url-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
#navUrl {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  outline: none;
  transition: all var(--t-base);
  margin: 0;
  height: 30px;
}
#navUrl:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59,130,246,.18);
}
.btn-inline-nav {
  padding: 5px 7px;
  min-width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-sm);
  border-radius: var(--r-sm);
}

/* Status em toolbar */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface-2);
  color: var(--text-muted);
  height: 24px;
}
.status-chip.running {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(16,185,129,.3);
}
.status-chip.stopped {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(239,68,68,.3);
}

/* ---------- Log / Console (AGORA NUNCA ESCONDE log-content, mesmo com Fetch UI aberto!) ---------- */
.log-panel {
  grid-area: logpanel;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  max-height: 340px;                 /* ← EXPANDIDO: 340px (antigo 170px → NÃO engole logContent) */
  transition: max-height var(--t-slow);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 28px;                  /* ← COLLAPSED: 28px (só header) */
  overflow: hidden;                  /* ← NUNCA transborda; overflow-y:auto EM CADA filho individual */
}
.log-panel.collapsed { max-height: 28px; min-height: 28px; }
.log-panel.fetch-open  { max-height: 340px; min-height: 250px; }  /* ← FETCH UI ABERTO: 250~340px (cabe fetch + log!) */

.log-header {
  padding: 5px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: var(--sp-2);
  height: 28px;
  min-height: 28px;
}

.console-fetch-panel {
  padding: 8px 10px;                /* ← COMPACTADO (era 10 14 → ganha ~8px p/ log-content) */
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface-2);
  flex-shrink: 0;                   /* ← NUNCA esmaga; log-content recebe o 1fr restante */
  overflow: hidden;
}
.console-fetch-form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.console-fetch-output {
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 8px;
  max-height: 100px;                /* ← COMPACTADO (era 140 → ganha 40px p/ log!) */
  overflow-y: auto;
  overflow-x: hidden;               /* ← sem scroll horizontal no fetch output */
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}
.input-sm, .textarea-sm {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 4px 8px;                 /* ← COMPACTADO (era 5 8 → +1px) */
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color var(--t-base);
}
.textarea-sm {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  min-height: 28px;                 /* ← COMPACTADO (era 30 → +2px) */
  resize: vertical;
}
.input-sm:focus, .textarea-sm:focus { border-color: var(--border-focus); }

.log-content {
  flex: 1;                          /* ← PREENCHE RESTO DO log-panel (mesmo com fetch UI aberto!) */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text);
  line-height: 1.45;
  min-height: 0;                    /* ← CRÍTICO: permite ser menor que conteúdo → overflow-y:auto FUNCIONA */
  max-height: none;
}

/* ============================================================
   3) BOTÕES E INPUTS — novo padrão
   ============================================================ */

button {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 5px 10px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  transition: all var(--t-fast);
  line-height: 1.3;
  white-space: nowrap;
}
button:hover { background: var(--bg-hover); border-color: #4B5563; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.btn-primary {
  background: linear-gradient(180deg, #3B82F6 0%, #2563EB 100%);
  border-color: #2563EB;
  color: #fff;
  box-shadow: 0 1px 2px rgba(37,99,235,.35), inset 0 1px 0 rgba(255,255,255,.08);
}
.btn-primary:hover { background: linear-gradient(180deg, #60A5FA 0%, #3B82F6 100%); border-color: #3B82F6; }

.btn-success {
  background: linear-gradient(180deg, #10B981 0%, #059669 100%);
  border-color: #059669;
  color: #fff;
  box-shadow: 0 1px 2px rgba(5,150,105,.35);
}
.btn-success:hover { background: linear-gradient(180deg, #34D399 0%, #10B981 100%); border-color: #10B981; }

.btn-danger {
  background: linear-gradient(180deg, #EF4444 0%, #DC2626 100%);
  border-color: #DC2626;
  color: #fff;
  box-shadow: 0 1px 2px rgba(220,38,38,.35);
}
.btn-danger:hover { background: linear-gradient(180deg, #F87171 0%, #EF4444 100%); border-color: #EF4444; }

.btn-warning {
  background: linear-gradient(180deg, #F59E0B 0%, #D97706 100%);
  border-color: #D97706;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(217,119,6,.35);
}
.btn-warning:hover {
  background: linear-gradient(180deg, #FBBF24 0%, #F59E0B 100%);
  border-color: #F59E0B;
  color: #fff;
}

.btn-secondary {
  background: var(--bg-surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-full { width: 100%; margin-top: 6px; }
.btn-icon { padding: 4px 6px; min-width: 28px; text-align: center; }
.btn-icon-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  padding: 2px 6px;
}
.btn-icon-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-sicredi {
  background: linear-gradient(180deg, #10B981 0%, #059669 100%);
  border-color: #059669;
  color: #fff;
  font-weight: 600;
}
.btn-sicredi:hover { background: linear-gradient(180deg, #34D399 0%, #10B981 100%); border-color: #10B981; color: #fff; }

.btn-scroll {
  background: linear-gradient(180deg, #3B82F6 0%, #2563EB 100%);
  border-color: #2563EB;
  color: #fff;
  font-weight: 600;
}
.btn-scroll:hover { background: linear-gradient(180deg, #60A5FA 0%, #3B82F6 100%); border-color: #3B82F6; color: #fff; }

.btn-tab-action {
  font-size: 10.5px;
  padding: 4px 5px;
  min-height: 24px;
  font-weight: 500;
  font-family: var(--font-ui);
}
.btn-tab-action.btn-add {
  background: linear-gradient(180deg, #10B981 0%, #059669 100%);
  border-color: #059669;
  color: #fff;
}
.btn-tab-action.btn-add:hover { background: linear-gradient(180deg, #34D399 0%, #10B981 100%); border-color: #10B981; color: #fff; }
.btn-tab-action.btn-danger {
  background: linear-gradient(180deg, #EF4444 0%, #DC2626 100%);
  border-color: #DC2626;
  color: #fff;
}
.btn-tab-action.btn-danger:hover { background: linear-gradient(180deg, #F87171 0%, #EF4444 100%); border-color: #EF4444; color: #fff; }
.btn-tab-action.btn-incognito {
  background: linear-gradient(180deg, #8B5CF6 0%, #7C3AED 100%);
  border-color: #7C3AED;
  color: #fff;
}
.btn-tab-action.btn-incognito:hover { background: linear-gradient(180deg, #A78BFA 0%, #8B5CF6 100%); border-color: #8B5CF6; color: #fff; }
.btn-tab-action.btn-silent {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-tab-action.btn-silent:hover { background: var(--bg-hover); border-color: #4B5563; color: #fff; }

/* Grids de botões compactos (painel direito) — RESPONSIVOS auto-fit com minmax:
   colunas quebram automaticamente (4→3→2→1) se n couber na largura, SEM scroll-x */
.compact-grid   { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 6px; }
.compact-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 6px; }
.compact-grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));  gap: 6px; }
.compact-grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));  gap: 6px; }
.btn-row { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

/* ---------- Inputs ---------- */
input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 5px 8px;
  font-family: var(--font-ui);
  font-size: 11px;
  width: 100%;
  margin-top: 6px;
  outline: none;
  transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-base);
}
textarea { resize: vertical; line-height: 1.4; min-height: 50px; font-size: 11px; }
input:focus, textarea:focus, select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59,130,246,.18);
  background: #0C1425;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-muted);
  user-select: none;
}
.checkbox-label input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
  width: 13px; height: 13px;
}

.key-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(60px, 1fr)); gap: 6px; }
.key-btn {
  font-size: 11px;
  padding: 6px 3px;
  font-family: var(--font-ui);
  font-weight: 500;
  min-height: 30px;
}

.placeholder-text {
  color: var(--text-subtle);
  font-size: 11px;
  text-align: center;
  padding: var(--sp-3);
}

.sub-label {
  font-size: var(--fs-xs);
  color: var(--text-subtle);
  margin-bottom: var(--sp-2);
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.section-sub {
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px dashed var(--border);
}

/* ============================================================
   4) BADGES
   ============================================================ */

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-family: var(--font-ui);
  line-height: 1.5;
}
.status-badge.on  { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,.3); }
.status-badge.off { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(239,68,68,.3); }
.status-badge.status-2xx { background: var(--success-bg); color: var(--success); }
.status-badge.status-3xx { background: rgba(59,130,246,.12); color: var(--accent); }
.status-badge.status-4xx { background: var(--warning-bg); color: var(--warning); }
.status-badge.status-5xx { background: var(--danger-bg);  color: var(--danger); }

/* ============================================================
   5) MÓDULOS: PROXY
   ============================================================ */

.proxy-layout { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

.proxy-toolbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.proxy-filter-select,
.proxy-filter-input {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  color: var(--text);
  font-size: var(--fs-sm);
  font-family: var(--font-ui);
  outline: none;
  margin: 0;
  width: auto;
}
.proxy-filter-input { width: 100px; }
.proxy-filter-select:focus,
.proxy-filter-input:focus { border-color: var(--border-focus); }

.proxy-split { display: flex; flex: 1; overflow: hidden; min-height: 0; }

.proxy-list-panel {
  width: 58%;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--bg-app);
}

.proxy-list-header {
  display: flex;
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border);
  padding: 9px 14px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  flex-shrink: 0;
}
.proxy-list-header span, .proxy-row > span {
  padding: 0 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.proxy-request-list { flex: 1; overflow-y: auto; }

.proxy-row {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-family: var(--font-ui);
  transition: background var(--t-fast);
}
.proxy-row:hover { background: var(--bg-surface-2); }
.proxy-row.selected {
  background: rgba(59,130,246,.1);
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}

.pr-num   { width: 44px; color: var(--text-subtle); font-family: var(--font-mono); font-size: var(--fs-xs); }
.pr-method { width: 62px; font-weight: 700; font-family: var(--font-mono); font-size: var(--fs-xs); }
.pr-status { width: 54px; font-family: var(--font-mono); font-size: var(--fs-xs); }
.pr-url   { flex: 1; color: var(--text); }
.pr-type  { width: 72px; color: var(--text-muted); font-size: var(--fs-xs); }
.pr-size  { width: 72px; color: var(--text-muted); font-size: var(--fs-xs); text-align: right; font-family: var(--font-mono); }
.pr-time  { width: 72px; color: var(--text-muted); font-size: var(--fs-xs); text-align: right; font-family: var(--font-mono); }

.method-get    { color: var(--success); }
.method-post   { color: var(--warning); }
.method-put    { color: var(--accent); }
.method-delete { color: var(--danger); }
.method-patch  { color: var(--purple); }
.method-head, .method-options { color: var(--text-muted); }
.method-response { color: var(--accent); }

.proxy-detail-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--bg-surface);
}

.proxy-detail-tabs {
  display: flex;
  flex-wrap: wrap;                 /* ← RESPONSIVO: tabs quebram p/ linha 2 se n couber, sem scroll-x */
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding: 4px var(--sp-2);
  overflow: hidden;                /* ← NUNCA scroll-x; apenas scroll-y > 3 fileiras */
  overflow-y: auto;
  align-content: flex-start;
  max-height: 100px;               /* ← LIMITE MÁXIMO ~3 fileiras */
  min-height: 36px;
  gap: 2px;
}
.detail-tab {
  padding: 10px 14px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  border-bottom: 2px solid transparent;
  font-family: var(--font-ui);
  font-weight: 500;
}
.detail-tab:hover { background: var(--bg-hover); color: var(--text); }
.detail-tab.active { color: var(--accent-hover); border-bottom-color: var(--accent); background: rgba(59,130,246,.06); }

.proxy-detail-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
  font-size: var(--fs-sm);
  background: var(--bg-app);
  min-height: 0;
}
.proxy-detail-actions {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--sp-2);
  flex-shrink: 0;
  background: var(--bg-surface);
}
.detail-pre {
  white-space: pre-wrap;
  word-break: break-all;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text);
  line-height: 1.55;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--sp-3);
}
.status-line {
  color: var(--success);
  font-weight: 700;
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-md);
}

/* ============================================================
   6) INTERCEPT · REGEX · HISTÓRICO · REPEATER · RECORDER
   ============================================================ */

.intercept-layout { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

.intercept-toolbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.intercept-queue {
  flex: 0 0 140px;
  overflow-y: auto;
  border-bottom: 1px solid var(--border);
  background: var(--bg-app);
}
.intercept-queue-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: var(--fs-sm);
  transition: background var(--t-fast);
}
.intercept-queue-item:hover { background: var(--bg-surface-2); }
.queue-url { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: var(--fs-xs); }

.intercept-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-surface);
}
.intercept-editor-header {
  padding: 10px 14px;
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: var(--sp-3);
}
.intercept-editor-title { font-weight: 600; font-size: var(--fs-md); }
.intercept-editor-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.intercept-editor-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  background: var(--bg-app);
  min-height: 0;
}
.intercept-field-group { display: flex; flex-direction: column; gap: var(--sp-2); }
.intercept-field-group label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.4px;
}
.intercept-field-row { display: flex; gap: var(--sp-3); }
.intercept-input, .intercept-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color var(--t-base);
}
.intercept-textarea {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  resize: vertical;
  line-height: 1.55;
}
.intercept-input:focus, .intercept-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}

.intercept-rules-section {
  padding: var(--sp-5);
  background: var(--bg-app);
  border-top: 1px solid var(--border);
  overflow-y: auto;
  flex: 1;
}
.intercept-rules-section h3 {
  font-size: var(--fs-md);
  color: var(--text);
  font-weight: 600;
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}
.rule-form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  margin-bottom: var(--sp-4);
}
.rule-form-grid input, .rule-form-grid select {
  flex: 1;
  min-width: 140px;
  margin: 0;
}
.rules-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.rule-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
}
.rule-pattern { flex: 1; color: var(--accent); font-family: var(--font-mono); font-size: var(--fs-xs); }
.rule-type { color: var(--text-muted); width: 100px; font-size: var(--fs-xs); }
.rule-actions { color: var(--warning); flex: 1; font-size: var(--fs-xs); }

/* ----- Repeater ----- */
.repeater-layout { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.repeater-tabs-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;                 /* ← RESPONSIVO: header wrap + tabs list wrap se n couber 1 linha */
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 6px 10px;
  gap: var(--sp-2);
  flex-shrink: 0;
  overflow: hidden;                /* ← NUNCA scroll-x */
  overflow-y: auto;                /* ← Apenas scroll vertical se > 3 fileiras */
  align-content: flex-start;
  max-height: 108px;               /* ← LIMITE MÁXIMO ~3 fileiras (inclui header + lista) */
  min-height: 44px;
}
.repeater-tabs-list {
  display: flex; gap: var(--sp-2); flex: 1 1 auto;
  flex-wrap: wrap;                 /* ← RESPONSIVO: tabs repeater quebram p/ linha 2 se n couber */
  min-width: 200px;
}
.repeater-tab-btn {
  padding: 6px 12px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  position: relative;
  white-space: nowrap;
  font-family: var(--font-ui);
  font-weight: 500;
}
.repeater-tab-btn.active {
  background: rgba(59,130,246,.14);
  color: #93C5FD;
  border-color: rgba(59,130,246,.4);
}
.repeater-tab-close {
  margin-left: 6px;
  opacity: 0.65;
  cursor: pointer;
  font-size: var(--fs-md);
}
.repeater-tab-close:hover { opacity: 1; color: var(--danger); }

.repeater-content { flex: 1; overflow: hidden; min-height: 0; }
.repeater-session { display: flex; flex-direction: column; height: 100%; }
.repeater-split { display: flex; flex: 1; overflow: hidden; min-height: 0; }
.repeater-request-panel, .repeater-response-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: var(--sp-4);
  gap: var(--sp-3);
  background: var(--bg-app);
  min-width: 0;
}
.repeater-request-panel { border-right: 1px solid var(--border); }

.repeater-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.4px;
}
.repeater-field-group { display: flex; flex-direction: column; gap: var(--sp-1); }
.repeater-field-group label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 600;
}
.repeater-field-row { display: flex; gap: var(--sp-3); }
.repeater-input {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  outline: none;
  width: 100%;
  margin: 0;
  transition: border-color var(--t-base);
}
.repeater-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: var(--sp-2);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  resize: vertical;
  width: 100%;
  flex: 1;
  line-height: 1.55;
  margin: 0;
  outline: none;
  min-height: 120px;
  transition: border-color var(--t-base);
}
.repeater-input:focus, .repeater-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}

.repeater-response-tabs {
  display: flex;
  gap: var(--sp-1);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--sp-1);
}
.resp-tab {
  padding: 4px 12px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-weight: 500;
}
.resp-tab:hover { background: var(--bg-hover); color: var(--text); }
.resp-tab.active {
  color: var(--accent-hover);
  border-color: rgba(59,130,246,.4);
  background: rgba(59,130,246,.1);
}
.repeater-response-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--sp-3);
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  line-height: 1.55;
  min-height: 160px;
}
.repeater-history-panel {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
  max-height: 130px;
  overflow-y: auto;
  background: var(--bg-surface);
  flex-shrink: 0;
}
.repeater-history-panel h4 {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
  font-weight: 600;
  letter-spacing: 0.5px;
}
.repeater-history-list { display: flex; flex-direction: column; gap: 2px; }
.repeater-history-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px 8px;
  cursor: pointer;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  transition: background var(--t-fast);
}
.repeater-history-item:hover { background: var(--bg-hover); }

/* ----- Recorder ----- */
.recorder-layout { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.recorder-toolbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.recorder-split { display: flex; flex: 1; overflow: hidden; min-height: 0; }
.recorder-live-panel, .recorder-saved-panel {
  flex: 1;
  padding: var(--sp-5);
  overflow-y: auto;
  background: var(--bg-app);
}
.recorder-live-panel { border-right: 1px solid var(--border); }
.recorder-live-panel h3, .recorder-saved-panel h3 {
  font-size: var(--fs-md);
  color: var(--text);
  font-weight: 600;
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}
.recording-live-list { display: flex; flex-direction: column; gap: 3px; }
.recording-live-item {
  padding: 5px 10px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
}
.saved-recordings-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.saved-recording-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
}
.saved-recording-item span:first-child {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

/* ----- Capturas ----- */
.capture-controls { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.captured-data-log { overflow-y: auto; max-height: 100%; flex: 1; padding: var(--sp-4); }
.request-item {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
  font-size: var(--fs-sm);
}
.request-item pre {
  white-space: pre-wrap;
  word-break: break-all;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.5;
  margin-top: var(--sp-2);
}

/* ----- VK Sessions ----- */
.vk-session-item {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.vk-session-item h4 {
  font-size: var(--fs-sm);
  color: var(--accent);
  margin-bottom: var(--sp-2);
  font-weight: 600;
}
.vk-resolved { color: var(--success); font-weight: 700; }

/* ----- Histórico ----- */
.history-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background: var(--bg-app);
  min-height: 0;
}
.history-toolbar {
  display: flex;
  align-items: center;
  padding: var(--sp-3) var(--sp-5);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  gap: var(--sp-3);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.history-split { display: flex; flex: 1; overflow: hidden; min-height: 0; }
.history-list-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-app);
  min-width: 0;
}
.history-list-header {
  display: flex;
  padding: 10px 16px;
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.history-request-list { flex: 1; overflow-y: auto; }
.history-item {
  display: flex;
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--t-fast);
  align-items: center;
  gap: var(--sp-3);
}
.history-item:hover { background: var(--bg-surface-2); }
.history-item.selected {
  background: rgba(59,130,246,.1);
  border-left: 3px solid var(--accent);
  padding-left: calc(var(--sp-5) - 3px);
}
.history-item .time {
  width: 130px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.history-item .title {
  flex: 2;
  font-size: var(--fs-md);
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item .url {
  flex: 3;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
}
.history-item .actions {
  width: 90px;
  display: flex;
  gap: var(--sp-1);
  justify-content: flex-end;
}
.history-detail-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  min-width: 0;
}
.history-detail-tabs {
  display: flex;
  flex-wrap: wrap;                 /* ← RESPONSIVO: history tabs quebram p/ linha 2 se n couber, sem scroll-x */
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border);
  padding: 4px var(--sp-2);
  flex-shrink: 0;
  overflow: hidden;                /* ← NUNCA scroll-x; apenas scroll-y > 3 fileiras */
  overflow-y: auto;
  align-content: flex-start;
  max-height: 100px;               /* ← LIMITE MÁXIMO ~3 fileiras */
  min-height: 36px;
  gap: 2px;
}
.history-detail-content {
  flex: 1;
  padding: var(--sp-5);
  overflow-y: auto;
  background: var(--bg-app);
  min-height: 0;
}
.history-detail-actions {
  padding: var(--sp-3) var(--sp-5);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--sp-2);
  flex-shrink: 0;
}
.history-filter-select {
  padding: 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--fs-sm);
  font-family: var(--font-ui);
  outline: none;
}
.history-filter-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}
.history-search-wrapper {
  flex: 1;
  position: relative;
  margin: 0 var(--sp-2);
  min-width: 280px;
  max-width: 540px;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  font-size: var(--fs-md);
  pointer-events: none;
  z-index: 1;
}
.history-search-input {
  width: 100% !important;
  padding: 9px 12px 9px 36px !important;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: var(--fs-sm) !important;
  font-family: var(--font-ui);
  outline: none;
  transition: all var(--t-base);
  margin: 0 !important;
}
.history-search-input::placeholder { color: var(--text-subtle); }
.history-search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
  background: #0C1425;
}

/* ============================================================
   7) SICREDI · BOTÕES ESPECIAIS
   ============================================================ */

.sicredi-section-top {
  background: var(--success-bg);
  border: 1px solid rgba(16,185,129,.25) !important;
  border-radius: var(--r-md);
  padding: var(--sp-4) !important;
}
.sicredi-section-top h3 {
  color: var(--success) !important;
}
.btn-sicredi-action {
  font-size: var(--fs-sm);
  padding: 6px 4px;
  font-weight: 700;
  color: #fff;
  font-family: var(--font-ui);
  transition: all var(--t-fast);
}
.btn-sicredi-action.btn-t1 { background: linear-gradient(180deg, #1E40AF 0%, #1D4ED8 100%); border-color: #1D4ED8; }
.btn-sicredi-action.btn-t1:hover { background: linear-gradient(180deg, #2563EB 0%, #3B82F6 100%); border-color: #3B82F6; }
.btn-sicredi-action.btn-t2 { background: linear-gradient(180deg, #C2410C 0%, #EA580C 100%); border-color: #EA580C; }
.btn-sicredi-action.btn-t2:hover { background: linear-gradient(180deg, #F97316 0%, #FB923C 100%); border-color: #FB923C; }
.btn-sicredi-action.btn-q  { background: linear-gradient(180deg, #6D28D9 0%, #7C3AED 100%); border-color: #7C3AED; }
.btn-sicredi-action.btn-q:hover  { background: linear-gradient(180deg, #8B5CF6 0%, #A78BFA 100%); border-color: #A78BFA; }
.btn-sicredi-action.btn-b  { background: linear-gradient(180deg, #A16207 0%, #CA8A04 100%); border-color: #CA8A04; }
.btn-sicredi-action.btn-b:hover  { background: linear-gradient(180deg, #EAB308 0%, #FACC15 100%); border-color: #FACC15; color: var(--text-invert); }
.btn-sicredi-action.btn-t  { background: linear-gradient(180deg, #047857 0%, #059669 100%); border-color: #059669; }
.btn-sicredi-action.btn-t:hover  { background: linear-gradient(180deg, #10B981 0%, #34D399 100%); border-color: #10B981; }

.sicredi-placeholder {
  background: var(--danger-bg);
  border: 1px dashed rgba(239,68,68,.45);
  border-radius: var(--r-sm);
  color: var(--danger) !important;
  font-weight: 600;
  padding: var(--sp-3) !important;
  font-size: var(--fs-xs);
  margin-top: var(--sp-2);
}
.sicredi-controls .btn-full { margin-top: var(--sp-2); }

/* ============================================================
   8) SCROLLBARS · PERSONALIZADAS
   ============================================================ */

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: #273244;
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: #374151; background-clip: content-box; border: 2px solid transparent; }
*::-webkit-scrollbar-corner { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: #374151 transparent; }

/* ============================================================
   9) ANIMAÇÕES · ESTADOS ESPECIAIS
   ============================================================ */

@keyframes flashing {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}
.flashing { animation: flashing 0.6s ease-in-out 3; }
.error-text { color: var(--danger); }

.btn-warning.active-swap {
  background: linear-gradient(180deg, #F59E0B 0%, #FBBF24 100%) !important;
  color: var(--text-invert) !important;
  box-shadow: 0 0 16px rgba(245,158,11,.5);
  border-color: #FBBF24 !important;
}

#btnWindowSwap {
  background: linear-gradient(180deg, #F59E0B 0%, #D97706 100%);
  border: 1px solid #D97706;
  color: #fff;
  font-weight: 600;
  transition: all var(--t-base);
}
#btnWindowSwap:hover {
  background: linear-gradient(180deg, #FBBF24 0%, #F59E0B 100%);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(217,119,6,.3);
  color: #fff;
}
#btnWindowSwap.active-swap {
  background: linear-gradient(180deg, #10B981 0%, #059669 100%) !important;
  color: #fff !important;
  box-shadow: 0 0 20px rgba(16,185,129,.5);
  border-color: #10B981 !important;
  animation: pulseSwap 1.6s infinite;
}
@keyframes pulseSwap {
  0%, 100% { box-shadow: 0 0 12px rgba(16,185,129,.45); }
  50%      { box-shadow: 0 0 22px rgba(16,185,129,.8); }
}

/* ============================================================
   10) TOASTS · já existiam (mantidos, ajuste de variáveis)
   ============================================================ */

.toast-janela-container {
  position: fixed;
  top: calc(var(--topbar-h) + 14px);
  right: 16px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 380px;
}
.toast-janela {
  position: relative;
  background: linear-gradient(135deg, #0F172A 0%, #111827 100%);
  border: 1px solid var(--border-focus);
  border-left: 4px solid var(--border-focus);
  border-radius: var(--r-md);
  padding: 12px 14px 12px 48px;
  color: #E6EDF3;
  font-size: var(--fs-sm);
  line-height: 1.4;
  box-shadow: var(--sh-lg), 0 0 0 1px rgba(59,130,246,.15) inset;
  pointer-events: auto;
  overflow: hidden;
  animation: toastIn .26s cubic-bezier(.2,.8,.2,1) both;
  font-family: var(--font-ui);
}
.toast-janela.toast-info    { border-color: #3B82F6; border-left-color: #3B82F6; }
.toast-janela.toast-success { border-color: #10B981; border-left-color: #10B981; }
.toast-janela.toast-warn    { border-color: #F59E0B; border-left-color: #F59E0B; }
.toast-janela.toast-danger  { border-color: #EF4444; border-left-color: #EF4444; }
.toast-janela::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: var(--fs-md);
  font-weight: 700;
  color: #fff;
}
.toast-janela.toast-info::before    { content: 'i'; background: rgba(59,130,246,.22); color: #60A5FA; }
.toast-janela.toast-success::before { content: '✓'; background: rgba(16,185,129,.2); color: #34D399; }
.toast-janela.toast-warn::before    { content: '!'; background: rgba(245,158,11,.22); color: #FBBF24; font-weight: 900; }
.toast-janela.toast-danger::before  { content: '✖'; background: rgba(239,68,68,.22); color: #F87171; }
.toast-janela-title { font-weight: 700; font-size: var(--fs-md); margin-bottom: 2px; color: #fff; }
.toast-janela-body  { opacity: 0.92; font-size: var(--fs-sm); }
.toast-janela-footer { margin-top: 4px; font-size: var(--fs-xs); opacity: 0.65; }
.toast-janela-progress {
  position: absolute; left: 0; bottom: 0; height: 2px;
  background: currentColor;
  opacity: 0.6;
  width: 100%;
  transform-origin: left center;
  animation: toastProgress linear forwards;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastProgress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}
.toast-janela.toast-leaving { animation: toastOut .2s ease-in both; }
@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px); max-height: 0; padding-top: 0; padding-bottom: 0; margin: 0; border-width: 0; }
}

/* ============================================================
   11) MODAIS
   ============================================================ */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(6px);
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
}
.modal-overlay[style*="display:flex"], .modal-overlay[style*="display: flex"] { display: flex; }
.modal-overlay > div {
  background: linear-gradient(180deg, #111827 0%, #0F172A 100%);
  color: #fff;
  padding: var(--sp-6);
  border-radius: var(--r-lg);
  min-width: 360px;
  max-width: 92vw;
  max-height: 88vh;
  overflow: auto;
  border: 1px solid var(--border-strong);
  box-shadow: var(--sh-lg);
  font-family: var(--font-ui);
}

/* ============================================================
   12) CLASSES LEGADO (manter para não quebrar JS — antigas sidebar)
   ============================================================ */

.sidebar { display: none; }               /* sidebar antiga esquerda — substituída pelo painel direito */
.sidebar-header { display: none; }
.sidebar-scroll { display: none; }
.section {
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.section h3 {
  font-size: var(--fs-sm);
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.2px;
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}

/* Login overlay (mantemos intacto — só tipografia) */
#login-overlay {
  position: fixed; inset: 0;
  background: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999999;
  font-family: var(--font-ui);
}
#login-overlay > div {
  background: var(--bg-surface);
  padding: 32px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border-strong);
  width: 340px;
  text-align: center;
  box-shadow: var(--sh-lg);
}
#login-overlay h2 {
  color: var(--text);
  margin-bottom: var(--sp-5);
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: 0.3px;
}
#login-password {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  margin-bottom: var(--sp-3);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  outline: none;
  transition: all var(--t-base);
}
#login-password:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,.2);
}
#login-button {
  width: 100%;
  padding: 11px;
  background: linear-gradient(180deg, #10B981 0%, #059669 100%);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  font-weight: 700;
  font-size: var(--fs-md);
  font-family: var(--font-ui);
  box-shadow: 0 1px 2px rgba(5,150,105,.35);
  transition: all var(--t-base);
}
#login-button:hover { background: linear-gradient(180deg, #34D399 0%, #10B981 100%); }
#login-error {
  color: var(--danger);
  margin-top: var(--sp-3);
  font-size: var(--fs-sm);
  display: none;
  font-weight: 500;
}

/* ============================================================
   13) AJUSTES MÓDULO CONFIGURAÇÕES
   ============================================================ */

.cfg-wrapper {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--sp-6);
  overflow-y: auto;
  height: 100%;
  width: 100%;
}
.cfg-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
}
.cfg-card-title {
  color: var(--accent-hover);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--sp-2);
  font-size: var(--fs-lg);
  font-weight: 700;
}
.cfg-field { margin-bottom: var(--sp-4); }
.cfg-field > label {
  display: block;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  margin-bottom: var(--sp-2);
  letter-spacing: 0.4px;
  font-weight: 600;
}
.cfg-field .hint {
  font-size: var(--fs-xs);
  color: var(--text-subtle);
  margin-top: var(--sp-2);
  line-height: 1.5;
}
.cfg-status-box {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.cfg-actions-row { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); }
