:root {
  --bg: #0a0d12;
  --panel: #11161e;
  --panel-2: #171d27;
  --line: #27303d;
  --text: #f2f5f8;
  --muted: #97a3b3;
  --accent: #42d3a4;
  --accent-strong: #24b989;
  --danger: #ff7b7b;
  --radius: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.shell { width: min(1440px, 100%); min-height: 100vh; margin: 0 auto; padding: 20px 24px 28px; }
.topbar { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; color: #07100d; background: var(--accent); font-weight: 850; }
h1, h2, p { margin: 0; }
h1 { font-size: 18px; letter-spacing: -.02em; }
h2 { font-size: 15px; line-height: 1.35; }
.brand p, .panel-head p, .auth-panel p { color: var(--muted); font-size: 12px; margin-top: 3px; }
.connection { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #687386; }
.connection[data-state="online"] .status-dot { background: var(--accent); box-shadow: 0 0 0 4px rgba(66,211,164,.1); }
.scope { color: var(--accent); border-left: 1px solid var(--line); padding-left: 8px; font-weight: 700; text-transform: capitalize; }
.auth-panel { max-width: 1080px; margin: 5vh auto 0; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.auth-copy { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.staging-badge { flex: 0 0 auto; padding: 5px 8px; border: 1px solid rgba(66,211,164,.32); border-radius: 999px; color: var(--accent); background: rgba(66,211,164,.08); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.role-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.role-card { min-height: 106px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: #0d1118; text-align: left; }
.role-card strong, .role-card span, .role-card small { display: block; }
.role-card strong { margin-bottom: 5px; font-size: 12px; }
.role-card span { min-height: 32px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.role-card small { margin-top: 9px; color: #687386; font-size: 9px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.role-card:hover { border-color: #435063; }
.role-card.selected { border-color: var(--accent-strong); box-shadow: 0 0 0 2px rgba(66,211,164,.08); }
.role-card.selected small, .role-card.active small { color: var(--accent); }
.role-card.active { background: rgba(66,211,164,.06); }
.credential-form { display: grid; grid-template-columns: minmax(240px, 1.4fr) minmax(180px, 1fr) 110px auto; gap: 8px; align-items: center; }
.credential-form > button, .token-form button { height: 42px; border: 0; border-radius: 8px; background: var(--accent); color: #06110d; font-weight: 800; padding: 0 18px; }
.memory-option { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; width: fit-content; margin-top: 2px; color: var(--muted); font-size: 10px; }
.memory-option input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }
.auth-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; color: var(--muted); font-size: 10px; }
.text-button { padding: 0; border: 0; color: var(--muted); background: transparent; font-size: 10px; text-decoration: underline; text-underline-offset: 3px; }
.advanced-auth { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.advanced-auth summary { width: fit-content; cursor: pointer; color: var(--muted); font-size: 11px; }
.token-form { display: flex; gap: 8px; max-width: 680px; margin-top: 10px; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; outline: none; background: #0d1118; color: var(--text); }
input { height: 42px; padding: 0 12px; }
textarea { resize: none; min-height: 50px; max-height: 160px; padding: 13px 14px; line-height: 1.45; }
input:focus, textarea:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 3px rgba(66,211,164,.09); }
.composer button { border: 0; border-radius: 8px; background: var(--accent); color: #06110d; font-weight: 800; padding: 0 18px; }
button:disabled { cursor: wait; opacity: .55; }
.form-error { margin-top: 10px !important; color: var(--danger) !important; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-height: calc(100vh - 104px); }
.chat-panel, .evidence-panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.chat-panel { display: grid; grid-template-rows: auto minmax(280px, 1fr) auto auto; }
.panel-head { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.quiet-button { height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--muted); }
.messages { overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.message { width: min(760px, 88%); padding: 13px 15px; border-radius: 9px; line-height: 1.55; font-size: 14px; white-space: pre-wrap; }
.message.assistant { align-self: flex-start; border: 1px solid var(--line); background: var(--panel-2); }
.message.user { align-self: flex-end; color: #07110e; background: #79e0bd; }
.message.error { border-color: rgba(255,123,123,.4); color: #ffd4d4; }
.message-label { margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.message.user .message-label { color: #225d49; }
.presentation { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.presentation h3 { margin: 0 0 8px; color: var(--accent); font-size: 12px; }
.presentation-table-scroll { overflow-x: auto; }
.presentation table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: normal; }
.presentation th, .presentation td { padding: 7px 8px; border: 1px solid var(--line); text-align: start; vertical-align: top; }
.presentation th { color: var(--accent); background: rgba(66,211,164,.06); }
.presentation-flow-list { display: flex; flex-wrap: wrap; align-items: stretch; gap: 22px; margin: 0; padding: 0; list-style: none; counter-reset: flow-step; }
.presentation-flow-list li { position: relative; flex: 1 1 150px; min-width: 130px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: #0d1118; white-space: normal; counter-increment: flow-step; }
.presentation-flow-list li::before { content: counter(flow-step); display: grid; place-items: center; width: 20px; height: 20px; margin-bottom: 6px; border-radius: 50%; color: #06110d; background: var(--accent); font-size: 10px; font-weight: 800; }
.presentation-flow-list li:not(:last-child)::after { content: "→"; position: absolute; inset-inline-end: -18px; top: 50%; color: var(--accent); }
.message-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.message-action-link { display: inline-flex; align-items: center; min-height: 32px; padding: 7px 11px; border: 1px solid rgba(66,211,164,.5); border-radius: 999px; color: #07110e; background: var(--accent); font-size: 12px; font-weight: 800; text-decoration: none; white-space: normal; }
.message-action-link:hover { background: #79e0bd; border-color: #79e0bd; }
.message-action-link:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 16px 12px; }
.suggestions button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font-size: 11px; }
.suggestions button:hover, .quiet-button:hover { color: var(--text); border-color: #435063; }
.composer { display: grid; grid-template-columns: 1fr auto; gap: 9px; padding: 13px 16px 16px; border-top: 1px solid var(--line); }
.composer button { min-width: 76px; }
.evidence-panel { display: flex; flex-direction: column; }
.evidence-list { flex: 1; overflow-y: auto; padding: 12px; }
.empty-state { padding: 24px 12px; color: var(--muted); text-align: center; font-size: 12px; }
.evidence-item { padding: 11px; border-bottom: 1px solid var(--line); }
.evidence-item:last-child { border-bottom: 0; }
.evidence-source { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; color: var(--accent); font-size: 11px; font-weight: 800; }
.evidence-number { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; background: rgba(66,211,164,.12); }
.evidence-locator { overflow-wrap: anywhere; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; line-height: 1.45; }
.meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; border-top: 1px solid var(--line); background: var(--line); }
.meta div { min-width: 0; padding: 10px; background: var(--panel); }
.meta span, .meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta span { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.meta strong { margin-top: 3px; font-size: 11px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 860px) {
  .shell { padding: 14px; }
  .auth-panel { margin-top: 3vh; }
  .role-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .credential-form { grid-template-columns: 1fr 1fr; }
  .credential-form > button { grid-column: 1 / -1; }
  .workspace { grid-template-columns: 1fr; min-height: auto; }
  .chat-panel { min-height: calc(100vh - 100px); }
  .evidence-panel { min-height: 280px; }
}
@media (max-width: 560px) {
  .shell { padding: 10px; }
  .topbar { align-items: flex-start; }
  .connection { min-width: 0; max-width: 46%; padding-inline: 9px; }
  #connectionText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .auth-panel { padding: 16px; }
  .auth-copy { align-items: center; }
  .role-grid { grid-template-columns: 1fr; }
  .role-card { min-height: 82px; }
  .role-card span { min-height: auto; }
  .credential-form { grid-template-columns: 1fr; }
  .credential-form > button, .memory-option { grid-column: 1; }
  .auth-actions { align-items: flex-start; flex-direction: column; }
  .token-form { flex-direction: column; }
  .token-form button { height: 42px; }
  .workspace { gap: 10px; }
  .message { width: 94%; }
  .suggestions { overflow-x: auto; flex-wrap: nowrap; }
  .suggestions button { flex: 0 0 auto; }
  .composer { grid-template-columns: 1fr; }
  .composer button { height: 42px; }
}
