:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --text: #18202a;
  --muted: #667281;
  --line: #d8dee7;
  --accent: #1466d8;
  --accent-2: #0f8b74;
  --danger: #b42318;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { border: 0; background: var(--accent); color: white; padding: 9px 13px; border-radius: 7px; cursor: pointer; }
button.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
button:disabled { opacity: .55; cursor: not-allowed; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--text); padding: 9px 10px; }
textarea { resize: vertical; line-height: 1.45; }
label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
pre { white-space: pre-wrap; overflow: auto; margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 20px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; display: grid; gap: 16px; box-shadow: 0 18px 50px rgba(22, 34, 51, .08); }
.eyebrow { color: var(--accent-2); margin: 0 0 4px; font-size: 13px; font-weight: 700; }
.login h1 { margin: 0; font-size: 30px; letter-spacing: 0; }

.app { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { background: #101820; color: white; padding: 20px 14px; display: flex; flex-direction: column; gap: 24px; }
.brand { display: grid; gap: 4px; padding: 0 8px; }
.brand span { color: #aeb8c5; font-size: 13px; }
.brand strong { font-size: 21px; }
nav { display: grid; gap: 6px; }
.nav { text-align: left; background: transparent; color: #d8dee7; border-radius: 7px; }
.nav.active, .nav:hover { background: #25313f; color: white; }
.workspace { min-width: 0; padding: 22px; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 18px; }
.topbar h2 { margin: 0 0 4px; }
.topbar p { margin: 0; color: var(--muted); }
.userbar { display: flex; align-items: center; gap: 10px; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.summary-card, .panel, .trace-panel, .table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.summary-card { padding: 13px; }
.summary-card strong { display: block; font-size: 22px; margin-top: 4px; }
.filters { display: grid; grid-template-columns: 180px 150px 180px minmax(180px, 1fr) 90px; gap: 10px; align-items: center; margin-bottom: 14px; }
.checkbox { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 7px; }
.checkbox input { width: auto; }
.split { display: grid; grid-template-columns: minmax(420px, .9fr) minmax(420px, 1.1fr); gap: 14px; align-items: start; }
.table-wrap { overflow: auto; max-height: calc(100vh - 230px); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: #fbfcfe; position: sticky; top: 0; }
tr { cursor: pointer; }
tr:hover { background: #f5f8fc; }
.badge { display: inline-block; padding: 3px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
.badge.ok { color: #067647; background: #ecfdf3; }
.badge.err { color: #b42318; background: #fef3f2; }
.trace-panel { padding: 14px; max-height: calc(100vh - 230px); overflow: auto; }
.trace-head { display: flex; justify-content: space-between; gap: 10px; align-items: start; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 12px; }
.trace-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.kv { background: var(--surface-2); border-radius: 7px; padding: 8px; font-size: 12px; }
.kv span { display: block; color: var(--muted); margin-bottom: 3px; }
.payload-section { margin-top: 14px; }
.payload-section h4 { margin: 0 0 8px; }
.message { border: 1px solid var(--line); border-radius: 7px; padding: 10px; margin-bottom: 10px; background: #fbfcfe; }
.message-role { color: var(--accent); font-weight: 700; margin-bottom: 6px; }
.ai-image { max-width: 100%; border: 1px solid var(--line); border-radius: 7px; margin: 8px 0; display: block; }
.two-col { display: grid; grid-template-columns: minmax(360px, 460px) minmax(0, 1fr); gap: 14px; align-items: start; }
.panel { padding: 16px; display: grid; gap: 13px; }
.panel h3 { margin: 0; }
.narrow { max-width: 520px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.prompt-list { display: grid; gap: 10px; }
.prompt-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px; }
.prompt-card h3 { margin: 0 0 6px; }
.prompt-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 2; flex-direction: row; align-items: center; overflow: auto; }
  nav { display: flex; }
  .split, .two-col { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
}
