:root {
  /* Local mirror of app.css tokens (evergreens.html does not load app.css) */
  --bg: #0B0B0D;
  --surface: #1C1C1E;
  --surface-2: #2C2C2E;
  --border: color-mix(in srgb, #FFFFFF 12%, transparent);
  --text: #FFFFFF;
  --muted: #A1A1A6;
  --logo-lav: #B8B0F0;
  --logo-white: #F8F8F8;
  --accent: var(--logo-lav);
  --accent-ink: #14121A;
  --success: #30D158;
  --warning: #FF9F0A;
  --danger: #FF453A;
  --ok: var(--success);
  --warn: var(--warning);
  --err: var(--danger);
  --green: var(--success);
  --ready: #6ea8fe;
  --radius-button: 16px;
  --radius-pill: 999px;
  --shadow-sm:
    0 1px 2px color-mix(in srgb, #000 35%, transparent),
    0 2px 6px color-mix(in srgb, #000 22%, transparent);
  --glass-highlight:
    inset 0 1px 0 color-mix(in srgb, #FFFFFF 16%, transparent);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
}

a { color: var(--ready); }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 32px);
}

header.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

header.top h1 {
  margin: 0 0 4px;
  font-size: 1.25rem;
  font-weight: 700;
}

header.top .sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 36rem;
}

header.top .sub code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  color: var(--text);
}

.back-wrap { margin: 0 0 6px; }

.back {
  color: var(--muted);
  text-decoration: none;
  font: 600 13px/1 system-ui, sans-serif;
}

.back:hover { color: var(--text); }

.mode {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  font: 600 13px/1 system-ui, sans-serif;
  white-space: nowrap;
}

.mode::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  background: currentColor;
}

.mode.is-live {
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 40%, transparent);
  background: color-mix(in srgb, var(--green) 14%, transparent);
}

.mode.is-live::before {
  background: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 14%, transparent);
}

.mode.is-mock {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
}

.mode.is-mock::before {
  background: var(--warn);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 14%, transparent);
}

.mode.is-auth-err {
  color: var(--err);
  border-color: color-mix(in srgb, var(--err) 40%, transparent);
  background: color-mix(in srgb, var(--err) 14%, transparent);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 650;
}

.hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.conn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.conn-row input {
  flex: 1 1 160px;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: 15px/1.3 system-ui, sans-serif;
}

.conn-status {
  margin: 10px 0 0;
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--muted);
}

.conn-status.is-ok { color: var(--ok); }
.conn-status.is-err { color: var(--err); }

button {
  font: 600 14px/1 system-ui, sans-serif;
  padding: 12px 16px;
  min-height: 44px;
  border-radius: var(--radius-button);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.primary {
  background: color-mix(in srgb, var(--logo-lav) 88%, var(--logo-white));
  color: var(--accent-ink);
  border: 1px solid color-mix(in srgb, #FFF 18%, transparent);
  box-shadow: var(--glass-highlight), var(--shadow-sm);
}

button.primary:hover { filter: brightness(1.06); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
}

.toolbar input[type="search"] {
  flex: 1 1 180px;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: 15px/1.3 system-ui, sans-serif;
}

.toolbar button {
  flex: 0 0 auto;
}

.status-line {
  margin: 0 0 8px;
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--muted);
}

.status-line.is-err { color: var(--err); }
.status-line.is-ok { color: var(--ok); }

.trunc-warn {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  color: var(--warn);
  font-size: 0.85rem;
}

.trunc-warn[hidden] { display: none !important; }

.product-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.product-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.product-thumb {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.product-thumb.is-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font: 700 12px/1 system-ui, sans-serif;
}

.product-main { min-width: 0; }

.product-title {
  margin: 0 0 4px;
  font: 650 14px/1.3 system-ui, sans-serif;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-sub {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex: none;
}

.bin-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text);
}

.bin-badge.is-unmapped {
  color: var(--muted);
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid color-mix(in srgb, var(--err) 75%, transparent);
}

/* T shelf = pink, B shelf = purple */
.bin-badge.is-t {
  color: #2a1024;
  border-color: color-mix(in srgb, #F088D8 45%, transparent);
  background: color-mix(in srgb, #F088D8 78%, #fff);
}

.bin-badge.is-b {
  color: #14102a;
  border-color: color-mix(in srgb, #7878B8 45%, transparent);
  background: color-mix(in srgb, #7878B8 78%, #fff);
}

/* Evergreen = green, Supplies TOOL = yellow */
.bin-badge.is-ev {
  color: #0b1a0f;
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
  background: color-mix(in srgb, var(--ok) 78%, #fff);
}

.bin-badge.is-tool {
  color: #1a1400;
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  background: color-mix(in srgb, var(--warn) 82%, #fff);
}

.row-apply {
  font: 650 12px/1 system-ui, sans-serif;
  padding: 8px 12px;
  min-height: 36px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--logo-lav) 35%, transparent);
  background: color-mix(in srgb, var(--logo-lav) 18%, transparent);
  color: var(--logo-lav);
  cursor: pointer;
  white-space: nowrap;
}

.row-apply:hover:not(:disabled) {
  filter: brightness(1.08);
}

.row-apply:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--muted);
}

.shopify-link {
  font: 600 12px/1 system-ui, sans-serif;
  color: var(--ready);
  text-decoration: none;
}

.shopify-link:hover { text-decoration: underline; }

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
}

.empty-state[hidden] { display: none !important; }

.empty-title {
  margin: 0 0 8px;
  font: 650 1rem/1.3 system-ui, sans-serif;
  color: var(--text);
}

.empty-sub {
  margin: 0;
  font-size: 0.9rem;
}

.empty-sub code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text);
}

@media (prefers-reduced-motion: reduce) {
  .mode.is-live::before,
  .mode.is-mock::before {
    box-shadow: none;
  }
}
