:root {
  --bg: #0d0d14;
  --card: #16161f;
  --card-2: #1c1c28;
  --purple: #a855f7;
  --purple-2: #7c3aed;
  --green: #22c55e;
  --orange: #f97316;
  --text: #f5f5f7;
  --text-dim: #9a9aab;
  --border: #2a2a38;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.screen { display: none; min-height: 100vh; padding-bottom: 90px; }
.screen.active { display: block; }

/* ---------- Auth ---------- */
#auth-screen {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-box {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
}
.auth-logo {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}
.auth-logo span { color: var(--purple); }
.auth-sub { text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  font-size: 15px;
}
.field textarea { resize: vertical; min-height: 70px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: linear-gradient(135deg, var(--purple), var(--purple-2)); color: white; }
.btn-secondary { background: var(--card-2); color: var(--text); border: 1px solid var(--border); }
.btn-orange { background: var(--orange); color: white; }
.btn-green { background: var(--green); color: #06210f; }
.btn-danger { background: #3a1414; color: #ff8a8a; border: 1px solid #5c1f1f; }
.btn-sm { padding: 8px 12px; font-size: 13px; width: auto; }

.auth-toggle { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-dim); }
.auth-toggle a { color: var(--purple); cursor: pointer; text-decoration: none; }

.error-msg { color: #ff6b6b; font-size: 13px; margin-top: 8px; min-height: 16px; }
.ok-msg { color: var(--green); font-size: 13px; margin-top: 8px; min-height: 16px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 6px;
}
.topbar-brand { font-weight: 700; font-size: 16px; }
.topbar-brand .pill {
  background: linear-gradient(135deg, var(--purple), var(--purple-2));
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  margin-left: 4px;
}
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--card-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; color: var(--text);
}

.greeting { padding: 4px 20px 14px; }
.greeting h2 { margin: 0 0 2px; font-size: 20px; }
.greeting p { margin: 0; color: var(--purple); font-size: 13px; }
.greeting small { display: block; color: var(--text-dim); font-size: 12px; margin-top: 8px; line-height: 1.4; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 8px; padding: 0 20px 16px; overflow-x: auto; }
.filter-chip {
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text-dim);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.filter-chip.active { background: var(--purple); color: white; border-color: var(--purple); }

/* ---------- Cards ---------- */
.section { padding: 0 20px 20px; }
.section h3 { font-size: 15px; margin: 0 0 12px; color: var(--text-dim); font-weight: 600; }

.sales-card {
  background: linear-gradient(160deg, #16351f, #0e2015);
  border: 1px solid #1e4a2b;
  border-radius: var(--radius);
  padding: 20px;
  margin: 0 20px 20px;
}
.sales-card .label { color: #7fdb9a; font-size: 13px; }
.sales-card .value { font-size: 30px; font-weight: 700; margin: 4px 0; }
.sales-card .meta { color: #7fdb9a; font-size: 12px; }
.sales-card .meta2 { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.sparkline { width: 100%; height: 40px; margin-top: 10px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mini-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
}
.mini-card .mc-icon { font-size: 20px; margin-bottom: 8px; }
.mini-card .mc-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.mini-card .mc-num { font-size: 18px; font-weight: 700; }
.mini-card .mc-sub { font-size: 12px; color: var(--text-dim); }
.mini-card.purple .mc-title { color: #c4b5fd; }
.mini-card.green .mc-title { color: #86efac; }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.qa-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 8px;
  text-align: center;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}
.qa-btn.highlight { background: var(--orange); border-color: var(--orange); color: white; font-weight: 600; }
.qa-btn .qa-icon { font-size: 20px; display: block; margin-bottom: 6px; }

/* ---------- Lists ---------- */
.list-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; font-size: 14px; }
.list-item .li-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.list-item .li-right { text-align: right; font-size: 13px; white-space: nowrap; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.disponivel { background: #14322066; color: #86efac; }
.badge.vendida { background: #3a1a4a66; color: #d8b4fe; }
.badge.pendente { background: #4a2f1466; color: #fdba74; }

.empty-state { text-align: center; color: var(--text-dim); font-size: 13px; padding: 30px 10px; }

.fab-add {
  position: fixed;
  right: 20px;
  bottom: 100px;
  width: 54px; height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--purple-2));
  color: white;
  border: none;
  font-size: 26px;
  box-shadow: 0 6px 18px rgba(168,85,247,0.4);
  cursor: pointer;
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(13,13,20,0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 10px 0 max(10px, env(safe-area-inset-bottom));
  z-index: 40;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-dim);
  font-size: 11px;
  background: none; border: none; cursor: pointer;
}
.nav-item.active { color: var(--purple); }
.nav-item .ni-icon { font-size: 20px; }
.nav-item.center .ni-icon {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--purple-2));
  display: flex; align-items: center; justify-content: center;
  color: white;
  margin-top: -22px;
  box-shadow: 0 6px 16px rgba(168,85,247,0.5);
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
}
.modal-backdrop.active { display: flex; }
.modal-sheet {
  width: 100%; max-width: 480px;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 88vh;
  overflow-y: auto;
}
.modal-sheet h3 { margin-top: 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ---------- Scan page (público) ---------- */
.scan-body {
  background: radial-gradient(circle at top, #241a3d, #0d0d14 60%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.scan-card {
  width: 100%; max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px 26px;
  text-align: center;
}
.scan-icon { font-size: 44px; margin-bottom: 10px; }
.scan-card h1 { font-size: 20px; margin: 0 0 4px; }
.scan-card .scan-name { font-size: 26px; font-weight: 700; margin: 6px 0 16px; color: var(--purple); }
.scan-info-row { text-align: left; background: var(--card-2); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; }
.scan-info-row .lbl { font-size: 12px; color: var(--text-dim); }
.scan-info-row .val { font-size: 15px; margin-top: 2px; word-break: break-word; }
.scan-call-btn {
  display: block; margin-top: 14px;
  background: var(--green); color: #06210f;
  padding: 14px; border-radius: 14px;
  font-weight: 700; text-decoration: none; font-size: 16px;
}
.scan-footer { margin-top: 22px; font-size: 11px; color: var(--text-dim); }

.spinner { display:flex; align-items:center; justify-content:center; padding: 40px; color: var(--text-dim); }

@media (min-width: 640px) {
  #app-screen { max-width: 480px; margin: 0 auto; border-left: 1px solid var(--border); border-right: 1px solid var(--border); min-height: 100vh; }
}
