:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-2: #f0f4f8;
  --line: #d9e1ea;
  --text: #17202a;
  --muted: #697889;
  --accent: #1769aa;
  --accent-strong: #0f4f82;
  --good: #18715d;
  --shadow: 0 14px 40px rgba(18, 35, 52, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 260px;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.1;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

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

select,
input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.14);
}

.top-actions select {
  width: min(420px, 42vw);
}

.button,
button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 13px;
  white-space: nowrap;
}

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

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

.button.secondary:hover,
button:hover {
  border-color: #b9c6d4;
  background: #f9fbfd;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
}

.filters {
  position: sticky;
  top: 88px;
  align-self: start;
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.view-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.segmented {
  min-height: 38px;
  border: 0;
  border-radius: 0;
}

.segmented.active {
  background: var(--accent);
  color: #fff;
}

.results {
  min-width: 0;
}

.summary-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  min-height: 50px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: var(--panel);
}

.summary-strip > div {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: var(--muted);
}

.summary-strip strong {
  color: var(--text);
  font-size: 17px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.table-wrap {
  overflow: auto;
  height: calc(100vh - 154px);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: var(--panel);
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px;
}

tbody td {
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f7fbff;
}

.image-col {
  width: 72px;
}

.number-col {
  width: 106px;
  text-align: right;
}

.link-col {
  width: 64px;
}

.thumb {
  display: block;
  width: 54px;
  height: 72px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.name-cell {
  width: 300px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.category-cell {
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.sku-cell {
  width: 112px;
  color: var(--good);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.money {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.small-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.small-link:hover {
  color: var(--accent-strong);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: var(--panel);
}

.product-card {
  display: grid;
  grid-template-rows: 116px auto;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.product-card:hover {
  box-shadow: 0 8px 18px rgba(18, 35, 52, 0.1);
}

.product-card img {
  justify-self: center;
  width: 90px;
  height: 112px;
  object-fit: contain;
}

.product-card h3 {
  display: -webkit-box;
  min-height: 56px;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.card-meta {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 16px;
}

.details-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 30;
  width: min(430px, 92vw);
  height: 100vh;
  padding: 22px;
  transform: translateX(104%);
  transition: transform 180ms ease;
  border-left: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
  overflow: auto;
}

.details-drawer.open {
  transform: translateX(0);
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 22px;
}

.details-drawer img {
  display: block;
  width: 150px;
  height: 180px;
  margin: 28px auto 16px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.details-drawer h2 {
  margin-bottom: 18px;
  font-size: 18px;
  line-height: 1.35;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
}

dl div {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

dd {
  margin: 0;
  line-height: 1.4;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(16, 30, 44, 0.24);
}

@media (max-width: 900px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    align-items: stretch;
  }

  .top-actions select {
    width: 100%;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .filters {
    position: static;
  }

  .table-wrap {
    height: auto;
    max-height: 70vh;
  }
}

@media (max-width: 420px) {
  .topbar,
  .workspace {
    padding-left: 12px;
    padding-right: 12px;
  }

  .brand {
    min-width: 0;
  }

  .summary-strip {
    gap: 8px;
    padding: 8px 10px;
  }

  .summary-strip strong {
    font-size: 16px;
  }

  .pager {
    margin-left: auto;
  }
}
