/* Две темы по прототипу заказчика: светлая и тёмная с зелёным акцентом.
   Тема ставится атрибутом data-theme на <html> (см. applyTheme в app.js). */
:root, [data-theme="light"] {
  --bg: #f3f6f4; --card: #ffffff; --card-2: #f4f7f5; --text: #111a15; --muted: #6f7a73; --line: #e6ece8;
  --soft: #3b4740; --green: #1d9a57; --green-bg: #e2f5e9; --green-strong: #178a4c;
  --red: #e0474d; --violet: #5a5fd6; --violet-bg: #ebecfb; --yellow: #f4b400;
  --chip-shadow: 0 1px 2px rgba(17, 26, 21, .05);
  --card-shadow: 0 2px 10px rgba(17, 26, 21, .05);
  --hero: linear-gradient(120deg, #1d9a57 0%, #178a4c 50%, #126b3c 100%); --hero-text: #e6f7ee;
  --hero-declared: linear-gradient(120deg, #2f7fb0 0%, #276b95 55%, #1d5375 100%);
  --ad-bg: radial-gradient(120% 140% at 0% 0%, #eafaf0 0%, #d3f1de 45%, #bfe9cf 100%);
  --ad-border: #cbe9d6; --ad-title: #10301e; --ad-text: #3c5546; --ad-label-bg: #1d9a57; --ad-label: #ffffff;
  --ad-go-bg: #1d9a57; --ad-go: #ffffff; --ad-blob: rgba(255, 255, 255, .55);
  --chart-bar: rgba(29, 154, 87, .18); --chart-bar-line: #1d9a57; --chart-line: #e2a200; --chart-grid: #edf1ee;
}
[data-theme="dark"] {
  --bg: #0e1311; --card: #171d1b; --card-2: #1d2422; --text: #f2f5f3; --muted: #8b958f; --line: #252d2a;
  --soft: #c3ccc7; --green: #3fd27f; --green-bg: rgba(63, 210, 127, .14); --green-strong: #3fd27f;
  --red: #f0646a; --violet: #8b8cff; --violet-bg: rgba(139, 140, 255, .14); --yellow: #f5c84b;
  --chip-shadow: none; --card-shadow: none;
  --hero: linear-gradient(120deg, #1d7a4e 0%, #185a3c 55%, #16312a 100%); --hero-text: #cfe3d8;
  --hero-declared: linear-gradient(120deg, #2b6a8a 0%, #1f4a62 55%, #182a33 100%);
  --ad-bg: radial-gradient(120% 140% at 0% 0%, #237a50 0%, #1a5139 45%, #15241f 100%);
  --ad-border: rgba(63, 210, 127, .25); --ad-title: #f2f5f3; --ad-text: #c7d4cd; --ad-label-bg: rgba(255, 255, 255, .14); --ad-label: #f2f5f3;
  --ad-go-bg: rgba(255, 255, 255, .14); --ad-go: #ffffff; --ad-blob: rgba(255, 255, 255, .05);
  --chart-bar: rgba(63, 210, 127, .22); --chart-bar-line: #3fd27f; --chart-line: #f5c84b; --chart-grid: #252d2a;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { font-family: -apple-system, "Segoe UI", Inter, Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); transition: background .2s; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
#app { display: flex; flex-direction: column; height: 100%; max-width: 640px; margin: 0 auto; position: relative; }

/* ---------- шапка ---------- */
.appbar { min-height: 64px; flex: none; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--bg); }
.appbar-mid { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 10px; text-align: center; }
.appbar-mid.left { justify-content: flex-start; text-align: left; }
.appbar .title { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .title.big { font-size: 20px; white-space: normal; line-height: 1.2; }
.appbar .sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.actions { display: flex; gap: 8px; flex: none; }
.icon-btn { width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--card); display: grid; place-items: center; color: var(--text);
            box-shadow: var(--chip-shadow); border: 1px solid var(--line); }
.icon-btn.plain { background: none; border: 0; box-shadow: none; width: 30px; }
.icon-btn.on { color: var(--green); }
.icon-btn[hidden] { display: none; }
.icon-btn svg, .search svg, .ico { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.on svg { fill: currentColor; }
.ico.fill { fill: currentColor; stroke: none; }
.ico.mini { width: 14px; height: 14px; stroke-width: 1.8; vertical-align: -2px; margin-right: 5px; }

.menu { position: absolute; right: 16px; top: 64px; z-index: 5; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
        padding: 6px; min-width: 240px; box-shadow: 0 14px 34px rgba(0,0,0,.18); }
.menu a { display: block; padding: 11px 12px; border-radius: 10px; font-size: 14.5px; }
.menu a:active { background: var(--card-2); }
.menu-sep { font-size: 12px; color: var(--muted); padding: 10px 12px 6px; border-top: 1px solid var(--line); margin-top: 4px; }
.seg { display: flex; gap: 4px; background: var(--card-2); border-radius: 12px; padding: 4px; margin: 0 6px 6px; }
.seg button { flex: 1; padding: 8px 6px; border-radius: 9px; font-size: 13px; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--card); color: var(--green); box-shadow: var(--chip-shadow); }

.content { flex: 1; overflow-y: auto; padding: 4px 16px 18px; display: flex; flex-direction: column; gap: 14px; -webkit-overflow-scrolling: touch; }

/* ---------- поиск и быстрые кнопки ---------- */
.search { background: var(--card); border-radius: 18px; padding: 0 16px; display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); box-shadow: var(--chip-shadow); }
.search svg { color: var(--muted); flex: none; }
.search input { flex: 1; border: 0; outline: 0; font: inherit; font-size: 15.5px; padding: 15px 0; background: transparent; color: var(--text); }
.search input::placeholder { color: var(--muted); }
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 9px 18px; font-size: 14.5px; font-weight: 500; box-shadow: var(--chip-shadow); }

/* ---------- карточки и списки ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 14px 16px; box-shadow: var(--card-shadow); }
.section-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.section-title .st { display: flex; align-items: center; gap: 10px; }
.section-title a { font-size: 14.5px; color: var(--green-strong); font-weight: 600; }
.section-title .star { width: 22px; height: 22px; color: var(--yellow); }
.row { display: flex; align-items: center; gap: 13px; padding: 11px 0; border-top: 1px solid var(--line); }
.section-title + .row, .row:first-child { border-top: none; }
.logo { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; flex: none; }
.logo.sm { width: 34px; height: 34px; font-size: 12px; border-radius: 10px; }
.row > div:nth-child(2) { flex: 1; min-width: 0; }
.row .name { font-weight: 600; font-size: 15.5px; }
.row .meta { font-size: 13.5px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .right { margin-left: auto; text-align: right; flex: none; }
.row .sum { font-weight: 700; font-size: 16px; }
.pill { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 9px; margin-top: 5px; }
.pill.green { background: var(--green-bg); color: var(--green-strong); }
.pill.violet { background: var(--violet-bg); color: var(--violet); }
.month { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; padding: 6px 2px 0; }

/* ---------- реклама: мягкий зелёный градиент, подарок слева, стрелка справа ---------- */
.ad { position: relative; display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 6px; border-radius: 22px; overflow: hidden;
      background: var(--ad-bg); border: 1px solid var(--ad-border); min-height: 128px; isolation: isolate; }
.ad::before, .ad::after { content: ""; position: absolute; border-radius: 50%; background: var(--ad-blob); z-index: -1; }
.ad::before { width: 150px; height: 150px; left: -50px; top: -60px; }
.ad::after { width: 120px; height: 120px; right: 40px; bottom: -70px; }
.ad .label { position: absolute; top: 10px; right: 12px; font-size: 11px; font-weight: 700; color: var(--ad-label); background: var(--ad-label-bg);
             padding: 4px 10px; border-radius: 9px; letter-spacing: .4px; }
.ad .ad-img { width: 92px; height: 96px; flex: none; border-radius: 16px; object-fit: cover; display: grid; place-items: center; }
.ad .ad-img.ph { background: none; }
.ad .ad-img .gift { width: 98px; height: 98px; margin-top: 6px; filter: drop-shadow(0 6px 10px rgba(0,0,0,.12)); }
.ad .ad-body { flex: 1; min-width: 0; padding-top: 18px; }
.ad .ad-title { font-weight: 700; font-size: 17px; color: var(--ad-title); margin-right: 36px; }
.ad .ad-text { font-size: 13px; color: var(--ad-text); margin-top: 5px; line-height: 1.4; margin-right: 40px; }
.ad .ad-go { position: absolute; right: 12px; top: 50%; transform: translateY(-20%); width: 38px; height: 38px; border-radius: 50%;
             background: var(--ad-go-bg); display: grid; place-items: center; }
.ad .ad-go svg { width: 18px; height: 18px; fill: none; stroke: var(--ad-go); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ad.small { min-height: 96px; }
.ad.small .ad-img, .ad.small .ad-img .gift { width: 76px; height: 76px; }
.ad.small .ad-title { font-size: 15px; }
#sticky .ad { border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0; }

/* ---------- нижние вкладки ---------- */
.tabbar { flex: none; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: space-around; align-items: stretch;
          padding: 10px 0 calc(8px + env(safe-area-inset-bottom)); }
.tab { text-align: center; font-size: 12.5px; color: var(--muted); font-weight: 500; min-width: 64px; display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; padding-bottom: 6px; }
.tab .ti { height: 28px; display: grid; place-items: center; }
.tab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--green-strong); font-weight: 600; }
.tab.active svg .f { fill: currentColor; }
.tab.active svg .cut { stroke: var(--card); }
.tab.active::after { content: ""; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 64px; height: 3px; border-radius: 2px; background: var(--green-strong); }

/* ---------- карточка компании ---------- */
.hero { border-radius: 22px; padding: 18px; position: relative; overflow: hidden; color: #fff; background: var(--hero); }
.hero.declared { background: var(--hero-declared); }
.hero.muted { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.hero .k { font-size: 13.5px; color: var(--hero-text); }
.hero.muted .k { color: var(--muted); }
.hero .v { font-size: 36px; font-weight: 800; margin: 4px 0 10px; }
.hero .badges { display: flex; gap: 8px; flex-wrap: wrap; }
.hero .b { background: rgba(255,255,255,.16); border-radius: 10px; padding: 5px 10px; font-size: 13px; font-weight: 600; }

.steps { display: flex; justify-content: space-between; position: relative; margin: 4px 0 2px; }
.steps::before { content: ""; position: absolute; top: 10px; left: 16%; right: 16%; height: 2px; background: var(--line); }
.step { text-align: center; position: relative; width: 33%; }
.dot { width: 20px; height: 20px; border-radius: 50%; margin: 0 auto 8px; border: 4px solid var(--card); box-shadow: 0 0 0 2px currentColor; background: currentColor; }
.step .s1 { font-size: 12px; color: var(--muted); }
.step .s2 { font-size: 14px; font-weight: 700; margin-top: 2px; color: var(--text); }
.note { font-size: 12px; color: var(--muted); margin-top: 12px; text-align: center; }

.kv { display: flex; justify-content: space-between; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 14.5px; }
.section-title + .kv { border-top: none; }
.kv span { color: var(--soft); }
.kv b { font-weight: 700; text-align: right; }
.up { color: var(--green); font-weight: 700; }
.down { color: var(--red); font-weight: 700; }

.quote { border-left: 3px solid var(--green); background: var(--card-2); border-radius: 0 12px 12px 0; padding: 12px 14px;
         font-size: 14px; line-height: 1.55; color: var(--soft); white-space: pre-line; }
.quote.short { max-height: 9.4em; overflow: hidden; }
.more { display: block; margin-top: 10px; font-size: 14px; color: var(--green-strong); font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: right; color: var(--muted); font-weight: 500; padding: 6px 0 8px; font-size: 12.5px; }
th:first-child, td:first-child { text-align: left; }
td { text-align: right; padding: 9px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
td.y { color: var(--green-strong); font-weight: 700; }

.link-card { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 15px; }
.link-card span { color: var(--green-strong); }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font-family: inherit; fill: var(--muted); }
.chart .grid { stroke: var(--chart-grid); }
.chart .bar { fill: var(--chart-bar); stroke: var(--chart-bar-line); stroke-width: 1.1; }
.chart .yl { fill: none; stroke: var(--chart-line); stroke-width: 2; }
.chart .yp { fill: var(--card); stroke: var(--chart-line); stroke-width: 1.6; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .lb { background: var(--chart-bar); border: 1px solid var(--chart-bar-line); }
.legend .ll { background: var(--chart-line); }

.empty, .loading, .error { text-align: center; color: var(--muted); font-size: 14.5px; padding: 30px 10px; line-height: 1.5; }
.error { color: var(--red); }
.spinner { width: 30px; height: 30px; border: 3px solid var(--green-bg); border-top-color: var(--green); border-radius: 50%;
           margin: 0 auto 12px; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.rate { display: flex; align-items: center; gap: 13px; padding: 12px 0; border-top: 1px solid var(--line); }
.section-title + .rate { border-top: none; }
.rate .cur { width: 40px; height: 40px; border-radius: 12px; background: var(--green-bg); color: var(--green-strong); display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none; }
.rate .code { font-weight: 700; font-size: 15.5px; }
.rate .val { margin-left: auto; font-weight: 700; font-size: 17px; }
.small { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
