@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root{
  --ink: #12201A;
  --ink-soft: #4E5D55;
  --muted: #8A968E;
  --line: #E1E7E2;
  --bg: #F4F7F4;
  --card: #FFFFFF;
  --green: #2F7A4D;
  --green-deep: #1F5A38;
  --green-tint: #E4F1E8;
  --gold: #E3A21A;
  --gold-tint: #FBF0DA;
  --danger: #C4483A;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-card: 0 1px 2px rgba(18,32,26,0.06);
  --shadow-float: 0 10px 24px rgba(18,32,26,0.18);
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }

/* ---------- Transição de página estilo iOS (View Transitions API) ---------- */
@keyframes ticaai-slide-out{ to{ transform: translateX(-100%); } }
@keyframes ticaai-slide-in{ from{ transform: translateX(100%); } to{ transform: translateX(0); } }

::view-transition-old(root){
  animation: ticaai-slide-out 0.32s cubic-bezier(0.32, 0.72, 0, 1) both;
}
::view-transition-new(root){
  animation: ticaai-slide-in 0.32s cubic-bezier(0.32, 0.72, 0, 1) both;
}

body{
  margin:0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input{ font-family: inherit; }

/* Evita o zoom automático do iOS ao focar em campos de texto — Safari só evita
   o zoom quando o font-size do elemento focado é 16px ou mais. */
input, select, textarea{ font-size: 16px; }

#app{
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

.view{ flex:1; display:flex; flex-direction:column; padding-bottom: 100px; }
.view.no-nav{ padding-bottom: 0; }

h1,h2,h3{ font-family:'Sora', sans-serif; margin:0; }

/* ---------- Top bar ---------- */
.topbar{
  display:flex;
  align-items:center;
  gap:12px;
  padding:18px 20px 4px;
}
.topbar h2{ font-size:16px; font-weight:700; flex:1; }
.icon-btn{
  width:34px; height:34px;
  border-radius:50%;
  background:var(--card);
  border:none;
  box-shadow:var(--shadow-card);
  display:flex; align-items:center; justify-content:center;
  font-size:14px;
  cursor:pointer;
  color: var(--ink);
}
.wordmark{
  font-family:'Sora', sans-serif;
  font-weight:800;
  font-size:19px;
  color: var(--green-deep);
}

/* ---------- Botões ---------- */
.btn{
  border:none;
  border-radius:16px;
  padding:15px 0;
  font-family:'Sora', sans-serif;
  font-weight:700;
  font-size:14.5px;
  cursor:pointer;
  width:100%;
}
.btn-primary{ background: var(--green); color:#fff; box-shadow:0 10px 22px rgba(47,122,77,0.3); }
.btn-dark{ background: var(--ink); color:#fff; }
.btn-white{ background:#fff; color: var(--green-deep); }
.btn-ghost{ background:none; border:1.5px solid var(--line); color: var(--ink-soft); }
.btn:disabled{ opacity:0.55; cursor:not-allowed; }

/* ---------- Formulários ---------- */
.field{ margin-top:14px; }
.field label{ font-size:11.5px; color:var(--muted); font-weight:600; }
.field input, .field select{
  margin-top:6px;
  width:100%;
  background:var(--card);
  border:1px solid var(--line);
  border-radius:14px;
  padding:13px 15px;
  font-size:16px;
  color: var(--ink);
}
.field input:focus, .field select:focus{ outline:2px solid var(--green); outline-offset:1px; }
.error-msg{
  background:#FBEAE7; color:var(--danger);
  border-radius:12px; padding:10px 13px;
  font-size:12.5px; margin-top:14px;
}

/* ---------- Onboarding ---------- */
.onb-screen{
  flex:1;
  background: linear-gradient(165deg, var(--green) 0%, var(--green-deep) 100%);
  display:flex; flex-direction:column; align-items:center;
  padding: 0 28px;
  color:#fff;
}
.onb-illus{
  margin-top:64px; width:140px; height:140px; border-radius:36px;
  background:rgba(255,255,255,0.12);
  display:flex; align-items:center; justify-content:center;
}
.onb-title{ font-family:'Sora',sans-serif; font-weight:800; font-size:25px; text-align:center; margin-top:32px; }
.onb-sub{ font-size:13.5px; color:rgba(255,255,255,0.75); text-align:center; margin-top:10px; line-height:1.55; max-width:320px; }
.onb-screen .btn{ margin-top:auto; margin-bottom:36px; }

/* ---------- Login ---------- */
.login-body{ padding:0 26px; flex:1; display:flex; flex-direction:column; }
.login-logo{ margin-top:48px; display:flex; align-items:center; gap:10px; }
.login-title{ font-size:22px; font-weight:800; margin-top:26px; }
.login-sub{ font-size:13px; color:var(--ink-soft); margin-top:4px; }
.login-switch{ text-align:center; margin-top:18px; font-size:12.5px; color:var(--muted); }
.login-switch b{ color:var(--green-deep); cursor:pointer; }

/* ---------- Home hero ---------- */
.brand-row{
  position: sticky;
  top: 0;
  z-index: 15;
  display:flex; justify-content:space-between; align-items:center;
  margin: 0;
  padding: calc(14px + env(safe-area-inset-top)) 20px 12px;
  background: rgba(244,247,244,0.75);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(18,32,26,0.06);
}
.home-hero{
  margin:14px 20px 0;
  background: linear-gradient(160deg, var(--green) 0%, var(--green-deep) 100%);
  border-radius:22px; padding:20px 20px 22px; color:#fff;
}
.home-hero .label{ font-size:12.5px; color:rgba(255,255,255,0.75); }
.home-hero .place{ font-size:13.5px; font-weight:600; margin-top:2px; }
.home-hero .total{ font-family:'Sora',sans-serif; font-size:34px; font-weight:700; margin-top:12px; }
.home-hero .sub{ font-size:12.5px; color:rgba(255,255,255,0.8); margin-top:4px; }
.home-hero .btn{ margin-top:14px; }

.quick-row{ display:flex; justify-content:space-between; margin:18px 20px 4px; }
.quick{ display:flex; flex-direction:column; align-items:center; gap:7px; width:64px; background:none; border:none; cursor:pointer; }
.quick .ic{ width:46px; height:46px; border-radius:14px; display:flex; align-items:center; justify-content:center; font-size:18px; }
.quick span{ font-size:10.5px; color:var(--ink-soft); font-weight:500; text-align:center; }

.section-head{ display:flex; justify-content:space-between; align-items:baseline; margin:22px 20px 10px; }
.section-head h3{ font-size:15px; font-weight:700; }
.section-head a{ font-size:12px; color:var(--green); font-weight:600; cursor:pointer; }

.item-list, .cmp-list{ margin:0 20px; display:flex; flex-direction:column; gap:10px; }
.item-row, .hist-card, .mkt-row, .cmp-row{
  background:var(--card); border-radius:16px; padding:12px 14px;
  display:flex; align-items:center; gap:12px; box-shadow:var(--shadow-card);
}
.avatar, .mk-icon{
  width:38px; height:38px; border-radius:11px; display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:14px; color:#fff; flex-shrink:0; background: var(--green);
}
.item-row .info{ flex:1; min-width:0; }
.item-row .name{ font-size:13.5px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.item-row .qty{ font-size:11.5px; color:var(--muted); margin-top:1px; }
.item-row .price{ font-size:14px; font-weight:700; font-variant-numeric: tabular-nums; }

.empty-state{ margin:40px 20px; text-align:center; color:var(--muted); font-size:13px; }

/* ---------- Bottom nav (glass flutuante, estilo iOS) ---------- */
.bottom-nav{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: calc(100% - 32px);
  max-width: 448px;
  background: rgba(32,32,34,0.68);
  backdrop-filter: blur(26px) saturate(180%);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 28px;
  display:flex; justify-content:space-around; align-items:center;
  padding: 8px 6px;
  box-shadow: 0 14px 32px rgba(0,0,0,0.32);
  z-index:10;
}
.nav-btn{
  background:none; border:none;
  display:flex; flex-direction:column; align-items:center; gap:3px;
  color: rgba(255,255,255,0.5);
  font-size:10px; font-weight:600;
  cursor:pointer;
  padding: 7px 11px;
  border-radius: 16px;
  transition: background .2s ease, color .2s ease;
}
.nav-btn.active{ color:#fff; background: rgba(255,255,255,0.14); }
.nav-btn .nav-ic{ font-size:18px; display:flex; }
.fab-nav{
  width:56px; height:56px; border-radius:18px; background:var(--ink);
  display:flex; align-items:center; justify-content:center; margin-top:-30px;
  box-shadow: var(--shadow-float);
  border: none;
}

/* ---------- Scan ---------- */
.scan-screen{
  position: fixed;
  inset: 0;
  z-index: 50;
  height: 100vh;
  height: 100dvh; /* viewport dinâmico — desconta a barra de endereço do navegador mobile, evita sobra de conteúdo abaixo da tela */
  background:#000;
  display:flex;
  flex-direction:column;
}
.scan-video{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.scan-overlay{ position:relative; z-index:2; display:flex; flex-direction:column; height:100%; }
.scan-top{ display:flex; justify-content:space-between; padding:16px 20px 0; }
.scan-top .icon-btn{ background:rgba(255,255,255,0.16); color:#fff; box-shadow:none; }
.scan-title{ text-align:center; color:#fff; font-family:'Sora',sans-serif; font-weight:700; font-size:14.5px; margin-top:24px; }
.scan-sub{ text-align:center; color:rgba(255,255,255,0.65); font-size:12px; margin-top:4px; }
.viewfinder{ margin:26px auto 0; width:220px; height:130px; position:relative; }
.corner{ position:absolute; width:26px; height:26px; border:3px solid var(--gold); }
.corner.tl{ top:0; left:0; border-right:none; border-bottom:none; border-top-left-radius:8px; }
.corner.tr{ top:0; right:0; border-left:none; border-bottom:none; border-top-right-radius:8px; }
.corner.bl{ bottom:0; left:0; border-right:none; border-top:none; border-bottom-left-radius:8px; }
.corner.br{ bottom:0; right:0; border-left:none; border-top:none; border-bottom-right-radius:8px; }
.scan-sheet{
  margin-top:auto; background:#fff; border-radius:26px 26px 0 0; padding:18px 22px calc(24px + env(safe-area-inset-bottom));
  display:flex; flex-direction:column; align-items:center; gap:14px;
}
.scan-sheet p{ font-size:12.5px; color:var(--ink-soft); text-align:center; }
.shutter{ width:64px; height:64px; border-radius:50%; background:var(--green); border:5px solid var(--green-tint); box-shadow:0 8px 18px rgba(47,122,77,0.4); cursor:pointer; }
.shutter:disabled{ opacity:0.5; }

/* ---------- Confirmar ---------- */
.confirm-body{ padding:0 22px; flex:1; display:flex; flex-direction:column; }
.confirm-body .topbar{ padding-left:0; padding-right:0; }
.value-block{ text-align:center; margin-top:18px; }
.value-block .cap{ font-size:12px; color:var(--muted); }
.value-input-wrap{ display:flex; align-items:baseline; justify-content:center; gap:6px; margin-top:6px; }
.value-input-wrap .prefix{ font-size:22px; color:var(--muted); font-family:'Sora',sans-serif; font-weight:700; }
.value-input-wrap input{
  border:none; background:none; text-align:center;
  font-family:'Sora',sans-serif; font-size:40px; font-weight:700; color:var(--ink);
  width:160px;
}
.value-input-wrap input:focus{ outline:none; }
.ocr-tag{ display:inline-flex; align-items:center; gap:6px; margin-top:6px; background:var(--gold-tint); color:#8A6110; font-size:11px; font-weight:600; padding:5px 11px; border-radius:20px; }
.field-row{ display:flex; gap:10px; margin-top:20px; }
.stepper{ display:flex; align-items:center; justify-content:space-between; margin-top:6px; }
.stepper button{ width:24px; height:24px; border-radius:8px; background:var(--green-tint); color:var(--green-deep); border:none; font-weight:700; font-size:14px; cursor:pointer; }
.stepper span{ font-weight:700; font-size:14px; }

/* ---------- Mercado ---------- */
.mkt-body{ padding:0 20px; flex:1; display:flex; flex-direction:column; }
.mkt-row{ margin-bottom:9px; cursor:pointer; }
.mkt-row.selected{ border:1.5px solid var(--green); }
.mkt-row .mk-name{ font-size:13px; font-weight:600; flex:1; }
.mkt-row .check{ color:var(--green); font-weight:700; }
.mkt-new{ margin-top:14px; border:1.5px dashed var(--line); border-radius:16px; padding:14px; text-align:center; font-size:13px; font-weight:600; color:var(--green-deep); background:none; cursor:pointer; }
.mkt-section{ font-size:11.5px; color:var(--muted); font-weight:600; margin:16px 0 8px; }

/* ---------- Histórico ---------- */
.hist-summary{ margin:16px 20px 0; display:flex; gap:10px; }
.hist-summary .box{ flex:1; background:var(--card); border-radius:16px; padding:13px 14px; box-shadow:var(--shadow-card); }
.hist-summary .box .cap{ font-size:10.5px; color:var(--muted); }
.hist-summary .box .val{ font-family:'Sora',sans-serif; font-size:17px; font-weight:700; margin-top:3px; }
.hist-summary .box .val.up{ color:var(--danger); }
.hist-summary .box .val.down{ color:var(--green-deep); }
.hist-group-label{ margin:20px 20px 8px; font-size:11.5px; font-weight:600; color:var(--muted); }
.hist-card{ margin:0 20px 10px; cursor:pointer; }
.hist-card .mk-icon{ background:var(--green-tint); color:var(--green-deep); }
.hist-card .mk-info{ flex:1; }
.hist-card .mk-name{ font-size:13.5px; font-weight:600; }
.hist-card .mk-meta{ font-size:11px; color:var(--muted); margin-top:2px; }
.hist-card .mk-total{ text-align:right; }
.hist-card .mk-total .price{ font-size:14.5px; font-weight:700; }
.hist-card .mk-total .count{ font-size:10.5px; color:var(--muted); margin-top:2px; }

/* ---------- Recibo / Detalhe ---------- */
.rcpt-body{ padding:0 22px; flex:1; display:flex; flex-direction:column; }
.rcpt-head{ text-align:center; margin-top:18px; }
.rcpt-check{ width:52px; height:52px; border-radius:50%; background:var(--green-tint); color:var(--green-deep); display:flex; align-items:center; justify-content:center; margin:0 auto 12px; font-size:22px; }
.rcpt-head h3{ font-size:17px; font-weight:700; }
.rcpt-head p{ font-size:12px; color:var(--muted); margin-top:3px; }
.rcpt-list{ margin-top:18px; display:flex; flex-direction:column; gap:2px; }
.rcpt-item{ display:flex; justify-content:space-between; padding:9px 0; border-bottom:1px solid var(--line); }
.rcpt-item .nm{ font-size:12.5px; font-weight:600; }
.rcpt-item .qt{ font-size:10.5px; color:var(--muted); margin-top:1px; }
.rcpt-item .pr{ font-size:12.5px; font-weight:700; align-self:center; }
.rcpt-totals{ margin-top:14px; display:flex; flex-direction:column; gap:6px; }
.rcpt-totals .row{ display:flex; justify-content:space-between; font-size:12px; color:var(--ink-soft); }
.rcpt-totals .row.total{ font-size:16px; font-weight:800; color:var(--ink); font-family:'Sora',sans-serif; margin-top:4px; }
.rcpt-body .btn{ margin-top:16px; }

/* ---------- Comparação ---------- */
.cmp-body{ padding:0 20px; flex:1; }
.cmp-search{ position:relative; }
.cmp-search input{ width:100%; background:var(--card); border:1px solid var(--line); border-radius:14px; padding:12px 14px; font-size:16px; box-shadow:var(--shadow-card); }
.cmp-suggestions{ margin-top:6px; background:var(--card); border-radius:14px; box-shadow:var(--shadow-card); overflow:hidden; }
.cmp-suggestions div{ padding:11px 14px; font-size:13px; cursor:pointer; border-bottom:1px solid var(--line); }
.cmp-suggestions div:last-child{ border-bottom:none; }
.cmp-product{ margin-top:18px; display:flex; align-items:center; gap:12px; }
.cmp-product .thumb{ width:52px; height:52px; border-radius:14px; background:var(--gold-tint); display:flex; align-items:center; justify-content:center; font-size:20px; }
.cmp-product .name{ font-family:'Sora',sans-serif; font-size:15px; font-weight:700; }
.cmp-product .meta{ font-size:11.5px; color:var(--muted); margin-top:2px; }
.cmp-row{ position:relative; margin-top:0; }
.cmp-row.best{ border:1.5px solid var(--green); }
.cmp-row .rank{ width:26px; height:26px; border-radius:8px; background:var(--bg); color:var(--ink-soft); display:flex; align-items:center; justify-content:center; font-size:11.5px; font-weight:700; flex-shrink:0; }
.cmp-row.best .rank{ background:var(--green); color:#fff; }
.cmp-row .cmp-info{ flex:1; }
.cmp-row .cmp-mk{ font-size:13px; font-weight:600; }
.cmp-row .cmp-date{ font-size:10.5px; color:var(--muted); margin-top:1px; }
.cmp-row .cmp-price{ font-size:14.5px; font-weight:700; }
.best-badge{ position:absolute; top:-9px; right:14px; background:var(--green); color:#fff; font-size:9.5px; font-weight:700; padding:3px 9px; border-radius:20px; }

.loading{ text-align:center; color:var(--muted); font-size:13px; margin:30px 0; }
.toast{
  position:fixed; bottom:100px; left:50%; transform:translateX(-50%);
  background:var(--ink); color:#fff; padding:11px 18px; border-radius:14px;
  font-size:12.5px; z-index:50; box-shadow:var(--shadow-float);
}

/* ---------- Swipe-to-reveal (editar/excluir, estilo iOS) ---------- */
.swipe-row{
  position: relative;
  overflow: hidden;
  border-radius: 16px;
}
.swipe-actions{
  position: absolute;
  top: 0; right: 0;
  height: 100%;
  display: flex;
}
.swipe-btn{
  width: 72px;
  height: 100%;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
}
.swipe-btn .ic{ font-size: 16px; }
.swipe-edit{ background: #3B5A9A; }
.swipe-delete{ background: var(--danger); }
.swipe-content{
  position: relative;
  z-index: 1;
  background: var(--card);
  border-radius: 16px;
  touch-action: pan-y;
  will-change: transform;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.swipe-content.dragging{ transition: none; }
.swipe-content > *{ border-radius: inherit; }

/* ---------- Modal estilo iOS (Liquid Glass) ---------- */
@keyframes modal-fade-in{ from{ opacity:0; } to{ opacity:1; } }
@keyframes modal-fade-out{ from{ opacity:1; } to{ opacity:0; } }
@keyframes modal-pop-in{
  0%{ opacity:0; transform:scale(0.85); }
  60%{ opacity:1; transform:scale(1.025); }
  100%{ opacity:1; transform:scale(1); }
}
@keyframes modal-pop-out{
  from{ opacity:1; transform:scale(1); }
  to{ opacity:0; transform:scale(0.92); }
}
.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 32px;
  animation: modal-fade-in 0.28s ease-out;
}
.modal-backdrop.closing{
  animation: modal-fade-out 0.22s ease-in forwards;
}
.modal-card{
  width: 100%;
  max-width: 300px;
  background: rgba(44,44,46,0.72);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 26px;
  overflow: hidden;
  text-align: center;
  box-shadow: var(--shadow-float);
  padding: 22px 18px 18px;
  animation: modal-pop-in 0.36s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.modal-backdrop.closing .modal-card{
  animation: modal-pop-out 0.22s ease-in forwards;
}
.modal-title{
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  margin-bottom: 6px;
}
.modal-message{
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  padding: 0 4px;
  line-height: 1.45;
  margin-bottom: 18px;
}
.modal-fields{ padding: 2px 2px 16px; text-align: left; }
.modal-fields label{ color: rgba(255,255,255,0.55); }
.modal-buttons-row{ display: flex; gap: 10px; }
.modal-btn{
  flex: 1;
  border: none;
  background: rgba(255,255,255,0.14);
  border-radius: 999px;
  padding: 13px 0;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
}
.modal-btn.destructive{ color: #FF6B5B; }
.modal-btn.cancel{ font-weight: 700; }