/* ============================================================
   Signal Point VPN — дизайн-система Mini App
   Графит/чёрный фон, сдержанные оранжево-янтарные акценты.
   ============================================================ */

:root {
  --bg: #08080A;
  --bg-grad: radial-gradient(120% 80% at 12% -10%, #1A1409 0%, rgba(8,8,10,0) 55%);
  --surface: #16161A;
  --surface-2: #1D1D21;
  --surface-3: #26262B;
  --line: #33333A;
  --line-soft: #2C2C33;

  --text: #F3F3F4;
  --text-2: #C7C7CC;
  --muted: #9A9AA2;
  --muted-2: #8C8C94;

  --accent: #FF7A18;
  --accent-2: #FFB24D;
  --accent-soft: rgba(255, 122, 24, 0.12);
  --accent-line: rgba(255, 122, 24, 0.32);

  --ok: #3FD08A;
  --ok-soft: rgba(63, 208, 138, 0.12);
  --warn: #FFB020;
  --warn-soft: rgba(255, 176, 32, 0.12);
  --err: #FF6B6B;
  --err-soft: rgba(255, 107, 107, 0.12);

  --r-xs: 8px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 18px;
  --r-xl: 24px;

  --pad: 16px;
  --gap: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs: 15px;
  --fs-lg: 17px;
  --fs-xl: 21px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { background-image: var(--bg-grad); background-attachment: fixed; min-height: 100vh; }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ic { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor;
      stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ic--sm { width: 16px; height: 16px; }
.ic--lg { width: 26px; height: 26px; }

/* ---------------------------------------------------------- каркас */

#app { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-top) + 12px) var(--pad) 12px;
  background: rgba(10, 10, 11, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand__mark {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 9px;
  background: linear-gradient(160deg, var(--accent) 0%, #C6510A 100%);
  color: #170A00;
}
.brand__mark .ic { width: 17px; height: 17px; stroke-width: 1.8; }
.brand__text { font-size: var(--fs); font-weight: 600; letter-spacing: .2px; white-space: nowrap;
               overflow: hidden; text-overflow: ellipsis; }
.brand__text b { color: var(--accent-2); font-weight: 650; }

.topbar__back { margin-left: -6px; }

.icon-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text-2); cursor: pointer; padding: 0;
}
.icon-btn:active { background: var(--surface-3); }

.view {
  flex: 1;
  padding: 18px var(--pad) calc(92px + var(--safe-bottom));
  max-width: 620px; width: 100%; margin: 0 auto;
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: #0C0C0F;
  background-image: linear-gradient(180deg, #131316 0%, #0C0C0F 55%);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 24px rgba(0, 0, 0, .55);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 4px; border-radius: var(--r-sm);
  color: var(--muted); text-decoration: none; font-size: 11px; letter-spacing: .2px;
}
.tab .ic { stroke-width: 1.8; }
.tab.is-active { color: var(--accent-2); background: var(--accent-soft); }

/* ---------------------------------------------------------- типографика */

.page-title { margin: 0 0 4px; font-size: var(--fs-xl); font-weight: 650; letter-spacing: -.2px; }
.page-sub { margin: 0 0 18px; color: var(--muted); font-size: var(--fs-sm); }
.sec-title { margin: 22px 0 10px; font-size: var(--fs-xs); font-weight: 600;
             letter-spacing: .9px; text-transform: uppercase; color: var(--muted-2); }
.sec-title:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: var(--fs-sm); }
.tiny { font-size: var(--fs-xs); color: var(--muted-2); }
.hidden { display: none !important; }

/* ---------------------------------------------------------- карточки */

[hidden] { display: none !important; }

.card {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r-lg); padding: 16px; margin-bottom: var(--gap);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 22px rgba(0, 0, 0, .35);
}
.card--tight { padding: 12px; }
.card__title { margin: 0 0 6px; font-size: var(--fs-lg); font-weight: 620; letter-spacing: -.1px; }
.card__text { margin: 0; color: var(--text-2); font-size: var(--fs-sm); }

.hero { display: flex; align-items: center; gap: 14px; }
.hero__ring {
  position: relative; display: grid; place-items: center;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--muted);
}
.hero__ring.is-on { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.hero__body { min-width: 0; flex: 1; }
.hero__title { font-size: var(--fs-lg); font-weight: 620; }
.hero__meta { color: var(--muted); font-size: var(--fs-sm); }

.meter { height: 6px; border-radius: 99px; background: var(--surface-3);
          border: 1px solid var(--line-soft); overflow: hidden; margin-top: 10px; }
.meter__fill { height: 100%; border-radius: 99px;
               background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%); }
.meter__fill.is-full { background: linear-gradient(90deg, var(--warn) 0%, #FF8A3D 100%); }

/* сегментный счётчик устройств: виден даже при нуле */
.pips { display: flex; gap: 5px; margin-top: 10px; }
.pip { flex: 1; height: 6px; border-radius: 99px; background: var(--surface-3);
       border: 1px solid var(--line); }
.pip.is-on { background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
             border-color: transparent; }
.pip.is-on.is-full { background: linear-gradient(90deg, var(--warn) 0%, #FF8A3D 100%); }

/* ---------------------------------------------------------- пилюли/статусы */

.badge, .pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 99px;
  font-size: var(--fs-xs); font-weight: 550; letter-spacing: .2px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge--muted, .pill--muted { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.pill--ok, .badge--ok { background: var(--ok-soft); color: var(--ok); border-color: rgba(63,208,138,.28); }
.pill--warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(255,176,32,.28); }
.pill--err { background: var(--err-soft); color: var(--err); border-color: rgba(255,107,107,.28); }
.pill--accent { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent-line); }
.pill--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%;
                     background: currentColor; opacity: .9; }

/* ---------------------------------------------------------- кнопки */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 48px; padding: 12px 16px;
  border-radius: var(--r); border: 1px solid transparent;
  font-family: inherit; font-size: var(--fs); font-weight: 600; letter-spacing: .1px;
  cursor: pointer; text-decoration: none; transition: transform .06s ease, filter .15s ease;
}
.btn:active { transform: scale(.985); }
.btn:disabled, .btn.is-busy { opacity: .62; cursor: default; transform: none; }

.btn--primary { background: linear-gradient(160deg, var(--accent) 0%, #E2650F 100%); color: #180B00;
                box-shadow: 0 6px 18px rgba(255, 122, 24, .18); }
.btn--secondary { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--text-2); }
.btn--danger { background: var(--err-soft); border-color: rgba(255,107,107,.34); color: var(--err); }
.btn--sm { min-height: 40px; padding: 9px 13px; font-size: var(--fs-sm); border-radius: var(--r-sm); width: auto; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { width: auto; flex: 1; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------- списки */

.list { display: flex; flex-direction: column; gap: 10px; }

.item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 14px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line-soft);
  color: var(--text); font-family: inherit; font-size: var(--fs); cursor: pointer;
}
.item:active { background: var(--surface-2); }
.item__icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px;
              background: var(--surface-2); border: 1px solid var(--line); color: var(--accent-2); }
.item__body { flex: 1; min-width: 0; }
.item__title { font-weight: 570; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__meta { margin-top: 2px; color: var(--muted); font-size: var(--fs-xs);
              white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item__chev { color: var(--muted-2); }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0;
      border-bottom: 1px solid var(--line-soft); font-size: var(--fs-sm); }
.kv:last-child { border-bottom: none; }
.kv__k { color: var(--muted); flex: 0 0 auto; }
.kv__v { text-align: right; color: var(--text); word-break: break-word; }

/* ---------------------------------------------------------- формы */

.field { margin-bottom: 16px; }
.field__label { display: block; margin-bottom: 8px; font-size: var(--fs-sm); font-weight: 550;
                color: var(--text-2); }
.field__hint { margin-top: 7px; font-size: var(--fs-xs); color: var(--muted-2); }

.input {
  width: 100%; min-height: 48px; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
  color: var(--text); font-family: inherit; font-size: var(--fs); outline: none;
}
.input::placeholder { color: var(--muted-2); }
.input:focus { border-color: var(--accent-line); background: var(--surface-3); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 13px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text-2); font-family: inherit; font-size: var(--fs-sm); font-weight: 520; cursor: pointer;
}
.chip .ic { width: 17px; height: 17px; }
.chip.is-on { border-color: var(--accent-line); color: var(--accent-2); background: var(--accent-soft); }

.opt {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left;
  padding: 14px; margin-bottom: 10px; border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text); font-family: inherit; cursor: pointer;
}
.opt.is-on { border-color: var(--accent-line); background: var(--accent-soft); }
.opt__radio { width: 18px; height: 18px; border-radius: 50%; border: 1.6px solid var(--muted-2);
              flex: 0 0 auto; margin-top: 2px; position: relative; }
.opt.is-on .opt__radio { border-color: var(--accent); }
.opt.is-on .opt__radio::after { content: ""; position: absolute; inset: 3px; border-radius: 50%;
                                background: var(--accent); }
.opt__title { font-weight: 570; }
.opt__text { margin-top: 3px; color: var(--muted); font-size: var(--fs-xs); line-height: 1.4; }

/* ---------------------------------------------------------- сообщения */

.callout {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r); font-size: var(--fs-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2);
  margin-bottom: var(--gap);
}
.callout--warn { background: var(--warn-soft); border-color: rgba(255,176,32,.3); color: #F6D9A8;
                border-left: 3px solid var(--warn); }
.callout--err { background: var(--err-soft); border-color: rgba(255,107,107,.3); color: #FFC9C9; }
.callout--ok { background: var(--ok-soft); border-color: rgba(63,208,138,.3); color: #BEF0D6; }
.callout .ic { margin-top: 1px; }

.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty .ic { width: 34px; height: 34px; color: var(--muted-2); margin-bottom: 10px; }
.empty__title { font-size: var(--fs-lg); font-weight: 600; color: var(--text-2); margin-bottom: 4px; }

/* ---------------------------------------------------------- QR и профиль */

.qr-box {
  display: grid; place-items: center; padding: 18px;
  background: #FFFFFF; border-radius: var(--r-lg); margin: 4px 0 14px;
}
.qr-box img { display: block; width: 100%; max-width: 250px; height: auto; image-rendering: pixelated; }

.conf-view {
  max-height: 190px; overflow: auto; margin: 0;
  padding: 13px; border-radius: var(--r);
  background: var(--bg); border: 1px solid var(--line);
  color: var(--text-2); font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-all;
}

.danger-zone { border-color: rgba(255,107,107,.24); background: rgba(255,107,107,.05); }
.danger-zone .card__title { color: var(--err); }

/* Пошаговая подсказка (заполняет низ экрана осмысленно) */
.steps { margin: 0; padding-left: 20px; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.55; }
.steps li { margin: 0 0 6px; }
.steps li:last-child { margin-bottom: 0; }
.steps li::marker { color: var(--accent-2); font-weight: 600; }

/* ---------------------------------------------------------- модальные окна */

.backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, .62); backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .16s ease;
}
.backdrop--center { align-items: center; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.sheet {
  width: 100%; max-width: 620px;
  background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
  border-top: 1px solid var(--line);
  padding: 18px var(--pad) calc(18px + var(--safe-bottom));
  animation: up .2s ease;
}
.sheet__grip { width: 38px; height: 4px; border-radius: 99px; background: var(--line);
               margin: 0 auto 14px; }
@keyframes up { from { transform: translateY(18px); opacity: .7 } to { transform: none; opacity: 1 } }

.modal {
  width: calc(100% - 40px); max-width: 420px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 20px;
}
.modal__title { margin: 0 0 6px; font-size: var(--fs-lg); font-weight: 620; }
.modal__text { margin: 0 0 18px; color: var(--muted); font-size: var(--fs-sm); }

/* ---------------------------------------------------------- тосты */

.toasts {
  position: fixed; left: 0; right: 0; bottom: calc(84px + var(--safe-bottom));
  z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 var(--pad);
}
.toast {
  max-width: 480px; width: 100%;
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r);
  background: var(--surface-3); border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  font-size: var(--fs-sm); color: var(--text);
  animation: up .18s ease;
}
.toast--ok { border-color: rgba(63,208,138,.32); }
.toast--err { border-color: rgba(255,107,107,.34); }
.toast .ic { color: var(--muted); }
.toast--ok .ic { color: var(--ok); }
.toast--err .ic { color: var(--err); }

/* ---------------------------------------------------------- скелетоны */

.skeleton-stack { display: flex; flex-direction: column; gap: 12px; }
.sk { border-radius: var(--r); background: linear-gradient(90deg, var(--surface) 25%,
      var(--surface-2) 37%, var(--surface) 63%); background-size: 400% 100%;
      animation: shimmer 1.3s ease infinite; }
.sk--line { height: 18px; width: 55%; }
.sk--card { height: 92px; }
@keyframes shimmer { from { background-position: 100% 0 } to { background-position: 0 0 } }

/* ---------------------------------------------------------- узкие экраны */

@media (max-width: 360px) {
  :root { --pad: 13px; --fs: 14.5px; --fs-xl: 19px; }
  .brand__text { font-size: var(--fs-sm); }
  .item { padding: 12px; }
  .btn { min-height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; transition: none !important; }
}
