:root {
  --bg: #f4efe4;
  --bg-accent: #efe0c2;
  --panel: rgba(255, 251, 244, 0.88);
  --panel-strong: #fffdf8;
  --text: #26211c;
  --muted: #6f665c;
  --border: rgba(61, 43, 25, 0.15);
  --shadow: 0 22px 55px rgba(67, 45, 11, 0.12);
  --accent: #bf4f22;
  --accent-strong: #8e3412;
  --accent-soft: #ffd8b8;
  --badge: #f4e5cf;
  --font-display: Georgia, "Times New Roman", serif;
  --font-body: "Trebuchet MS", "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  --bg: #16181d;
  --bg-accent: #1f252d;
  --panel: rgba(28, 32, 39, 0.9);
  --panel-strong: #222831;
  --text: #f2ede4;
  --muted: #b1aba0;
  --border: rgba(233, 220, 201, 0.12);
  --shadow: 0 22px 55px rgba(0, 0, 0, 0.35);
  --accent: #dd7b47;
  --accent-strong: #ffb07e;
  --accent-soft: #4a3124;
  --badge: #2e343d;
}

:root[data-theme="cherry"] {
  --bg: #fff4f7;
  --bg-accent: #ffdbe6;
  --panel: rgba(255, 247, 250, 0.92);
  --panel-strong: #fffafd;
  --text: #452d37;
  --muted: #8a6673;
  --border: rgba(129, 67, 89, 0.16);
  --shadow: 0 22px 55px rgba(150, 82, 108, 0.14);
  --accent: #d65d85;
  --accent-strong: #b34067;
  --accent-soft: #ffd2e0;
  --badge: #ffe3ec;
}

:root[data-theme="sky"] {
  --bg: #eef7ff;
  --bg-accent: #d6ebff;
  --panel: rgba(246, 251, 255, 0.92);
  --panel-strong: #fcfeff;
  --text: #21384c;
  --muted: #64809a;
  --border: rgba(52, 103, 149, 0.16);
  --shadow: 0 22px 55px rgba(84, 140, 194, 0.14);
  --accent: #2d8fd6;
  --accent-strong: #1769a6;
  --accent-soft: #d7eeff;
  --badge: #deefff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top left, rgba(255, 220, 184, 0.95), transparent 34%),
    radial-gradient(circle at top right, rgba(205, 233, 204, 0.55), transparent 26%),
    linear-gradient(180deg, #f7f0e5 0%, var(--bg) 100%);
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(120, 88, 62, 0.22), transparent 30%),
    radial-gradient(circle at top right, rgba(61, 102, 109, 0.16), transparent 24%),
    linear-gradient(180deg, #121418 0%, var(--bg) 100%);
}

:root[data-theme="cherry"] body {
  background:
    radial-gradient(circle at top left, rgba(255, 196, 216, 0.82), transparent 34%),
    radial-gradient(circle at top right, rgba(255, 232, 186, 0.42), transparent 28%),
    linear-gradient(180deg, #fff8fb 0%, var(--bg) 100%);
}

:root[data-theme="sky"] body {
  background:
    radial-gradient(circle at top left, rgba(184, 222, 255, 0.9), transparent 34%),
    radial-gradient(circle at top right, rgba(214, 244, 255, 0.62), transparent 28%),
    linear-gradient(180deg, #f9fcff 0%, var(--bg) 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 24px auto 40px;
}

.hero,
.panel {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero {
  padding: 28px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  background:
    linear-gradient(140deg, rgba(255, 247, 235, 0.94), rgba(248, 236, 213, 0.82)),
    var(--panel);
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.74rem;
  color: var(--accent-strong);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  margin: 0;
}

h1 {
  font-size: clamp(2.3rem, 4vw, 4.2rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.7rem;
}

h3 {
  font-size: 1.15rem;
}

.hero-text,
.section-heading p,
.import-card p,
#datasetMeta,
#resultsMeta,
.status-bar,
.detail-meta,
.empty-state,
.detail-card p {
  color: var(--muted);
}

.hero-actions,
.action-row,
.results-header,
.view-toggle,
.results-tools {
  display: flex;
  gap: 12px;
  align-items: center;
}

.theme-control {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.theme-control select {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
}

:root[data-theme="dark"] .theme-control select,
:root[data-theme="dark"] .inline-control select,
:root[data-theme="dark"] .filters input,
:root[data-theme="dark"] .filters select,
:root[data-theme="dark"] .paste-input,
:root[data-theme="dark"] .file-input,
:root[data-theme="dark"] .sort-chip,
:root[data-theme="dark"] .page-button,
:root[data-theme="dark"] .detail-link,
:root[data-theme="dark"] .meta-pill,
:root[data-theme="dark"] .toggle-button,
:root[data-theme="dark"] .button-ghost {
  background: rgba(39, 45, 54, 0.94);
  color: var(--text);
}

:root[data-theme="dark"] .hero {
  background:
    linear-gradient(140deg, rgba(34, 39, 46, 0.96), rgba(27, 31, 37, 0.88)),
    var(--panel);
}

:root[data-theme="cherry"] .hero {
  background:
    linear-gradient(140deg, rgba(255, 247, 250, 0.97), rgba(255, 230, 239, 0.9)),
    var(--panel);
}

:root[data-theme="sky"] .hero {
  background:
    linear-gradient(140deg, rgba(248, 253, 255, 0.97), rgba(226, 242, 255, 0.9)),
    var(--panel);
}

:root[data-theme="dark"] .stat-card,
:root[data-theme="dark"] .import-card,
:root[data-theme="dark"] .empty-state,
:root[data-theme="dark"] .detail-card,
:root[data-theme="dark"] .detail-stat {
  background: linear-gradient(180deg, rgba(36, 42, 50, 0.96), rgba(28, 33, 40, 0.92));
}

:root[data-theme="cherry"] .stat-card,
:root[data-theme="cherry"] .import-card,
:root[data-theme="cherry"] .empty-state,
:root[data-theme="cherry"] .detail-card,
:root[data-theme="cherry"] .detail-stat {
  background: linear-gradient(180deg, rgba(255, 251, 252, 0.98), rgba(255, 238, 244, 0.94));
}

:root[data-theme="sky"] .stat-card,
:root[data-theme="sky"] .import-card,
:root[data-theme="sky"] .empty-state,
:root[data-theme="sky"] .detail-card,
:root[data-theme="sky"] .detail-stat {
  background: linear-gradient(180deg, rgba(252, 254, 255, 0.98), rgba(232, 244, 255, 0.94));
}

:root[data-theme="dark"] .chip {
  background: rgba(52, 60, 70, 0.96);
  color: #efe6d6;
}

:root[data-theme="cherry"] .chip {
  background: rgba(255, 226, 236, 0.98);
  color: #784357;
}

:root[data-theme="sky"] .chip {
  background: rgba(221, 240, 255, 0.98);
  color: #2b5f86;
}

:root[data-theme="dark"] .item-card {
  background: linear-gradient(180deg, rgba(36, 42, 50, 0.98), rgba(27, 32, 39, 0.94));
}

:root[data-theme="cherry"] .item-card {
  background: linear-gradient(180deg, rgba(255, 252, 253, 0.98), rgba(255, 235, 242, 0.94));
}

:root[data-theme="sky"] .item-card {
  background: linear-gradient(180deg, rgba(253, 255, 255, 0.98), rgba(231, 244, 255, 0.94));
}

:root[data-theme="dark"] .item-image-wrap {
  background:
    radial-gradient(circle at top, rgba(70, 80, 94, 0.78), rgba(31, 37, 45, 0.96));
}

:root[data-theme="cherry"] .item-image-wrap {
  background:
    radial-gradient(circle at top, rgba(255, 245, 249, 0.98), rgba(255, 226, 236, 0.95));
}

:root[data-theme="sky"] .item-image-wrap {
  background:
    radial-gradient(circle at top, rgba(249, 253, 255, 0.98), rgba(219, 239, 255, 0.95));
}

:root[data-theme="dark"] .item-title,
:root[data-theme="dark"] .item-price,
:root[data-theme="dark"] .item-price strong,
:root[data-theme="dark"] .stat-value,
:root[data-theme="dark"] .detail-name,
:root[data-theme="dark"] .detail-stat strong,
:root[data-theme="dark"] td,
:root[data-theme="dark"] th {
  color: var(--text);
}

:root[data-theme="dark"] thead th {
  background: #252c34;
}

:root[data-theme="cherry"] thead th {
  background: #fff0f5;
}

:root[data-theme="sky"] thead th {
  background: #eaf5ff;
}

:root[data-theme="dark"] .item-table-wrap {
  background: rgba(26, 31, 37, 0.82);
}

:root[data-theme="cherry"] .item-table-wrap {
  background: rgba(255, 247, 250, 0.88);
}

:root[data-theme="sky"] .item-table-wrap {
  background: rgba(247, 252, 255, 0.88);
}

:root[data-theme="dark"] .detail-links {
  border-top-color: rgba(233, 220, 201, 0.12);
}

.layout {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.panel {
  padding: 20px;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading-collapsible {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.section-heading p {
  margin: 6px 0 0;
}

.collapse-toggle {
  flex: 0 0 auto;
  min-width: 96px;
}

.filter-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

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

.import-card {
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--border);
}

.paste-input {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
}

.file-input {
  width: 100%;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
}

.file-action-row {
  margin-top: 14px;
}

.paste-input-short {
  min-height: 148px;
}

.button,
.toggle-button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, color 120ms ease;
}

.button {
  background: var(--accent);
  color: #fff8f2;
}

.button:hover,
.toggle-button:hover {
  transform: translateY(-1px);
}

.button-secondary {
  background: #1e5c6e;
}

.button-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.status-bar {
  margin-top: 14px;
  min-height: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(248, 238, 223, 0.9));
  border: 1px solid var(--border);
}

.stat-label {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  margin-top: 8px;
  font-size: 1.6rem;
  font-weight: 700;
}

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

.filters label {
  display: grid;
  gap: 7px;
}

.filters span {
  font-size: 0.82rem;
  color: var(--muted);
}

.filters input,
.filters select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.7fr);
  gap: 18px;
}

.results-header {
  justify-content: space-between;
}

.results-tools {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.inline-control {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.inline-control select {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
}

.sort-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.sort-row-label {
  color: var(--muted);
  font-size: 0.95rem;
}

.sort-chip-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.sort-chip {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.sort-chip.is-active {
  background: var(--text);
  color: #fffdf7;
}

.toggle-button {
  background: rgba(247, 235, 214, 0.9);
  color: var(--text);
}

.toggle-button.is-active {
  background: var(--text);
  color: #fffdf7;
}

.chip-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--badge);
  color: #513b26;
  font-size: 0.88rem;
}

.empty-state {
  padding: 26px;
  text-align: center;
  border-radius: 18px;
  border: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.5);
}

.is-hidden {
  display: none !important;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.item-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(245, 236, 220, 0.84));
  cursor: pointer;
}

.item-card:hover,
.item-row:hover {
  border-color: rgba(191, 79, 34, 0.45);
}

.item-image-wrap {
  position: relative;
  min-height: 145px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.95), rgba(236, 225, 204, 0.92));
  overflow: hidden;
}

.item-image {
  max-width: 96px;
  max-height: 96px;
  object-fit: contain;
}

.qty-pill {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(38, 33, 28, 0.86);
  color: #fff;
  font-size: 0.85rem;
}

.item-title {
  font-size: 1rem;
  line-height: 1.2;
}

.meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-pill {
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border);
}

.item-price {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.item-price strong {
  font-size: 1.1rem;
}

.item-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.pagination-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.page-button {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.page-button.is-active {
  background: var(--text);
  color: #fffdf7;
}

.page-summary {
  color: var(--muted);
  font-size: 0.95rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(61, 43, 25, 0.08);
}

thead th {
  position: sticky;
  top: 0;
  background: #f7efe2;
  z-index: 1;
}

.item-row {
  cursor: pointer;
}

.detail-panel {
  position: sticky;
  top: 18px;
  align-self: start;
}

.detail-card {
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
  min-height: 320px;
  padding: 18px;
}

.detail-card.empty-detail {
  display: grid;
  place-items: center;
}

.detail-hero {
  display: grid;
  gap: 16px;
}

.detail-image {
  max-width: 120px;
  max-height: 120px;
  object-fit: contain;
}

.detail-name {
  font-size: 1.6rem;
}

.detail-description {
  margin: 14px 0;
  line-height: 1.5;
}

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

.detail-stat {
  padding: 12px;
  border-radius: 16px;
  background: rgba(246, 238, 227, 0.8);
}

.detail-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.detail-links {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(61, 43, 25, 0.12);
  text-align: center;
}

.detail-links-title {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.detail-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(61, 43, 25, 0.18);
  box-shadow: 0 8px 20px rgba(61, 43, 25, 0.08);
  overflow: hidden;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.detail-link:hover {
  transform: translateY(-1px);
  border-color: rgba(191, 79, 34, 0.4);
  box-shadow: 0 12px 24px rgba(61, 43, 25, 0.12);
}

.detail-link-icon-image {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

.mobile-detail-sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
}

.mobile-detail-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(16, 18, 22, 0.58);
}

.mobile-detail-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(82vh, 760px);
  overflow: auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  box-shadow: 0 -18px 40px rgba(0, 0, 0, 0.22);
}

.mobile-detail-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.mobile-detail-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.mobile-detail-close {
  flex: 0 0 auto;
}

body.has-mobile-detail-open {
  overflow: hidden;
}

@media (max-width: 1100px) {
  .import-grid,
  .filters,
  .stats-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }
}

@media (max-width: 1000px) {
  .item-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

@media (max-width: 720px) {
  .detail-panel {
    display: none;
  }

  .page-shell {
    width: min(100% - 20px, 100%);
  }

  .panel,
  .hero {
    padding: 16px;
    border-radius: 20px;
  }

  .hero {
    flex-direction: column;
    align-items: start;
    gap: 16px;
  }

  .hero-text {
    font-size: 0.98rem;
  }

  .section-heading-collapsible,
  .results-header,
  .sort-row {
    flex-direction: column;
    align-items: stretch;
  }

  .collapse-toggle,
  .results-tools,
  .inline-control,
  .inline-control select,
  .theme-control,
  .theme-control select {
    width: 100%;
  }

  .results-tools,
  .hero-actions,
  .action-row,
  .view-toggle {
    flex-wrap: wrap;
    width: 100%;
  }

  .hero-actions,
  .results-tools,
  .view-toggle,
  .action-row {
    gap: 10px;
  }

  .button,
  .toggle-button,
  .button-ghost {
    min-height: 44px;
  }

  .hero-actions .button,
  .hero-actions .theme-control,
  .action-row .button,
  .results-tools .inline-control,
  .results-tools .view-toggle {
    width: 100%;
  }

  .view-toggle .toggle-button {
    flex: 1 1 0;
  }

  .inline-control {
    justify-content: space-between;
  }

  .file-action-row .button,
  .action-row .button {
    width: 100%;
  }

  .paste-input {
    min-height: 180px;
  }

  .filters {
    gap: 12px;
  }

  .filter-actions {
    justify-content: stretch;
  }

  .filter-actions .button {
    width: 100%;
  }

  .chip-bar {
    gap: 8px;
  }

  .chip {
    width: 100%;
    justify-content: center;
  }

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

  .detail-name {
    font-size: 1.4rem;
  }

  .detail-link-row {
    gap: 8px;
  }

  .detail-link {
    width: 42px;
    height: 42px;
  }
}

@media (min-width: 721px) {
  .mobile-detail-sheet {
    display: none !important;
  }
}

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

  .stat-value {
    font-size: 1.35rem;
  }

  .page-button {
    padding: 9px 11px;
  }
}
