:root {
  --bg: #0b0f14; --panel: #111821; --panel2: #16202b; --line: #223040;
  --text: #dce6f0; --muted: #7d8fa3; --accent: #3ddc97; --accent-ink: #062418;
  --warn: #f5b94a; --bad: #ff6b6b; --info: #6cb6ff;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); min-height: 1.2em; }
a { color: var(--info); }
button, input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px;
}
textarea { width: 100%; min-height: 90px; font-family: var(--mono); font-size: 13px; resize: vertical; }
input, select { width: 100%; }
button { cursor: pointer; background: var(--panel2); }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--bad); border-color: #5a2a2a; }
button.link { background: none; border: none; color: var(--muted); padding: 0; }
button.block { width: 100%; }
button:disabled { opacity: .5; cursor: default; }
label { display: block; margin: 10px 0; color: var(--muted); font-size: 12px; }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--text); font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.brand b { color: var(--accent); }
.brand span { color: var(--muted); font-weight: 400; }

.auth { display: grid; place-items: center; min-height: 100%; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; }

.app { display: grid; grid-template-columns: 250px 1fr; height: 100%; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 16px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.agent-link { text-align: left; background: none; border: 1px solid transparent; display: flex; justify-content: space-between; gap: 8px; }
.agent-link.active { background: var(--panel2); border-color: var(--line); }
.sidebar-foot { display: flex; justify-content: space-between; align-items: end; gap: 8px; }
main { overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.empty { margin: auto; text-align: center; padding: 24px; }

.agent-head { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.agent-head h1 { font-size: 18px; margin: 0; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-family: var(--mono); }
.pill.ok { color: var(--accent); border-color: #1e5a43; }
.pill.warn { color: var(--warn); border-color: #5a4a1e; }
.pill.bad { color: var(--bad); border-color: #5a2a2a; }
.tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 10px 12px; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { background: var(--warn); color: #241a05; border-radius: 999px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.pane { flex: 1; overflow: auto; padding: 16px 20px; }

.chat { display: flex; flex-direction: column; height: 100%; }
.chat-log { flex: 1; overflow: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 760px; padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: #17324a; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); }
.msg.system { align-self: center; color: var(--muted); font-size: 12px; font-family: var(--mono); background: none; padding: 2px 8px; }
.msg .meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; font-family: var(--mono); }
.chat-input { border-top: 1px solid var(--line); padding: 12px 20px; display: flex; gap: 8px; }
.chat-input textarea { min-height: 44px; height: 44px; font-family: var(--sans); font-size: 14px; }
.thinking { color: var(--muted); font-style: italic; align-self: flex-start; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.mono, .mono { font-family: var(--mono); font-size: 12px; }
pre { white-space: pre-wrap; word-wrap: break-word; font-family: var(--mono); font-size: 12px; margin: 0; }
.list { display: flex; flex-direction: column; gap: 10px; }
.item { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.item h3 { margin: 0 0 4px; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.section-title h2 { margin: 0; font-size: 15px; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; width: min(640px, 94vw); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.6); }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .grid2 { grid-template-columns: 1fr; }
  .pane, .chat-log, .chat-input, .agent-head { padding-left: 16px; padding-right: 16px; }
}
