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

:root {
  --pink: #c2185b;
  --pink-light: #fce4ec;
  --pink-dark: #880e4f;
  --bg: #f5f5f5;
  --white: #ffffff;
  --gray-50: #fafafa;
  --gray-100: #f0f0f0;
  --gray-200: #e0e0e0;
  --gray-400: #9e9e9e;
  --gray-600: #616161;
  --gray-800: #424242;
  --text: #212121;
  --border: #e0e0e0;
  --green: #2e7d32;
  --green-bg: #e8f5e9;
  --yellow-bg: #fff8e1;
  --red: #c62828;
  --red-bg: #ffebee;
  --blue: #1565c0;
  --blue-bg: #e3f2fd;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body { height: 100%; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; }

#app { min-height: 100%; display: flex; flex-direction: column; }

/* ── Login ─────────────────────────────────────────────────────────── */
.login-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px; background: linear-gradient(135deg, var(--pink-dark), var(--pink));
}
.login-logo { color: white; font-size: 28px; font-weight: 800; margin-bottom: 8px; letter-spacing: -0.5px; }
.login-logo span { opacity: 0.8; font-weight: 400; font-size: 20px; }
.login-sub { color: rgba(255,255,255,0.75); margin-bottom: 32px; font-size: 14px; }
.login-card { background: var(--white); border-radius: var(--radius); padding: 32px 28px; width: 100%; max-width: 360px; box-shadow: 0 8px 32px rgba(0,0,0,0.15); }
.login-card h2 { font-size: 18px; margin-bottom: 20px; color: var(--gray-800); }

/* ── Inputs ────────────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-600); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 15px; font-family: var(--font); background: var(--white); color: var(--text);
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pink); }
input.error { border-color: var(--red); }
textarea { resize: vertical; min-height: 70px; }
.field .hint { font-size: 11px; color: var(--gray-400); margin-top: 4px; }

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; font-family: var(--font); white-space: nowrap;
}
.btn-primary { background: var(--pink); color: white; }
.btn-primary:hover { background: var(--pink-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-800); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #1b5e20; }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #b71c1c; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn + .btn { margin-left: 8px; }

/* ── Header ─────────────────────────────────────────────────────────── */
.header {
  background: var(--pink); color: white; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-title { font-size: 18px; font-weight: 700; }
.header-user { font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 10px; }
.header-actions { display: flex; gap: 8px; }
.header-btn {
  background: rgba(255,255,255,0.2); border: none; color: white; padding: 6px 12px;
  border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600;
  transition: background 0.15s;
}
.header-btn:hover { background: rgba(255,255,255,0.3); }

/* ── Tabs ───────────────────────────────────────────────────────────── */
.tabs {
  display: flex; background: var(--white); border-bottom: 2px solid var(--border);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tab {
  flex: 1; min-width: 80px; padding: 12px 8px; text-align: center; font-size: 13px;
  font-weight: 600; color: var(--gray-400); cursor: pointer; border: none;
  background: none; border-bottom: 3px solid transparent; transition: all 0.15s;
  white-space: nowrap;
}
.tab.active { color: var(--pink); border-bottom-color: var(--pink); }
.tab:hover:not(.active) { color: var(--gray-600); background: var(--gray-50); }

/* ── Main content ──────────────────────────────────────────────────── */
.main { flex: 1; padding: 16px; max-width: 600px; margin: 0 auto; width: 100%; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 16px; color: var(--gray-800); }
.page-title .count { font-weight: 400; color: var(--gray-400); font-size: 16px; }

/* ── Search bar ────────────────────────────────────────────────────── */
.search-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.search-bar input { flex: 1; }

/* ── Cards ─────────────────────────────────────────────────────────── */
.card {
  background: var(--white); border-radius: var(--radius); padding: 16px;
  margin-bottom: 12px; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.card-title { font-size: 15px; font-weight: 700; color: var(--gray-800); }
.card-subtitle { font-size: 13px; color: var(--gray-600); }
.card-actions { display: flex; gap: 6px; }

/* ── Product card ──────────────────────────────────────────────────── */
.product-card { display: flex; gap: 12px; align-items: center; }
.product-img {
  width: 64px; height: 64px; object-fit: cover; border-radius: 8px;
  background: var(--gray-100); flex-shrink: 0; border: 1px solid var(--border);
}
.product-img-placeholder { width: 64px; height: 64px; border-radius: 8px; background: var(--pink-light); display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.product-info { flex: 1; min-width: 0; }
.product-name { font-weight: 700; font-size: 14px; color: var(--gray-800); margin-bottom: 3px; }
.product-meta { font-size: 12px; color: var(--gray-600); }
.product-price { font-weight: 700; color: var(--pink); font-size: 16px; }
.product-stock { font-size: 12px; margin-top: 2px; }
.product-stock.ok { color: var(--green); }
.product-stock.low { color: #e65100; }
.product-stock.out { color: var(--red); }

/* ── Badges / Status ───────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 700;
}
.badge-novo { background: var(--blue-bg); color: var(--blue); }
.badge-aguardando_pagamento { background: var(--yellow-bg); color: #f57f17; }
.badge-cartao_motoboy { background: var(--blue-bg); color: var(--blue); }
.badge-pago { background: var(--green-bg); color: var(--green); }
.badge-enviado { background: var(--pink-light); color: var(--pink-dark); }
.badge-entregue { background: var(--green-bg); color: var(--green); }
.badge-cancelado { background: var(--red-bg); color: var(--red); }
.badge-vip { background: #fde7f0; color: #c2185b; }
.badge-Ativa { background: var(--green-bg); color: var(--green); }
.badge-Esfriando { background: var(--yellow-bg); color: #f57f17; }
.badge-Inativa { background: var(--red-bg); color: var(--red); }
.badge-Sem_compra { background: var(--gray-50); color: var(--gray-600); }
.badge-pronto_retirada { background: var(--green-bg); color: var(--green); }
.badge-retirado { background: #ede7f6; color: #5e35b1; }
.badge-verificar_entrega { background: #fff3e0; color: #e65100; }

/* ── Order detail ──────────────────────────────────────────────────── */
.order-items { margin: 12px 0; }
.order-item { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.order-item:last-child { border-bottom: none; }
.order-item-name { flex: 1; }
.order-item-price { font-weight: 600; margin-left: 12px; }
.order-total { display: flex; justify-content: space-between; font-weight: 700; font-size: 16px; padding: 12px 0; border-top: 2px solid var(--border); margin-top: 4px; }
.order-address { background: var(--gray-50); padding: 12px; border-radius: 8px; font-size: 13px; line-height: 1.6; }
.order-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ── Customer card ─────────────────────────────────────────────────── */
.customer-card { display: flex; justify-content: space-between; align-items: center; }
.customer-info .customer-name { font-weight: 700; font-size: 14px; }
.customer-info .customer-phone { font-size: 13px; color: var(--gray-600); margin-top: 2px; }
.customer-info .customer-address { font-size: 12px; color: var(--gray-400); margin-top: 2px; }

/* ── Modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal { background: var(--white); border-radius: var(--radius); width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 17px; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Form grid ─────────────────────────────────────────────────────── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* ── Stock grid ────────────────────────────────────────────────────── */
.stock-grid { display: grid; gap: 6px; margin-top: 8px; }
.stock-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.stock-row .size-label { font-weight: 700; width: 30px; flex-shrink: 0; }
.stock-row input { width: 70px; text-align: center; padding: 6px; }
.stock-row .stock-qty { flex: 1; color: var(--gray-600); }
.stock-colors { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.stock-color-chip { padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; border: 2px solid var(--border); cursor: pointer; }
.stock-color-chip.active { border-color: var(--pink); background: var(--pink-light); color: var(--pink-dark); }

/* ── Image upload ──────────────────────────────────────────────────── */
.img-upload-area { border: 2px dashed var(--border); border-radius: 10px; padding: 20px; text-align: center; cursor: pointer; transition: all 0.15s; }
.img-upload-area:hover { border-color: var(--pink); background: var(--pink-light); }
.img-upload-area input { display: none; }
.img-preview-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.img-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.img-thumb-remove { position: relative; display: inline-block; }
.img-thumb-remove::after { content: '×'; position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; background: var(--red); color: white; border-radius: 50%; font-size: 12px; line-height: 18px; cursor: pointer; }

/* ── Section titles ─────────────────────────────────────────────────── */
.section-title { font-size: 13px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.5px; margin: 18px 0 10px; }

/* ── Empty state ───────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--gray-400); }
.empty-state .emoji { font-size: 40px; display: block; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Toast / alerts ────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; font-weight: 500; }
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid #ffcdd2; }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid #c8e6c9; }
.alert-info { background: var(--blue-bg); color: var(--blue); border: 1px solid #bbdefb; }

/* ── Loading ───────────────────────────────────────────────────────── */
.loading { text-align: center; padding: 32px; color: var(--gray-400); font-size: 14px; }
.loading::after { content: '…'; animation: dots 1s infinite; }
@keyframes dots { 0%{content:'.'} 33%{content:'..'} 66%{content:'...'} }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .header-title { font-size: 16px; }
  .modal { margin: 0; border-radius: 0; max-height: 100vh; }
  .modal-overlay { padding: 0; align-items: flex-end; }
}

/* ── Config ────────────────────────────────────────────────────────── */
.config-section { background: var(--white); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; border: 1px solid var(--border); }
.config-section h3 { font-size: 15px; font-weight: 700; margin-bottom: 14px; color: var(--gray-800); }

/* ── Order form (new order) ────────────────────────────────────────── */
.order-customer { background: var(--gray-50); padding: 14px; border-radius: 8px; margin-bottom: 14px; }
.order-customer h4 { font-size: 13px; font-weight: 700; color: var(--gray-600); margin-bottom: 10px; }
.order-items-list { margin: 10px 0; }
.order-item-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 14px; }
.order-item-row select, .order-item-row input { flex: 1; }
