:root {
  --cream: #f8f7f3;
  --cream-deep: #efece4;
  --ink: #0a0a0a;
  --muted: #5c5a55;
  --line: #0a0a0a1a;
  --accent: #e85d04;
  --lime: #d6ff4a;
  --violet: #7c3aed;
  --danger: #d92d20;
  --warn: #e85d04;
  --ok: #0f7a4a;
  --card: #fff;
  --radius: 24px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: Geist, "Geist Fallback", ui-sans-serif, system-ui, sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

.hidden { display: none !important; }

/* —— Login —— */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(circle at 15% 20%, rgba(232, 93, 4, 0.12), transparent 40%),
    radial-gradient(circle at 85% 70%, rgba(124, 58, 237, 0.1), transparent 40%),
    var(--cream);
}
.login-card {
  width: min(420px, 100%);
  background: var(--ink);
  color: var(--cream);
  border-radius: 36px;
  padding: 2.5rem;
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: "";
  position: absolute;
  inset: -40%;
  background:
    radial-gradient(circle at 20% 30%, rgba(232, 93, 4, 0.5), transparent 35%),
    radial-gradient(circle at 80% 40%, rgba(124, 58, 237, 0.45), transparent 35%);
  filter: blur(40px);
}
.login-card > * { position: relative; z-index: 1; }
.login-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  margin-bottom: 1.5rem;
}
.login-brand img { height: 28px; width: auto; filter: invert(1) brightness(1.1); }
.login-card h1 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.15;
  margin-bottom: 0.5rem;
}
.login-card p { color: rgba(248, 247, 243, 0.65); font-size: 0.95rem; margin-bottom: 1.5rem; }
.login-card input {
  width: 100%;
  background: rgba(248, 247, 243, 0.08);
  border: 1px solid rgba(248, 247, 243, 0.15);
  border-radius: 999px;
  padding: 0.85rem 1.25rem;
  margin-bottom: 0.75rem;
}
.login-card input:focus { outline: 2px solid var(--lime); outline-offset: 2px; }
.login-error { color: #ff8a7a; font-size: 0.85rem; margin-bottom: 0.75rem; min-height: 1.2em; }

/* —— Shell —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 3vw, 2rem);
  background: rgba(248, 247, 243, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
}
.brand img { height: 26px; }
.topbar-meta {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.topbar-meta::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.topbar-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.88rem;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--card);
  transition: transform 0.15s, background 0.15s;
}
.pill:hover { transform: translateY(-1px); }
.pill-dark { background: var(--ink); color: var(--cream); border-color: var(--ink); }
.pill-lime { background: var(--lime); border-color: transparent; color: var(--ink); font-weight: 600; }
.pill-ghost { background: transparent; }

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 3vw, 2rem) 4rem;
}

.nav-tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
  padding: 0.35rem;
  background: var(--cream-deep);
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
}
.nav-tabs button {
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}
.nav-tabs button.active {
  background: var(--ink);
  color: var(--cream);
}

.page-head { margin-bottom: 1.5rem; }
.badge {
  font-family: ui-monospace, "Geist Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
}
.badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.page-head h1 {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.1;
}
.page-head h1 .hl {
  background: linear-gradient(transparent 62%, var(--lime) 62%, var(--lime) 92%, transparent 92%);
  padding: 0 0.05em;
}
.page-head p { color: var(--muted); margin-top: 0.5rem; max-width: 640px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.25rem;
}
.toolbar input[type="search"],
.toolbar select,
.field input,
.field select,
.field textarea {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.65rem 1rem;
}
.toolbar input[type="search"] { min-width: min(280px, 100%); flex: 1; }
.field textarea { border-radius: var(--radius-sm); min-height: 80px; width: 100%; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}

/* —— Cards / grid —— */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.cat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  text-align: left;
  transition: transform 0.2s, box-shadow 0.2s;
}
.cat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 36px rgba(10, 10, 10, 0.07);
}
.cat-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
  line-height: 1.25;
}
.cat-stats {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
}
.stat-chip {
  background: var(--cream-deep);
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
}
.stat-chip.danger { background: rgba(217, 45, 32, 0.12); color: var(--danger); }
.stat-chip.warn { background: rgba(232, 93, 4, 0.12); color: var(--warn); }
.stat-chip.ok { background: rgba(15, 122, 74, 0.1); color: var(--ok); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
}

.dark-card {
  background: var(--ink);
  color: var(--cream);
  border-radius: var(--radius);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}
.dark-card::before {
  content: "";
  position: absolute;
  inset: -30%;
  background:
    radial-gradient(circle at 80% 20%, rgba(232, 93, 4, 0.45), transparent 35%),
    radial-gradient(circle at 20% 90%, rgba(124, 58, 237, 0.4), transparent 35%);
  filter: blur(30px);
}
.dark-card > * { position: relative; }

/* —— Table —— */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data th,
table.data td {
  text-align: left;
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data th {
  font-family: ui-monospace, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}
table.data tbody tr:hover { background: rgba(10, 10, 10, 0.03); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .title-cell {
  white-space: normal;
  max-width: 280px;
  font-weight: 500;
}

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
}
.status.ok { background: rgba(15, 122, 74, 0.12); color: var(--ok); }
.status.warn { background: rgba(232, 93, 4, 0.14); color: var(--warn); }
.status.danger { background: rgba(217, 45, 32, 0.12); color: var(--danger); }
.status.noshopify { background: var(--cream-deep); color: var(--muted); }

/* —— Detail —— */
.detail-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1rem;
}
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .topbar-meta { display: none; }
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.kpi {
  background: var(--cream-deep);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
}
.kpi .lbl {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}
.kpi .val {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-top: 0.25rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
  margin: 1rem 0;
}

.callout {
  margin-top: 1rem;
  padding: 1rem 1.2rem;
  border-radius: var(--radius-sm);
  background: var(--cream-deep);
  color: var(--muted);
  font-size: 0.92rem;
}
.callout strong { color: var(--ink); }

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  background: var(--card);
  transition: border-color 0.2s, background 0.2s;
}
.dropzone.drag { border-color: var(--accent); background: rgba(232, 93, 4, 0.06); }
.dropzone h3 { color: var(--ink); margin-bottom: 0.35rem; }

.comp-list { display: grid; gap: 0.75rem; }
.comp-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: start;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
}
.comp-item h4 { font-size: 1rem; margin-bottom: 0.25rem; }
.comp-meta { font-size: 0.85rem; color: var(--muted); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.back-link:hover { color: var(--ink); }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, monospace; font-size: 0.85rem; }

.empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
