:root {
  --bg: #f4f6f4;
  --panel: #ffffff;
  --line: #e1e7e2;
  --line-strong: #c9d3cb;
  --text: #15211a;
  --muted: #5b6a60;
  --faint: #8a978e;
  --brand: #2f8a3b;
  --brand-deep: #1f5a22;
  --brand-soft: #e6f3e7;
  --top: #0c2311;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #9a6400;
  --warn-soft: #fff4dc;
  --blue: #1d4f91;
  --blue-soft: #e7effa;
  --gray-soft: #eef1ef;
  --radius: 12px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: var(--brand-deep); }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 10px; }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* Top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: var(--top); color: #eaf4e8; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; color: #fff; text-decoration: none; font-weight: 700; }
.brand img { border-radius: 8px; }
.brand-sub { font-weight: 500; color: #9fc79a; }
.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tabs a { color: #cfe3cb; text-decoration: none; padding: 6px 12px; border-radius: 8px; font-weight: 600; }
.tabs a:hover { background: rgba(255, 255, 255, 0.08); }
.tabs a.on { background: #fff; color: var(--top); }
.who { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.who a { color: #cfe3cb; }
.who .link { color: #cfe3cb; }

.main { max-width: 1280px; margin: 0 auto; padding: 22px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head p { margin: 4px 0 0; }

/* Toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search] { min-width: 240px; flex: 1; max-width: 360px; }
input[type=search], input[type=text], input[type=email], input[type=password], select {
  height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff;
}
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
label.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.btn { height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-deep); }
.btn.danger { color: var(--danger); border-color: #f0c3be; }
.btn.danger:hover { background: var(--danger-soft); }
.btn:disabled { opacity: 0.55; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--brand-deep); text-decoration: underline; cursor: pointer; }

/* Cards and grids */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 22px; letter-spacing: -0.01em; }
.stat span { color: var(--muted); font-size: 12.5px; }
.stat.bad { border-color: #f0c3be; background: var(--danger-soft); }
.stat.bad b { color: var(--danger); }
.section { margin-top: 18px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: #fafbfa; font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f7faf7; }
td .sub { color: var(--muted); font-size: 12.5px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--gray-soft); color: #3d4a42; }
.r-zero { background: var(--brand-soft); color: var(--brand-deep); }
.r-dr { background: var(--blue-soft); color: var(--blue); }
.r-pending { background: var(--warn-soft); color: var(--warn); }
.r-bot, .b-bad { background: var(--danger-soft); color: var(--danger); }
.b-test { background: #f1ecfb; color: #5b3a99; }
.b-ok { background: var(--brand-soft); color: var(--brand-deep); }
.badges { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Chat list */
.chat-list { display: grid; gap: 10px; }
.chat-item { display: block; text-decoration: none; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.chat-item:hover { border-color: var(--brand); }
.chat-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.chat-name { font-weight: 700; font-size: 15px; margin-right: 6px; }
.chat-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.chat-preview { margin-top: 8px; color: #2c3a31; background: #f7f9f7; border-radius: 8px; padding: 8px 10px; font-size: 13.5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Transcript */
.transcript { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 78%; padding: 9px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.bubble .who-line { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.bubble.assistant { align-self: flex-start; background: var(--gray-soft); border-bottom-left-radius: 4px; }
.bubble.user { align-self: flex-end; background: var(--brand-soft); border-bottom-right-radius: 4px; }

/* Key-value lists */
dl.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--muted); font-size: 12.5px; }
.timeline .t-bad { color: var(--danger); }
.timeline .t-good { color: var(--brand-deep); }

.back { display: inline-block; margin-bottom: 10px; }
.detail-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.detail-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.note { background: var(--warn-soft); color: #5c3d00; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.error { color: var(--danger); }
.more { display: flex; justify-content: center; margin-top: 12px; }

/* Sign-in screens */
.auth { max-width: 400px; margin: 9vh auto; padding: 0 16px; }
.auth .card { padding: 24px; }
.auth h1 { margin-bottom: 6px; }
.auth form { display: grid; gap: 12px; margin-top: 16px; }
.auth label { display: grid; gap: 5px; font-weight: 600; font-size: 13px; }
.auth .btn { height: 40px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-weight: 700; }
.auth-brand img { border-radius: 8px; }
.auth.inline { max-width: none; margin: 0; padding: 0; }
.narrow { max-width: 420px; }
.btn-link { display: inline-flex; align-items: center; text-decoration: none; }
.note-lead { margin: 0 0 6px; }
.secret { font: 600 16px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--gray-soft); padding: 8px 10px; border-radius: 8px; user-select: all; }

@media (max-width: 700px) {
  .top { padding: 10px 14px 0; gap: 8px 10px; }
  .brand-sub { display: none; }
  .who { margin-left: auto; }
  .tabs { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 8px; }
  .tabs a { white-space: nowrap; }
  .main { padding: 16px 14px 50px; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
  .bubble { max-width: 92%; }
  .toolbar input[type=search] { min-width: 0; max-width: none; width: 100%; }
}
