:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1e2430;
  --muted: #657084;
  --line: #d9dee8;
  --focus: #176b87;
  --good: #137547;
  --warn: #a05a00;
  --bad: #b42318;
  --info: #27548a;
  --soft-good: #e9f7ef;
  --soft-warn: #fff4df;
  --soft-bad: #fdecec;
  --soft-info: #eaf2fb;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

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

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: #9aa5b8;
  background: #f9fafb;
}

button.primary {
  border-color: var(--focus);
  background: var(--focus);
  color: #ffffff;
}

button.danger {
  border-color: var(--bad);
  color: var(--bad);
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

a {
  color: var(--focus);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
}

#statusLine {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.connection {
  display: grid;
  grid-template-columns: minmax(220px, 360px) minmax(160px, 240px) auto;
  gap: 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 0 10px;
}

textarea {
  min-height: 94px;
  resize: vertical;
  padding: 10px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: 2px solid rgba(23, 107, 135, 0.22);
  outline-offset: 1px;
}

main {
  display: grid;
  gap: 16px;
  padding: 18px 24px 32px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.metrics article,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metrics article {
  display: grid;
  gap: 5px;
  padding: 14px;
}

.metrics span {
  color: var(--muted);
  font-size: 12px;
}

.metrics strong {
  font-size: 22px;
  line-height: 1.1;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(5, auto) minmax(160px, 220px);
  gap: 10px;
  justify-content: start;
  align-items: center;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.session-panel textarea {
  border: 0;
  border-radius: 0;
  border-top: 1px solid var(--line);
  background: #fbfcfd;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.panel-header span {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #fbfcfd;
}

tbody tr:hover {
  background: #fbfcfd;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status.shortlisted,
.status.approved {
  color: var(--info);
  background: var(--soft-info);
}

.status.needs_review,
.status.failed {
  color: var(--warn);
  background: var(--soft-warn);
}

.status.sent {
  color: var(--good);
  background: var(--soft-good);
}

.status.rejected {
  color: var(--bad);
  background: var(--soft-bad);
}

.project-title {
  display: grid;
  gap: 5px;
  min-width: 260px;
}

.project-title strong {
  font-size: 14px;
}

.project-title span,
.muted,
.date-stack {
  color: var(--muted);
  font-size: 12px;
}

.signals {
  display: grid;
  gap: 6px;
  max-width: 320px;
}

.signals div {
  overflow-wrap: anywhere;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tags span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--muted);
  font-size: 11px;
}

.date-stack {
  display: grid;
  gap: 4px;
  min-width: 140px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 260px;
}

.actions button,
.actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #ffffff;
  font-size: 12px;
  text-decoration: none;
}

.events {
  display: grid;
  max-height: 720px;
  overflow: auto;
}

.event {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.event strong {
  font-size: 13px;
}

.event code {
  display: block;
  max-height: 96px;
  overflow: auto;
  padding: 8px;
  border-radius: 6px;
  background: #f5f7fa;
  color: #344054;
  white-space: pre-wrap;
}

.candidates-panel[hidden] {
  display: none;
}

.candidate-list {
  display: grid;
}

.candidate {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 16px 48px rgba(30, 36, 48, 0.16);
  color: var(--text);
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

#toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .connection,
  .metrics,
  .workspace {
    grid-template-columns: 1fr;
  }

  .toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar,
  main {
    padding-left: 14px;
    padding-right: 14px;
  }

  .connection,
  .toolbar {
    grid-template-columns: 1fr;
  }
}
