:root {
  --bg: #f5f7f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --side: #0b1220;
  --side-ink: #cbd5e1;
  --accent: #10b981;
  --accent-ink: #065f46;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
.hidden { display: none !important; }
code, pre { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.error { color: var(--danger); min-height: 1em; }

.demo-banner { background: #fef3c7; color: #78350f; font-size: 12.5px; text-align: center; padding: 6px 12px; border-bottom: 1px solid #fde68a; position: sticky; top: 0; z-index: 20; }

/* Login */
.login { display: grid; place-items: center; min-height: calc(100vh - 32px); background: radial-gradient(circle at 30% 20%, #d1fae5, transparent 50%), var(--bg); }
.login-card { background: var(--panel); padding: 32px; border-radius: 16px; width: 360px; box-shadow: 0 10px 40px rgba(15, 23, 42, .08); display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin: 0; }

/* Shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 32px); }
.sidebar { background: var(--side); color: var(--side-ink); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 32px; height: calc(100vh - 32px); }
.brand { font-weight: 700; font-size: 16px; color: #fff; display: flex; align-items: center; gap: 8px; padding: 0 8px; }
.brand.big { font-size: 22px; color: var(--ink); padding: 0; }
.bolt { color: var(--accent); }
nav { display: grid; gap: 2px; overflow: auto; }
nav .group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; padding: 12px 10px 4px; }
nav a { color: var(--side-ink); text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: 14px; display: flex; gap: 10px; }
nav a:hover { background: #1e293b; }
nav a.active { background: #134e4a; color: #fff; }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding: 0 8px; }
main { min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 20px 28px 8px; gap: 12px; flex-wrap: wrap; }
.topbar h1 { font-size: 22px; margin: 0; }
.view { padding: 12px 28px 40px; display: grid; gap: 18px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }

/* Bars */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.bars div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; opacity: .85; min-height: 2px; }
.bars-x { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 4px; }

/* Tables */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 4px; flex-wrap: nowrap; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: #e2e8f0; color: #334155; }
.b-green { background: #d1fae5; color: var(--accent-ink); }
.b-blue { background: #dbeafe; color: #1e40af; }
.b-amber { background: #fef3c7; color: #92400e; }
.b-red { background: #fee2e2; color: #991b1b; }
.method { font-family: ui-monospace, monospace; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; min-width: 52px; text-align: center; display: inline-block; }
.m-GET { background: #dbeafe; color: #1e40af; }
.m-POST { background: #d1fae5; color: #065f46; }
.m-PUT { background: #fef3c7; color: #92400e; }
.m-DELETE { background: #fee2e2; color: #991b1b; }
.m-ANY, .m-PATCH { background: #ede9fe; color: #5b21b6; }

/* Controls */
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 8px; font-size: 13.5px; cursor: pointer; font-weight: 500; }
.btn:hover { border-color: #94a3b8; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.ghost { background: transparent; border-color: transparent; color: inherit; }
.btn:disabled { opacity: .5; cursor: progress; }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 14px; background: #fff; color: var(--ink); }
textarea { font-family: ui-monospace, monospace; font-size: 12.5px; width: 100%; min-height: 140px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #a7f3d0; border-color: var(--accent); }

/* Console */
.console { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.2fr); gap: 14px; align-items: start; }
.endpoint-list { max-height: 70vh; overflow: auto; }
.endpoint { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.endpoint:hover, .endpoint.sel { background: #f0fdf4; }
.endpoint code { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.endpoint .fx { color: var(--warn); font-size: 12px; }
.cat-head { padding: 8px 12px; background: #f8fafc; font-size: 12px; font-weight: 600; color: var(--muted); position: sticky; top: 0; border-bottom: 1px solid var(--line); }
pre.json { background: #0b1220; color: #d1fae5; padding: 14px; border-radius: 8px; overflow: auto; max-height: 60vh; margin: 0; }

/* Modal & toasts */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(720px, 94vw); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
.modal { padding: 18px 20px 20px; display: grid; gap: 12px; }
.modal h3 { margin: 0; }
.modal label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--side); color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: 380px; border-left: 4px solid var(--accent); }
.toast.err { border-left-color: var(--danger); }

.chat { display: grid; gap: 10px; }
.bubble { padding: 10px 14px; border-radius: 12px; max-width: 80%; font-size: 14px; }
.bubble.me { background: #d1fae5; justify-self: end; }
.bubble.ai { background: var(--panel); border: 1px solid var(--line); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .console { grid-template-columns: 1fr; }
}
