/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e0e3e8;
  --primary: #0064d2;
  --primary-dark: #0053b3;
  --success: #27ae60;
  --warning: #e67e22;
  --danger: #e74c3c;
  --text: #1a1a2e;
  --text-soft: #5a6278;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ── Nav ── */
.nav {
  display: flex; align-items: center; gap: 12px;
  background: var(--primary); color: #fff;
  padding: 0 20px; height: 52px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.nav-brand { font-weight: 700; font-size: 16px; margin-right: 8px; white-space: nowrap; }
.nav-actions { display: flex; gap: 6px; align-items: center; }
.nav-tabs { display: flex; gap: 2px; flex: 1; }
.nav-tab {
  background: transparent; border: none; color: rgba(255,255,255,0.75);
  padding: 0 16px; height: 52px; cursor: pointer; font-size: 14px;
  border-bottom: 3px solid transparent; transition: all .15s;
}
.nav-tab:hover { color: #fff; }
.nav-tab.active { color: #fff; border-bottom-color: #fff; font-weight: 600; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius); border: none;
  cursor: pointer; font-size: 13px; font-weight: 500; transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-soft); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { background: var(--danger); color: #fff; }

/* ── Inputs ── */
.input {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; background: #fff; color: var(--text);
  outline: none; transition: border-color .15s;
}
.input:focus { border-color: var(--primary); }
.input-row { display: flex; gap: 6px; }
.input-row .input { flex: 1; }

/* ── Tab Content ── */
.tab-content { display: none; padding: 20px; }
.tab-content.active { display: block; }

/* ── Toolbar ── */
.toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; margin-bottom: 12px; flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-input { width: 260px; }

/* ── Stats Bar ── */
.stats-bar {
  display: flex; gap: 20px; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 12px;
  font-size: 13px; color: var(--text-soft); flex-wrap: wrap;
}
.stats-bar span strong { color: var(--text); }

/* ── Table ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
#inventory-table { width: 100%; border-collapse: collapse; }
#inventory-table th {
  background: #f8f9fb; padding: 10px 12px; text-align: left;
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-soft); border-bottom: 1px solid var(--border);
  cursor: pointer; white-space: nowrap; user-select: none;
}
#inventory-table th:hover { color: var(--primary); }
#inventory-table td { padding: 9px 12px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
#inventory-table tr:last-child td { border-bottom: none; }
#inventory-table tr:hover td { background: #fafbff; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.badge-listed { background: #e3f2fd; color: #1565c0; }
.badge-sold { background: #e8f5e9; color: #2e7d32; }
.badge-unlisted { background: #fafafa; color: #757575; border: 1px solid #e0e0e0; }

.profit-pos { color: var(--success); font-weight: 600; }
.profit-neg { color: var(--danger); font-weight: 600; }

.action-btns { display: flex; gap: 4px; }

/* ── Labels Tab ── */
.labels-layout { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h2 { font-size: 16px; margin-bottom: 16px; }
.card h3 { font-size: 14px; margin: 16px 0 10px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-soft); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.form-group .input { width: 100%; }

.size-toggle { display: flex; gap: 0; }
.size-btn {
  flex: 1; padding: 8px; border: 1px solid var(--border); background: #fff;
  cursor: pointer; font-size: 13px; transition: all .15s;
}
.size-btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.size-btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; border-left: none; }
.size-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.label-actions { display: flex; gap: 8px; margin-top: 4px; }

#label-queue-list { list-style: none; margin: 0; }
#label-queue-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 8px; border-radius: 4px; background: #f8f9fb;
  margin-bottom: 4px; font-size: 12px;
}
#label-queue-list li button { background: none; border: none; cursor: pointer; color: var(--danger); font-size: 14px; }

.label-preview-area h2 { font-size: 16px; margin-bottom: 16px; }

/* ── Label itself ── */
.label-card {
  background: #fff; border: 2px solid #333;
  display: inline-flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; gap: 6px;
  margin: 8px; box-shadow: 2px 2px 8px rgba(0,0,0,.12);
}
.label-card .label-sku { font-size: 28px; font-weight: 700; letter-spacing: 0; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
.label-card .label-name { font-size: 11px; font-weight: 500; line-height: 1.3; max-width: 90%; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
.label-card .label-size-text { font-size: 10px; color: #999; }

/* 4x6 inches at 96dpi */
.label-4x6 { width: 576px; height: 384px; padding: 20px; }
.label-4x6 .label-sku { font-size: 48px; }
.label-4x6 .label-name { font-size: 20px; max-width: 95%; }

/* 40x30mm at 96dpi ≈ 151x113px */
.label-40x30 { width: 151px; height: 113px; padding: 6px; }
.label-40x30 .label-sku { font-size: 20px; }
.label-40x30 .label-name { font-size: 9px; }

/* ── Stats Tab ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { text-align: center; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-soft); margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stats-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.simple-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.simple-table th { text-align: left; padding: 6px 8px; border-bottom: 2px solid var(--border); color: var(--text-soft); font-size: 11px; text-transform: uppercase; }
.simple-table td { padding: 6px 8px; border-bottom: 1px solid #f0f2f5; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--surface); border-radius: 10px; padding: 28px;
  width: 560px; max-width: 95vw; max-height: 90vh; overflow-y: auto;
  position: relative; box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-soft);
}
.modal-content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-content-grid .full { grid-column: 1 / -1; }
.modal-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-soft); margin: 14px 0 8px; grid-column: 1 / -1; border-top: 1px solid var(--border); padding-top: 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; grid-column: 1 / -1; }

/* ── New Listing Tab ── */
.listing-layout { display: grid; grid-template-columns: 420px 1fr; gap: 20px; align-items: start; }
.listing-form-col {}
.listing-output-col {}
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.auto-badge {
  display: inline-block; background: var(--primary); color: #fff;
  font-size: 9px; padding: 1px 5px; border-radius: 10px;
  vertical-align: middle; margin-left: 4px; font-weight: 600; letter-spacing: .04em;
}
.photo-drop {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center; cursor: pointer;
  transition: border-color .15s; background: #fafbff;
}
.photo-drop:hover { border-color: var(--primary); }
.photo-drop:hover span { color: var(--primary); }
#photo-drop-label span { color: var(--text-soft); font-size: 13px; }
.listing-generate-actions { display: flex; gap: 8px; margin-top: 4px; }
.api-key-field { display: flex; gap: 8px; }
.api-key-field .input { flex: 1; font-family: monospace; font-size: 12px; }

/* ── Thumbnail ── */
.item-thumb {
  width: 48px; height: 48px; object-fit: cover;
  border-radius: 4px; border: 1px solid var(--border);
  display: block;
}
.item-thumb-placeholder {
  width: 48px; height: 48px; border-radius: 4px;
  background: #f0f2f5; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #ccc;
}

/* ── Print Zone (hidden on screen) ── */
#label-print-zone { display: none; }

/* ── Print Styles ── */
@media print {
  @page { size: 40mm 30mm; margin: 0; }
  body > *:not(#label-print-zone) { display: none !important; }
  #label-print-zone {
    display: block !important;
    width: 40mm;
    height: 30mm;
  }
  #label-print-zone .label-card {
    box-shadow: none !important;
    border: 1px solid #000 !important;
    margin: 0 !important;
    width: 40mm !important;
    height: 30mm !important;
    padding: 2mm !important;
  }
  #label-print-zone .label-sku { font-size: 14pt !important; }
  #label-print-zone .label-name { font-size: 7pt !important; }
}

/* ── Utility ── */
.hidden { display: none !important; }
.text-soft { color: var(--text-soft); }
.mt-8 { margin-top: 8px; }
