/* ── Reset & Variables ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0f1117;
  --bg2:          #161b27;
  --bg3:          #1e2436;
  --bg-card:      #161b27;
  --bg-elevated:  #1e2436;
  --border:       #2a3147;
  --accent:       #6366f1;
  --accent-hover: #818cf8;
  --danger:       #ef4444;
  --warn:         #f97316;
  --success:      #22c55e;
  --text:         #e8eaf0;
  --text-primary: #e8eaf0;
  --text-muted:   #8b91a7;
  --text-faint:   #4a5165;
  --ui-zoom:      1.25;   /* mesmo valor do zoom do body: vh/vw dentro do body são multiplicados por ele, então dividimos de volta */
  --sidebar-w:    236px;
  --sidebar-coll: 58px;
  --topbar-h:     60px;
  --radius:       10px;
  --shadow:       0 4px 24px rgba(0,0,0,.4);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: calc(100vh / var(--ui-zoom));
  font-size: 14px;
  line-height: 1.5;
  zoom: var(--ui-zoom);   /* equivale ao zoom 125% do browser — ajuste --ui-zoom no :root se quiser outro tamanho */
}

/* ── Utilities ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.active  { display: flex !important; }

button { cursor: pointer; font-family: inherit; font-size: 13px; border: none; outline: none; transition: all .15s; }

input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 12px;
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }

hr { border: none; border-top: 1px solid var(--border); }

/* ── Login ─────────────────────────────────────────────────────────────────── */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 100;
}

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 340px;
  text-align: center;
  box-shadow: var(--shadow);
}

.login-logo {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; color: white;
  margin: 0 auto 16px;
}

.login-card h1 { font-size: 24px; font-weight: 700; letter-spacing: 2px; }
.login-subtitle { color: var(--text-muted); font-size: 12px; margin: 6px 0 28px; letter-spacing: .5px; }

.login-card form { display: flex; flex-direction: column; gap: 12px; }

.login-card button[type=submit] {
  background: var(--accent);
  color: white;
  padding: 11px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
}
.login-card button[type=submit]:hover { background: var(--accent-hover); }

.error { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* Login com MFA (Fase 3) */
.login-mfa-texto { color: var(--text-muted); font-size: 12px; line-height: 1.5; margin: 2px 0; }
#login-mfa-qr { display: block; margin: 8px auto; background: #fff; padding: 8px; border-radius: 10px; }
#login-mfa-segredo { display: inline-block; margin-top: 4px; padding: 3px 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; font-size: 12px; word-break: break-all; user-select: all; }
#login-mfa-codigo { text-align: center; letter-spacing: 8px; font-size: 20px; }
.login-card .login-link { background: none; color: var(--text-muted); font-size: 12px; text-decoration: underline; padding: 4px; }
.login-card .login-link:hover { color: var(--text); }

/* ── App Layout ────────────────────────────────────────────────────────────── */
.app {
  display: flex;
  min-height: calc(100vh / var(--ui-zoom));
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  /* top+bottom (e não 100vh): ocupa exatamente a altura visível em qualquer zoom/tamanho de janela,
     senão o zoom do body deixa o menu mais alto que a tela e o rodapé (Novo Perfil / Sair) some */
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 10;
  transition: width .2s ease;
  overflow: hidden;
}

/* ── Sidebar colapsada ────────────────────────────────────────────────────── */
/* Recolhida = só ícones; com o mouse em cima abre por cima do conteúdo (sem empurrá-lo) e volta ao tirar o mouse.
   Clicar na seta fixa o menu aberto. Por isso todas as regras 'colapsada' valem só enquanto NÃO há hover. */
.sidebar.collapsed:hover { box-shadow: 6px 0 24px rgba(0,0,0,.45); }
.sidebar.collapsed:not(:hover) { width: var(--sidebar-coll); }

.sidebar.collapsed:not(:hover) .sidebar-title   { display: none; }
.sidebar.collapsed:not(:hover) .nav-btn .label  { display: none; }
.sidebar.collapsed:not(:hover) .profiles-label  { display: none; }
.sidebar.collapsed:not(:hover) .profile-name    { display: none; }
.sidebar.collapsed:not(:hover) .profile-pending { display: none; }

.sidebar.collapsed:not(:hover) .sidebar-header  { justify-content: center; padding: 20px 8px 16px; gap: 0; }
.sidebar.collapsed:not(:hover) .sidebar-nav     { padding: 12px 4px 4px; }
.sidebar.collapsed:not(:hover) .nav-btn         { justify-content: center; padding: 9px 0; gap: 0; }
.sidebar.collapsed:not(:hover) .sidebar-profiles{ padding: 16px 4px 8px; }
.sidebar.collapsed:not(:hover) .profile-item    { justify-content: center; padding: 8px 0; gap: 0; }
.sidebar.collapsed:not(:hover) .sidebar-footer  { padding: 4px; }

/* Botão toggle ‹ / › */
.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 5px;
  margin-left: auto;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.sidebar-toggle:hover { color: var(--text); background: var(--bg3); }
.sidebar.collapsed:not(:hover) .sidebar-toggle  { margin-left: 0; margin-top: 6px; }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;   /* nunca comprime o cabeçalho */
}

.sidebar-logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: white;
  flex-shrink: 0;
}

.sidebar-title { font-weight: 700; letter-spacing: 1.5px; font-size: 14px; }

.sidebar-nav {
  padding: 12px 8px 4px;
  display: flex; flex-direction: column; gap: 2px;
  flex-shrink: 0;   /* nunca comprime a navegação */
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  width: 100%;
  text-align: left;
  font-size: 13.5px;
}
.nav-btn:hover  { background: var(--bg3); color: var(--text); }
.nav-btn.active { background: rgba(99,102,241,.15); color: var(--accent); }

.nav-btn .icon  { font-size: 17px; width: 22px; text-align: center; }
.nav-btn .label { font-weight: 500; }

/* Profiles section in sidebar */
.sidebar-profiles {
  flex: 1;
  min-height: 0;    /* permite que flex shrink funcione corretamente */
  padding: 16px 8px 8px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.profiles-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-faint);
  padding: 0 8px 8px;
}

.profile-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  transition: background .1s;
  position: relative;
}
.profile-item:hover { background: var(--bg3); color: var(--text); }
.profile-item.active { background: var(--bg3); color: var(--text); }

.profile-dot {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  color: white;
  overflow: hidden;
}
.profile-dot img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { flex: 1; font-weight: 500; }

.profile-pending {
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
  flex-shrink: 0;        /* nunca comprime */
  margin-top: auto;      /* empurra para o fundo quando profiles é pequeno */
  background: var(--bg2);
}

/* ── Main Content ──────────────────────────────────────────────────────────── */
.sidebar.collapsed ~ .main-content,
body.sb-collapsed .main-content {
  margin-left: var(--sidebar-coll);
}

.main-content {
  margin-left: var(--sidebar-w);
  transition: margin-left .2s ease;
  flex: 1;
  min-width: 0;          /* impede flex item de expandir além do viewport */
  overflow-x: hidden;    /* garante que overflow interno fique contido */
  display: flex;
  flex-direction: column;
  min-height: calc(100vh / var(--ui-zoom));
}

.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-left h2 { font-size: 16px; font-weight: 600; }

/* ── Topbar search ─────────────────────────────────────────────────────────── */
.topbar-search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  flex: 0 1 280px;
  transition: border-color .15s, box-shadow .15s;
}
.topbar-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99,102,241,.15);
}
.topbar-search-icon { font-size: 14px; flex-shrink: 0; opacity: .6; }
.topbar-search input {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 13px;
  width: 100%;
  color: var(--text);
}
.topbar-search input:focus { border: none; box-shadow: none; }
.topbar-search input::placeholder { color: var(--text-faint); }
.search-clear-btn {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 11px;
  padding: 1px 4px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
}
.search-clear-btn:hover { color: var(--text); background: var(--border); }

/* highlight matched text */
.search-highlight { background: rgba(99,102,241,.35); border-radius: 2px; }

.profile-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: white;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 500;
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
  background: rgba(239,68,68,.1);
  color: var(--danger);
  padding: 6px 12px;
  border-radius: 7px;
  font-weight: 500;
  border: 1px solid rgba(239,68,68,.2);
}
.btn-danger:hover { background: rgba(239,68,68,.2); }

.btn-icon {
  background: transparent;
  color: var(--text-muted);
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 15px;
}
.btn-icon:hover { background: var(--bg3); color: var(--text); }

/* ── Views ─────────────────────────────────────────────────────────────────── */
.view {
  flex: 1;
  padding: 24px;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

/* ── Stats grid ────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.stat-card.urgent { border-color: rgba(239,68,68,.3); }

.stat-number {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
}
.stat-card.urgent .stat-number { color: var(--danger); }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* ── Section header ────────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-header h3 { font-size: 14px; font-weight: 600; }
.section-hint { font-size: 12px; color: var(--text-faint); }

/* ── Task list ─────────────────────────────────────────────────────────────── */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  transition: border-color .15s, background .1s;
  border-left: 3px solid transparent;
}
.task-card:hover { border-color: var(--accent); background: var(--bg3); }
.task-card[data-priority="1"] { border-left-color: var(--danger); }
.task-card[data-priority="2"] { border-left-color: var(--warn); }
.task-card[data-priority="3"] { border-left-color: var(--success); }

.task-priority-badge {
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .4px;
}
.task-priority-badge.p1 { background: rgba(239,68,68,.15); color: var(--danger); }
.task-priority-badge.p2 { background: rgba(249,115,22,.15); color: var(--warn); }
.task-priority-badge.p3 { background: rgba(34,197,94,.15); color: var(--success); }

.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.task-meta  { font-size: 12px; color: var(--text-muted); }
.task-meta-secondary { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.task-checker-tag {
  font-size: 11px;
  background: var(--bg3);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 5px;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Filters ───────────────────────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.filters-bar select { width: auto; min-width: 160px; }

/* Sticky variant — used in view-tasks so the bar sticks when scrolling */
.view-tasks {
  padding: 0;             /* remove padding from view; handled per child */
  overflow: visible;      /* permite que o sticky funcione em relação ao body scroll */
}
.sticky-bar {
  position: sticky;
  /* fica logo abaixo do topbar (60px) ao rolar a página */
  top: var(--topbar-h);
  z-index: 4;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  margin: 0;
  flex-shrink: 0;
}
.task-list-padded {
  padding: 20px 24px 24px;
}

/* Search: hide items that don't match */
.search-hidden { display: none !important; }

/* ── Integrations ──────────────────────────────────────────────────────────── */
.integrations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.integration-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.integration-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.integration-name { font-weight: 600; font-size: 14px; }
.integration-status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
}
.status-connected    { background: rgba(34,197,94,.15); color: var(--success); }
.status-disconnected { background: rgba(139,145,167,.1); color: var(--text-faint); }
.status-error        { background: rgba(239,68,68,.1);  color: var(--danger); }

.integration-desc { font-size: 12px; color: var(--text-muted); }

.integration-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Routines ──────────────────────────────────────────────────────────────── */
.routines-list { display: flex; flex-direction: column; gap: 10px; }

/* ── Agrupadores de rotinas ────────────────────────────────────────────────── */
.routine-group { display: flex; flex-direction: column; gap: 0; }

.routine-group-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.routine-group-header:hover { background: #252836; }
.routine-group-icon  { font-size: 16px; display: inline-flex; align-items: center; }
.routine-group-icon img { display: block; }
.routine-group-label { font-weight: 700; font-size: 13px; color: var(--text); flex: 1; }
.routine-group-count { font-size: 11px; color: var(--text-faint); background: var(--bg2); padding: 2px 8px; border-radius: 10px; }
.routine-group-pending { font-size: 11px; color: var(--accent); background: rgba(99,102,241,.15); padding: 2px 8px; border-radius: 10px; }
.routine-group-chevron { font-size: 13px; color: var(--text-muted); margin-left: 4px; }

.routine-group-body {
  display: flex; flex-direction: column; gap: 4px;
  padding: 4px 0 0 0;
}

/* Prefix "Bling | " no título da rotina */
.routine-group-prefix {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  margin-right: 6px;
  padding: 1px 6px;
  background: var(--bg3);
  border-radius: 4px;
  vertical-align: middle;
}

.routine-row {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color .15s, background .15s;
}
.routine-row:hover { background: var(--bg3); }
.routine-row[draggable="true"] { cursor: default; }
.routine-row.drag-over {
  border-color: var(--accent) !important;
  background: rgba(99,102,241,.07);
  box-shadow: 0 0 0 2px rgba(99,102,241,.25);
}
.routine-row.dragging { opacity: 0.4; }

.routine-drag-handle {
  color: var(--text-faint);
  font-size: 15px;
  cursor: grab;
  flex-shrink: 0;
  padding: 2px 4px;
  user-select: none;
  line-height: 1;
}
.routine-drag-handle:active { cursor: grabbing; }

.routine-row-icon  { font-size: 22px; flex-shrink: 0; }

.routine-row-body  { flex: 1; min-width: 0; }
.routine-row-title { font-weight: 600; font-size: 14px; }
.routine-row-meta  { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.routine-row-desc  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.routine-row-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.routine-row-actions { display: flex; gap: 6px; align-items: center; }

.routine-badge {
  font-size: 11px; font-weight: 700;
  padding: 2px 9px; border-radius: 20px; white-space: nowrap;
}
.badge-urgent  { background: rgba(239,68,68,.15);  color: var(--danger);  }
.badge-pending { background: rgba(99,102,241,.12); color: var(--accent);  }
.badge-ok      { background: rgba(34,197,94,.1);   color: var(--success); font-weight: 600; }

.btn-sm { padding: 5px 12px !important; font-size: 12px !important; }

/* ── Param info icon (ℹ tooltip) ───────────────────────────────────────────── */
.param-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-style: normal;
  cursor: help;
  margin-left: 5px;
  vertical-align: middle;
  line-height: 1;
  flex-shrink: 0;
}
.param-info-icon:hover { opacity: .85; }

/* ── String-list param (chips removíveis) ──────────────────────────────────── */
.string-list-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  min-height: 4px;
}
.string-list-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px 4px 12px;
  font-size: 12px;
  color: var(--text);
  line-height: 1;
}
.string-list-chip button {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 11px;
  padding: 0 1px;
  border-radius: 50%;
  line-height: 1;
  transition: color .12s;
}
.string-list-chip button:hover { color: var(--danger); }
.string-list-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.string-list-input-row input { flex: 1; }

/* ── External system icons (favicons em botões) ─────────────────────────────── */
/*
 * .ext-favicon  — img do favicon do sistema externo (Bling, Mercado Livre, etc.)
 * .bling-icon   — fallback CSS (B verde) quando o favicon não carrega
 * .bling-link-btn / .ext-link-btn — botão/link que abre um sistema externo
 */
.ext-link-btn,
.bling-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  flex-shrink: 0;
}

/* Favicon real carregado via <img> */
.ext-favicon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  object-fit: contain;
  flex-shrink: 0;
  vertical-align: middle;
}

/* Fallback CSS: badge "B" verde do Bling */
.bling-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: #00A859;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  border-radius: 3px;
  flex-shrink: 0;
  line-height: 1;
  vertical-align: middle;
}

.ext-link-btn:hover,
.bling-link-btn:hover { opacity: .85; }

/* ── Copy value button ─────────────────────────────────────────────────────── */
.copy-value-btn {
  background:none;border:1px solid var(--border);border-radius:5px;
  color:var(--text-muted);font-size:11px;padding:3px 8px;cursor:pointer;
  white-space:nowrap;transition:all .15s;
}
.copy-value-btn:hover { background:var(--bg3);color:var(--text);border-color:var(--accent); }

/* ── Field tags (produtos_cadastro missing fields) ─────────────────────────── */
.task-tags { display:flex;flex-wrap:wrap;gap:4px;margin-top:5px;align-items:center; }
.field-tag { font-size:10px;font-weight:600;padding:2px 7px;border-radius:20px;white-space:nowrap; }
.tag-p1 { background:rgba(239,68,68,.15);  color:var(--danger); }
.tag-p2 { background:rgba(249,115,22,.12); color:var(--warn);   }

/* ── Due-date tags (contas a pagar) ─────────────────────────────────────────── */
.tag-due-today   { background:rgba(59,130,246,.18);  color:#3b82f6; }   /* azul  — HOJE          */
.tag-due-overdue { background:rgba(239,68,68,.18);   color:#ef4444; }   /* vermelho — VENCEU     */
.tag-due-soon    { background:rgba(249,115,22,.18);  color:#f97316; }   /* laranja — até 3 dias  */
.tag-due-future  { background:rgba(34,197,94,.15);   color:#16a34a; }   /* verde — prazo folgado */

/* ── Task card: produto layout ─────────────────────────────────────────────── */
.task-prod-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.copy-inline-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  line-height: 1;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.copy-inline-btn:hover {
  color: var(--accent);
  background: rgba(99,102,241,.1);
}
.task-missing-label {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  margin-right: 2px;
}

/* ── History ───────────────────────────────────────────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: 8px; }

.history-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.history-status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-success   { background: var(--success); }
.dot-error     { background: var(--danger); }
.dot-partial   { background: var(--warn); }
.dot-running   { background: var(--accent); animation: pulse-dot 1.2s ease-in-out infinite; }
.dot-queued    { background: var(--text-faint); }
.dot-cancelled { background: var(--text-faint); }

.history-info { flex: 1; }
.history-title { font-weight: 600; font-size: 13px; }
.history-meta  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.history-count {
  font-size: 12px;
  background: var(--bg3);
  padding: 3px 10px;
  border-radius: 6px;
  color: var(--text-muted);
}

/* ── Modals ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.active { display: flex !important; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-height: calc(90vh / var(--ui-zoom));   /* compensa o zoom do body → 90vh real na tela */
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; }

.modal-close {
  background: var(--bg3);
  color: var(--text-muted);
  width: 28px; height: 28px;
  border-radius: 7px;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.form-group input[type=color] { width: 60px; height: 36px; padding: 3px; border-radius: 7px; cursor: pointer; }

/* Task detail in modal */
.task-detail-table { width: 100%; border-collapse: collapse; }
.task-detail-table td { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.task-detail-table td:first-child { color: var(--text-muted); width: 40%; font-weight: 500; }
.task-detail-table tr:last-child td { border-bottom: none; }

.integration-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; line-height: 1.6; }

.test-result {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
}
.test-result.ok    { background: rgba(34,197,94,.1); color: var(--success); }
.test-result.error { background: rgba(239,68,68,.1); color: var(--danger); }

/* ── Params modal (checker settings) ───────────────────────────────────────── */
.modal-params { max-width: 600px; }

/* ── Aba Bling: oculta coluna Frete Log. (só aparece no Consolidado) ─────── */
/* visibility:collapse colapsa a coluna a zero-width preservando a estrutura    */
/* do table: colspan e rowspan continuam funcionando corretamente no Chrome.    */
/* display:none quebra o layout porque remove o elemento do fluxo de colunas.  */
.fin-hide-frete-log  .col-frete-log  { visibility: collapse; }
.fin-hide-frete-log  .th-frete-log   { visibility: collapse; }
.fin-hide-frete-log  .td-frete-log   { visibility: collapse; }
.fin-hide-frete-vend .col-frete-vend { visibility: collapse; }
.fin-hide-frete-vend .th-frete-vend  { visibility: collapse; }
.fin-hide-frete-vend .td-frete-vend  { visibility: collapse; }
.fin-hide-utm .col-utm  { visibility: collapse; }
.fin-hide-utm .th-utm   { visibility: collapse; }
.fin-hide-utm .td-utm   { visibility: collapse; }

/* ── Product CRUD modal ─────────────────────────────────────────────────────── */
.modal-produto { max-width: 760px; }

.modal-produto-header-inner {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 0;
}
.modal-produto-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.produto-loading {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

.produto-section { margin-bottom: 22px; }
.produto-section:last-child { margin-bottom: 0; }

.produto-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-faint);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.produto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 10px;
}
.produto-grid.wide { grid-template-columns: 1fr; }
.produto-grid.two  { grid-template-columns: 1fr 1fr; }

.produto-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.produto-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.produto-field input,
.produto-field textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  padding: 7px 10px;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  cursor: default;
}
.produto-field input:disabled,
.produto-field textarea:disabled { opacity: 1; }

/* Textarea auto-resize (JS seta a altura via scrollHeight) */
.produto-field textarea {
  resize: vertical;
  line-height: 1.6;
  min-height: 60px;
  overflow: hidden;   /* evita scrollbar durante o cálculo de altura */
}
.produto-field textarea.auto-resize { resize: none; overflow: hidden; }

/* Select de unidade de medida — mesma aparência e altura dos inputs */
.produto-field select,
.produto-um-select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  font-family: inherit;
  cursor: default;
  box-sizing: border-box;
}
.produto-field select:disabled,
.produto-um-select:disabled { opacity: 1; }
.produto-field select:focus,
.produto-um-select:focus { outline: none; border-color: var(--accent); }

/* Wrapper do select fora do grid (abaixo das dimensões) */
.produto-um-wrapper {
  margin-top: 10px;
  max-width: 200px;   /* mesma largura de um campo normal no grid */
}

/* Missing (P2 — atenção) */
.produto-field.missing input,
.produto-field.missing textarea {
  border-color: var(--warn);
  background: rgba(234,179,8,.07);
}
.produto-field.missing label { color: var(--warn); }
.produto-field.missing label::after { content: ' ⚠'; font-size: 10px; }

/* Urgent (P1 — urgente) */
.produto-field.urgent input,
.produto-field.urgent textarea {
  border-color: var(--danger);
  background: rgba(239,68,68,.07);
}
.produto-field.urgent label { color: var(--danger); }
.produto-field.urgent label::after { content: ' ✗'; font-size: 10px; }

/* Unidade de medida badge no título da seção */
.produto-um-badge {
  display: inline-block;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  vertical-align: middle;
  margin-left: 5px;
}

/* Image area */
.produto-image-area {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.produto-image-preview {
  width: 110px;
  height: 110px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg3);
  flex-shrink: 0;
}
.produto-image-missing {
  width: 110px;
  height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--danger);
  border-radius: 9px;
  background: rgba(239,68,68,.06);
  color: var(--danger);
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  text-align: center;
  gap: 5px;
}
.produto-image-missing span { font-size: 22px; }
.produto-image-url-field { flex: 1; }

/* Bling link button */
.btn-bling-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ── Run spinner ───────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 200;
  transition: opacity .2s;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger); color: var(--danger); }

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── Loading skeleton ──────────────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg2) 50%, var(--bg3) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}

/* ── Fields Config Table (params modal for produtos_cadastro) ─────────────── */
.fields-config-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 8px;
}
.fields-config-table th {
  text-align: left;
  padding: 6px 10px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.fields-config-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.fields-config-table tr:last-child td { border-bottom: none; }
.fields-config-table tr:hover td     { background: var(--bg3); }
.fields-config-table select {
  padding: 3px 6px;
  font-size: 12px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  width: 110px;
}
.fields-config-table .fld-enabled {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.fields-config-table .fld-priority { cursor: pointer; }

/* Row dimmed when disabled */
.fields-config-table tr.field-row-disabled td {
  opacity: .4;
}

/* ── Dashboard filter bar ─────────────────────────────────────────────────── */
.dash-filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px 0;
}
.dash-filter-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.dash-filter-bar select {
  width: 220px;
  padding: 6px 10px;
  font-size: 13px;
}

/* ── Stat card clickable ──────────────────────────────────────────────────── */
.stat-card.clickable {
  cursor: pointer;
  transition: border-color .15s, transform .1s, background .15s;
}
.stat-card.clickable:hover {
  border-color: var(--accent);
  background: var(--bg3);
  transform: translateY(-1px);
}

/* ── Dashboard charts area ────────────────────────────────────────────────── */
.dash-charts-area {
  padding: 12px 0 16px;
}
.dash-chart-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.dash-chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 16px;
}
.dash-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background .12s;
}
.dash-bar-row:hover { background: var(--bg3); }
.dash-bar-label {
  width: 200px;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-bar-track {
  flex: 1;
  height: 10px;
  background: var(--bg3);
  border-radius: 5px;
  overflow: hidden;
}
.dash-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 5px;
  transition: width .3s ease;
}
.dash-bar-fill.urgent { background: var(--danger); }
.dash-bar-count {
  width: 120px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}
.dash-bar-urgent {
  font-size: 11px;
  font-weight: 500;
  color: var(--danger);
}
.dash-chart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}
.dash-empty-icon { font-size: 32px; }

/* ── Dashboard Tabs (Geral / Financeiro) ─────────────────────────────────── */
.dash-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.dash-tab {
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.dash-tab:hover { color: var(--text-primary); }
.dash-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--bg-card);
}

/* ── Dashboard Financeiro ────────────────────────────────────────────────── */
.dash-fin-filterbar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
}
.dash-fin-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.dash-fin-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dash-fin-kpi.accent { border-color: var(--accent); }
.dash-fin-kpi.warn   { border-color: var(--warning, #f59e0b); }
.dash-fin-kpi-icon   { font-size: 18px; line-height: 1; }
.dash-fin-kpi-val    { font-size: 18px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.dash-fin-kpi-label  { font-size: 11px; color: var(--text-muted); font-weight: 500; }

.dash-fin-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  align-items: flex-start;
}
.dash-fin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 14px 10px;
  min-width: 0;
}
.dash-fin-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 10px;
}
.dash-fin-bars { display: flex; flex-direction: column; gap: 5px; }
.dash-fin-bars-sm .dash-fin-bar-row { min-height: 18px; }

.dash-fin-bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 90px;
  align-items: center;
  gap: 6px;
  min-height: 22px;
}
.dash-fin-bar-label {
  font-size: 11px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-fin-bar-track {
  height: 8px;
  background: var(--bg3, var(--bg-input));
  border-radius: 4px;
  overflow: hidden;
}
.dash-fin-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width .3s ease;
}
.dash-fin-bar-val {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}
.dash-fin-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 12px 0;
  text-align: center;
}
.dash-fin-expand-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 5px 0;
  font-size: 11px;
  color: var(--accent);
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 5px;
  cursor: pointer;
  text-align: center;
  transition: background .15s;
}
.dash-fin-expand-btn:hover { background: var(--bg3, var(--bg-input)); }

/* ── Canvas wrap para Chart.js ───────────────────────────────────────────── */
.dash-fin-cvs-wrap {
  position: relative;
  width: 100%;
  cursor: pointer;
}

/* ── Fix: select dropdown background em dark mode ────────────────────────── */
select option {
  background: var(--bg-card, #1e1e2e);
  color: var(--text-primary, #e2e8f0);
}

/* ── Curva ABC table ─────────────────────────────────────────────────────── */
.dash-fin-abc-wrap {
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}
.dash-fin-abc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.dash-fin-abc-table th {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  transition: color .15s;
}
.dash-fin-abc-table th[onclick]:hover {
  color: var(--text-primary);
  background: var(--bg3, var(--bg-input));
}
.dash-fin-abc-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.dash-fin-abc-table tr:hover td { background: var(--bg3, var(--bg-input)); }
.dash-fin-abc-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

/* ── Routine disabled state ───────────────────────────────────────────────── */
.routine-disabled {
  opacity: 0.55;
}
.routine-disabled .routine-row-title,
.routine-disabled .routine-row-desc {
  color: var(--text-muted);
}

/* ── Routine toggle button ────────────────────────────────────────────────── */
.routine-toggle-btn {
  padding: 5px 11px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all .15s;
}
.routine-toggle-btn.toggle-active {
  background: transparent;
  color: var(--text-muted);
}
.routine-toggle-btn.toggle-active:hover {
  background: rgba(239,68,68,.1);
  border-color: var(--danger);
  color: var(--danger);
}
.routine-toggle-btn.toggle-inactive {
  background: rgba(34,197,94,.1);
  border-color: var(--success);
  color: var(--success);
}
.routine-toggle-btn.toggle-inactive:hover {
  background: rgba(34,197,94,.2);
}

/* ── Routine badge: disabled ──────────────────────────────────────────────── */
.badge-disabled {
  background: var(--bg3);
  color: var(--text-faint);
  border: 1px solid var(--border);
}

/* ── Routine observação ───────────────────────────────────────────────────── */
.routine-row-obs {
  font-size: 11px;
  color: var(--accent);
  margin-top: 4px;
  font-style: italic;
}

/* ── Params modal: observação field ──────────────────────────────────────── */
.params-obs-sep {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ── History timing ───────────────────────────────────────────────────────── */
.hist-timing-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 6px;
}
.hist-timing {
  font-size: 11px;
  color: var(--text-muted);
}
.hist-live {
  color: var(--warn);
  font-weight: 500;
}
.hist-dur {
  color: var(--success);
  font-weight: 500;
}
.hist-detail-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.hist-log-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.hist-log-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.hist-params-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: monospace;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-muted);
  max-height: 120px;
  overflow-y: auto;
}
.hist-group-badge {
  font-size: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 7px;
  color: var(--text-faint);
}
.hist-queue-badge {
  font-size: 11px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--text-muted);
}

/* Pulsing dot for RUNNING executions */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .4; transform: scale(.75); }
}

/* ── Financeiro Hub – Tab Bar ────────────────────────────────────────────── */
.fin-hub-tabbar {
  display: flex;
  gap: 4px;
  padding: 12px 20px 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
  background: var(--bg-main);
  /* Sticky: gruda no topo da view ao rolar */
  position: sticky;
  top: 0;
  z-index: 6;
}

/* ── Financeiro Hub – Painéis sticky (filtros + KPIs) ───────────────────── */
#fin-sticky-panel,
#ml-fin-sticky-panel,
#ifood-fin-sticky-panel {
  position: sticky;
  top: var(--fin-tabbar-h, 46px);
  z-index: 5;
  background: var(--bg-main);
  padding-top: 16px;
  padding-bottom: 4px;
  /* Sombra sutil quando grudado — indica que o conteúdo está rolando abaixo */
  box-shadow: 0 6px 12px -4px rgba(0,0,0,0.35);
  margin: 0 -24px;   /* cancela o padding do .view para ir de borda a borda */
  padding-left: 24px;
  padding-right: 24px;
}

/* ── Financeiro Bling – thead sticky via ghost JS (ver _finGhostThead) ───── */
/* overflow-x:auto no wrapper cria contexto de scroll implícito → position:sticky
   no thead não funciona. Solução: ghost div position:fixed criado por JS. */
.fin-hub-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  position: relative;
  bottom: -2px;
}
.fin-hub-tab:hover {
  background: var(--bg-card);
  color: var(--text-main);
}
.fin-hub-tab.active {
  background: var(--bg-card);
  color: var(--text-main);
  font-weight: 600;
  border: 2px solid var(--border);
  border-bottom: 2px solid var(--bg-card);
}
.fin-hub-tab img {
  width: 14px;
  height: 14px;
  object-fit: contain;
  border-radius: 2px;
}

/* ── Módulo Financeiro ───────────────────────────────────────────────────── */
.fin-kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fin-kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.fin-kpi-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  white-space: nowrap;
}
.fin-table tbody tr:hover {
  background: var(--bg-elevated);
}
.fin-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.fin-table tbody tr.fin-detail-row {
  cursor: default;
}
.fin-table tbody tr.fin-detail-row:hover {
  background: transparent;
}
.fin-table td {
  padding: 6px 6px;
  vertical-align: middle;
}
/* linha expandida */
.fin-detail-row td {
  padding: 0 !important;
  background: var(--bg-base, #0f1117);
}
.fin-detail-inner {
  padding: 8px 0 8px 0;
  border-top: 2px solid var(--accent);
}
.fin-detail-inner table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.fin-detail-inner th {
  padding: 7px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.fin-detail-inner th.num { text-align: right; }
.fin-detail-inner td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fin-detail-inner td:last-child   { padding-right: 20px; }
.fin-detail-inner td.num { text-align: right; }
.fin-detail-inner tr:last-child td { border-bottom: none; }
.fin-detail-inner .detail-tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--border);
  border-bottom: none;
  padding-bottom: 16px;
}
.fin-row-expanded > td:first-child::before {
  content: '▼ ';
  color: var(--accent);
  font-size: 10px;
}

/* ── Multi-select filtros financeiro ─────────────────────────────────────── */
.fin-ms { position: relative; display: inline-block; }
.fin-ms-trigger {
  font-size: 13px;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 110px;
  text-align: left;
  transition: border-color .15s;
}
.fin-ms-trigger:hover,
.fin-ms.open .fin-ms-trigger { border-color: var(--accent); }
.fin-ms-caret { font-size: 10px; color: var(--text-muted); transition: transform .15s; }
.fin-ms.open .fin-ms-caret  { transform: rotate(180deg); }
.fin-ms-badge {
  font-size: 10px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-weight: 700;
  flex-shrink: 0;
}
.fin-ms-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
  z-index: 300;
  padding: 4px 0;
}
.fin-ms.open .fin-ms-dropdown { display: block; }
.fin-ms-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: background .1s;
  user-select: none;
}
.fin-ms-option:hover { background: var(--hover-bg); }
.fin-ms-option input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  cursor: pointer;
}
.fin-ms-empty {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── ML Financeiro ─────────────────────────────────────────────────────────── */
.ml-th {
  padding: 5px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border);
}
.ml-th:hover { color: var(--text); }

