:root {
  color-scheme: light;
  --bg: #f5f5f2;
  --panel: #ffffff;
  --ink: #1e2428;
  --muted: #687076;
  --line: #d7d9d5;
  --accent: #1f7a5b;
  --accent-strong: #135f46;
  --warning: #9a5a13;
  --danger: #ab2d2d;
  --shadow: 0 16px 44px rgba(36, 42, 43, 0.09);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  padding: 0 18px;
}

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

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

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 91, 0.16);
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 64px);
  line-height: 0.95;
}

h2 {
  font-size: 22px;
}

.total {
  min-width: 230px;
  border-left: 3px solid var(--accent);
  padding-left: 18px;
  text-align: right;
}

.total span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.total strong {
  display: block;
  margin-top: 4px;
  font-size: 34px;
  line-height: 1;
}

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

.input-panel {
  padding: 16px;
}

.link-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.manual-button {
  margin-top: 10px;
}

.edit-form {
  display: grid;
  grid-template-columns: 1.7fr 150px 190px 150px 1fr;
  gap: 10px;
  margin-top: 12px;
}

.edit-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.hidden {
  display: none;
}

.ghost {
  background: #eef1ee;
  color: var(--ink);
}

.ghost:hover {
  background: #e0e5e0;
}

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

.danger:hover {
  background: #edd0d0;
}

.status {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.status[data-tone="ok"] {
  color: var(--accent-strong);
}

.status[data-tone="warn"] {
  color: var(--warning);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.summary {
  display: grid;
  min-height: 94px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.summary:hover {
  background: #f9faf7;
}

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

.summary strong {
  align-self: end;
  font-size: 22px;
}

.parts {
  overflow: hidden;
}

.parts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.parts-head select {
  max-width: 240px;
}

.items-list {
  display: grid;
}

.part {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.part:last-child {
  border-bottom: 0;
}

.part-main {
  min-width: 0;
}

.part-category {
  display: inline-flex;
  margin-bottom: 7px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.part-title {
  display: block;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
  text-decoration: none;
}

.part-title:hover {
  color: var(--accent-strong);
}

.part-title.no-link {
  cursor: default;
}

.part-title.no-link:hover {
  color: var(--ink);
}

.part-note {
  margin-top: 7px;
  color: var(--muted);
}

.part-side {
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 7px;
  min-width: 230px;
}

.part-price {
  font-size: 22px;
}

.part-shop {
  color: var(--muted);
  font-size: 14px;
}

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

.part-actions button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
}

.empty {
  grid-column: 1 / -1;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 820px) {
  .app {
    width: min(100% - 20px, 680px);
    padding-top: 18px;
  }

  .topbar,
  .parts-head,
  .part {
    align-items: stretch;
    flex-direction: column;
  }

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

  .total {
    min-width: 0;
    text-align: left;
  }

  .link-form,
  .edit-form,
  .edit-actions {
    grid-template-columns: 1fr;
  }

  .part-side {
    justify-items: start;
    min-width: 0;
  }

  .part-actions {
    width: 100%;
  }

  .part-actions button {
    flex: 1;
  }
}
