* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --black: #1a1a1a;
  --white: #ffffff;
  --gray-light: #f5f5f5;
  --gray: #e0e0e0;
  --gray-dark: #888;
  --green: #25D366;
  --green-dark: #128C7E;
  --blue: #4A90D9;
  --gold: #C9A96E;
  --red: #e74c3c;
  --pix-green: #00BDAE;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-light);
  color: var(--black);
  font-size: 16px;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  overflow-x: hidden;
}

/* === SCREENS === */
.screen { display: none; min-height: 100vh; padding: 16px; }
.screen.active { display: flex; flex-direction: column; }

/* === LOGIN === */
#screen-login {
  background: var(--black);
  color: var(--white);
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.login-logo { font-size: 28px; font-weight: 700; letter-spacing: 2px; text-align: center; }
.login-sub { color: var(--gold); font-size: 14px; letter-spacing: 4px; text-transform: uppercase; }

.pin-display {
  display: flex; gap: 12px; margin: 16px 0;
}
.pin-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--gold);
  transition: background 0.2s;
}
.pin-dot.filled { background: var(--gold); }

.pin-pad {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; max-width: 280px; width: 100%;
}
.pin-btn {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  color: var(--white); font-size: 24px; font-weight: 600;
  padding: 18px; border-radius: 12px; cursor: pointer;
  transition: all 0.15s; -webkit-tap-highlight-color: transparent;
}
.pin-btn:active { background: var(--gold); color: var(--black); transform: scale(0.95); }
.pin-btn.special { font-size: 16px; }
.pin-error { color: var(--red); font-size: 14px; min-height: 20px; }

/* === HEADER === */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--gray);
  margin-bottom: 12px; position: sticky; top: 0;
  background: var(--gray-light); z-index: 10;
}
.header-title { font-size: 18px; font-weight: 700; }
.header-seller { font-size: 12px; color: var(--gold); font-weight: 600; }
.header-btn {
  background: none; border: none; font-size: 24px; cursor: pointer;
  padding: 8px; -webkit-tap-highlight-color: transparent;
}

/* === SEARCH === */
.search-bar {
  width: 100%; padding: 14px 16px; border: 2px solid var(--gray);
  border-radius: 12px; font-size: 16px; background: var(--white);
  margin-bottom: 12px;
}
.search-bar:focus { outline: none; border-color: var(--gold); }

/* === PRODUCT GRID === */
.product-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 12px; padding-bottom: 80px;
}

.product-card {
  background: var(--white); border-radius: 12px;
  overflow: hidden; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.15s; -webkit-tap-highlight-color: transparent;
}
.product-card:active { transform: scale(0.97); }

.product-card img {
  width: 100%; height: 180px; object-fit: cover;
}
.product-card-info { padding: 10px; }
.product-card-name { font-size: 13px; font-weight: 600; line-height: 1.3; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-card-price { font-size: 16px; font-weight: 700; color: var(--green-dark); }

/* === PRODUCT DETAIL === */
#screen-product { background: var(--white); }

.product-image-large {
  width: 100%; height: 300px; object-fit: cover;
  border-radius: 12px; margin-bottom: 16px;
}
.product-name { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.product-price-large { font-size: 24px; font-weight: 700; color: var(--green-dark); margin-bottom: 16px; }

.attr-section { margin-bottom: 16px; }
.attr-label { font-size: 14px; font-weight: 600; margin-bottom: 8px; color: var(--gray-dark); text-transform: uppercase; letter-spacing: 1px; }

.attr-options { display: flex; flex-wrap: wrap; gap: 8px; }
.attr-btn {
  padding: 12px 20px; border: 2px solid var(--gray);
  border-radius: 10px; font-size: 15px; font-weight: 600;
  cursor: pointer; background: var(--white);
  transition: all 0.15s; -webkit-tap-highlight-color: transparent;
  min-width: 52px; text-align: center;
}
.attr-btn.selected { border-color: var(--black); background: var(--black); color: var(--white); }
.attr-btn.out-of-stock { opacity: 0.3; text-decoration: line-through; pointer-events: none; }

/* === CUSTOM PRICE === */
.price-edit-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
}
.price-input {
  width: 140px; padding: 12px; border: 2px solid var(--gold);
  border-radius: 10px; font-size: 20px; font-weight: 700;
  text-align: center; color: var(--green-dark);
}
.price-input:focus { outline: none; border-color: var(--green-dark); }
.price-label { font-size: 13px; color: var(--gray-dark); }

.qty-row { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.qty-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--black);
  font-size: 22px; font-weight: 700; cursor: pointer; background: var(--white);
  display: flex; align-items: center; justify-content: center;
}
.qty-btn:active { background: var(--black); color: var(--white); }
.qty-value { font-size: 22px; font-weight: 700; min-width: 30px; text-align: center; }

/* === CART === */
.cart-fab {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--black); color: var(--white); border: none;
  padding: 16px 32px; border-radius: 50px; font-size: 16px; font-weight: 700;
  cursor: pointer; z-index: 100; box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 32px); width: 100%; justify-content: center;
}
.cart-fab:active { transform: translateX(-50%) scale(0.97); }
.cart-badge {
  background: var(--gold); color: var(--black); width: 24px; height: 24px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}

.add-to-cart-btn {
  width: 100%; padding: 18px; background: var(--black); color: var(--white);
  border: none; border-radius: 14px; font-size: 18px; font-weight: 700;
  cursor: pointer; margin-top: 12px;
}
.add-to-cart-btn:active { background: var(--gold); color: var(--black); }

/* === CART SCREEN === */
.cart-item {
  display: flex; gap: 12px; padding: 12px; background: var(--white);
  border-radius: 12px; margin-bottom: 8px; align-items: center;
}
.cart-item img { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; }
.cart-item-info { flex: 1; }
.cart-item-name { font-size: 14px; font-weight: 600; }
.cart-item-detail { font-size: 12px; color: var(--gray-dark); }
.cart-item-price { font-size: 16px; font-weight: 700; color: var(--green-dark); }
.cart-item-remove { background: none; border: none; font-size: 20px; color: var(--red); cursor: pointer; padding: 8px; }

.cart-total {
  background: var(--white); border-radius: 12px; padding: 16px;
  margin: 12px 0; display: flex; justify-content: space-between; align-items: center;
}
.cart-total-label { font-size: 18px; font-weight: 600; }
.cart-total-value { font-size: 24px; font-weight: 700; color: var(--green-dark); }

/* === PAYMENT === */
.payment-option {
  background: var(--white); border: 3px solid var(--gray);
  border-radius: 16px; padding: 20px; margin-bottom: 12px;
  cursor: pointer; transition: all 0.2s;
}
.payment-option:active, .payment-option.selected {
  border-color: var(--black);
}
.payment-option-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.payment-option-detail { font-size: 14px; color: var(--gray-dark); }
.payment-option-price { font-size: 22px; font-weight: 700; color: var(--green-dark); margin-top: 8px; }
.pix-badge { background: var(--pix-green); color: white; padding: 2px 8px; border-radius: 6px; font-size: 12px; }

.installments-select {
  width: 100%; padding: 14px; border: 2px solid var(--gray); border-radius: 10px;
  font-size: 16px; margin-top: 8px; background: var(--white);
}

.generate-btn {
  width: 100%; padding: 20px; border: none; border-radius: 16px;
  font-size: 20px; font-weight: 700; cursor: pointer;
  margin-top: 16px; color: var(--white); background: var(--green-dark);
}
.generate-btn:active { opacity: 0.9; transform: scale(0.98); }
.generate-btn:disabled { background: var(--gray); color: var(--gray-dark); }

/* === LINK READY === */
#screen-link { background: var(--white); align-items: center; justify-content: center; text-align: center; }

.link-icon { font-size: 64px; margin-bottom: 16px; }
.link-title { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.link-detail { font-size: 16px; color: var(--gray-dark); margin-bottom: 24px; }
.link-price { font-size: 32px; font-weight: 700; color: var(--green-dark); margin-bottom: 24px; }

.link-btn {
  width: 100%; padding: 18px; border: none; border-radius: 14px;
  font-size: 18px; font-weight: 700; cursor: pointer; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.link-btn:active { transform: scale(0.98); }
.link-btn.copy { background: var(--black); color: var(--white); }
.link-btn.whatsapp { background: var(--green); color: var(--white); }
.link-btn.new-sale { background: var(--gray-light); color: var(--black); border: 2px solid var(--gray); }

/* === LOADING === */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 40px; color: var(--gray-dark);
}
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--gray);
  border-top-color: var(--gold); border-radius: 50%;
  animation: spin 0.6s linear infinite; margin-right: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === TOAST === */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--black); color: var(--white); padding: 12px 24px;
  border-radius: 50px; font-size: 14px; font-weight: 600;
  z-index: 1000; opacity: 0; transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* === CUSTOMER FIELDS === */
.customer-section { margin-top: 16px; }
.customer-input {
  width: 100%; padding: 12px 16px; border: 2px solid var(--gray);
  border-radius: 10px; font-size: 15px; margin-bottom: 8px;
}
.customer-input:focus { outline: none; border-color: var(--gold); }
