:root {
  --teal: #0f766e;
  --teal-dark: #0b5a54;
  --green: #16a34a;
  --red: #dc2626;
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e2e8f0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 72px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--teal);
  color: #fff;
  padding: 14px 16px;
}
.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.topbar-brand { display: flex; align-items: center; gap: 8px; }
.topbar-logo { width: 28px; height: 28px; border-radius: 6px; display: block; }
.topbar-title { font-size: 20px; font-weight: 700; }
.topbar-sub { font-size: 13px; opacity: 0.9; margin-top: 2px; }

.install-btn[hidden] { display: none; }
.install-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.6);
  color: #fff;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.install-btn:active { background: rgba(255,255,255,0.3); }
.install-btn::before {
  content: "";
  width: 14px;
  height: 14px;
  background: currentColor;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 3v10.6l3.3-3.3 1.4 1.4L12 17l-4.7-4.7 1.4-1.4 3.3 3.3V3h2zM5 19h14v2H5z"/></svg>') no-repeat center / contain;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 3v10.6l3.3-3.3 1.4 1.4L12 17l-4.7-4.7 1.4-1.4 3.3 3.3V3h2zM5 19h14v2H5z"/></svg>') no-repeat center / contain;
}

.help-btn {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.6);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}
.help-btn:active { background: rgba(255,255,255,0.3); }

.view { padding: 12px 12px 24px; max-width: 640px; margin: 0 auto; }

.panel {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.panel h2 { margin: 0 0 10px; font-size: 16px; color: var(--teal-dark); }

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.product-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: left;
  min-height: 64px;
  font-size: 15px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.product-btn:active { background: #ecfdf5; border-color: var(--teal); }
.product-btn .p-name { display: block; font-weight: 600; margin-bottom: 4px; }
.product-btn .p-price { display: block; color: var(--teal-dark); font-weight: 700; }
.no-products { color: var(--muted); grid-column: 1 / -1; text-align: center; padding: 20px 0; }

.cart-panel {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  margin-bottom: 8px;
}
.cart-list { min-height: 40px; margin-bottom: 8px; }
.empty-hint { color: var(--muted); font-size: 14px; margin: 8px 0; }

.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.cart-item .ci-name { flex: 1; font-size: 14px; }
.cart-item .ci-price { font-size: 13px; color: var(--muted); }
.qty-controls { display: flex; align-items: center; gap: 6px; }
.qty-controls button {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; font-size: 16px; line-height: 1;
}
.qty-controls span { min-width: 20px; text-align: center; font-weight: 600; }
.ci-remove { color: var(--red); background: none; border: none; font-size: 13px; padding: 4px; }

.totals-box { border-top: 1px dashed var(--border); padding-top: 10px; margin-top: 6px; }
.totals-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 15px;
}
.totals-row label { font-size: 14px; color: var(--muted); }
.totals-row input {
  width: 130px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 15px;
  text-align: right;
}
.totals-value { font-weight: 700; font-size: 17px; }
#changeValue.negative { color: var(--red); }
#changeValue.positive { color: var(--green); }

.primary-btn {
  width: 100%;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  margin-top: 4px;
}
.primary-btn:active { background: var(--teal-dark); }

.secondary-btn {
  background: #fff;
  border: 1px solid var(--teal);
  color: var(--teal-dark);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
}

.link-btn { background: none; border: none; color: var(--red); font-size: 13px; }
.danger-link { background: none; border: 1px solid var(--red); color: var(--red); border-radius: 10px; padding: 10px 12px; font-size: 13px; }

.product-form label { display: block; margin-bottom: 10px; font-size: 14px; color: var(--muted); }
.product-form input {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 15px;
  margin-top: 4px;
}
.form-actions { display: flex; gap: 10px; margin-top: 4px; }
.form-actions .primary-btn { flex: 1; }

.product-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.product-list-item .pl-name { font-weight: 600; }
.product-list-item .pl-price { color: var(--teal-dark); font-size: 14px; }
.pl-actions button { background: none; border: none; font-size: 13px; padding: 6px; }
.pl-actions .edit-btn { color: var(--teal-dark); }
.pl-actions .delete-btn { color: var(--red); }
.empty-list { color: var(--muted); text-align: center; padding: 16px 0; }

.scan-hint { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.scan-status {
  margin-top: 10px;
  font-size: 14px;
  color: var(--teal-dark);
}
.scan-status.error { color: var(--red); }
.scan-results { margin-top: 12px; }
.scan-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.scan-item input[type="checkbox"] { width: 20px; height: 20px; flex-shrink: 0; }
.scan-item .scan-name {
  flex: 1;
  min-width: 0;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
}
.scan-item .scan-price {
  width: 80px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  text-align: right;
}
.scan-empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

.records-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.date-group {
  background: var(--card);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.date-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  cursor: pointer;
}
.date-group-header .dg-total { color: var(--teal-dark); }
.sale-entry {
  border-top: 1px solid var(--border);
  padding: 8px 0;
  font-size: 13px;
}
.sale-entry .se-time { color: var(--muted); }
.sale-entry .se-items { margin: 4px 0; }
.sale-entry .se-money { display: flex; justify-content: space-between; font-weight: 600; }

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--border);
  z-index: 10;
}
.nav-btn {
  flex: 1;
  padding: 12px 0;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.nav-btn.active { color: var(--teal-dark); border-top: 3px solid var(--teal); }

.toast {
  position: fixed;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 50;
}

.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.onboarding-overlay[hidden] { display: none; }
.onboarding-card {
  position: relative;
  background: var(--card);
  border-radius: 16px;
  padding: 28px 22px 20px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.onboarding-skip {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  padding: 6px;
}
.onboarding-icon { font-size: 40px; margin-bottom: 8px; }
.onboarding-card h2 { margin: 0 0 10px; font-size: 18px; color: var(--teal-dark); }
.onboarding-card p { margin: 0; font-size: 14.5px; color: var(--text); line-height: 1.5; }
.onboarding-dots { display: flex; justify-content: center; gap: 6px; margin: 18px 0 6px; }
.onboarding-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
}
.onboarding-dots span.active { background: var(--teal); }
.onboarding-actions { display: flex; gap: 10px; margin-top: 12px; }
.onboarding-actions .secondary-btn, .onboarding-actions .primary-btn { flex: 1; margin-top: 0; }
.onboarding-actions .secondary-btn[hidden] { display: none; }
