:root {
  --bg: #000000;
  --panel: #111111;
  --panel-strong: #1a1a1a;
  --line: rgba(255, 255, 255, 0.1);
  --text: #ffffff;
  --muted: #888888;
  --accent: #ffffff;
  --accent-dim: rgba(255, 255, 255, 0.1);
  --warn: #ffb020;
  --danger: #ff5f56;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
}

a {
  color: var(--text);
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 32px 24px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 40%);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.sidebar h1,
.topbar h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 0.95;
}

.sidebar-copy,
.muted {
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 8px;
}

.nav a,
.action-button {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  transition: 180ms ease;
}

.nav a:hover,
.action-button:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--accent-dim);
}

.main-content {
  padding: 28px;
  min-width: 0;
  overflow-x: clip;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

.panel,
.sync-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  backdrop-filter: blur(12px);
}

.stats-grid,
.product-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

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

.stat-card span,
.metric-grid span,
.sync-metrics span,
.variant-row span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.stat-card strong,
.metric-grid strong {
  font-size: 1.8rem;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.filter-bar label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

input,
select,
.action-button {
  color: var(--text);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

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

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

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

.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  border-radius: 999px;
  padding: 6px 10px;
  font-family: "IBM Plex Mono", monospace;
}

.score-good {
  color: #aaaaaa;
  background: rgba(255, 255, 255, 0.08);
}

.score-warn {
  color: var(--warn);
  background: rgba(255, 176, 32, 0.12);
}

.score-critical {
  color: var(--danger);
  background: rgba(255, 95, 86, 0.12);
}

.sync-row,
.sync-metrics,
.variant-row,
.metric-grid {
  display: grid;
  gap: 14px;
}

.sync-row {
  grid-template-columns: 1fr auto;
  margin-bottom: 14px;
}

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

.heatmap-wrap {
  overflow: auto;
  position: relative;
}

.heatmap-header,
.heatmap-row {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 12px;
  min-width: max-content;
  margin-bottom: 8px;
}

.heatmap-product,
.sticky-title {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--panel);
  padding: 10px 12px;
  border-radius: 12px;
  box-shadow: 4px 0 12px rgba(0,0,0,0.5);
}

.heatmap-product span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.heatmap-cells {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 16px;
  gap: 3px;
}

.heatmap-header-cell,
.heat-cell {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}

.heatmap-header-cell {
  width: auto;
  font-size: 0.72rem;
  color: var(--muted);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  min-height: 58px;
}

.lvl-0 { background: #1a1a1a; }
.lvl-1 { background: rgba(255,255,255,0.15); }
.lvl-2 { background: rgba(255,255,255,0.35); }
.lvl-3 { background: rgba(255,255,255,0.6); }
.lvl-4 { background: rgba(255,255,255,0.9); }

.gap-cell {
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(255, 95, 86, 0.85),
      rgba(255, 95, 86, 0.85) 3px,
      rgba(255, 95, 86, 0.18) 3px,
      rgba(255, 95, 86, 0.18) 6px
    );
}

.chart-scroll {
  overflow-x: auto;
}

.sales-chart {
  width: 100%;
  min-height: 220px;
  fill: var(--accent);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
    rgba(255, 255, 255, 0.015);
  border-radius: 16px;
}

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

.variant-row {
  grid-template-columns: 1fr auto;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.error-text {
  color: var(--danger);
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stats-grid,
  .filter-bar,
  .product-layout {
    grid-template-columns: 1fr;
  }
}

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

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

  th,
  td {
    padding: 12px 8px;
    font-size: 0.9rem;
  }
}

/* Colour variant tags */
.colour-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.colour-tag {
  font-size: 0.68rem;
  font-family: var(--font-mono, monospace);
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 1px 6px;
  color: #aaa;
  white-space: nowrap;
}

.chart-bar { cursor: crosshair; transition: opacity 0.1s; }

/* Reorder page */
.reorder-row.recently-ordered td { opacity: 0.55; }
.reorder-row td { vertical-align: middle; }

/* Heatmap sticky column layout */
.heatmap-sticky-col .heatmap-product {
  padding: 4px 12px;
  background: var(--panel);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.heatmap-sticky-col .heatmap-product a { color: var(--text); }
#heatmap-scroll .heatmap-row {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  display: flex;
  align-items: center;
}
#heatmap-scroll .heatmap-header {
  display: flex;
  align-items: center;
}
/* heat-cell dimensions now inline */

/* Heatmap dark backgrounds - critical */
#heatmap-scroll,
#heatmap-names,
.hm-cell-row,
.hm-name-row {
  background: #0d0d0d !important;
}
.heatmap-panel {
  background: #0d0d0d !important;
}
