:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1d2430;
  --muted: #667085;
  --line: #d7dce3;
  --blue: #1f6feb;
  --green: #16833a;
  --amber: #9a6400;
  --red: #c03221;
  --teal: #087f8c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 0 12px;
}

button:hover {
  border-color: #9aa7b8;
}

button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

button.secondary {
  background: #eef2f7;
}

button.success {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

button.warning {
  color: #fff;
  background: var(--amber);
  border-color: var(--amber);
}

button.danger {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 12px;
}

.app-shell {
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 20px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.brand p,
.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.tab {
  justify-content: flex-start;
  text-align: left;
}

.tab.active {
  border-color: var(--blue);
  color: var(--blue);
  background: #edf5ff;
}

.content {
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.topbar h2 {
  margin: 0;
  font-size: 22px;
}

.actions,
.mini-actions,
.split-actions,
.upload-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.view {
  display: none;
  padding: 22px;
}

.view.active {
  display: block;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.panel.wide {
  padding: 0;
  overflow: hidden;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.result {
  min-height: 78px;
  overflow: auto;
  margin: 12px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  white-space: pre-wrap;
}

.result.tall {
  min-height: 360px;
}

.coverage {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  background: #fff;
}

.chip.ok {
  border-color: #89c99a;
  color: var(--green);
  background: #f0fbf3;
}

.chip.missing {
  border-color: #e5a5a0;
  color: var(--red);
  background: #fff4f3;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  vertical-align: top;
  font-size: 13px;
}

th {
  background: #f8fafc;
  text-align: left;
  color: var(--muted);
  font-weight: 600;
}

td textarea,
td input,
td select {
  min-height: 34px;
  font-size: 13px;
}

td:nth-child(1) {
  width: 120px;
}

td:nth-child(2) {
  width: 105px;
}

td:nth-child(6) {
  width: 74px;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
}

.list-item h4 {
  margin: 0 0 6px;
  font-size: 14px;
}

.list-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.agent-message {
  color: #334155;
  font-size: 13px;
  line-height: 1.55;
}

.agent-message p,
.agent-message ul,
.agent-message ol,
.agent-message blockquote,
.agent-message .agent-table-wrap {
  margin: 8px 0 0;
}

.agent-message p:first-child,
.agent-message ul:first-child,
.agent-message ol:first-child,
.agent-message blockquote:first-child,
.agent-message .agent-table-wrap:first-child {
  margin-top: 0;
}

.agent-message h4,
.agent-message h5,
.agent-message h6 {
  margin: 10px 0 4px;
  color: #0f172a;
}

.agent-message blockquote {
  border-left: 3px solid #bfdbfe;
  background: #eff6ff;
  padding: 8px 10px;
  color: #1e3a8a;
}

.agent-message code {
  background: #f1f5f9;
  border-radius: 4px;
  padding: 1px 4px;
}

.agent-table-wrap {
  overflow-x: auto;
}

.agent-table {
  table-layout: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.agent-table th,
.agent-table td {
  font-size: 12px;
  padding: 7px 8px;
}

.scope-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 10px;
  margin: 0 0 12px;
  font-size: 13px;
}

.scope-card strong {
  display: block;
  color: #334155;
  margin-bottom: 4px;
}

.scope-card span,
.source-scope {
  color: var(--muted);
}

.source-card {
  background: #fbfdff;
}

.source-meta {
  margin-bottom: 4px;
}

.source-scope {
  font-size: 12px;
  margin-bottom: 8px;
}

.source-excerpt {
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  background: #eef2ff;
  color: #1e293b;
  padding: 10px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.source-excerpt mark {
  background: #fde68a;
  color: #713f12;
  padding: 1px 2px;
  border-radius: 3px;
}

.source-full {
  margin-top: 8px;
}

.source-full summary {
  cursor: pointer;
  color: var(--blue);
  font-size: 12px;
}

.source-snippet {
  margin: 8px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 420px;
}

@media (max-width: 900px) {
  .app-shell,
  .grid.two {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }
}
