:root {
  --bg: #07080b;
  --side: #0c0d11;
  --card: #12141a;
  --card2: #16181f;
  --line: #23262f;
  --text: #f4f5f8;
  --muted: #8b90a0;
  --brand: #e8772e;
  --brand-2: #ff9a4a;
  --ok: #3ee08f;
  --bad: #ff5c6a;
  --dot: rgba(255,255,255,.045);
  --r: 16px;
  --font: Inter, system-ui, sans-serif;
  --display: "Space Grotesk", Inter, sans-serif;
  --sidew: 228px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.dots {
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 14px 14px;
}

/* AUTH */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 440px; background: #000; }
.auth-hero {
  background:
    radial-gradient(900px 520px at 15% 10%, rgba(232,119,46,.32), transparent 55%),
    radial-gradient(700px 480px at 90% 90%, rgba(232,119,46,.1), transparent 50%),
    #050505;
  position: relative;
}
.auth-hero::after {
  content: ""; position: absolute; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='28' height='28'><circle cx='1' cy='1' r='1' fill='%23e8772e' fill-opacity='0.12'/></svg>");
}
.auth-panel { background: #0c0d11; display: flex; align-items: center; justify-content: center; padding: 36px 32px; border-left: 1px solid #1a1c24; }
.auth-box { width: 100%; max-width: 340px; }
.logo { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -.04em; white-space: nowrap; }
.logo i {
  width: 34px; height: 34px; border-radius: 10px; font-style: normal;
  background: linear-gradient(145deg, #ff9a4a, #e8772e 45%, #c45a14);
  display: grid; place-items: center; box-shadow: 0 8px 24px rgba(232,119,46,.35);
}
.logo em { font-style: normal; color: var(--muted); font-weight: 500; margin-left: 2px; }
.auth-box h1 { font-size: 24px; margin: 28px 0 6px; letter-spacing: -.03em; }
.auth-box .sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
label { display: block; font-size: 13px; margin: 0 0 6px; color: #c9ceda; }
input, select, textarea {
  width: 100%; padding: 0 12px; height: 42px;
  background: #0a0b10; border: 1px solid var(--line); border-radius: 10px; outline: none;
}
textarea { height: auto; padding: 10px 12px; min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(232,119,46,.18); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 16px; border: 0; border-radius: 10px;
  background: var(--brand); color: #fff; font-weight: 600;
}
.btn:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { width: 100%; margin-top: 14px; }
.auth-foot { margin-top: 18px; font-size: 13px; color: var(--muted); text-align: center; }
.auth-foot a { color: var(--brand-2); }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 8px; }

@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; } }

/* APP */
.app { min-height: 100vh; display: grid; grid-template-columns: var(--sidew) 1fr; }
.side {
  background: var(--side); border-right: 1px solid #16181f;
  padding: 18px 12px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh;
}
.side .logo { padding: 4px 8px 18px; }
.side .logo small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; margin-left: 44px; margin-top: -14px; letter-spacing: .04em; }
.side nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; color: #b8bcc8; font-size: 14px;
}
.side nav a:hover { background: #15171e; }
.side nav a.on { color: var(--brand); background: rgba(232,119,46,.08); font-weight: 600; }
.side .ico { width: 18px; opacity: .85; }
.side .grow { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; padding: 12px 8px; border-top: 1px solid #16181f; font-size: 13px; }
.ava { width: 32px; height: 32px; border-radius: 50%; background: #2a1a10; color: var(--brand); display: grid; place-items: center; font-weight: 700; }
.main { min-width: 0; }
.top {
  height: 64px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; border-bottom: 1px solid #16181f;
}
.page { padding: 22px 28px 40px; }
.hello { font-size: 28px; margin: 0; font-family: var(--display); letter-spacing: -.04em; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.chip {
  display: inline-flex; align-items: center;
  height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: #101218; font-size: 13px; color: #c5c9d4;
}
.chip.on { border-color: #3a2a20; background: #1a140f; color: #fff; }

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.kpi {
  background: var(--card); border: 1px solid #1c1f28; border-radius: var(--r); padding: 16px;
  min-height: 108px;
}
.kpi span { font-size: 12px; color: var(--muted); }
.kpi b { display: block; font-size: 26px; margin-top: 10px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 12px; margin-top: 6px; }
.d.up { color: var(--ok); } .d.dn { color: var(--bad); }

.grid-2 { display: grid; grid-template-columns: 1.35fr .9fr; gap: 12px; margin-top: 12px; }
.card { background: var(--card); border: 1px solid #1c1f28; border-radius: var(--r); padding: 18px; }
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }

.chart { height: 180px; position: relative; }
.chart svg { width: 100%; height: 100%; }
.funnel { display: flex; gap: 0; align-items: stretch; height: 86px; border-radius: 10px; overflow: hidden; margin-top: 8px; }
.funnel i { display: flex; align-items: flex-end; justify-content: center; color: #fff; font-size: 11px; font-weight: 700; padding-bottom: 10px; }
.funnel-leg { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 8px; }

.sale { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid #1c1f28; }
.sale:last-child { border: 0; }
.sale small { color: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.bot-card, .add-card {
  height: 168px; border-radius: var(--r); border: 1px solid #1c1f28;
  background: var(--card); padding: 18px; cursor: pointer; display: flex; flex-direction: column; justify-content: center;
}
.add-card { align-items: center; color: var(--muted); border-style: dashed; }
.bot-card:hover, .add-card:hover { border-color: var(--brand); }
.bot-card small { color: var(--muted); }
.tabs { display: flex; gap: 6px; margin: 14px 0 18px; flex-wrap: wrap; }
.tabs.wrap { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; }
.tabs button { height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; }
.tabs button.on { background: var(--brand); border-color: var(--brand); }

.form { max-width: 520px; display: grid; gap: 12px; }
.improve {
  background: rgba(232,119,46,.08); border: 1px solid rgba(232,119,46,.28);
  border-radius: 12px; padding: 12px 14px; font-size: 13px; margin: 12px 0 18px; color: #f0d2b8;
}
.nodes { display: grid; gap: 10px; max-width: 640px; }
.node {
  background: var(--card); border: 1px solid #1c1f28; border-radius: 14px; padding: 14px;
}
.node .hd { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.inbox { display: grid; grid-template-columns: 300px 1fr; min-height: 70vh; border: 1px solid #1c1f28; border-radius: var(--r); overflow: hidden; }
.ilist { border-right: 1px solid #1c1f28; overflow: auto; background: #0e1016; }
.iitem { padding: 12px 14px; border-bottom: 1px solid #1c1f28; cursor: pointer; }
.iitem.on { background: #171922; }
.ichat { display: flex; flex-direction: column; }
.imsgs { flex: 1; padding: 16px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 70%; padding: 8px 12px; border-radius: 12px; font-size: 14px; }
.bubble.in { background: #1c1f28; align-self: flex-start; }
.bubble.out { background: #3a2414; align-self: flex-end; }
.isend { display: flex; gap: 8px; padding: 12px; border-top: 1px solid #1c1f28; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #1c1f28; }
th { color: var(--muted); font-weight: 500; }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, 1fr); } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .inbox { grid-template-columns: 1fr; }
  .page { padding: 16px; }
}

.page.flow-page { padding: 0; height: calc(100vh - 64px); display: flex; flex-direction: column; }
.flow-app { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.flow-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid #1c1f28; background: #0c0d11; }
.flow-add { position: relative; }
.flow-menu { position: absolute; top: 44px; left: 0; z-index: 20; width: 240px; max-height: 70vh; overflow: auto; background: #12141a; border: 1px solid #2a2e3a; border-radius: 12px; padding: 8px; box-shadow: 0 16px 40px #000; }
.fm-cat { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #8b90a0; margin: 8px 0 4px; }
.fm-cat button { display: block; width: 100%; text-align: left; background: transparent; border: 0; color: #eee; padding: 7px 8px; border-radius: 8px; font-size: 13px; text-transform: none; letter-spacing: 0; }
.fm-cat button:hover { background: #1c1f28; }
.flow-body { display: grid; grid-template-columns: 1fr 320px; flex: 1; min-height: 0; }
.flow-canvas { position: relative; overflow: hidden; background: #07080b; background-image: radial-gradient(rgba(255,255,255,.05) 1px, transparent 1px); background-size: 22px 22px; }
.flow-world { position: absolute; inset: 0; transform-origin: 0 0; }
.flow-edges { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.fnode { position: absolute; width: 220px; background: #141722; border: 1px solid #2a2e3a; border-radius: 12px; z-index: 2; box-shadow: 0 8px 24px #0008; }
.fnode.on { box-shadow: 0 0 0 2px #e8772e; }
.fnode .fh { padding: 6px 10px; font-size: 11px; font-weight: 700; color: #fff; border-radius: 11px 11px 0 0; }
.fnode .fb { padding: 10px; font-size: 12px; color: #c5c9d4; min-height: 36px; }
.h-in, .h-out { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: #e8772e; border: 2px solid #0b0d11; }
.h-in { left: -7px; top: 22px; }
.h-out { right: -7px; top: 22px; }
.flow-insp { border-left: 1px solid #1c1f28; background: #0c0d11; padding: 14px; overflow: auto; font-size: 13px; }
.flow-insp label { margin-top: 10px; }
.flow-insp textarea { min-height: 72px; }
.insp-h { font-weight: 700; padding-bottom: 8px; border-bottom: 2px solid; margin-bottom: 8px; }
.fbtn { display: grid; gap: 6px; background: #12141a; padding: 8px; border-radius: 10px; margin: 8px 0; border: 1px solid #23262f; }
@media (max-width: 860px) { .flow-body { grid-template-columns: 1fr; } .flow-insp { display: none; } }

.ai-ov { position: fixed; inset: 0; z-index: 80; background: #07080b; display: flex; flex-direction: column; }
.ai-top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid #1c1f28; background: #0c0d11; }
.ai-body { display: grid; grid-template-columns: 1fr 320px; flex: 1; min-height: 0; }
.ai-canvas { position: relative; overflow: hidden; background: #07080b; background-image: radial-gradient(rgba(255,255,255,.05) 1px, transparent 1px); background-size: 22px 22px; }
.ai-side { border-left: 1px solid #1c1f28; background: #0c0d11; padding: 14px; overflow: auto; font-size: 13px; }
.ai-side-h { font-weight: 700; margin-bottom: 8px; }
.ai-g { padding: 8px; border: 1px solid #23262f; border-radius: 10px; margin: 6px 0; cursor: pointer; background: #12141a; }
.ai-g.on { border-color: #e8772e; }
.ai-g code { color: #e8772e; font-size: 12px; }
.ai-g span { display: block; color: #8b90a0; font-size: 11px; }
.ai-g input { width: 100%; margin-top: 4px; height: 28px; font-size: 12px; }
.h-ok, .h-exp { position: absolute; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #0b0d11; right: -7px; }
.h-ok { background: #22c55e; top: 48px; }
.h-exp { background: #ef4444; top: 68px; }
@media (max-width: 860px) { .ai-body { grid-template-columns: 1fr; } }
