/* ============================================================
   ZapFlow · Design System v2 (modern dark)
   ============================================================ */

:root {
  /* Surfaces (mais claras pra dar contraste com o bg escuro) */
  --bg: #0b0b14;
  --bg2: #1a1a28;
  --bg3: #232336;
  --bg4: #2d2d44;

  /* Glass / glow */
  --glass: rgba(255, 255, 255, 0.03);
  --glass-strong: rgba(255, 255, 255, 0.06);
  --glow-accent: 0 0 32px rgba(99, 102, 241, 0.3);
  --glow-purple: 0 0 32px rgba(168, 85, 247, 0.25);

  /* Borders mais visíveis */
  --border: #34344e;
  --border-hover: #4a4a6a;
  --border-strong: #5a5a80;

  /* Text mais claro/legível */
  --text: #f5f5fc;
  --text2: #c8c8e0;
  --text3: #9090b4;
  --text4: #6c6c8c;

  /* Status */
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.1);
  --green-border: rgba(34, 197, 94, 0.28);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.1);
  --red-border: rgba(239, 68, 68, 0.28);
  --blue: #3b82f6;
  --blue-bg: rgba(59, 130, 246, 0.1);
  --blue-border: rgba(59, 130, 246, 0.28);
  --yellow: #eab308;
  --yellow-bg: rgba(234, 179, 8, 0.1);
  --yellow-border: rgba(234, 179, 8, 0.28);
  --purple: #a855f7;
  --purple-bg: rgba(168, 85, 247, 0.1);
  --purple-border: rgba(168, 85, 247, 0.28);

  --accent: #6366f1;
  --accent2: #818cf8;
  --accent3: #a78bfa;

  /* Geometry */
  --radius: 16px;
  --radius-lg: 22px;
  --radius-sm: 12px;
  --radius-xs: 8px;

  /* Shadows */
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);

  --font: "DM Sans", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", monospace;
  --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  font-size: 16px;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  /* Rede de segurança: nada empurra a página pra fora horizontalmente */
  overflow-x: hidden;
  max-width: 100vw;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-image:
    radial-gradient(
      1200px 600px at -10% -10%,
      rgba(99, 102, 241, 0.08),
      transparent 60%
    ),
    radial-gradient(
      1000px 500px at 110% 110%,
      rgba(168, 85, 247, 0.07),
      transparent 60%
    );
  background-attachment: fixed;
}

a {
  color: inherit;
  text-decoration: none;
}
button {
  font-family: inherit;
}
code {
  font-family: var(--mono);
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}
::selection {
  background: rgba(99, 102, 241, 0.35);
  color: var(--text);
}

/* ============================================================
   Layout
   ============================================================ */
.app {
  display: flex;
  min-height: 100vh;
  min-width: 0;
  max-width: 100vw;
}

.sidebar {
  width: 264px;
  background: linear-gradient(
    180deg,
    rgba(19, 19, 31, 0.98),
    rgba(19, 19, 31, 0.92)
  );
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(14px);
}
.main {
  margin-left: 264px;
  flex: 1;
  min-height: 100vh;
  min-width: 0;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main {
    margin-left: 0;
  }
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar-header {
  padding: 22px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  color: #fff;
  box-shadow: var(--glow-accent);
  transition: var(--transition);
}
.sidebar-logo:hover {
  transform: rotate(-6deg) scale(1.05);
}
.sidebar-brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.sidebar-brand span {
  color: var(--accent2);
}

.sidebar-nav {
  padding: 14px;
  flex: 1;
  overflow-y: auto;
}
.nav-section {
  margin-bottom: 22px;
}
.nav-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text4);
  padding: 0 12px;
  margin-bottom: 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  font-weight: 500;
  position: relative;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--bg3);
  color: var(--text);
  transform: translateX(2px);
}
.nav-item.active {
  background: linear-gradient(
    135deg,
    rgba(99, 102, 241, 0.18),
    rgba(168, 85, 247, 0.1)
  );
  color: var(--accent2);
  border: 1px solid rgba(99, 102, 241, 0.25);
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.18);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: linear-gradient(180deg, var(--accent), var(--purple));
  border-radius: 0 3px 3px 0;
}
.nav-icon {
  font-size: 17px;
  width: 22px;
  text-align: center;
}
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 22px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.3);
}
.user-info {
  flex: 1;
  min-width: 0;
}
.user-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 11px;
  color: var(--text3);
}

/* ============================================================
   Header
   ============================================================ */
.header {
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(19, 19, 31, 0.75);
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}
.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}
@media (max-width: 768px) {
  .menu-btn {
    display: block;
  }
}
.header-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.header-sub {
  font-size: 13.5px;
  color: var(--text3);
  margin-top: 3px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-btn {
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
}
.header-btn:hover {
  border-color: var(--border-hover);
  background: var(--bg4);
  transform: translateY(-1px);
}
.header-btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border: none;
  color: #fff;
  box-shadow: var(--glow-accent);
}
.header-btn.primary:hover {
  box-shadow:
    0 0 24px rgba(99, 102, 241, 0.45),
    0 4px 12px rgba(0, 0, 0, 0.3);
}
.header-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================
   Content
   ============================================================ */
.content {
  padding: 28px;
  max-width: 1600px;
}

/* ============================================================
   Stat Cards
   ============================================================ */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}
.stat-card {
  background: linear-gradient(135deg, var(--bg2), rgba(27, 27, 42, 0.6));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(8px);
}
.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card::after {
  content: "";
  position: absolute;
  inset: auto -40% -40% auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  opacity: 0.07;
  filter: blur(40px);
  transition: opacity 0.3s ease;
}
.stat-card:hover::after {
  opacity: 0.14;
}
.stat-card.green::before {
  background: linear-gradient(90deg, var(--green), #34d399);
}
.stat-card.green::after {
  background: var(--green);
}
.stat-card.blue::before {
  background: linear-gradient(90deg, var(--blue), #60a5fa);
}
.stat-card.blue::after {
  background: var(--blue);
}
.stat-card.yellow::before {
  background: linear-gradient(90deg, var(--yellow), #fbbf24);
}
.stat-card.yellow::after {
  background: var(--yellow);
}
.stat-card.red::before {
  background: linear-gradient(90deg, var(--red), #f87171);
}
.stat-card.red::after {
  background: var(--red);
}
.stat-card.purple::before {
  background: linear-gradient(90deg, var(--purple), var(--accent2));
}
.stat-card.purple::after {
  background: var(--purple);
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
}
.stat-card.green .stat-icon {
  background: var(--green-bg);
  border: 1px solid var(--green-border);
}
.stat-card.blue .stat-icon {
  background: var(--blue-bg);
  border: 1px solid var(--blue-border);
}
.stat-card.yellow .stat-icon {
  background: var(--yellow-bg);
  border: 1px solid var(--yellow-border);
}
.stat-card.red .stat-icon {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
}
.stat-card.purple .stat-icon {
  background: var(--purple-bg);
  border: 1px solid var(--purple-border);
}

.stat-value {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 14px;
  color: var(--text2);
  margin-top: 8px;
  font-weight: 500;
}

/* ============================================================
   Panels
   ============================================================ */
.panel {
  background: linear-gradient(180deg, var(--bg2), rgba(19, 19, 31, 0.85));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
  backdrop-filter: blur(8px);
  transition: var(--transition);
}
.panel:hover {
  border-color: var(--border-hover);
}
.panel-header {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
}
.panel-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.01em;
}
.panel-body {
  padding: 22px;
}
.panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============================================================
   Instance Cards (legacy-page)
   ============================================================ */
.instances-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.instance-card {
  background: linear-gradient(135deg, var(--bg2), var(--bg3));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.instance-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    400px circle at var(--mx, 50%) var(--my, 0%),
    rgba(99, 102, 241, 0.08),
    transparent 50%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.instance-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.instance-card:hover::before {
  opacity: 1;
}
.instance-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.instance-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.instance-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--bg4), var(--bg3));
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.instance-name {
  font-size: 16px;
  font-weight: 700;
}
.instance-number {
  font-size: 13px;
  color: var(--text3);
  font-family: var(--mono);
  margin-top: 3px;
}
.instance-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 999px;
}
.instance-status.online {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}
.instance-status.offline {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red-border);
}
.instance-status.paused {
  background: var(--yellow-bg);
  color: var(--yellow);
  border: 1px solid var(--yellow-border);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.instance-status.online .status-dot {
  background: var(--green);
  animation: pulse-dot 2s infinite;
  box-shadow: 0 0 8px var(--green);
}
.instance-status.offline .status-dot {
  background: var(--red);
}
.instance-status.paused .status-dot {
  background: var(--yellow);
}

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.85);
  }
}

.instance-progress {
  margin-bottom: 12px;
}
.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13.5px;
  color: var(--text2);
  margin-bottom: 8px;
}
.progress-info b {
  color: var(--text);
  font-family: var(--mono);
}
.progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(90deg, var(--green), #34d399);
  position: relative;
}
.progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.25),
    transparent
  );
  animation: shimmer 2.4s infinite;
}
@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}
.progress-fill.warning {
  background: linear-gradient(90deg, var(--yellow), #fbbf24);
}
.progress-fill.danger {
  background: linear-gradient(90deg, var(--red), #f87171);
}

.instance-meta {
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: var(--text2);
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  flex-wrap: wrap;
  align-items: center;
}
.instance-meta b {
  color: var(--text);
  font-family: var(--mono);
  font-weight: 600;
}

.instance-actions {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  flex-wrap: wrap;
  align-items: stretch;
}
.instance-actions > .btn-sm {
  flex: 1 1 auto;
  min-width: 0;
  justify-content: center;
  height: 36px;
  padding: 0 12px;
}
.instance-actions > .btn-sm.danger {
  flex: 0 0 36px;
  width: 36px;
  padding: 0;
  justify-content: center;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-sm {
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg4);
  color: var(--text2);
  transition: var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn-sm:hover {
  border-color: var(--border-hover);
  color: var(--text);
  transform: translateY(-1px);
}
.btn-sm:active {
  transform: translateY(0);
}
.btn-sm.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-sm.primary {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  border: none;
}
.btn-sm.danger {
  border-color: var(--red-border);
  color: var(--red);
  background: var(--red-bg);
}
.btn-sm.danger:hover {
  background: rgba(239, 68, 68, 0.16);
  border-color: var(--red);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg4);
  color: var(--text2);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
}
.btn-icon:hover {
  border-color: var(--border-hover);
  color: var(--text);
  transform: translateY(-1px);
}
.btn-icon.danger {
  border-color: var(--red-border);
  color: var(--red);
  background: var(--red-bg);
}
.btn-icon.danger:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: var(--red);
}
.btn-icon.force {
  border-color: var(--yellow-border);
  color: var(--yellow);
  background: var(--yellow-bg);
}
.btn-icon.force:hover {
  background: rgba(250, 204, 21, 0.2);
  border-color: var(--yellow);
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.25);
}
.btn-icon:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ============================================================
   Mini stats (in-panel)
   ============================================================ */
.mini-stat {
  background: linear-gradient(135deg, var(--bg3), var(--bg2));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.mini-stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  opacity: 0.9;
}
.mini-stat:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}
.mini-stat-l {
  font-size: 12px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-bottom: 6px;
}
.mini-stat-v {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.mini-stat.green::before {
  background: linear-gradient(90deg, var(--green), #34d399);
}
.mini-stat.green .mini-stat-v {
  color: var(--green);
}
.mini-stat.blue::before {
  background: linear-gradient(90deg, var(--blue), #60a5fa);
}
.mini-stat.blue .mini-stat-v {
  color: var(--blue);
}
.mini-stat.purple::before {
  background: linear-gradient(90deg, var(--purple), var(--accent2));
}
.mini-stat.purple .mini-stat-v {
  color: var(--purple);
}
.mini-stat.yellow::before {
  background: linear-gradient(90deg, var(--yellow), #fbbf24);
}
.mini-stat.yellow .mini-stat-v {
  color: var(--yellow);
}

.alert-erro {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  border-left: 3px solid var(--red);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--red);
  font-size: 13.5px;
  margin-bottom: 12px;
  line-height: 1.5;
}

/* ============================================================
   Dias da semana (checkbox group)
   ============================================================ */
.dias-semana {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
}
.dia-chk {
  flex: 1 1 auto;
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text3);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dia-chk:hover {
  border-color: var(--border-hover);
  color: var(--text2);
  transform: translateY(-1px);
}
.dia-chk input {
  display: none;
}
.dia-chk.on {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}
.dia-chk.on:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.45);
}

/* ============================================================
   Pager (paginação ajax)
   ============================================================ */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.pager:empty {
  display: none;
}
.pager-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer;
  transition: var(--transition);
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pager-btn:hover:not(:disabled) {
  border-color: var(--border-hover);
  color: var(--text);
  background: var(--bg4);
  transform: translateY(-1px);
}
.pager-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.pager-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.35);
}
.pager-sep {
  color: var(--text3);
  padding: 0 4px;
  user-select: none;
}

#ultimos-tbody {
  transition: opacity 0.15s ease;
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
thead th {
  text-align: left;
  padding: 14px 18px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.025);
}
tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr {
  transition: background 0.15s ease;
}
tbody tr:hover {
  background: var(--bg3);
}
tbody tr:last-child td {
  border-bottom: none;
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
}
.badge.sent {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}
.badge.queued {
  background: var(--yellow-bg);
  color: var(--yellow);
  border: 1px solid var(--yellow-border);
}
.badge.error {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red-border);
}
.badge.scheduled {
  background: var(--blue-bg);
  color: var(--blue);
  border: 1px solid var(--blue-border);
}

/* ============================================================
   Message preview / errors in tables
   ============================================================ */
.msg-preview {
  max-width: 380px;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.5;
}
.msg-preview > .msg-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.msg-preview .msg-error {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--red);
  font-family: var(--mono);
  background: rgba(239, 68, 68, 0.08);
  border-left: 2px solid var(--red);
  padding: 7px 10px;
  border-radius: 4px;
  white-space: normal;
  word-break: break-word;
  line-height: 1.5;
}

/* ============================================================
   Forms / Inputs
   ============================================================ */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.config-item {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.config-label,
.form-group label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.config-input,
textarea.config-input,
select.config-input {
  padding: 12px 15px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-size: 15px;
  font-family: var(--font);
  transition: var(--transition);
  outline: none;
  width: 100%;
}
.config-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
  background: var(--bg2);
}
select.config-input {
  cursor: pointer;
}
textarea.config-input {
  font-family: var(--mono);
  line-height: 1.55;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.alert-erro {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  color: var(--red);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  margin: 14px 0;
  text-align: center;
}

/* ============================================================
   Upload zones
   ============================================================ */
.upload-area,
.upload-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* input file fora do fluxo: label[for] abre o picker sem JS (evita stack overflow com bubble) */
.upload-zone .upload-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}
.upload-empty-label {
  cursor: pointer;
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: inherit;
}
.upload-area:hover,
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.04);
  transform: translateY(-1px);
}
.upload-icon {
  font-size: 42px;
  margin-bottom: 12px;
  opacity: 0.6;
}
.upload-text {
  font-size: 14px;
  color: var(--text2);
  margin-bottom: 4px;
  font-weight: 500;
}
.upload-sub {
  font-size: 12px;
  color: var(--text3);
}

.upload-empty {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  color: var(--text2);
}
.upload-preview {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  width: 100%;
}
.upload-preview img {
  max-width: 100%;
  max-height: 240px;
  border-radius: 10px;
  object-fit: contain;
  background: var(--bg);
  box-shadow: var(--shadow);
}

/* ============================================================
   Chart (envios por hora)
   ============================================================ */
.chart-area {
  background: linear-gradient(180deg, var(--bg3), rgba(27, 27, 42, 0.7));
  border-radius: var(--radius-sm);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--border);
}
.chart-area-lg .chart-plot {
  height: 280px;
}
.chart-area-lg .chart-bars {
  gap: 5px;
}

/* Wrapper que vira scroll-x no mobile (mantém o gráfico em tamanho legível) */
.chart-scroll {
  position: relative;
}
.chart-scroll-inner {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.chart-scroll-hint {
  display: none;
  text-align: center;
  font-size: 11px;
  color: var(--text3);
  padding: 6px 0 0;
  letter-spacing: 0.04em;
  font-family: var(--mono);
  opacity: 0.8;
}

/* Header com cards de stats */
.chart-head {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}
.chart-stat {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  transition: var(--transition);
}
.chart-stat:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}
.chart-stat-l {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  margin-bottom: 4px;
}
.chart-stat-v {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.chart-stat-v b {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  font-family: var(--mono);
  line-height: 1;
  letter-spacing: -0.02em;
}
.chart-stat-v span {
  font-size: 12px;
  color: var(--text3);
  font-weight: 500;
}
.chart-stat-v.green b {
  color: var(--green);
}
.chart-stat-v.yellow b {
  color: var(--yellow);
}
.chart-stat.now {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.06);
}

/* Body */
.chart-body {
  display: flex;
  height: 240px;
  gap: 10px;
}
.chart-y {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 44px;
  padding: 4px 0;
}
.chart-y-label {
  font-size: 12px;
  color: var(--text3);
  text-align: right;
  font-family: var(--mono);
  line-height: 1;
}
.chart-plot {
  flex: 1;
  position: relative;
}
.chart-grid {
  position: absolute;
  inset: 4px 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}
.chart-grid > div {
  border-top: 1px dashed var(--border);
  height: 0;
  opacity: 0.4;
}
.chart-grid > div:last-child {
  border-top-style: solid;
  opacity: 0.8;
}

/* Linha vertical "agora" */
.chart-now-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(
    to bottom,
    transparent,
    var(--green) 15%,
    var(--green) 85%,
    transparent
  );
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.6);
  pointer-events: none;
  z-index: 2;
  animation: pulse-now 2.5s ease-in-out infinite;
}
.chart-now-line::before {
  content: "AGORA";
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--green);
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(34, 197, 94, 0.4);
  white-space: nowrap;
}
@keyframes pulse-now {
  0%,
  100% {
    opacity: 0.85;
  }
  50% {
    opacity: 0.45;
  }
}

.chart-bars {
  position: absolute;
  inset: 4px 0 0;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  z-index: 1;
}
.chart-col {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  position: relative;
  cursor: pointer;
}
.chart-val {
  font-size: 11px;
  color: var(--text);
  font-family: var(--mono);
  margin-bottom: 4px;
  transition: all 0.2s ease;
  height: 14px;
  line-height: 14px;
  font-weight: 700;
  opacity: 0;
}
.chart-val.visible {
  opacity: 0.85;
}
.chart-col:hover .chart-val {
  opacity: 1;
  transform: translateY(-2px);
}
.chart-col.now .chart-val {
  color: var(--green);
  opacity: 1;
}

.chart-bar {
  width: 100%;
  max-width: 28px;
  min-height: 2px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(to top, var(--accent), var(--purple));
  opacity: 0.9;
  transition: all 0.25s ease;
  position: relative;
}
.chart-col:hover .chart-bar {
  opacity: 1;
  transform: scaleY(1.04);
  transform-origin: bottom;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.45);
}
.chart-bar.empty {
  background: var(--border);
  opacity: 0.35;
  min-height: 2px;
}
.chart-bar.now {
  background: linear-gradient(to top, var(--green), #34d399);
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.55);
}
.chart-bar.peak {
  background: linear-gradient(to top, var(--yellow), #fbbf24);
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.5);
}

/* Tooltip no hover */
.chart-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--bg);
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
  font-family: var(--mono);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 5;
  box-shadow: var(--shadow-md);
}
.chart-tip b {
  color: var(--text);
  font-weight: 700;
}
.chart-tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--border-hover);
}
.chart-col:hover .chart-tip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Eixo X — todos os 24 horários */
.chart-x {
  display: flex;
  gap: 10px;
}
.chart-x-spacer {
  width: 44px;
}
.chart-x-labels {
  flex: 1;
  display: flex;
  gap: 3px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.chart-x-label {
  flex: 1;
  text-align: center;
  font-size: 10.5px;
  color: var(--text3);
  font-family: var(--mono);
  line-height: 1.4;
  padding: 4px 0;
  border-radius: 4px;
  transition: var(--transition);
}
.chart-x-label:hover {
  color: var(--text2);
  background: var(--bg4);
}
.chart-x-label.now {
  color: var(--green);
  font-weight: 800;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

@media (max-width: 900px) {
  .chart-x-label {
    font-size: 9px;
    padding: 3px 0;
  }
  .chart-x-label:nth-child(odd) {
    visibility: hidden;
  }
  .chart-x-label.now {
    visibility: visible !important;
  }
  .chart-bar {
    max-width: 18px;
  }
}

/* ============================================================
   Instâncias dashboard (chips + mini-cards)
   ============================================================ */
.text-green {
  color: var(--green) !important;
}
.text-yellow {
  color: var(--yellow) !important;
}
.text-red {
  color: var(--red) !important;
}

.chip-info {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--bg3);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text2);
}
.chip-info .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.inst-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.inst-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.4);
  font-size: 13px;
  color: var(--text2);
  transition: var(--transition);
  cursor: default;
}
.inst-chip.off {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.35);
  opacity: 0.75;
}
.inst-chip.travada {
  background: rgba(250, 204, 21, 0.1);
  border-color: rgba(250, 204, 21, 0.35);
}
.inst-chip:hover {
  transform: translateY(-2px) scale(1.02);
}
.inst-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text3);
}
.inst-chip .dot.on {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.inst-chip .dot.off {
  background: var(--red);
}
.inst-chip b {
  color: var(--text);
  font-weight: 700;
}
.inst-chip .chip-num {
  font-family: var(--mono);
  color: var(--text3);
  font-size: 12px;
}

.inst-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  padding: 18px;
}
.inst-mini {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.inst-mini:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.inst-mini.livre {
  background: linear-gradient(
    135deg,
    rgba(34, 197, 94, 0.06),
    rgba(34, 197, 94, 0.02)
  );
  border-color: rgba(34, 197, 94, 0.3);
}
.inst-mini.quase {
  background: linear-gradient(
    135deg,
    rgba(250, 204, 21, 0.08),
    rgba(250, 204, 21, 0.02)
  );
  border-color: rgba(250, 204, 21, 0.4);
}
.inst-mini.cheio {
  background: linear-gradient(
    135deg,
    rgba(239, 68, 68, 0.08),
    rgba(239, 68, 68, 0.02)
  );
  border-color: rgba(239, 68, 68, 0.35);
}
.inst-mini.off {
  background: rgba(148, 163, 184, 0.06);
  border-color: var(--border);
  opacity: 0.65;
}

.inst-mini-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.inst-mini-nome {
  font-weight: 700;
  color: var(--text);
  font-size: 14px;
}
.inst-mini-tag {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 4px 9px;
  border-radius: 6px;
  white-space: nowrap;
}
.inst-mini.livre .inst-mini-tag {
  color: var(--green);
  background: rgba(34, 197, 94, 0.15);
}
.inst-mini.quase .inst-mini-tag {
  color: #b45309;
  background: rgba(250, 204, 21, 0.2);
}
.inst-mini.cheio .inst-mini-tag {
  color: var(--red);
  background: rgba(239, 68, 68, 0.15);
}
.inst-mini.off .inst-mini-tag {
  color: var(--text3);
  background: rgba(148, 163, 184, 0.15);
}

.inst-mini-body {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.inst-mini-num {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.inst-mini-livres {
  font-size: 13px;
  color: var(--text2);
}
.inst-mini-livres strong {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text);
}

.inst-mini-bar {
  height: 5px;
  background: var(--bg4);
  border-radius: 4px;
  overflow: hidden;
}
.inst-mini-bar-fill {
  height: 100%;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 4px;
  position: relative;
}
.inst-mini-bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 2.4s infinite;
}
.inst-mini-bar-fill.green {
  background: linear-gradient(90deg, var(--green), #34d399);
}
.inst-mini-bar-fill.yellow {
  background: linear-gradient(90deg, var(--yellow), #fbbf24);
}
.inst-mini-bar-fill.red {
  background: linear-gradient(90deg, var(--red), #f87171);
}

.inst-mini-foot {
  font-size: 12px;
  color: var(--text2);
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.inst-mini-foot b {
  font-family: var(--mono);
  color: var(--text2);
  font-weight: 700;
}

/* ============================================================
   Live indicator
   ============================================================ */
.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  box-shadow: 0 0 10px var(--green);
  animation: pulse-dot 2s infinite;
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: linear-gradient(135deg, var(--bg3), var(--bg2));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 22px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  backdrop-filter: blur(12px);
}
.toast.show {
  transform: translateY(0);
  opacity: 1;
}
.toast.ok {
  border-color: var(--green-border);
  color: var(--green);
  box-shadow:
    var(--shadow-lg),
    0 0 30px rgba(34, 197, 94, 0.15);
}
.toast.err {
  border-color: var(--red-border);
  color: var(--red);
  box-shadow:
    var(--shadow-lg),
    0 0 30px rgba(239, 68, 68, 0.15);
}

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes slideRight {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.fade-in {
  animation: fadeIn 0s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.scale-in {
  animation: scaleIn 0s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.slide-in {
  animation: slideRight 0s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.fade-in-d1 {
  animation-delay: 0s;
}
.fade-in-d2 {
  animation-delay: 0s;
}
.fade-in-d3 {
  animation-delay: 0s;
}
.fade-in-d4 {
  animation-delay: 0;
}
.fade-in-d5 {
  animation-delay: 0s;
}

/* Stagger nos stat cards */
.stats .stat-card:nth-child(1) {
  animation: fadeIn 0.45s ease both;
  animation-delay: 0.03s;
}
.stats .stat-card:nth-child(2) {
  animation: fadeIn 0.45s ease both;
  animation-delay: 0.08s;
}
.stats .stat-card:nth-child(3) {
  animation: fadeIn 0.45s ease both;
  animation-delay: 0.13s;
}
.stats .stat-card:nth-child(4) {
  animation: fadeIn 0.45s ease both;
  animation-delay: 0.18s;
}
.stats .stat-card:nth-child(5) {
  animation: fadeIn 0.45s ease both;
  animation-delay: 0.23s;
}

/* ============================================================
   Two columns
   ============================================================ */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Modal
   ============================================================ */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal-box {
  background: linear-gradient(180deg, var(--bg2), rgba(19, 19, 31, 0.95));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ============================================================
   Login
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(
      circle at 20% 30%,
      rgba(99, 102, 241, 0.18),
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 70%,
      rgba(168, 85, 247, 0.15),
      transparent 50%
    ),
    var(--bg);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 440px;
  background: linear-gradient(180deg, var(--bg2), rgba(19, 19, 31, 0.85));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 44px 36px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  animation: scaleIn 0.4s ease;
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.login-logo h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.025em;
}
.login-logo h1 span {
  color: var(--accent2);
}
.login-logo p {
  font-size: 13px;
  color: var(--text3);
}

.login-form .form-group {
  margin-bottom: 18px;
}
.login-form .form-group label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 7px;
}
.login-form button {
  margin-top: 12px;
}

.login-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text3);
  font-size: 12px;
}

/* ============================================================
   Relatórios — tabela "Disparos por instância · janelas"
   ============================================================ */
.tbl-periodos thead tr:first-child th {
  border-bottom: 1px solid var(--border);
}
.tbl-periodos .th-grupo {
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 6px 6px;
}
.tbl-periodos .th-grupo.green {
  color: var(--green);
  background: rgba(34, 197, 94, 0.05);
}
.tbl-periodos .th-grupo.blue {
  color: var(--blue);
  background: rgba(59, 130, 246, 0.05);
}
.tbl-periodos .th-sub {
  text-align: right;
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  padding: 6px 10px;
}
.tbl-periodos td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 13px;
  padding-right: 14px;
}
.tbl-periodos tbody tr:hover {
  background: rgba(99, 102, 241, 0.04);
}
.tbl-periodos .tr-total {
  background: linear-gradient(
    180deg,
    rgba(99, 102, 241, 0.08),
    rgba(99, 102, 241, 0.03)
  );
  border-top: 2px solid var(--border-hover);
}
.tbl-periodos .tr-total td {
  padding-top: 12px;
  padding-bottom: 12px;
}
.tbl-periodos .tr-total td.num {
  font-size: 14px;
}

/* ============================================================
   Tooltips de ajuda — ícone "?" + bolha flutuante
   ============================================================ */

/* Ícone "?" inline (vai depois do label) */
.tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-left: 6px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.14);
  color: var(--accent2);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  cursor: help;
  border: 1px solid rgba(99, 102, 241, 0.35);
  transition:
    background 0.15s,
    color 0.15s,
    transform 0.15s,
    border-color 0.15s;
  vertical-align: middle;
  user-select: none;
  flex-shrink: 0;
}
.tip:hover,
.tip:focus {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: scale(1.15);
  outline: none;
}

/* Variação contextual */
.tip.warn {
  background: rgba(234, 179, 8, 0.14);
  color: var(--yellow);
  border-color: rgba(234, 179, 8, 0.4);
}
.tip.warn:hover {
  background: var(--yellow);
  color: #000;
  border-color: var(--yellow);
}

.tip.danger {
  background: rgba(239, 68, 68, 0.14);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.4);
}
.tip.danger:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

/* Qualquer elemento com [data-tip] dispara a bolha (botões, badges, status) */
[data-tip] {
  cursor: help;
}
button[data-tip],
a[data-tip] {
  cursor: pointer;
}

/* A bolha flutuante (única no body, posicionada via JS) */
.tooltip-bubble {
  position: fixed;
  z-index: 99999;
  max-width: 300px;
  min-width: 180px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #1e1e30 0%, #16162a 100%);
  color: var(--text);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.55;
  font-family: var(--font);
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(99, 102, 241, 0.15) inset;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition:
    opacity 0.14s ease,
    transform 0.14s ease;
  text-align: left;
  white-space: normal;
}
.tooltip-bubble.on {
  opacity: 1;
  transform: translateY(0);
}
.tooltip-bubble b,
.tooltip-bubble strong {
  color: var(--accent2);
  font-weight: 700;
}
.tooltip-bubble code {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 1px;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent2);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid rgba(99, 102, 241, 0.25);
}
.tooltip-bubble i,
.tooltip-bubble em {
  color: var(--text3);
  font-style: italic;
}
.tooltip-bubble small {
  display: block;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  color: var(--text3);
  font-size: 11px;
}

/* Setinha (CSS puro, gira conforme [data-arrow]) */
.tooltip-bubble::before {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  background: #1e1e30;
  border: 1px solid var(--border-hover);
  transform: rotate(45deg);
  left: 50%;
  margin-left: -5px;
}
.tooltip-bubble[data-arrow="down"]::before {
  bottom: -6px;
  border-top: 0;
  border-left: 0;
  background: #16162a;
}
.tooltip-bubble[data-arrow="up"]::before {
  top: -6px;
  border-bottom: 0;
  border-right: 0;
  background: #1e1e30;
}

@media (max-width: 720px) {
  .tooltip-bubble {
    max-width: calc(100vw - 24px);
  }
}

/* ============================================================
   Sidebar backdrop (mobile só)
   ============================================================ */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 39;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.sidebar-backdrop.on {
  opacity: 1;
  pointer-events: auto;
}
@media (max-width: 768px) {
  .sidebar-backdrop {
    display: block;
  }
}

/* ============================================================
   Mobile · revisão geral (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {
  /* ---------- Anti-overflow (filhos não podem empurrar a página) ---------- */
  .main,
  .content,
  .panel,
  .panel-body,
  .panel-header,
  .stats,
  .inst-grid,
  .inst-chips,
  .table-wrap,
  .chart-area,
  .chart-head,
  .config-grid {
    min-width: 0;
    max-width: 100%;
  }
  .table-wrap {
    overflow-x: auto;
  } /* tabela rola dentro do painel */
  img,
  video,
  canvas,
  svg {
    max-width: 100%;
    height: auto;
  }

  /* ---------- Layout / header ---------- */
  .content {
    padding: 14px;
    width: 100%;
    box-sizing: border-box;
  }
  .header {
    padding: 12px 14px;
    gap: 8px;
  }
  .header-left {
    gap: 10px;
    min-width: 0;
    flex: 1;
  }
  .header-title {
    font-size: 16px;
  }
  .header-sub {
    font-size: 11.5px;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
  }
  .header-right {
    gap: 6px;
    flex-shrink: 0;
  }
  .header-right > div:first-child {
    display: none;
  } /* "Sistema ativo" some */
  /* Botões do header global (Atualizar / Novo Disparo) */
  .header .header-right .header-btn {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 9px;
  }
  .header .header-right .header-btn:not(.primary) {
    display: none;
  } /* só o CTA fica */
  .header .header-right .header-btn.primary {
    padding: 8px 14px;
  }

  /* Botões dentro de painéis/topo da página: deixar quebrar e encolher */
  .panel-header {
    flex-wrap: wrap;
  }
  .panel-header .panel-actions,
  .panel-header > div {
    flex-wrap: wrap;
  }
  .panel-actions .header-btn,
  .panel-actions .btn-sm,
  .content > div .header-btn,
  .content > div .btn-sm {
    white-space: normal; /* deixa quebrar */
    font-size: 12.5px;
    padding: 8px 12px;
    flex: 0 1 auto;
    min-width: 0;
  }

  /* ---------- Stats: 2 por linha ---------- */
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
    margin-bottom: 16px;
  }
  .stat-card {
    padding: 14px 14px 16px;
    border-radius: 14px;
  }
  .stat-card .stat-icon {
    width: 34px;
    height: 34px;
    font-size: 15px;
    border-radius: 10px;
  }
  .stat-card .stat-value {
    font-size: 24px;
  }
  .stat-card .stat-label {
    font-size: 12px;
    margin-top: 6px;
    line-height: 1.3;
  }
  .stat-header {
    margin-bottom: 10px;
  }

  /* ---------- Painéis ---------- */
  .panel {
    border-radius: 14px;
    margin-bottom: 14px;
  }
  .panel-header {
    padding: 14px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .panel-title {
    font-size: 14.5px;
  }
  .panel-body {
    padding: 14px;
  }
  .panel-actions {
    width: 100%;
  }

  /* ---------- Instâncias mini cards: 2 por linha ---------- */
  .inst-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
    padding: 12px;
  }
  .inst-mini {
    padding: 10px 12px;
    border-radius: 10px;
    gap: 8px;
  }
  .inst-mini-nome {
    font-size: 13px;
  }
  .inst-mini-tag {
    font-size: 9.5px;
    padding: 3px 6px;
  }
  .inst-mini-num {
    font-size: 17px;
  }
  .inst-mini-livres {
    font-size: 12px;
  }
  .inst-mini-livres strong {
    font-size: 13px;
  }
  .inst-mini-foot {
    font-size: 11px;
    padding-top: 6px;
  }

  .inst-chips {
    padding: 10px 12px;
    gap: 6px;
  }
  .inst-chip {
    font-size: 12px;
    padding: 5px 10px;
    max-width: 100%;
    min-width: 0;
  }
  .inst-chip b {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 90px;
    display: inline-block;
    vertical-align: middle;
  }
  .inst-chip .chip-num {
    font-size: 11px;
  }

  /* Instance grid (página /instancias) — 1 por linha (cards densos) */
  .instances-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .instance-card {
    padding: 16px;
    border-radius: 14px;
  }

  /* ---------- Chart: scroll horizontal mantendo o tamanho ---------- */
  .chart-area {
    padding: 12px;
  }
  .chart-area-lg .chart-plot {
    height: 220px;
  }
  .chart-head {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .chart-stat {
    padding: 8px 10px;
  }
  .chart-stat-l {
    font-size: 10px;
  }
  .chart-stat-v b {
    font-size: 17px;
  }

  /* O wrapper rola na horizontal, eixos ficam preservados */
  .chart-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    margin: 0 -2px;
    padding-bottom: 2px;
  }
  .chart-scroll-inner {
    min-width: 640px; /* força largura legível, mas sem exagero */
  }
  .chart-scroll-hint {
    display: block;
  }
  /* Sobrescreve o "esconder labels ímpares" — agora cabem todos no scroll */
  .chart-x-label:nth-child(odd) {
    visibility: visible;
  }
  .chart-x-label {
    font-size: 10.5px;
    padding: 4px 0;
  }
  .chart-bar {
    max-width: 28px;
  }

  /* ---------- Mini stats (modais de import etc.) ---------- */
  .mini-stat {
    padding: 12px 12px;
  }
  .mini-stat-l {
    font-size: 11px;
  }
  .mini-stat-v {
    font-size: 22px;
  }

  /* ---------- Tabelas (já têm .table-wrap, só refinar) ---------- */
  thead th,
  tbody td {
    padding: 11px 12px;
    font-size: 13px;
  }
  .msg-preview {
    max-width: 220px;
  }

  /* ---------- Pager ---------- */
  .pager-btn {
    min-width: 32px;
    height: 32px;
    font-size: 12.5px;
    padding: 0 8px;
  }

  /* ---------- Forms ---------- */
  .config-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .config-input {
    font-size: 16px;
  } /* evita zoom do iOS */
  textarea.config-input {
    font-size: 14px;
  }

  /* ---------- Upload ---------- */
  .upload-area,
  .upload-zone {
    padding: 20px 14px;
    min-height: 110px;
  }
  .upload-icon {
    font-size: 32px;
    margin-bottom: 8px;
  }
  .upload-text {
    font-size: 13px;
  }
  .upload-sub {
    font-size: 11px;
  }

  /* ---------- Modal ---------- */
  .modal-bg {
    padding: 10px;
    align-items: flex-end;
  }
  .modal-box {
    max-height: 95vh;
    border-radius: 16px 16px 14px 14px;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .modal-head {
    padding: 14px 16px;
  }

  /* ---------- Toast ---------- */
  .toast {
    left: 14px;
    right: 14px;
    bottom: 14px;
    padding: 14px 16px;
    font-size: 13px;
  }

  /* ---------- Dias da semana ---------- */
  .dia-chk {
    padding: 8px 6px;
    font-size: 12px;
    min-width: 38px;
  }
}

/* Telas bem pequenas (≤ 380px): ainda 2 col, mas com mais respiro vertical */
@media (max-width: 380px) {
  .header-title {
    font-size: 15px;
  }
  .header-sub {
    display: none;
  }
  .stat-card .stat-value {
    font-size: 21px;
  }
  .stat-card .stat-label {
    font-size: 11.5px;
  }
  .inst-mini-num {
    font-size: 16px;
  }
  .chart-scroll-inner {
    min-width: 640px;
  }
}

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