:root {
  --bg: #0b0b0d;
  --bg-2: #111114;
  --panel: #151519;
  --panel-2: #1a1a20;
  --border: #2a2a32;
  --border-soft: #222229;
  --text: #f2f0eb;
  --muted: #92909a;
  --faint: #5f5d68;
  --blue: #3b82f6;
  --blue-2: #60a5fa;
  --blue-dim: rgba(59, 130, 246, 0.14);
  --green: #47c78a;
  --red: #ff5f6d;
  --yellow: #f6c177;
  --mono: "SFMono-Regular", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(59, 130, 246, 0.10), transparent 60%),
    radial-gradient(800px 500px at 0% 100%, rgba(59, 130, 246, 0.05), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--blue-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  border-right: 1px solid var(--border-soft);
  background: rgba(10, 10, 12, 0.7);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); padding: 4px 8px 18px;
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  /* The logo image (public/brand) already contains the blue tile. */
  width: 30px; height: 30px; display: block; flex: none;
  border-radius: 9px;
  box-shadow: 0 8px 30px rgba(59, 130, 246, 0.25);
}
.brand-text { font-weight: 650; font-size: 15px; }
.brand .muted { color: var(--faint); font-weight: 400; }

.side-section { padding: 12px 6px 0; }
.side-section.grow { flex: 1; min-height: 0; overflow: auto; }
.side-label {
  text-transform: uppercase; letter-spacing: 0.12em; font-size: 10px;
  color: var(--faint); padding: 0 8px 8px;
}

.nav-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 9px 10px; border-radius: 8px; text-align: left; font-size: 13px;
  transition: 120ms ease;
}
.nav-item span { width: 16px; text-align: center; color: var(--faint); font-size: 14px; }
.nav-item:hover { background: rgba(255,255,255,0.03); color: var(--text); }
.nav-item.active { background: var(--blue-dim); border-color: rgba(59, 130, 246, 0.25); color: #dbeafe; }
.nav-item.active span { color: var(--blue); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.field > span { font-size: 11px; color: var(--muted); letter-spacing: 0.01em; }
.field em { color: var(--faint); font-style: normal; font-size: 10px; }
.field input, .field textarea, .field select {
  width: 100%; background: #0d0d10; border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); padding: 10px 11px; font-size: 13px;
  outline: none; transition: border-color 120ms, box-shadow 120ms;
}
.field textarea { font-family: var(--mono); font-size: 12px; line-height: 1.5; resize: vertical; }
.field input:hover, .field textarea:hover, .field select:hover { border-color: #3a3a44; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: rgba(59, 130, 246, 0.70); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.field input::placeholder, .field textarea::placeholder { color: #4d4b55; }
.field.compact { margin-bottom: 10px; }
.field.compact input { padding: 8px 10px; font-size: 12px; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  padding: 6px 9px; border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); cursor: pointer; user-select: none; background: #0d0d10;
}
.chip input { display: none; }
.chip:hover { border-color: #41414b; color: var(--text); }
.chip.checked { color: #dbeafe; border-color: rgba(59, 130, 246, 0.55); background: rgba(59, 130, 246, 0.12); }

.switch { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; margin: 4px 0 10px; }
.switch input { accent-color: var(--blue); width: 14px; height: 14px; }

.status-line { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); padding: 2px 8px 8px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 8px rgba(246,193,119,.6); }
.dot.ok { background: var(--green); box-shadow: 0 0 8px rgba(71,199,138,.6); }
.dot.bad { background: var(--red); box-shadow: 0 0 8px rgba(255,95,109,.6); }

.history { display: flex; flex-direction: column; gap: 4px; }
.history-item {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  border-radius: 7px; padding: 7px 8px; text-align: left; font-size: 11px;
  display: flex; flex-direction: column; gap: 2px; overflow: hidden;
}
.history-item:hover { background: rgba(255,255,255,0.03); color: var(--text); }
.history-item b { font-weight: 600; color: #cfccd6; font-size: 11px; }
.history-item span { color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-small { color: var(--faint); font-size: 11px; padding: 4px 8px; }

.side-footer {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid var(--border-soft); padding: 12px 8px 2px; margin-top: 10px;
  color: var(--faint); font-size: 10px;
}
.side-footer a { color: var(--muted); }

.main { flex: 1; min-width: 0; padding: 28px 32px 32px; max-width: 1500px; margin: 0 auto; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
h1 { margin: 0 0 5px; font-size: 26px; letter-spacing: -0.03em; font-weight: 650; }
#page-subtitle { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; max-width: 680px; }
.top-actions { display: flex; gap: 9px; align-items: center; padding-top: 3px; }

.primary, .ghost {
  border-radius: 8px; padding: 9px 13px; font-size: 12px; font-weight: 600;
  border: 1px solid rgba(59, 130, 246, 0.55);
  background: linear-gradient(180deg, #2563eb, #1e40af);
  color: #ffffff; box-shadow: 0 8px 24px rgba(59, 130, 246, 0.25);
  transition: 120ms ease;
}
.primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.primary:active { transform: translateY(0); }
.primary:disabled { opacity: 0.55; cursor: wait; transform: none; }
.ghost { background: #151519; border-color: var(--border); color: var(--muted); box-shadow: none; }
.ghost:hover { color: var(--text); border-color: #3a3a44; }
kbd { font-family: var(--mono); font-size: 9px; opacity: .7; margin-left: 6px; border: 1px solid rgba(0,0,0,.2); border-radius: 4px; padding: 1px 3px; }

.workspace { display: grid; grid-template-columns: minmax(330px, 0.72fr) minmax(0, 1.28fr); gap: 16px; align-items: start; }
.panel {
  background: linear-gradient(180deg, rgba(25,25,30,.92), rgba(18,18,22,.92));
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border-soft);
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em;
}
.endpoint { font-family: var(--mono); color: var(--blue-2); text-transform: none; letter-spacing: 0; font-size: 10px; }
.form { padding: 16px 14px 6px; }
.hidden, .tab-pane.hidden, .json-fields.hidden { display: none !important; }
.or { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 10px; margin: 2px 0 10px; }
.or::before, .or::after { content: ''; height: 1px; flex: 1; background: var(--border-soft); }
.hint { color: var(--faint); font-size: 11px; margin: 4px 0 10px; }

.response-panel { min-height: 520px; display: flex; flex-direction: column; }
.response-tabs { display: flex; gap: 4px; }
.mini {
  background: transparent; border: 1px solid transparent; color: var(--faint);
  border-radius: 6px; padding: 4px 7px; font-size: 10px; text-transform: none; letter-spacing: 0;
}
.mini:hover { color: var(--text); }
.mini.active { color: var(--blue-2); background: rgba(59, 130, 246, .10); border-color: rgba(59, 130, 246, .22); }

.response-meta { display: flex; gap: 10px; align-items: center; padding: 9px 14px; border-bottom: 1px solid var(--border-soft); color: var(--faint); font-size: 11px; min-height: 36px; }
.pill { border: 1px solid var(--border); border-radius: 999px; padding: 2px 7px; color: var(--muted); font-size: 10px; }
.pill.ok { color: var(--green); border-color: rgba(71,199,138,.3); background: rgba(71,199,138,.06); }
.pill.bad { color: var(--red); border-color: rgba(255,95,109,.3); background: rgba(255,95,109,.06); }

.response-body { padding: 20px; overflow: auto; flex: 1; max-height: calc(100vh - 220px); }
.empty-state { display: grid; place-items: center; text-align: center; min-height: 380px; color: var(--muted); }
.empty-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: #19191e; border: 1px solid var(--border); color: var(--blue); font-size: 24px; margin-bottom: 12px; }
.empty-state h2 { margin: 0 0 6px; font-size: 16px; color: #d8d4de; font-weight: 600; }
.empty-state p { margin: 0; font-size: 12px; max-width: 360px; line-height: 1.55; }

.doc { max-width: 860px; }
.doc h1, .doc h2, .doc h3 { letter-spacing: -0.02em; line-height: 1.25; margin: 1.2em 0 0.5em; }
.doc h1 { font-size: 24px; }
.doc h2 { font-size: 19px; }
.doc h3 { font-size: 16px; }
.doc p, .doc li { color: #d6d2dc; font-size: 13.5px; line-height: 1.72; }
.doc ul, .doc ol { padding-left: 22px; }
.doc a { color: var(--blue-2); }
.doc code { font-family: var(--mono); font-size: 12px; background: #0c0c0f; border: 1px solid var(--border-soft); border-radius: 4px; padding: 1px 4px; }
.doc pre { background: #0b0b0e; border: 1px solid var(--border); border-radius: 9px; padding: 13px; overflow: auto; }
.doc pre code { border: 0; background: transparent; padding: 0; font-size: 12px; }
.doc blockquote { border-left: 2px solid var(--blue); margin: 1em 0; padding: 2px 0 2px 14px; color: var(--muted); }
.doc img { max-width: 100%; border-radius: 8px; }
.doc table { border-collapse: collapse; width: 100%; font-size: 12px; }
.doc th, .doc td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; }

pre.json-view { margin: 0; font-family: var(--mono); font-size: 12px; line-height: 1.55; color: #cfccd6; white-space: pre-wrap; word-break: break-word; }
.meta-grid { display: grid; grid-template-columns: 140px 1fr; gap: 1px; background: var(--border-soft); border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.meta-grid div { background: #111114; padding: 8px 10px; font-size: 12px; }
.meta-grid .k { color: var(--faint); font-family: var(--mono); font-size: 11px; }
.meta-grid .v { color: #d6d2dc; word-break: break-word; }

.error-box { border: 1px solid rgba(255,95,109,.3); background: rgba(255,95,109,.06); border-radius: 9px; padding: 12px 14px; color: #ffb3b9; font-size: 12px; line-height: 1.5; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; padding: 20px 0; }
.spinner { width: 15px; height: 15px; border: 2px solid #2c2c35; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.search-results { display: flex; flex-direction: column; gap: 12px; }
.result-card { border: 1px solid var(--border-soft); background: #111114; border-radius: 9px; padding: 12px 13px; }
.result-card a { font-size: 13px; font-weight: 600; color: #93c5fd; }
.result-card p { margin: 5px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.result-card .url { font-family: var(--mono); font-size: 10px; color: var(--faint); margin-top: 5px; word-break: break-all; }
.result-card .body { margin-top: 8px; font-size: 12px; color: #c9c5d0; white-space: pre-wrap; max-height: 180px; overflow: auto; }

@media (max-width: 1000px) {
  .workspace { grid-template-columns: 1fr; }
  .response-body { max-height: none; }
}
@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex: none; }
  .side-section.grow { display: none; }
  .main { padding: 20px 16px; }
  .topbar { flex-direction: column; }
  .row { grid-template-columns: 1fr; }
}

/* Dashboard */
.dash-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
.dash-card { border: 1px solid var(--border-soft); background: #111114; border-radius: 9px; padding: 10px 11px; }
.dash-card .n { display: block; font-size: 20px; font-weight: 650; letter-spacing: -.03em; color: var(--text); }
.dash-card .l { display: block; color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; margin-top: 3px; }
.dash-section { margin-top: 16px; }
.dash-section h3 { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); margin: 0 0 7px; }
.dash-table { border: 1px solid var(--border-soft); border-radius: 8px; overflow: hidden; }
.dash-row { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-bottom: 1px solid var(--border-soft); font-size: 11px; color: var(--muted); }
.dash-row:last-child { border-bottom: 0; }
.dash-row .tag { font-family: var(--mono); font-size: 9px; color: var(--blue-2); background: rgba(59,130,246,.10); border: 1px solid rgba(59,130,246,.22); border-radius: 4px; padding: 2px 4px; }
.dash-row .path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #cfccd6; }
.dash-row .status { font-family: var(--mono); font-size: 10px; }
.dash-row .status.ok { color: var(--green); }
.dash-row .status.bad { color: var(--red); }
.dash-empty { padding: 12px; color: var(--faint); font-size: 11px; }

/* Monitors */
.monitor-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.monitor-card { border: 1px solid var(--border-soft); background: #111114; border-radius: 9px; padding: 10px 11px; }
.monitor-card .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.monitor-card .name { font-size: 12px; font-weight: 600; color: #ded9e4; }
.monitor-card .target { font-family: var(--mono); font-size: 10px; color: var(--faint); margin-top: 3px; word-break: break-all; }
.monitor-card .meta { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: 10px; color: var(--faint); flex-wrap: wrap; }
.monitor-actions { display: flex; gap: 5px; margin-top: 8px; }
.monitor-actions button { font-size: 10px; padding: 4px 7px; border-radius: 5px; border: 1px solid var(--border); background: #17171c; color: var(--muted); }
.monitor-actions button:hover { color: var(--text); border-color: #41414b; }
.monitor-actions button.danger:hover { color: var(--red); border-color: rgba(255,95,109,.4); }
.check-item { border: 1px solid var(--border-soft); background: #111114; border-radius: 8px; padding: 9px 10px; margin-bottom: 7px; }
.check-item .head { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); }
.check-item .summary { margin-top: 5px; font-size: 12px; color: #d6d2dc; }
.check-item pre { margin: 8px 0 0; max-height: 220px; overflow: auto; font-size: 10px; }
@media (min-width: 1000px) { .dash-grid { grid-template-columns: repeat(3, 1fr); } }

.progress-track { height: 7px; background: #0d0d10; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin: 8px 0 12px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #3b82f6, #93c5fd); width: 0%; transition: width .25s ease; }
.live-pages { display: flex; flex-direction: column; gap: 6px; }
.live-page { border: 1px solid var(--border-soft); border-radius: 7px; padding: 7px 9px; font-size: 11px; color: var(--muted); }
.live-page b { color: #ded9e4; font-weight: 600; }

.rag-source { border: 1px solid var(--border-soft); background: #111114; border-radius: 8px; padding: 9px 10px; margin-bottom: 7px; }
.rag-source a { font-size: 12px; font-weight: 600; }
.rag-source .snippet { color: var(--muted); font-size: 11px; line-height: 1.5; margin-top: 4px; }

.research-card { border: 1px solid var(--border-soft); background: #111114; border-radius: 8px; padding: 10px 11px; margin-bottom: 7px; }
.research-card .top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.research-card .summary { color: var(--muted); font-size: 11px; line-height: 1.55; margin-top: 6px; }

/* Agent feedback on the dashboard */
.dash-sub { font-weight: 400; color: var(--faint); font-size: 11px; margin-left: 6px; }
.fb-row { flex-wrap: wrap; align-items: flex-start; }
.fb-row .fb-main { flex: 1; min-width: 0; }
.fb-row .fb-summary { color: #cfccd6; white-space: normal; }
.fb-row .fb-meta { color: var(--faint); font-family: var(--mono); font-size: 10px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-row .fb-details { color: var(--muted); white-space: pre-wrap; margin-top: 4px; font-size: 11px; }
.fb-row .sev-high { color: var(--red); }
.fb-row .sev-medium { color: #e0b049; }
.fb-row .sev-low { color: var(--faint); }
.fb-row .fb-actions { display: flex; gap: 4px; }
.fb-row .fb-actions button { font-size: 10px; padding: 2px 6px; border-radius: 4px; border: 1px solid var(--border-soft); background: transparent; color: var(--muted); cursor: pointer; }
.fb-row .fb-actions button:hover { color: #cfccd6; border-color: var(--blue-2); }
