@font-face { font-family: 'Unbounded'; src: url('/fonts/unbounded.woff2') format('woff2'); font-weight: 200 900; font-display: swap; }
@font-face { font-family: 'Bricolage'; src: url('/fonts/bricolage.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }
:root {
  --ink: #0c0a14; --paper: #f5efe6; --muted: #b7aec0; --accent: #f29a2e; --gold: #dd9933; --glow: #3a1d08;
  --line: rgba(255,255,255,.1); --panel: rgba(20,16,32,.62); --violet: #9a7cff;
  --ok: #57d39a; --warn: #f2c94c; --bad: #ff6b6b;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--ink); color: var(--paper); font-family: 'Bricolage', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
body::before { content: ''; position: fixed; inset: 0; z-index: -2;
  background: radial-gradient(60vmax 50vmax at 50% 0%, color-mix(in srgb, var(--glow) 92%, transparent), transparent 70%),
              radial-gradient(40vmax 30vmax at 92% 100%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%), var(--ink); }
#particles { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
[hidden] { display: none !important; }
a { color: var(--accent); }
code { font-family: ui-monospace, Menlo, monospace; font-size: .88em; color: var(--gold); }
h2, h3, .brand-name { font-family: 'Unbounded', 'Bricolage', sans-serif; letter-spacing: .01em; }
h2 { margin: 0; font-size: clamp(1.3rem, 2.4vw, 1.75rem); }
h3 { margin: 0 0 14px; font-size: .95rem; font-weight: 600; color: var(--paper); }
h3.mt { margin-top: 22px; }
.f72 { color: var(--gold); text-shadow: 0 0 22px rgba(221,153,51,.45); }
.ws { background: linear-gradient(180deg, #fff 10%, #c4c8d2 95%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.muted { color: var(--muted); }
.tiny { font-size: .78rem; }
.glass { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: 0 24px 60px -30px #000; }
.card { padding: 20px 22px; margin-bottom: 18px; min-width: 0; }
label { display: grid; gap: 6px; font-size: .82rem; color: var(--muted); margin-bottom: 12px; }
.lbl { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
input, select, textarea { font: inherit; color: var(--paper); background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; outline: none; min-width: 0; }
select option { background: #16111f; }
input:focus, select:focus, textarea:focus, .rte-area:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.btn { font: inherit; font-weight: 700; font-size: .9rem; border-radius: 12px; padding: 10px 18px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; transition: filter .2s, background .2s; }
.btn.gold { background: var(--accent); color: #1b1208; box-shadow: 0 12px 26px -14px var(--accent), inset 0 1px 0 rgba(255,255,255,.45); }
.btn.gold:hover { filter: brightness(1.1); }
.btn.ghost { background: rgba(255,255,255,.06); color: var(--paper); border-color: var(--line); }
.btn.ghost:hover { background: rgba(255,255,255,.11); }
.btn.danger { background: rgba(255,107,107,.12); color: #ffb3b3; border-color: rgba(255,107,107,.3); }
.btn.small { padding: 6px 10px; font-size: .78rem; border-radius: 9px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.wide { width: 100%; margin-top: 10px; }
.status { min-height: 1.2em; font-size: .84rem; margin: 8px 0 0; }
.status[data-state='error'] { color: #ff9c9c; }
.status[data-state='ok'] { color: var(--ok); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); padding: 34px 30px; text-align: center; }
.login-card img { filter: drop-shadow(0 6px 24px rgba(221,153,51,.35)); }
.login-card h1 { margin: 10px 0 4px; font-size: 1.5rem; }
.login-card label { text-align: left; }
.login-card .btn { width: 100%; margin-top: 6px; height: 46px; }

/* layout */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; border-radius: 0 22px 22px 0; border-left: 0; padding: 22px 16px; display: flex; flex-direction: column; gap: 22px; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.side-brand img { filter: drop-shadow(0 4px 14px rgba(221,153,51,.4)); }
.brand-name.small { font-size: 1rem; }
.tabs { display: grid; gap: 4px; }
.tabs button { all: unset; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; color: var(--muted); font-weight: 600; font-size: .93rem; transition: background .2s, color .2s; }
.tabs button:hover { background: rgba(255,255,255,.06); color: var(--paper); }
.tabs button[aria-current='page'] { background: linear-gradient(90deg, rgba(242,154,46,.22), rgba(242,154,46,.04)); color: var(--paper); box-shadow: inset 2px 0 0 var(--accent); }
.tabs button:focus-visible { outline: 2px solid var(--accent); }
.tabs .ic { width: 20px; text-align: center; color: var(--gold); }
.badge { margin-left: auto; background: var(--accent); color: #1b1208; font-size: .72rem; border-radius: 999px; padding: 1px 8px; }
.logout { margin-top: auto; }
.main { padding: 28px clamp(16px, 3vw, 40px) 40px; min-width: 0; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.view-head p { margin: 4px 0 0; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h3 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; }
.grid-2 > .card { margin-bottom: 18px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 18px 20px; position: relative; overflow: hidden; }
.kpi::after { content: ''; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, rgba(242,154,46,.22), transparent 70%); }
.kpi .v { font-family: 'Unbounded', sans-serif; font-size: 1.9rem; font-weight: 700; margin-top: 6px; }
.kpi .l { color: var(--muted); font-size: .82rem; }
.kpi .s { color: var(--gold); font-size: .78rem; margin-top: 4px; }
.kpi.hot .v { color: var(--accent); }

.legend { display: flex; gap: 8px; align-items: center; font-size: .78rem; color: var(--muted); margin: -6px 0 10px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-left: 8px; }
.dot.g { background: var(--accent); margin-left: 0; } .dot.v { background: var(--violet); }
.chart svg { width: 100%; height: 200px; display: block; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 34px; gap: 10px; align-items: center; margin-bottom: 9px; font-size: .86rem; }
.bar { height: 9px; border-radius: 99px; background: rgba(255,255,255,.07); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--gold), var(--accent)); }
.activity { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.activity li { display: grid; grid-template-columns: 130px 140px 1fr auto; gap: 12px; padding: 9px 4px; border-bottom: 1px solid rgba(255,255,255,.05); font-size: .86rem; align-items: center; }
.activity li:last-child { border: 0; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .74rem; font-weight: 700; background: rgba(255,255,255,.08); color: var(--paper); white-space: nowrap; }
.chip.novo { background: rgba(242,154,46,.2); color: #ffc27a; }
.chip.em-análise { background: rgba(154,124,255,.2); color: #c9b8ff; }
.chip.respondido, .chip.ativo, .chip.enviada, .chip.teste-enviado { background: rgba(87,211,154,.16); color: #8ff0c2; }
.chip.arquivado, .chip.cancelado, .chip.cancelada { background: rgba(255,255,255,.08); color: var(--muted); }
.chip.erro, .chip.teste-falhou, .chip.interrompida { background: rgba(255,107,107,.16); color: #ffb3b3; }
.chip.enviando, .chip.na-fila { background: rgba(242,201,76,.16); color: #ffe08a; }

/* tables */
.table-wrap { overflow: auto; max-height: 460px; }
.table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px; position: sticky; top: 0; background: rgba(20,16,32,.96); }
.table td { padding: 9px 10px; border-top: 1px solid rgba(255,255,255,.06); vertical-align: middle; }
.table tr:hover td { background: rgba(255,255,255,.025); }
.log { max-height: 240px; overflow: auto; background: rgba(0,0,0,.3); border-radius: 12px; padding: 12px; font-size: .78rem; color: var(--muted); white-space: pre-wrap; }

/* editor */
.rte { border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.04); overflow: hidden; margin-bottom: 12px; }
.rte-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); background: rgba(0,0,0,.18); }
.rte-bar button { all: unset; cursor: pointer; min-width: 30px; height: 30px; padding: 0 7px; border-radius: 8px; display: grid; place-items: center; font-size: .85rem; color: var(--paper); box-sizing: border-box; }
.rte-bar button:hover { background: rgba(255,255,255,.1); }
.rte-bar .sep { width: 1px; background: var(--line); margin: 4px 4px; }
.rte-area { min-height: 220px; max-height: 460px; overflow: auto; padding: 14px 16px; line-height: 1.6; outline: none; border-radius: 0 0 14px 14px; }
.rte-area:empty::before { content: attr(data-placeholder); color: rgba(245,239,230,.35); }
.rte-area a { color: var(--accent); }
.rte-area blockquote { margin: 0 0 12px; padding: 6px 14px; border-left: 3px solid var(--gold); color: #cfc6d8; }
.send-row { display: flex; gap: 8px; }
.send-row input { flex: 1; }
.preview { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: 14px; background: #0c0a14; display: block; }
.preview-card { position: sticky; top: 18px; align-self: start; }

/* split (consultoria / templates) */
.split { display: grid; grid-template-columns: minmax(250px, 340px) minmax(0, 1fr); gap: 18px; align-items: start; }
.list { padding: 8px; max-height: calc(100vh - 170px); overflow: auto; position: sticky; top: 18px; }
.item { all: unset; box-sizing: border-box; cursor: pointer; display: block; width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid transparent; }
.item:hover { background: rgba(255,255,255,.05); }
.item[aria-current='true'] { background: rgba(242,154,46,.1); border-color: rgba(242,154,46,.35); }
.item .t { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; font-size: .93rem; }
.item .t span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .m { font-size: .78rem; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0; }
.fact { background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); border-radius: 12px; padding: 10px 12px; }
.fact b { display: block; font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; }
.story { white-space: pre-wrap; background: rgba(0,0,0,.22); border-left: 3px solid var(--gold); padding: 12px 14px; border-radius: 10px; line-height: 1.55; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.thread { display: grid; gap: 10px; margin: 6px 0 18px; }
.msg { border-radius: 14px; padding: 12px 14px; border: 1px solid var(--line); background: rgba(255,255,255,.03); }
.msg.out { border-color: rgba(242,154,46,.3); background: rgba(242,154,46,.06); }
.msg .h { display: flex; justify-content: space-between; gap: 8px; font-size: .78rem; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.msg .b { line-height: 1.55; font-size: .92rem; overflow-wrap: anywhere; }
.msg .b p { margin: 0 0 8px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 12px; }
.chips button { all: unset; cursor: pointer; font-family: ui-monospace, Menlo, monospace; font-size: .74rem; padding: 4px 9px; border-radius: 99px; background: rgba(221,153,51,.13); color: #ffc27a; border: 1px solid rgba(221,153,51,.25); }
.chips button:hover { background: rgba(221,153,51,.25); }
.tpl-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
#t-html { width: 100%; height: 640px; font-family: ui-monospace, Menlo, monospace; font-size: .78rem; line-height: 1.45; resize: vertical; white-space: pre; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; padding: 12px 18px; border-radius: 14px; background: rgba(20,16,32,.95); border: 1px solid rgba(242,154,46,.45); box-shadow: 0 18px 40px -16px #000; font-size: .9rem; max-width: min(420px, calc(100vw - 40px)); }
.empty { padding: 18px; color: var(--muted); text-align: center; }

@media (max-width: 1100px) {
  .grid-2, .tpl-body { grid-template-columns: 1fr; }
  .preview-card { position: static; }
  .preview, #t-html { height: 520px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px 16px; }
  .kpi .v { font-size: 1.5rem; }
  .tabs { min-width: 0; }
  .view-head .tools, .view-head .tools input { width: 100%; }
  .send-row { flex-wrap: wrap; }
  .send-row input { min-width: 100%; }
  .preview { height: 460px; }
  .side { position: sticky; top: 0; z-index: 10; height: auto; border-radius: 0 0 18px 18px; border: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; flex-direction: row; align-items: center; gap: 10px; }
  .side-brand > div { display: none; }
  .tabs { display: flex; overflow-x: auto; gap: 2px; flex: 1; scrollbar-width: none; }
  .tabs button { padding: 9px 10px; font-size: .84rem; white-space: nowrap; }
  .tabs .ic { display: none; }
  .logout { margin: 0; padding: 8px 12px; }
  .split { grid-template-columns: 1fr; }
  .list { position: static; max-height: 320px; }
  .activity li { grid-template-columns: 1fr auto; }
  .activity li .when { grid-column: 1 / -1; font-size: .74rem; color: var(--muted); }
  .row2 { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 90px 1fr 30px; }
  .main { padding-top: 20px; }
}
