:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #18202f;
  --muted: #667085;
  --line: #dde3ec;
  --accent: #0b9f7a;
  --accent-dark: #06765a;
  --danger: #c2410c;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  padding: 10px 14px;
  cursor: pointer;
}
button:hover { background: var(--accent-dark); }
button.secondary { background: #eef3f7; color: var(--ink); }
button.secondary:hover { background: #e2e9f0; }
.ghost { width: 100%; background: #eef3f7; color: var(--ink); }
.shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.sidebar { border-right: 1px solid var(--line); background: #ffffff; padding: 20px; display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand.compact { margin-bottom: 18px; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 8px; background: #e3f8f1; color: var(--accent-dark); font-weight: 800; }
.brand strong { display: block; }
.brand small { display: block; color: var(--muted); margin-top: 2px; }
nav { display: grid; gap: 6px; }
nav a { color: var(--ink); text-decoration: none; padding: 10px 12px; border-radius: 7px; }
nav a.active, nav a:hover { background: #eef8f5; color: var(--accent-dark); }
.main { padding: 28px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
h1 { margin: 0; font-size: 28px; letter-spacing: 0; }
h2 { margin: 0 0 14px; font-size: 17px; }
p { line-height: 1.65; }
.topbar p { margin: 6px 0 0; color: var(--muted); }
.status-pill { padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: white; }
.notice { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.notice span { background: #fff7ed; color: var(--danger); border: 1px solid #fed7aa; border-radius: 7px; padding: 8px 10px; }
.chat-layout { display: grid; grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); gap: 18px; height: calc(100vh - 132px); min-height: 580px; }
.assistant-panel, .chat-panel, .panel, .metric { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.assistant-panel { padding: 16px; overflow: auto; display: grid; align-content: start; gap: 18px; }
label { display: grid; gap: 8px; font-weight: 650; }
select, input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 11px 12px; background: white; color: var(--ink); }
textarea { resize: vertical; }
.conversation-section { display: grid; gap: 10px; }
.conversation-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.conversation-header h2 { margin: 0; }
.conversation-list { display: grid; gap: 8px; }
.conversation-item { width: 100%; text-align: left; display: grid; gap: 4px; padding: 10px 11px; background: #f7fafc; color: var(--ink); border: 1px solid var(--line); border-radius: 7px; }
.conversation-item:hover, .conversation-item.active { background: #eef8f5; border-color: #bce8da; color: var(--accent-dark); }
.conversation-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-item span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assistant-list { display: grid; gap: 10px; }
.assistant-list article { border-top: 1px solid var(--line); padding-top: 12px; }
.assistant-list strong, .assistant-list span { display: block; }
.assistant-list span { color: var(--muted); margin-top: 5px; line-height: 1.5; }
.chat-panel { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.chat-toolbar { border-bottom: 1px solid var(--line); padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff; }
.chat-toolbar span { color: var(--muted); margin-right: 8px; }
.chat-toolbar strong { color: var(--accent-dark); }
.messages { padding: 18px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.message { max-width: 880px; border: 1px solid var(--line); border-radius: 8px; padding: 13px 14px; background: #fbfcfe; }
.message.user { align-self: flex-end; background: #eef8f5; border-color: #bce8da; }
.message strong { display: inline-block; margin-bottom: 4px; }
.message small { margin-left: 8px; color: var(--muted); }
.message p { margin: 0; white-space: normal; overflow-wrap: anywhere; }
.composer { border-top: 1px solid var(--line); padding: 14px; display: grid; grid-template-columns: 1fr auto; gap: 12px; background: #fff; }
.composer-input { display: grid; gap: 9px; min-width: 0; }
.composer-actions { display: grid; align-content: end; gap: 8px; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 8px; }
.attachment-chip { border: 1px solid var(--line); border-radius: 7px; background: #f7fafc; color: var(--ink); padding: 6px 8px; display: inline-flex; align-items: center; gap: 6px; max-width: 280px; }
.attachment-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip small { color: var(--muted); }
.attachment-chip button { padding: 0; width: 18px; height: 18px; border-radius: 999px; background: #e2e9f0; color: var(--ink); line-height: 1; }
.attachment-chip button:hover { background: #d7e0e8; }
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { padding: 15px; }
.metric span, .metric small { display: block; color: var(--muted); }
.metric strong { display: block; font-size: 30px; margin: 8px 0; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.8fr); gap: 18px; }
.panel { padding: 16px; min-width: 0; }
.table { display: grid; gap: 1px; overflow: auto; }
.row { display: grid; grid-template-columns: 180px 100px 80px 80px minmax(260px, 1fr); gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.row.head { font-weight: 700; color: var(--muted); }
.status.failed { color: var(--danger); }
.status.succeeded { color: var(--accent-dark); }
.stack { display: grid; gap: 10px; }
.knowledge-item { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.knowledge-item strong, .knowledge-item small { display: block; }
.knowledge-item small, .muted { color: var(--muted); }
.knowledge-item p { margin-bottom: 0; }
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(100%, 380px); background: white; border: 1px solid var(--line); border-radius: 8px; padding: 22px; display: grid; gap: 16px; }
.error { color: var(--danger); margin: 0; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .chat-layout, .admin-grid { grid-template-columns: 1fr; height: auto; }
  .chat-panel { min-height: 620px; }
  .composer { grid-template-columns: 1fr; }
  .row { grid-template-columns: 140px 90px 70px 70px minmax(220px, 1fr); }
}
