:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #273549;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --ebay: #e53238;
  --mercari: #ff4f2c;
  --poshmark: #7c3aed;
  --facebook: #1877f2;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

/* ── Header ── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  flex: 1;
}

.btn-sync {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-sync:hover { background: var(--accent-hover); }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 2px;
  padding: 10px 16px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 8px 14px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.15s;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab:hover:not(.active) { color: var(--text); }

/* ── Search & Filters ── */
.toolbar {
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.search-wrap {
  position: relative;
  flex: 1;
}

.search-wrap input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px 8px 36px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap input::placeholder { color: var(--muted); }

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 15px;
  pointer-events: none;
}

select.filter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  outline: none;
}
select.filter:focus { border-color: var(--accent); }

/* ── Stats bar ── */
.stats-bar {
  display: flex;
  gap: 16px;
  padding: 0 16px 12px;
  font-size: 12px;
  color: var(--muted);
}
.stats-bar span { color: var(--text); font-weight: 600; }

/* ── Item Grid ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 0 16px 80px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--accent); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.card-name {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
}

.card-sku {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.card-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-type  { background: #1e3a5f; color: #60a5fa; }
.badge-size  { background: #1e3a2f; color: #4ade80; }
.badge-cond  { background: #2d1f3d; color: #c084fc; }
.badge-new   { background: #1a3a1a; color: #4ade80; }
.badge-used  { background: #3a1a1a; color: #f87171; }
.badge-like  { background: #1a2a3a; color: #60a5fa; }

.card-marketplaces {
  display: flex;
  gap: 5px;
  margin-bottom: 10px;
}

.mp-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
}
.mp-ebay     { background: var(--ebay);     color: white; }
.mp-mercari  { background: var(--mercari);  color: white; }
.mp-poshmark { background: var(--poshmark); color: white; }
.mp-facebook { background: var(--facebook); color: white; }

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-qty {
  font-size: 12px;
  color: var(--muted);
}
.card-qty span { color: var(--text); font-weight: 600; }

.card-location {
  font-size: 11px;
  color: var(--muted);
}

.card-actions {
  display: flex;
  gap: 6px;
}

.btn-icon {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 5px 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.btn-icon:hover { color: var(--text); border-color: var(--muted); }
.btn-icon.delete:hover { color: var(--red); border-color: var(--red); }

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: 24px;
  right: 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(99,102,241,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.fab:hover { background: var(--accent-hover); }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 { font-size: 16px; font-weight: 600; }

.modal-body { padding: 20px; }

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Form ── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

textarea { resize: vertical; min-height: 70px; }

.form-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 16px 0 8px;
}

.checkbox-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.checkbox-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* ── Buttons ── */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--muted); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Sync Modal ── */
.sync-modal input[type="email"],
.sync-modal input[type="number"] {
  margin-bottom: 12px;
}

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  grid-column: 1 / -1;
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty p { font-size: 15px; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: 13px;
  z-index: 999;
  opacity: 0;
  transition: all 0.25s;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red); }

/* ── Loading ── */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  grid-column: 1 / -1;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  header h1 { font-size: 17px; }
}
