:root {
  --orange: #fa582d;
  --orange-600: #e34a21;
  --orange-100: #fff1ec;
  --ink: #0e1116;
  --ink-2: #171b22;
  --ink-3: #232935;
  --line: #e6e8ec;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1f29;
  --muted: #6b7280;
  --ok: #16a34a;
  --ok-bg: #ecfdf3;
  --block: #dc2626;
  --block-bg: #fef2f2;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.accent { color: var(--orange); }

/* ---------- marca ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.5px; color: #fff; }
.brand b { color: var(--orange); font-weight: 800; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, var(--orange), #ff8a5c); position: relative; box-shadow: 0 4px 14px rgba(250, 88, 45, .45); }
.brand-mark::after { content: ""; position: absolute; inset: 7px; border: 3px solid #fff; border-radius: 3px; transform: rotate(45deg) scale(.8); }
.brand-lg { font-size: 26px; }

/* ---------- botões ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 13px 20px; border-radius: 12px; border: 0; font-weight: 600; transition: .15s; }
.btn-primary { background: var(--orange); color: #fff; box-shadow: 0 6px 18px rgba(250, 88, 45, .35); }
.btn-primary:hover { background: var(--orange-600); transform: translateY(-1px); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--orange); color: var(--orange); }
.btn-block { width: 100%; }
.icon-btn { background: transparent; border: 0; color: inherit; opacity: .8; padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.icon-btn:hover { opacity: 1; background: rgba(255, 255, 255, .12); }

/* ---------- login ---------- */
.login { display: grid; grid-template-columns: 1.15fr 1fr; min-height: 100vh; }
.login-hero { position: relative; overflow: hidden; background: radial-gradient(1200px 600px at -10% 110%, rgba(250, 88, 45, .35), transparent 60%), var(--ink); color: #fff; padding: 64px 72px; display: flex; flex-direction: column; justify-content: center; gap: 22px; }
.login-hero h1 { font-size: 44px; line-height: 1.1; letter-spacing: -1.5px; margin: 24px 0 0; font-weight: 800; }
.login-hero .lead { color: #b8bfcc; font-size: 16px; max-width: 520px; line-height: 1.6; margin: 0; }
.hero-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 14px; color: #d6dae3; font-size: 15px; }
.hero-list li { display: flex; align-items: center; gap: 12px; }
.hero-list .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 5px rgba(250, 88, 45, .18); }
.hero-glow { position: absolute; right: -180px; top: -180px; width: 480px; height: 480px; border-radius: 50%; border: 70px solid rgba(250, 88, 45, .08); }
.login-panel { display: grid; place-items: center; padding: 40px; }
.login-card { width: 100%; max-width: 420px; background: var(--card); border-radius: 22px; padding: 40px 36px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.login-card h2 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.5px; }
.login-card .muted { margin: 0 0 26px; }
.login-steps { margin-top: 26px; display: grid; gap: 12px; color: var(--muted); font-size: 13px; }
.login-steps div { display: flex; align-items: center; gap: 12px; }
.login-steps span { width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--orange-100); color: var(--orange); font-weight: 700; font-size: 12px; }
.disclaimer { margin: 26px 0 0; font-size: 12px; color: #9aa1ad; text-align: center; }
.config-warning { margin-top: 20px; padding: 12px 14px; border-radius: 10px; background: var(--warn-bg); color: #92400e; font-size: 12px; line-height: 1.5; border: 1px solid #fde68a; }

/* ---------- app ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 36px; padding: 0 32px; height: 68px; background: var(--ink); color: #fff; }
.topnav { display: flex; gap: 6px; flex: 1; }
.topnav a { padding: 8px 14px; border-radius: 10px; color: #aab1bd; font-weight: 500; }
.topnav a:hover { color: #fff; }
.topnav a.active { color: #fff; background: var(--ink-3); box-shadow: inset 0 -2px 0 var(--orange); }
.user-chip { display: flex; align-items: center; gap: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--orange); font-weight: 700; }
.user-meta { display: grid; line-height: 1.25; }
.user-meta small { color: #9aa1ad; font-size: 12px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout { color: #9aa1ad; padding: 8px; border-radius: 8px; display: grid; }
.logout:hover { color: #fff; background: var(--ink-3); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 28px; padding: 28px 32px; max-width: 1480px; margin: 0 auto; }
.dashboard { display: grid; gap: 22px; align-content: start; }
.greeting h1 { margin: 0; font-size: 26px; letter-spacing: -.6px; }
.greeting p { margin: 4px 0 0; }

.balance-card { position: relative; overflow: hidden; border-radius: 22px; padding: 28px 30px; color: #fff; background: radial-gradient(500px 220px at 100% 0%, rgba(255, 255, 255, .18), transparent 60%), linear-gradient(135deg, #fa582d 0%, #d9431c 55%, #1b1f27 140%); box-shadow: 0 18px 40px rgba(250, 88, 45, .28); }
.balance-top { display: flex; justify-content: space-between; align-items: center; opacity: .92; font-weight: 500; }
.balance-value { font-size: 40px; font-weight: 800; letter-spacing: -1px; margin: 8px 0 22px; }
.balance-value.masked { letter-spacing: 4px; }
.balance-sub { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, .25); }
.balance-sub small { display: block; opacity: .85; font-size: 12px; }
.balance-sub b { font-size: 15px; }

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.quick-actions button { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 10px; display: grid; justify-items: center; gap: 10px; font-weight: 600; color: var(--text); transition: .15s; }
.quick-actions button:hover { border-color: var(--orange); transform: translateY(-2px); box-shadow: var(--shadow); }
.qa-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--orange-100); color: var(--orange); display: grid; place-items: center; }
.qa-icon svg { width: 22px; height: 22px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-head h3 { margin: 0; font-size: 16px; }
.link { color: var(--orange); font-weight: 600; font-size: 13px; }
.tx-list { list-style: none; margin: 0; padding: 0; }
.tx-list li { display: grid; grid-template-columns: 40px 1fr auto; gap: 14px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); }
.tx-list li:last-child { border-bottom: 0; }
.tx-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: #f1f3f6; font-size: 18px; }
.tx-list b { display: block; font-weight: 600; }
.tx-list small { color: var(--muted); }
.tx-amount { font-weight: 700; }
.tx-amount.in { color: var(--ok); }

.security-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.ss-item { display: flex; gap: 12px; align-items: flex-start; }
.ss-item small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; word-break: break-all; }
.ss-icon { width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; flex: none; background: var(--muted); }
.ss-icon.ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-bg); }
.ss-icon.warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-bg); }

/* ---------- assistente ---------- */
.assistant { position: sticky; top: 96px; height: calc(100vh - 124px); min-height: 560px; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
.assistant-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; background: var(--ink); color: #fff; }
.bot-avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--orange); }
.bot-meta { flex: 1; display: grid; }
.bot-meta small { color: #aab1bd; display: flex; align-items: center; gap: 6px; font-size: 12px; }
.live { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .25); }

.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 10px; }
.tab { flex: 1; background: none; border: 0; padding: 13px 8px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; display: flex; gap: 6px; justify-content: center; align-items: center; }
.tab.active { color: var(--text); border-bottom-color: var(--orange); }
.badge { min-width: 20px; padding: 1px 6px; border-radius: 10px; background: var(--orange); color: #fff; font-size: 11px; }
.tab-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; background: #fafbfc; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: 86%; padding: 11px 14px; border-radius: 14px; line-height: 1.55; word-wrap: break-word; }
.msg.bot .bubble { background: var(--card); border: 1px solid var(--line); border-top-left-radius: 4px; }
.msg.user .bubble { background: var(--ink-2); color: #fff; border-top-right-radius: 4px; }
.bubble code { background: #f1f3f6; padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }
.bubble ul { margin: 6px 0; padding-left: 18px; }
.msg.blocked .bubble { background: var(--block-bg); border: 1px solid #fecaca; color: #7f1d1d; }
.block-title { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--block); margin-bottom: 4px; }
.block-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #fff; border: 1px solid var(--line); color: var(--text); }
.tag.red { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
.tag.green { background: var(--ok-bg); border-color: #bbf7d0; color: #166534; }
.tag.amber { background: var(--warn-bg); border-color: #fde68a; color: #92400e; }
.msg-foot { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; gap: 6px; align-items: center; }
.msg.error .bubble { background: var(--warn-bg); border: 1px solid #fde68a; color: #78350f; }

.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: #c2c7d0; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 14px 0; scrollbar-width: none; }
.chips button { flex: none; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; font-size: 12.5px; color: var(--text); }
.chips button:hover { border-color: var(--orange); color: var(--orange); }
.chips .chip-attack:hover { border-color: var(--block); color: var(--block); }
.composer { display: flex; gap: 10px; padding: 12px 14px 16px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; font: inherit; max-height: 140px; outline: none; background: #fafbfc; }
.composer textarea:focus { border-color: var(--orange); background: #fff; box-shadow: 0 0 0 4px rgba(250, 88, 45, .1); }
.send { width: 46px; height: 46px; flex: none; border: 0; border-radius: 14px; background: var(--orange); color: #fff; display: grid; place-items: center; }
.send:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- painel de segurança ---------- */
#tab-security, #tab-identity { overflow-y: auto; padding: 16px; gap: 14px; }
.sec-empty { color: var(--muted); text-align: center; padding: 40px 20px; line-height: 1.6; }
.timeline { display: grid; gap: 14px; }
.turn { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.turn-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 14px; background: #fafbfc; border-bottom: 1px solid var(--line); }
.turn-head b { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn-head small { color: var(--muted); flex: none; }
.ev { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 11px 14px; border-bottom: 1px dashed var(--line); }
.ev:last-child { border-bottom: 0; }
.ev-icon { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 13px; }
.ev-icon.allow { background: var(--ok-bg); color: var(--ok); }
.ev-icon.block { background: var(--block-bg); color: var(--block); }
.ev-icon.info { background: #eef2ff; color: #4338ca; }
.ev-icon.warn { background: var(--warn-bg); color: var(--warn); }
.ev-title { font-weight: 600; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ev-sub { color: var(--muted); font-size: 12px; margin-top: 3px; line-height: 1.5; word-break: break-word; }
.ev-sub code { background: #f1f3f6; padding: 0 4px; border-radius: 4px; }

/* ---------- identidade ---------- */
.id-grid { display: grid; gap: 10px; }
.id-row { border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; }
.id-row small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.id-row div { margin-top: 3px; font-weight: 500; word-break: break-all; }
.claims { background: var(--ink); color: #e5e7eb; border-radius: 12px; padding: 14px; font-size: 12px; overflow: auto; max-height: 340px; }

/* ---------- toast / erro ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); z-index: 50; }
.error-page { display: grid; place-items: center; min-height: 100vh; background: var(--ink); }
.error-card { background: #fff; border-radius: 20px; padding: 36px; max-width: 640px; width: calc(100% - 40px); }
.error-card .brand { color: var(--ink); margin-bottom: 18px; }
.error-card pre { white-space: pre-wrap; background: var(--bg); padding: 14px; border-radius: 10px; font-size: 12.5px; }

/* ---------- responsivo ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .assistant { position: relative; top: 0; height: 680px; }
  .topnav { display: none; }
}
@media (max-width: 760px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { padding: 40px 28px; }
  .login-hero h1 { font-size: 32px; }
  .layout { padding: 18px; }
  .quick-actions, .security-strip { grid-template-columns: repeat(2, 1fr); }
  .balance-sub { grid-template-columns: 1fr 1fr; }
  .user-meta { display: none; }
}
