:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #15202b;
  --muted: #5b6b7c;
  --border: #d9e0e8;
  --accent: #0b5cad;
  --accent-text: #ffffff;
  --accent-soft: #e3effb;
  --ok: #1d7a4c;
  --warn: #a35c00;
  --danger: #b42318;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419; --surface: #172029; --surface-2: #1f2a35; --text: #e6edf3; --muted: #93a3b4;
    --border: #2b3946; --accent: #4fa3f7; --accent-text: #08131d; --accent-soft: #15324d;
    --ok: #4cc38a; --warn: #f0a445; --danger: #f97066;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
header.top .brand { font-weight: 700; display: flex; align-items: center; gap: .5rem; color: var(--text); }
header.top nav { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .9rem; }
main { max-width: 1180px; margin: 0 auto; padding: 1.25rem 16px 3rem; }

.grid { display: grid; gap: 1rem; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-6 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.grid > .card + .card { margin-top: 0; }
.stat .n { font-size: 1.6rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .85rem; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem;
         background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.ok { color: var(--ok); } .badge.warn { color: var(--warn); } .badge.danger { color: var(--danger); }

.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem; border-radius: 8px;
       border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
       font: inherit; font-size: .9rem; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

label { display: block; font-weight: 600; font-size: .85rem; margin: .8rem 0 .3rem; }
input[type=text], input[type=number], textarea, select {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 90px; resize: vertical; }

table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
.table-wrap { overflow-x: auto; max-width: 100%; }
td pre { margin: 0; white-space: pre-wrap; word-break: break-word; max-width: 420px; font-size: .8rem; }

.timeline .item { padding: .6rem .8rem; border-radius: 10px; margin: .5rem 0; max-width: 85%; }
.timeline .user { background: var(--surface-2); }
.timeline .assistant { background: var(--accent-soft); margin-left: auto; }
.timeline .staff { background: #fff4e5; color: #4a2a00; margin-left: auto; }
.timeline .tool { font-size: .8rem; border: 1px dashed var(--border); max-width: 100%; }
.timeline .tool pre { white-space: pre-wrap; word-break: break-word; margin: .3rem 0 0; }
.timeline .meta { font-size: .72rem; color: var(--muted); margin-bottom: .2rem; }
details summary { cursor: pointer; }

/* ---------- chat ---------- */
.chat-shell { max-width: 760px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column;
              background: var(--surface); border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
.chat-head .row { flex-wrap: nowrap; }
.chat-head { padding: .9rem 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between;
             align-items: center; gap: .5rem; }
.chat-log { flex: 1; overflow-y: auto; padding: 1rem 16px; display: flex; flex-direction: column; gap: .6rem; }
.bubble { padding: .6rem .85rem; border-radius: 14px; max-width: 85%; white-space: pre-wrap; word-wrap: break-word; }
.bubble.bot { background: var(--surface-2); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.me { background: var(--accent); color: var(--accent-text); align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.staff { background: #fff4e5; color: #4a2a00; align-self: flex-start; }
.bubble.notice { align-self: center; background: transparent; color: var(--muted); font-size: .85rem; }
.bubble p { margin: 0 0 .4rem; } .bubble p:last-child { margin: 0; }
.bubble ul { margin: .2rem 0; padding-left: 1.2rem; }
.typing { color: var(--muted); font-size: .85rem; padding: 0 16px .5rem; min-height: 1.4rem; }
.chat-form { display: flex; gap: .5rem; padding: .75rem 16px; border-top: 1px solid var(--border); }
.chat-form input { flex: 1; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface);
            color: var(--text); cursor: pointer; font-size: 1.1rem; flex: none; }
.icon-btn.on { background: var(--danger); color: #fff; border-color: var(--danger); }

.hero { padding: 1.5rem 0 1rem; }
.agent-card h2 { margin-bottom: .25rem; }
.agent-card .channels { margin-top: .8rem; display: grid; gap: .4rem; font-size: .9rem; }
code { background: var(--surface-2); padding: .05rem .35rem; border-radius: 5px; font-size: .85em; }
