/* ==========================================================================
   TunKillVp — личный кабинет
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg:        #08080c;
  --bg-elev:   #0e0e15;
  --surface:   #12121b;
  --surface-2: #181824;
  --surface-hover: #1e1e2c;
  --line:        #23233250;
  --line-strong: #2e2e40;

  --text:      #ececf4;
  --text-dim:  #9a9ab0;
  --text-mute: #64647c;

  --accent:      #7c5cff;
  --accent-soft: #7c5cff1f;
  --accent-2:    #22d3ee;

  --ok: #34d399;      --ok-soft: #34d3991f;
  --warn: #fbbf24;    --warn-soft: #fbbf241f;
  --danger: #f87171;  --danger-soft: #f871711f;
  --info: #60a5fa;    --info-soft: #60a5fa1f;

  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 22px;
  --shadow:    0 1px 2px #0006, 0 8px 24px -12px #0009;
  --shadow-lg: 0 12px 48px -16px #000c;

  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  --font: ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Consolas, monospace;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7fb; --bg-elev: #fff; --surface: #fff;
  --surface-2: #f3f4f9; --surface-hover: #ebedf5;
  --line: #1b1b2e14; --line-strong: #d7d9e6;
  --text: #14141f; --text-dim: #55566b; --text-mute: #8b8ca3;
  --accent-soft: #7c5cff17;
  --shadow: 0 1px 2px #10132408, 0 8px 24px -14px #10132426;
  --shadow-lg: 0 12px 40px -16px #10132433;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(700px 400px at 50% -10%, #7c5cff14, transparent 65%),
    radial-gradient(500px 320px at 88% 8%, #22d3ee0d, transparent 60%);
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.015em; }
p { margin: 0; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

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

.page {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 64px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0 10px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; letter-spacing: -.02em; }
.brand-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: 0 4px 14px -4px var(--accent);
  flex: none;
}
.head .spacer { flex: 1; }

/* ---------------- примитивы ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background .16s var(--ease), border-color .16s var(--ease), transform .16s var(--ease);
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--text-mute); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent); color: #fff; border-color: transparent;
  box-shadow: 0 4px 16px -6px var(--accent);
}
.btn-primary:hover:not(:disabled) { background: #8f73ff; border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-icon { width: 38px; padding: 0; flex: none; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn-sm.btn-icon { width: 32px; }

.input {
  width: 100%; height: 42px; padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--bg-elev); color: var(--text);
  font: inherit; font-size: 14px;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-mute); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 99px;
  font-size: 12px; font-weight: 600;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-active   { color: var(--ok); background: var(--ok-soft); }
.badge-on_hold  { color: var(--info); background: var(--info-soft); }
.badge-expired, .badge-disabled { color: var(--text-mute); background: #64647c1f; }
.badge-depleted { color: var(--warn); background: var(--warn-soft); }

.mono { font-family: var(--mono); font-size: 12.5px; }
.dim { color: var(--text-dim); }
.mute { color: var(--text-mute); }
.hidden { display: none !important; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.card-head h2 { font-size: 14px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 20px; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 24px;
}
.hero-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.qr {
  width: 168px; height: 168px;
  padding: 12px;
  background: #fff;
  border-radius: var(--r);
  color: #0a0a12;
  flex: none;
}
.qr svg { width: 100%; height: 100%; display: block; }

.sub-row { display: flex; gap: 8px; }
.sub-row .input { font-family: var(--mono); font-size: 12.5px; }

.grid-stats {
  display: grid;
  /* min() не даёт колонке стать шире экрана на узких устройствах */
  grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
  gap: 14px;
}
.stat {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  transition: transform .24s var(--ease-out), border-color .24s var(--ease);
}
.stat:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.stat-label { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.stat-value {
  font-size: 24px; font-weight: 700; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; line-height: 1.2;
}
.stat-sub { margin-top: 5px; font-size: 12px; color: var(--text-mute); }

.meter { width: 100%; height: 7px; border-radius: 99px; background: var(--surface-hover); overflow: hidden; }
.meter > i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .6s var(--ease-out);
}
.meter.warn > i { background: linear-gradient(90deg, var(--warn), #fb923c); }
.meter.danger > i { background: linear-gradient(90deg, var(--danger), #ef4444); }

.notice {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 15px;
  border-radius: var(--r);
  font-size: 13px;
  border: 1px solid transparent;
}
.notice-info { background: var(--info-soft); color: var(--info); border-color: #60a5fa30; }
.notice-warn { background: var(--warn-soft); color: var(--warn); border-color: #fbbf2430; }
.notice-danger { background: var(--danger-soft); color: var(--danger); border-color: #f8717130; }

/* ---------------- гайд ---------------- */

.steps { display: flex; flex-direction: column; gap: 18px; counter-reset: step; }
.step { display: flex; gap: 14px; }
.step-num {
  counter-increment: step;
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px; font-weight: 700;
}
.step-num::before { content: counter(step); }
.step-body { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.step-body h3 { font-size: 13.5px; }
.step-body p { font-size: 13px; color: var(--text-dim); }

.apps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 10px; }
.app {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  transition: border-color .16s var(--ease), transform .16s var(--ease-out);
}
.app:hover { border-color: var(--accent); transform: translateY(-1px); }
.app-os {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--text-dim);
}
.app-os svg { width: 16px; height: 16px; }
.app b { display: block; font-size: 13px; font-weight: 600; }
.app small { font-size: 11.5px; color: var(--text-mute); }

/* ---------------- график ---------------- */

.chart { width: 100%; display: block; }
.chart-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-grid { stroke: var(--line-strong); stroke-width: 1; opacity: .4; }
.chart-label { fill: var(--text-mute); font-size: 10px; font-family: var(--font); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-dim); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; }

/* ---------------- вход ---------------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; position: relative; z-index: 1; }
.login-card {
  width: min(420px, 100%);
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  animation: pop .4s var(--ease-out);
}
.login-card .brand { justify-content: center; padding-bottom: 8px; font-size: 18px; }
.login-form { display: flex; flex-direction: column; gap: 16px; margin-top: 22px; }
.login-err { padding: 11px 13px; border-radius: var(--r-sm); background: var(--danger-soft); color: var(--danger); font-size: 12.5px; }

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

.toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; max-width: min(380px, calc(100vw - 40px));
}
.toast {
  padding: 11px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: slide-in .24s var(--ease-out);
  overflow-wrap: anywhere;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.out { animation: slide-out .18s var(--ease) forwards; }

.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  height: 44px; margin-bottom: 10px;
}

@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97) } to { opacity: 1; transform: none } }
@keyframes slide-in { from { opacity: 0; transform: translateX(16px) } to { opacity: 1; transform: none } }
@keyframes slide-out { to { opacity: 0; transform: translateX(16px); height: 0; padding: 0; margin: 0 } }
@keyframes shimmer { from { background-position: 100% 0 } to { background-position: 0 0 } }
@keyframes view-in { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

.page > * { animation: view-in .34s var(--ease-out) backwards; }
.page > *:nth-child(2) { animation-delay: .04s }
.page > *:nth-child(3) { animation-delay: .08s }
.page > *:nth-child(4) { animation-delay: .12s }
.page > *:nth-child(5) { animation-delay: .16s }
.page > *:nth-child(6) { animation-delay: .2s }

/* ---------------- адаптив ---------------- */

@media (max-width: 720px) {
  .page { padding: 16px 14px 48px; gap: 14px; }
  .hero { grid-template-columns: minmax(0, 1fr); padding: 18px; gap: 20px; }
  .qr { width: 150px; height: 150px; justify-self: center; }
  .card-head, .card-body { padding: 16px; }
  .grid-stats { grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)); gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 20px; }
  .toasts { left: 14px; right: 14px; bottom: 14px; max-width: none; }
}

@media (max-width: 400px) {
  .grid-stats { grid-template-columns: 1fr 1fr; }
  .sub-row { flex-wrap: wrap; }
  .sub-row .input { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
