:root {
  --bg: #09090b;
  --bg-2: #111114;
  --surface: rgba(18, 18, 22, 0.92);
  --surface-2: rgba(25, 25, 30, 0.96);
  --surface-3: rgba(31, 31, 37, 0.98);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #f5f5f5;
  --text-2: #d4d4d8;
  --text-3: #9ca3af;
  --red: #d72638;
  --red-hover: #ec394f;
  --red-soft: rgba(215, 38, 56, 0.12);
  --red-line: rgba(215, 38, 56, 0.35);
  --red-deep: #3b0b14;
  --ok: #38d39f;
  --ok-soft: rgba(56, 211, 159, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --gray-soft: rgba(156, 163, 175, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 10px 25px rgba(0, 0, 0, 0.22);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Chakra Petch', 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 620px at 0% -10%, rgba(215, 38, 56, 0.18), transparent 35%),
    radial-gradient(900px 540px at 100% 0%, rgba(255,255,255,0.04), transparent 30%),
    var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--red); color: #fff; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid var(--bg); }
.hidden { display: none !important; }

/* ───────── shell ───────── */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: linear-gradient(180deg, rgba(11, 11, 13, 0.96) 0%, rgba(8, 8, 10, 0.98) 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px;
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.02);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; text-decoration: none; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 21px; letter-spacing: .5px; }
.brand-name b { color: var(--red); }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-3); padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-weight: 500; transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: rgba(255,255,255,0.025); color: var(--text); transform: translateX(1px); }
.nav a.active {
  background: linear-gradient(90deg, rgba(215, 38, 56, 0.18), rgba(215, 38, 56, 0.08));
  color: #fff; box-shadow: inset 2px 0 0 var(--red), inset 1px 0 0 rgba(255,255,255,0.04);
}
.nav a.active svg { color: var(--red); }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--red) 0%, #7a1828 100%); color: #fff; font-weight: 700; font-size: 13px; border: 1px solid var(--red-line);
  box-shadow: 0 10px 18px rgba(215, 38, 56, 0.25);
}
.sidebar-foot .who { flex: 1; min-width: 0; }
.sidebar-foot .who div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .who small { color: var(--text-3); display: block; overflow: hidden; text-overflow: ellipsis; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 16px 30px; background: rgba(9, 9, 11, 0.78); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-family: var(--font-display); font-size: 20px; margin: 0; font-weight: 600; letter-spacing: .3px; }
.topbar .sub { color: var(--text-3); font-size: 13px; }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.content { padding: 28px 30px 60px; max-width: 1400px; width: 100%; }

/* ───────── primitives ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: rgba(255,255,255,0.02);
  font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .18s ease, border-color .18s ease, transform .08s ease, box-shadow .18s ease;
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.btn:hover { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.16); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: linear-gradient(180deg, var(--red-hover) 0%, var(--red) 100%);
  border-color: rgba(255,255,255,0.12); color: #fff;
  box-shadow: 0 12px 24px rgba(215, 38, 56, 0.25);
}
.btn-primary:hover { background: linear-gradient(180deg, #ee4a5d 0%, var(--red) 100%); border-color: rgba(255,255,255,0.18); box-shadow: 0 14px 28px rgba(215, 38, 56, 0.32); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: rgba(255,255,255,0.03); color: var(--text); border-color: transparent; }
.btn-danger { color: #ff6b77; }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red-line); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 32px; padding: 0; height: 32px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.loading { pointer-events: none; opacity: .75; }
.btn.loading::after {
  content: ''; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card {
  background: linear-gradient(180deg, rgba(18,18,22,0.96), rgba(12,12,15,0.96));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head .spacer { flex: 1; }
.card-head small { color: var(--text-3); }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

label.field, div.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
label.field small { font-weight: 400; color: var(--text-3); }
.input, select.input, textarea.input {
  width: 100%; height: 40px; padding: 0 12px; background: rgba(9,9,11,0.9); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: rgba(215,38,56,0.7); box-shadow: 0 0 0 3px rgba(215,38,56,0.14); background: rgba(12,12,15,1); }
.input::placeholder { color: #5d6470; }
select.input { appearance: none; padding-right: 32px; cursor: pointer;
  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='%23a1a1aa' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.input-group { display: flex; }
.input-group .prefix {
  display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--border-strong); border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: rgba(255,255,255,0.02); color: var(--text-2); font-size: 13px;
}
.input-group .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--gray-soft); color: var(--text-2); white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--red-soft); color: #ff5a67; }

.alert {
  display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-2);
}
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert.red { background: var(--red-soft); border-color: var(--red-line); color: #ffb3b9; }
.alert.warn { background: var(--warn-soft); border-color: rgba(245, 158, 11, .35); color: #fcd38a; }
.alert b { color: var(--text); }

/* tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 500; color: var(--text-3); font-size: 12px; text-transform: uppercase; letter-spacing: .6px;
  padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: rgba(255, 255, 255, .015); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty svg { width: 36px; height: 36px; color: var(--text-3); margin-bottom: 8px; }
.empty h4 { color: var(--text); margin: 4px 0; font-size: 15px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 13px; }

/* KPI tiles */
.kpi { padding: 18px 20px; position: relative; overflow: hidden; }
.kpi .label { color: var(--text-2); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.kpi .label svg { width: 16px; height: 16px; color: var(--text-3); }
.kpi .value { font-family: var(--font-display); font-size: 28px; font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: .2px; }
.kpi .hint { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.kpi.hero {
  background: radial-gradient(120% 140% at 100% 0%, rgba(215, 38, 56, .22) 0%, transparent 55%),
              linear-gradient(180deg, rgba(20,20,25,0.96), rgba(12,12,15,0.96));
  border-color: var(--red-line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.kpi.hero .value { font-size: 32px; }

/* chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 260px; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--red); transition: opacity .15s; }
.chart .bar.dim { opacity: .35; }
.chart .hit { fill: transparent; cursor: crosshair; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface-3); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 12.5px; box-shadow: var(--shadow); white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px)); z-index: 5;
}
.tooltip b { font-size: 14px; display: block; }
.tooltip span { color: var(--text-2); }

.meter { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; }
.meter + .meter { border-top: 1px solid var(--border); }
.meter .track { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.meter .fill { height: 100%; background: var(--red); border-radius: 99px; }
.meter .val { font-variant-numeric: tabular-nums; text-align: right; min-width: 110px; }
.meter .val small { color: var(--text-3); display: block; font-size: 12px; }

.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .grow div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* checklist */
.checklist { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.check-step { display: flex; gap: 12px; padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); text-decoration: none; transition: border-color .15s; }
.check-step:hover { border-color: var(--red-line); }
.check-step .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; background: var(--surface-3); flex: none; }
.check-step.done .n { background: var(--ok-soft); color: var(--ok); }
.check-step.done { opacity: .7; }
.check-step b { display: block; font-size: 13.5px; }
.check-step small { color: var(--text-3); }

/* bot cards */
.bot-card { display: flex; flex-direction: column; }
.bot-card .top { display: flex; gap: 14px; padding: 18px 20px; align-items: center; }
.bot-avatar {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-size: 19px;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-deep) 100%); color: #fff; flex: none; font-family: var(--font-display);
}
.bot-card h3 { margin: 0; font-size: 16px; }
.bot-card .stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.bot-card .stats div { padding: 12px 20px; }
.bot-card .stats div + div { border-left: 1px solid var(--border); }
.bot-card .stats b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.bot-card .stats small { color: var(--text-3); font-size: 12px; }
.bot-card .cfg { padding: 16px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bot-card .actions { padding: 12px 20px; display: flex; gap: 8px; border-top: 1px solid var(--border); flex-wrap: wrap; margin-top: auto; }

/* gateway cards */
.gw-card { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.gw-logo { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-family: var(--font-display); font-size: 18px; flex: none; }
.gw-logo { overflow: hidden; }
.gw-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gw-card.soon { opacity: .55; border-style: dashed; }
.gw-card p { margin: 0; color: var(--text-2); font-size: 13px; }

.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; border: 1px solid var(--border); }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px 12px; border-radius: 7px; cursor: pointer; color: var(--text-2); font-weight: 600; font-size: 13px; }
.tabs button.active { background: var(--surface-3); color: var(--text); }

.steps-guide { counter-reset: s; display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.steps-guide li { counter-increment: s; display: flex; gap: 12px; align-items: flex-start; color: var(--text-2); font-size: 13.5px; }
.steps-guide li::before {
  content: counter(s); width: 24px; height: 24px; border-radius: 50%; background: var(--red-soft); color: var(--red);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none;
}
.steps-guide code, .kbd { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; font-family: var(--mono); font-size: 12px; color: var(--text); }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .7); backdrop-filter: blur(4px); z-index: 100;
  display: grid; place-items: center; padding: 20px; animation: fade .15s ease;
}
.modal { width: 100%; max-width: 560px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow); animation: pop .18s ease; }
.modal.wide { max-width: 780px; }
.modal-head { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 17px; flex: 1; font-family: var(--font-display); font-weight: 600; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; gap: 10px; align-items: center; min-width: 260px; max-width: 420px; padding: 12px 16px; border-radius: 10px;
  background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: var(--shadow); animation: pop .2s ease; font-size: 13.5px;
}
.toast svg { width: 18px; height: 18px; flex: none; }
.toast.ok svg { color: var(--ok); }
.toast.err { border-color: var(--red-line); }
.toast.err svg { color: var(--red); }

/* auth (entrar / criar conta) */
.logo-img { display: block; flex: none; border-radius: 50%; object-fit: contain; }
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; background: #050506; }
.auth-form { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 96px 24px 40px; }
.auth-brand { position: absolute; top: 28px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; text-decoration: none; }
.auth-brand .brand-name { font-size: 22px; }
.auth-card {
  width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 18px; padding: 34px 32px 28px;
  border: 1px solid var(--border-strong); border-radius: 22px;
  background: linear-gradient(180deg, rgba(24, 24, 28, .92), rgba(12, 12, 15, .96));
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .04);
}
.auth-head { text-align: center; margin-bottom: 6px; }
.auth-head h1 { font-family: var(--font-display); margin: 0; font-size: 30px; font-weight: 700; letter-spacing: .3px; }
.auth-head p { margin: 6px 0 0; color: var(--text-2); font-size: 15px; }
.auth-field { gap: 8px; }
.auth-input { position: relative; display: flex; align-items: center; }
.auth-input > svg { position: absolute; left: 16px; width: 18px; height: 18px; color: var(--text-3); pointer-events: none; }
.auth-input .input { height: 52px; padding-left: 46px; border-radius: 12px; font-size: 15px; background: rgba(255, 255, 255, .025); }
.auth-input .input[type="password"], .auth-input .input[name="password"] { padding-right: 48px; }
.auth-eye { position: absolute; right: 8px; width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); cursor: pointer; }
.auth-eye:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.auth-eye svg { width: 18px; height: 18px; }
.auth-submit { height: 52px; justify-content: space-between; padding: 0 20px; border-radius: 12px; font-size: 15px; background: rgba(255, 255, 255, .03); }
.auth-submit:hover { border-color: var(--red-line); background: var(--red-soft); }
.auth-submit svg { width: 18px; height: 18px; transition: transform .15s; }
.auth-submit:hover svg { transform: translateX(3px); }
.auth-switch { margin: 0; text-align: center; color: var(--text-3); font-size: 14px; }
.auth-switch a { color: var(--text); font-weight: 600; text-decoration: none; }
.auth-switch a:hover { color: var(--red-hover); }

.auth-stats { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.auth-stat { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 14px 8px; text-align: center; border: 1px solid var(--border); border-radius: 14px; background: rgba(255, 255, 255, .02); }
.auth-stat svg { width: 18px; height: 18px; color: var(--red); flex: none; }
.auth-stat b { display: block; font-family: var(--font-display); font-size: 18px; line-height: 1.1; }
.auth-stat small { display: block; margin-top: 3px; color: var(--text-3); font-size: 10.5px; line-height: 1.3; text-transform: uppercase; letter-spacing: .7px; }
.auth-stats-mini { max-width: 440px; }
.auth-stats-mini .auth-stat { padding: 8px 4px; border-color: transparent; background: none; }
.auth-stats-mini .auth-stat b { font-size: 15px; }

.auth-art {
  position: relative; overflow: hidden; display: grid; place-items: center; padding: 48px 32px;
  border-left: 1px solid var(--border);
  background:
    radial-gradient(60% 45% at 50% 18%, rgba(215, 38, 56, .22), transparent 70%),
    radial-gradient(50% 50% at 80% 100%, rgba(215, 38, 56, .08), transparent 70%),
    linear-gradient(180deg, #0c0a0c, #070608);
}
.auth-art::before { content: ''; position: absolute; width: 640px; height: 640px; border-radius: 50%; border: 1px solid rgba(215, 38, 56, .12); top: 50%; left: 50%; transform: translate(-50%, -50%); }
.auth-art-inner { position: relative; width: 100%; max-width: 480px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 18px; }
.auth-logo { padding: 10px; border-radius: 50%; background: radial-gradient(circle, rgba(215, 38, 56, .25), rgba(215, 38, 56, 0) 70%); box-shadow: 0 0 60px rgba(215, 38, 56, .25); }
.auth-art h2 { font-family: var(--font-display); font-size: 36px; line-height: 1.1; margin: 4px 0 0; }
.auth-art p { margin: 0; color: var(--text-2); font-size: 15.5px; max-width: 420px; }
.auth-art .auth-stats { margin: 8px 0 6px; }
.auth-feats { width: 100%; display: flex; flex-direction: column; gap: 12px; text-align: left; }
.auth-feat { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border: 1px solid var(--border); border-radius: 14px; background: rgba(255, 255, 255, .02); }
.auth-feat > span { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 10px; }
.auth-feat > span svg { width: 20px; height: 20px; }
.auth-feat > span.ok { background: var(--ok-soft); color: var(--ok); }
.auth-feat > span.violet { background: rgba(139, 92, 246, .14); color: #a78bfa; }
.auth-feat > span.red { background: var(--red-soft); color: #ff6b77; }
.auth-feat b { display: block; font-size: 15px; }
.auth-feat small { display: block; color: var(--text-3); font-size: 13px; margin-top: 2px; }

/* ───────── flow builder ───────── */
.flow-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.flow-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.flow-bar .name { font-family: var(--font-display); font-size: 18px; font-weight: 600; max-width: 360px; background: transparent; border-color: transparent; }
.flow-bar .name:hover { border-color: var(--border-strong); }
.plan-preview { padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); font-weight: 650; }
.upsell-item { display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.media-storage { display: grid; grid-template-columns: minmax(180px, .7fr) minmax(280px, 1.3fr); gap: 12px 20px; align-items: center; margin: 0 0 14px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.media-storage .storage-title { display: flex; align-items: center; gap: 12px; }
.media-storage .storage-title > svg { width: 22px; height: 22px; color: var(--red); }
.media-storage .storage-title b, .media-storage .storage-title small { display: block; }
.media-storage .storage-title small, .media-storage > small { color: var(--text-3); font-size: 12px; }
.media-storage .grid { grid-column: 2; grid-row: 1 / span 2; }
.media-storage > small { grid-column: 1; grid-row: 2; }
.media-gallery { margin: 0 0 18px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.media-gallery-head, .media-gallery-head > div { display: flex; align-items: center; gap: 10px; }
.media-gallery-head { justify-content: space-between; margin-bottom: 14px; }
.media-gallery-head > div > svg { width: 20px; height: 20px; color: var(--red); }
.media-gallery-head b, .media-gallery-head small { display: block; }
.media-gallery-head small { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.media-gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.media-gallery-grid.media-gallery-welcome { grid-template-columns: repeat(auto-fill, minmax(150px, 200px)); }
.upsell-media-section .media-tile { width: 100%; max-width: 200px; }
.segmented { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.segmented button { border: 0; border-radius: 5px; padding: 7px 12px; color: var(--text-2); background: transparent; cursor: pointer; font-size: 12px; font-weight: 600; }
.segmented button.active { color: var(--text); background: var(--surface-3); }
.upsell-media-section { display: grid; grid-template-columns: minmax(0, 1fr) 200px; align-items: center; gap: 16px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.upsell-media-section > div:first-child b, .upsell-media-section > div:first-child small { display: block; }
.upsell-media-section > div:first-child small { margin-top: 4px; color: var(--text-3); font-size: 12px; }
.media-tile { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.media-tile-preview { aspect-ratio: 3 / 4; display: grid; place-items: center; overflow: hidden; background: var(--bg); }
.media-tile-preview img, .media-tile-preview video { width: 100%; height: 100%; max-height: none; object-fit: cover; border-radius: 0; }
.media-tile-info { display: flex; align-items: center; gap: 6px; min-height: 60px; padding: 8px 10px; }
.media-tile-info > div { min-width: 0; flex: 1; }
.media-tile-info b, .media-tile-info small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-tile-info b { font-size: 12.5px; }
.media-tile-info small { color: var(--text-3); font-size: 11px; margin-top: 2px; }
.media-select { position: relative; overflow: hidden; flex: none; }
.media-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.media-empty { width: 100%; height: 100%; min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--text-3); font-size: 12px; }
.media-empty svg { width: 24px; height: 24px; }
.media-add-tile { position: relative; display: block; padding: 0; text-align: center; cursor: pointer; border-style: dashed; transition: border-color .15s, color .15s; }
.media-add-tile:hover, .media-add-tile:focus-within { border-color: var(--red); }
.media-add-tile:hover .media-empty { color: var(--text); }
.flow-media-preview { display: block; width: 100%; max-height: 200px; object-fit: contain; border-radius: var(--radius-sm); background: var(--bg); }
.flow-canvas { position: relative; }
.flow-start { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: var(--red-soft); color: #ff8a94; font-weight: 600; font-size: 13px; border: 1px solid var(--red-line); }
.connector { position: relative; height: 34px; display: flex; justify-content: center; align-items: center; }
.connector::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: var(--border-strong); transform: translateX(-50%); }
.connector .add {
  position: relative; z-index: 1; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border-strong);
  background: var(--surface-2); display: grid; place-items: center; cursor: pointer; color: var(--text-2); opacity: 0; transition: opacity .15s, background .15s;
}
.connector:hover .add, .connector .add:focus { opacity: 1; }
.connector .add:hover { background: var(--red); color: #fff; border-color: var(--red); }
.connector .add svg { width: 14px; height: 14px; }
.step { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.step.selected { border-color: var(--red-line); box-shadow: 0 0 0 3px var(--red-soft); }
.step-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.step.collapsed .step-head { border-bottom: 0; }
.step.collapsed .step-body { display: none; }
.step-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.step-icon svg { width: 16px; height: 16px; }
.step[data-type="offer"] .step-icon { background: var(--red-soft); color: var(--red); }
.step-title { flex: 1; min-width: 0; }
.step-title b { font-size: 14px; }
.step-title small { display: block; color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-num { font-family: var(--mono); font-size: 11px; color: var(--text-3); background: var(--bg); padding: 2px 6px; border-radius: 5px; }
.step-tools { display: flex; gap: 2px; }
.step-tools .btn { color: var(--text-3); }
.step-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.branch-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 14px; border-radius: var(--radius-sm); background: var(--bg); border: 1px dashed var(--border-strong); }
.branch-grid .field span { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.btn-rows { display: flex; flex-direction: column; gap: 8px; }
.btn-row { display: grid; grid-template-columns: 1fr 120px 1fr 32px; gap: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-family: var(--mono); font-size: 11.5px; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); cursor: pointer; border: 1px solid transparent; }
.chip:hover { border-color: var(--red-line); color: var(--text); }
.add-menu { position: absolute; z-index: 30; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; min-width: 220px; }
.add-menu button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 9px 10px; border: 0; background: transparent; border-radius: 7px; cursor: pointer; text-align: left; }
.add-menu button:hover { background: var(--surface-3); }
.add-menu button svg { width: 16px; height: 16px; color: var(--red); }
.add-menu button small { display: block; color: var(--text-3); font-size: 12px; }

/* telegram preview */
.phone { position: sticky; top: 84px; border-radius: 28px; border: 1px solid var(--border-strong); background: #0b0b0d; overflow: hidden; box-shadow: var(--shadow); }
.phone-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.phone-head .bot-avatar { width: 34px; height: 34px; border-radius: 50%; font-size: 14px; }
.phone-head small { display: block; color: var(--text-3); font-size: 12px; }
.phone-chat {
  height: 560px; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 8px;
  background: radial-gradient(circle at 20% 20%, rgba(225, 29, 46, .05), transparent 40%), #0d0d10;
}
.bubble { max-width: 88%; background: #1c1c21; border-radius: 14px 14px 14px 4px; padding: 8px 11px; font-size: 13.5px; white-space: pre-wrap; word-wrap: break-word; }
.bubble.user { align-self: flex-end; background: var(--red-deep); border-radius: 14px 14px 4px 14px; }
.bubble.active { outline: 2px solid var(--red-line); }
.bubble .media { margin: -8px -11px 8px; height: 120px; border-radius: 14px 14px 0 0; background: var(--surface-3); display: grid; place-items: center; color: var(--text-3); font-size: 12px; overflow: hidden; }
.bubble .media img { width: 100%; height: 100%; object-fit: cover; }
.bubble code { font-family: var(--mono); font-size: 12px; background: rgba(255, 255, 255, .06); padding: 0 4px; border-radius: 4px; }
.tg-buttons { display: flex; flex-direction: column; gap: 4px; max-width: 88%; }
.tg-buttons span { background: rgba(255, 255, 255, .07); border-radius: 8px; padding: 7px; text-align: center; font-size: 13px; font-weight: 500; }
.sys { align-self: center; font-size: 11.5px; color: var(--text-3); background: rgba(255, 255, 255, .04); padding: 3px 10px; border-radius: 99px; }
.role-tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; font-weight: 700; padding: 2px 7px; border-radius: 5px; }
.role-main { background: var(--red-soft); color: #ff6b77; }
.role-upsell { background: var(--ok-soft); color: var(--ok); }
.role-downsell { background: var(--warn-soft); color: var(--warn); }
.role-remarketing { background: rgba(139, 92, 246, .14); color: #a78bfa; }
.role-pack { background: var(--gray-soft); color: var(--text-2); }

.progress { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; min-width: 100px; }
.progress div { height: 100%; background: var(--red); }

.live-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(56, 211, 159, .6); animation: live 2s infinite; vertical-align: 1px; }
@keyframes live { 70% { box-shadow: 0 0 0 6px rgba(56, 211, 159, 0); } 100% { box-shadow: 0 0 0 0 rgba(56, 211, 159, 0); } }
.copy-field { display: flex; gap: 8px; }
.copy-field .input { font-family: var(--mono); font-size: 12px; }

/* layouts de página */
.main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.key-split { grid-template-columns: 150px minmax(0, 1fr); }
.name-price { grid-template-columns: minmax(0, 1fr) 160px; }

/* ───────── responsivo ───────── */
@media (max-width: 1200px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow-layout { grid-template-columns: 1fr; }
  .phone { position: static; }
  .media-gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .checklist { grid-template-columns: repeat(2, 1fr); }
  .main-side { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  /* fundo escuro atrás do menu aberto; toque fora fecha */
  .shell.nav-open::after { content: ''; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .55); }
  .topbar .menu-btn { display: inline-flex; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-form { padding-top: 88px; }
  .content { padding: 16px 16px 48px; }
  .media-storage { grid-template-columns: 1fr; }
  .media-storage .grid, .media-storage > small { grid-column: 1; grid-row: auto; }
  .upsell-media-section { grid-template-columns: 1fr; }
  .branch-grid { grid-template-columns: 1fr; }
  .btn-row { grid-template-columns: 1fr 1fr; }

  /* topo: título em cima, ações ocupam a linha de baixo */
  .topbar { padding: 12px 16px; flex-wrap: wrap; row-gap: 10px; }
  .topbar > div:not(.row):not(.spacer) { flex: 1; min-width: 0; }
  .topbar .spacer { display: none; }
  .topbar #actions:not(:empty) { width: 100%; flex-wrap: wrap; gap: 8px; }
  .topbar #actions > * { flex: 1 1 auto; }
  .topbar #actions select.input { width: auto !important; min-width: 0 !important; flex: 1 1 140px; }
  .topbar h1 { font-size: 18px; }

  .card-head { flex-wrap: wrap; }
  .media-gallery-head { flex-wrap: wrap; }
  .flow-bar > label { width: 100%; justify-content: space-between; }
  .flow-bar > label select { flex: 1; }
  .flow-bar .name { max-width: 100%; }
  .tabs { flex-wrap: wrap; }
  .tabs button { flex: 1 0 auto; white-space: nowrap; }
  .phone-chat { height: 460px; }
  .modal-backdrop { padding: 10px; align-items: end; }
  .modal { max-height: calc(100vh - 20px); }
  .modal-head { padding: 14px 16px; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 12px 16px; flex-wrap: wrap; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: none; }
  .pager { flex-wrap: wrap; gap: 8px; }
  .row > .input[style*="max-width"] { max-width: none !important; flex: 1 1 100%; }
}
@media (max-width: 640px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .label { font-size: 12px; }
  .kpi .value { font-size: 20px; overflow-wrap: anywhere; }
  .kpi.hero .value { font-size: 26px; }
  .checklist { grid-template-columns: 1fr; }
  .bot-card .cfg { grid-template-columns: 1fr; }
  .bot-card .stats div { padding: 10px 12px; }
  .meter { grid-template-columns: 80px 1fr; }
  .meter .val { grid-column: 1 / -1; text-align: left; }
  .media-gallery-grid { grid-template-columns: 1fr; }
  .card-pad { padding: 16px; }
  .card-head { padding: 14px 16px; }
  .list-item { padding: 12px 16px; }
  .modal-foot .btn { flex: 1 1 auto; }

  /* tabelas viram cartões empilhados; o rótulo de cada célula vem do cabeçalho (data-label, ver app.js) */
  .table-wrap { overflow-x: visible; }
  table.table thead { display: none; }
  table.table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .table tr:last-child { border-bottom: 0; }
  .table td { display: flow-root; padding: 4px 0; border: 0; text-align: right; }
  .table td::before { content: attr(data-label); float: left; margin-right: 12px; color: var(--text-3); font-size: 12px; line-height: 21px; text-align: left; }
  .table td:first-child { display: block; text-align: left; padding-bottom: 8px; }
  .table td:first-child::before, .table td[data-label=""]::before { display: none; }
  .table td:empty { display: none; }
  .table td:last-child[data-label=""] { text-align: left; padding-top: 8px; }
  .table tbody tr:hover td { background: none; }
}
@media (max-width: 480px) {
  .key-split, .name-price { grid-template-columns: 1fr; }
  .auth-form { padding: 84px 14px 28px; }
  .auth-card { padding: 26px 18px 22px; border-radius: 18px; }
  .auth-head h1 { font-size: 26px; }
}
.auth-label-row { display: flex; justify-content: space-between; align-items: baseline; }
.auth-label-row a { color: var(--text-2); font-weight: 500; text-decoration: none; }
.auth-label-row a:hover { color: var(--red-hover); }

/* faixa do "entrar como usuário" (admin) */
.impersonation-bar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 30px; background: linear-gradient(90deg, rgba(251, 191, 36, .18), rgba(251, 191, 36, .08));
  border-bottom: 1px solid rgba(251, 191, 36, .45); color: #fde68a; font-size: 13.5px;
}
.impersonation-bar > svg { width: 18px; height: 18px; flex: none; color: var(--warn); }
.impersonation-bar > span { flex: 1; min-width: 200px; }
.impersonation-bar b { color: #fff; }
.impersonation-bar + .topbar { top: 41px; }
@media (max-width: 900px) { .impersonation-bar { padding: 10px 16px; } .impersonation-bar + .topbar { top: 0; position: static; } }

/* código curto de exportação (fluxo / remarketing) */
.share-code {
  padding: 18px 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--bg);
  text-align: center; font-size: 22px; font-weight: 600; letter-spacing: 2px; color: var(--text); user-select: all; word-break: break-all;
}
