:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #5d6875;
  --line: #d8dee5;
  --surface: #f7f8fa;
  --panel: #ffffff;
  --accent: #176b87;
  --accent-2: #7b4d20;
  --good: #116c43;
  --warn: #9a6700;
  --bad: #b42318;
  --shadow: 0 12px 34px rgba(23, 33, 43, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button, input, textarea, select { font: inherit; }

button, .link-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 650;
}

button:disabled { opacity: 0.55; cursor: wait; }
button.ghost { background: #fff; color: var(--accent); }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea { resize: vertical; min-height: 112px; }

input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.12); }

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

.topbar {
  min-height: 76px;
  padding: 14px 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand-block { display: flex; align-items: center; gap: 12px; min-width: 260px; }
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; line-height: 1.1; }
h2 { font-size: 22px; }
h3 { font-size: 15px; margin-bottom: 14px; }
p { color: var(--muted); font-size: 13px; margin-top: 4px; }

.auth-strip { display: grid; grid-template-columns: minmax(210px, 320px) auto auto; gap: 8px; align-items: center; }

.main-grid { display: grid; grid-template-columns: 190px minmax(0, 1fr); min-height: calc(100vh - 76px); }

.side-nav {
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-button {
  background: transparent;
  color: var(--ink);
  border-color: transparent;
  justify-content: flex-start;
}

.nav-button.active { background: #eaf4f7; border-color: #c7dfe8; color: #0f536b; }

.content-area { padding: 22px; max-width: 1280px; width: 100%; }

.message-bar {
  min-height: 0;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 14px;
}

.message-bar.error { color: var(--bad); }
.message-bar.good { color: var(--good); }

.view { display: none; }
.view.active { display: block; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.status-grid { display: grid; grid-template-columns: repeat(6, minmax(110px, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric-tile {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 88px;
  box-shadow: var(--shadow);
}
.metric-tile span { color: var(--muted); font-size: 12px; display: block; }
.metric-tile strong { font-size: 24px; margin-top: 8px; display: block; overflow-wrap: anywhere; }

.split-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.list-stack { display: grid; gap: 10px; }
.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}
.list-item strong { display: block; margin-bottom: 5px; overflow-wrap: anywhere; }
.list-item span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

.brain-panel { display: grid; gap: 12px; }
.chat-log {
  min-height: 260px;
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
  display: grid;
  align-content: start;
  gap: 10px;
}
.message { padding: 12px; border-radius: 8px; max-width: 84%; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user { background: #eaf4f7; justify-self: end; }
.message.assistant { background: #fff7ed; border: 1px solid #ead6bf; }

.field-label { font-size: 13px; color: var(--muted); font-weight: 650; }
.inline-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: center; }
.check-line { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.check-line input { width: auto; }
.search-line { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 12px; }
.result-box {
  min-height: 120px;
  overflow: auto;
  background: #17212b;
  color: #f7f8fa;
  border-radius: 8px;
  padding: 12px;
  white-space: pre-wrap;
}

@media (max-width: 920px) {
  .topbar { align-items: stretch; flex-direction: column; }
  .auth-strip { grid-template-columns: 1fr 1fr; }
  .auth-strip input { grid-column: 1 / -1; }
  .main-grid { grid-template-columns: 1fr; }
  .side-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-layout { grid-template-columns: 1fr; }
  .inline-controls { grid-template-columns: 1fr; }
  .message { max-width: 100%; }
}
