:root {
  /* superfícies: preto em camadas, com grão */
  --bg: #070707;
  --surface: #111111;
  --surface-2: #1b1b1b;
  --surface-3: #232323;
  --inset: #0a0a0a;
  --border: rgb(255 255 255 / 0.07);
  --border-strong: rgb(255 255 255 / 0.13);
  --highlight: inset 0 1px 0 rgb(255 255 255 / 0.05);

  --text: #f4f4f2;
  --text-2: #bdbdb8;
  --text-3: #8b8b86;

  /* verde-limão da marca */
  --accent: #c6f135;
  --accent-hover: #d6ff52;
  --accent-ink: #0d1100;
  --accent-soft: rgb(198 241 53 / 0.12);
  --accent-line: rgb(198 241 53 / 0.32);
  --accent-text: #d5f76b;
  --accent-glow: 0 0 0 1px rgb(198 241 53 / 0.5), 0 8px 28px -6px rgb(198 241 53 / 0.45);

  --ok: #5ee08a;
  --ok-soft: rgb(94 224 138 / 0.12);
  --warn: #f5c451;
  --warn-soft: rgb(245 196 81 / 0.12);
  --err: #ff7a6b;
  --err-soft: rgb(255 122 107 / 0.12);
  --info: #8ab8ff;
  --info-soft: rgb(138 184 255 / 0.12);

  --radius-lg: 22px;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 1px 0 rgb(255 255 255 / 0.03) inset, 0 12px 32px -12px rgb(0 0 0 / 0.7);
  --shadow-lg: 0 24px 64px -12px rgb(0 0 0 / 0.85);
  --sidebar: 248px;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --font: 'Fustat', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* ruído fractal: dá a textura granulada aos blocos pretos */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .11 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --card-bg: var(--grain), linear-gradient(180deg, #161616 0%, #0f0f0f 100%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(900px 480px at 12% -8%, rgb(198 241 53 / 0.07), transparent 70%),
    radial-gradient(700px 400px at 100% 0%, rgb(255 255 255 / 0.025), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01', 'cv11';
}
::selection { background: var(--accent); color: var(--accent-ink); }
a { color: var(--accent-text); text-decoration-color: var(--accent-line); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 650; letter-spacing: -0.015em; }
h1 { font-size: 28px; font-weight: 750; letter-spacing: -0.03em; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #262626; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: #333; }
::-webkit-scrollbar-track { background: transparent; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100dvh; }
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  margin: var(--s3) 0 var(--s3) var(--s3);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--s3);
  height: calc(100dvh - var(--s5));
}
.brand { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s4) var(--s3); font-weight: 750; font-size: 15px; letter-spacing: -0.02em; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(180deg, #232323, #121212);
  border: 1px solid var(--border-strong);
  box-shadow: var(--highlight), 0 6px 16px -6px rgb(0 0 0 / 0.8);
  color: var(--accent); display: grid; place-items: center; font-size: 13px; font-weight: 800; letter-spacing: -0.04em;
}
.brand small { display: block; font-size: 11.5px; font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: var(--s2); overflow-y: auto; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 40px; padding: 0 var(--s3); border-radius: 12px;
  border: 1px solid transparent;
  color: var(--text-3); text-decoration: none; font-weight: 550;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav a svg { width: 18px; height: 18px; flex-shrink: 0; transition: color 0.15s; }
.nav a:hover { background: rgb(255 255 255 / 0.04); color: var(--text); }
.nav a[aria-current='page'] {
  background: linear-gradient(180deg, #262626, #1a1a1a);
  border-color: var(--border-strong);
  box-shadow: var(--highlight), 0 6px 18px -8px rgb(0 0 0 / 0.9);
  color: var(--text);
}
.nav a[aria-current='page'] svg { color: var(--accent); }
.nav-sep { height: 1px; background: var(--border); margin: var(--s2) var(--s3); }
.sidebar-foot { margin: var(--s2); padding: var(--s2) var(--s2) var(--s2) var(--s3); border-radius: 12px; background: var(--inset); border: 1px solid var(--border); display: flex; gap: var(--s2); justify-content: space-between; align-items: center; color: var(--text-2); font-size: 13px; font-weight: 550; }
.avatar { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { padding: var(--s6) 40px 48px; max-width: 1440px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-head p { color: var(--text-3); margin-top: 6px; font-size: 14.5px; }
.page-actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }

@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; transform: translateX(calc(-100% - 24px)); transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 0.6); backdrop-filter: blur(4px); z-index: 30; }
  .topbar {
    display: flex; align-items: center; gap: var(--s3);
    padding: var(--s2) var(--s4); padding-top: max(var(--s2), env(safe-area-inset-top));
    background: rgb(7 7 7 / 0.8); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20; min-height: 56px;
  }
  .content { padding: var(--s5) var(--s4) var(--s6); }
  h1 { font-size: 24px; }
}

/* ---------- componentes ---------- */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: var(--s5); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); min-height: 56px; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: var(--s3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid { display: grid; gap: var(--s4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-kpi { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
@media (max-width: 700px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
  .card-pad { padding: var(--s4); }
  .card-head { padding: var(--s3) var(--s4); }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, #252525, #1b1b1b);
  box-shadow: var(--highlight);
  color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn:hover { background: linear-gradient(180deg, #2d2d2d, #222); color: var(--text); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(180deg, #dcff6a 0%, var(--accent) 55%, #b3dd22 100%);
  border-color: transparent; color: var(--accent-ink); font-weight: 700;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.55), 0 8px 24px -8px rgb(198 241 53 / 0.55);
}
.btn-primary:hover { background: linear-gradient(180deg, #e6ff86 0%, var(--accent-hover) 55%, #c0ea2b 100%); color: var(--accent-ink); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.6), 0 10px 30px -8px rgb(198 241 53 / 0.7); }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: rgb(255 255 255 / 0.05); }
.btn-danger { color: var(--err); }
.btn-danger:hover { background: var(--err-soft); border-color: rgb(255 122 107 / 0.3); color: var(--err); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-icon { width: 38px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn svg { width: 16px; height: 16px; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

label.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-weight: 600; font-size: 13px; color: var(--text-2); }
.field-hint { font-size: 12.5px; color: var(--text-3); }
input[type='text'], input[type='number'], input[type='password'], input[type='search'], input[type='url'], input[type='email'], input[type='datetime-local'], input[type='date'], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--inset); color: var(--text); font: inherit;
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.5);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: #5f5f5b; }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8b86' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
select option { background: #151515; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 38px; height: 22px; border-radius: 11px; background: var(--inset); border: 1px solid var(--border-strong); position: relative; transition: background 0.2s, border-color 0.2s; flex-shrink: 0; }
.switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #6b6b67; transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.2s; }
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 12px -2px rgb(198 241 53 / 0.6); }
.switch input:checked + .switch-track::after { transform: translateX(16px); background: var(--accent-ink); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; background: rgb(255 255 255 / 0.04); border: 1px solid var(--border-strong); color: var(--text-2); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); border-color: rgb(94 224 138 / 0.25); color: var(--ok); }
.badge-warn { background: var(--warn-soft); border-color: rgb(245 196 81 / 0.25); color: var(--warn); }
.badge-err { background: var(--err-soft); border-color: rgb(255 122 107 / 0.25); color: var(--err); }
.badge-info { background: var(--info-soft); border-color: rgb(138 184 255 / 0.25); color: var(--info); }
.badge-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 750; text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px var(--s5); border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.09em; background: #121212; position: sticky; top: 0; white-space: nowrap; padding-top: 10px; padding-bottom: 10px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.12s; }
tbody tr:hover td { background: rgb(255 255 255 / 0.02); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: rgb(255 255 255 / 0.035); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td a { text-decoration: none; }
td a:hover { text-decoration: underline; }

.toolbar { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; margin-bottom: var(--s4); }
.toolbar input[type='search'] { max-width: 300px; padding-left: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b8b86' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 12px center; }
.toolbar select { width: auto; }
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border); margin-bottom: var(--s4); overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 12px 14px; font: inherit; font-weight: 600; color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color 0.15s; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected='true'] { color: var(--text); border-bottom-color: var(--accent); }

/* controle segmentado: trilho escuro afundado, opção ativa em bloco elevado */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--inset); border: 1px solid var(--border); border-radius: 12px; box-shadow: inset 0 1px 3px rgb(0 0 0 / 0.6); max-width: 100%; overflow-x: auto; }
.seg button { background: transparent; border: 1px solid transparent; padding: 6px 14px; min-height: 32px; border-radius: 9px; font: inherit; font-size: 13px; font-weight: 600; color: var(--text-3); cursor: pointer; white-space: nowrap; transition: color 0.15s, background 0.15s; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed='true'] { background: linear-gradient(180deg, #2a2a2a, #1e1e1e); border-color: var(--border-strong); box-shadow: var(--highlight), 0 2px 6px rgb(0 0 0 / 0.5); color: var(--text); }

.empty { text-align: center; padding: 48px var(--s4); color: var(--text-3); }
.empty h3 { color: var(--text); margin-bottom: var(--s1); font-size: 15px; }
.skeleton { background: linear-gradient(90deg, #151515, #202020, #151515); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-xs); }
@keyframes shimmer { to { background-position: -200% 0; } }
.alert { padding: var(--s3) var(--s4); border-radius: var(--radius-sm); background: var(--info-soft); border: 1px solid rgb(138 184 255 / 0.2); color: var(--info); font-size: 13.5px; }
.alert a { color: inherit; font-weight: 650; }
.alert-warn { background: var(--warn-soft); border-color: rgb(245 196 81 / 0.22); color: var(--warn); }
.alert-err { background: var(--err-soft); border-color: rgb(255 122 107 / 0.22); color: var(--err); }
.alert-ok { background: var(--ok-soft); border-color: rgb(94 224 138 / 0.22); color: var(--ok); }

.pager { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); padding: var(--s3) var(--s5); border-top: 1px solid var(--border); color: var(--text-3); font-size: 13px; }

/* KPI */
.kpi { padding: var(--s5); position: relative; overflow: hidden; min-width: 0; }
.kpi-label { color: var(--text-3); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; }
.kpi-value { font-size: 28px; font-weight: 750; margin-top: 10px; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; line-height: 1.1; overflow-wrap: anywhere; }
.kpi-sub { color: var(--text-3); font-size: 12.5px; margin-top: 6px; }
.kpi-hero { background: radial-gradient(120% 140% at 0% 0%, rgb(198 241 53 / 0.16), transparent 55%), var(--card-bg); border-color: var(--accent-line); }
.kpi-hero .kpi-label { color: var(--accent-text); }
.kpi-hero .kpi-value { color: var(--accent); text-shadow: 0 0 24px rgb(198 241 53 / 0.3); }
@media (max-width: 700px) {
  .kpi { padding: var(--s4); }
  .kpi-value { font-size: 21px; }
}

/* gráfico */
.chart { width: 100%; height: 220px; display: block; }
.chart .bar { fill: var(--accent); }
.chart .bar2 { fill: #5a5a56; opacity: 0.55; }
.chart text { fill: var(--text-3); font-size: 10px; font-family: var(--font); }
.chart .grid-line { stroke: rgb(255 255 255 / 0.06); stroke-dasharray: 2 4; }
.legend { display: flex; gap: var(--s4); font-size: 12.5px; color: var(--text-3); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* modal / drawer */
.overlay { position: fixed; inset: 0; background: rgb(0 0 0 / 0.65); backdrop-filter: blur(6px); z-index: 50; display: flex; align-items: center; justify-content: center; padding: var(--s4); animation: fade-in 0.15s ease; }
.modal { background: var(--grain), #111; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; animation: pop-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1); }
.modal-lg { max-width: 900px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); gap: var(--s3); }
.modal-body { padding: var(--s5); overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s3) var(--s5); border-top: 1px solid var(--border); }
.drawer-overlay { justify-content: flex-end; align-items: stretch; padding: 0; }
.drawer { background: var(--grain), var(--bg); border-left: 1px solid var(--border-strong); width: min(760px, 100%); height: 100dvh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slide-in 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); }
.drawer .modal-head { background: rgb(17 17 17 / 0.9); }
.drawer .modal-body { flex: 1; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes slide-in { from { transform: translateX(32px); opacity: 0; } }
@media (max-width: 640px) {
  .overlay:not(.drawer-overlay) { align-items: flex-end; padding: 0; }
  .modal { max-height: 92dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-width: none; padding-bottom: env(safe-area-inset-bottom); }
  .modal-head, .modal-body { padding-left: var(--s4); padding-right: var(--s4); }
}

.toasts { position: fixed; bottom: var(--s4); right: var(--s4); z-index: 100; display: flex; flex-direction: column; gap: var(--s2); max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; background: #1c1c1c; color: var(--text); border: 1px solid var(--border-strong); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 550; animation: toast-in 0.2s ease; }
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); flex-shrink: 0; }
.toast-err { background: #1f1311; border-color: rgb(255 122 107 / 0.35); }
.toast-err::before { background: var(--err); box-shadow: 0 0 10px var(--err); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: var(--s4); }
.login .card { width: 100%; max-width: 380px; padding: var(--s6) var(--s5) var(--s5); position: relative; overflow: hidden; border-radius: var(--radius-lg); }
.login .card::before { content: ''; position: absolute; inset: 0 0 auto; height: 1px; background: linear-gradient(90deg, transparent, var(--accent), transparent); }
.login .brand { padding: 0; }
.login .btn-primary { min-height: 44px; }

/* editor de mensagens */
.msg-editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s4); }
@media (max-width: 980px) { .msg-editor { grid-template-columns: 1fr; } }
.fmt-bar { display: flex; gap: 2px; flex-wrap: wrap; padding: 4px; border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: #141414; }
.fmt-bar + textarea { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.fmt-bar button { min-width: 30px; height: 28px; border: 0; background: transparent; border-radius: var(--radius-xs); cursor: pointer; color: var(--text-2); font: inherit; font-size: 13px; padding: 0 6px; }
.fmt-bar button:hover { background: var(--surface-3); color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: rgb(255 255 255 / 0.03); border: 1px solid var(--border-strong); font-size: 12px; cursor: pointer; color: var(--text-2); font-family: var(--mono); transition: border-color 0.15s, color 0.15s; }
.chip:hover { border-color: var(--accent-line); color: var(--accent-text); }
.btn-rows { display: flex; flex-direction: column; gap: var(--s2); }
.btn-row { display: flex; gap: var(--s2); align-items: flex-start; padding: var(--s2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.btn-cell { display: grid; grid-template-columns: 1fr; gap: 6px; flex: 1; min-width: 0; padding: var(--s2); background: var(--surface-2); border-radius: var(--radius-sm); }
.media-strip { display: flex; gap: var(--s2); flex-wrap: wrap; }
.media-thumb { width: 72px; height: 72px; border-radius: 12px; overflow: hidden; background: var(--inset); position: relative; border: 1px solid var(--border-strong); display: grid; place-items: center; font-size: 11px; color: var(--text-3); text-align: center; }
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-thumb .rm, .media-thumb .mv { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgb(0 0 0 / 0.7); backdrop-filter: blur(4px); color: #fff; cursor: pointer; font-size: 13px; line-height: 1; }
.media-thumb .mv { top: auto; right: auto; bottom: 3px; left: 3px; font-size: 10px; }
.media-drop { display: flex; flex-direction: column; gap: var(--s3); align-items: stretch; padding: var(--s4); }
.media-drop .media-strip { justify-content: flex-start; }
.media-drop .media-thumb { width: 88px; height: 88px; }

/* prévia estilo Telegram */
.tg-preview { background: #0e1621 url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='40'><circle cx='20' cy='20' r='1.5' fill='%23ffffff' opacity='.08'/></svg>"); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s3); min-height: 200px; position: sticky; top: var(--s4); }
.tg-bubble { background: #182533; color: #f5f5f5; border-radius: 12px 12px 12px 4px; padding: 6px 10px 8px; max-width: 100%; font-size: 14px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; box-shadow: 0 1px 1px rgb(0 0 0 / 0.2); }
.tg-bubble a { color: #6ab3f3; }
.tg-bubble code { background: rgb(255 255 255 / 0.08); padding: 0 3px; border-radius: 3px; }
.tg-bubble blockquote { margin: 4px 0; padding-left: 8px; border-left: 3px solid #3390ec; }
.tg-media { margin: -6px -10px 6px; border-radius: 12px 12px 0 0; overflow: hidden; background: #22303e; display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 2px; }
.tg-media img, .tg-media video { width: 100%; height: 140px; object-fit: cover; display: block; }
.tg-media.spoiler img, .tg-media.spoiler video { filter: blur(14px); }
.tg-buttons { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.tg-buttons .r { display: flex; gap: 4px; }
.tg-btn { flex: 1; background: rgb(255 255 255 / 0.1); color: #fff; text-align: center; border-radius: 8px; padding: 8px 6px; font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-btn.success { background: #2e7d32; }
.tg-btn.danger { background: #c62828; }
.tg-btn.primary { background: #1e88e5; }

/* fluxos — lista */
.eyebrow { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3); }
.eyebrow svg { color: var(--accent); }
.eyebrow-count { padding: 1px 7px; border-radius: var(--radius-xs); background: rgb(255 255 255 / 0.05); border: 1px solid var(--border); color: var(--text-2); letter-spacing: 0; }
.flow-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s4); }
.flow-card { display: flex; flex-direction: column; transition: border-color 0.15s; }
.flow-card:hover { border-color: var(--border-strong); }
.flow-card.is-off .flow-card-main h3 { color: var(--text-2); }
.flow-card-top { display: flex; justify-content: space-between; align-items: center; padding: var(--s4) var(--s5) 0; }
.flow-card-main { display: block; padding: var(--s3) var(--s5) var(--s4); color: inherit; text-decoration: none; flex: 1; }
.flow-card-main:hover h3 { color: var(--accent-text); }
.flow-card-main h3 { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; transition: color 0.15s; }
.flow-card-main p { margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.flow-card-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 var(--s5); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.flow-card-stats div { padding: var(--s3) 0; }
.flow-card-stats div + div { padding-left: var(--s3); border-left: 1px solid var(--border); }
.flow-card-stats dt { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }
.flow-card-stats dd { margin: 2px 0 0; font-size: 20px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.flow-card-stats .is-win dd { color: var(--accent); }
.flow-card-actions { display: flex; align-items: center; gap: var(--s1); padding: var(--s3) var(--s4) var(--s3) var(--s5); }

/* fluxos — editor em tela cheia */
.focus { min-height: 100dvh; }
.fe { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100dvh; }
.fe-top { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s4); padding-top: max(var(--s2), env(safe-area-inset-top)); min-height: 64px; border-bottom: 1px solid var(--border); background: var(--grain), rgb(10 10 10 / 0.92); backdrop-filter: blur(12px); z-index: 5; }
.fe-title { flex: 1; min-width: 0; }
.fe-top .fe-name { width: 100%; max-width: 520px; background: transparent; border-color: transparent; box-shadow: none; padding: 2px 8px; min-height: 32px; margin-left: -8px; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; text-overflow: ellipsis; }
.fe-top .fe-name:hover { border-color: var(--border); }
.fe-top .fe-name:focus { border-color: var(--accent-line); background: var(--inset); }
.fe-meta { display: flex; gap: var(--s3); font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; }
.fe-live { display: inline-flex; align-items: center; gap: 6px; }
.fe-live i { width: 7px; height: 7px; border-radius: 50%; background: #4a4a47; }
.fe-live.on { color: var(--text-2); }
.fe-live.on i { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }
.fe-top-actions { display: flex; align-items: center; gap: var(--s3); flex-shrink: 0; }
.fe-dirty { font-size: 12.5px; color: var(--warn); font-weight: 600; }
.fe-warn { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--warn); }

.fe-body { display: grid; grid-template-columns: minmax(0, 1fr) 460px; min-height: 0; }
.fe-canvas {
  overflow: auto; min-height: 0; padding: 40px 24px 96px;
  background:
    radial-gradient(circle at 1px 1px, rgb(255 255 255 / 0.07) 1px, transparent 0) 0 0 / 22px 22px,
    radial-gradient(700px 360px at 50% 0%, rgb(198 241 53 / 0.05), transparent 70%);
}
.fe-chain { position: relative; width: min(400px, 100%); margin: 0 auto; display: flex; flex-direction: column; align-items: stretch; }
.fe-jumps { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.fe-jumps > path { fill: none; stroke-width: 1.6; }
.fe-jumps > path.then { stroke: var(--accent); }
.fe-jumps > path.else { stroke: #7a7a75; stroke-dasharray: 4 4; }
.fe-jumps marker path.then { fill: var(--accent); }
.fe-jumps marker path.else { fill: #7a7a75; }

.tone-message, .tone-template { --tone: var(--info); }
.tone-pix { --tone: var(--ok); }
.tone-branch { --tone: var(--warn); }
.tone-action, .tone-accent { --tone: var(--accent); }
.tone-end { --tone: var(--text-3); }
.fe-tile { width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0; display: grid; place-items: center; color: var(--tone, var(--accent)); background: linear-gradient(180deg, #242424, #141414); border: 1px solid var(--border-strong); box-shadow: var(--highlight), 0 0 18px -8px var(--tone, var(--accent)); }
.fe-tile.sm { width: 32px; height: 32px; border-radius: 9px; }

.fe-node { position: relative; text-align: left; border-radius: var(--radius); background: var(--card-bg); border: 1px solid var(--border-strong); box-shadow: var(--shadow); padding: var(--s3) var(--s4) var(--s4); cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s; outline: none; }
.fe-node:hover { border-color: rgb(255 255 255 / 0.2); }
.fe-node:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.fe-node.is-sel { border-color: var(--accent-line); box-shadow: 0 0 0 1px var(--accent-line), 0 0 0 5px var(--accent-soft), var(--shadow); }
.fe-node.is-off { opacity: 0.55; }
.fe-node.is-drag { opacity: 0.35; }
.fe-node.is-drop { outline: 2px dashed var(--accent); outline-offset: 4px; }
.fe-trigger { background: radial-gradient(120% 120% at 0% 0%, rgb(198 241 53 / 0.12), transparent 60%), var(--card-bg); border-color: var(--accent-line); }
.fe-node-head { display: flex; align-items: center; gap: var(--s3); }
.fe-kind { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-3); }
.fe-node-title { font-size: 14.5px; font-weight: 650; letter-spacing: -0.01em; margin-top: 1px; }
.fe-grip { color: #5a5a56; cursor: grab; display: grid; }
.fe-node:hover .fe-grip { color: var(--text-3); }
.fe-node-text { margin-top: var(--s3); font-size: 13px; color: var(--text-2); }
.fe-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s3); }
.fe-chip { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--text-2); background: rgb(255 255 255 / 0.04); border: 1px solid var(--border-strong); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fe-flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s3); }
.fe-preview { margin-top: var(--s3); max-height: 280px; overflow: hidden; border-radius: 12px; -webkit-mask-image: linear-gradient(180deg, #000 80%, transparent); mask-image: linear-gradient(180deg, #000 80%, transparent); }
.fe-preview .tg-preview { position: static; min-height: 0; border-radius: 12px; padding: 10px; }
.fe-preview .tg-bubble { font-size: 13px; }
.fe-preview .tg-media img, .fe-preview .tg-media video { height: 110px; }
.fe-outs { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-top: var(--s3); }
.fe-out { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); min-width: 0; }
.fe-outs .fe-out { padding: 6px 10px; border-radius: 10px; background: var(--inset); border: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fe-out b { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; padding: 1px 6px; border-radius: 5px; }
.fe-out.then b { background: var(--accent); color: var(--accent-ink); }
.fe-out.else b { background: #3a3a37; color: var(--text); }
.fe-outs .fe-out.then { border-color: rgb(198 241 53 / 0.25); }

/* conectores: linha + espera + inserir */
.fe-link { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0; }
.fe-link::before { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: linear-gradient(180deg, rgb(198 241 53 / 0.45), rgb(255 255 255 / 0.12)); }
.fe-delay { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-strong); background: #141414; color: var(--text-2); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.fe-delay:hover { border-color: var(--accent-line); color: var(--text); }
.fe-delay svg { color: var(--accent); }
.fe-delay-t { color: var(--text-3); font-weight: 500; padding-left: 6px; border-left: 1px solid var(--border-strong); }
.fe-add-wrap { position: relative; }
.fe-add { position: relative; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--border-strong); background: #1a1a1a; color: var(--text-3); cursor: pointer; transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.15s; }
.fe-add:hover, .fe-add.open { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 0 16px -2px rgb(198 241 53 / 0.6); transform: scale(1.1); }
.fe-link.is-dragging .fe-add-wrap { visibility: hidden; }
.fe-menu { position: absolute; z-index: 20; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: 300px; max-width: calc(100vw - 32px); padding: 6px; border-radius: 14px; background: var(--grain), #151515; border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); animation: fade-in 0.15s ease; }
.fe-menu-title { padding: 6px 10px 8px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-3); }
.fe-menu button { display: flex; align-items: center; gap: var(--s3); width: 100%; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.fe-menu button:hover, .fe-menu button:focus-visible { background: rgb(255 255 255 / 0.06); outline: none; }
.fe-menu strong { display: block; font-size: 13.5px; font-weight: 650; }
.fe-menu small { display: block; font-size: 12px; color: var(--text-3); }
.fe-end { align-self: center; display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px; border: 1px dashed var(--border-strong); color: var(--text-3); font-size: 12.5px; font-weight: 600; }

/* painel lateral */
.fe-panel { min-height: 0; overflow: hidden; border-left: 1px solid var(--border); background: var(--grain), #0d0d0d; }
.fe-panel-inner { display: flex; flex-direction: column; height: 100%; }
.fe-panel-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.fe-panel-head h2 { font-size: 17px; font-weight: 700; }
.fe-panel-close { display: none; }
.fe-panel-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.fe-panel-foot { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s5); padding-bottom: max(var(--s3), env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: #0d0d0d; }
.fe-panel-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: var(--s2); padding: var(--s6); }
.fe-panel-empty p { max-width: 260px; }
.fe-sec-plain { display: flex; flex-direction: column; gap: var(--s4); padding: var(--s5); border-bottom: 1px solid var(--border); }
.fe-sec { border-bottom: 1px solid var(--border); }
.fe-sec summary { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); list-style: none; cursor: pointer; }
.fe-sec summary::-webkit-details-marker { display: none; }
.fe-sec summary:hover { background: rgb(255 255 255 / 0.02); }
.fe-sec summary strong { display: block; font-size: 14px; font-weight: 650; }
.fe-sec summary small { display: block; font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fe-sec summary > svg { color: var(--text-3); transition: transform 0.2s; flex-shrink: 0; }
.fe-sec[open] summary > svg { transform: rotate(180deg); }
.fe-sec-body { display: flex; flex-direction: column; gap: var(--s4); padding: 0 var(--s5) var(--s5); }
.fe-checks { display: flex; flex-direction: column; gap: 10px; }
.fe-outs-edit { display: grid; gap: var(--s3); }
.fe-outs-edit .field-label { display: inline-flex; align-items: center; gap: 6px; }
.fe-panel .msg-editor { display: block; }
.fe-panel .seg { width: 100%; }
.fe-panel .seg button { flex: 1; }

@media (max-width: 1000px) {
  .fe-body { grid-template-columns: 1fr; }
  .fe-panel { position: fixed; z-index: 45; inset: auto 0 0; height: 88dvh; border-left: 0; border-top: 1px solid var(--border-strong); border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: 0 -24px 64px rgb(0 0 0 / 0.8); transform: translateY(105%); transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); }
  .fe-panel.open { transform: none; }
  .fe-panel-close { display: inline-flex; }
  .fe-canvas { padding: var(--s5) var(--s4) 96px; }
  .fe-chain { width: min(400px, calc(100% - 40px)); margin-left: 0; margin-right: auto; }
}
@media (max-width: 640px) {
  .hide-sm { display: none !important; }
  .fe-top { gap: var(--s2); padding-left: var(--s2); padding-right: var(--s3); }
  .fe-top-actions { gap: var(--s2); }
}
.cond-row { display: grid; grid-template-columns: auto minmax(0, 2fr) minmax(0, 1.2fr) auto; gap: var(--s2); align-items: center; }
@media (max-width: 640px) { .cond-row { grid-template-columns: 1fr 1fr; } }
.timeline-note { font-size: 12.5px; padding: var(--s2) var(--s3); background: var(--inset); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-2); }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s3); }
.media-card { overflow: hidden; cursor: pointer; position: relative; transition: border-color 0.15s, transform 0.15s; }
.media-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.media-card.selected { outline: 2px solid var(--accent); outline-offset: -1px; }
.media-card .thumb { aspect-ratio: 1; background: var(--inset); display: grid; place-items: center; color: var(--text-3); font-size: 12px; overflow: hidden; }
.media-card .thumb img, .media-card .thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-card .meta { padding: 8px 10px; font-size: 12px; }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: var(--s5); text-align: center; color: var(--text-3); background: var(--grain), var(--inset); transition: border-color 0.15s, background-color 0.15s; }
.dropzone.over { border-color: var(--accent); background: var(--grain), var(--accent-soft); color: var(--accent-text); }

.timeline { display: flex; flex-direction: column; gap: var(--s2); }
.tl-item { display: flex; gap: var(--s2); font-size: 13px; }
.tl-item.in { justify-content: flex-start; }
.tl-item.out { justify-content: flex-end; }
.tl-msg { max-width: 80%; padding: 8px 12px; border-radius: 14px 14px 14px 4px; background: var(--surface-2); border: 1px solid var(--border); white-space: pre-wrap; word-break: break-word; }
.tl-item.out .tl-msg { background: var(--accent-soft); border-color: rgb(198 241 53 / 0.18); border-radius: 14px 14px 4px 14px; }
.tl-item.err .tl-msg { background: var(--err-soft); border-color: rgb(255 122 107 / 0.2); }
.tl-meta { font-size: 11px; color: var(--text-3); margin-top: 3px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px var(--s4); margin: 0; }
dl.kv dt { color: var(--text-3); }
dl.kv dd { margin: 0; min-width: 0; word-break: break-word; }
pre.json { background: var(--inset); border: 1px solid var(--border); padding: var(--s3); border-radius: var(--radius-sm); overflow-x: auto; font-size: 12px; margin: 0; max-height: 300px; color: var(--text-2); }
details summary { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
