/* ============================================================
   botzap - Painel de gestao (Nortex Tecnologia)
   Vanilla CSS, sem build. Dark-mode aware. Marca: azul profundo / teal.
   ============================================================ */

/* ---------- Tokens de cor ---------- */
:root {
  color-scheme: dark light;

  /* Marca */
  --brand-teal: #2fb8ea;
  --brand-teal-strong: #17a2db;
  --brand-navy: #0c1a2e;
  --brand-navy-soft: #122441;

  /* Status */
  --ok: #22c55e;
  --ok-soft: #16311f;
  --warn: #f59e0b;
  --warn-soft: #3a2c0c;
  --danger: #ef4444;
  --danger-soft: #3a1416;
  --danger-text: #ff8d8d;

  /* Radii / sombras / espacos */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.18), 0 1px 3px rgba(0,0,0,.12);
  --shadow-2: 0 8px 24px rgba(0,0,0,.28);
  --gutter: 16px;

  --maxw: 1240px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, "Liberation Mono", monospace;
}

/* Tema escuro (padrao) */
:root,
:root[data-theme="dark"] {
  --bg: #0a1420;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(47,184,234,.08), transparent 60%),
             radial-gradient(900px 500px at -10% 10%, rgba(18,36,65,.55), transparent 55%);
  --surface: #0f1d30;
  --surface-2: #13243b;
  --surface-3: #18304d;
  --surface-hover: #1a3250;
  --border: #203757;
  --border-strong: #2b4a73;
  --text: #e8eef6;
  --text-dim: #9fb2cb;
  --text-faint: #6c829e;
  --accent: var(--brand-teal);
  --accent-contrast: #04121f;
  --input-bg: #0c1a2c;
  --row-hover: rgba(47,184,234,.06);
}

/* Tema claro */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2f7;
  --bg-grad: radial-gradient(1200px 600px at 85% -10%, rgba(47,184,234,.12), transparent 60%),
             radial-gradient(900px 500px at -10% 5%, rgba(12,26,46,.06), transparent 55%);
  --surface: #ffffff;
  --surface-2: #f4f7fb;
  --surface-3: #eaf0f7;
  --surface-hover: #e8f1f8;
  --border: #d7e0ec;
  --border-strong: #bccbde;
  --text: #0c1a2e;
  --text-dim: #4a5b72;
  --text-faint: #7488a1;
  --accent: var(--brand-teal-strong);
  --accent-contrast: #ffffff;
  --input-bg: #ffffff;
  --row-hover: rgba(23,162,219,.07);
  --ok-soft: #e3f7ea;
  --warn-soft: #fdf1da;
  --danger-soft: #fde7e8;
  --danger-text: #c0303a;
  --shadow-1: 0 1px 2px rgba(16,40,70,.06), 0 1px 3px rgba(16,40,70,.08);
  --shadow-2: 0 10px 30px rgba(16,40,70,.12);
}

/* Segue o SO quando nenhum tema foi escolhido manualmente */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #eef2f7; --surface: #ffffff; --surface-2: #f4f7fb; --surface-3: #eaf0f7;
    --surface-hover: #e8f1f8; --border: #d7e0ec; --border-strong: #bccbde;
    --text: #0c1a2e; --text-dim: #4a5b72; --text-faint: #7488a1;
    --accent: var(--brand-teal-strong); --accent-contrast: #ffffff; --input-bg: #ffffff;
    --row-hover: rgba(23,162,219,.07);
  }
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; }
img { display: block; max-width: 100%; }
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.mono { font-family: var(--mono); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Spinner / boot ---------- */
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
.spinner--sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.boot {
  min-height: 70vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; text-align: center; padding: 40px var(--gutter);
}
.boot__logo { width: 180px; opacity: .9; }
.boot__txt { color: var(--text-dim); margin: 0; }
:root[data-theme="light"] .boot__logo,
:root:not([data-theme]) .boot__logo { content: url("nortex-logo-dark.png"); }

/* ---------- App shell ---------- */
.app { min-height: 100vh; }
.shell { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter) 64px; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding: 10px var(--gutter);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; flex-shrink: 0; }
.brand__logo { height: 26px; width: auto; }
:root[data-theme="light"] .brand__logo--light,
:root:not([data-theme]) .brand__logo--light { display: block; }
:root[data-theme="light"] .brand__logo--dark,
:root:not([data-theme]) .brand__logo--dark { display: none; }
.brand__logo--light { display: none; }
.brand__tag {
  font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
  padding: 2px 8px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav__link {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: var(--r-sm);
  color: var(--text-dim); text-decoration: none; font-weight: 600; font-size: 13px;
  border: 1px solid transparent; white-space: nowrap;
}
.nav__link:hover { background: var(--surface-hover); color: var(--text); }
.nav__link.is-active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 28%, transparent); }
.nav__link i { width: 16px; height: 16px; }

.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }

/* SSE / connection pill */
.conn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-dim);
}
.conn__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.conn[data-state="online"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.conn[data-state="online"] .conn__dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); animation: pulse 2s ease-in-out infinite; }
.conn[data-state="connecting"] { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.conn[data-state="connecting"] .conn__dot { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
.conn[data-state="offline"] { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.conn[data-state="offline"] .conn__dot { background: var(--danger); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
.conn i { width: 14px; height: 14px; }

/* ---------- Botoes ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: 13px; line-height: 1; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .04s, opacity .12s;
  user-select: none;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn i { width: 16px; height: 16px; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn--primary:hover { background: var(--brand-teal-strong); border-color: var(--brand-teal-strong); }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn--danger:hover { background: var(--danger-soft); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn--ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn--sm { padding: 6px 10px; font-size: 12px; }
.btn--icon { padding: 8px; }
.btn--block { width: 100%; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 12px; font-weight: 600; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.field__hint { font-size: 11.5px; color: var(--text-faint); }
.field__error { font-size: 12px; color: var(--danger-text); display: none; align-items: center; gap: 5px; }
.field.is-invalid .field__error { display: flex; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > i.lead { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--text-faint); pointer-events: none; }
.input {
  width: 100%; padding: 10px 12px; border-radius: var(--r-sm);
  background: var(--input-bg); border: 1px solid var(--border);
  color: var(--text); font-size: 14px; font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
.input-wrap > i.lead + .input { padding-left: 36px; }
.input::placeholder { color: var(--text-faint); }
.input:hover { border-color: var(--border-strong); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.field.is-invalid .input { border-color: var(--danger); }
.field.is-invalid .input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }
.field.is-valid .input { border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); }
.input--mono { font-family: var(--mono); font-size: 12.5px; }
.input-wrap .ok-check {
  position: absolute; right: 11px; width: 16px; height: 16px; color: var(--ok); display: none;
}
.field.is-valid .input-wrap .ok-check { display: block; }

/* Dropdown custom (sem <select> nativo) */
.dd { position: relative; }
.dd__btn {
  width: 100%; display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: var(--r-sm); cursor: pointer;
  background: var(--input-bg); border: 1px solid var(--border); color: var(--text);
  font-size: 13px; font-weight: 500; text-align: left;
}
.dd__btn:hover { border-color: var(--border-strong); }
.dd__btn[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.dd__btn .dd__val { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd__btn .dd__val.is-placeholder { color: var(--text-faint); }
.dd__btn .chev { width: 15px; height: 15px; color: var(--text-faint); transition: transform .14s; }
.dd__btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.dd__lead { width: 15px; height: 15px; color: var(--text-faint); flex-shrink: 0; }
.dd__menu {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 100%;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-2); padding: 5px;
  z-index: 50; max-height: 300px; overflow: auto; display: none;
}
.dd.is-open .dd__menu { display: block; animation: ddin .12s ease; }
@keyframes ddin { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.dd__opt {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer;
  background: transparent; border: 0; color: var(--text); font-size: 13px; text-align: left;
}
.dd__opt:hover, .dd__opt.is-active { background: var(--surface-hover); }
.dd__opt .tick { width: 15px; height: 15px; margin-left: auto; color: var(--accent); opacity: 0; }
.dd__opt[aria-selected="true"] .tick { opacity: 1; }
.dd__opt .swatch { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* Toggle custom (sem checkbox nativo) */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch__track {
  width: 38px; height: 22px; border-radius: 999px; background: var(--surface-3);
  border: 1px solid var(--border-strong); position: relative; transition: background .14s, border-color .14s; flex-shrink: 0;
}
.switch__thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-dim); transition: transform .16s, background .14s;
}
.switch[aria-checked="true"] .switch__track { background: color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
.switch[aria-checked="true"] .switch__thumb { transform: translateX(16px); background: var(--accent); }
.switch__label { font-size: 13px; color: var(--text-dim); font-weight: 600; }

/* ---------- Cards / layout util ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.card__head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card__title { font-size: 15px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 9px; }
.card__title i { width: 18px; height: 18px; color: var(--accent); }
.card__body { padding: 18px; }

.page-head {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
  padding: 22px 0 18px;
}
.page-title { font-size: 22px; font-weight: 800; margin: 0; letter-spacing: -.3px; }
.page-sub { color: var(--text-dim); margin: 3px 0 0; font-size: 13px; }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Status dot ---------- */
.sdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.sdot--open { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
.sdot--connecting { background: var(--warn); box-shadow: 0 0 0 4px color-mix(in srgb, var(--warn) 20%, transparent); animation: pulse 1.2s ease-in-out infinite; }
.sdot--close { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 18%, transparent); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .2px;
  border: 1px solid var(--border);
}
.badge--open { color: var(--ok); background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.badge--connecting { color: var(--warn); background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.badge--close { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }

/* ---------- Dashboard grid ---------- */
.inst-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}
.inst-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); padding: 16px; cursor: pointer; text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 14px; transition: border-color .14s, transform .08s, box-shadow .14s;
}
.inst-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); transform: translateY(-2px); box-shadow: var(--shadow-2); }
.inst-card__top { display: flex; align-items: flex-start; gap: 10px; }
.inst-card__name { font-size: 15.5px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 8px; min-width: 0; }
.inst-card__name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inst-card__evo { font-size: 11.5px; color: var(--text-faint); font-family: var(--mono); margin-top: 2px; }
.inst-card__phone { display: flex; align-items: center; gap: 7px; color: var(--text-dim); font-size: 13px; }
.inst-card__phone i { width: 15px; height: 15px; color: var(--text-faint); }
.inst-card__phone .tnum { letter-spacing: .2px; }
.inst-card__stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.stat {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 9px 10px; text-align: center;
}
.stat__num { font-size: 19px; font-weight: 800; line-height: 1.1; }
.stat__lbl { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; margin-top: 2px; }
.stat--err .stat__num { color: var(--danger); }
.stat--err.is-zero .stat__num { color: var(--text); }
.inst-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text-faint); font-size: 11.5px; }
.inst-card__foot .live-flash { color: var(--accent); }

/* ---------- Instance detail ---------- */
.detail-grid { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; align-items: start; }
.detail-grid .span-2 { grid-column: 1 / -1; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; align-items: center; }
.kv dt { color: var(--text-faint); font-size: 12px; font-weight: 600; }
.kv dd { margin: 0; font-size: 13.5px; }

/* QR */
.qr-box {
  display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
  padding: 10px 0;
}
.qr-frame {
  width: 260px; height: 260px; max-width: 72vw; max-height: 72vw;
  border-radius: var(--r-md); border: 1px solid var(--border);
  background: #fff; padding: 12px; display: flex; align-items: center; justify-content: center;
  position: relative;
}
.qr-frame img { width: 100%; height: 100%; image-rendering: pixelated; }
.qr-frame--empty { background: var(--surface-2); border-style: dashed; color: var(--text-faint); flex-direction: column; gap: 10px; }
.qr-frame--empty i { width: 46px; height: 46px; }
.qr-hint { color: var(--text-dim); font-size: 13px; max-width: 300px; }
.qr-hint b { color: var(--text); }
.connected-ok { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px 0; text-align: center; }
.connected-ok .big-ic { width: 56px; height: 56px; color: var(--ok); }

.webhook-row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: start; margin-bottom: 12px; }
.webhook-row__key { display: flex; align-items: center; gap: 8px; padding-top: 10px; font-size: 13px; font-weight: 600; color: var(--text-dim); }
.webhook-row__key i { width: 15px; height: 15px; color: var(--accent); }

/* ---------- Logs ---------- */
.filterbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow-1);
}
.filterbar .field { min-width: 150px; }
.filterbar .field--grow { flex: 1 1 220px; }
.filterbar__actions { display: flex; gap: 8px; align-items: flex-end; margin-left: auto; }

.logs-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); overflow: hidden;
}
.logs-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.logs-toolbar__count { font-size: 12.5px; color: var(--text-dim); font-weight: 600; }
.logs-toolbar__spacer { flex: 1; }
.new-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px;
  background: var(--accent); color: var(--accent-contrast); font-size: 12px; font-weight: 700;
  cursor: pointer; border: 0; animation: ddin .15s ease;
}
.new-pill i { width: 14px; height: 14px; }

.logs-scroll { max-height: calc(100vh - 290px); min-height: 280px; overflow: auto; }
.detail-logs .logs-scroll { max-height: 420px; }

table.logs { width: 100%; border-collapse: collapse; font-size: 13px; }
table.logs thead th {
  position: sticky; top: 0; z-index: 2; text-align: left;
  background: var(--surface-3); color: var(--text-dim);
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700;
  padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.logs tbody td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.logs tbody tr { transition: background .1s; }
table.logs tbody tr:hover { background: var(--row-hover); }
table.logs tbody tr.row-new { animation: rowin .5s ease; }
@keyframes rowin { from { background: color-mix(in srgb, var(--accent) 16%, transparent); } to { background: transparent; } }

.col-time { white-space: nowrap; color: var(--text-dim); width: 1%; }
.col-inst { white-space: nowrap; }
.col-dir { width: 1%; text-align: center; }
.col-type { white-space: nowrap; }
.col-part { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.col-resumo { color: var(--text-dim); max-width: 420px; }
.col-resumo .resumo-txt { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-status { width: 1%; text-align: center; }

.dir-ic { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 6px; }
.dir-ic i { width: 15px; height: 15px; }
.dir-in { color: var(--brand-teal); background: color-mix(in srgb, var(--brand-teal) 14%, transparent); }
.dir-out { color: #a98bff; background: color-mix(in srgb, #a98bff 15%, transparent); }

.type-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 11.5px; font-weight: 600; color: var(--text-dim);
}
.type-chip i { width: 13px; height: 13px; }

.st-ic i { width: 17px; height: 17px; }
.st-ok { color: var(--ok); }
.st-erro { color: var(--danger); }

tr.is-error td { background: var(--danger-soft); }
tr.is-error:hover td { background: color-mix(in srgb, var(--danger) 18%, transparent); }
tr.is-error { cursor: pointer; }
tr.err-detail td { padding: 0; }
.err-panel {
  padding: 12px 14px 14px 48px; background: color-mix(in srgb, var(--danger) 10%, transparent);
  border-bottom: 1px solid var(--border);
}
.err-panel__lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--danger-text); font-weight: 700; margin-bottom: 5px; display: flex; align-items: center; gap: 6px; }
.err-panel pre {
  margin: 0; font-family: var(--mono); font-size: 12px; color: var(--text);
  white-space: pre-wrap; word-break: break-word; background: var(--input-bg);
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px; max-height: 240px; overflow: auto;
}
.err-panel .meta { margin-top: 8px; font-size: 11.5px; color: var(--text-faint); display: flex; gap: 16px; flex-wrap: wrap; }

.load-more { padding: 14px; text-align: center; border-top: 1px solid var(--border); }

/* ---------- Empty / error / loading states ---------- */
.state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; text-align: center; padding: 48px 20px; color: var(--text-dim);
}
.state i.state__ic { width: 42px; height: 42px; color: var(--text-faint); }
.state__title { font-size: 16px; font-weight: 700; color: var(--text); margin: 0; }
.state__msg { margin: 0; max-width: 420px; font-size: 13.5px; }
.state--error i.state__ic { color: var(--danger); }
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-card { height: 180px; border-radius: var(--r-lg); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px var(--gutter);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: 30px 28px 26px; text-align: center;
}
.login-card__logo { width: 168px; margin: 0 auto 6px; }
:root[data-theme="light"] .login-card__logo,
:root:not([data-theme]) .login-card__logo { content: url("nortex-logo-dark.png"); }
.login-card h1 { font-size: 18px; margin: 10px 0 2px; font-weight: 800; }
.login-card p.sub { color: var(--text-dim); font-size: 13px; margin: 0 0 22px; }
.login-card .field { text-align: left; }
.login-card .btn { margin-top: 16px; }
.login-err {
  display: none; align-items: center; gap: 8px; justify-content: center;
  margin-top: 14px; padding: 9px 12px; border-radius: var(--r-sm);
  background: var(--danger-soft); color: var(--danger-text); font-size: 13px; font-weight: 600;
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}
.login-err.show { display: flex; }
.login-err i { width: 16px; height: 16px; }
.login-foot { margin-top: 20px; font-size: 11.5px; color: var(--text-faint); }

/* ---------- Modal (overlay e card IRMAOS) ---------- */
.modal-layer { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-layer[hidden] { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4,10,18,.40);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  animation: fade .14s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative; z-index: 1; width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: 22px;
  animation: pop .16s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-card__ic { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.modal-card__ic i { width: 22px; height: 22px; }
.modal-card__ic--warn { background: var(--warn-soft); color: var(--warn); }
.modal-card__ic--danger { background: var(--danger-soft); color: var(--danger); }
.modal-card__ic--accent { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.modal-card h3 { margin: 0 0 6px; font-size: 17px; font-weight: 800; }
.modal-card p { margin: 0; color: var(--text-dim); font-size: 13.5px; }
.modal-card__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ---------- Toasts ---------- */
.toast-layer { position: fixed; right: 16px; bottom: 16px; z-index: 120; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 360px;
  padding: 12px 14px; border-radius: var(--r-md); box-shadow: var(--shadow-2);
  background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text);
  font-size: 13.5px; font-weight: 500; pointer-events: auto; animation: toastin .2s ease;
}
@keyframes toastin { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.toast.out { animation: toastout .2s ease forwards; }
@keyframes toastout { to { opacity: 0; transform: translateX(16px); } }
.toast i { width: 18px; height: 18px; flex-shrink: 0; }
.toast--ok { border-left: 3px solid var(--ok); }
.toast--ok i { color: var(--ok); }
.toast--err { border-left: 3px solid var(--danger); }
.toast--err i { color: var(--danger); }
.toast--info { border-left: 3px solid var(--accent); }
.toast--info i { color: var(--accent); }

/* ---------- Net banner ---------- */
.net-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  background: var(--danger); color: #fff; font-size: 13px; font-weight: 600;
  padding: 8px 14px; animation: fade .2s ease;
}
.net-banner[hidden] { display: none; }
.net-banner i { width: 16px; height: 16px; }

/* ---------- Responsivo ---------- */
@media (max-width: 860px) {
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .topbar__inner { flex-wrap: wrap; gap: 10px; }
  .nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
  .nav__link { flex: 1; justify-content: center; }
  .brand__tag { display: none; }
  .conn span.conn__txt { display: none; }
  .conn { padding: 7px; }
  .page-title { font-size: 19px; }
  .webhook-row { grid-template-columns: 1fr; gap: 6px; }
  .webhook-row__key { padding-top: 0; }
  .filterbar__actions { margin-left: 0; width: 100%; }
  .filterbar .field { min-width: 0; flex: 1 1 140px; }
  .col-resumo { max-width: 180px; }
  .logs-scroll { max-height: calc(100vh - 340px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
