/* FindMargin — дизайн-система. Мобильный премиум-минимализм. */
:root {
  --bg: #f5f5f7;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --ink: #0b0c0f;
  --ink-soft: #3d4149;
  --muted: #71767f;
  --line: rgba(11, 12, 15, 0.09);
  --line-strong: rgba(11, 12, 15, 0.16);
  --accent: #3b5bff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(59, 91, 255, 0.1);
  --lime: #b8f03c;
  --ok: #12b981;
  --warn: #e9a13b;
  --bad: #e5484d;
  --shadow-s: 0 1px 2px rgba(11, 12, 15, 0.05);
  --shadow-m: 0 2px 6px rgba(11, 12, 15, 0.05), 0 18px 40px -28px rgba(11, 12, 15, 0.35);
  --r-lg: 26px;
  --r-md: 18px;
  --r-sm: 12px;
  --tab-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #07080b;
  --bg-elev: #0c0e12;
  --surface: #111318;
  --surface-2: #171a21;
  --ink: #f4f5f7;
  --ink-soft: #c9ccd3;
  --muted: #8b909a;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #6d84ff;
  --accent-ink: #0a0b0f;
  --accent-soft: rgba(109, 132, 255, 0.14);
  --lime: #c8ff4d;
  --ok: #2fd39a;
  --warn: #f0b354;
  --bad: #ff6b6b;
  --shadow-s: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-m: 0 2px 8px rgba(0, 0, 0, 0.4), 0 24px 60px -32px rgba(0, 0, 0, 0.9);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}
@media (min-width: 720px) {
  body { background: var(--bg); }
  .shell { margin: 0 auto; max-width: 560px; min-height: 100vh; background: var(--bg); }
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
::selection { background: var(--accent-soft); }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.shell { padding-bottom: calc(var(--tab-h) + var(--safe-b) + 18px); }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(145deg, #4c6bff, #b8f03c 140%);
  color: #0a0b0f; font-weight: 800; font-size: 12.5px;
  display: grid; place-items: center; letter-spacing: -.04em;
}
.brand-name { font-weight: 660; font-size: 16.5px; letter-spacing: -.02em; }
.brand-name span { color: var(--muted); font-weight: 500; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  color: var(--ink-soft); border: 1px solid transparent; transition: background .16s, border-color .16s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.95); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: var(--bg); font-weight: 650; font-size: 13px;
}
main.view { padding: 4px 18px 24px; animation: fade .22s cubic-bezier(.2,.8,.2,1); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- typography ---------- */
h1, h2, h3 { margin: 0; letter-spacing: -.028em; font-weight: 660; }
h1 { font-size: 27px; line-height: 1.15; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
.eyebrow {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); font-weight: 600;
}
.lead { color: var(--muted); font-size: 14.5px; margin: 6px 0 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 650; }
.alert-title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-width: 0; padding-right: 6px;
}

/* ---------- layout ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 0 10px; }
.section-head h2 { font-size: 17px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 16px; box-shadow: var(--shadow-s);
}
.card-flat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.hr { height: 1px; background: var(--line); margin: 12px 0; border: 0; }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(120% 90% at 88% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%),
    var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px; box-shadow: var(--shadow-m);
}
.hero h1 { font-size: 26px; }
.hero .lead { max-width: 30ch; }
.dropzone {
  margin-top: 16px; border: 1.5px dashed var(--line-strong); border-radius: 20px;
  padding: 22px 16px; text-align: center; transition: border-color .18s, background .18s, transform .18s;
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}
.dropzone:active { transform: scale(.995); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.has-photo { border-style: solid; padding: 0; overflow: hidden; background: var(--surface-2); }
.dropzone img.preview { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 18px; }
.dz-icon {
  width: 54px; height: 54px; border-radius: 17px; margin: 0 auto 10px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.dz-title { font-weight: 620; font-size: 15.5px; }
.dz-hint { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.cta-row { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 50px; padding: 0 18px; border-radius: 15px; font-weight: 620; font-size: 15px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  transition: transform .14s cubic-bezier(.2,.8,.2,1), background .16s, opacity .16s, border-color .16s;
  white-space: nowrap;
}
.btn:active { transform: scale(.975); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
[data-theme="dark"] .btn-primary { color: #0a0b0f; }
.btn-primary:disabled { opacity: .45; }
.btn-ghost { background: transparent; }
.btn-soft { background: var(--surface-2); border-color: transparent; }
.btn-sm { height: 38px; padding: 0 13px; border-radius: 12px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 550; color: var(--ink-soft);
  transition: background .16s, color .16s, border-color .16s;
}
.chip[aria-pressed="true"], .chip.active { background: var(--ink); color: var(--bg); border-color: transparent; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .7; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  background: var(--surface-2); color: var(--ink-soft);
}
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.pill-warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.pill-demo { background: var(--surface-2); color: var(--muted); }
.badge-mp { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.badge-mp i { width: 8px; height: 8px; border-radius: 50%; display: block; }

/* ---------- tabs / nav ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
@media (min-width: 720px) { .tabbar { max-width: 560px; margin: 0 auto; border-radius: 20px 20px 0 0; } }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 10.5px; font-weight: 550; position: relative;
  transition: color .16s;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--ink); }
.tab.active::before {
  content: ""; position: absolute; top: 6px; width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent); transform: translateY(-6px);
}
.seg { display: flex; background: var(--surface-2); border-radius: 13px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; height: 34px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--muted);
}
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-s); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.input, select.input, textarea.input {
  height: 50px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); padding: 0 14px; color: var(--ink); width: 100%;
  transition: border-color .16s, box-shadow .16s;
  font-size: 15px;
}
textarea.input { height: auto; padding: 13px 14px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hint { font-size: 11.5px; color: var(--muted); }

/* ---------- offer card ---------- */
.offers { display: flex; flex-direction: column; gap: 10px; }
.offer {
  display: grid; grid-template-columns: 84px 1fr; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 10px; box-shadow: var(--shadow-s); position: relative;
  transition: border-color .16s, transform .16s;
}
.offer:active { transform: scale(.995); }
.offer.best { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.offer-img {
  width: 84px; height: 84px; border-radius: 13px; object-fit: cover; background: var(--surface-2);
}
.offer-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.offer-title {
  font-size: 13.5px; font-weight: 570; line-height: 1.3; letter-spacing: -.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.offer-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 11.5px; }
.offer-price { font-size: 19px; font-weight: 700; letter-spacing: -.03em; }
.offer-price small { font-size: 11.5px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.offer-side { position: absolute; right: 10px; bottom: 10px; display: flex; align-items: center; gap: 6px; }
.offer-body .offer-meta:last-child { padding-right: 104px; }
.match {
  --p: 80; width: 34px; height: 34px; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-2) 0);
  display: grid; place-items: center;
}
.match span {
  width: 26px; height: 26px; border-radius: 50%; background: var(--surface);
  display: grid; place-items: center; font-size: 9.5px; font-weight: 700; letter-spacing: -.02em;
}
.fav-btn { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); }
.fav-btn.on { color: var(--bad); }
.fav-btn.on svg { fill: currentColor; }

/* ---------- summary ---------- */
.summary {
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 9%, var(--surface)), var(--surface));
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow-s);
}
.summary .big { font-size: 30px; font-weight: 700; letter-spacing: -.035em; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.kpi { background: color-mix(in srgb, var(--surface) 70%, transparent); border-radius: 13px; padding: 9px 10px; }
.kpi .l { font-size: 10.5px; color: var(--muted); letter-spacing: .01em; }
.kpi .v { font-size: 15px; font-weight: 660; letter-spacing: -.02em; margin-top: 2px; }
.recognized {
  display: flex; gap: 12px; align-items: flex-start; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px;
}
.recognized img { width: 66px; height: 66px; border-radius: 12px; object-fit: cover; }

/* ---------- charts ---------- */
.chart { width: 100%; height: 120px; display: block; overflow: visible; }
.chart .area { fill: color-mix(in srgb, var(--accent) 14%, transparent); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
.chart .dot { fill: var(--accent); }
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 1fr 60px; gap: 8px; align-items: center; }
.bar-label { font-size: 12.5px; color: var(--ink-soft); }
.bar-track { height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 99px; }
.bar-fill.ok { background: var(--ok); }
.bar-value { text-align: right; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- table ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line);
}
.table td { padding: 10px 6px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }

/* ---------- sheets / modals ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(6, 7, 10, .48); backdrop-filter: blur(3px);
  z-index: 60; opacity: 0; transition: opacity .2s; display: flex; align-items: flex-end;
  justify-content: center;
}
.sheet-backdrop.show { opacity: 1; }
.sheet {
  width: 100%; max-width: 560px; background: var(--bg-elev); border-radius: 26px 26px 0 0;
  padding: 10px 18px calc(20px + var(--safe-b)); max-height: 88vh; overflow-y: auto;
  transform: translateY(14px); transition: transform .24s cubic-bezier(.2,.8,.2,1);
  border-top: 1px solid var(--line);
}
.sheet-backdrop.show .sheet { transform: none; }
.sheet-grab { width: 38px; height: 4px; border-radius: 99px; background: var(--line-strong); margin: 4px auto 14px; }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .ico { width: 54px; height: 54px; border-radius: 18px; background: var(--surface-2); display: grid; place-items: center; margin: 0 auto 12px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 10px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 22px); transform: translate(-50%, 12px);
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 13px; font-size: 13px;
  z-index: 80; opacity: 0; transition: all .22s cubic-bezier(.2,.8,.2,1); max-width: 88vw; text-align: center;
  pointer-events: none;
  box-shadow: var(--shadow-m);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: #04150f; }
.demo-note {
  display: flex; gap: 8px; align-items: flex-start; font-size: 11.5px; color: var(--muted);
  border: 1px dashed var(--line-strong); border-radius: 12px; padding: 9px 11px; line-height: 1.4;
}
.demo-note b { color: var(--ink-soft); font-weight: 600; }
.demo-note svg { width: 14px; height: 14px; flex: 0 0 14px; margin-top: 1px; opacity: .75; }
.plan-card {
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; background: var(--surface);
  display: flex; flex-direction: column; gap: 10px;
}
.plan-card.current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.plan-price { font-size: 24px; font-weight: 700; letter-spacing: -.03em; }
.plan-features { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.plan-features li { font-size: 12.5px; color: var(--ink-soft); display: flex; gap: 7px; }
.plan-features li::before { content: "✓"; color: var(--ok); font-weight: 700; }
.usage-bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.usage-bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.stat-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.stat-row:last-child { border-bottom: 0; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link { color: var(--accent); font-weight: 600; }
.scroll-x { overflow-x: auto; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }
.toggle { width: 44px; height: 26px; border-radius: 99px; background: var(--surface-2); position: relative; transition: background .18s; border: 1px solid var(--line); }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); transition: transform .18s; box-shadow: var(--shadow-s); }
.toggle.on { background: var(--accent); border-color: transparent; }
.toggle.on::after { transform: translateX(18px); background: #fff; }
