:root {
  --brand: #39A9A5;
  --accent: #007B78;
  --accent-strong: #005452;
  --paper: #F4F7F7;
  --card: #FFFFFF;
  --ink: #0F2524;
  --ink-2: #2E4746;
  --muted: #5E7372;
  --rule: #DCE5E4;
  --good: #1D7A47;
  --good-bg: #E3F3EA;
  --warn: #B3261E;
  --warn-bg: #FCE9E7;
  --amber: #8A5A00;
  --amber-bg: #FFF3D6;
  --r: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #CFD8D7; }
body {
  font: 16px/1.45 "Public Sans", system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: Poppins, sans-serif; margin: 0; letter-spacing: -0.01em; }

#app {
  position: relative;
  max-width: 440px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 600px) {
  #app { height: min(920px, 100dvh - 40px); margin-top: 20px; border-radius: 28px; box-shadow: 0 0 0 10px #111, 0 20px 60px rgba(0,0,0,.25); }
}

/* ---------- top bar ---------- */
#bar {
  background: #1C252E;
  color: #fff;
  padding: calc(var(--safe-t) + 14px) 18px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  flex: none;
}
#logo { height: 19px; }
#title { font-size: 18px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#dealer { margin-left: auto; font-size: 14px; opacity: .85; font-weight: 500; }
#title:not([hidden]) ~ #dealer { display: none; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; margin-left: -8px; border-radius: 8px; }
.icon-btn:active { background: rgba(255,255,255,.15); }

#view { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 24px; }
.pad { padding: 18px; }

/* ---------- tabs ---------- */
#tabs {
  flex: none;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  background: var(--card);
  border-top: 1px solid var(--rule);
  padding: 6px 6px calc(var(--safe-b) + 6px);
}
#tabs button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: var(--muted); font-size: 12px; font-weight: 600; }
#tabs button svg { width: 25px; height: 25px; }
#tabs button.on { color: var(--accent); }
#tabs .plus { justify-self: center; width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: #fff; justify-content: center; margin-top: -22px; box-shadow: 0 4px 14px rgba(0,84,82,.35); }
#tabs .plus svg { width: 28px; height: 28px; }
#tabs .plus:active { background: var(--accent-strong); }
#badge { position: absolute; top: 0; left: 50%; margin-left: 6px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--warn); color: #fff; font-size: 12px; line-height: 19px; text-align: center; }

/* ---------- common ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 16px 18px 6px; }
.stat { background: var(--card); border-radius: var(--r); padding: 12px; border: 1px solid var(--rule); }
.stat b { display: block; font: 600 22px/1.1 Poppins, sans-serif; }
.stat span { font-size: 13px; color: var(--muted); }

.alert { margin: 12px 18px 0; display: flex; gap: 12px; align-items: center; padding: 13px 14px; border-radius: var(--r); background: var(--warn-bg); color: var(--warn); font-weight: 600; font-size: 15px; width: calc(100% - 36px); text-align: left; }
.alert small { display: block; font-weight: 500; color: #7a2a24; font-size: 13px; }
.alert .arrow { margin-left: auto; font-size: 20px; }

.section-h { display: flex; justify-content: space-between; align-items: baseline; padding: 22px 18px 8px; }
.section-h h2 { font-size: 17px; }
.section-h span { font-size: 14px; color: var(--muted); }

.car { display: flex; gap: 12px; width: 100%; text-align: left; padding: 10px 18px; align-items: center; }
.car:active { background: #E8EFEE; }
.car .ph { position: relative; width: 112px; height: 78px; border-radius: 8px; overflow: hidden; flex: none; background: #ccc; }
.car .ph img { width: 100%; height: 100%; object-fit: cover; }
.car .info { flex: 1; min-width: 0; }
.car h3 { font-size: 16px; font-weight: 600; }
.car .sub { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.car .row { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.price { font: 600 16px Poppins, sans-serif; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 5px; }
.tag.new { background: var(--accent); color: #fff; }
.tag.sold { background: var(--ink); color: #fff; }
.tag.res { background: var(--amber-bg); color: var(--amber); }
.tag.leads { background: var(--warn-bg); color: var(--warn); }
.ph .tag { position: absolute; top: 6px; left: 6px; }
.channels { display: flex; gap: 5px; margin-top: 5px; }
.ch { font-size: 11px; font-weight: 700; color: var(--good); background: var(--good-bg); padding: 2px 6px; border-radius: 4px; }
.ch.off { color: var(--muted); background: #EBEFEF; }

.foot { font-size: 12.5px; color: var(--muted); text-align: center; padding: 26px 30px 6px; }

/* ---------- detail ---------- */
.hero { position: relative; aspect-ratio: 16/10; background: #222; overflow: hidden; }
.hero .strip { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; }
.hero .strip img { flex: none; width: 100%; height: 100%; object-fit: cover; scroll-snap-align: start; }
.hero .count { position: absolute; right: 10px; bottom: 10px; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; padding: 3px 8px; border-radius: 6px; }
.d-head { padding: 16px 18px 4px; }
.d-head h2 { font-size: 22px; }
.d-head .sub { color: var(--muted); }
.d-head .price { font-size: 24px; margin-top: 6px; display: block; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--rule); margin: 14px 18px; border-radius: var(--r); overflow: hidden; border: 1px solid var(--rule); }
.facts div { background: var(--card); padding: 10px 12px; }
.facts span { display: block; font-size: 12.5px; color: var(--muted); }
.facts b { font-weight: 600; font-size: 15px; }
.perf { margin: 0 18px; background: var(--card); border: 1px solid var(--rule); border-radius: var(--r); padding: 4px 14px; }
.perf .line { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 15px; }
.perf .line:last-child { border: 0; }
.perf .line b { font-weight: 600; }
.ok { color: var(--good); font-weight: 600; }

.lead { display: flex; gap: 12px; padding: 12px 18px; align-items: flex-start; width: 100%; text-align: left; border-bottom: 1px solid var(--rule); background: var(--card); }
.lead:active { background: #EEF3F3; }
.av { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 15px; }
.lead .body { flex: 1; min-width: 0; }
.lead .top { display: flex; justify-content: space-between; gap: 8px; }
.lead .top b { font-weight: 600; }
.lead .top small { color: var(--muted); font-size: 13px; white-space: nowrap; }
.lead p { margin: 2px 0 0; font-size: 15px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lead .meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.lead .late { color: var(--warn); font-weight: 700; }
.lead.unread b::after { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: 7px; vertical-align: middle; }

.seg { display: flex; margin: 14px 18px 8px; background: #E3EAEA; border-radius: 9px; padding: 3px; }
.seg button { flex: 1; padding: 8px 0; font-size: 14px; font-weight: 600; color: var(--ink-2); border-radius: 7px; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.1); }

/* ---------- buttons ---------- */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 52px; border-radius: var(--r); background: var(--accent); color: #fff; font-weight: 700; font-size: 16px; }
.btn:active { background: var(--accent-strong); }
.btn.ghost { background: var(--card); color: var(--accent); border: 1.5px solid var(--accent); }
.btn.ghost:active { background: #E6F2F1; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sticky { position: sticky; bottom: 0; padding: 12px 18px; background: linear-gradient(transparent, var(--paper) 18%); }
.link { color: var(--accent); font-weight: 600; font-size: 15px; display: block; margin: 14px auto 0; }

/* ---------- forms ---------- */
.step { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.h { font-size: 22px; margin-bottom: 4px; }
.lede { color: var(--ink-2); margin: 0 0 16px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; color: var(--ink-2); }
.field input, .field select { width: 100%; height: 50px; border: 1.5px solid var(--rule); border-radius: var(--r); padding: 0 14px; background: var(--card); font-size: 17px; outline: none; }
.field input:focus { border-color: var(--accent); }
.reg { display: flex; align-items: stretch; height: 64px; border: 2px solid var(--ink); border-radius: 9px; overflow: hidden; background: #fff; margin-bottom: 14px; }
.reg .eu { width: 34px; background: #1F4FA8; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 7px; font: 700 13px Public Sans, sans-serif; }
.reg input { flex: 1; border: 0; font: 700 30px/1 "Public Sans", sans-serif; letter-spacing: .06em; text-transform: uppercase; padding: 0 14px; outline: none; min-width: 0; }

.shots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; }
.shots div { aspect-ratio: 4/3; border-radius: 7px; overflow: hidden; position: relative; background: #ddd; }
.shots img { width: 100%; height: 100%; object-fit: cover; }
.shots div:first-child { grid-column: span 3; aspect-ratio: 16/10; }
.shots .main { position: absolute; left: 8px; top: 8px; }
.camzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; aspect-ratio: 16/10; border: 2px dashed #A9BDBC; border-radius: var(--r); color: var(--accent); font-weight: 700; margin-bottom: 14px; width: 100%; background: var(--card); }
.camzone svg { width: 44px; height: 44px; }
.camzone small { color: var(--muted); font-weight: 500; }

.spec { background: var(--card); border: 1px solid var(--rule); border-radius: var(--r); margin-bottom: 14px; }
.spec .line { display: flex; justify-content: space-between; padding: 11px 14px; border-bottom: 1px solid var(--rule); font-size: 15px; }
.spec .line:last-child { border: 0; }
.spec .line span { color: var(--muted); }
.spec .line b { font-weight: 600; text-align: right; }
.source { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--good); font-weight: 600; margin-bottom: 10px; }

.shimmer { height: 18px; border-radius: 5px; background: linear-gradient(90deg, #E7EDED 0%, #F5F8F8 50%, #E7EDED 100%); background-size: 200% 100%; animation: sh 1s infinite linear; }
@keyframes sh { to { background-position: -200% 0; } }

.hint { background: var(--good-bg); color: #164F31; border-radius: var(--r); padding: 12px 14px; font-size: 14.5px; margin-bottom: 14px; }
.hint b { font-weight: 700; }

.toggle { display: flex; align-items: center; gap: 12px; padding: 13px 14px; background: var(--card); border-bottom: 1px solid var(--rule); width: 100%; text-align: left; }
.toggle:first-child { border-radius: var(--r) var(--r) 0 0; }
.toggle:last-child { border-radius: 0 0 var(--r) var(--r); border: 0; }
.toggles { border: 1px solid var(--rule); border-radius: var(--r); margin-bottom: 16px; overflow: hidden; }
.toggle .t { flex: 1; }
.toggle .t b { display: block; font-weight: 600; }
.toggle .t small { color: var(--muted); font-size: 13px; }
.sw { width: 46px; height: 28px; border-radius: 14px; background: #C9D4D3; position: relative; flex: none; transition: background .2s; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s; }
.toggle.on .sw { background: var(--accent); }
.toggle.on .sw::after { transform: translateX(18px); }

.progress .p { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--rule); font-size: 16px; }
.progress .p:last-child { border: 0; }
.dot { width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid #C9D4D3; flex: none; display: grid; place-items: center; }
.p.busy .dot { border-color: var(--accent); border-right-color: transparent; animation: spin .7s linear infinite; }
.p.done .dot { background: var(--good); border-color: var(--good); }
.p.done .dot::after { content: ""; width: 10px; height: 5px; border: 2.5px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.p.done { color: var(--ink); }
.p { color: var(--muted); }
.p small { margin-left: auto; color: var(--muted); font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }

.done-hero { text-align: center; padding: 26px 18px 6px; }
.big-check { width: 72px; height: 72px; border-radius: 50%; background: var(--good); margin: 0 auto 14px; display: grid; place-items: center; animation: pop .45s cubic-bezier(.2,1.4,.4,1); }
.big-check::after { content: ""; width: 28px; height: 14px; border: 5px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(2px, -3px); }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.done-hero h2 { font-size: 24px; }
.done-hero p { color: var(--ink-2); margin: 6px 0 0; }

/* ---------- chat ---------- */
.chat { padding: 14px 14px 0; display: flex; flex-direction: column; gap: 8px; }
.bub { max-width: 82%; padding: 9px 13px; border-radius: 16px; font-size: 15.5px; line-height: 1.4; }
.bub.them { background: var(--card); border: 1px solid var(--rule); align-self: flex-start; border-bottom-left-radius: 5px; }
.bub.me { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 5px; }
.bub small { display: block; font-size: 12px; opacity: .7; margin-top: 3px; }
.chat-car { display: flex; gap: 10px; align-items: center; margin: 12px 14px 0; padding: 8px; background: var(--card); border: 1px solid var(--rule); border-radius: var(--r); width: calc(100% - 28px); text-align: left; }
.chat-car img { width: 64px; height: 44px; object-fit: cover; border-radius: 6px; }
.chat-car b { font-weight: 600; font-size: 15px; }
.chat-car span { display: block; font-size: 13px; color: var(--muted); }
.quick { display: flex; gap: 8px; overflow-x: auto; padding: 12px 14px 4px; }
.quick button { flex: none; padding: 8px 12px; border-radius: 9px; background: #E2EEED; color: var(--accent-strong); font-weight: 600; font-size: 14px; }
.compose { display: flex; gap: 8px; padding: 8px 14px 12px; }
.compose input { flex: 1; height: 46px; border-radius: 23px; border: 1.5px solid var(--rule); padding: 0 16px; background: var(--card); outline: none; font-size: 16px; }
.compose button { width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }
.call { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 14px 0; }
.call a, .call button { display: flex; align-items: center; justify-content: center; gap: 7px; height: 44px; border-radius: var(--r); background: var(--card); border: 1px solid var(--rule); font-weight: 600; color: var(--ink); text-decoration: none; font-size: 15px; }
.after { margin: 12px 14px 0; padding: 10px 12px; border-radius: var(--r); background: var(--amber-bg); color: var(--amber); font-size: 14px; font-weight: 600; }

/* ---------- signature ---------- */
.contract { background: var(--card); border: 1px solid var(--rule); border-radius: var(--r); padding: 4px 14px; margin-bottom: 14px; }
.contract .line { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 15px; }
.contract .line:last-child { border: 0; }
.contract .line span { color: var(--muted); }
.contract .line b { font-weight: 600; }
.contract .total b { font: 600 18px Poppins, sans-serif; }
.sig-wrap { position: relative; background: #fff; border: 1.5px solid var(--ink); border-radius: var(--r); height: 200px; margin-bottom: 8px; touch-action: none; }
.sig-wrap canvas { width: 100%; height: 100%; display: block; }
.sig-wrap .lbl { position: absolute; left: 14px; bottom: 34px; right: 14px; border-top: 1.5px solid #B9C6C5; padding-top: 4px; font-size: 13px; color: var(--muted); pointer-events: none; }
.sig-wrap .x { position: absolute; left: 14px; bottom: 40px; font-size: 22px; color: #B9C6C5; pointer-events: none; }
.clear { font-size: 14px; color: var(--accent); font-weight: 600; float: right; }

/* ---------- salg ---------- */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding: 0 18px; margin-top: 8px; }
.chart div { flex: 1; background: #B7DCDA; border-radius: 4px 4px 0 0; position: relative; }
.chart div.now { background: var(--accent); }
.chart div span { position: absolute; bottom: -20px; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--muted); }
.chart-wrap { background: var(--card); margin: 0 18px; border-radius: var(--r); border: 1px solid var(--rule); padding: 16px 0 28px; }
.chart-wrap h3 { padding: 0 18px; font-size: 15px; }
.chart-wrap .big { padding: 0 18px; font: 600 26px Poppins, sans-serif; }

#toast { position: absolute; left: 18px; right: 18px; bottom: calc(var(--safe-b) + 84px); background: var(--ink); color: #fff; padding: 13px 16px; border-radius: var(--r); font-weight: 600; font-size: 15px; z-index: 9; animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(12px); opacity: 0; } }

.fade { animation: fade .22s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

[hidden] { display: none !important; }
