:root {
  --bg: #f3efe8;
  --surface: #fbfaf6;
  --surface-strong: #f7f4ed;
  --line: #d8d1c2;
  --line-strong: #b9b09d;
  --text: #17251f;
  --muted: #5f695f;
  --accent: #0f7b45;
  --accent-soft: #dceedd;
  --accent-warm: #d89e3d;
  --shadow: 0 20px 40px rgba(23, 37, 31, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  overflow-x: hidden;
  background:
    radial-gradient(circle at top right, rgba(216, 158, 61, 0.08), transparent 26%),
    linear-gradient(180deg, #f8f5ef 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "Segoe UI Variable Text", "Bahnschrift", "Trebuchet MS", sans-serif;
}

body.detail-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="search"] {
  min-height: 44px;
}

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

.topbar,
.summary-strip,
.workspace,
.sidebar,
.list-panel {
  animation: rise-in 500ms ease both;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: end;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.brand-block h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 4vw, 4rem);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.eyebrow,
.panel-kicker,
.sidebar-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.subtitle,
.panel-meta,
.context-note,
.empty-copy,
.muted-copy {
  color: var(--muted);
}

.subtitle {
  max-width: 700px;
  margin: 14px 0 0;
  font-size: 1rem;
  line-height: 1.6;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 18px;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.summary-item {
  padding-right: 18px;
  border-right: 1px solid var(--line);
}

.summary-item:last-child {
  border-right: 0;
}

.summary-value {
  margin: 0;
  font-size: clamp(1.5rem, 2vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.summary-label {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.sidebar,
.list-panel,
.detail-modal {
  background: color-mix(in srgb, var(--surface) 88%, white 12%);
  border: 1px solid rgba(185, 176, 157, 0.65);
  box-shadow: var(--shadow);
}

.sidebar {
  position: sticky;
  top: 20px;
  align-self: start;
  padding: 18px;
}

.sidebar-block + .sidebar-block {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tab-button,
.tag,
.mini-chip {
  border: 1px solid var(--line);
  background: transparent;
}

.tab-button {
  padding: 11px 14px;
  color: var(--text);
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.tab-button:hover,
.result-row:hover {
  transform: translateY(-1px);
}

.tab-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.text-input,
.select-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.text-input:focus,
.select-input:focus {
  outline: 2px solid rgba(15, 123, 69, 0.14);
  border-color: var(--accent);
}

.list-panel,
.detail-modal {
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(247, 244, 237, 0.7));
}

.panel-head h2 {
  margin: 0;
  font-size: 1.3rem;
}

.results {
  max-height: calc(100vh - 270px);
  overflow: auto;
}

.result-row {
  width: 100%;
  display: grid;
  gap: 14px;
  align-items: center;
  padding: 18px 24px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 180ms ease, transform 180ms ease;
}

.result-row.active {
  background: linear-gradient(90deg, rgba(220, 238, 221, 0.85), rgba(251, 250, 246, 0.95));
}

.product-row {
  grid-template-columns: 64px minmax(0, 1.5fr) repeat(4, minmax(0, 0.8fr));
}

.order-row {
  grid-template-columns: minmax(0, 1.2fr) repeat(4, minmax(0, 0.8fr));
}

.store-row {
  grid-template-columns: minmax(0, 1.2fr) repeat(3, minmax(0, 0.8fr));
}

.result-primary {
  min-width: 0;
}

.thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.result-title,
.detail-hero h3,
.detail-section h4 {
  margin: 0;
}

.result-title {
  font-size: 1rem;
}

.result-subtitle,
.result-meta,
.detail-meta,
.detail-list,
.detail-table th,
.detail-table td {
  margin-top: 6px;
  font-size: 0.92rem;
  color: var(--muted);
}

.result-stat strong,
.money {
  color: var(--text);
}

.result-stat {
  min-width: 0;
}

.result-stat strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.98rem;
}

.result-stat,
.result-subtitle,
.result-meta,
.detail-meta,
.detail-list-item,
.detail-table th,
.detail-table td {
  overflow-wrap: anywhere;
}

.detail-body {
  max-height: calc(100vh - 180px);
  overflow: auto;
  padding: 24px;
}

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: start center;
  padding: 40px 24px;
}

.detail-overlay.open {
  display: grid;
  animation: fade-in 180ms ease both;
}

.detail-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(23, 37, 31, 0.34);
  cursor: pointer;
}

.detail-modal {
  position: relative;
  z-index: 1;
  width: min(980px, calc(100vw - 48px));
  max-height: calc(100vh - 80px);
}

.detail-close {
  min-height: 40px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  color: var(--text);
  cursor: pointer;
  transition: background-color 180ms ease, transform 180ms ease;
}

.detail-close:hover {
  transform: translateY(-1px);
  background: white;
}

.detail-hero {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.detail-hero .thumb {
  width: 88px;
  height: 88px;
}

.tag-row,
.mini-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag,
.mini-chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  color: var(--text);
  font-size: 0.82rem;
}

.tag {
  background: var(--accent-soft);
  border-color: rgba(15, 123, 69, 0.26);
}

.mini-chip {
  background: var(--surface-strong);
}

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

.detail-stat {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.detail-stat strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.15rem;
}

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

.detail-section h4 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.detail-list,
.detail-links {
  display: grid;
  gap: 10px;
}

.image-editor {
  display: grid;
  gap: 18px;
}

.editor-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.editor-state {
  min-width: 220px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.editor-state.tone-success {
  border-color: rgba(15, 123, 69, 0.34);
  background: var(--accent-soft);
  color: var(--text);
}

.editor-state.tone-error {
  border-color: rgba(165, 55, 38, 0.28);
  background: rgba(165, 55, 38, 0.08);
  color: #7e2d20;
}

.editor-grid {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 18px;
}

.image-preview-stage {
  display: grid;
  gap: 10px;
  align-content: start;
}

.editor-preview {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.editor-form {
  display: grid;
  gap: 12px;
}

.editor-label {
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.editor-button {
  padding: 11px 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.editor-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.6);
}

.editor-button-strong {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.editor-button-strong:hover {
  background: #0b6639;
}

.detail-list-item {
  padding: 12px 0;
  border-bottom: 1px solid rgba(216, 209, 194, 0.68);
}

.detail-list-item:last-child {
  border-bottom: 0;
}

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

.detail-table-wrap {
  overflow-x: auto;
}

.detail-table th,
.detail-table td {
  padding: 11px 0;
  border-bottom: 1px solid rgba(216, 209, 194, 0.68);
  text-align: left;
  vertical-align: top;
}

.detail-table th {
  color: var(--text);
  font-size: 0.86rem;
}

.detail-links a {
  color: var(--accent);
  text-decoration: none;
}

.detail-links a:hover {
  text-decoration: underline;
}

.empty-state {
  padding: 48px 24px 56px;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .results {
    max-height: none;
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 18px;
  }

  .topbar,
  .summary-strip,
  .workspace {
    grid-template-columns: 1fr;
  }

  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .summary-item {
    border-right: 0;
    padding: 0 0 14px;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    gap: 18px;
  }

  .sidebar {
    position: static;
  }

  .detail-overlay {
    padding: 20px 14px;
  }

  .detail-modal {
    width: min(100%, 920px);
    max-height: calc(100vh - 28px);
  }

  .product-row,
  .order-row,
  .store-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .product-row .thumb,
  .product-row .result-primary,
  .order-row .result-primary,
  .store-row .result-primary {
    grid-column: 1 / -1;
  }

  .product-row .thumb {
    width: 72px;
    height: 72px;
    margin-bottom: 2px;
  }

  .panel-head {
    flex-direction: column;
    align-items: start;
  }

  .panel-meta {
    margin: 0;
  }

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

  .detail-hero .thumb {
    width: 96px;
    height: 96px;
  }

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

  .editor-head,
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .editor-head {
    display: grid;
  }

  .editor-state {
    min-width: 0;
  }

  .detail-body {
    padding: 20px 18px 24px;
  }

  .detail-table {
    min-width: 520px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    gap: 18px;
    padding-bottom: 18px;
  }

  .subtitle {
    font-size: 0.95rem;
    line-height: 1.5;
  }

  .summary-strip {
    grid-template-columns: 1fr;
    padding: 18px 0;
  }

  .sidebar,
  .panel-head,
  .result-row,
  .detail-modal {
    border-radius: 0;
  }

  .sidebar {
    padding: 16px;
  }

  .list-panel,
  .detail-modal {
    box-shadow: none;
  }

  .detail-overlay {
    padding: 0;
    place-items: end stretch;
  }

  .detail-modal {
    width: 100%;
    max-height: 92vh;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }

  .product-row,
  .order-row,
  .store-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .result-row {
    padding: 16px 18px;
  }

  .product-row .thumb,
  .product-row .result-primary,
  .order-row .result-primary,
  .store-row .result-primary {
    grid-column: auto;
  }

  .result-title {
    font-size: 0.98rem;
  }

  .result-subtitle,
  .result-meta,
  .result-stat,
  .detail-meta,
  .detail-list,
  .detail-table th,
  .detail-table td {
    font-size: 0.88rem;
  }

  .detail-stat strong {
    font-size: 1.05rem;
  }

  .editor-preview {
    width: 112px;
    height: 112px;
  }
}
