:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --ink: #20252b;
  --muted: #65717d;
  --line: #d9dfda;
  --panel: #ffffff;
  --accent: #1f6f5b;
  --accent-dark: #154c3f;
  --gold: #aa7a16;
  --red: #b84032;
  --blue: #2f5d7c;
  --soft: #eef3ef;
}

* {
  box-sizing: border-box;
}

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

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

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 0.96;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: end;
}

.file-pill {
  max-width: min(420px, 80vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-weight: 750;
  padding: 11px 14px;
  cursor: pointer;
  min-height: 42px;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  opacity: 0.55;
  cursor: progress;
}

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

button.secondary {
  background: var(--blue);
}

button.secondary:hover {
  background: #244b65;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 92px;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  margin-bottom: 10px;
}

.kpi strong {
  display: block;
  font-size: clamp(1.15rem, 2vw, 1.65rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.tabs {
  display: grid;
  gap: 8px;
  position: sticky;
  top: 12px;
}

.tab {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  text-align: left;
}

.tab.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.panels {
  min-width: 0;
}

.panel {
  display: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.panel.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  color: var(--muted);
}

.section-head h2 {
  color: var(--ink);
}

.summary-table {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.summary-table div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.summary-table div:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.summary-table div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.summary-table span {
  color: var(--muted);
}

.summary-table strong {
  text-align: right;
}

.checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.check {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  padding: 12px;
}

.check.ok {
  border-left-color: var(--accent);
}

.check.bad {
  border-left-color: var(--red);
}

.activity {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.activity-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.activity-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.activity-row span,
.muted {
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.question-form {
  display: grid;
  gap: 14px;
}

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

label.wide {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
  min-height: 42px;
}

textarea {
  resize: vertical;
}

.form-grid button,
.question-form button {
  justify-self: start;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.answer-box {
  margin: 18px 0 0;
  white-space: pre-wrap;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  line-height: 1.45;
  color: var(--ink);
  font-family: inherit;
}

.archive-layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.archive-list {
  display: grid;
  gap: 8px;
  max-height: 620px;
  overflow: auto;
}

.archive-item {
  display: grid;
  gap: 6px;
  width: 100%;
  text-align: left;
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
  border-left: 5px solid var(--line);
  border-radius: 8px;
  padding: 11px;
}

.archive-item:hover,
.archive-item.selected {
  background: var(--soft);
  border-left-color: var(--accent);
}

.archive-item span,
.archive-item em {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: normal;
}

.archive-item strong {
  line-height: 1.25;
}

.archive-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  min-height: 360px;
}

.archive-detail h3 {
  margin-top: 18px;
  margin-bottom: 8px;
}

.archive-detail h3:first-of-type {
  margin-top: 0;
}

.archive-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.archive-meta span {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.archive-answer {
  white-space: pre-wrap;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  font-family: inherit;
  line-height: 1.45;
}

.progress-box {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--gold);
  border-radius: 8px;
  padding: 14px;
  background: #fffaf0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(12px);
  max-width: min(620px, calc(100vw - 28px));
  background: var(--ink);
  color: white;
  padding: 12px 16px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: 160ms ease;
  box-shadow: 0 12px 32px rgba(20, 20, 20, 0.18);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--red);
}

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

.login-box {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.error-line {
  min-height: 1.2em;
  color: var(--red);
  font-weight: 700;
}

@media (max-width: 900px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .tabs {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .archive-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 14px;
  }

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

  .kpi-grid,
  .summary-table,
  .checks,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .summary-table div:nth-child(odd) {
    border-right: 0;
  }

  .summary-table div:nth-last-child(2) {
    border-bottom: 1px solid var(--line);
  }

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

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