/* ── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f0f0f;
  --surface:   #1a1a1a;
  --surface2:  #242424;
  --border:    #2e2e2e;
  --text:      #f0f0f0;
  --muted:     #888;
  --accent:    #6366f1;   /* indigo */
  --green:     #22c55e;
  --yellow:    #eab308;
  --red:       #ef4444;
  --radius:    12px;
  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: 80px;   /* space for FAB */
}

/* ── Header ──────────────────────────────────────────────────────── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; }
.header-sub { font-size: 0.75rem; color: var(--muted); }
.user-badge {
  font-size: 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
  color: var(--muted);
}

/* ── Stats Bar ───────────────────────────────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.stat {
  background: var(--surface);
  padding: 12px 8px;
  text-align: center;
}
.stat-value { font-size: 1.1rem; font-weight: 700; }
.stat-label { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }
.stat-value.green  { color: var(--green); }
.stat-value.yellow { color: var(--yellow); }
.stat-value.accent { color: var(--accent); }

/* ── Tabs ────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  padding: 12px 16px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 8px 8px 0 0;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab:hover:not(.active) { color: var(--text); }

/* ── Item Grid ───────────────────────────────────────────────────── */
.item-grid {
  padding: 12px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.item-card:hover { border-color: var(--accent); transform: translateY(-1px); }

.item-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 2rem;
}
.item-thumb img { width: 100%; height: 100%; object-fit: cover; }

.item-body { padding: 10px; }
.item-title {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-prices { display: flex; justify-content: space-between; font-size: 0.75rem; }
.item-price  { color: var(--text); font-weight: 600; }
.item-cost   { color: var(--muted); }

.status-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 4px;
  margin-top: 6px;
}
.status-draft   { background: #2e2e2e; color: var(--muted); }
.status-listed  { background: #1e3a5f; color: #60a5fa; }
.status-sold    { background: #14532d; color: var(--green); }
.status-pulled  { background: #3f1f1f; color: var(--red); }

/* ── Empty State ─────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty p { font-size: 0.9rem; }

/* ── FAB ─────────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.6rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(99,102,241,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none;
  z-index: 20;
}
.fab:hover { transform: scale(1.07); box-shadow: 0 6px 24px rgba(99,102,241,0.65); }

/* ── Form Page ───────────────────────────────────────────────────── */
.page { max-width: 540px; margin: 0 auto; padding: 16px; }

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 12px;
  font-weight: 600;
}

/* Photo upload zone */
.photo-zone {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}
.photo-slot {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px dashed var(--border);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  font-size: 1.4rem;
  color: var(--muted);
  transition: border-color 0.15s;
}
.photo-slot:hover { border-color: var(--accent); }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.photo-slot .remove-btn {
  position: absolute;
  top: 2px; right: 2px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px; height: 20px;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.photo-hint { font-size: 0.72rem; color: var(--muted); }

/* Form inputs */
label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
input[type=text], input[type=number], select, textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select option { background: var(--surface2); }
textarea { resize: vertical; min-height: 70px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { margin-bottom: 12px; }

/* Platforms checkboxes */
.platform-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.platform-check {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color 0.15s;
}
.platform-check input { width: auto; }
.platform-check:has(input:checked) { border-color: var(--accent); background: #1e1f3a; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.98); }
.btn-primary   { background: var(--accent); color: #fff; width: 100%; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger    { background: #3f1f1f; color: var(--red); border: 1px solid #6b2222; }
.btn-success   { background: #14532d; color: var(--green); border: 1px solid #166534; }

.btn-row { display: flex; gap: 10px; }

/* Item Detail */
.detail-photos { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; }
.detail-photo { flex-shrink: 0; width: 100px; height: 100px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); }
.detail-photo.placeholder { background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 2rem; color: var(--muted); }

.detail-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--muted); font-size: 0.8rem; }
.detail-value { font-weight: 500; }
.profit-value { font-size: 1.1rem; font-weight: 700; color: var(--green); }

/* Status select row */
.status-row { display: flex; gap: 8px; flex-wrap: wrap; }
.status-btn {
  flex: 1;
  min-width: 80px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.status-btn.active-draft   { background: #2e2e2e;  color: var(--text);   border-color: #555; }
.status-btn.active-listed  { background: #1e3a5f;  color: #60a5fa;       border-color: #2563eb; }
.status-btn.active-sold    { background: #14532d;  color: var(--green);  border-color: var(--green); }
.status-btn.active-pulled  { background: #3f1f1f;  color: var(--red);    border-color: var(--red); }

/* Sale price input (shown when marking sold) */
#sale-price-row { display: none; }

/* Toast */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 0.85rem;
  opacity: 0;
  transition: all 0.25s;
  z-index: 100;
  pointer-events: none;
  white-space: nowrap;
}
.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); }

/* Spinner */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Back button */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 0.85rem; text-decoration: none;
  padding: 6px 0; margin-bottom: 4px;
}
.back-btn:hover { color: var(--text); }
