:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #dbe2ea;
  --text: #1c2633;
  --muted: #66758a;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warn: #a15c08;
  --bad: #b42318;
  --good: #067647;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 16px;
  min-height: 100vh;
  padding: 16px;
}

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

.input-panel {
  position: sticky;
  top: 16px;
  align-self: start;
  padding: 18px;
}

.result-panel {
  display: grid;
  gap: 16px;
}

.panel {
  padding: 16px;
}

.panel.collapsible {
  padding-top: 12px;
}

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

.collapse-toggle {
  width: 100%;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.collapse-toggle:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  outline-offset: 6px;
  border-radius: 6px;
}

.head-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  transition: transform 0.16s ease;
}

.collapsible.is-collapsed .chevron {
  transform: rotate(180deg);
}

.collapsible.is-collapsed .table,
.collapsible.is-collapsed .chips {
  display: none;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.25;
}

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

p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.tag {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid #a7d9d4;
  border-radius: 999px;
  color: var(--accent-strong);
  background: #e9fbf8;
  font-size: 12px;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.field span {
  color: #344256;
  font-size: 13px;
  font-weight: 600;
}

input,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--text);
  background: #fff;
  font: inherit;
  font-size: 14px;
  outline: none;
}

textarea {
  min-height: 190px;
  resize: vertical;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

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

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.primary {
  width: 100%;
  margin-top: 16px;
  border: 0;
  border-radius: 6px;
  padding: 12px 14px;
  color: #fff;
  background: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

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

.primary:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.status {
  min-height: 20px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary > div {
  min-height: 96px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
  line-height: 1.1;
}

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

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

.part {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

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

.part strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
}

.table {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.row {
  display: grid;
  grid-template-columns: 80px 1fr 92px 90px 110px;
  min-height: 40px;
  border-top: 1px solid var(--line);
  align-items: center;
}

.row:first-child {
  border-top: 0;
}

.row.header {
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.cell {
  min-width: 0;
  padding: 9px 10px;
  overflow-wrap: anywhere;
}

.status-pill {
  display: inline-flex;
  max-width: 100%;
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef2f7;
  color: #475569;
  font-size: 12px;
}

.status-pill.good {
  background: #e7f8ef;
  color: var(--good);
}

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

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcfe;
  font-size: 13px;
}

.chip img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}

.empty {
  color: var(--muted);
  font-size: 13px;
}

.warnings {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }

  .input-panel {
    position: static;
  }

  .summary,
  .parts-list {
    grid-template-columns: 1fr;
  }

  .row {
    grid-template-columns: 72px 1fr 80px;
  }

  .row .cell:nth-child(4),
  .row .cell:nth-child(5) {
    display: none;
  }
}
