:root {
  --bg: #f0f2f5;
  --ink: #050505;
  --muted: #65676b;
  --card: #fff;
  --line: #dadde1;
  --line-soft: #e4e6eb;
  --accent: #1877f2;
  --accent-hover: #166fe5;
  --accent-tint: #e7f3ff;
  --green: #31a24c;
  --green-tint: #e7f7ed;
  --amber: #b45309;
  --danger: #e41e3f;
  --danger-tint: #ffebe9;
  --shadow: 0 1px 2px rgba(0,0,0,.10), 0 0 1px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 56px;
}

h1, h2, h3 { margin: 0; letter-spacing: 0; }
h1 { font-size: 28px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 800; }
h3 { font-size: 16px; font-weight: 900; }

p {
  color: var(--muted);
  margin: 4px 0 0;
  font-size: 15px;
}

button, input, textarea {
  font: inherit;
}

.page-head {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--card);
  padding: 6px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.nav-btn:hover {
  background: var(--line-soft);
  color: var(--ink);
}

.nav-btn.active {
  background: var(--accent-tint);
  color: var(--accent);
}

.panel {
  background: var(--card);
  border: none;
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.panel-head,
.results-head,
.content-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.panel-head {
  margin-bottom: 12px;
}

.content-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, .75fr) minmax(90px, .35fr) minmax(190px, .8fr) auto;
  gap: 12px;
  align-items: end;
}

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

input, textarea {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f0f2f5;
  color: var(--ink);
  padding: 10px 12px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

input {
  min-height: 42px;
}

textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.45;
}

input:focus, textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.btn,
.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}

.btn:hover,
.action:hover {
  background: var(--accent-hover);
}

.btn.secondary,
.action.secondary {
  background: var(--line-soft);
  color: var(--ink);
}

.btn.secondary:hover,
.action.secondary:hover {
  background: #d8dadf;
}

.action.danger {
  background: var(--danger-tint);
  color: var(--danger);
}

.action.danger:hover {
  background: #ffd9d6;
}

.btn:disabled,
.action:disabled {
  cursor: wait;
  opacity: .68;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.status-card {
  text-align: left;
  border: none;
  border-radius: 8px;
  background: var(--card);
  padding: 14px 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.status-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 6px;
}

.status-card strong {
  display: block;
  color: var(--accent);
  font-size: 28px;
  line-height: 1;
  font-weight: 800;
}

.status-card.active {
  box-shadow: inset 0 0 0 2px var(--accent), var(--shadow);
}

.tools-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: end;
  margin: 16px 0;
}

.data-status {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.data-status.is-error {
  color: var(--danger);
}

.content-list {
  display: grid;
  gap: 14px;
}

.content-card {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 16px;
  background: var(--card);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.product-image-panel {
  display: grid;
  gap: 10px;
  align-content: start;
}

.image-drop {
  border: 2px dashed var(--line);
  border-radius: 8px;
  background: #f7f8fa;
  color: var(--muted);
  min-height: 150px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  transition: border-color .15s, background .15s, color .15s;
}

.image-drop:hover,
.image-drop.is-dragover {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent);
}

.image-drop img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  display: block;
  border-radius: 6px;
  background: #fff;
}

.image-drop input {
  display: none;
}

.drop-hint {
  display: grid;
  gap: 4px;
}

.drop-hint small {
  color: var(--muted);
  font-weight: 700;
}

.content-main {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.content-title-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(110px, .55fr) minmax(90px, .35fr);
  gap: 10px;
}

.content-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-top: 4px;
}

.content-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

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

.part-box {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fafbfc;
  padding: 10px;
}

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

.part-head strong {
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.part-head button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.extra-images {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}

.extra-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.extra-head h3 {
  color: var(--ink);
}

.extra-drop {
  min-height: 82px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.image-tile {
  position: relative;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.image-tile img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #f0f2f5;
}

.image-tile button {
  position: absolute;
  top: 6px;
  right: 6px;
  min-height: 28px;
  width: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(228, 30, 63, .94);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
}

.empty {
  color: var(--amber);
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: 14px 16px;
  font-weight: 700;
}

@media (max-width: 900px) {
  .content-form,
  .tools-panel,
  .status-strip,
  .content-card,
  .content-title-grid {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .results-head,
  .content-top {
    flex-direction: column;
  }

  .data-status {
    text-align: left;
  }

  .btn,
  .tools-panel .btn {
    width: 100%;
  }

  .nav-btn {
    flex: 1 1 auto;
    padding: 8px 10px;
  }
}
