:root {
  color-scheme: light;
  --bg: #f5f4f0;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e3e1db;
  --grid: #e8e6e1;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7973;
  /* Accent = verdele din logo (pompa de pe bord); ajustat pentru contrast ≥4.5. */
  --accent: #0f7f40;
  --accent-ink: #ffffff;
  /* Culorile pistoalelor de la pompă: verde = benzină, negru = diesel.
     Pe fundal închis „negrul” devine gri deschis, altfel nu s-ar vedea. */
  --s1: #13924a;
  --s2: #1f1f1d;
  /* Status: scump = critical, ieftin = good. Mereu cu săgeată + text. */
  --up: #d03b3b;
  --down: #0ca30c;
  --radius: 14px;
  --gutter: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #242422;
    --border: #2e2e2b;
    --grid: #2a2a28;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #8f8e86;
    --accent: #2bb866;
    --accent-ink: #0c1a11;
    --s1: #2bb866;
    --s2: #b4b3ab;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110;
  --surface: #1a1a19;
  --surface-2: #242422;
  --border: #2e2e2b;
  --grid: #2a2a28;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #8f8e86;
  --accent: #2bb866;
  --accent-ink: #0c1a11;
  --s1: #2bb866;
  --s2: #b4b3ab;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
a { color: var(--accent); }
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) var(--gutter) 6px;
  max-width: 720px; margin: 0 auto;
}
.top h1 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
/* Logo + nume, ca în celelalte aplicații EANmatch (Vagtløn: .brand / .brand-mark). */
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 28px; height: 28px; display: block; flex-shrink: 0; border-radius: 7px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { max-width: 720px; margin: 0 auto; padding: 0 var(--gutter); }
.view { display: flex; flex-direction: column; gap: 12px; padding-top: 8px; }

h2 { font-size: 15px; margin: 0 0 10px; font-weight: 650; }

/* Carduri de preț */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 10px; min-height: 108px; display: flex; flex-direction: column; gap: 2px;
  position: relative; overflow: hidden;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, transparent); border-radius: 4px 0 0 4px; }
.card.mine { border-color: var(--c); box-shadow: 0 0 0 1px var(--c) inset; }
.card .name { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .price { font-size: 25px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.card .price small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.card .delta { font-size: 12px; color: var(--text-2); }
.card .delta b { font-weight: 650; }
.card .since { font-size: 11.5px; color: var(--muted); margin-top: auto; }
.up { color: var(--up); }
.down { color: var(--down); }
.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (max-width: 380px) {
  .card .price { font-size: 21px; }
  .card { padding: 10px 8px; }
}

.checked { margin: -2px 2px 0; font-size: 12px; color: var(--muted); }
.banner {
  background: var(--surface); border: 1px solid var(--up); border-radius: var(--radius);
  padding: 10px 12px; font-size: 13.5px;
}

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.panel-head h2 { margin: 0; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 12.5px;
  padding: 5px 9px; border-radius: 8px; cursor: pointer; min-height: 30px;
}
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }

.legend { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 6px; }
.legend button {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 12.5px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 4px 10px; border-radius: 999px; cursor: pointer; min-height: 30px;
}
.legend button .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.legend button[aria-pressed="false"] { color: var(--muted); }
.legend button[aria-pressed="false"] .dot { background: transparent; box-shadow: 0 0 0 1.5px var(--muted) inset; }

.chart-wrap { position: relative; width: 100%; }
#chart, #month-chart { width: 100%; display: block; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
#chart { height: 230px; }
#month-chart { height: 170px; }
.chart-wrap svg text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart-wrap svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-wrap svg .end-label { fill: var(--text-2); font-weight: 600; }
.chart-wrap svg .cross { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; }
.tooltip {
  position: absolute; top: 0; pointer-events: none; z-index: 2;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.14); padding: 8px 10px; font-size: 12.5px; min-width: 140px;
}
.tooltip .t-date { color: var(--text-2); margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.tooltip .t-row span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tooltip .sw { width: 8px; height: 8px; border-radius: 50%; background: var(--c); display: inline-block; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.stats > div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.stats .label, .result .label { display: block; font-size: 11.5px; color: var(--muted); }
.stats b { font-size: 15px; }
.stats.big { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 0; }
.stats.big > div { background: var(--surface); border: 1px solid var(--border); padding: 12px; border-radius: var(--radius); }
.stats.big b { font-size: 20px; }
.stats small { color: var(--muted); font-size: 11.5px; }

.note { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }
.table-toggle { margin-top: 10px; }
.table-toggle summary { cursor: pointer; color: var(--text-2); font-size: 13px; }
table.data { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
table.data th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 4px 4px; border-bottom: 1px solid var(--border); }
table.data td { padding: 6px 4px; border-bottom: 1px solid var(--grid); }
table.data .num { text-align: right; }

/* Formulare */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 13px; color: var(--text-2); min-width: 0; }
.field.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.field.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.field small { color: var(--muted); }
input[type="number"], input[type="text"], input[type="date"], input[type="password"], select {
  font: inherit; font-size: 16px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; width: 100%; min-height: 42px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 32px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: end; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
button { font: inherit; }
.row button, .primary, #fill-form button {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 10px; padding: 9px 14px; cursor: pointer; min-height: 42px;
}
.primary { background: var(--accent) !important; color: var(--accent-ink) !important; border-color: var(--accent) !important; font-weight: 600; }
button:disabled { opacity: 0.55; cursor: default; }

.price-line { margin: 0; color: var(--text-2); font-size: 13.5px; }
.result { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.result > div { background: var(--surface-2); border-radius: 10px; padding: 10px; }
.result b { font-size: 20px; }

.checks { display: flex; flex-direction: column; gap: 2px; margin: 8px 0 10px; }
/* Prag de alertă: rândul de sub fiecare combustibil bifat. Gol = orice schimbare. */
.push-row { display: flex; flex-direction: column; gap: 4px; padding: 2px 0 6px; }
.push-row .below { display: flex; align-items: center; gap: 8px; margin-left: 28px; color: var(--text-2); font-size: 14px; }
.push-row .below input { width: 140px; }

details.add summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
details.add summary::-webkit-details-marker { display: none; }
details.add summary h2 { margin: 0; }
details.add summary::after { content: "+"; font-size: 22px; color: var(--accent); line-height: 1; }
details.add[open] summary::after { content: "–"; }
details.add[open] summary { margin-bottom: 12px; }

.log-list { list-style: none; padding: 0; margin: 0; }
.log-list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--grid); }
.log-list li:last-child { border-bottom: 0; }
.log-list .bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--c); }
.log-list .main { flex: 1; min-width: 0; }
.log-list .l1 { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.log-list .l2 { font-size: 12.5px; color: var(--muted); }
.log-list .del { border: 0; background: transparent; color: var(--muted); font-size: 18px; width: 36px; height: 36px; border-radius: 8px; cursor: pointer; }
.log-list .del:hover { color: var(--up); background: var(--surface-2); }
.log-list .empty { color: var(--muted); font-size: 13px; }

/* Tab bar */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px;
  color: var(--muted); text-decoration: none; font-size: 11px;
}
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.on { color: var(--accent); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 10px; font-size: 13.5px;
  max-width: calc(100% - 32px);
}

.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.log-local { margin: 0 0 12px; }
details.owner summary { list-style: none; cursor: pointer; }
details.owner summary::-webkit-details-marker { display: none; }
details.owner summary h2 { margin: 0; color: var(--muted); font-size: 14px; font-weight: 500; }
details.owner[open] summary h2 { margin-bottom: 10px; }

.install-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 10px;
}
.install-card p { margin: 4px 0 0; color: var(--text-2); font-size: 14px; line-height: 1.4; }
.sheet-body .why { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.45; }
.sheet-body p { margin: 4px 0 0; color: var(--text-2); font-size: 14px; line-height: 1.45; }
.sheet-body .steps { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--text-2); line-height: 1.45; }
.sheet-body .steps li { display: list-item; }
.sheet-body .steps li::before { content: none; }

/* Del appen: QR pe fundal alb (contrastul de care au nevoie camerele), ca în Minløn. */
.share-open {
  width: 100%; min-height: 44px; border: 1px dashed var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--accent); font-weight: 600; cursor: pointer;
}
.share-sheet { text-align: center; }
.share-qr { display: block; width: 220px; height: 220px; max-width: 100%; margin: 16px auto 10px; border-radius: 10px; background: #fff; }
.share-url { margin: 0 0 12px; color: var(--accent); font-size: 15px; word-break: break-all; }
.share-actions { justify-content: center; }
.share-actions button:not([hidden]) { flex: 1; }
.share-msg { min-height: 1.2em; margin: 8px 0 0; }

.support { text-align: center; }
.support p { margin: 0 0 12px; color: var(--text-2); font-size: 14px; line-height: 1.45; }
.support-btn { display: inline-block; padding: 11px 18px; border-radius: 12px; text-decoration: none; }

.app-meta { text-align: center; padding: 4px 0 2px; }
.version-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent;
  color: var(--muted); font-size: 13px; padding: 8px 12px; cursor: pointer; border-radius: 8px;
}
.version-btn:active { transform: scale(0.97); }
.unseen-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--up); }
.credit { font-size: 12px; color: var(--muted); margin: 0; }
.credit + .credit { margin-top: 6px; }

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 30; background: rgb(0 0 0 / 0.4);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 480px; background: var(--surface); color: var(--text);
  border-radius: 18px 18px 0 0; padding: 20px 20px calc(env(safe-area-inset-bottom) + 16px);
  animation: sheet-up 0.2s ease-out;
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet h3 { margin: 0; font-size: 18px; }
.sheet-body { margin-top: 14px; max-height: 55vh; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 18px; }
.sheet-body h4 { margin: 0; display: flex; align-items: baseline; gap: 8px; font-size: 15px; }
.sheet-body h4 span { font-weight: 400; font-size: 13px; color: var(--muted); }
.sheet-body ul { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.sheet-body li { display: flex; gap: 8px; font-size: 14px; color: var(--text-2); line-height: 1.45; }
.sheet-body li::before { content: "•"; color: var(--accent); }
.sheet-close { margin-top: 14px; width: 100%; border: 0; background: transparent; color: var(--muted); font-size: 14px; padding: 10px; cursor: pointer; }
