:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --ink: #17201b;
  --muted: #69736d;
  --line: #d8ded7;
  --panel: #ffffff;
  --panel-soft: #eef3ef;
  --green: #146947;
  --green-2: #0d5137;
  --amber: #a96b00;
  --red: #b13c2f;
  --blue: #245a87;
  --shadow: 0 18px 45px rgba(23, 32, 27, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  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;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
}

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

.topbar,
.panel-header,
.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  padding: 18px 0 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.02;
}

h2 {
  margin-bottom: 4px;
  font-size: 22px;
}

h3 {
  margin-bottom: 6px;
  font-size: 17px;
}

.top-actions,
.view-switch,
.actions-row,
.link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.plain-button,
.icon-button,
.view-switch button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 750;
}

.primary-button {
  background: var(--green);
  color: #fff;
}

.primary-button:hover {
  background: var(--green-2);
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.plain-button {
  width: 100%;
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--ink);
}

.icon-button,
.view-switch button {
  width: 40px;
  padding: 0;
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.view-switch .is-active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

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

.metrics article,
.filters,
.content-panel,
.product-card,
.certificate-card,
.dialog-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics article {
  padding: 18px;
  min-height: 92px;
}

.metrics span {
  display: block;
  font-size: 30px;
  line-height: 1;
  font-weight: 850;
}

.metrics p,
.panel-header p,
.product-card p,
.certificate-card p,
.detail-meta p {
  margin-bottom: 0;
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.filters,
.content-panel {
  box-shadow: var(--shadow);
}

.filters {
  position: sticky;
  top: 16px;
  padding: 16px;
}

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

label {
  color: #2d3931;
  font-size: 13px;
  font-weight: 800;
}

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

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(20, 105, 71, 0.18);
  outline-offset: 2px;
}

.certificate-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.certificate-card {
  padding: 12px;
}

.certificate-card strong {
  display: block;
  margin-bottom: 6px;
  line-height: 1.25;
}

.certificate-card code,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  background: #eef5f1;
  color: var(--green-2);
  font-size: 12px;
  font-weight: 800;
}

.content-panel {
  min-height: 640px;
  padding: 18px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.product-card {
  overflow: hidden;
  display: grid;
  grid-template-rows: 170px 1fr;
}

.product-image,
.image-placeholder {
  width: 100%;
  height: 170px;
  background: #e8ece8;
}

.image-frame {
  position: relative;
  width: 100%;
  height: 170px;
  background: #e8ece8;
}

.product-image {
  object-fit: contain;
  padding: 10px;
}

.image-frame .product-image,
.image-frame .image-placeholder {
  display: block;
}

.image-edit-button {
  position: absolute;
  right: 8px;
  bottom: 8px;
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(20, 105, 71, 0.92);
  color: #fff;
  font-size: 12px;
  font-weight: 850;
  box-shadow: 0 8px 20px rgba(23, 32, 27, 0.18);
}

.image-edit-button:hover {
  background: var(--green-2);
}

.image-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 850;
}

.product-body {
  display: grid;
  gap: 10px;
  padding: 13px;
}

.product-title-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.model {
  overflow-wrap: anywhere;
  font-weight: 850;
}

.status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 850;
}

.status.certified {
  background: #e4f3ea;
  color: var(--green-2);
}

.status.open {
  background: #fff4d9;
  color: var(--amber);
}

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

.fact {
  min-height: 50px;
  padding: 8px;
  border-radius: 8px;
  background: #f5f7f5;
}

.fact span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.fact strong {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.actions-row button {
  flex: 1 1 110px;
}

.table-wrap {
  margin-top: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
  background: #fff;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  background: #f1f5f1;
  font-size: 12px;
  text-transform: uppercase;
}

td img {
  width: 64px;
  height: 52px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f8f7;
}

dialog {
  width: min(920px, calc(100vw - 28px));
  border: 0;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(12, 18, 16, 0.52);
}

.dialog-card {
  padding: 20px;
  box-shadow: var(--shadow);
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin-top: 21px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.detail-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 18px;
  margin-top: 16px;
}

.detail-product-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f5f3;
  padding: 12px;
}

.detail-image-wrap {
  display: grid;
  gap: 8px;
}

.detail-image-action {
  width: 100%;
  margin-top: 8px;
}

.detail-meta {
  display: grid;
  gap: 10px;
}

.category-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f7f9f7;
}

.category-editor label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.category-editor div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.category-editor select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  min-height: 40px;
  background: #fff;
  font: inherit;
  font-weight: 800;
  color: var(--ink);
}

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

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

.label-preview-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f8f7;
}

.link-row a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 300px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

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

  .filters {
    position: static;
  }

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

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

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1500px);
    padding-top: 14px;
  }

  .topbar,
  .panel-header,
  .dialog-header,
  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .dialog-actions {
    width: 100%;
  }

  .top-actions > *,
  .dialog-actions > * {
    flex: 1 1 auto;
  }

  .metrics,
  .form-grid,
  .product-facts {
    grid-template-columns: 1fr;
  }

  .product-card {
    grid-template-rows: 145px 1fr;
  }

  .product-image,
  .image-placeholder {
    height: 145px;
  }
}
