/* Painel Cloakilio — console de rotação de links
   Identidade "mesa de sinal": slate-navy, accent índigo, status semântico. */

@import url('https://fonts.googleapis.com/css2?family=Inter+Tight:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* superfícies */
  --bg:         #0b0f14;
  --surface:    #121821;
  --surface-2:  #0d131b;   /* insets, inputs */
  --surface-3:  #1a2330;   /* hover */
  --line:       #243041;
  --line-soft:  #19212d;

  /* texto */
  --text:       #e6edf6;
  --text-dim:   #97a6ba;
  --text-faint: #5f7084;

  /* marca / interação */
  --accent:     #6d7cff;
  --accent-bright: #8b95ff;
  --accent-wash: rgba(109,124,255,.14);
  --accent-line: rgba(109,124,255,.45);

  /* status semântico */
  --ok:    #34d399;  --ok-wash:   rgba(52,211,153,.13);  --ok-line:   rgba(52,211,153,.32);
  --warn:  #fbbf24;  --warn-wash: rgba(251,191,36,.12);  --warn-line: rgba(251,191,36,.30);
  --err:   #fb7185;  --err-wash:  rgba(251,113,133,.13); --err-line:  rgba(251,113,133,.32);

  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sans: 'Inter Tight', -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif;

  --rail-w: 232px;
  --r-card: 14px;
  --r-ctrl: 9px;
  --shadow-pop: 0 24px 60px -18px rgba(0,0,0,.72), 0 0 0 1px var(--line);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { font-size: 15px; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.006em;
}
a { color: var(--accent-bright); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, .mono { font-family: var(--mono); }
code {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.82em;
  color: #cdd8e6;
  overflow-wrap: anywhere;
}

/* ---------- shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  background: linear-gradient(180deg, #0e141c, #0a0e13);
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 6px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 8px 16px;
}
.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: radial-gradient(120% 120% at 30% 20%, #2a3550, #12192a);
  border: 1px solid var(--accent-line);
  color: var(--accent-bright);
  flex: none;
}
.brand-name { font-weight: 600; font-size: 0.98rem; letter-spacing: -0.02em; }
.brand-sub  { font-size: 0.72rem; color: var(--text-faint); margin-top: 1px; }

nav { display: flex; flex-direction: column; gap: 3px; }
nav button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text-dim);
  border: none;
  padding: 9px 11px;
  border-radius: var(--r-ctrl);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background .14s ease, color .14s ease;
}
nav button svg { width: 18px; height: 18px; flex: none; opacity: .82; }
nav button:hover { background: var(--surface-3); color: var(--text); }
nav button.active {
  background: var(--accent-wash);
  color: #eef0ff;
  box-shadow: inset 0 0 0 1px var(--accent-line);
}
nav button.active svg { opacity: 1; color: var(--accent-bright); }

.rail-foot { margin-top: auto; padding-top: 14px; }
.rail-health {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 11px;
  border-radius: var(--r-ctrl);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  font-size: 0.8rem;
  color: var(--text-dim);
}
.rail-health .dot { flex: none; }
.rail-health b { color: var(--text); font-weight: 600; }

/* ---------- content ---------- */
.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 18px 28px;
  background: rgba(11,15,20,.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
#page-title { margin: 0; font-size: 1.22rem; font-weight: 600; letter-spacing: -0.025em; }
.page-sub { margin: 2px 0 0; font-size: 0.85rem; color: var(--text-dim); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

main { padding: 24px 28px 56px; max-width: 1160px; width: 100%; }
.tab { display: none; animation: rise .2s ease; }
.tab.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.card > h2 {
  margin: 0 0 4px;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.card > h2 + .muted { margin-top: 0; margin-bottom: 4px; }
.muted { color: var(--text-dim); font-size: 0.86rem; }
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 10px;
}
.card-head h2 { margin: 0; }

/* ---------- forms ---------- */
form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.84rem; color: var(--text-dim); }
form label.row { flex-direction: row; align-items: center; gap: 10px; color: var(--text); }
input[type="text"], input[type="email"], input[type="password"], textarea {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: var(--r-ctrl);
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
  transition: border-color .14s ease, box-shadow .14s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
textarea { font-family: var(--mono); font-size: 0.8rem; resize: vertical; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }

/* ---------- buttons ---------- */
.actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 4px; }
button {
  background: var(--accent);
  color: #0b0e18;
  border: none;
  padding: 9px 15px;
  border-radius: var(--r-ctrl);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: filter .14s ease, background .14s ease, transform .06s ease;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button.secondary {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}
button.secondary:hover { background: #222d3d; filter: none; }
button.danger { background: transparent; color: var(--err); box-shadow: inset 0 0 0 1px var(--err-line); }
button.danger:hover { background: var(--err-wash); filter: none; }
button:disabled { opacity: .38; cursor: not-allowed; transform: none; filter: none; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  background: var(--surface-3); color: var(--text-dim);
  box-shadow: inset 0 0 0 1px var(--line);
}
.icon-btn:hover { color: var(--text); background: #222d3d; filter: none; }
.icon-btn svg { width: 16px; height: 16px; }

:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; border-radius: 4px; }

/* ---------- status banner ---------- */
.status {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--r-ctrl);
  font-size: 0.86rem;
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: grid;
  gap: 5px;
}
.status strong { color: var(--text); font-weight: 600; }
.status.ok      { background: var(--ok-wash);   border-color: var(--ok-line); }
.status.err     { background: var(--err-wash);  border-color: var(--err-line); }
.status.pending { background: var(--warn-wash); border-color: var(--warn-line); }

/* ---------- pills / badges / dots ---------- */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 999px; background: var(--text-faint); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-wash); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-wash); }
.dot.err { background: var(--err); box-shadow: 0 0 0 3px var(--err-wash); }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 500;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-dim);
}
.pill b { color: var(--text); font-weight: 600; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 0.73rem; font-weight: 600; letter-spacing: .01em;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.badge.synced     { color: var(--ok);   background: var(--ok-wash);   border-color: var(--ok-line); }
.badge.failed     { color: var(--warn); background: var(--warn-wash); border-color: var(--warn-line); }
.badge.offline    { color: var(--err);  background: var(--err-wash);  border-color: var(--err-line); }
.badge.not_linked { color: var(--text-dim); background: var(--surface-3); border-color: var(--line); }

/* ---------- painel de sessão (Conexão) ---------- */
.session-card { padding-bottom: 18px; }
.session-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
}
.session-state { display: flex; align-items: center; gap: 15px; min-width: 0; }
.state-ic {
  width: 46px; height: 46px; flex: none;
  display: grid; place-items: center;
  border-radius: 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-faint);
  transition: color .2s ease, background .2s ease, border-color .2s ease;
}
.state-ic svg { width: 23px; height: 23px; }
.state-ic.ok   { color: var(--ok);   background: var(--ok-wash);   border-color: var(--ok-line); }
.state-ic.warn { color: var(--warn); background: var(--warn-wash); border-color: var(--warn-line); }
.state-ic.err  { color: var(--err);  background: var(--err-wash);  border-color: var(--err-line); }
.session-label { font-size: 1.12rem; font-weight: 600; letter-spacing: -0.02em; }
.session-desc { font-size: 0.85rem; margin-top: 2px; }
.session-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.session-hint {
  margin: 16px 0 0; padding-top: 15px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.82rem; line-height: 1.55;
}
.session-card .status { margin-top: 15px; }
@media (max-width: 560px) {
  .session-head { align-items: flex-start; }
  .session-actions { width: 100%; }
  .session-actions button { flex: 1 1 auto; }
}

/* ---------- disclosure (conexão manual) ---------- */
.disclosure { padding: 0; overflow: hidden; }
.disclosure > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 14px;
  padding: 16px 22px;
  transition: background .14s ease;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary:hover { background: var(--surface-2); }
.disclosure > summary:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: -2px; }
.disclosure[open] > summary { border-bottom: 1px solid var(--line-soft); }
.disclosure-ic {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  color: var(--text-dim);
}
.disclosure-ic svg { width: 18px; height: 18px; }
.disclosure-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.disclosure-title { font-weight: 600; font-size: 0.96rem; }
.disclosure-text .muted { font-size: 0.82rem; }
.disclosure .chev { width: 18px; height: 18px; flex: none; margin-left: auto; color: var(--text-faint); transition: transform .2s ease; }
.disclosure[open] .chev { transform: rotate(180deg); }
.disclosure-body { padding: 16px 22px 22px; }
.disclosure-body > .muted:first-child { margin-top: 0; }

/* ---------- stat tiles (dashboard hero) ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
  overflow: hidden;
}
.tile::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent);
}
.tile.is-ok::before   { background: var(--ok); }
.tile.is-warn::before { background: var(--warn); }
.tile.is-err::before  { background: var(--err); }
.tile .t-label { font-size: 0.78rem; color: var(--text-dim); display: flex; align-items: center; gap: 7px; }
.tile .t-value { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .t-sub   { font-size: 0.78rem; color: var(--text-faint); }
.tile.is-ok   .t-value { color: var(--ok); }
.tile.is-warn .t-value { color: var(--warn); }
.tile.is-err  .t-value { color: var(--err); }

/* ---------- dashboard (Visão geral) ---------- */
.dash-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-bottom: 14px; }
.dash-updated { font-size: 0.8rem; color: var(--text-faint); }
#btn-refresh-dash svg { transition: transform .4s ease; }
#btn-refresh-dash.spinning svg { animation: spin .8s linear infinite; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.dash-grid .card { margin-bottom: 0; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

/* tiles: topo com ícone, número protagonista */
.tile .t-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile .t-ic { display: inline-flex; color: var(--text-faint); }
.tile .t-ic svg { width: 18px; height: 18px; }
.tile.is-ok .t-ic { color: var(--ok); }
.tile.is-warn .t-ic { color: var(--warn); }
.tile.is-err .t-ic { color: var(--err); }
.tile .t-value { margin-top: 4px; }

/* ofertas — linhas compactas */
.dash-offer {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 15px; background: var(--surface-2);
  border: 1px solid var(--line-soft); border-left-width: 3px; border-radius: 10px;
}
.dash-offer + .dash-offer { margin-top: 10px; }
.dash-offer.is-ok { border-left-color: var(--ok); }
.dash-offer.is-warn { border-left-color: var(--warn); }
.dash-offer.is-err { border-left-color: var(--err); }
.dash-offer.is-neutral { border-left-color: var(--line); }
.do-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 600; font-size: 0.95rem; }
.do-meta { font-size: 0.8rem; }
.do-meta code { display: inline-block; max-width: min(300px, 44vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.do-retry { font-size: 0.78rem; margin-top: 2px; }
.dash-offer .status { margin-top: 7px; }

/* eventos no painel lateral */
#dashboard-events { max-height: 440px; overflow: auto; }

/* skeletons */
.skel { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 8px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.045), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skel-tile { height: 106px; border: 1px solid var(--line-soft); border-radius: var(--r-card); }
.skel-line { height: 12px; margin: 11px 0; }
.skel-row { height: 58px; margin-bottom: 10px; border: 1px solid var(--line-soft); border-radius: 10px; }

/* erro de carregamento */
.dash-error { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 28px 20px; color: var(--text-dim); }
.dash-error svg { width: 28px; height: 28px; color: var(--err); }
.dash-error p { margin: 0; font-size: 0.9rem; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin-top: 14px; border: 1px solid var(--line-soft); border-radius: var(--r-ctrl); }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
th {
  background: var(--surface-2); color: var(--text-dim);
  font-weight: 500; font-size: 0.74rem; letter-spacing: .02em;
  position: sticky; top: 0;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s ease; }
tbody tr:hover td { background: var(--surface-3); }
td .mono, td code { font-size: 0.8rem; }
.num { font-variant-numeric: tabular-nums; }
.nowrap, .nowrap code { white-space: nowrap; overflow-wrap: normal; }

/* ---------- empty state ---------- */
.empty {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-dim);
  border: 1px dashed var(--line);
  border-radius: var(--r-card);
  background: var(--surface-2);
}
.empty svg { width: 30px; height: 30px; color: var(--text-faint); margin-bottom: 10px; }
.empty p { margin: 0; font-size: 0.9rem; }
td.muted, td.empty-cell { text-align: center; color: var(--text-dim); padding: 22px; }

/* ---------- offers ---------- */
#offers-list { display: flex; flex-direction: column; gap: 14px; }
.offer-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 16px 18px;
}
.offer-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.offer-actions button { padding: 7px 11px; font-size: 0.8rem; }
.offer-links { margin-top: 14px; }
.offer-links .table-wrap { margin-top: 0; }
.offer-links table { font-size: 0.82rem; }

/* cabeçalho da seção */
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* oferta — resumo */
.offer-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.offer-ident { min-width: 0; flex: 1 1 300px; }
.offer-ident h3 {
  margin: 0 0 10px; font-size: 1.04rem; font-weight: 600; letter-spacing: -0.015em;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.offer-meta { display: flex; flex-wrap: wrap; gap: 7px 16px; }
.offer-meta .meta { display: inline-flex; align-items: center; gap: 7px; font-size: 0.82rem; color: var(--text-dim); min-width: 0; }
.offer-meta .meta svg { width: 15px; height: 15px; color: var(--text-faint); flex: none; }
.offer-meta .meta strong { color: var(--text); font-weight: 600; }
.offer-meta code { display: inline-block; max-width: min(340px, 52vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.offer-meta em { color: var(--text-faint); font-style: normal; }

/* menu de ações (popover) */
.offer-actions .icon-btn { width: 34px; height: 34px; padding: 0; }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  min-width: 178px; display: none; flex-direction: column; gap: 2px; padding: 5px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctrl);
  box-shadow: var(--shadow-pop);
}
.menu.open { display: flex; animation: pop .14s ease; }
.menu button {
  background: transparent; color: var(--text); box-shadow: none;
  justify-content: flex-start; gap: 10px; padding: 8px 10px; border-radius: 7px;
  font-size: 0.85rem; font-weight: 500;
}
.menu button:hover { background: var(--surface-3); filter: none; }
.menu button:disabled { opacity: .4; background: transparent; }
.menu button svg { width: 15px; height: 15px; opacity: .85; flex: none; }
.menu button.danger { color: var(--err); box-shadow: none; }
.menu button.danger:hover { background: var(--err-wash); }
.menu-sep { height: 1px; background: var(--line-soft); margin: 4px 2px; }

/* oferta — expandir links */
.offer-toggle {
  margin-top: 14px; width: 100%;
  display: flex; align-items: center; justify-content: flex-start; gap: 9px;
  background: var(--surface); color: var(--text-dim);
  box-shadow: inset 0 0 0 1px var(--line-soft);
  padding: 9px 12px; font-size: 0.84rem; font-weight: 500;
}
.offer-toggle:hover { background: var(--surface-3); color: var(--text); filter: none; }
.offer-toggle .chev { width: 16px; height: 16px; flex: none; transition: transform .2s ease; }
.offer-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.offer-toggle .count {
  margin-left: auto;
  color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: 0.74rem;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  padding: 1px 8px; border-radius: 999px;
}
.offer-toggle .count:empty { display: none; }

/* estados de links */
.links-empty { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 4px 0; }
.loading { display: inline-flex; align-items: center; gap: 9px; color: var(--text-dim); font-size: 0.85rem; padding: 4px 0; }
.spinner { width: 15px; height: 15px; flex: none; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* link ativo em destaque */
.offer-links tbody tr.is-active td { background: var(--accent-wash); }
.offer-links tbody tr.is-active:hover td { background: var(--accent-wash); }
.offer-links tbody tr.is-active td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

/* ---------- events ---------- */
.events { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; }
.events li {
  display: flex; gap: 11px; align-items: baseline;
  padding: 9px 2px; font-size: 0.85rem;
  border-bottom: 1px solid var(--line-soft);
}
.events li:last-child { border-bottom: none; }
.events .ev-time { font-family: var(--mono); font-size: 0.72rem; color: var(--text-faint); white-space: nowrap; }
.events .ev-dot { flex: none; margin-top: 6px; }
.event-error { color: var(--err); }
.event-warn  { color: var(--warn); }
.event-info  { color: var(--text-dim); }

/* ---------- webhooks ---------- */
.spec { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; margin: 16px 0 0; font-size: 0.85rem; }
.spec dt { color: var(--text-faint); white-space: nowrap; }
.spec dd { margin: 0; color: var(--text-dim); line-height: 1.55; }

.wh-filter { display: flex; margin: 4px 0 2px; }
.segmented {
  display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-ctrl);
}
.segmented button {
  background: transparent; color: var(--text-dim); box-shadow: none;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px; border-radius: 6px; font-size: 0.82rem; font-weight: 500;
}
.segmented button:hover { background: var(--surface-3); color: var(--text); filter: none; }
.segmented button.active { background: var(--accent-wash); color: #eef0ff; box-shadow: inset 0 0 0 1px var(--accent-line); }
.segmented .seg-count { font-size: 0.74rem; font-variant-numeric: tabular-nums; color: var(--text-faint); }
.segmented button.active .seg-count { color: var(--accent-bright); }

#webhook-log-table th.wh-caret-h { width: 36px; padding: 0; }
.wh-row { cursor: pointer; }
.wh-caret { width: 36px; text-align: center; color: var(--text-faint); }
.wh-caret svg { width: 15px; height: 15px; vertical-align: middle; transition: transform .18s ease; }
.wh-row[aria-expanded="true"] .wh-caret svg { transform: rotate(90deg); }
.wh-row[aria-expanded="true"] td { background: var(--surface-3); }
.wh-incident code { display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.wh-detail > td { padding: 0; background: var(--surface-2); border-top: none; }
.payload-pretty {
  margin: 0; padding: 14px 16px; max-height: 340px; overflow: auto;
  font-family: var(--mono); font-size: 0.76rem; line-height: 1.55; color: #cdd8e6;
  white-space: pre; tab-size: 2;
}

/* ---------- webhook endpoint field ---------- */
.copyfield {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-ctrl); padding: 6px 6px 6px 12px;
}
.copyfield code { background: none; border: none; padding: 0; font-size: 0.86rem; color: var(--accent-bright); }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5,8,12,.66);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal.hidden { display: none; }
.modal-content {
  max-width: 480px; width: 100%; margin: 0;
  box-shadow: var(--shadow-pop);
  animation: pop .18s cubic-bezier(.2,.8,.3,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-content h2 { margin: 0 0 2px; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
  max-width: min(360px, calc(100vw - 40px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-ctrl);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  font-size: 0.86rem; color: var(--text);
  animation: toastin .22s cubic-bezier(.2,.8,.3,1);
}
.toast.out { animation: toastout .2s ease forwards; }
.toast svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.toast.ok   { border-color: var(--ok-line); }
.toast.ok svg { color: var(--ok); }
.toast.err  { border-color: var(--err-line); }
.toast.err svg { color: var(--err); }
.toast.info svg { color: var(--accent-bright); }
@keyframes toastin  { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toastout { to { opacity: 0; transform: translateX(16px); } }

/* ---------- login ---------- */
.rail-logout {
  margin-top: 8px; width: 100%;
  display: flex; align-items: center; gap: 9px; justify-content: flex-start;
  background: transparent; color: var(--text-dim);
  box-shadow: inset 0 0 0 1px var(--line-soft);
  padding: 9px 11px; font-size: 0.84rem; font-weight: 500;
}
.rail-logout:hover { background: var(--err-wash); color: var(--err); box-shadow: inset 0 0 0 1px var(--err-line); filter: none; }
.rail-logout svg { width: 16px; height: 16px; flex: none; }

.login-overlay {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(120% 120% at 50% 0%, #0e141c, var(--bg));
}
.login-overlay.hidden { display: none; }
.login-card {
  width: 100%; max-width: 380px; margin: 0;
  box-shadow: var(--shadow-pop);
  animation: pop .2s cubic-bezier(.2,.8,.3,1);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.login-card label { margin-bottom: 2px; }
.login-card .actions { margin-top: 6px; }
.login-card #login-submit { width: 100%; justify-content: center; padding: 11px; }
.login-card .status { margin-top: 0; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: static; height: auto; flex-direction: row; align-items: center;
    gap: 8px; padding: 12px; overflow-x: auto;
    border-right: none; border-bottom: 1px solid var(--line-soft);
  }
  .brand { padding: 0 8px 0 2px; }
  .brand-sub { display: none; }
  nav { flex-direction: row; flex: 1; }
  nav button span { display: none; }
  nav button { padding: 10px; }
  .rail-foot { margin: 0; padding: 0; }
  .rail-health { white-space: nowrap; }
  .topbar { padding: 16px; }
  main { padding: 18px 16px 48px; }
  .card { padding: 16px; }
}

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