:root {
  color-scheme: light;
  --bg: #14081f;
  --surface: rgba(248, 244, 235, 0.92);
  --surface-strong: #fffaf2;
  --ink: #22180f;
  --muted: #6f5b42;
  --line: rgba(109, 83, 46, 0.18);
  --brand: #d4af37;
  --accent: #241732;
  --danger: #c33f5c;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.24);
  --radius: 24px;
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(212, 175, 55, 0.18), transparent 24%),
    radial-gradient(circle at bottom right, rgba(36, 23, 50, 0.22), transparent 28%),
    linear-gradient(180deg, #f6efe2 0%, #eadcc4 100%);
}

.global-loader[hidden] {
  display: none;
}

.global-loader {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  background: rgba(20, 8, 31, 0.2);
  backdrop-filter: blur(4px);
}

.global-loader__panel {
  min-width: 220px;
  padding: 20px 22px;
  border-radius: 22px;
  background: var(--surface-strong);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  display: grid;
  justify-items: center;
  gap: 12px;
}

.global-loader__spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(36, 23, 50, 0.12);
  border-top-color: var(--brand);
  animation: app-spin 0.8s linear infinite;
}

.global-loader__text {
  color: var(--muted);
  font-size: 0.95rem;
}

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

.shell {
  min-height: 100vh;
}

.main {
  padding: 28px;
}

.app-header,
.page-header,
.panel-header,
.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.app-header {
  margin-bottom: 18px;
}

.page-header {
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 56px;
  height: 56px;
  display: block;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.status-pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  box-shadow: var(--shadow);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.cards,
.dashboard-grid {
  display: grid;
  gap: 16px;
}

.cards {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 18px;
}

.dashboard-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  margin-bottom: 18px;
}

.metric-card,
.panel {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.metric-card {
  padding: 18px;
}

.metric-card .label {
  color: var(--muted);
  margin-bottom: 8px;
}

.metric-card .value {
  font-size: 2rem;
  line-height: 1;
  font-weight: 700;
}

.panel {
  padding: 18px;
}

.button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
}

.button-primary {
  color: white;
  background: linear-gradient(135deg, var(--brand), var(--accent));
}

.button-secondary {
  background: rgba(36, 23, 50, 0.08);
  color: var(--ink);
  border-color: rgba(36, 23, 50, 0.12);
}

.table-wrap {
  overflow: auto;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.import-actions input[type="file"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.file-button {
  display: inline-flex;
  align-items: center;
}

.file-name,
.helper-text {
  color: var(--muted);
}

.helper-text {
  margin: 0 0 14px;
  font-size: 0.92rem;
}

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

.sort-button.is-active {
  color: var(--ink);
}

.sort-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 14px;
  opacity: 0.75;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  background: rgba(36, 23, 50, 0.08);
  text-transform: capitalize;
}

.customer-meta {
  display: grid;
  gap: 4px;
  min-width: 220px;
  line-height: 1.45;
}

.customer-meta strong {
  color: var(--ink);
}

.product-meta {
  display: grid;
  grid-template-columns: 56px minmax(180px, 1fr);
  gap: 12px;
  align-items: start;
}

.product-meta__media {
  display: inline-flex;
  width: 56px;
  height: 56px;
}

.product-meta__image,
.product-meta__placeholder {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
}

.product-meta__placeholder {
  background: rgba(36, 23, 50, 0.08);
  border: 1px solid var(--line);
}

.product-meta__details {
  display: grid;
  gap: 4px;
  line-height: 1.45;
}

.product-meta__details strong {
  color: var(--ink);
}

.product-meta__details a {
  color: var(--ink);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.settings-stack {
  display: grid;
  gap: 18px;
}

.settings-section h3 {
  margin: 0 0 6px;
}

.section-copy {
  margin: 0;
  color: var(--muted);
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.choice-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
}

.choice-card input {
  width: auto;
  margin: 0;
}

.settings-install {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-top: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.45);
}

.settings-install-copy {
  display: grid;
  gap: 6px;
}

.settings-install-copy strong {
  font-size: 1rem;
}

.settings-install-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-grid label {
  display: grid;
  gap: 8px;
}

.settings-color-input {
  position: relative;
  display: grid;
}

.settings-color-input input {
  padding-right: 52px;
}

.settings-color-swatch {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  transform: translateY(-50%);
  background: var(--preview-color, transparent);
  border: 1px solid rgba(36, 23, 50, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.38);
  pointer-events: none;
}

.settings-color-swatch.is-invalid {
  background:
    linear-gradient(135deg, transparent 44%, rgba(208, 59, 59, 0.82) 44%, rgba(208, 59, 59, 0.82) 56%, transparent 56%),
    rgba(36, 23, 50, 0.06);
  border-color: rgba(208, 59, 59, 0.32);
}

.full-width {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  padding: 12px 14px;
  color: var(--ink);
}

.empty {
  color: var(--muted);
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(34px, 1fr));
  gap: 12px;
  align-items: end;
  min-height: 220px;
}

.bar-card {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.bar-fill {
  width: 100%;
  border-radius: 999px 999px 10px 10px;
  background: linear-gradient(180deg, #d4af37 0%, #241732 100%);
  min-height: 12px;
}

.bar-value,
.bar-label {
  font-size: 12px;
  color: var(--muted);
}

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

.admin-dialog {
  width: min(1100px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  border: 0;
  padding: 0;
  background: transparent;
}

.admin-dialog::backdrop {
  background: rgba(20, 8, 31, 0.44);
}

.admin-dialog__panel {
  background: var(--surface-strong);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.admin-dialog__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.admin-dialog__header h3 {
  margin: 0;
}

.admin-dialog__body {
  padding: 22px;
  max-height: calc(100vh - 180px);
  overflow: auto;
}

.top-products-list {
  display: grid;
  gap: 14px;
}

.top-product-card {
  display: grid;
  grid-template-columns: auto 88px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
}

.top-product-rank {
  font-weight: 700;
  color: var(--accent);
  min-width: 36px;
}

.top-product-media img,
.top-product-placeholder {
  width: 88px;
  height: 88px;
  border-radius: 14px;
  object-fit: cover;
  display: block;
  background: rgba(36, 23, 50, 0.08);
}

.top-product-copy h4 {
  margin: 0 0 6px;
}

.top-product-copy p {
  margin: 0;
  color: var(--muted);
}

.top-product-actions {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 768px) {
  .main {
    padding: 18px;
  }

  .page-header,
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .settings-install {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-dialog {
    width: calc(100vw - 24px);
  }

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

  .top-product-actions {
    justify-content: flex-start;
  }
}
