:root {
  --bg: #090a0d;
  --surface: #111318;
  --surface-2: #171a21;
  --surface-3: #20242c;
  --text: #f4f6f8;
  --muted: #9aa2ad;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #b7ff22;
  --accent-strong: #9bea18;
  --accent-soft: rgba(183, 255, 34, 0.12);
  --warn: #f6c768;
  --danger: #ff6f61;
  --good: #b7ff22;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.32);
  --shadow-soft: 0 8px 22px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #090a0d 0%, #0f1116 48%, #090a0d 100%);
  color: var(--text);
  font-family: "Manrope", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: 0;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(183, 255, 34, 0.7);
  outline-offset: 2px;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 8px 0 12px;
  background: linear-gradient(180deg, rgba(9, 10, 13, 0.96), rgba(9, 10, 13, 0.76));
  backdrop-filter: blur(14px);
}

.topbar #statusLine {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.topbar #statusLine::before {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(183, 255, 34, 0.12);
  content: "";
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

h2 {
  margin: 14px 0 8px;
  font-size: 20px;
  line-height: 1.2;
}

h3 {
  margin: 20px 0 10px;
  font-size: 15px;
  line-height: 1.25;
}

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

.primary-btn,
.danger-btn,
.icon-btn,
.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.primary-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #0c1008;
  box-shadow: 0 10px 24px rgba(183, 255, 34, 0.14);
}

.primary-btn:active {
  background: var(--accent-strong);
}

.danger-btn {
  border-color: rgba(255, 111, 97, 0.35);
  color: var(--danger);
  background: rgba(255, 111, 97, 0.1);
}

.icon-btn {
  width: 40px;
  padding: 0;
  flex: 0 0 auto;
}

.icon-btn svg,
.primary-btn svg,
.tab svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.35;
}

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

.stat {
  min-height: 74px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01)), var(--surface);
  box-shadow: var(--shadow-soft);
}

.stat strong {
  display: block;
  color: var(--text);
  font-size: 23px;
  line-height: 1.05;
}

.stat span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

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

.tab {
  overflow: hidden;
  color: var(--muted);
  background: rgba(21, 23, 29, 0.88);
}

.tab span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab.is-active {
  color: #0c1008;
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 10px 22px rgba(183, 255, 34, 0.14);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
  animation: view-enter 220ms ease-out;
}

.motion-ready .view.is-active {
  animation: none;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px 40px;
  gap: 8px;
  margin-bottom: 12px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 19, 24, 0.94);
  color: var(--text);
  padding: 9px 11px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

input:focus,
select:focus {
  border-color: rgba(183, 255, 34, 0.7);
  box-shadow: 0 0 0 3px rgba(183, 255, 34, 0.13);
}

input[readonly] {
  color: var(--accent);
  background: #10150b;
  border-color: rgba(183, 255, 34, 0.28);
}

.panel-form {
  display: grid;
  grid-template-columns: 1fr 2fr 130px auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 19, 24, 0.9);
  box-shadow: var(--shadow-soft);
}

.settings-form {
  grid-template-columns: repeat(5, minmax(0, 1fr)) 40px auto auto;
}

.settings-save-btn {
  min-width: 132px;
  padding-inline: 20px;
}

.settings-cleanup-btn {
  min-width: 152px;
}

label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.category-list,
.job-list {
  display: grid;
  gap: 9px;
}

.product-list {
  display: grid;
  gap: 12px;
}

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

.product-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 19, 24, 0.94);
  color: var(--muted);
  font-weight: 800;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.product-tab span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-tab strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 24px;
  border-radius: 8px;
  padding: 2px 7px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 12px;
}

.product-tab.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #0c1008;
}

.product-tab.is-active strong {
  background: rgba(12, 16, 8, 0.14);
  color: #0c1008;
}

.product-section {
  display: grid;
  gap: 10px;
}

.product-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.product-section-head h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.product-section-head p {
  max-width: 680px;
  font-size: 12px;
}

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

.product-row,
.category-row,
.job-row {
  display: grid;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.012)), var(--surface);
  box-shadow: var(--shadow-soft);
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.product-row {
  grid-template-columns: 72px minmax(0, 1fr) 42px;
  align-items: start;
  cursor: pointer;
}

.product-row.is-viewed {
  border-color: rgba(183, 255, 34, 0.58);
  box-shadow: 0 0 0 1px rgba(183, 255, 34, 0.22), var(--shadow-soft);
}

.product-row .icon-btn {
  justify-self: end;
}

.category-row {
  grid-template-columns: minmax(0, 1fr) 92px 92px 42px;
}

.job-row {
  grid-template-columns: 88px minmax(0, 1fr) 160px;
}

.job-progress {
  height: 7px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.job-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #4de3ff);
  transition: width 220ms ease;
}

.thumb {
  width: 72px;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.title {
  min-width: 0;
}

.title strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.35;
}

.product-row .title strong {
  display: -webkit-box;
  min-height: 40px;
  white-space: normal;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid rgba(183, 255, 34, 0.18);
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 800;
  background: rgba(183, 255, 34, 0.11);
  color: var(--accent);
}

.badge.warn {
  border-color: rgba(246, 199, 104, 0.2);
  background: rgba(246, 199, 104, 0.12);
  color: var(--warn);
}

.badge.good {
  border-color: rgba(183, 255, 34, 0.22);
  background: rgba(183, 255, 34, 0.14);
  color: var(--good);
}

.price,
.margin {
  text-align: right;
  font-weight: 800;
}

.margin {
  color: var(--good);
}

.product-metrics {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding-top: 2px;
}

.product-metrics span {
  min-width: 0;
  padding: 8px 0 0;
  border-top: 1px solid var(--line);
}

.product-metrics small {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.product-metrics strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-metrics span:nth-child(2) strong {
  color: var(--good);
}

.product-metrics .sales-metric strong {
  color: var(--text);
}

.product-metrics .demand-metric strong {
  color: var(--text);
}

.product-metrics .demand-metric.warn strong {
  color: var(--warn);
}

.product-metrics .demand-metric.good strong {
  color: var(--good);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 42px;
}

.pager span {
  min-width: 64px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.pager button:disabled {
  opacity: 0.35;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  background: rgba(17, 19, 24, 0.56);
}

.detail-panel {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 20;
  width: min(520px, 100%);
  overflow-y: auto;
  background: #101218;
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 42px rgba(0, 0, 0, 0.44);
  transform: translateX(105%);
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform, opacity;
}

.detail-panel.is-open {
  transform: translateX(0);
}

.detail-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 18, 24, 0.94);
  backdrop-filter: blur(14px);
}

.detail-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-body {
  padding: 12px;
}

.detail-body .primary-btn {
  width: 100%;
}

.hero-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  box-shadow: var(--shadow-soft);
}

.kv {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px;
  margin: 12px 0;
  font-size: 14px;
}

.kv span:nth-child(odd) {
  color: var(--muted);
  font-weight: 700;
}

.kv strong,
.kv a {
  min-width: 0;
  overflow-wrap: anywhere;
}

.source-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  padding: 10px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow-soft);
}

.source-card .meta-line {
  color: var(--muted);
}

.source-link {
  display: inline-flex;
  margin-top: 6px;
  color: var(--accent);
  font-weight: 800;
}

.image-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 150ms ease, visibility 150ms ease;
}

.image-preview-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.image-preview-overlay img {
  max-width: min(88vw, 920px);
  max-height: 84vh;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  object-fit: contain;
  background: var(--surface-2);
  box-shadow: 0 28px 84px rgba(0, 0, 0, 0.62);
  transform: scale(0.96);
  transition: transform 150ms ease;
}

.image-preview-overlay.is-open img {
  transform: scale(1);
}

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

@keyframes view-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (hover: hover) {
  .primary-btn:hover {
    background: #c4ff46;
    box-shadow: 0 12px 26px rgba(183, 255, 34, 0.18);
  }

  .danger-btn:hover {
    border-color: rgba(255, 111, 97, 0.55);
    background: rgba(255, 111, 97, 0.15);
  }

  .icon-btn:hover,
  .tab:hover,
  .product-tab:hover {
    border-color: var(--line-strong);
    background: var(--surface-3);
  }

  .tab.is-active:hover,
  .product-tab.is-active:hover {
    background: var(--accent);
    color: #0c1008;
  }

  .product-row:hover,
  .category-row:hover,
  .job-row:hover,
  .source-card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow);
  }

  .product-row.is-viewed:hover {
    border-color: rgba(183, 255, 34, 0.72);
    box-shadow: 0 0 0 1px rgba(183, 255, 34, 0.26), var(--shadow);
  }

  .previewable-image:hover {
    cursor: zoom-in;
    border-color: rgba(183, 255, 34, 0.65);
  }
}

@media (max-width: 920px) {
  .settings-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-form .primary-btn,
  .settings-form .danger-btn {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 14px;
  }

  .app-shell {
    padding: 10px;
  }

  .topbar {
    min-height: 58px;
  }

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

  .panel-form,
  .settings-form {
    grid-template-columns: 1fr;
  }

  .settings-save-btn {
    width: 100%;
  }

  .settings-cleanup-btn {
    width: 100%;
  }

  .product-tabs {
    grid-template-columns: 1fr;
  }

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

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

  .product-row {
    grid-template-columns: 58px minmax(0, 1fr) 42px;
  }

  .thumb {
    width: 58px;
  }

  .category-row,
  .job-row {
    grid-template-columns: 1fr auto;
  }

  .category-row .title,
  .job-row .title {
    grid-column: 1 / -1;
  }

  .detail-head {
    grid-template-columns: 40px minmax(0, 1fr) auto;
  }
}

@media (max-width: 430px) {
  .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .tab {
    padding-inline: 8px;
  }

  .tab svg {
    width: 17px;
    height: 17px;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
