:root {
  color-scheme: light;
  --canvas: #f5f4ef;
  --paper: #fff;
  --ink: #20242c;
  --muted: #565c66;
  --line: #d8d9d5;
  --blue: #2648a3;
  --bad: #a12c31;
  font: 16px/1.5 system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
.shell { width: min(1060px, calc(100% - 48px)); margin-inline: auto; }
header { background: var(--paper); border-bottom: 1px solid var(--line); }
.top { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { color: var(--ink); text-decoration: none; font-size: 1.45rem; font-weight: 800; letter-spacing: -.055em; }
.brand span { color: var(--blue); }
.local, .hint { color: var(--muted); font-size: .875rem; }

nav { display: flex; gap: 24px; border-bottom: 1px solid var(--line); }
nav a { padding: 13px 1px 11px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; font-size: .925rem; }
nav a:hover, nav a[aria-current] { color: var(--blue); }
nav a[aria-current] { border-bottom-color: currentColor; font-weight: 650; }

main { padding-bottom: 32px; }
.intro { margin: 24px 0 18px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.7rem, 4vw, 2.2rem); line-height: 1.15; letter-spacing: -.04em; font-weight: 720; }
h2 { font-size: 1.0625rem; line-height: 1.3; }
h3 { font-size: .925rem; }
.intro p, .card-head p { margin-top: 5px; color: var(--muted); font-size: .875rem; }
.grid { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); gap: 16px; }
.card, dialog { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 20px; min-width: 0; }
.card-head, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 15px 0 12px; }
label { display: grid; gap: 4px; color: var(--muted); font-size: .875rem; }
input, select, button { font: inherit; border-radius: 4px; }
input, select { width: 100%; min-width: 0; min-height: 38px; padding: 6px 9px; background: var(--paper); color: var(--ink); border: 1px solid #bfc2c4; font-size: 1rem; }
select { appearance: none; padding-right: 26px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%; background-size: 4px 4px; background-repeat: no-repeat; }
button { min-height: 36px; padding: 6px 11px; cursor: pointer; font-size: .875rem; font-weight: 650; }
.primary { color: white; background: var(--blue); border: 1px solid var(--blue); }
.secondary { color: var(--ink); background: var(--paper); border: 1px solid #bfc2c4; }
.primary:hover { background: #1d397f; }
.secondary:hover { background: #eef2fa; border-color: var(--blue); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
#save-calculation { margin-top: 12px; }

.result { border-top: 3px solid var(--blue); padding-top: 18px; }
.hero-result { display: grid; gap: 2px; margin-top: 13px; }
.hero-result span { color: var(--muted); font-size: .875rem; }
.hero-result strong { color: var(--blue); font-size: clamp(2rem, 5vw, 2.85rem); font-weight: 700; letter-spacing: -.05em; line-height: 1.1; overflow-wrap: anywhere; }
dl { margin: 9px 0; }
dl div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .875rem; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.competition { margin-top: 14px; }
.competition p, #supplier-result, #notice { font-size: .875rem; color: var(--muted); }
.competition .bad, #editor-error { color: var(--bad); }
.competition .caution { color: #815216; }

.suppliers { margin-top: 16px; }
#supplier-result { margin-top: 10px; }
.supplier, .entry { display: grid; align-items: end; gap: 10px; margin-top: 12px; }
.supplier { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; }
.supplier button { min-height: 38px; }
.entry { grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.entry p, .empty { color: var(--muted); margin-top: 4px; font-size: .875rem; }
#product-list { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding-inline: 16px; }
#product-list > :last-child { border: none; margin-bottom: 0; }
#product-list > .empty { margin: 0; padding-inline: 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.metrics strong { display: block; font-size: 1.4rem; overflow-wrap: anywhere; }
.metrics span { color: var(--muted); font-size: .875rem; }

dialog { color: var(--ink); width: min(510px, calc(100% - 28px)); max-height: calc(100dvh - 28px); }
dialog::backdrop { background: #20242c80; }
#editor-error:not(:empty), #notice:not(:empty) { margin-block: 10px; }

@media (max-width: 680px) {
  .shell { width: calc(100% - 28px); }
  .top { min-height: 54px; }
  nav { gap: 16px; }
  nav a { font-size: .875rem; }
  .card { padding: 15px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .intro { margin-top: 20px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .entry:has(.actions) { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .suppliers .card-head, .section-heading { align-items: flex-start; flex-direction: column; }
  .supplier { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto; gap: 6px; }
}

/* FlipCore theme */
:root {
  color-scheme: dark;
  --canvas: #101729;
  --paper: #19243a;
  --ink: #f5f1ec;
  --muted: #b5c0d4;
  --line: #35435d;
  --blue: #ffba9b;
  --bad: #ffa9aa;
  font-family: "Golos Text", "Segoe UI", system-ui, sans-serif;
}

body {
  min-height: 100vh;
  background: radial-gradient(ellipse at 95% 0%, #243758 0%, transparent 48rem), var(--canvas);
}
header { background: #101729cc; border-color: #ffffff18; }
.top { min-height: 67px; }
.brand { display: inline-flex; gap: 10px; align-items: center; letter-spacing: -.055em; }
.brand-mark {
  display: inline-block;
  width: 29px;
  height: 29px;
  border-radius: 7px;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='14' fill='%23151f34'/%3E%3Cpath fill='%23ffba9b' d='M17 15h31l-7 8H26v6h12l-7 8h-5v12h-9z'/%3E%3C/svg%3E");
  outline: 1px solid #ffba9b55;
}

.telegram-app main {
  padding-bottom: calc(32px + max(env(safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px)));
}
nav { gap: 26px; border-color: #ffffff24; }
nav a { padding-block: 16px 12px; transition: color .18s, border-color .18s; }
nav a[aria-current] { color: var(--blue); }

.intro { margin: 27px 0 17px; }
.calculator-intro {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: center;
  min-height: 180px;
  padding: 24px clamp(18px, 4vw, 38px);
  border: 1px solid #7d96bd65;
  border-radius: 16px;
  background: linear-gradient(115deg, #202f4a, #294266);
}
.calculator-intro h1 {
  font-size: clamp(2.05rem, 5.5vw, 3.9rem);
  letter-spacing: -.065em;
  line-height: 1;
  font-weight: 750;
}
.title-break { display: none; }
.intro-bars {
  position: absolute;
  z-index: -1;
  inset: 14px 0 0 auto;
  width: 34%;
  display: flex;
  align-items: end;
  gap: 6px;
  padding-inline: 8px 22px;
  opacity: .65;
  pointer-events: none;
}
.intro-bars i {
  display: block;
  flex: 1;
  height: var(--bar);
  min-height: 8px;
  border-radius: 5px 5px 0 0;
  border: 1px solid #c9d9ff40;
  background: linear-gradient(#8cabe36e, #5875a629);
  transform-origin: bottom;
  animation: bar-in .58s cubic-bezier(.22,.8,.3,1) both;
  animation-delay: var(--delay, 0s);
}
.intro-bars i:nth-child(1) { --bar: 18%; }
.intro-bars i:nth-child(2) { --bar: 31%; --delay: .045s; }
.intro-bars i:nth-child(3) { --bar: 24%; --delay: .09s; }
.intro-bars i:nth-child(4) { --bar: 52%; --delay: .135s; }
.intro-bars i:nth-child(5) { --bar: 46%; --delay: .18s; }
.intro-bars i:nth-child(6) { --bar: 68%; --delay: .225s; }
.intro-bars i:nth-child(7) { --bar: 88%; --delay: .27s; background: linear-gradient(#ffba9bbd, #ffba9b30); }
@keyframes bar-in { from { transform: scaleY(.08); opacity: 0; } }
@keyframes reveal { from { opacity: 0; transform: translateY(14px); } }
.supplier, dialog[open], #custom-market-field:not([hidden]), #custom-currency-field:not([hidden]), #rate-field:not([hidden]) {
  animation: reveal .42s cubic-bezier(.16,1,.3,1) both;
}
main { overflow-x: clip; }
nav a { position: relative; border-bottom-color: transparent !important; }
nav a::after {
  content: "";
  position: absolute;
  inset: auto 0 -2px;
  height: 2px;
  border-radius: 2px;
  background: var(--blue);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .38s cubic-bezier(.16,1,.3,1);
}
nav a[aria-current]::after { transform: scaleX(1); }
main > section { scroll-margin-top: 16px; }

.grid { gap: 14px; }
.card, dialog, #product-list { border-radius: 13px; }
.card, dialog { padding: 20px; }
.result {
  border: 1px solid #546884;
  background: linear-gradient(155deg, #243655, #18263e 75%);
}
.hero-result {
  padding: 12px 14px;
  border: 1px solid #ffba9b4d;
  border-radius: 9px;
  background: #ffba9b10;
}
.hero-result strong {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.065em;
}
#target-profit { color: var(--ink); font-variant-numeric: tabular-nums; }
#plans { max-width: 820px; margin-inline: auto; }
.plans-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.card.plan {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: clamp(18px, 3vw, 26px);
  border-radius: 18px;
  background: linear-gradient(150deg, #24334d, #172237 75%);
}
.card.plan-pro {
  border-color: #ffba9b80;
  background: radial-gradient(ellipse at 100% 0%, #745366 0%, transparent 68%), #222e49;
}
.plan-pro::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: 180px;
  height: 180px;
  top: -95px;
  right: -60px;
  border-radius: 50%;
  border: 1px solid #ffcfb55c;
  box-shadow: 0 0 0 14px #ffcfb519, 0 0 0 28px #ffcfb515, 0 0 0 42px #ffcfb511;
}
.plan-heading { display: flex; align-items: center; gap: 10px; }
.plan-heading h2 { font-size: 1.1rem; }
.plan-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  color: #c4d5ff;
  background: #afc6ff26;
}
.plan-pro .plan-icon { color: #39263a; background: #ffba9b; }
.plan-badge { margin-left: auto; border: 1px solid #ffba9b73; padding: 3px 8px; border-radius: 20px; color: #ffdbc9; font-size: .75rem; }
.plan-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 8px; margin: 11px 0 13px; }
.plan-price strong { font-size: clamp(2.2rem, 5.4vw, 3.3rem); line-height: 1.18; letter-spacing: -.065em; }
.plan-price span { color: var(--muted); font-size: .875rem; }
.plan-pro .plan-price strong { color: #ffc3a6; }
.plan ul { list-style: none; padding: 13px 0 0; margin: 0 0 18px; border-top: 1px solid #ffffff26; }
.plan li { display: grid; grid-template-columns: 1.1em 1fr; gap: 7px; font-size: .875rem; }
.plan li + li { margin-top: 7px; }
.plan li::before { content: "✓"; color: #b8cff9; }
.plan-pro li::before { color: #ffc3a6; }
.plan-link, .plan-status {
  margin-top: auto;
  padding: 8px 10px;
  border-radius: 8px;
  text-align: center;
  font-size: .875rem;
}
.plan-link { background: #dbe6ff; color: #182745; font-weight: 650; text-decoration: none; }
.plan-link:hover { background: #fff; }
.plan-status { color: #ffdbc9; background: #ffba9b17; border: 1px solid #ffba9b45; }
.plan #subscribe { margin-top: auto; margin-bottom: 8px; }
.analytics-tools { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
@media (max-width: 540px) {
  nav { gap: clamp(8px, 3vw, 16px); }
  .plans-grid { grid-template-columns: 1fr; }
}
dl div { padding-block: 7px; }
.competition .caution { color: #ffd098; }
input, select, button { border-radius: 7px; }
input, select { background-color: #111c30; border-color: #465570; transition: border-color .18s, background-color .18s; }
input:hover, select:hover { border-color: #7485a0; }
button { transition: background-color .18s, border-color .18s, transform .18s; }
button:active { transform: translateY(1px); }
.primary { color: #27212a; }
.primary:hover { background: #ffd2bd; border-color: #ffd2bd; }
.secondary { border-color: #54637e; background: #25334e; }
.secondary:hover { background: #324466; border-color: #a8b9d6; }
.suppliers { border-left: 3px solid #8ca8de; }
#notice { color: var(--blue); }

@media (max-width: 680px) {
  .top { min-height: 57px; }
  nav { gap: 16px; }
  .intro { margin-top: 17px; }
  .calculator-intro { min-height: 138px; }
  .title-break { display: initial; }
  .intro-bars { width: 37%; opacity: .45; padding-right: 12px; }
  .card { padding: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

