:root {
  --bg: #0a0a0a;
  --bg2: #111111;
  --bg3: #1a1a1a;
  --border: #222222;
  --text: #f0f0f0;
  --text2: #888888;
  --text3: #555555;
  --accent: #e8ff47;
  --accent-dark: #b8cc2a;
  --green: #4ade80;
  --red: #f87171;
  --radius: 14px;
  --radius-sm: 8px;
  --font-head: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-head);
  font-size: 16px;
  overflow: hidden;
}

#app { height: 100vh; height: 100dvh; position: relative; overflow: hidden; }

/* ─── SCREENS ─── */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; opacity: 0; pointer-events: none; transition: opacity 0.25s; overflow: hidden; }
.screen.active { opacity: 1; pointer-events: all; }

/* ─── LOGIN ─── */
.login-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 20%, #1a2200 0%, transparent 60%),
              radial-gradient(ellipse at 80% 80%, #001a10 0%, transparent 60%);
}
.login-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; padding: 2rem; text-align: center;
}
.logo-mark { margin-bottom: 1.5rem; }
.app-title { font-size: 3rem; font-weight: 700; letter-spacing: -0.04em; color: var(--text); margin-bottom: 0.75rem; }
.app-sub { font-size: 1rem; color: var(--text2); line-height: 1.6; margin-bottom: 3rem; }

.btn-google {
  display: flex; align-items: center; gap: 10px;
  background: var(--text); color: #0a0a0a;
  border: none; border-radius: var(--radius);
  padding: 14px 24px; font-size: 15px; font-weight: 500;
  font-family: var(--font-head); cursor: pointer;
  width: 100%; max-width: 300px; justify-content: center;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-google:active { opacity: 0.85; transform: scale(0.98); }
.login-note { margin-top: 1.5rem; font-size: 12px; color: var(--text3); }

/* ─── HEADER ─── */
.screen-header {
  display: flex; align-items: center; gap: 10px;
  padding: 1rem 1.25rem;
  padding-top: max(1rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.logo-sm { display: flex; }
.user-email { font-size: 13px; color: var(--text2); font-family: var(--font-mono); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-icon { background: none; border: none; color: var(--text2); cursor: pointer; padding: 4px; display: flex; border-radius: 8px; transition: color 0.15s; }
.btn-icon:hover { color: var(--text); }

/* ─── SETUP ─── */
.setup-body { flex: 1; padding: 2rem 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; overflow-y: auto; }
.setup-body h2 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.setup-sub { font-size: 14px; color: var(--text2); line-height: 1.6; }

/* ─── TABS ─── */
.tabs { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--bg); }
.tab { flex: 1; padding: 12px; font-size: 14px; font-weight: 500; font-family: var(--font-head); border: none; background: none; color: var(--text2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all 0.15s; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; flex: 1; overflow-y: auto; padding: 1.25rem; padding-bottom: max(1.25rem, env(safe-area-inset-bottom)); }
.tab-content.active { display: flex; flex-direction: column; }

/* ─── FORM ─── */
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label { font-size: 12px; color: var(--text2); letter-spacing: 0.04em; text-transform: uppercase; font-family: var(--font-mono); }
.field-group input {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 15px; padding: 12px 14px; font-family: var(--font-head);
  outline: none; transition: border-color 0.15s;
  -webkit-appearance: none;
}
.field-group input:focus { border-color: var(--accent); }
.field-group input::placeholder { color: var(--text3); }

/* ─── BUTTONS ─── */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #0a0a0a;
  border: none; border-radius: var(--radius);
  padding: 14px; font-size: 15px; font-weight: 700;
  font-family: var(--font-head); cursor: pointer; width: 100%;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-primary:active { opacity: 0.85; transform: scale(0.98); }
.btn-secondary {
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px; font-size: 15px; font-weight: 500;
  font-family: var(--font-head); cursor: pointer; width: 100%;
  transition: background 0.15s;
}
.btn-secondary:active { background: var(--border); }
.btn-ghost { background: none; border: none; color: var(--text2); font-size: 14px; font-family: var(--font-head); cursor: pointer; padding: 10px; text-align: center; }
.btn-ghost:hover { color: var(--text); }

/* Ryškesnis galerijos mygtukas */
.btn-gallery {
  background: var(--bg2);
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-size: 14px;
  font-family: var(--font-head);
  font-weight: 600;
  cursor: pointer;
  padding: 12px 22px;
  min-height: 44px;
  border-radius: 100px;
  transition: background 0.15s, transform 0.1s;
}
.btn-gallery:active { background: #1a1a00; transform: scale(0.97); }

/* Rankinio įvedimo mygtukas — identiškas galerijos mygtukui */
.btn-manual {
  background: var(--bg2);
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-size: 14px;
  font-family: var(--font-head);
  font-weight: 600;
  cursor: pointer;
  padding: 12px 22px;
  min-height: 44px;
  border-radius: 100px;
  transition: background 0.15s, transform 0.1s;
}
.btn-manual:active { background: #1a1a00; transform: scale(0.97); }

/* Rankinio įvedimo produktų eilutės */
.manual-item-row {
  display: grid;
  grid-template-columns: 1fr 90px auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}
.manual-item-row input {
  background: var(--bg3); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 14px; padding: 10px 12px; font-family: var(--font-head);
  outline: none; transition: border-color 0.15s; -webkit-appearance: none;
  width: 100%;
}
.manual-item-row input:focus { border-color: var(--accent); }
.manual-item-row .manual-item-sum {
  width: 90px;
  border-color: var(--accent);
  color: var(--accent);
}
.manual-item-row .manual-item-sum::placeholder { color: var(--text3); }
.btn-add-item {
  background: var(--bg2);
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-head);
  cursor: pointer;
  padding: 10px;
  border-radius: var(--radius-sm);
  width: 100%;
  margin-top: 4px;
  transition: background 0.15s;
}
.btn-add-item:active { background: #1a1a00; }
.btn-remove-item {
  background: none; border: none; color: var(--text3);
  font-size: 16px; cursor: pointer; padding: 4px 8px;
  border-radius: 6px; transition: color 0.15s;
}
.btn-remove-item:active { color: var(--red); }

/* Rankinio įvedimo modal eilutė */
.manual-entry-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ─── SCAN ─── */
.scan-hero { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; padding: 2rem 1rem 1rem; gap: 1rem; }

/* Žalias švytintis apskritimas */
.scan-circle {
  min-width: 64px; min-height: 64px;
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #1a3a1a, #0a1a0a);
  border: 2px solid var(--green);
  box-shadow: 0 0 18px rgba(74, 222, 128, 0.35), 0 0 40px rgba(74, 222, 128, 0.12);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s; color: var(--green);
  animation: pulseGreen 2.5s ease-in-out infinite;
}
.scan-circle:active { transform: scale(0.95); box-shadow: 0 0 28px rgba(74, 222, 128, 0.6); }

@keyframes pulseGreen {
  0%, 100% { box-shadow: 0 0 18px rgba(74, 222, 128, 0.35), 0 0 40px rgba(74, 222, 128, 0.12); }
  50% { box-shadow: 0 0 28px rgba(74, 222, 128, 0.55), 0 0 60px rgba(74, 222, 128, 0.2); }
}

.scan-label { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.scan-sub { font-size: 13px; color: var(--text3); }

/* ─── Rankinio įvedimo forma ─── */
.manual-entry {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.manual-entry-title {
  font-size: 12px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-mono);
  margin-bottom: 0.25rem;
}
.manual-entry input {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 14px; padding: 10px 12px; font-family: var(--font-head);
  outline: none; transition: border-color 0.15s;
  -webkit-appearance: none; width: 100%;
}
.manual-entry input:focus { border-color: var(--accent); }
.manual-entry input::placeholder { color: var(--text3); }
.manual-entry-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Loading */
.loading-card { display: flex; flex-direction: column; align-items: center; gap: 1.5rem; padding: 1rem 0; }
.scan-preview-wrap { width: 100%; max-height: 300px; border-radius: var(--radius); overflow: hidden; position: relative; }
.scan-preview { width: 100%; height: 100%; object-fit: cover; max-height: 300px; display: block; }
.scan-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.3); }
.scan-line {
  position: absolute; left: 0; right: 0; height: 2px;
  background: var(--accent); box-shadow: 0 0 12px var(--accent);
  animation: scanLine 1.8s ease-in-out infinite;
}
@keyframes scanLine { 0% { top: 10%; } 50% { top: 85%; } 100% { top: 10%; } }
.loading-text { font-size: 14px; color: var(--text2); font-family: var(--font-mono); }

/* Result */
.result-header { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 12px; position: relative; }
.result-store { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 4px; }
.result-date { font-size: 13px; color: var(--text2); font-family: var(--font-mono); }
.totals-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.total-box { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 4px; position: relative; }
.total-box.accent { border-color: #3a4a00; background: #111a00; }
.total-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; font-family: var(--font-mono); }
.total-val { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.total-box.accent .total-val { color: var(--accent); }

.items-list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; }
.item-row { display:flex; align-items:center; gap:8px; padding:10px 14px; border-bottom:1px solid var(--border); text-align:left; }
.item-row:last-child { border-bottom: none; }
.item-name { font-size:14px; line-height:1.3; flex:1; color:#ddd; text-align:left; }
.item-qty { font-size:12px; color:var(--text2); font-family:var(--font-mono); white-space:nowrap; min-width:24px; text-align:left; }
.item-sum { font-size: 14px; font-weight: 500; font-family: var(--font-mono); white-space: nowrap; }

.result-actions { display: flex; flex-direction: column; gap: 10px; }

/* ─── KOREGAVIMO STILIAI ─── */
.editable { cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.editable:active { border-color: var(--accent) !important; background: #1a1a00 !important; }
.edit-hint { position:absolute; top:8px; right:10px; font-size:13px; color:#888; pointer-events:none; }
.edit-hint-inline { font-size:13px; color:#e8ff47; opacity:0.8; margin-left:4px; pointer-events:none; }
#edit-modal .modal-card { display: flex; flex-direction: column; gap: 1rem; }
#edit-modal .modal-card .btn-confirm-no { width: 100%; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); padding: 14px; font-size: 15px; font-weight: 700; font-family: var(--font-head); cursor: pointer; }

/* ─── HISTORY ─── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; gap: 1rem; color: var(--text3); }
.empty-state p { font-size: 14px; }
.history-item { display:block; width:100%; background:#111; border:1px solid #222; border-radius:12px; margin-bottom:8px; overflow:hidden; transition:border-color 0.2s; box-sizing:border-box; }
.history-item.open { border-color:#333; }
.history-item-header { display:flex; justify-content:space-between; align-items:flex-start; padding:14px 16px; cursor:pointer; }
.history-item-header:hover { background:#161616; }
.h-left { flex:1; display:flex; flex-direction:column; gap:3px; }
.h-store { font-size:15px; font-weight:600; color:#f0f0f0; }
.h-date { font-size:12px; color:#666; }
.h-right { display:flex; align-items:center; gap:10px; flex-shrink:0; padding-top:2px; }
.h-total { font-size:15px; font-weight:600; color:#e8ff47; }
.h-chevron { font-size:10px; color:#555; }
.history-detail { display:block; width:100%; border-top:1px solid #1e1e1e; padding:12px 16px; box-sizing:border-box; }
.hd-section { margin-bottom:12px; }
.hd-section + .hd-section { border-top:1px solid #1a1a1a; padding-top:10px; }
.hd-row { display:flex; justify-content:space-between; align-items:center; padding:5px 0; gap:8px; position:relative; min-width:0; }
.hd-label { font-size:11px; color:#555; text-transform:uppercase; letter-spacing:0.05em; min-width:80px; flex-shrink:0; }
.hd-value { font-size:13px; color:#ccc; text-align:right; flex:1; }
.hd-value.editable-field { cursor:pointer; }
.hd-value.editable-field:hover { color:#e8ff47; }
.hd-products-header { display:flex; justify-content:space-between; font-size:11px; color:#555; text-transform:uppercase; letter-spacing:0.05em; padding:0 0 4px; margin-bottom:2px; }
.hd-product-row { border-bottom:1px solid #1a1a1a; }
.hd-product-row:last-child { border-bottom:none; }
.hd-product-row .hd-value:first-child { text-align:left; color:#ddd; flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }
.hd-item-sum { min-width:80px; text-align:right; color:#888 !important; flex-shrink:0; }
.hd-footer { text-align:right; margin-top:8px; }
.history-refresh-btn { display:inline-block; font-size:11px; color:#444; cursor:pointer; padding:4px 0; }
.history-refresh-btn:hover { color:#e8ff47; }
.history-store { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 3px; }
.history-meta { font-size: 12px; color: var(--text2); font-family: var(--font-mono); }
.history-amount { font-size: 18px; font-weight: 700; font-family: var(--font-mono); }
.history-discount { font-size: 11px; color: var(--green); font-family: var(--font-mono); text-align: right; }

/* ─── ANALYTICS ─── */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 1.5rem; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; font-family: var(--font-mono); }
.stat-val { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.stat-val.green { color: var(--green); }
.chart-section { margin-bottom: 1.5rem; }
.chart-title { font-size: 12px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; font-family: var(--font-mono); margin-bottom: 12px; }
.bar-row { display: grid; grid-template-columns: 80px 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.bar-label { font-size: 12px; color: var(--text2); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--bg3); border-radius: 4px; height: 24px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; display: flex; align-items: center; padding: 0 8px; font-size: 11px; font-weight: 500; color: #0a0a0a; font-family: var(--font-mono); transition: width 0.6s ease; white-space: nowrap; }

/* ─── TOAST ─── */
.toast {
  position: fixed; bottom: max(2rem, env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #0a0a0a;
  padding: 10px 20px; border-radius: 100px;
  font-size: 13px; font-weight: 500;
  opacity: 0; transition: all 0.25s; pointer-events: none;
  white-space: nowrap; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); color: white; }

/* ─── WIZARD ─── */
.wizard-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 1rem;
}
.wizard-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.wizard-step-label {
  font-size: 13px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 600;
  margin-bottom: 1.5rem;
}
.wizard-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 1.25rem;
}
.wizard-actions .btn-confirm-no {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-head);
  cursor: pointer;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  transition: opacity 0.15s;
}
.wizard-actions .btn-confirm-no:active { opacity: 0.8; }
.wizard-summary {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wizard-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}
.wizard-summary-row span { color: var(--text2); }
.wizard-summary-row strong { color: var(--text); font-weight: 600; }
#wizard-content .field-group { margin-bottom: 12px; }
#wizard-content .field-group label {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}
#wizard-content input {
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  padding: 13px 14px;
  font-family: var(--font-head);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  width: 100%;
}
#wizard-content input:focus { border-color: var(--accent); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: none; align-items: center; justify-content: center; z-index: 50; backdrop-filter: blur(4px); }
.modal.open { display: flex; }
.modal-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; width: calc(100% - 3rem); max-width: 360px; display: flex; flex-direction: column; gap: 1rem; }
.modal-card h3 { font-size: 18px; font-weight: 700; }

/* ─── "IŠSAUGOTI KVITĄ?" MODALAS ─── */
#save-receipt-modal { align-items: center; justify-content: center; }
#save-receipt-modal .modal-card { border-radius: var(--radius); max-width: 320px; width: calc(100% - 2rem); text-align: center; padding: 2rem 1.5rem; padding-bottom: 2rem; }
.save-receipt-icon { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; background: #111a00; border: 1px solid #3a4a00; border-radius: 50%; margin: 0 auto 0.5rem; }
.modal-sub { font-size: 14px; color: var(--text2); line-height: 1.5; }
.modal-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 0.5rem; }
.modal-actions .btn-primary, .modal-actions .btn-confirm-no { width: 100%; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); padding: 14px; font-size: 15px; font-weight: 700; font-family: var(--font-head); cursor: pointer; transition: opacity 0.15s, transform 0.1s; }
.btn-confirm-no { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-confirm-no:active { opacity: 0.85; transform: scale(0.98); }

/* ─── PWA safe area ─── */
#tab-scan { padding-bottom: max(5rem, calc(env(safe-area-inset-bottom) + 4rem)); }

/* ─── INLINE EDIT POPUP ─── */
.inline-edit-popup { position:fixed; inset:0; background:rgba(0,0,0,0.85); display:flex; align-items:center; justify-content:center; z-index:200; backdrop-filter:blur(4px); padding:1.5rem; box-sizing:border-box; }
.inline-edit-inner { background:#1a1a1a; border:1px solid #444; border-radius:16px; padding:1.5rem; width:100%; max-width:360px; display:flex; flex-direction:column; gap:1rem; }
.inline-edit-label { font-size:11px; color:#888; text-transform:uppercase; letter-spacing:0.05em; }
.inline-edit-input { background:#111; border:1.5px solid #444; border-radius:8px; color:#f0f0f0; font-size:17px; font-family:inherit; padding:12px 14px; width:100%; outline:none; box-sizing:border-box; -webkit-appearance:none; }
.inline-edit-input:focus { border-color:#e8ff47; }
.inline-edit-actions { display:flex; gap:10px; }
.inline-edit-save { flex:1; background:#e8ff47; color:#0a0a0a; border:none; border-radius:10px; padding:12px; font-size:15px; font-weight:700; cursor:pointer; font-family:inherit; }
.inline-edit-cancel { flex:1; background:#222; color:#aaa; border:1px solid #333; border-radius:10px; padding:12px; font-size:15px; cursor:pointer; font-family:inherit; }

/* ─── HISTORY REFRESH BAR ─── */
#history-refresh-bar { text-align:center; color:#555; font-size:11px; padding:8px 16px; display:flex; align-items:center; justify-content:space-between; }

/* ─── CROP EDITOR ─── */
#crop-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: #0a0a0a;
  display: flex; flex-direction: column;
}
.crop-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; flex-shrink: 0;
  padding-top: max(12px, env(safe-area-inset-top));
}
.crop-title { color: #f0f0f0; font-size: 15px; font-weight: 600; }
.crop-btn-cancel, .crop-btn-skip {
  background: none; border: none; color: #888; font-size: 14px;
  font-family: 'Syne', sans-serif; cursor: pointer; padding: 8px 12px;
}
.crop-btn-cancel:hover, .crop-btn-skip:hover { color: #f0f0f0; }
.crop-btn-skip { color: #e8ff47; }
.crop-canvas-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: hidden; padding: 8px;
}
#crop-canvas { max-width: 100%; max-height: 100%; touch-action: none; }
.crop-footer {
  display: flex; gap: 12px; padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.crop-btn-reset {
  flex: 1; background: #1a1a1a; border: 1px solid #333; color: #888;
  border-radius: 12px; padding: 14px; font-size: 15px;
  font-family: 'Syne', sans-serif; cursor: pointer;
}
.crop-btn-confirm {
  flex: 2; background: #e8ff47; border: none; color: #0a0a0a;
  border-radius: 12px; padding: 14px; font-size: 15px; font-weight: 700;
  font-family: 'Syne', sans-serif; cursor: pointer;
}
.crop-btn-confirm:active { opacity: 0.85; transform: scale(0.98); }

/* ─── CROP PREVIEW ─── */
#crop-preview-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: #0a0a0a;
  display: flex; flex-direction: column;
}
.crop-preview-header {
  text-align: center; padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  font-size: 16px; font-weight: 600; color: #f0f0f0;
}
.crop-preview-img-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: hidden; padding: 12px;
}
.crop-preview-img {
  max-width: 100%; max-height: 100%; border-radius: 12px;
  border: 2px solid #333;
}
.crop-preview-actions {
  display: flex; gap: 12px; padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.crop-btn-rescan {
  flex: 1; background: #1a1a1a; border: 1px solid #333; color: #888;
  border-radius: 12px; padding: 14px; font-size: 14px;
  font-family: 'Syne', sans-serif; cursor: pointer;
}
.crop-btn-scan {
  flex: 2; background: #e8ff47; border: none; color: #0a0a0a;
  border-radius: 12px; padding: 14px; font-size: 15px; font-weight: 700;
  font-family: 'Syne', sans-serif; cursor: pointer;
}
.crop-btn-scan:active { opacity: 0.85; transform: scale(0.98); }

/* ─── LIVE SCANNER ─── */
#live-scanner {
  position: fixed; inset: 0; z-index: 400;
  background: #000; display: flex; align-items: center; justify-content: center;
}
#live-video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
#live-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  pointer-events: none;
}
.live-close {
  position: absolute; top: max(16px, env(safe-area-inset-top)); left: 16px;
  z-index: 10; background: rgba(0,0,0,0.6); border: none; color: #fff;
  width: 44px; height: 44px; border-radius: 22px; font-size: 20px;
  cursor: pointer; backdrop-filter: blur(8px);
}
#live-status {
  position: absolute; bottom: max(80px, calc(env(safe-area-inset-bottom) + 60px));
  left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.7); color: #888;
  padding: 10px 24px; border-radius: 100px;
  font-size: 15px; font-weight: 600; white-space: nowrap;
  backdrop-filter: blur(8px); z-index: 10;
  transition: color 0.2s;
}
#live-hint {
  position: absolute; top: max(70px, calc(env(safe-area-inset-top) + 50px));
  left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.5); font-size: 13px;
  z-index: 10; white-space: nowrap;
}

/* Rankinis fotografavimo mygtukas */
#live-snap-btn {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  z-index: 10;
  width: 70px; height: 70px; border-radius: 50%;
  background: transparent;
  border: 4px solid rgba(255,255,255,0.8);
  color: transparent;
  font-size: 50px; line-height: 62px;
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.3);
  transition: all 0.15s;
}
#live-snap-btn:active {
  background: rgba(255,255,255,0.3);
  transform: translateX(-50%) scale(0.9);
}

/* ─── Skenuoti dar vieną mygtukas ─── */
.btn-new-scan {
  display: block; width: 100%; margin-top: 16px;
  background: var(--bg2); border: 1.5px solid var(--border);
  color: var(--text2); padding: 14px; min-height: 44px;
  border-radius: 12px; font-size: 14px; font-weight: 500;
  font-family: var(--font-head); cursor: pointer;
  transition: all 0.15s;
}
.btn-new-scan:hover { border-color: var(--accent); color: var(--accent); }
.btn-new-scan:active { transform: scale(0.97); }

/* Loading teksto animacija */
#loading-text {
  transition: opacity 0.15s ease;
}

/* ─── ANALITIKA: papildomi elementai ─── */
.bar-fill-alt { background: #47c8ff; }

.day-chart-wrap {
  display: flex; align-items: flex-end; justify-content: space-around;
  height: 120px; padding: 12px 0; gap: 6px;
}
.day-bar-col {
  display: flex; flex-direction: column; align-items: center;
  flex: 1; height: 100%;
  justify-content: flex-end; gap: 6px;
}
.day-bar {
  width: 100%; max-width: 32px; min-height: 4px;
  background: var(--accent); border-radius: 4px 4px 0 0;
  transition: height 0.3s;
}
.day-label { font-size: 11px; color: var(--text2); font-family: var(--font-mono); }

.bar-row small { color: var(--text3); font-size: 11px; margin-left: 4px; }

/* ─── ONBOARDING ─── */
#onboarding-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.9);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(8px);
}
.ob-card {
  background: #111; border: 1px solid #333; border-radius: 20px;
  padding: 2.5rem 2rem; max-width: 340px; width: 100%;
  text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 1rem;
}
.ob-icon { font-size: 48px; line-height: 1; }
.ob-title { font-size: 20px; font-weight: 700; color: #f0f0f0; }
.ob-desc { font-size: 14px; color: #888; line-height: 1.5; }
.ob-dots { display: flex; gap: 8px; margin: 0.5rem 0; }
.ob-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #333; transition: background 0.2s;
}
.ob-dot.active { background: var(--accent); }
.ob-actions { display: flex; gap: 10px; width: 100%; margin-top: 0.5rem; }
.ob-btn-back {
  flex: 1; background: transparent; border: 1px solid #333;
  color: #888; padding: 12px; border-radius: 12px;
  font-size: 14px; font-family: var(--font-head); cursor: pointer;
}
.ob-btn-next {
  flex: 2; background: var(--accent); border: none; color: #0a0a0a;
  padding: 12px; border-radius: 12px; font-size: 15px; font-weight: 700;
  font-family: var(--font-head); cursor: pointer;
}
.ob-btn-next:active { opacity: 0.85; transform: scale(0.97); }

/* Flashlight mygtukas */
#live-torch-btn {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  z-index: 10;
  background: rgba(0,0,0,0.6);
  border: none;
  width: 44px; height: 44px;
  border-radius: 22px;
  font-size: 20px;
  cursor: pointer;
  backdrop-filter: blur(8px);
}


/* ─── RESPONSIVE ─── */

/* Mažas ekranas (<380px) */
@media (max-width: 380px) {
  .tabs { gap: 0; }
  .tab { font-size: 12px; padding: 10px 4px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-val { font-size: 20px; }
  .bar-label { font-size: 11px; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chart-section { padding: 12px; }
  .hd-label { min-width: 60px; font-size: 10px; }
  .hd-value { font-size: 12px; }
  .h-store { font-size: 14px; }
  .btn-gallery, .btn-manual { padding: 10px 16px; font-size: 13px; }
  .scan-label { font-size: 13px; }
}

/* Vidutinis ekranas (381-768px) — telefonai */
@media (min-width: 381px) and (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Didelis ekranas (>768px) — planšetės/kompiuteriai */
@media (min-width: 769px) {
  .screen { max-width: 480px; margin: 0 auto; position: relative; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .tab-content { padding: 0 1rem; }
}

/* Safari iOS fixes */
@supports (-webkit-touch-callout: none) {
  body { min-height: -webkit-fill-available; }
  .screen { min-height: -webkit-fill-available; }
}

/* Flex-wrap apsauga */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.ob-actions { flex-wrap: wrap; }
.controls { flex-wrap: wrap; }

/* Produkto nuolaida po sumos */
.item-discount {
  font-size: 11px;
  color: #4ade80;
  margin-top: 2px;
  opacity: 0.8;
}
