:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #fffdfa;
  --surface-strong: #ffffff;
  --text: #22201c;
  --muted: #6f6a61;
  --line: #ded8cd;
  --accent: #376655;
  --accent-strong: #22483c;
  --danger: #9b3d35;
  --warning: #8b6124;
  --shadow: 0 18px 44px rgba(36, 32, 26, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: #bbb2a4;
}

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

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

.primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.ghost {
  background: transparent;
}

.shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 24px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(420px, 720px);
  gap: 18px;
  align-items: end;
  padding: 8px 0 16px;
}

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

h1 {
  font-size: 28px;
  line-height: 1.1;
  font-weight: 760;
}

.topbar p,
.detail-header p {
  color: var(--muted);
  margin-top: 5px;
}

.connection,
.filters {
  display: flex;
  gap: 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
}

input,
select {
  height: 38px;
  padding: 0 11px;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(55, 102, 85, 0.14);
}

.connection label:first-child {
  flex: 1.2;
}

.connection label:nth-child(2) {
  flex: 1;
}

.filters {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 11px;
  box-shadow: var(--shadow);
}

.filters label {
  width: 180px;
}

.filters label:nth-child(2) {
  width: min(320px, 28vw);
}

.pager {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-left: auto;
}

#pageLabel {
  min-width: 56px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
  min-height: calc(100vh - 150px);
}

.report-list,
.detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.report-list {
  overflow: auto;
  padding: 8px;
}

.report-row {
  display: grid;
  gap: 8px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  padding: 12px;
  text-align: left;
}

.report-row + .report-row {
  border-top-color: var(--line);
  border-radius: 0;
}

.report-row:hover,
.report-row.active {
  border-color: #c9c0b1;
  background: #faf7f0;
}

.report-row strong {
  display: block;
  font-size: 15px;
  line-height: 1.25;
}

.report-row span,
.report-row small {
  color: var(--muted);
  font-size: 12px;
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-chip,
.row-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f8f5ed;
  color: var(--muted);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 760;
}

.status-chip {
  width: fit-content;
  margin-bottom: 10px;
  text-transform: capitalize;
}

.status-chip.verified,
.status-chip.fixed {
  border-color: rgba(55, 102, 85, 0.3);
  background: rgba(55, 102, 85, 0.1);
  color: var(--accent-strong);
}

.status-chip.rejected {
  border-color: rgba(155, 61, 53, 0.28);
  background: rgba(155, 61, 53, 0.09);
  color: var(--danger);
}

.status-chip.reviewing {
  border-color: rgba(139, 97, 36, 0.32);
  background: rgba(139, 97, 36, 0.1);
  color: var(--warning);
}

.detail {
  overflow: auto;
  padding: 22px;
}

.detail-header {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
}

.detail h2 {
  font-size: 25px;
  line-height: 1.2;
}

.open-link {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
}

.review-controls {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-actions button[data-status="verified"],
.status-actions button[data-status="fixed"] {
  border-color: rgba(55, 102, 85, 0.35);
  color: var(--accent-strong);
}

.status-actions button[data-status="rejected"] {
  border-color: rgba(155, 61, 53, 0.35);
  color: var(--danger);
}

.facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 0;
}

.facts div {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  padding: 12px;
}

.facts dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.facts dd {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.events-section {
  margin-top: 22px;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title h3 {
  font-size: 18px;
}

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

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

.event {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  padding: 12px;
}

.event-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.event-note {
  margin-top: 8px;
  line-height: 1.45;
}

.event pre {
  max-height: 170px;
  overflow: auto;
  margin: 10px 0 0;
  border-radius: 6px;
  background: #f1eee7;
  color: #49443c;
  padding: 10px;
  font-size: 12px;
  white-space: pre-wrap;
}

.empty {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.detail-empty {
  min-height: calc(100vh - 210px);
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  border: 1px solid #cfc6b8;
  border-radius: 8px;
  background: #22201c;
  color: #ffffff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

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

@media (max-width: 980px) {
  .shell {
    width: min(100vw - 20px, 720px);
  }

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

  .connection,
  .filters {
    flex-wrap: wrap;
  }

  .connection label,
  .filters label,
  .filters label:nth-child(2) {
    width: 100%;
    flex: 1 1 240px;
  }

  .pager {
    width: 100%;
    margin-left: 0;
  }

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

@media (max-width: 560px) {
  .shell {
    width: calc(100vw - 12px);
    padding-top: 8px;
  }

  .topbar,
  .detail {
    padding-left: 4px;
    padding-right: 4px;
  }

  .filters,
  .detail,
  .report-list {
    border-radius: 6px;
  }

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

  .detail-header {
    display: grid;
  }

  .open-link {
    width: fit-content;
  }
}
