:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --ink: #202427;
  --muted: #657078;
  --line: #dcd6ca;
  --brand: #6f4bc2;
  --brand-ink: #ffffff;
  --ok: #1f7a55;
  --warn: #b46912;
  --danger: #b13a3a;
  --focus: #2b7a9b;
  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(--ink);
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: var(--brand-ink);
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
  font-weight: 700;
}

button:hover {
  filter: brightness(0.96);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  background: #2d6f74;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  letter-spacing: 0;
}

h3 {
  font-size: 15px;
  letter-spacing: 0;
}

.hidden {
  display: none !important;
}

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

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(68, 58, 42, 0.11);
}

.login-copy {
  color: var(--muted);
  margin: 8px 0 22px;
}

.stack {
  display: grid;
  gap: 14px;
}

.status-line {
  min-height: 20px;
  color: var(--muted);
  margin-top: 14px;
}

.workbench {
  min-height: 100vh;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: #e7e0f7;
  color: #493073;
  font-size: 12px;
  font-weight: 800;
}

.pill.muted {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--line);
}

.pill.ok {
  background: #dcefe6;
  color: var(--ok);
}

.pill.warn {
  background: #f5e8ce;
  color: var(--warn);
}

.pill.danger {
  background: #f2dede;
  color: var(--danger);
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
}

.tab {
  background: transparent;
  color: var(--muted);
  border-radius: 0;
  min-height: 42px;
  border-bottom: 3px solid transparent;
}

.tab.active {
  color: var(--ink);
  border-bottom-color: var(--brand);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
}

.review-grid {
  grid-template-columns: minmax(300px, 460px) minmax(0, 1fr);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.table-list {
  display: grid;
  gap: 10px;
}

.row-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffefa;
  display: grid;
  gap: 8px;
}

.row-card.clickable {
  cursor: pointer;
}

.row-card.active {
  outline: 2px solid var(--focus);
}

.row-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.row-meta {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  min-height: 260px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
}

.candidate-detail {
  min-height: 640px;
}

.detail-stack {
  display: grid;
  gap: 14px;
}

.detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.markdown-preview {
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  background: #172026;
  color: #f4f1e9;
  border-radius: 8px;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
}

.facts-grid,
.controls-grid {
  display: grid;
  gap: 10px;
}

.fact-row,
.control-row {
  display: grid;
  grid-template-columns: minmax(120px, 220px) 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  background: #202427;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.24);
}

@media (max-width: 900px) {
  .grid.two,
  .review-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .fact-row,
  .control-row {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}
