@font-face {
  font-family: "Carrinho Sans";
  src: local("Segoe UI Variable"), local("Segoe UI"), local("Avenir Next"), local("Helvetica Neue");
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "Carrinho Display";
  src: local("Segoe UI Variable Display"), local("Avenir Next"), local("Futura"), local("Trebuchet MS");
  font-weight: 700;
  font-display: swap;
}

:root {
  --green-deep: #1a5c3a;
  --green-mid: #2a7a4f;
  --green-soft: #e8f3ec;
  --citrus: #e8a317;
  --citrus-press: #c9890f;
  --ink: #14241a;
  --ink-muted: #4a6354;
  --surface: #f4faf6;
  --surface-elevated: #ffffff;
  --danger: #c43c2c;
  --danger-soft: #fcecea;
  --shadow: 0 8px 28px rgba(20, 36, 26, 0.12);
  --radius: 16px;
  --touch: 48px;
  --kpi-h: 7.5rem;
  --fab-h: 5.5rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-body: "Carrinho Sans", "Segoe UI", sans-serif;
  --font-display: "Carrinho Display", "Avenir Next", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  height: -webkit-fill-available;
  background-color: #e3f0e8;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  font-family: var(--font-body);
  color: var(--ink);
  touch-action: manipulation;
  -ms-touch-action: manipulation;
  background-color: #e3f0e8;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-top: calc(var(--kpi-h) + var(--safe-top));
  padding-bottom: calc(var(--fab-h) + var(--safe-bottom));
  position: relative;
}

/* Fundo em tela cheia (evita faixa branca no rodapé / safe-area) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 120% 80% at 10% -10%, #c8e6d4 0%, transparent 55%),
    radial-gradient(ellipse 90% 60% at 100% 0%, #d4ecd8 0%, transparent 45%),
    linear-gradient(180deg, #eef7f1 0%, var(--surface) 40%, #e3f0e8 100%);
}

button,
a,
input,
.fab,
.numpad button,
.qty-btn,
.btn-share,
.btn-text,
.btn-delete,
.camera-shutter {
  touch-action: manipulation;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

.offline-banner {
  position: fixed;
  top: var(--safe-top);
  left: 0;
  right: 0;
  z-index: 50;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.35rem 0.75rem;
  background: var(--ink);
  color: #fff;
  animation: slideDown 0.25s ease;
}

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.kpi-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  padding: calc(0.75rem + var(--safe-top)) 1.1rem 0.85rem;
  background: linear-gradient(165deg, var(--green-deep) 0%, var(--green-mid) 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(26, 92, 58, 0.35);
}

.kpi-brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.kpi-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.btn-text {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.5rem;
  min-height: 36px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-text:active {
  opacity: 0.7;
}

.btn-share {
  color: var(--ink);
  background: var(--citrus);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.4rem 0.75rem;
  min-height: 36px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-share:active {
  background: var(--citrus-press);
}

.btn-share[hidden] {
  display: none;
}

.kpi-values {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.kpi-block {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.kpi-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.75;
  font-weight: 600;
}

.kpi-amount {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.kpi-count {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.kpi-block--items {
  align-items: flex-end;
}

.feed {
  max-width: 32rem;
  margin: 0 auto;
  padding: 1rem 1rem 1.5rem;
  min-height: 40vh;
}

.empty-state {
  text-align: center;
  padding: 3.5rem 1.25rem 2rem;
  animation: fadeIn 0.4s ease;
}

.empty-state[hidden] {
  display: none;
}

.empty-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--green-deep);
}

.empty-text {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
  line-height: 1.45;
  max-width: 16rem;
  margin-inline: auto;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.item-card {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem;
  background: var(--surface-elevated);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: fadeIn 0.3s ease;
}

.item-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 12px;
  background: var(--green-soft);
}

.item-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.item-unit {
  font-size: 0.8rem;
  color: var(--ink-muted);
  font-weight: 500;
}

.item-subtotal {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--green-deep);
  font-variant-numeric: tabular-nums;
}

.item-qty-badge {
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.btn-delete {
  width: var(--touch);
  height: var(--touch);
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

.btn-delete:active {
  background: #f5d4d0;
}

.fab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  padding: 0.75rem 1.1rem calc(0.85rem + var(--safe-bottom));
  background: linear-gradient(180deg, transparent 0%, #eef7f1 22%, #e3f0e8 100%);
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.fab {
  pointer-events: auto;
  width: min(100%, 22rem);
  min-height: 56px;
  border-radius: 999px;
  background: var(--citrus);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: 0 6px 24px rgba(232, 163, 23, 0.45);
  transition: transform 0.12s ease, background 0.12s ease;
}

.fab:active {
  transform: scale(0.97);
  background: var(--citrus-press);
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(20, 36, 26, 0.45);
  animation: fadeIn 0.2s ease;
}

.sheet-backdrop[hidden],
.sheet[hidden] {
  display: none;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  max-height: min(92vh, 40rem);
  overflow-y: auto;
  padding: 0.5rem 1.1rem calc(1.1rem + var(--safe-bottom));
  background: var(--surface-elevated);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 40px rgba(20, 36, 26, 0.2);
  animation: sheetUp 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 32rem;
  margin: 0 auto;
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: #c5d6cb;
  margin: 0.35rem auto 0.75rem;
}

.sheet-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0 0 0.75rem;
  text-align: center;
  color: var(--green-deep);
}

.sheet-preview-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.sheet-preview {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 14px;
  background: var(--green-soft);
}

.sheet-price {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  padding: 0.5rem;
  background: var(--green-soft);
  border-radius: 12px;
}

.sheet-currency {
  font-weight: 700;
  color: var(--ink-muted);
  font-size: 1.1rem;
}

.sheet-price-value {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  min-width: 4ch;
  text-align: right;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.numpad button {
  min-height: var(--touch);
  border-radius: 12px;
  background: #eef5f0;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink);
}

.numpad button:active {
  background: #d8e8de;
}

.numpad-back {
  font-size: 1.2rem !important;
}

.numpad-spacer {
  visibility: hidden;
  pointer-events: none;
}

/* Câmera in-app */
.camera-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #0a120e;
  display: flex;
  flex-direction: column;
}

.camera-overlay[hidden] {
  display: none;
}

.camera-video {
  flex: 1;
  width: 100%;
  object-fit: cover;
  background: #000;
}

.camera-controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.1rem calc(1.1rem + var(--safe-bottom));
  background: rgba(10, 18, 14, 0.92);
}

.camera-cancel {
  justify-self: start;
  min-height: 44px;
  padding: 0 0.85rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 600;
}

.camera-shutter {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--citrus);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25);
  justify-self: center;
}

.camera-shutter:active {
  transform: scale(0.94);
  background: #f0f0f0;
}

.camera-spacer {
  width: 1px;
  height: 1px;
}

.qty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 1rem;
}

.qty-label {
  font-weight: 600;
  font-size: 0.95rem;
}

.qty-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.qty-btn {
  width: var(--touch);
  height: var(--touch);
  border-radius: 14px;
  background: var(--green-deep);
  color: #fff;
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1;
}

.qty-btn:active {
  background: var(--green-mid);
}

.qty-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  min-width: 2ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 0.65rem;
}

.btn-secondary,
.btn-primary {
  min-height: 52px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 1rem;
}

.btn-secondary {
  background: #e8eee9;
  color: var(--ink-muted);
}

.btn-primary {
  background: var(--green-deep);
  color: #fff;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary:active:not(:disabled) {
  background: var(--green-mid);
}

.btn-secondary:active {
  background: #d8e0da;
}

.sync-banner {
  position: fixed;
  top: var(--safe-top);
  left: 0;
  right: 0;
  z-index: 49;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  background: var(--green-deep);
  color: #fff;
}

.sync-banner[hidden] {
  display: none;
}

.room-hint {
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.9rem;
  margin: 0 0 1rem;
  line-height: 1.4;
}

.room-label {
  text-align: center;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin: 0 0 0.35rem;
}

.room-code {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-align: center;
  color: var(--green-deep);
  margin: 0 0 0.75rem;
}

.room-qr {
  display: block;
  margin: 0 auto 1rem;
  border-radius: 12px;
  background: #fff;
}

.room-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.room-active {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.room-active[hidden],
.room-actions[hidden] {
  display: none;
}

.room-join-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.room-input {
  min-height: 52px;
  border-radius: 14px;
  border: 2px solid #c5d6cb;
  padding: 0 0.85rem;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-align: center;
  color: var(--ink);
  background: #fff;
}

.room-close {
  width: 100%;
  margin-top: 0.25rem;
}

.scan-hint {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(1rem + var(--safe-top));
  z-index: 2;
  text-align: center;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  margin: 0;
  padding: 0 1rem;
}

@media (min-width: 480px) {
  .kpi-amount,
  .kpi-count {
    font-size: 2.1rem;
  }
}
