/* ============================================================
   Eletrofrio · Dashboard de Notificações
   Tema claro · paleta da marca (navy #1B2E5C + cyan #00B5DC)
   ============================================================ */

:root {
  /* Marca Eletrofrio */
  --ef-navy: #1b2e5c;
  --ef-navy-strong: #122247;
  --ef-navy-soft: #2a3f75;
  --ef-cyan: #00b5dc;
  --ef-cyan-strong: #0095b8;
  --ef-cyan-soft: #e0f5fa;

  /* Superfícies */
  --ef-bg: #f4f6fb;
  --ef-bg-alt: #eef2f8;
  --ef-surface: #ffffff;
  --ef-surface-muted: #f8fafc;

  /* Bordas */
  --ef-border: #e2e8f0;
  --ef-border-strong: #cbd5e1;
  --ef-divider: #eef2f7;

  /* Texto */
  --ef-text: #1b2e5c;
  --ef-text-body: #475569;
  --ef-text-muted: #94a3b8;
  --ef-text-soft: #64748b;

  /* Semânticas */
  --ef-success: #16a34a;
  --ef-success-soft: #dcfce7;
  --ef-danger: #dc2626;
  --ef-danger-soft: #fee2e2;
  --ef-warn: #d97706;
  --ef-warn-soft: #fef3c7;
  --ef-purple: #7c3aed;
  --ef-purple-soft: #ede9fe;

  /* Sombras */
  --ef-shadow-sm: 0 1px 2px rgba(27, 46, 92, 0.06);
  --ef-shadow: 0 1px 3px rgba(27, 46, 92, 0.06), 0 4px 12px rgba(27, 46, 92, 0.04);
  --ef-shadow-lg: 0 4px 24px rgba(27, 46, 92, 0.08);
  --ef-shadow-focus: 0 0 0 3px rgba(0, 181, 220, 0.18);
}

/* === Reset & base === */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--ef-bg);
  color: var(--ef-text-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--ef-cyan-strong);
}

code {
  font-family: "SF Mono", Monaco, Consolas, "Courier New", monospace;
  font-size: 0.9em;
  background: var(--ef-bg-alt);
  color: var(--ef-navy);
  padding: 1px 6px;
  border-radius: 4px;
}

/* === Topbar === */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: var(--ef-surface);
  border-bottom: 1px solid var(--ef-border);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--ef-shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-logo {
  height: 44px;
  width: auto;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--ef-border);
  padding-left: 18px;
}

.brand h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
  color: var(--ef-navy);
  letter-spacing: 0.01em;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ef-text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 13px;
  color: var(--ef-text-body);
}

.refresh-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  color: var(--ef-text-body);
}

.refresh-toggle input {
  accent-color: var(--ef-cyan);
}

.last-update {
  color: var(--ef-text-muted);
  font-variant-numeric: tabular-nums;
}

/* Faixa de acento ciano (igual ao site do cliente) */
.topbar-accent {
  height: 4px;
  background: linear-gradient(90deg, var(--ef-cyan) 0%, var(--ef-cyan-strong) 60%, var(--ef-navy) 100%);
  position: sticky;
  top: 72px;
  z-index: 9;
}

/* === Layout === */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 32px 80px;
}

/* === KPIs === */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi {
  background: var(--ef-surface);
  border: 1px solid var(--ef-border);
  border-radius: 12px;
  padding: 18px 20px 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--ef-shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi:hover {
  transform: translateY(-1px);
  box-shadow: var(--ef-shadow-lg);
}

.kpi::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent, var(--ef-cyan));
}

.kpi-blue {
  --accent: var(--ef-cyan);
}

.kpi-green {
  --accent: var(--ef-success);
}

.kpi-red {
  --accent: var(--ef-danger);
}

.kpi-amber {
  --accent: var(--ef-warn);
}

.kpi-purple {
  --accent: var(--ef-purple);
}

.kpi-cyan {
  --accent: var(--ef-navy);
}

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ef-text-muted);
  font-weight: 600;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--ef-navy);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

/* === Filters === */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  background: var(--ef-surface);
  border: 1px solid var(--ef-border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: var(--ef-shadow);
}

.filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.filter label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ef-text-muted);
  font-weight: 600;
}

.filter input,
.filter select {
  background: var(--ef-surface);
  color: var(--ef-text);
  border: 1px solid var(--ef-border-strong);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.filter input:hover,
.filter select:hover {
  border-color: var(--ef-cyan);
}

.filter input:focus,
.filter select:focus {
  border-color: var(--ef-cyan);
  box-shadow: var(--ef-shadow-focus);
}

.btn-primary {
  background: linear-gradient(135deg, var(--ef-cyan) 0%, var(--ef-navy) 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s, filter 0.15s;
  letter-spacing: 0.02em;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 149, 184, 0.28);
  filter: brightness(1.05);
}

.btn-primary:active {
  transform: translateY(0);
}

/* === Table === */
.table-wrapper {
  background: var(--ef-surface);
  border: 1px solid var(--ef-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--ef-shadow);
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--ef-divider);
  background: var(--ef-surface-muted);
}

.table-header h2 {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
  color: var(--ef-navy);
}

.badge {
  background: var(--ef-cyan-soft);
  border: 1px solid rgba(0, 181, 220, 0.3);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--ef-navy);
  font-weight: 600;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 12px 16px;
  background: var(--ef-surface-muted);
  color: var(--ef-text-muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  font-weight: 700;
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--ef-border);
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--ef-divider);
  vertical-align: middle;
  color: var(--ef-text-body);
}

tbody tr {
  transition: background 0.1s;
}

tbody tr:hover {
  background: var(--ef-cyan-soft);
}

tbody tr:last-child td {
  border-bottom: none;
}

td.empty {
  text-align: center;
  color: var(--ef-text-muted);
  padding: 30px;
  font-style: italic;
}

/* === Status pill === */
.status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-enviado {
  background: var(--ef-success-soft);
  color: #15803d;
  border: 1px solid rgba(22, 163, 74, 0.3);
}

.status-pendente {
  background: var(--ef-warn-soft);
  color: #b45309;
  border: 1px solid rgba(217, 119, 6, 0.3);
}

.status-pendente_retry {
  background: var(--ef-purple-soft);
  color: #6d28d9;
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.status-falha {
  background: var(--ef-danger-soft);
  color: #b91c1c;
  border: 1px solid rgba(220, 38, 38, 0.3);
}

.status-falha_permanente {
  background: #fecaca;
  color: #991b1b;
  border: 1px solid rgba(185, 28, 28, 0.4);
}

.status-desconhecido {
  background: var(--ef-bg-alt);
  color: var(--ef-text-soft);
  border: 1px solid var(--ef-border-strong);
}

/* === Criticidade pill === */
.crit {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.crit-CRÍTICO,
.crit-CRITICO {
  background: var(--ef-danger-soft);
  color: #b91c1c;
}

.crit-ALTO {
  background: #ffedd5;
  color: #c2410c;
}

.crit-MEDIO {
  background: var(--ef-warn-soft);
  color: #b45309;
}

.crit-BAIXO {
  background: var(--ef-success-soft);
  color: #15803d;
}

.crit-N-A {
  background: var(--ef-bg-alt);
  color: var(--ef-text-soft);
}

.msg-preview {
  color: var(--ef-text-muted);
  font-style: italic;
  font-size: 12px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s;
}

.msg-preview:hover {
  color: var(--ef-cyan-strong);
}

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

/* === Footer === */
footer {
  text-align: center;
  padding: 18px;
  color: var(--ef-text-muted);
  font-size: 12px;
  border-top: 1px solid var(--ef-border);
  margin-top: 40px;
  background: var(--ef-surface);
}

/* === Modal === */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(27, 46, 92, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal[hidden] {
  display: none;
}

.modal-content {
  background: var(--ef-surface);
  border: 1px solid var(--ef-border);
  border-radius: 12px;
  max-width: 720px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--ef-shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--ef-divider);
  background: var(--ef-surface-muted);
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  color: var(--ef-navy);
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--ef-text-muted);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0 8px;
  transition: color 0.15s;
}

.modal-close:hover {
  color: var(--ef-navy);
}

.modal-content pre {
  margin: 0;
  padding: 20px;
  overflow: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: "SF Mono", Monaco, Consolas, "Courier New", monospace;
  font-size: 13px;
  color: var(--ef-text-body);
  line-height: 1.6;
  background: var(--ef-surface);
}

/* --- Modal de confirmacao --- */
.modal-confirm-content {
  max-width: 460px;
}

.modal-confirm-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-confirm-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 181, 220, 0.12);
  color: var(--ef-cyan, #00b5dc);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.modal-confirm-body {
  padding: 20px 22px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ef-text-body);
  background: var(--ef-surface);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--ef-divider);
  background: var(--ef-surface-muted);
}

.btn-modal-cancel,
.btn-modal-confirm {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}

.btn-modal-cancel {
  background: var(--ef-surface);
  color: var(--ef-text-body);
  border: 1px solid var(--ef-border);
}

.btn-modal-cancel:hover {
  background: var(--ef-surface-muted);
  border-color: var(--ef-navy);
  color: var(--ef-navy);
}

.btn-modal-confirm {
  background: var(--ef-navy, #1b2e5c);
  color: #fff;
  border: 1px solid var(--ef-navy, #1b2e5c);
}

.btn-modal-confirm:hover {
  filter: brightness(1.1);
}

.btn-modal-cancel:focus-visible,
.btn-modal-confirm:focus-visible {
  outline: 2px solid var(--ef-cyan, #00b5dc);
  outline-offset: 2px;
}

/* ============================================================
   === Responsive ===
   Breakpoints:
     - 1280px : compacta paddings (telas pequenas de desktop / iPad pro)
     - 1024px : tablet landscape (single col em kill switches j\u00e1 acontece em 900px)
     -  768px : mobile/tablet portrait (empilhamento geral)
     -  480px : mobile pequeno (KPIs em 1 col, esconde colunas extras)
   ============================================================ */

/* --- Desktop pequeno / iPad Pro --- */
@media (max-width: 1280px) {
  main {
    padding: 24px 24px 70px;
  }

  .topbar {
    padding: 14px 24px;
  }

  .tabbar {
    padding: 0 24px;
  }
}

/* --- Tablet landscape --- */
@media (max-width: 1024px) {
  main {
    padding: 22px 20px 60px;
  }

  .topbar {
    padding: 12px 20px;
  }

  .tabbar {
    padding: 0 20px;
    top: 70px;
  }

  .topbar-accent {
    top: 66px;
  }

  .filters {
    padding: 14px 16px;
  }

  .kpi {
    padding: 16px 18px;
  }

  .kpi-value {
    font-size: 26px;
  }

  .auto-card {
    padding: 20px 20px;
  }
}

/* --- Mobile / tablet portrait --- */
@media (max-width: 768px) {
  /* Desativa sticky no mobile para evitar overlap quando o topbar empilha
     (a altura cresce e quebraria a posi\u00e7\u00e3o sticky do tabbar/acento). */
  .topbar,
  .topbar-accent,
  .tabbar {
    position: static;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
  }

  .brand {
    gap: 14px;
    width: 100%;
  }

  .brand-logo {
    height: 38px;
  }

  .brand-text {
    border-left: none;
    padding-left: 0;
  }

  .brand h1 {
    font-size: 15px;
    line-height: 1.25;
  }

  .subtitle {
    font-size: 11px;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
  }

  /* Tabbar full-width, cada tab ocupa metade */
  .tabbar {
    padding: 0;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tabbar::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex: 1 1 0;
    justify-content: center;
    padding: 12px 12px;
    font-size: 13px;
    white-space: nowrap;
  }

  main {
    padding: 16px 14px 60px;
  }

  /* KPIs em 2 colunas no mobile */
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
  }

  .kpi {
    padding: 14px 14px 14px 16px;
  }

  .kpi-value {
    font-size: 22px;
  }

  .kpi-label {
    font-size: 10px;
  }

  /* Filtros empilhados */
  .filters {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 14px;
    gap: 10px;
  }

  .filter {
    min-width: 0;
    width: 100%;
  }

  /* Inputs com 16px previnem auto-zoom no iOS Safari */
  .filter input,
  .filter select,
  .form-row input,
  .form-row select,
  .form-row textarea {
    font-size: 16px;
  }

  .btn-primary {
    width: 100%;
    padding: 12px 18px;
  }

  /* Tabela: padding mais apertado + esconde colunas menos cr\u00edticas */
  .table-header {
    padding: 14px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .table-header h2 {
    font-size: 15px;
  }

  thead th,
  tbody td {
    padding: 10px 12px;
    font-size: 12px;
  }

  thead th {
    font-size: 10px;
  }

  /* Esconde: Telefone (col 6) e Tentativas (col 8). Resto rola horizontal se precisar. */
  thead th:nth-child(6),
  tbody td:nth-child(6),
  thead th:nth-child(8),
  tbody td:nth-child(8) {
    display: none;
  }

  .msg-preview {
    max-width: 180px;
  }

  /* Auto card */
  .auto-card {
    padding: 18px 16px;
    margin-bottom: 16px;
  }

  .auto-card-header h2 {
    font-size: 15px;
  }

  .auto-card-sub {
    font-size: 12px;
    line-height: 1.5;
  }

  .kill-switches-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .ks-tile {
    padding: 16px 16px;
    gap: 10px;
  }

  .ks-tile-head {
    gap: 12px;
  }

  .ks-icon {
    width: 42px;
    height: 42px;
    font-size: 18px;
    border-radius: 10px;
  }

  .ks-title {
    font-size: 14px;
  }

  .ks-help {
    font-size: 11.5px;
  }

  .btn-ks {
    padding: 11px 14px;
    font-size: 13px;
  }

  /* Modal: vira bottom-sheet no mobile */
  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-content {
    max-width: 100%;
    max-height: 92vh;
    border-radius: 14px 14px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-content pre {
    padding: 16px;
    font-size: 12.5px;
  }

  /* Footer mais compacto */
  footer {
    padding: 14px;
    font-size: 11px;
  }
}

/* --- Mobile pequeno (\u22a4 480px) --- */
@media (max-width: 480px) {
  .brand-logo {
    height: 34px;
  }

  .brand h1 {
    font-size: 14px;
  }

  .subtitle {
    display: none;
  }

  .topbar-right {
    font-size: 11px;
  }

  .last-update {
    text-align: right;
  }

  /* Tabs ainda menores */
  .tab {
    font-size: 12px;
    padding: 11px 10px;
    gap: 6px;
  }

  /* KPIs em 1 coluna */
  .kpis {
    grid-template-columns: 1fr;
  }

  /* Esconde mais uma coluna na tabela: Alarme (col 4) */
  thead th:nth-child(4),
  tbody td:nth-child(4) {
    display: none;
  }

  .msg-preview {
    max-width: 140px;
  }

  .badge {
    font-size: 11px;
    padding: 3px 10px;
  }

  /* KS tile ainda mais compacto */
  .ks-icon {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }
}

/* --- Prefer\u00eancia de movimento reduzido --- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* === Tabbar === */
.tabbar {
  display: flex;
  gap: 6px;
  padding: 0 32px;
  background: var(--ef-surface);
  border-bottom: 1px solid var(--ef-border);
  position: sticky;
  top: 76px;
  z-index: 8;
  box-shadow: var(--ef-shadow-sm);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--ef-text-body);
  border: none;
  border-bottom: 3px solid transparent;
  padding: 14px 18px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.tab:hover {
  color: var(--ef-navy);
  background: var(--ef-cyan-soft);
}

.tab-active {
  color: var(--ef-navy);
  border-bottom-color: var(--ef-cyan);
  background: rgba(0, 181, 220, 0.06);
}

.tab-icon {
  font-size: 16px;
}

/* === Views (aba ativa) === */
.view {
  display: none;
}

.view-active {
  display: block;
}

.view[hidden] {
  display: none;
}

/* === Automation Center === */
.auto-card {
  background: var(--ef-surface);
  border: 1px solid var(--ef-border);
  border-radius: 12px;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--ef-shadow);
  margin-bottom: 20px;
}

.auto-card-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--ef-navy);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.auto-card-sub {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--ef-text-body);
  line-height: 1.55;
}

.auto-card-sub code,
.auto-card-sub strong {
  color: var(--ef-navy);
}

.muted-tag {
  font-size: 11px;
  font-weight: 500;
  background: var(--ef-bg-alt);
  color: var(--ef-text-soft);
  border: 1px solid var(--ef-border);
  border-radius: 999px;
  padding: 3px 10px;
  font-family: "SF Mono", Monaco, Consolas, monospace;
}

.form-result {
  margin: 0;
  padding: 12px 14px;
  background: var(--ef-surface-muted);
  border: 1px solid var(--ef-border);
  border-radius: 8px;
  font-family: "SF Mono", Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--ef-text-body);
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.form-result.ok {
  border-color: rgba(22, 163, 74, 0.4);
  background: var(--ef-success-soft);
  color: #15803d;
}

.form-result.error {
  border-color: rgba(220, 38, 38, 0.4);
  background: var(--ef-danger-soft);
  color: #b91c1c;
}

/* === Kill Switches (hero card) === */
.kill-switches-card {
  background: linear-gradient(135deg, #ffffff 0%, var(--ef-cyan-soft) 100%);
  border: 1px solid rgba(0, 181, 220, 0.25);
}

.kill-switches-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .kill-switches-grid {
    grid-template-columns: 1fr;
  }
}

.ks-tile {
  background: var(--ef-surface);
  border: 1px solid var(--ef-border);
  border-radius: 12px;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  box-shadow: var(--ef-shadow-sm);
}

.ks-tile::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--tile-accent, var(--ef-success));
  transition: background 0.2s;
}

.ks-tile[data-state="active"] {
  --tile-accent: var(--ef-success);
}

.ks-tile[data-state="paused"] {
  --tile-accent: var(--ef-danger);
  background: #fff5f5;
  border-color: rgba(220, 38, 38, 0.25);
}

.ks-tile-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ks-icon {
  font-size: 22px;
  line-height: 1;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--ef-cyan) 0%, var(--ef-navy) 100%);
  border-radius: 12px;
  color: #ffffff;
  flex-shrink: 0;
}

.ks-tile-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ks-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ef-navy);
}

.ks-sub {
  font-size: 11px;
  color: var(--ef-text-muted);
  font-family: "SF Mono", Monaco, Consolas, monospace;
}

.ks-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ks-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ef-success);
  box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7);
  animation: ks-pulse 1.6s infinite;
}

.ks-tile[data-state="paused"] .ks-dot {
  background: var(--ef-danger);
  box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
}

@keyframes ks-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.55);
  }

  70% {
    box-shadow: 0 0 0 8px rgba(22, 163, 74, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0);
  }
}

.ks-tile[data-state="paused"] .ks-dot {
  animation-name: ks-pulse-red;
}

@keyframes ks-pulse-red {
  0% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.55);
  }

  70% {
    box-shadow: 0 0 0 8px rgba(220, 38, 38, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
  }
}

.ks-status-text {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ef-success);
}

.ks-tile[data-state="paused"] .ks-status-text {
  color: var(--ef-danger);
}

.ks-help {
  margin: 0;
  font-size: 12px;
  color: var(--ef-text-body);
  line-height: 1.55;
}

.btn-ks {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
  letter-spacing: 0.02em;
}

.btn-ks:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-ks:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-ks-icon {
  font-size: 14px;
  line-height: 1;
}

.btn-ks-pause {
  background: var(--ef-warn-soft);
  color: #b45309;
  border-color: rgba(217, 119, 6, 0.4);
}

.btn-ks-pause:hover:not(:disabled) {
  background: #fde68a;
  border-color: rgba(217, 119, 6, 0.6);
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.2);
}

.btn-ks-resume {
  background: linear-gradient(135deg, var(--ef-cyan) 0%, var(--ef-navy) 100%);
  color: #ffffff;
  border-color: var(--ef-cyan-strong);
}

.btn-ks-resume:hover:not(:disabled) {
  filter: brightness(1.05);
  box-shadow: 0 4px 14px rgba(0, 149, 184, 0.3);
}

/* Scrollbar suave (WebKit) */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: var(--ef-bg-alt);
}

*::-webkit-scrollbar-thumb {
  background: var(--ef-border-strong);
  border-radius: 6px;
  border: 2px solid var(--ef-bg-alt);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--ef-cyan);
}

/* ============================================================
   === Viewport-pinned layout (desktop >= 769px) ===
   O corpo da pagina NAO rola: o cabecalho, KPIs, filtros e
   o titulo da tabela ficam fixos. Apenas o conteudo da tabela
   (tbody) rola internamente, e o <thead> sticky acompanha.
   No mobile (<=768px) a pagina rola normalmente, preservando
   o comportamento existente.
   ============================================================ */
@media (min-width: 769px) {
  html,
  body {
    height: 100%;
  }

  body {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  main {
    flex: 1 1 auto;
    min-height: 0;            /* permite que o conteudo encolha dentro do flex */
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .view {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }

  .table-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .table-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;           /* x e y: scroll vertical do tbody + scroll horizontal no responsivo */
  }

  /* Reduz padding inferior ja que nao ha mais rolagem de pagina */
  main {
    padding-bottom: 16px;
  }

  /* Destaque do thead sticky quando o usuario rola a tabela */
  thead th {
    box-shadow: 0 1px 0 var(--ef-border);
  }
}
