:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-soft: #faf8f2;
  --ink: #2b2f36;
  --muted: #66707d;
  --line: #d9dde3;
  --brand: #0f6d7a;
  --brand-dark: #1f2a44;
  --accent: #a06a20;
  --ok: #117a4b;
  --empty: #9a3412;
  --shadow: 0 14px 34px rgba(31, 42, 68, 0.1);
  --shadow-soft: 0 8px 22px rgba(31, 42, 68, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

.dashboard-header {
  display: grid;
  gap: 14px;
  padding: 24px clamp(18px, 5vw, 52px) 18px;
  background: linear-gradient(180deg, #fffdf8 0%, #f8f5ee 100%);
  border-bottom: 1px solid var(--line);
  box-shadow: none;
}

.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 5vw, 38px);
  line-height: 1.06;
  color: var(--brand-dark);
}

.module-description {
  max-width: 520px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.35;
}

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

.status-row {
  display: grid;
  grid-template-columns: minmax(220px, auto) 1fr;
  gap: 12px;
  align-items: center;
  padding-top: 2px;
}

.status-copy {
  display: grid;
  gap: 4px;
}

.updated-at {
  color: var(--muted);
  font-size: 12px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.secondary-action {
  min-width: 150px;
}

.load-progress {
  width: 100%;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(217, 221, 227, 0.7);
}

.load-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
  transition: width 180ms ease;
}

.metric-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 6px 0 16px;
}

.metric-card {
  display: inline-flex;
  min-height: 34px;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.72);
}

.metric-card span {
  display: block;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  color: var(--brand-dark);
  font-size: 16px;
  line-height: 1;
}

main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 4vw, 30px) 34px;
}

.search-panel {
  position: sticky;
  top: 0;
  z-index: 2;
  margin-bottom: 14px;
  padding: 14px 16px 13px;
  border: 1px solid rgba(217, 221, 227, 0.58);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  box-shadow: 0 8px 18px rgba(31, 42, 68, 0.04);
  backdrop-filter: blur(10px);
}

.loading-state {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.86);
  box-shadow: none;
}

.loading-state[hidden] {
  display: none;
}

.loading-state strong,
.loading-state span {
  display: block;
}

.loading-state strong {
  margin-bottom: 3px;
}

.loading-state span {
  color: var(--muted);
  font-size: 14px;
}

.loader {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.search-panel label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

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

input[type="search"] {
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
  outline: none;
}

input[type="search"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(15, 109, 122, 0.14);
}

button,
.market-link {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button {
  padding: 0 16px;
  border: 1px solid rgba(217, 221, 227, 0.9);
  background: var(--surface-soft);
  color: var(--brand-dark);
}

#clearSearch {
  min-height: 40px;
  align-self: center;
  padding: 0 14px;
  border-color: rgba(217, 221, 227, 0.72);
  background: rgba(255, 253, 248, 0.58);
  color: var(--muted);
  font-size: 13px;
}

button:hover,
button:focus {
  border-color: rgba(15, 109, 122, 0.45);
  background: #edf7f7;
}

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 16px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.search-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.search-suggestions[hidden] {
  display: none;
}

.suggestion-chip {
  display: inline-flex;
  width: auto;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
}

.suggestion-chip span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.suggestion-chip strong {
  max-width: min(240px, 60vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.suggestion-chip:hover,
.suggestion-chip:focus {
  border-color: var(--brand);
  background: #edf7f7;
}

.filters-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 9px 12px;
  margin-top: 11px;
  padding: 9px 0 0;
  border: 1px solid rgba(217, 221, 227, 0.62);
  border-width: 1px 0 0;
  border-radius: 0;
  background: transparent;
}

.filters-toggle {
  display: none;
}

.filter-group,
.select-filter {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.filter-group > span,
.select-filter > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.filter-option {
  min-width: 0;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.68);
  color: var(--muted);
  font-size: 13px;
}

.filter-option.active,
.view-option.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
}

.view-group {
  grid-column: 1 / -1;
}

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

.view-option {
  min-height: 36px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.68);
  color: var(--muted);
  font-size: 13px;
}

select {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

select:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 109, 122, 0.12);
}

.summary span {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.68);
}

.cards {
  display: grid;
  gap: 12px;
}

.view-compact .cards {
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
}

.view-visual .cards {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.product-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 18px rgba(31, 42, 68, 0.045);
}

.view-visual .product-card {
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 13px;
}

.product-image-wrap {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 1 / 1;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.view-visual .product-image-wrap {
  aspect-ratio: 4 / 3;
}

.product-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffffff;
}

.product-info {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 9px;
}

.product-head {
  display: flex;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.identity {
  min-width: 0;
}

.brand-value {
  display: block;
  margin-bottom: 2px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.model-value {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.view-compact .model-value {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.full-badge {
  flex: 0 0 auto;
  padding: 4px 7px;
  border: 1px solid rgba(15, 109, 122, 0.2);
  border-radius: 999px;
  background: #e9f5f6;
  color: var(--brand);
  font-size: 11px;
  font-weight: 900;
}

.image-placeholder {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.product-title {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.view-compact .product-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.tag-row {
  display: flex;
  max-width: 100%;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.color-tag {
  max-width: 100%;
  padding: 5px 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf7f7;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.variant-details {
  display: grid;
  max-width: 100%;
  min-width: 0;
  gap: 5px;
  padding: 8px;
  border-left: 3px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.variant-details[hidden],
.variant-line[hidden],
.variation-id[hidden] {
  display: none;
}

.variant-line {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 8px;
  align-items: baseline;
}

.variant-line span,
.variation-id {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.variant-line strong {
  overflow-wrap: anywhere;
  font-size: 15px;
}

.stock-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.stock-box {
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.stock-box span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.stock-box strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 18px;
  line-height: 1;
}

.stock-box.total {
  border-left: 4px solid var(--ok);
}

.stock-low .stock-box.total {
  border-left-color: var(--accent);
}

.stock-empty .stock-box.total {
  border-left-color: var(--empty);
}

.stock-box.full {
  background: #e9f5f6;
}

.stock-box.deposito {
  background: #eef5ed;
}

.technical-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.logistic-type {
  text-transform: uppercase;
}

.stock-pill {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.stock-good .stock-pill {
  background: #e7f6ee;
  color: var(--ok);
}

.stock-low .stock-pill {
  background: #fff7db;
  color: var(--accent);
}

.stock-empty .stock-pill {
  background: #fff1e9;
  color: var(--empty);
}

.market-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--brand-dark);
  font-size: 13px;
  text-decoration: none;
}

.market-link:focus,
.market-link:hover {
  border-color: var(--brand);
  background: #edf7f7;
}

.empty-state {
  padding: 28px 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

.empty-state.error-state {
  border-color: #f0b7a5;
  background: #fff5f2;
  color: var(--empty);
}

.back-to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 4;
  width: 46px;
  min-height: 46px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background: var(--brand-dark);
  color: #ffffff;
  font-size: 22px;
  line-height: 1;
  box-shadow: var(--shadow);
}

.back-to-top[hidden] {
  display: none;
}

@media (max-width: 620px), (max-width: 900px) and (max-height: 520px) {
  body {
    background: var(--bg);
  }

  .dashboard-header {
    gap: 9px;
    padding: 12px 14px 10px;
    box-shadow: none;
  }

  .header-main,
  .status-row {
    align-items: flex-start;
    grid-template-columns: 1fr;
  }

  .header-main {
    display: grid;
    gap: 8px;
  }

  .eyebrow {
    margin-bottom: 2px;
    font-size: 11px;
  }

  h1 {
    font-size: 25px;
  }

  .header-actions {
    display: none;
  }

  .status {
    text-align: left;
    font-size: 12px;
  }

  .updated-at {
    font-size: 11px;
  }

  .load-progress {
    height: 5px;
  }

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

  .metric-card {
    display: grid;
    padding: 7px 6px;
    border-radius: 7px;
    gap: 4px;
  }

  .metric-card span {
    margin-bottom: 4px;
    font-size: 9px;
    line-height: 1.05;
  }

  .metric-card strong {
    font-size: 17px;
  }

  main {
    padding: 10px 10px 28px;
  }

  .loading-state {
    margin-bottom: 8px;
    padding: 10px;
  }

  .loader {
    width: 22px;
    height: 22px;
  }

  .search-panel {
    position: sticky;
    top: 0;
    z-index: 3;
    margin: 0 -10px;
    padding: 8px 10px 10px;
    border: 1px solid var(--line);
    border-width: 1px 0;
    border-radius: 0;
    background: rgba(244, 241, 234, 0.96);
    backdrop-filter: blur(10px);
  }

  .search-panel label {
    margin-bottom: 6px;
    font-size: 12px;
  }

  .search-row {
    position: relative;
    grid-template-columns: 1fr;
  }

  input[type="search"] {
    min-height: 46px;
    padding: 0 74px 0 12px;
    border-width: 1px;
    font-size: 15px;
  }

  #clearSearch {
    position: absolute;
    top: 7px;
    right: 7px;
    width: auto;
    min-height: 32px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
  }

  button {
    width: 100%;
  }

  .suggestion-chip {
    width: auto;
    max-width: 100%;
  }

  .search-suggestions {
    max-height: 84px;
    overflow: auto;
  }

  .filters-toggle {
    display: flex;
    width: 100%;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--brand-dark);
  }

  .filters-toggle::after {
    content: "+";
    margin-left: 8px;
    font-size: 18px;
    line-height: 1;
  }

  .filters-toggle.is-open::after {
    content: "-";
  }

  .filters-panel {
    display: none;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 8px;
    padding: 10px;
  }

  .filters-panel.is-open {
    display: grid;
  }

  .segmented-control {
    grid-template-columns: 1fr;
  }

  .filter-option,
  .view-option,
  select {
    min-height: 34px;
    font-size: 12px;
  }

  .summary {
    gap: 6px;
    margin-top: 8px;
    font-size: 12px;
  }

  .summary span {
    padding: 5px 8px;
  }

  .back-to-top {
    right: 12px;
    bottom: 12px;
    width: 44px;
    min-height: 44px;
    padding: 0;
  }

  .cards,
  .view-compact .cards,
  .view-visual .cards {
    grid-template-columns: minmax(0, 1fr);
  }

  .product-card,
  .view-compact .product-card,
  .view-visual .product-card {
    grid-template-columns: 96px minmax(0, 1fr);
    min-width: 0;
  }

  .view-visual .product-card {
    grid-template-columns: 1fr;
  }

  .product-image-wrap {
    aspect-ratio: 1 / 1;
  }

  .view-visual .product-image-wrap {
    aspect-ratio: 16 / 10;
  }
}
