:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-ink: #ffffff;
  --side: #0b1220;
  --side-ink: #cbd5e1;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --ai: #7c3aed;
  --ai-bg: #ede9fe;
  --radius: 12px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; display: flex; min-height: 100vh; background: var(--bg); color: var(--ink); font-size: 15px; }

.sidebar { width: 270px; flex-shrink: 0; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 12px; align-items: center; padding: 22px 20px; border-bottom: 1px solid #1e293b; }
.logo { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.brand-name { color: #fff; font-weight: 700; }
.brand-sub { font-size: 12px; color: #94a3b8; }
nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
nav a { display: flex; gap: 12px; align-items: center; padding: 11px 12px; border-radius: 9px; color: var(--side-ink); text-decoration: none; margin-bottom: 2px; cursor: pointer; }
nav a:hover { background: #111a2e; color: #fff; }
nav a.active { background: #1d2a44; color: #fff; }
nav .num { width: 24px; height: 24px; border-radius: 50%; background: #1e293b; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
nav a.active .num { background: var(--brand); color: #fff; }
.sidebar-foot { padding: 16px 20px; border-top: 1px solid #1e293b; font-size: 12px; }
.ai-mode { padding: 8px 10px; border-radius: 8px; background: #1e293b; margin-bottom: 8px; line-height: 1.4; }
.ai-mode.live { background: #14532d; color: #dcfce7; }
.ai-mode.fallback { background: #422006; color: #fde68a; }
.tenant { color: #64748b; }

main { flex: 1; padding: 32px 40px 60px; max-width: 1280px; min-width: 0; }
.scene-head { margin-bottom: 24px; }
.scene-head h1 { margin: 0 0 6px; font-size: 26px; }
.scene-head p { margin: 0; color: var(--muted); max-width: 820px; line-height: 1.5; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card .sub { color: var(--muted); font-size: 13px; margin-bottom: 12px; line-height: 1.45; }

.step { display: grid; grid-template-columns: 34px 1fr; gap: 14px; margin-bottom: 14px; }
.step .dot { width: 34px; height: 34px; border-radius: 50%; background: #e2e8f0; color: var(--muted); display: grid; place-items: center; font-weight: 700; }
.step.done .dot { background: var(--ok); color: #fff; }
.step.active .dot { background: var(--brand); color: #fff; }
.step .card { margin: 0; }
.step.locked .card { opacity: .55; }
.result { margin-top: 12px; }
.result:empty { display: none; }

button { font: inherit; border: 0; border-radius: 9px; padding: 9px 16px; background: var(--brand); color: var(--brand-ink); font-weight: 600; cursor: pointer; }
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: default; filter: none; }
button.ghost { background: #eef2ff; color: var(--brand); }
button.danger { background: var(--bad); }
button.success { background: var(--ok); }
button.small { padding: 6px 11px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.form label { font-size: 12px; color: var(--muted); display: grid; gap: 4px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #f1f5f9; color: #334155; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: #166534; }
.badge.bad { background: var(--bad-bg); color: #991b1b; }
.badge.warn { background: var(--warn-bg); color: #92400e; }
.badge.ai { background: var(--ai-bg); color: #5b21b6; }
.badge.blue { background: #dbeafe; color: #1e40af; }

.callout { border-radius: 10px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; line-height: 1.45; }
.callout.ok { background: var(--ok-bg); color: #14532d; }
.callout.bad { background: var(--bad-bg); color: #7f1d1d; }
.callout.ai { background: var(--ai-bg); color: #3b0764; }
.callout.info { background: #e0f2fe; color: #0c4a6e; }
.callout .icon { font-size: 18px; line-height: 1.2; }

.ai-card { border: 1px solid #ddd6fe; background: #faf5ff; border-radius: 10px; padding: 12px 14px; }
.ai-card .who { font-weight: 700; color: #5b21b6; display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.ai-card .reason { color: #3b0764; font-size: 14px; line-height: 1.5; }
.fallback-tag { font-size: 11px; color: #92400e; background: var(--warn-bg); border-radius: 6px; padding: 2px 6px; font-weight: 600; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.big { font-size: 34px; font-weight: 800; line-height: 1; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.matrix td.cell { text-align: center; font-weight: 700; }
.matrix td.cell.allow { background: var(--ok-bg); color: #166534; }
.matrix td.cell.deny { background: var(--bad-bg); color: #991b1b; }
.matrix td.cell.pending { color: #cbd5e1; }

.chat { display: flex; flex-direction: column; gap: 10px; min-height: 360px; max-height: 560px; overflow-y: auto; padding: 6px 2px; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 14px; line-height: 1.45; }
.bubble.customer { align-self: flex-start; background: #f1f5f9; border-bottom-left-radius: 4px; }
.bubble.agent { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.bubble.draft { align-self: flex-end; background: #fff; border: 2px dashed #a78bfa; color: var(--ink); border-bottom-right-radius: 4px; }
.bubble .meta .badge { white-space: normal; text-align: left; }
.bubble .meta { font-size: 12px; margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { background: #eef2ff; color: #3730a3; border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; border: 0; font-weight: 500; }

#map { height: 520px; border-radius: var(--radius); border: 1px solid var(--line); }
.feed { display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow-y: auto; }
.feed .item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.45; background: #fff; }
.feed .item .when { color: var(--muted); font-size: 11px; }
.log { background: #0b1220; color: #a7f3d0; font-family: ui-monospace, Menlo, monospace; font-size: 12px; border-radius: 10px; padding: 10px 12px; height: 150px; overflow-y: auto; white-space: pre-wrap; }

.stat { text-align: left; }
.stat .label { color: var(--muted); font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1100px) { .tiles { grid-template-columns: 1fr; } }
.tile { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.tile:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15, 23, 42, .08); }
.tile .n { color: var(--brand); font-weight: 800; font-size: 13px; }
.tier-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; margin: 10px 0 8px; }
.tier-bar div { height: 100%; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.spinner { width: 14px; height: 14px; border: 2px solid #c7d2fe; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--muted); }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
