:root {
  --b-primary: #059669;
  --b-primary-dark: #047857;
  --b-primary-light: #d1fae5;
  --b-accent: #d97706;
  --b-bg: #f0fdf4;
  --b-surface: #ffffff;
  --b-text: #0f172a;
  --b-muted: #64748b;
  --b-nav-h: 64px;
  --b-topbar-h: 48px;
  --b-topbar-bulge: 26px;
  --b-safe-top: env(safe-area-inset-top, 0px);
  --b-topbar-total: calc(var(--b-safe-top) + var(--b-topbar-h) + var(--b-topbar-bulge));
  --b-safe-bottom: env(safe-area-inset-bottom, 0px);
  --b-radius: 16px;
  --b-shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body.buydly-app {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--b-bg);
  color: var(--b-text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.buydly-font-logo {
  font-family: 'Nothing You Could Do', cursive;
}

.buydly-page {
  max-width: 32rem;
  margin: 0 auto;
  padding: calc(var(--b-topbar-total) + 0.35rem) 1rem calc(var(--b-nav-h) + var(--b-safe-bottom) + 1rem);
}

.buydly-page--no-nav {
  padding-bottom: 1.5rem;
}

/* Login */
.buydly-login-bg {
  min-height: 100dvh;
  background: linear-gradient(145deg, #ecfdf5 0%, #f0fdf4 40%, #fff 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.buydly-login-hero {
  text-align: center;
  margin-bottom: 2rem;
}

.buydly-login-logo {
  font-size: 3rem;
  line-height: 1;
  margin: 0 0 0.25rem;
  color: var(--b-primary-dark);
}

.buydly-login-tagline {
  font-size: 1rem;
  color: var(--b-muted);
  max-width: 18rem;
  margin: 0 auto;
  line-height: 1.45;
}

.buydly-card {
  background: var(--b-surface);
  border-radius: var(--b-radius);
  box-shadow: var(--b-shadow);
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.buydly-input {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.buydly-input:focus {
  outline: none;
  border-color: var(--b-primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.buydly-btn-primary {
  width: 100%;
  background: var(--b-primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.buydly-btn-primary:hover { background: var(--b-primary-dark); }
.buydly-btn-primary:active { transform: scale(0.98); }
.buydly-btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

/* Home hero — continuar comprando */
.buydly-hero {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #fff;
  border-radius: var(--b-radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 8px 28px rgba(5, 150, 105, 0.35);
  text-decoration: none;
  display: block;
  transition: transform 0.15s;
}

.buydly-hero:hover { transform: translateY(-2px); color: #fff; }

.buydly-hero-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.85;
  margin-bottom: 0.25rem;
}

.buydly-hero-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.buydly-hero-meta {
  font-size: 0.85rem;
  opacity: 0.9;
}

/* Quick chips */
.buydly-chips {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  margin-bottom: 1.25rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.buydly-chips::-webkit-scrollbar { display: none; }

.buydly-chip {
  flex-shrink: 0;
  background: var(--b-surface);
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--b-text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.buydly-chip:hover {
  background: var(--b-primary-light);
  border-color: var(--b-primary);
  color: var(--b-primary-dark);
}

/* List cards */
.buydly-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--b-muted);
  margin: 0 0 0.75rem;
}

.buydly-list-card {
  background: var(--b-surface);
  border-radius: var(--b-radius);
  border: 1px solid rgba(15, 23, 42, 0.06);
  overflow: hidden;
  margin-bottom: 0.75rem;
  transition: box-shadow 0.15s;
}
.buydly-list-card:hover { box-shadow: var(--b-shadow); }

.buydly-list-card-inner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
}
.buydly-list-card-body { flex: 1; min-width: 0; }
.buydly-list-card-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.buydly-list-card-row .buydly-list-card-title { flex: 1; }
.buydly-list-card-link {
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.buydly-list-card-link:hover { color: inherit; }
.buydly-list-card-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.buydly-list-card-meta {
  font-size: 0.875rem;
  color: var(--b-muted);
  margin: 0.025rem 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.buydly-list-card-meta--warn { color: #b45309; }
.buydly-list-card-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}
.buydly-list-card-edit {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 9999px;
  background: #f8fafc;
  color: var(--b-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.buydly-list-card-edit svg {
  width: 1rem;
  height: 1rem;
}
.buydly-list-card-footer {
  padding: 0 1rem 0.75rem;
  border-top: 1px solid #f1f5f9;
  background: rgba(248, 250, 252, 0.8);
}
.buydly-list-card-duplicar {
  width: 50%;
  margin-top: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--b-primary-dark);
  background: var(--b-primary-light);
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  padding: 0.625rem 1rem;
  cursor: pointer;
}
.buydly-list-card-duplicar:hover { background: #a7f3d0; }

.buydly-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgba(15, 23, 42, 0.4);
}
@media (min-width: 640px) {
  .buydly-modal-overlay { align-items: center; padding: 1rem; }
}
.buydly-modal-panel {
  background: var(--b-surface);
  border-radius: 1rem 1rem 0 0;
  box-shadow: var(--b-shadow);
  width: 100%;
  max-width: 28rem;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.25rem;
}
@media (min-width: 640px) {
  .buydly-modal-panel { border-radius: var(--b-radius); }
}
.buydly-modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 1rem;
}
.buydly-modal-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--b-muted);
  margin-bottom: 0.25rem;
}
.buydly-modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}
.buydly-btn-secondary {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #fff;
  cursor: pointer;
}
.buydly-btn-danger {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: 12px;
  border: none;
  background: #dc2626;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.buydly-btn-danger:hover { background: #b91c1c; }
.buydly-btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }
.buydly-btn-danger-outline {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  padding: 0.625rem 1rem;
  border-radius: 12px;
  border: 1px solid #fecaca;
  background: #fff;
  color: #b91c1c;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
}
.buydly-btn-danger-outline:hover { background: #fef2f2; }
.buydly-modal-divider {
  border-top: 1px solid #f1f5f9;
  margin: 1.25rem 0 0.75rem;
}
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.buydly-text-muted { color: var(--b-muted); font-size: 0.875rem; }
.buydly-text-error { color: #dc2626; font-size: 0.75rem; margin-top: 0.75rem; }
.buydly-text-warn { color: #b45309; }

.buydly-modal-overlay--stack { z-index: 60; }
.buydly-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.buydly-modal-header .buydly-modal-title { margin: 0; }
.buydly-modal-close {
  border: none;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 0 0.25rem;
}
.buydly-modal-close:hover { color: #475569; }
.buydly-modal-subtitle {
  font-size: 0.875rem;
  color: var(--b-muted);
  margin: -0.5rem 0 1rem;
  line-height: 1.45;
}
.buydly-modal-indefinido {
  width: 100%;
  text-align: left;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}
.buydly-modal-indefinido:hover {
  border-color: var(--b-primary);
  background: #ecfdf5;
}
.buydly-modal-indefinido-title {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--b-text);
}
.buydly-modal-indefinido-desc {
  display: block;
  font-size: 0.75rem;
  color: var(--b-muted);
  margin-top: 0.125rem;
}
.buydly-mercado-list {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  max-height: 12rem;
  overflow-y: auto;
  margin-bottom: 0.75rem;
  list-style: none;
  padding: 0;
  margin-top: 0;
}
.buydly-mercado-list li {
  padding: 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
}
.buydly-mercado-list li:last-child { border-bottom: none; }
.buydly-mercado-list li:hover { background: #ecfdf5; }
.buydly-cadastro-box {
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 0.75rem;
  background: #fffbeb;
  margin-bottom: 0.75rem;
}
.buydly-cadastro-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.buydly-checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  margin-bottom: 0.25rem;
}
.buydly-checkbox-row--on {
  border-color: #60a5fa;
  background: #eff6ff;
}
.buydly-checkbox-row input { margin-top: 0.125rem; }
.buydly-checkbox-row-title { font-size: 0.875rem; font-weight: 600; }
.buydly-checkbox-row-desc { font-size: 0.75rem; color: var(--b-muted); }
.buydly-checkbox-row--off .buydly-checkbox-row-title { color: #94a3b8; }
.buydly-input-btn {
  width: 100%;
  text-align: left;
  background: #fff;
  cursor: pointer;
}
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

.buydly-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 600;
}
.buydly-pill-comprar { background: #dbeafe; color: #1d4ed8; }
.buydly-pill-carrinho { background: #d1fae5; color: #065f46; }
.buydly-pill-deixar { background: #f1f5f9; color: #475569; }
.buydly-pill-falta { background: #fee2e2; color: #b91c1c; }
.buydly-pill-vazio { background: #f8fafc; color: #94a3b8; }
.buydly-pill-concluida { background: #fef3c7; color: #92400e; }

/* Empty state */
.buydly-empty {
  text-align: center;
  padding: 2.5rem 1rem;
}
.buydly-empty-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 0.75rem;
}
.buydly-empty-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}
.buydly-empty-text {
  font-size: 0.875rem;
  color: var(--b-muted);
  margin: 0 0 1.25rem;
  line-height: 1.5;
}

/* FAB */
.buydly-fab {
  position: fixed;
  right: 1.25rem;
  bottom: calc(var(--b-nav-h) + var(--b-safe-bottom) + 1rem);
  z-index: 40;
  width: 56px;
  height: 56px;
  border-radius: 9999px;
  background: var(--b-primary);
  color: #fff;
  border: none;
  font-size: 1.75rem;
  line-height: 1;
  box-shadow: 0 4px 20px rgba(5, 150, 105, 0.45);
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}
.buydly-fab:hover { background: var(--b-primary-dark); transform: scale(1.05); }

/* FAB + barra de totais na tela da lista (sem nav inferior) */
.buydly-fab--lista {
  bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
  z-index: 300;
}
.buydly-barra-lista {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 290;
  width: 100%;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.lista-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgba(15, 23, 42, 0.45);
  pointer-events: auto;
}
@media (min-width: 640px) {
  .lista-modal-overlay { align-items: center; padding: 1rem; }
}
.lista-modal-panel {
  background: #fff;
  border-radius: 1rem 1rem 0 0;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.15);
  width: 100%;
  max-width: 24rem;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.25rem;
}
@media (min-width: 640px) {
  .lista-modal-panel { border-radius: 16px; }
}

/* Bottom nav */
.buydly-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  height: calc(var(--b-nav-h) + var(--b-safe-bottom));
  padding-bottom: var(--b-safe-bottom);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  display: flex;
  justify-content: space-around;
  align-items: center;
  max-width: 32rem;
  margin: 0 auto;
}

.buydly-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0.5rem;
  text-decoration: none;
  color: var(--b-muted);
  font-size: 0.625rem;
  font-weight: 600;
  transition: color 0.15s;
}
.buydly-nav-item svg { width: 22px; height: 22px; }
.buydly-nav-item--active { color: var(--b-primary); }
.buydly-nav-item:hover { color: var(--b-primary-dark); }

/* Top bar global */
.buydly-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  padding-top: var(--b-safe-top);
  pointer-events: none;
}

.buydly-topbar-inner {
  position: relative;
  max-width: 42rem;
  margin: 0 auto;
  height: var(--b-topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.75rem;
  background: rgba(240, 253, 244, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  transition: box-shadow 0.22s ease;
  pointer-events: auto;
}

.buydly-topbar--scrolled .buydly-topbar-inner {
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.1);
}

.buydly-topbar-side {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 5.5rem;
  z-index: 2;
}

.buydly-topbar-side--left { justify-content: flex-start; }
.buydly-topbar-side--right { justify-content: flex-end; }

.buydly-topbar-btn {
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--b-text);
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.buydly-topbar-btn:hover {
  background: rgb(241,252,245);
  border-color: rgba(5, 150, 105, 0.35);
  color: var(--b-primary-dark);
}
.buydly-topbar-btn svg { width: 18px; height: 18px; }

.buydly-topbar-center {
  position: absolute;
  left: 50%;
  top: 65%;
  transform: translateX(-50%);
  text-decoration: none;
  pointer-events: auto;
  z-index: 3;
}

.buydly-topbar-notch {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  margin-top: -27px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.1);
  transition: box-shadow 0.22s ease, transform 0.15s ease;
}
.buydly-topbar-center:hover .buydly-topbar-notch {
  transform: scale(1.04);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
}
.buydly-topbar--scrolled .buydly-topbar-notch {
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14);
}

.buydly-topbar-logo {
  width: 40px;
  height: 40px;
  margin-right:5px;
  object-fit: contain;
}

.buydly-topbar-points {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
}

.buydly-topbar-avatar {
  width: 32px;
  height: 32px;
  font-size: 0.8rem;
  text-decoration: none;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.buydly-topbar-avatar:hover { transform: scale(1.05); }

.buydly-context-header {
  margin-bottom: 1rem;
}

body.buydly-has-topbar {
  padding-top: var(--b-topbar-total);
}

/* Header app bar (legado — páginas antigas) */
.buydly-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.buydly-header-brand-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  min-width: 0;
}
.buydly-header-logo {
  height: 2rem;
  width: auto;
  max-width: 9rem;
  object-fit: contain;
}
.buydly-login-mark {
  display: block;
  margin: 0 auto 0.5rem;
  object-fit: contain;
}
.buydly-login-wordmark {
  display: block;
  margin: 0 auto 0.25rem;
  height: 2.5rem;
  width: auto;
  object-fit: contain;
}

.buydly-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.buydly-header-brand {
  font-size: 1.75rem;
  font-weight: 400;
  color: var(--b-primary-dark);
  margin: 0;
  line-height: 1;
}

.buydly-avatar {
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  background: var(--b-primary-light);
  color: var(--b-primary-dark);
  font-weight: 700;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.buydly-points-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #fffbeb;
  color: #b45309;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  text-decoration: none;
  border: 1px solid #fde68a;
}
