/* ═════════════════════════════════════════════════════
   EBH WMS · Estilos
   Paleta: sand / clay / ash (consistente com brand EBH)
   ═════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Syne:wght@500;600;700;800&display=swap');

:root {
  --sand: #F5F0E8;
  --cream: #FAF7F2;
  --clay: #C4956A;
  --clay-dark: #A07548;
  --clay-light: #E8D4BC;
  --ash: #2D2A26;
  --ash-mid: #6B6560;
  --ash-light: #B5B0A8;
  --white: #FFFFFF;
  --green: #5A7A5C;
  --green-light: #EBF0EB;
  --red: #8B3A3A;
  --red-light: #F5EDED;
  --yellow: #B58B3A;
  --yellow-light: #F5EFD9;
  --border: #E5DED4;
  --border-strong: #D4CCC0;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  font-family: 'Syne', system-ui, sans-serif;
  background: var(--sand);
  color: var(--ash);
  min-height: 100vh;
}

body {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 40px;
  position: relative;
}

/* ═════════ LOGIN ═════════ */
.login-body {
  background: var(--ash);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-container {
  background: var(--cream);
  border-radius: 24px;
  padding: 40px 28px 32px;
  width: 100%;
  max-width: 380px;
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  font-size: 38px;
  font-weight: 800;
  color: var(--ash);
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.login-tagline {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ash-mid);
  font-weight: 600;
}

.login-form .field-group { margin-bottom: 16px; }

.login-error {
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
  color: var(--red);
  font-weight: 600;
  min-height: 18px;
}

/* ═════════ HEADER ═════════ */
.header {
  background: var(--ash);
  color: var(--cream);
  padding: 18px 20px 14px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.header-logo {
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--ash-light);
  font-weight: 700;
}

.header-user {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--ash-light);
  text-transform: lowercase;
}

.header-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

/* ═════════ TABS ═════════ */
.tabs {
  display: flex;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 86px;
  z-index: 90;
}

.tab {
  flex: 1;
  padding: 14px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--ash-light);
  cursor: pointer;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  transition: all 0.2s;
}

.tab.active {
  color: var(--ash);
  border-bottom-color: var(--clay);
}

/* ═════════ PAGES ═════════ */
.page { display: none; padding: 20px; }
.page.active { display: block; }

/* ═════════ STEP CARDS ═════════ */
.step-card {
  background: var(--white);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ash);
  color: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.step-num-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 10px;
}

.step-num-inline {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--clay);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.step-label,
.step-label-inline {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ash-mid);
}

/* ═════════ INPUTS ═════════ */
.field-group { margin-bottom: 14px; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-row .field-group { margin-bottom: 0; }

.field-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ash-mid);
  margin-bottom: 6px;
  display: block;
}

.field-input {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  background: var(--cream);
  color: var(--ash);
  outline: none;
  transition: border-color 0.2s;
}

.field-input:focus { border-color: var(--clay); }
.field-input::placeholder { color: var(--ash-light); font-family: 'Syne', sans-serif; }

.field-input.number-big {
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 1px;
}

.scan-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.scan-row .field-input { flex: 1; }

.btn-scan {
  background: var(--clay);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 0 18px;
  font-size: 22px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.btn-scan:active { background: var(--clay-dark); transform: scale(0.96); }

.hint {
  font-size: 11px;
  color: var(--ash-mid);
  margin-top: 4px;
  font-style: italic;
}

/* ═════════ BUTTONS ═════════ */
.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary { background: var(--ash); color: var(--cream); }
.btn-primary:active { background: #444; transform: scale(0.98); }

.btn-ghost {
  background: transparent;
  color: var(--ash);
  border: 1.5px solid var(--border-strong);
}

.btn-pill {
  width: auto;
  padding: 6px 14px;
  border: none;
  border-radius: 100px;
  font-family: 'Syne', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
}

.btn-pill.btn-clay { background: var(--clay); color: white; }
.btn-pill.btn-ghost { background: transparent; border: 1.5px solid var(--border-strong); color: var(--ash); }

.form-actions {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
  margin-top: 18px;
}

/* ═════════ TIER TOGGLE ═════════ */
.tier-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tier-btn {
  padding: 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  background: var(--cream);
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: all 0.15s;
}

.tier-btn strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--ash);
}

.tier-btn small {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ash-mid);
}

.tier-btn.active {
  background: var(--ash);
  border-color: var(--ash);
}

.tier-btn.active strong { color: var(--cream); }
.tier-btn.active small { color: var(--ash-light); }

/* ═════════ PRODUCT CARD ═════════ */
.product-card {
  background: var(--ash);
  color: var(--cream);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.product-card::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 120px; height: 120px;
  border-radius: 50%;
  border: 2px solid rgba(196,149,106,0.25);
}

.product-card-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ash-light);
  margin-bottom: 6px;
}

.product-card-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.product-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-pill {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 4px 10px;
  border-radius: 100px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--cream);
}

/* ═════════ LOCATIONS LIST ═════════ */
.locations-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
}

.locations-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.locations-header h3 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ash-mid);
}

.location-row {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.location-row:last-child { margin-bottom: 0; }

.loc-tier-badge {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.loc-tier-badge.tier-0 {
  background: var(--clay);
  color: white;
}

.loc-tier-badge.tier-1 {
  background: var(--ash-light);
  color: var(--ash);
}

.loc-info { flex: 1; min-width: 0; }

.loc-code {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--ash);
  margin-bottom: 2px;
}

.loc-meta {
  font-size: 11px;
  color: var(--ash-mid);
}

.loc-qty {
  font-size: 18px;
  font-weight: 800;
  color: var(--ash);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.loc-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.loc-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--white);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loc-btn:active { transform: scale(0.9); }
.loc-btn.delete { background: var(--red-light); border-color: transparent; color: var(--red); }

/* ═════════ ADD LOCATION FORM ═════════ */
.add-loc-form {
  background: var(--white);
  border: 1.5px dashed var(--clay);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
}

.add-loc-form h4 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--clay-dark);
  margin-bottom: 4px;
}

/* ═════════ INVENTORY ═════════ */
.inv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.inv-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--ash);
}

.inv-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.inv-item:active { border-color: var(--clay); }

.inv-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.inv-item-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ash);
  flex: 1;
  min-width: 0;
  padding-right: 10px;
}

.inv-item-qty {
  font-size: 22px;
  font-weight: 800;
  color: var(--ash);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.inv-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ash-mid);
}

.inv-item-sku {
  font-family: 'DM Mono', monospace;
}

.inv-item-locs {
  display: flex;
  gap: 4px;
  align-items: center;
}

.qty-diff-warning {
  background: var(--yellow-light);
  color: var(--yellow);
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.5px;
}

.qty-diff-ok {
  color: var(--green);
  font-weight: 700;
}

/* ═════════ EMPTY STATE ═════════ */
.empty-state {
  text-align: center;
  padding: 32px 20px;
  color: var(--ash-light);
}
.empty-state .emoji { font-size: 36px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ═════════ SCANNER MODAL ═════════ */
.scanner-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: black;
  z-index: 1000;
  flex-direction: column;
}

.scanner-modal.open { display: flex; }

.scanner-header {
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
}

.scanner-close {
  background: rgba(255,255,255,0.15);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: white;
  font-size: 14px;
  cursor: pointer;
}

#scannerVideo {
  flex: 1;
  width: 100%;
  object-fit: cover;
  background: black;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scanner-frame {
  width: 80%;
  max-width: 320px;
  height: 160px;
  border: 3px solid var(--clay);
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.4);
}

.scanner-hint {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 10px 18px;
  border-radius: 100px;
  font-size: 13px;
}

/* ═════════ TOAST ═════════ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--ash);
  color: var(--cream);
  padding: 12px 22px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 1100;
  max-width: 90vw;
  text-align: center;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

/* ═════════ LOGOUT ═════════ */
.logout-btn {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(45,42,38,0.85);
  color: var(--cream);
  border: none;
  cursor: pointer;
  font-size: 14px;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.logout-btn:active { transform: scale(0.9); }

/* ═════════ SPINNER ═════════ */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: none;
}

.btn.loading .spinner { display: block; }
.btn.loading .btn-text { display: none; }
.btn-primary .spinner { border-top-color: var(--cream); }

@keyframes spin { to { transform: rotate(360deg); } }
