
:root {
  --bg: #0B1120; --s1: #1E293B; --s2: #334155; --s3: #475569;
  --border: rgba(255,255,255,0.08); --border2: rgba(255,255,255,0.15);
  --teal: #0EA5E9; --teal2: #38BDF8; --blue: #0284C7; --blue2: #7DD3FC;
  --ok: #10B981; --warn: #F59E0B; --danger: #EF4444;
  --text: #F8FAFC; --text2: #94A3B8; --text3: #64748B;
  --nav: 72px; --r: 12px; --r2: 16px; --r3: 24px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --glass: rgba(255,255,255,0.05);
}

[data-theme="light"] {
  --bg: #F1F5F9; --s1: #FFFFFF; --s2: #E2E8F0; --s3: #CBD5E1;
  --border: rgba(0,0,0,0.06); --border2: rgba(0,0,0,0.1);
  --text: #0F172A; --text2: #475569; --text3: #64748B;
  --teal: #0284C7; --teal2: #0EA5E9;
  --glass: rgba(255,255,255,0.8);
}

/* Modo Privacidade */
body.wife-mode .price-val, 
body.wife-mode .adm-price, 
body.wife-mode #adm-preco { 
  display: none !important; 
}
body.wife-mode .item-price-placeholder::after {
  content: "—"; color: var(--text3);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
html, body { height: 100%; overflow: hidden; background: var(--bg); transition: background 0.3s ease, color 0.3s ease; }
body { font-family: 'Plus Jakarta Sans', sans-serif; color: var(--text); display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; width: 100%; position: relative; letter-spacing: -0.01em; line-height: 1.5; background: var(--bg); }
i.ph, i.ph-fill, i.ph-bold { display: inline-flex; align-items: center; justify-content: center; line-height: 1; }

/* Scrollbar styling for desktop */
@media (min-width: 768px) {
  ::-webkit-scrollbar { width: 8px; height: 8px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
  ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
}

/* Skeleton Screen */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--s1) 25%, var(--s2) 50%, var(--s1) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--r);
}

/* Focus-visible for accessibility */
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* Smooth selection */
::selection { background: rgba(14,165,233,0.3); color: var(--text); }

.app-shell { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.scroll-body { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; scroll-behavior: smooth; }
.scroll-body::-webkit-scrollbar { display: none; }

/* Visibility Utils */
.desktop-only { display: none !important; }
.mobile-only { display: flex !important; }
@media (min-width: 768px) {
  .desktop-only { display: flex !important; }
  .mobile-only { display: none !important; }
}

/* Topbar */
.topbar { flex-shrink: 0; padding: calc(var(--safe-top) + 16px) 20px 12px; display: flex; align-items: center; justify-content: space-between; background: var(--bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-bottom: 1px solid var(--border); position: relative; z-index: 50; transition: background 0.3s; }
.topbar-l { display: flex; align-items: center; gap: 12px; }
.app-date { font-size: .65rem; font-weight: 600; color: var(--text2); margin-top: 2px; letter-spacing: 0.02em; }
.topbar-r { display: flex; align-items: center; gap: 10px; }
.top-btn { min-width: 44px; min-height: 44px; border-radius: 12px; background: var(--glass); border: 1px solid var(--border2); display: grid; place-items: center; font-size: 20px; cursor: pointer; transition: background .15s; flex-shrink: 0; }
.top-btn:active { background: var(--border2); }
#btnAdmin { box-shadow: 0 0 15px rgba(245,158,11,0.15); border-color: rgba(245,158,11,0.3); }
#btnAdmin:hover { box-shadow: 0 0 20px rgba(245,158,11,0.25); border-color: rgba(245,158,11,0.5); }

/* Bottom Nav */
.bnav { flex-shrink: 0; display: flex; align-items: stretch; height: calc(var(--nav) + var(--safe-bot)); padding-bottom: var(--safe-bot); background: var(--bg); backdrop-filter: blur(24px); border-top: 1px solid var(--border); position: relative; z-index: 50; }
.nb { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: none; border: none; cursor: pointer; color: var(--text3); transition: color .15s; min-height: 44px; }
.nb.on { color: var(--teal); }
.ni { font-size: 1.5rem; transition: transform .18s; }
.nb.on .ni { transform: translateY(-2px); }
.nl { font-size: .6rem; font-weight: 700; letter-spacing: .2px; }
.nb-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; background: none; border: none; cursor: pointer; padding: 0; gap: 4px; }
.cam-ball { width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, var(--teal), var(--blue)); display: grid; place-items: center; font-size: 1.6rem; color: white; margin-top: -24px; box-shadow: 0 6px 16px rgba(14,165,233,0.4); transition: transform .2s; }
.nb-center.on .cam-ball { transform: scale(1.05); }
.nb-center .nl { font-size: .6rem; font-weight: 700; color: var(--teal2); }

/* Pages */
.page { display: none; padding: 0 0 24px; animation: pgin .2s ease; }
.page.active { display: block; }
@keyframes pgin { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.sh { display: flex; align-items: center; justify-content: space-between; padding: 24px 20px 12px; }
.sh-title { font-size: .8rem; font-weight: 800; color: var(--text); letter-spacing: 0.06em; text-transform: uppercase; }
.sh-action { font-size: .75rem; font-weight: 700; color: var(--teal); cursor: pointer; transition: color .15s, transform .15s; }
.sh-action:hover { color: var(--teal2); }
.sh-action:active { transform: scale(.95); }

/* Hero */
.tank-hero { position: relative; height: 260px; overflow: hidden; background-image: url('https://images.unsplash.com/photo-1546026423-cc46426ba658?q=80&w=1000&auto=format&fit=crop'); background-size: cover; background-position: center; border-radius: 0 0 var(--r3) var(--r3); margin-bottom: 8px; }
.hero-img-overlay { position: absolute; inset: 0; background: linear-gradient(to top, var(--bg) 0%, rgba(11,17,32,0.4) 60%, transparent 100%); }
.hero-content { position: absolute; bottom: 0; left: 0; right: 0; padding: 20px 20px 16px; }
.hero-tank-name { font-size: 2rem; font-weight: 900; letter-spacing: -0.03em; text-shadow: 0 2px 10px rgba(0,0,0,.8); line-height: 1.15; }
.hero-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.hero-meta-pill { height: 28px; padding: 0 12px; border-radius: 999px; font-size: .7rem; font-weight: 700; display: flex; align-items: center; gap: 6px; backdrop-filter: blur(12px); background: rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.2); }
.hero-status-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.status-pill { height: 32px; padding: 0 14px; border-radius: 999px; font-size: .75rem; font-weight: 700; display: flex; align-items: center; gap: 6px; border: 1px solid; }
.sp-ok { background: rgba(16,185,129,.2); border-color: var(--ok); color: var(--ok); }
.sp-warn { background: rgba(245,158,11,.2); border-color: var(--warn); color: var(--warn); }
.sp-bad { background: rgba(239,68,68,.2); border-color: var(--danger); color: var(--danger); }
.sp-n { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.2); color: var(--text); }

/* Cards & Stats */
.qstats { display: flex; gap: 10px; padding: 10px 20px; }
.qs { flex: 1; background: var(--s1); padding: 14px 10px; border-radius: var(--r2); border: 1px solid var(--border); text-align: center; }
.qs-v { font-size: 1.3rem; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.qs-v.ok { color: var(--ok); } .qs-v.warn { color: var(--warn); } .qs-v.bad { color: var(--danger); } .qs-v.n { color: var(--text3); }
.qs-l { font-size: .6rem; color: var(--text2); text-transform: uppercase; letter-spacing: .8px; margin-top: 6px; font-weight: 600; }

/* Insight */
.insight-box { margin: 14px 20px; border-radius: var(--r2); overflow: hidden; border: 1px solid rgba(14,165,233,.3); background: var(--s1); }
.ib-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 0; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); flex-shrink: 0; animation: pd 2s infinite; }
@keyframes pd { 0%, 100% { box-shadow: 0 0 0 0 rgba(14,165,233,.5); } 60% { box-shadow: 0 0 0 7px rgba(14,165,233,0); } }
.ib-label { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; color: var(--teal2); }
.ib-body { padding: 12px 16px 16px; font-size: .85rem; color: var(--text2); line-height: 1.65; }
.tip-row { border-left: 3px solid; padding: 10px 14px; border-radius: 0 8px 8px 0; margin-top: 8px; font-size: .8rem; line-height: 1.55; color: var(--text); background: rgba(255,255,255,0.03); }
.tr-ok { border-color: var(--ok); } .tr-warn { border-color: var(--warn); } .tr-bad { border-color: var(--danger); }

/* Params */
.param-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 20px; }
.pc { padding: 18px; position: relative; overflow: hidden; border-radius: var(--r2); background: var(--s1); border: 1px solid var(--border); transition: transform 0.2s, box-shadow 0.2s; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.pc:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.2); border-color: var(--border2); }
.pc::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; border-radius: 4px 0 0 4px; }
.pc.ok::before { background: linear-gradient(to bottom, var(--ok), #059669); } 
.pc.warn::before { background: linear-gradient(to bottom, var(--warn), #d97706); } 
.pc.bad::before { background: linear-gradient(to bottom, var(--danger), #dc2626); } 
.pc.n::before { background: var(--text3); }
.pc-l { font-size: .7rem; font-weight: 800; color: var(--text2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.pc-v { font-size: 1.8rem; font-weight: 900; margin: 0; line-height: 1; display: inline-block; letter-spacing: -0.04em; }
.pc-v.ok { color: var(--text); } .pc-v.warn { color: var(--warn); } .pc-v.bad { color: var(--danger); } .pc-v.n { color: var(--text); }
.pc-t { font-size: .75rem; color: var(--text3); font-weight: 700; margin-left: 4px; display: inline-block; }

/* Quests Strip */
.quest-strip { margin: 14px 20px; padding: 16px; border-radius: var(--r2); background: linear-gradient(135deg, rgba(14,165,233,.1), rgba(2,132,199,.1)); border: 1px solid rgba(14,165,233,.3); cursor: pointer; }
.qs-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.qs-title { font-size: .85rem; font-weight: 800; color: var(--teal2); }
.qs-cnt { font-size: .8rem; font-weight: 700; color: var(--text); }
.qs-bar { height: 8px; border-radius: 999px; background: rgba(0,0,0,.3); overflow: hidden; margin-bottom: 10px; }
.qs-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--teal), var(--blue2)); transition: width .5s ease; }
.qs-next { font-size: .75rem; color: var(--text2); display: flex; align-items: center; gap: 6px; }
.qs-next strong { color: var(--text); }

/* Coral Library */
.coral-library-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 0 20px; }
.cl-card { border-radius: 20px; overflow: hidden; aspect-ratio: 0.85 / 1; position: relative; cursor: pointer; border: 1px solid var(--border); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.cl-card:active { transform: scale(.96); }
.cl-card:hover { border-color: var(--teal); transform: translateY(-4px); box-shadow: 0 12px 30px rgba(0,0,0,0.4); }
.cl-img { width: 100%; height: 100%; object-fit: cover; display: block; background: var(--s2); }
.cl-img-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; background: var(--s2); color: var(--text3); }
.cl-overlay { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, rgba(0,0,0,.9) 100%); }
.cl-info { position: absolute; bottom: 0; left: 0; right: 0; padding: 14px; }
.cl-name { font-size: .95rem; font-weight: 800; color: #fff; letter-spacing: -0.2px; }
.cl-type { font-size: .7rem; font-weight: 700; margin-top: 4px; }
.cl-type.sps { color: #93c5fd; } .cl-type.lps { color: #6ee7b7; } .cl-type.soft { color: #c4b5fd; }


.spin { width: 36px; height: 36px; border-radius: 50%; border: 3px solid rgba(255,255,255,.07); border-top-color: var(--teal); margin: 0 auto 12px; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* Bottom Sheet */
.sheet-ov { position: fixed; inset: 0; background: rgba(0,0,0,.8); z-index: 400; opacity: 0; pointer-events: none; transition: opacity .25s; backdrop-filter: blur(8px); }
.sheet-ov.on { opacity: 1; pointer-events: all; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 480px; margin: 0 auto; z-index: 401; background: var(--bg); border-radius: var(--r3) var(--r3) 0 0; border-top: 1px solid var(--border2); transform: translateY(100%); transition: transform .32s cubic-bezier(.4,0,.2,1); max-height: 90vh; display: flex; flex-direction: column; padding-bottom: var(--safe-bot); }
.sheet.on { transform: translateY(0); }
.sheet-handle { width: 48px; height: 6px; border-radius: 999px; background: var(--text3); margin: 16px auto 0; flex-shrink: 0; }
.sheet-scroll { overflow-y: auto; flex: 1; padding: 20px 24px 30px; }
.sheet-scroll::-webkit-scrollbar { display: none; }
.sheet-hero, .sheet-hero-placeholder { width: 100%; height: 220px; border-radius: var(--r2); margin-bottom: 20px; border: 1px solid var(--border); }
.sheet-hero { object-fit: cover; background: var(--s2); }
.sheet-hero-placeholder { background: var(--s1); display: flex; align-items: center; justify-content: center; font-size: 5rem; color: var(--text3); }
.sheet-name { font-size: 1.6rem; font-weight: 900; letter-spacing: -0.03em; line-height: 1.2; }
.sheet-sci { font-size: .9rem; font-style: italic; color: var(--text2); margin-top: 4px; }
.sheet-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 20px; }
.chip { height: 30px; padding: 0 14px; border-radius: 999px; font-size: .7rem; font-weight: 800; display: inline-flex; align-items: center; gap: 6px; }
.ch-sps { background: rgba(59,130,246,.15); color: var(--blue2); border: 1px solid rgba(59,130,246,.3); }
.ch-lps { background: rgba(14,165,233,.15); color: var(--teal2); border: 1px solid rgba(14,165,233,.3); }
.ch-soft { background: rgba(139,92,246,.15); color: #c4b5fd; border: 1px solid rgba(139,92,246,.3); }
.ch-gray { background: rgba(255,255,255,.08); color: var(--text2); border: 1px solid rgba(255,255,255,.15); }

/* STOCK & DOSING STYLES */
.stock-grid, .dosing-grid { display: grid; grid-template-columns: 1fr; gap: 16px; padding: 0 20px 20px; }
@media (min-width: 768px) {
  .stock-grid, .dosing-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}

.item-card { background: var(--s1); border: 1px solid var(--border); border-radius: var(--r2); padding: 16px; position: relative; overflow: hidden; transition: transform .2s, border-color .2s; }
.item-card:active { transform: scale(.98); }
.item-card.low-stock { border-color: rgba(239,68,68,0.4); }

.item-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.item-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--s2); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: var(--teal2); }
.item-info { flex: 1; min-width: 0; }
.item-title { font-size: .95rem; font-weight: 800; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: .75rem; color: var(--text2); margin-top: 2px; }

.progress-wrap { margin-top: 12px; }
.progress-meta { display: flex; justify-content: space-between; font-size: .7rem; font-weight: 700; color: var(--text3); margin-bottom: 6px; }
.progress-bar { height: 8px; background: var(--glass); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--teal), var(--blue)); transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.progress-fill.warn { background: linear-gradient(90deg, var(--warn), #fbbf24); }
.progress-fill.crit { background: linear-gradient(90deg, var(--danger), #f87171); }

.dose-action { width: 100%; height: 42px; margin-top: 16px; border-radius: 10px; border: 1px solid var(--teal); background: rgba(14,165,233,0.1); color: var(--teal2); font-weight: 800; font-size: .85rem; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; transition: all .15s; }
.dose-action:active { background: var(--teal); color: white; }

.status-badge { position: absolute; top: 16px; right: 16px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: .65rem; font-weight: 800; display: flex; align-items: center; background: var(--glass); color: var(--text3); }
.status-badge.active { background: rgba(16,185,129,0.15); color: #10b981; }

.tab-nav { display: flex; gap: 8px; padding: 0 20px 16px; overflow-x: auto; scrollbar-width: none; }
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn { height: 36px; padding: 0 16px; border-radius: 999px; background: var(--s1); border: 1px solid var(--border); color: var(--text2); font-size: .75rem; font-weight: 700; white-space: nowrap; cursor: pointer; transition: all .2s; }
.tab-btn.on { background: var(--teal); color: white; border-color: var(--teal); }

/* Switch Toggle */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background-color: var(--s2); transition: .3s; border-radius: 24px; border: 1px solid var(--border2); }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 2px; bottom: 2px; background-color: white; transition: .3s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
input:checked + .slider { background-color: var(--teal); border-color: var(--teal); }
input:checked + .slider:before { transform: translateX(20px); }

.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 0 20px 20px; }
.qa-card { background: var(--s1); border: 1px solid var(--border); border-radius: var(--r2); padding: 16px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.qa-icon { font-size: 1.5rem; color: var(--teal2); }
.qa-lbl { font-size: .85rem; font-weight: 800; }
.qa-sub { font-size: .7rem; color: var(--text3); }

.sheet-sec { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text2); margin: 24px 0 12px; display: flex; align-items: center; gap: 8px; }
.care-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.care-item { background: var(--s1); border: 1px solid var(--border); border-radius: var(--r2); padding: 16px; }
.care-ico { font-size: 1.4rem; margin-bottom: 8px; color: var(--teal2); }
.care-lbl { font-size: .65rem; text-transform: uppercase; letter-spacing: .8px; font-weight: 700; color: var(--text2); }
.care-val { font-size: .95rem; font-weight: 800; margin-top: 4px; color: var(--text); }
.vrow { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; font-size: .85rem; line-height: 1.55; color: var(--text); }
.vdot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }

/* Scan */
#fi-cam, #fi-gal { display: none; }
.scan-opts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 0 20px; margin-bottom: 20px; }
.scan-opt { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 130px; border-radius: var(--r3); border: 2px dashed var(--border2); background: rgba(255,255,255,.02); cursor: pointer; padding: 20px; transition: all .2s; }
.scan-opt:hover { border-color: var(--teal); background: rgba(14,165,233,.05); transform: translateY(-2px); }
.so-ico { font-size: 2.5rem; color: var(--teal2); }
.so-lbl { font-size: .95rem; font-weight: 800; }
.so-sub { font-size: .7rem; color: var(--text2); }
.prev-wrap { position: relative; padding: 0 20px; margin-bottom: 16px; }
.prev-img { width: 100%; max-height: 300px; object-fit: cover; border-radius: var(--r3); display: none; border: 1px solid var(--border2); }
.scan-corners { position: absolute; inset: 0; border-radius: var(--r3); pointer-events: none; display: none; }
.sc { position: absolute; width: 30px; height: 30px; border-color: var(--teal); border-style: solid; border-width: 0; }
.sc.tl { top: 16px; left: 36px; border-top-width: 4px; border-left-width: 4px; border-radius: 8px 0 0 0; }
.sc.tr { top: 16px; right: 36px; border-top-width: 4px; border-right-width: 4px; border-radius: 0 8px 0 0; }
.sc.bl { bottom: 16px; left: 36px; border-bottom-width: 4px; border-left-width: 4px; border-radius: 0 0 0 8px; }
.sc.br { bottom: 16px; right: 36px; border-bottom-width: 4px; border-right-width: 4px; border-radius: 0 0 8px 0; }
.close-prev { position: absolute; top: 16px; right: 36px; width: 38px; height: 38px; border-radius: 50%; background: rgba(0,0,0,.7); border: 1px solid var(--border2); display: none; place-items: center; font-size: 18px; cursor: pointer; color: var(--text); z-index: 5; }

/* Scan dynamic states */
.prev-wrap.show .prev-img { display: block; }
.prev-wrap.show #closePrev { display: grid; }
.scan-corners.scanning { display: block; }
.spin-box.show { display: block; }
.filter-btn { position: absolute; bottom: 16px; right: 36px; width: 44px; height: 44px; border-radius: 50%; background: rgba(0,0,0,.7); border: 1px solid var(--border2); display: none; place-items: center; font-size: 20px; cursor: pointer; color: var(--text); z-index: 5; transition: all .2s; }
.filter-btn.active { background: rgba(14,165,233,.3); border-color: var(--teal); color: var(--teal2); }
.prev-wrap.show .filter-btn { display: grid; }
.analyze-wrap.show { display: block; }

/* Spin Box — 3 steps */
.spin-box { display: none; text-align: center; padding: 36px 20px; margin: 0 20px; background: var(--s1); border-radius: var(--r3); border: 1px solid var(--border); }
.spin-box-title { font-size: .88rem; font-weight: 600; color: var(--text2); margin-bottom: 20px; }
.spin-steps { display: flex; flex-direction: column; gap: 4px; }
.spin-steps .step {
  font-size: .8rem; color: var(--text3); font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px;
  transition: all .35s ease;
}
.spin-steps .step.on {
  color: var(--teal2); font-weight: 800;
  background: rgba(14,165,233,.1); border: 1px solid rgba(14,165,233,.2);
}
.spin-steps .step.done { color: var(--ok); }

.ai-result-card { display: none; margin: 0 20px 20px; padding: 20px; border-radius: var(--r3); border: 1px solid rgba(14,165,233,.3); background: linear-gradient(135deg, rgba(14,165,233,.08), rgba(2,132,199,.05)); }
.ar-name { font-size: 1.25rem; font-weight: 900; margin-bottom: 10px; letter-spacing: -0.02em; line-height: 1.2; }
.ar-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.health-score { border-radius: var(--r2); padding: 16px 20px; margin-bottom: 16px; border: 1px solid; }
.hs-good { background: rgba(16,185,129,.1); border-color: rgba(16,185,129,.3); }
.hs-warn { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.3); }
.hs-bad { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.3); }
.hs-row { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.hs-emoji { font-size: 2.2rem; }
.hs-num { font-size: 2.4rem; font-weight: 900; line-height: 1; letter-spacing: -0.03em; }
.hs-lbl { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; margin-bottom: 4px; }
.hs-bar { height: 8px; border-radius: 999px; background: rgba(255,255,255,.1); overflow: hidden; }
.hs-fill { height: 100%; border-radius: 999px; transition: width .7s ease; }
.btn-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.btn { min-height: 56px; border-radius: 16px; font-weight: 800; font-size: .95rem; cursor: pointer; border: none; display: flex; align-items: center; justify-content: center; gap: 8px; transition: transform .15s cubic-bezier(.4,0,.2,1), opacity .15s, box-shadow .2s; font-family: inherit; width: 100%; letter-spacing: 0.01em; }
.btn:active { transform: scale(.97); opacity: .85; }
.btn-p { background: linear-gradient(135deg, var(--blue), var(--teal)); color: white; box-shadow: 0 6px 20px rgba(14,165,233,.25); }
.btn-p:hover { box-shadow: 0 8px 28px rgba(14,165,233,.35); }
.btn-s { background: rgba(255,255,255,.05); border: 1px solid var(--border2); color: var(--text); }
.btn-s:hover { background: rgba(255,255,255,.08); }
.analyze-wrap { padding: 0 20px; margin-bottom: 16px; display: none; }

/* Forms */
.form-pad { padding: 0 20px; }
.form-card { background: var(--s1); border: 1px solid var(--border); border-radius: var(--r3); padding: 20px; margin-bottom: 16px; }
.fg { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fi { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.fi:last-child { margin-bottom: 0; }
.fi label { font-size: .7rem; font-weight: 800; color: var(--text2); text-transform: uppercase; letter-spacing: .8px; }
.fi input, .fi select, .fi textarea { width: 100%; min-height: 52px; border-radius: 14px; border: 1px solid var(--border2); background: var(--bg); color: var(--text); padding: 0 16px; outline: none; font-size: 1rem; transition: border-color .2s; -webkit-appearance: none; font-family: inherit; }
.fi textarea { min-height: 100px; resize: none; padding: 14px 16px; line-height: 1.5; }
.fi input:focus, .fi select:focus, .fi textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14,165,233,.15); }
.form-foot { position: sticky; bottom: 0; padding: 16px 20px calc(12px + var(--safe-bot)); background: linear-gradient(0deg, var(--bg) 80%, transparent); margin-top: 10px; }

/* Diary */
.diary-item { margin: 0 20px 14px; padding: 18px; border-radius: var(--r2); background: var(--s1); border: 1px solid var(--border); }
.di-hd { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.di-date { font-size: .9rem; font-weight: 800; color: var(--text); }
.di-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.di-tag { height: 22px; padding: 0 10px; border-radius: 999px; font-size: .65rem; font-weight: 800; background: rgba(14,165,233,.15); color: var(--teal2); display: flex; align-items: center; gap: 4px; border: 1px solid rgba(14,165,233,.3); }
.pm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.pm-cell { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; text-align: center; padding: 10px 6px; }
.pm-cell .la { font-size: .6rem; font-weight: 700; color: var(--text3); text-transform: uppercase; display: block; margin-bottom: 4px; }
.pm-cell .va { font-size: .9rem; font-weight: 800; }
.di-obs { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; font-size: .8rem; color: var(--text2); font-style: italic; display: flex; gap: 8px; align-items: flex-start; }
.badge-pill { height: 26px; padding: 0 12px; border-radius: 999px; font-size: .65rem; font-weight: 800; display: inline-flex; align-items: center; border: 1px solid; }
.bp-ok { background: rgba(16,185,129,.1); color: var(--ok); border-color: rgba(16,185,129,.3); }
.bp-warn { background: rgba(245,158,11,.1); color: var(--warn); border-color: rgba(245,158,11,.3); }
.bp-bad { background: rgba(239,68,68,.1); color: var(--danger); border-color: rgba(239,68,68,.3); }

/* Quests */
.quest-trail { margin: 0 20px 16px; padding: 20px; border-radius: var(--r3); background: var(--s1); border: 1px solid var(--border); }
.qt-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.qt-nm { font-size: 1rem; font-weight: 800; color: var(--text); }
.qt-prog { font-size: .8rem; font-weight: 800; color: var(--teal2); }
.qt-bar-bg { height: 8px; border-radius: 999px; background: rgba(255,255,255,.05); overflow: hidden; margin-bottom: 20px; }
.qt-bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--teal), var(--blue)); transition: width .5s; }
.qt-item { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.qt-item:last-child { border-bottom: none; padding-bottom: 0; }
.qt-ico-box { width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0; display: grid; place-items: center; font-size: 1.5rem; background: var(--bg); border: 1px solid var(--border2); transition: all .2s; color: var(--text3); }
.qt-ico-box.done { background: rgba(14,165,233,.15); border-color: rgba(14,165,233,.4); color: var(--teal2); }
.qt-text { flex: 1; }
.qt-title { font-size: .9rem; font-weight: 700; }
.qt-desc { font-size: .7rem; color: var(--text2); margin-top: 4px; }

/* More (Config) */
.more-section { margin: 0 20px 16px; padding: 20px; border-radius: var(--r3); background: var(--s1); border: 1px solid var(--border); }
.cfg-field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.cfg-field label { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; color: var(--text2); }
.cfg-input { min-height: 52px; border-radius: 14px; border: 1px solid var(--border2); background: var(--bg); color: var(--text); padding: 0 16px; font-size: 1rem; width: 100%; outline: none; font-family: inherit; transition: border-color .2s; -webkit-appearance: none; }
.cfg-input:focus { border-color: var(--teal); }
.note-box { padding: 16px; border-radius: 14px; background: rgba(255,255,255,.03); border: 1px solid var(--border); font-size: .85rem; color: var(--text2); line-height: 1.65; margin-top: 12px; display: flex; gap: 12px; align-items: flex-start; }

/* Empty */
.empty { text-align: center; padding: 60px 20px; color: var(--text2); }
.empty-ico { font-size: 3.5rem; margin-bottom: 16px; color: var(--text3); }
.empty p { font-size: .95rem; line-height: 1.7; font-weight: 500; }

/* Toasts / Modals */
.toast { position: fixed; top: 0; left: 50%; transform: translateX(-50%) translateY(-70px); background: rgba(15,23,42,.98); backdrop-filter: blur(20px); border: 1px solid rgba(14,165,233,.4); border-radius: 999px; padding: 12px 24px; font-size: .9rem; font-weight: 700; color: var(--teal2); z-index: 9999; transition: transform .32s cubic-bezier(.34,1.56,.64,1); white-space: nowrap; pointer-events: none; display: flex; align-items: center; gap: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.toast.show { transform: translateX(-50%) translateY(calc(var(--safe-top) + 80px)); }
.badge-modal { position: fixed; inset: 0; z-index: 9998; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,.85); backdrop-filter: blur(16px); padding: 20px; }
.badge-modal.show { display: flex; }
.bm-card { background: linear-gradient(145deg, var(--s1), var(--bg)); border: 1px solid rgba(14,165,233,.4); border-radius: var(--r3); padding: 40px 30px; text-align: center; max-width: 340px; width: 100%; animation: bmpop .4s cubic-bezier(.34,1.56,.64,1); box-shadow: 0 20px 40px rgba(0,0,0,0.6); }
@keyframes bmpop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.bm-ico { font-size: 4.5rem; margin-bottom: 16px; color: var(--teal2); text-shadow: 0 0 20px rgba(14,165,233,0.5); }
.bm-t { font-size: 1.5rem; font-weight: 900; color: var(--text); margin-bottom: 8px; }
.bm-s { font-size: .95rem; font-weight: 500; color: var(--text2); line-height: 1.6; margin-bottom: 24px; }

/* Auth Gate */
#authGate { position: fixed; inset: 0; z-index: 8000; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 28px; text-align: center; transition: opacity .35s ease, visibility .35s ease; opacity: 1; visibility: visible; }
#authGate.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
#authGate .ag-logo { width: 200px; height: auto; background: transparent; box-shadow: none; border-radius: 0; margin: 0 auto 28px; animation: fadeInUp .6s ease both; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
#authGate .ag-sub { font-size: .95rem; color: var(--text2); line-height: 1.7; margin-bottom: 36px; letter-spacing: 0.01em; animation: fadeInUp .6s .1s ease both; }
#authGate .ag-features { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-bottom: 36px; animation: fadeInUp .6s .2s ease both; }
#authGate .ag-feat { display: flex; align-items: center; gap: 14px; text-align: left; background: var(--s1); border: 1px solid var(--border); border-radius: var(--r2); padding: 16px 18px; font-size: .88rem; font-weight: 600; color: var(--text2); transition: border-color .2s, transform .15s; }
#authGate .ag-feat:active { transform: scale(.98); border-color: rgba(14,165,233,.3); }
#authGate .ag-feat i { font-size: 1.4rem; color: var(--teal2); flex-shrink: 0; }
.btn-google { width: 100%; min-height: 56px; border-radius: 16px; border: none; background: #fff; color: #1f2937; font-family: inherit; font-size: 1rem; font-weight: 800; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 12px; box-shadow: 0 8px 32px rgba(255,255,255,.1); transition: transform .15s cubic-bezier(.4,0,.2,1), box-shadow .2s; animation: fadeInUp .6s .3s ease both; }
.btn-google:hover { box-shadow: 0 12px 40px rgba(255,255,255,.15); }
.btn-google:active { transform: scale(.97); }
.btn-google img { width: 22px; height: 22px; }
.ag-skip { margin-top: 20px; font-size: .82rem; color: var(--text3); cursor: pointer; text-decoration: underline; text-underline-offset: 4px; transition: color .15s; animation: fadeInUp .6s .4s ease both; }
.ag-skip:hover { color: var(--text2); }
.ag-spinner { display: none; flex-direction: column; align-items: center; gap: 14px; position: absolute; inset: 0; background: var(--bg); justify-content: center; }
.ag-spinner.show { display: flex; }

/* User chip */
.user-chip { min-height: 44px; padding: 0 12px; border-radius: 999px; background: rgba(255,255,255,.05); border: 1px solid var(--border2); display: flex; align-items: center; gap: 7px; font-size: .72rem; font-weight: 700; color: var(--text2); cursor: pointer; }
.user-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; background: linear-gradient(135deg, var(--blue), var(--teal)); display: flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0; }

@media (max-width: 390px) {
  .topbar { padding: calc(var(--safe-top) + 12px) 12px 10px; }
  .sh { padding: 20px 12px 10px; }
  .param-grid, .qstats, .coral-library-grid, .scan-opts-grid { padding: 0 12px; gap: 8px; }
  .insight-box, .quest-strip, .more-section, .form-pad, .diary-item, .inat-search-wrap, .inat-card, .ai-result-card { margin-left: 12px; margin-right: 12px; }
  .form-pad { padding-left: 12px; padding-right: 12px; margin: 0; }
  .qs { padding: 10px 6px; }
  .qs-v { font-size: 1.1rem; }
  .tank-hero { height: 160px; border-radius: 0 0 16px 16px; margin-bottom: 0px; }
  .hero-content { padding: 12px; }
  .hero-tank-name { font-size: 1.5rem; }
  .nl { font-size: 0.55rem; }
  .ni { font-size: 1.3rem; }
}
@media (min-width: 768px) {
  body { max-width: 100%; padding: 0; background: #04070D; overflow: auto; }
  .app-shell { 
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: auto 1fr;
    max-width: 1440px; 
    margin: 0 auto; 
    background: var(--bg); 
    height: 100vh; 
    box-shadow: 0 0 80px rgba(0,0,0,0.6); 
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  
  .topbar { 
    grid-column: 2; 
    grid-row: 1; 
    padding: 20px 40px;
    background: var(--bg);
    opacity: 0.95;
  }
  
  .bnav { 
    grid-column: 1; 
    grid-row: 1 / span 2;
    flex-direction: column; 
    width: 280px; 
    height: 100%; 
    border-top: none; 
    border-right: 1px solid var(--border); 
    padding: 40px 16px; 
    justify-content: flex-start; 
    gap: 8px; 
    background: #0F172A;
    z-index: 100;
  }
  
  .scroll-body { 
    grid-column: 2; 
    grid-row: 2;
  }

  .nb, .nb-center { 
    flex: none; 
    height: 54px; 
    min-height: 54px; 
    flex-direction: row; 
    justify-content: flex-start; 
    padding: 0 20px; 
    gap: 16px; 
    width: 100%; 
    border-radius: 14px; 
    transition: all 0.2s ease;
    background: transparent;
  }
  
  .nb:hover, .nb-center:hover { background: rgba(255,255,255,0.03); }
  
  .nb.on, .nb-center.on { 
    background: rgba(14,165,233,0.1); 
    color: var(--teal); 
    box-shadow: inset 0 0 0 1px rgba(14,165,233,0.2);
  }
  
  .cam-ball { 
    width: 32px; 
    height: 32px; 
    font-size: 1.1rem; 
    margin-top: 0; 
    box-shadow: none; 
    border-radius: 8px; 
    background: rgba(14,165,233,0.2);
    color: var(--teal);
  }
  
  .nb-center.on .cam-ball { background: var(--teal); color: white; }
  
  .nl { font-size: .95rem; font-weight: 600; letter-spacing: -0.01em; color: inherit; }
  .ni { font-size: 1.4rem; color: inherit; transform: none !important; }
  
  /* Ajustes de Conteúdo */
  .param-grid, .coral-library-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; padding: 0 40px; }
  .qstats { padding: 10px 40px; gap: 16px; }
  .hero-tank-name { font-size: 3.5rem; }
  .tank-hero { height: 380px; border-radius: 0 0 40px 40px; margin: 0 40px 20px; }
  .insight-box, .quest-strip, .more-section { margin-left: 40px; margin-right: 40px; }
  .sh { padding: 30px 40px 16px; }
  
  /* Ocultar redundâncias desktop se necessário */
}

/* LGPD Banner */
.lgpd-banner { position: fixed; bottom: 0; left: 0; right: 0; background: var(--s1); border-top: 1px solid var(--border); padding: 16px 20px; z-index: 1000; display: flex; flex-direction: column; gap: 12px; transform: translateY(100%); transition: transform 0.4s ease; box-shadow: 0 -4px 20px rgba(0,0,0,0.5); }
.lgpd-banner.show { transform: translateY(0); }
@media (min-width: 768px) { .lgpd-banner { left: 240px; } }
.lgpd-text { font-size: .8rem; color: var(--text2); line-height: 1.5; }
.lgpd-text a { color: var(--teal); text-decoration: underline; font-weight: bold; cursor: pointer; }
.lgpd-btn { background: var(--teal); color: #fff; border: none; padding: 10px 16px; border-radius: var(--r); font-weight: bold; cursor: pointer; width: 100%; text-align: center; }

/* Privacy Modal */
.priv-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px); z-index: 1100; display: none; padding: 20px; align-items: center; justify-content: center; }
.priv-modal.show { display: flex; }
.priv-content { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r2); max-width: 600px; width: 100%; max-height: 85vh; overflow-y: auto; padding: 24px; position: relative; }
.priv-content h2 { font-size: 1.2rem; margin-bottom: 16px; color: var(--text); }
.priv-content p, .priv-content li { font-size: .85rem; color: var(--text2); margin-bottom: 12px; line-height: 1.6; }
.priv-content ul { margin-left: 20px; margin-bottom: 16px; }
.priv-close { position: absolute; top: 16px; right: 16px; background: rgba(255,255,255,0.1); border: none; color: #fff; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }

/* SCANNER BLUE FILTER */
.prev-img.blue-filter { filter: sepia(0.5) hue-rotate(-15deg) saturate(1.5) brightness(1.1) contrast(1.2); }
.filter-btn { position: absolute; right: 14px; bottom: 14px; width: 44px; height: 44px; border-radius: 12px; background: rgba(245,158,11,0.9); border: 1px solid rgba(255,255,255,0.2); color: white; display: none; align-items: center; justify-content: center; font-size: 1.4rem; cursor: pointer; z-index: 10; transition: transform 0.2s; }
.filter-btn.on { background: #f59e0b; box-shadow: 0 0 15px rgba(245,158,11,0.4); transform: scale(1.1); }
.filter-btn:active { transform: scale(0.95); }

/* Analytics Charts - FIXED CLASSES */
.chart-card { background: var(--s1); border: 1px solid var(--border); border-radius: var(--r2); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); }
.chart-title { font-size: .9rem; font-weight: 800; color: var(--text); margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }
.chart-badge { font-size: .65rem; padding: 4px 10px; border-radius: 999px; background: var(--glass); color: var(--text3); font-weight: 700; border: 1px solid var(--border); }


/* ==========================================================================
   AFFORDANCES CRUD — Botões de Editar/Excluir nos cards
   ========================================================================== */

.crud-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.crud-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text3);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
}

.crud-btn:active {
  transform: scale(0.9);
}

.crud-btn.edit:hover,
.crud-btn.edit:active {
  color: var(--teal2);
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(56, 189, 248, 0.1);
}

.crud-btn.delete:hover,
.crud-btn.delete:active {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

/* ==========================================================================
   EMPTY STATES — Seções sem dados
   ========================================================================== */

@keyframes emptyPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.8; }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text3);
  background: rgba(0, 0, 0, 0.12);
  border: 1.5px dashed rgba(255, 255, 255, 0.08);
  border-radius: var(--r2);
  grid-column: 1 / -1;
  margin: 8px 0;
}

.empty-state i {
  font-size: 2.8rem;
  margin-bottom: 14px;
  color: var(--text3);
  animation: emptyPulse 3s ease-in-out infinite;
}

.empty-state div {
  font-size: 0.85rem;
  line-height: 1.5;
  max-width: 240px;
}

/* Chart card canvas height helper */
.chart-card canvas {
  min-height: 220px;
}
