:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e7ebf0;
  --muted: #97a0ad;
  --accent: #4f86f7;
  --green: #3fb950;
  --red: #e5534b;
  --amber: #d29922;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
h1, h2 { font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
button { cursor: pointer; font: inherit; border-radius: 8px; border: 1px solid var(--line); padding: 8px 14px; background: var(--panel-2); color: var(--text); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; }
button.approve { background: var(--green); border-color: var(--green); color: #04210b; font-weight: 600; }
button.reject { background: transparent; border-color: var(--red); color: var(--red); }
button:disabled { opacity: .55; cursor: default; }

/* Login */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px; width: min(360px, 92vw); text-align: center; }
.login-card h1 { margin: 0 0 4px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.login-card input { padding: 11px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }
.error { color: var(--red); }

/* App */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.brand { font-size: 18px; font-weight: 700; }
.tag { font-size: 11px; font-weight: 600; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 2px 8px; margin-left: 8px; vertical-align: middle; }
.actions { display: flex; gap: 10px; }

.banner { margin: 14px 22px 0; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); }
.banner.ok { border-color: var(--green); }
.banner.bad { border-color: var(--red); color: #ffd9d6; }

.grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 22px; padding: 22px; align-items: start; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }
.right-col { display: flex; flex-direction: column; gap: 22px; }

/* Chat */
.chat-col { display: flex; flex-direction: column; min-height: 0; }
.chatlog {
  margin-top: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 56vh;
  min-height: 320px;
  overflow-y: auto;
}
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg .bubble {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.4;
}
.msg.agent .bubble { background: var(--panel-2); border: 1px solid var(--line); border-top-left-radius: 3px; }
.msg.user .bubble { background: var(--accent); color: #fff; border-top-right-radius: 3px; }
.msg.note .bubble { background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: 13px; }
.msg.thinking .bubble { color: var(--muted); font-style: italic; }

.chatbar { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
.chatbar textarea {
  flex: 1;
  resize: none;
  font: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  max-height: 140px;
}
.chatbar button { white-space: nowrap; }
section h2 { margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.count { font-size: 13px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; color: var(--muted); }

.cards { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card .line1 { font-weight: 600; margin-bottom: 4px; }
.card .why { color: var(--muted); margin: 6px 0 12px; }
.card .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pill { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 9px; border: 1px solid var(--line); }
.pill.assign { color: var(--green); border-color: var(--green); }
.pill.needs_outside { color: var(--amber); border-color: var(--amber); }
.pill.needs_review { color: var(--accent); border-color: var(--accent); }
.spacer { flex: 1; }

.feed { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.event { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font-size: 13px; display: flex; gap: 8px; align-items: baseline; }
.event .when { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.event .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; align-self: center; }
.event .dot.success { background: var(--green); }
.event .dot.error { background: var(--red); }
.event .dot.info { background: var(--muted); }
.event .what { flex: 1; }
