/* ============================================================================
   Злой GPT Market — Black Liquid Glass design system
   ========================================================================== */

@layer reset, tokens, base, glass, layout, components, views, responsive;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; padding: 0; }
  html, body { height: 100%; }
  img, svg { display: block; max-width: 100%; }
  button, input, select, textarea { font: inherit; color: inherit; }
  button { background: none; border: 0; cursor: pointer; }
  a { color: inherit; text-decoration: none; }
  ul, ol { list-style: none; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
}

@layer tokens {
  :root {
    --bg: #04050a;
    --bg-soft: #070910;
    --ink: #f1f4f7;
    --ink-dim: rgba(241, 244, 247, 0.64);
    --ink-faint: rgba(241, 244, 247, 0.4);
    --ink-ghost: rgba(241, 244, 247, 0.22);

    --glass: rgba(255, 255, 255, 0.045);
    --glass-2: rgba(255, 255, 255, 0.07);
    --stroke: rgba(255, 255, 255, 0.085);
    --stroke-strong: rgba(255, 255, 255, 0.16);

    --accent: #cbf75a;
    --accent-soft: rgba(203, 247, 90, 0.14);
    --accent-ink: #0b0e04;
    --ok: #5fe6a4;
    --warn: #ffc861;
    --danger: #ff6f6f;
    --info: #7fb8ff;

    --r-xs: 10px;
    --r-sm: 14px;
    --r-md: 20px;
    --r-lg: 28px;
    --r-xl: 36px;

    --shadow-panel: 0 40px 90px -40px rgba(0, 0, 0, 0.95),
                    0 2px 0 rgba(255, 255, 255, 0.04) inset;
    --shadow-float: 0 24px 60px -24px rgba(0, 0, 0, 0.9);

    --font: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI",
            Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "JetBrains Mono", "SF Mono", ui-monospace, "Cascadia Code", Menlo,
            Consolas, monospace;

    --nav-h: 68px;
    --pad: clamp(16px, 3.4vw, 40px);
    --maxw: 1240px;
  }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.001ms !important;
      transition-duration: 0.001ms !important;
    }
  }
}

@layer base {
  html {
    -webkit-text-size-adjust: 100%;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
  }

  body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    min-height: 100dvh;
    overflow-x: hidden;
    letter-spacing: -0.011em;
  }

  /* Liquid depth: slow-drifting colour fields behind the glass. */
  body::before {
    content: "";
    position: fixed;
    inset: -20vmax;
    z-index: -2;
    background:
      radial-gradient(42vmax 34vmax at 12% 4%, rgba(203, 247, 90, 0.10), transparent 62%),
      radial-gradient(46vmax 40vmax at 88% -6%, rgba(96, 140, 255, 0.12), transparent 60%),
      radial-gradient(50vmax 42vmax at 62% 108%, rgba(255, 108, 168, 0.07), transparent 64%);
    filter: blur(20px);
    animation: drift 38s ease-in-out infinite alternate;
  }

  body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
      radial-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px);
    background-size: 3px 3px;
    opacity: 0.35;
    mask-image: radial-gradient(120vmax 90vmax at 50% 0%, #000 20%, transparent 78%);
  }

  @keyframes drift {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    50%  { transform: translate3d(-3%, 2%, 0) scale(1.05); }
    100% { transform: translate3d(2%, -2%, 0) scale(1.02); }
  }

  h1, h2, h3, h4 {
    font-weight: 620;
    letter-spacing: -0.028em;
    line-height: 1.14;
    text-wrap: balance;
  }
  h1 { font-size: clamp(2.1rem, 5.2vw, 4.1rem); font-weight: 660; }
  h2 { font-size: clamp(1.5rem, 3.1vw, 2.3rem); }
  h3 { font-size: clamp(1.08rem, 1.9vw, 1.32rem); }
  p  { text-wrap: pretty; }

  ::selection { background: var(--accent); color: var(--accent-ink); }

  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 99px;
    border: 3px solid transparent;
    background-clip: content-box;
  }
  ::-webkit-scrollbar-track { background: transparent; }
}

@layer glass {
  .glass {
    position: relative;
    background:
      linear-gradient(158deg,
        rgba(255, 255, 255, 0.075) 0%,
        rgba(255, 255, 255, 0.018) 44%,
        rgba(255, 255, 255, 0.042) 100%);
    border: 1px solid var(--stroke);
    border-radius: var(--r-md);
    backdrop-filter: blur(30px) saturate(155%);
    -webkit-backdrop-filter: blur(30px) saturate(155%);
    box-shadow: var(--shadow-panel);
  }

  /* Liquid highlight running along the top edge of every pane. */
  .glass::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    border-radius: inherit;
    background: linear-gradient(90deg,
      transparent, rgba(255, 255, 255, 0.42) 22%,
      rgba(255, 255, 255, 0.16) 60%, transparent);
    opacity: 0.7;
    pointer-events: none;
  }

  .glass-soft {
    background: rgba(255, 255, 255, 0.028);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--r-sm);
  }

  .sheen {
    position: relative;
    overflow: hidden;
    isolation: isolate;
  }
  .sheen::after {
    content: "";
    position: absolute;
    inset: -60% -20%;
    z-index: -1;
    background: conic-gradient(from 210deg at 50% 50%,
      transparent 0deg, rgba(255, 255, 255, 0.055) 42deg,
      transparent 96deg, rgba(203, 247, 90, 0.06) 168deg, transparent 240deg);
    animation: spin 26s linear infinite;
    pointer-events: none;
  }
  @keyframes spin { to { transform: rotate(1turn); } }
}

@layer layout {
  .wrap {
    width: 100%;
    max-width: var(--maxw);
    margin-inline: auto;
    padding-inline: var(--pad);
  }

  .stack { display: flex; flex-direction: column; }
  .row { display: flex; align-items: center; }
  .row-between { display: flex; align-items: center; justify-content: space-between; }
  .gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
  .gap-16 { gap: 16px; } .gap-20 { gap: 20px; } .gap-28 { gap: 28px; }
  .grow { flex: 1 1 auto; min-width: 0; }
  .wrap-text { overflow-wrap: anywhere; }

  .grid { display: grid; gap: 16px; }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-auto { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

  .page { padding-block: clamp(24px, 4vw, 48px) 96px; }
  .section { padding-block: clamp(48px, 7vw, 96px); }
}

@layer components {
  /* ---------------------------------------------------------------- buttons */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    height: 44px;
    padding: 0 20px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 560;
    letter-spacing: -0.01em;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: transform 0.16s ease, background 0.18s ease,
                border-color 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
    user-select: none;
  }
  .btn:active { transform: scale(0.978); }
  .btn:disabled { opacity: 0.45; pointer-events: none; }

  .btn-primary {
    background: linear-gradient(178deg, #d8ff6d, var(--accent) 55%, #a9dd3c);
    color: var(--accent-ink);
    font-weight: 640;
    box-shadow: 0 12px 34px -14px rgba(203, 247, 90, 0.7),
                0 1px 0 rgba(255, 255, 255, 0.5) inset;
  }
  .btn-primary:hover {
    box-shadow: 0 16px 42px -14px rgba(203, 247, 90, 0.85),
                0 1px 0 rgba(255, 255, 255, 0.6) inset;
  }

  .btn-glass {
    background: rgba(255, 255, 255, 0.055);
    border-color: var(--stroke);
    color: var(--ink);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
  .btn-glass:hover {
    background: rgba(255, 255, 255, 0.095);
    border-color: var(--stroke-strong);
  }

  .btn-ghost { color: var(--ink-dim); }
  .btn-ghost:hover { color: var(--ink); background: rgba(255, 255, 255, 0.05); }

  .btn-danger {
    background: rgba(255, 111, 111, 0.12);
    border-color: rgba(255, 111, 111, 0.28);
    color: #ffb3b3;
  }
  .btn-danger:hover { background: rgba(255, 111, 111, 0.2); }

  .btn-sm { height: 34px; padding: 0 14px; font-size: 0.8rem; gap: 6px; }
  .btn-lg { height: 52px; padding: 0 28px; font-size: 0.98rem; }
  .btn-block { width: 100%; }
  .btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 12px; }

  /* ----------------------------------------------------------------- fields */
  .field { display: flex; flex-direction: column; gap: 7px; }
  .label {
    font-size: 0.76rem;
    font-weight: 560;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--ink-faint);
  }
  .hint { font-size: 0.78rem; color: var(--ink-faint); line-height: 1.5; }

  .input, .select, .textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--stroke);
    border-radius: var(--r-sm);
    padding: 12px 14px;
    font-size: 0.92rem;
    color: var(--ink);
    transition: border-color 0.16s ease, background 0.16s ease,
                box-shadow 0.16s ease;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
  .input::placeholder, .textarea::placeholder { color: var(--ink-ghost); }
  .input:hover, .select:hover, .textarea:hover {
    border-color: var(--stroke-strong);
  }
  .input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: rgba(203, 247, 90, 0.55);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 4px rgba(203, 247, 90, 0.1);
  }
  .textarea { resize: vertical; min-height: 104px; line-height: 1.6; }
  .select {
    appearance: none;
    background-image:
      linear-gradient(45deg, transparent 50%, var(--ink-dim) 50%),
      linear-gradient(135deg, var(--ink-dim) 50%, transparent 50%);
    background-position: calc(100% - 19px) 20px, calc(100% - 14px) 20px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 38px;
  }
  .select option { background: #0b0e14; color: var(--ink); }

  .input-group { display: flex; gap: 8px; }
  .input-group .input { flex: 1; }

  .search {
    position: relative;
    display: flex;
    align-items: center;
  }
  .search .input { padding-left: 42px; height: 46px; border-radius: 999px; }
  .search svg {
    position: absolute;
    left: 15px;
    color: var(--ink-faint);
    pointer-events: none;
  }

  /* ------------------------------------------------------------------ chips */
  .chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 560;
    letter-spacing: 0.01em;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    color: var(--ink-dim);
    white-space: nowrap;
  }
  .chip-ok {
    color: #b7f5cf;
    border-color: rgba(95, 230, 164, 0.28);
    background: rgba(95, 230, 164, 0.1);
  }
  .chip-warn {
    color: #ffdcab;
    border-color: rgba(255, 200, 97, 0.3);
    background: rgba(255, 200, 97, 0.1);
  }
  .chip-danger {
    color: #ffb9b9;
    border-color: rgba(255, 111, 111, 0.3);
    background: rgba(255, 111, 111, 0.1);
  }
  .chip-info {
    color: #c3ddff;
    border-color: rgba(127, 184, 255, 0.28);
    background: rgba(127, 184, 255, 0.1);
  }
  .dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
    flex: none;
  }
  .chip-ok .dot { animation: pulse 2.4s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: 0.35; } }

  /* ------------------------------------------------------------------ cards */
  .card { padding: clamp(18px, 2.4vw, 26px); }
  .card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
  }
  .card-title { font-size: 0.98rem; font-weight: 600; letter-spacing: -0.02em; }
  .card-sub { font-size: 0.78rem; color: var(--ink-faint); margin-top: 2px; }

  .stat { display: flex; flex-direction: column; gap: 6px; }
  .stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-faint);
    font-weight: 560;
  }
  .stat-value {
    font-size: clamp(1.35rem, 2.5vw, 1.75rem);
    font-weight: 640;
    letter-spacing: -0.035em;
    font-variant-numeric: tabular-nums;
  }
  .stat-value small { font-size: 0.55em; color: var(--ink-faint); font-weight: 500; }

  /* ----------------------------------------------------------------- tables */
  .table-wrap { overflow-x: auto; margin-inline: -6px; padding-inline: 6px; }
  table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 560px;
  }
  table.data th {
    text-align: left;
    font-size: 0.7rem;
    font-weight: 560;
    text-transform: uppercase;
    letter-spacing: 0.055em;
    color: var(--ink-faint);
    padding: 0 14px 12px;
    white-space: nowrap;
    border-bottom: 1px solid var(--stroke);
  }
  table.data td {
    padding: 13px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.045);
    vertical-align: middle;
  }
  table.data tbody tr { transition: background 0.14s ease; }
  table.data tbody tr:hover { background: rgba(255, 255, 255, 0.028); }
  table.data tbody tr:last-child td { border-bottom: 0; }
  .num { font-variant-numeric: tabular-nums; text-align: right; }
  .mono {
    font-family: var(--mono);
    font-size: 0.82rem;
    letter-spacing: -0.01em;
  }

  /* ------------------------------------------------------------------- misc */
  .divider { height: 1px; background: var(--stroke); border: 0; }
  .muted { color: var(--ink-dim); }
  .faint { color: var(--ink-faint); }
  .small { font-size: 0.82rem; }
  .tiny { font-size: 0.74rem; }
  .accent { color: var(--accent); }
  .ok { color: var(--ok); }
  .danger { color: var(--danger); }
  .num-tab { font-variant-numeric: tabular-nums; }

  .empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 20px;
    text-align: center;
    color: var(--ink-faint);
  }
  .empty svg { opacity: 0.5; }
  .empty-title { color: var(--ink-dim); font-weight: 560; font-size: 0.95rem; }

  .spinner {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.16);
    border-top-color: var(--accent);
    animation: rotate 0.7s linear infinite;
  }
  @keyframes rotate { to { transform: rotate(1turn); } }

  .skeleton {
    background: linear-gradient(100deg,
      rgba(255, 255, 255, 0.04) 30%, rgba(255, 255, 255, 0.09) 50%,
      rgba(255, 255, 255, 0.04) 70%);
    background-size: 220% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--r-sm);
  }
  @keyframes shimmer { to { background-position: -180% 0; } }

  /* --------------------------------------------------------------- nav bar */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 60;
    height: var(--nav-h);
    display: flex;
    align-items: center;
    border-bottom: 1px solid transparent;
    transition: background 0.24s ease, border-color 0.24s ease,
                backdrop-filter 0.24s ease;
  }
  .topbar.scrolled {
    background: rgba(4, 5, 10, 0.72);
    backdrop-filter: blur(26px) saturate(160%);
    -webkit-backdrop-filter: blur(26px) saturate(160%);
    border-bottom-color: var(--stroke);
  }
  .topbar-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: var(--maxw);
    margin-inline: auto;
    padding-inline: var(--pad);
  }

  .brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 640;
    letter-spacing: -0.03em;
    font-size: 0.98rem;
    flex: none;
  }
  .brand-mark {
    width: 30px; height: 30px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, #d8ff6d, #a9dd3c 70%, #6f9c1d);
    color: var(--accent-ink);
    box-shadow: 0 8px 22px -10px rgba(203, 247, 90, 0.8),
                0 1px 0 rgba(255, 255, 255, 0.5) inset;
    flex: none;
  }
  .brand-mark svg { width: 17px; height: 17px; }

  .nav-links { display: flex; align-items: center; gap: 2px; }
  .nav-link {
    padding: 8px 13px;
    border-radius: 999px;
    font-size: 0.86rem;
    color: var(--ink-dim);
    transition: color 0.15s ease, background 0.15s ease;
    white-space: nowrap;
  }
  .nav-link:hover { color: var(--ink); background: rgba(255, 255, 255, 0.05); }
  .nav-link.active { color: var(--ink); background: rgba(255, 255, 255, 0.07); }

  .nav-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

  .menu-toggle {
    display: none;
    width: 40px; height: 40px;
    border-radius: 12px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.05);
    place-items: center;
  }

  /* ------------------------------------------------------------ app shell */
  .shell {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    gap: 28px;
    width: 100%;
    max-width: var(--maxw);
    margin-inline: auto;
    padding: 0 var(--pad) 80px;
  }
  .sidebar {
    position: sticky;
    top: calc(var(--nav-h) + 20px);
    align-self: start;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .side-group {
    padding: 14px 12px 6px;
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-ghost);
    font-weight: 620;
  }
  .side-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 0.86rem;
    color: var(--ink-dim);
    transition: color 0.15s ease, background 0.15s ease;
  }
  .side-link svg { width: 17px; height: 17px; opacity: 0.8; flex: none; }
  .side-link:hover { color: var(--ink); background: rgba(255, 255, 255, 0.045); }
  .side-link.active {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.075);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.07) inset;
  }
  .side-link.active svg { opacity: 1; color: var(--accent); }
  .side-badge {
    margin-left: auto;
    font-size: 0.68rem;
    padding: 1px 7px;
    border-radius: 99px;
    background: rgba(203, 247, 90, 0.16);
    color: var(--accent);
    font-weight: 600;
  }

  .mobile-tabs { display: none; }

  /* --------------------------------------------------------------- hero */
  .hero { padding-block: clamp(56px, 9vw, 118px) clamp(40px, 6vw, 72px); }
  .hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    height: 32px;
    padding: 0 14px 0 10px;
    border-radius: 999px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.76rem;
    color: var(--ink-dim);
    backdrop-filter: blur(18px);
  }
  .hero-title {
    margin-top: 22px;
    max-width: 17ch;
    background: linear-gradient(180deg, #ffffff 8%, rgba(255, 255, 255, 0.72) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
  .hero-sub {
    margin-top: 20px;
    max-width: 52ch;
    font-size: clamp(0.98rem, 1.5vw, 1.12rem);
    color: var(--ink-dim);
    line-height: 1.62;
  }
  .hero-actions { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 12px; }
  .hero-note {
    margin-top: 18px;
    font-size: 0.8rem;
    color: var(--ink-faint);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }

  .feature { padding: 22px; display: flex; flex-direction: column; gap: 12px; }
  .feature-icon {
    width: 38px; height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid var(--stroke);
    color: var(--accent);
  }
  .feature-icon svg { width: 18px; height: 18px; }
  .feature h3 { font-size: 0.98rem; }
  .feature p { font-size: 0.86rem; color: var(--ink-dim); line-height: 1.6; }

  /* ----------------------------------------------------------- model cards */
  .model-card {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color 0.18s ease, transform 0.18s ease,
                background 0.18s ease;
  }
  .model-card:hover {
    border-color: var(--stroke-strong);
    transform: translateY(-2px);
  }
  .model-name {
    font-size: 0.92rem;
    font-weight: 590;
    letter-spacing: -0.02em;
    word-break: break-word;
    line-height: 1.35;
  }
  .model-desc {
    font-size: 0.8rem;
    color: var(--ink-faint);
    line-height: 1.55;
    flex: 1;
  }
  .model-price {
    font-size: 0.8rem;
    color: var(--ink-dim);
    font-variant-numeric: tabular-nums;
    padding-top: 12px;
    border-top: 1px solid var(--stroke);
  }

  /* -------------------------------------------------------------- auth */
  .auth-shell {
    min-height: calc(100dvh - var(--nav-h));
    display: grid;
    place-items: center;
    padding: 40px var(--pad) 80px;
  }
  .auth-card {
    width: 100%;
    max-width: 424px;
    padding: clamp(24px, 4vw, 34px);
  }
  .auth-title { font-size: 1.4rem; margin-bottom: 6px; }
  .auth-sub { font-size: 0.86rem; color: var(--ink-faint); margin-bottom: 26px; }

  .tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--stroke);
    margin-bottom: 24px;
  }
  .tab {
    flex: 1;
    height: 34px;
    border-radius: 999px;
    font-size: 0.84rem;
    color: var(--ink-dim);
    display: grid;
    place-items: center;
    transition: background 0.16s ease, color 0.16s ease;
  }
  .tab.active {
    background: rgba(255, 255, 255, 0.09);
    color: var(--ink);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.09) inset;
  }

  /* --------------------------------------------------------------- alerts */
  .alert {
    display: flex;
    gap: 11px;
    padding: 13px 15px;
    border-radius: var(--r-sm);
    font-size: 0.84rem;
    line-height: 1.55;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    align-items: flex-start;
  }
  .alert svg { flex: none; margin-top: 1px; }
  .alert-error {
    border-color: rgba(255, 111, 111, 0.3);
    background: rgba(255, 111, 111, 0.09);
    color: #ffc9c9;
  }
  .alert-ok {
    border-color: rgba(95, 230, 164, 0.28);
    background: rgba(95, 230, 164, 0.08);
    color: #bdf7d6;
  }
  .alert-warn {
    border-color: rgba(255, 200, 97, 0.28);
    background: rgba(255, 200, 97, 0.08);
    color: #ffe3b8;
  }
  .alert-info {
    border-color: rgba(127, 184, 255, 0.26);
    background: rgba(127, 184, 255, 0.08);
    color: #d0e4ff;
  }

  /* --------------------------------------------------------------- toasts */
  .toasts {
    position: fixed;
    bottom: 22px;
    right: 22px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(380px, calc(100vw - 32px));
  }
  .toast {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 13px 16px;
    border-radius: var(--r-sm);
    font-size: 0.85rem;
    background: rgba(14, 17, 24, 0.92);
    border: 1px solid var(--stroke-strong);
    box-shadow: var(--shadow-float);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    animation: toast-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  }
  .toast.leaving { animation: toast-out 0.22s ease forwards; }
  .toast-ok { border-color: rgba(95, 230, 164, 0.34); }
  .toast-error { border-color: rgba(255, 111, 111, 0.36); }
  @keyframes toast-in {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
  }
  @keyframes toast-out {
    to { opacity: 0; transform: translateY(6px) scale(0.98); }
  }

  /* --------------------------------------------------------------- modal */
  .modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 150;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(2, 3, 6, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: fade 0.2s ease;
  }
  @keyframes fade { from { opacity: 0; } }
  .modal {
    width: 100%;
    max-width: 480px;
    padding: 26px;
    animation: modal-in 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
    max-height: min(86dvh, 720px);
    overflow-y: auto;
  }
  @keyframes modal-in {
    from { opacity: 0; transform: translateY(14px) scale(0.97); }
  }
  .modal-lg { max-width: 720px; }

  /* ---------------------------------------------------------------- docs */
  .docs-layout {
    display: grid;
    grid-template-columns: 216px minmax(0, 1fr);
    gap: 36px;
    align-items: start;
  }
  .docs-nav {
    position: sticky;
    top: calc(var(--nav-h) + 20px);
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px;
  }
  .prose { max-width: 74ch; }
  .prose > * + * { margin-top: 18px; }
  .prose h2 {
    font-size: 1.32rem;
    margin-top: 44px;
    padding-top: 4px;
    scroll-margin-top: 96px;
  }
  .prose h3 { font-size: 1.02rem; margin-top: 28px; scroll-margin-top: 96px; }
  .prose p, .prose li { color: var(--ink-dim); font-size: 0.92rem; line-height: 1.72; }
  .prose ul, .prose ol { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
  .prose ul { list-style: none; padding-left: 4px; }
  .prose ul li { position: relative; padding-left: 18px; }
  .prose ul li::before {
    content: "";
    position: absolute;
    left: 2px; top: 0.68em;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.75;
  }
  .prose ol { list-style: decimal; }
  .prose ol li::marker { color: var(--ink-faint); }
  .prose a { color: var(--accent); text-decoration: underline;
             text-underline-offset: 3px; text-decoration-thickness: 1px; }
  .prose strong { color: var(--ink); font-weight: 580; }
  .prose code {
    font-family: var(--mono);
    font-size: 0.84em;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--stroke);
    color: #e6ffb0;
  }
  .prose table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
  .prose th, .prose td {
    text-align: left; padding: 10px 12px;
    border-bottom: 1px solid var(--stroke);
  }
  .prose th { color: var(--ink-faint); font-weight: 560; font-size: 0.76rem;
              text-transform: uppercase; letter-spacing: 0.05em; }

  .code-block {
    position: relative;
    border-radius: var(--r-sm);
    border: 1px solid var(--stroke);
    background: rgba(0, 0, 0, 0.42);
    overflow: hidden;
  }
  .code-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px 9px 15px;
    border-bottom: 1px solid var(--stroke);
    font-size: 0.72rem;
    color: var(--ink-faint);
    font-family: var(--mono);
    letter-spacing: 0.02em;
  }
  .code-block pre {
    padding: 15px;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 0.8rem;
    line-height: 1.68;
    color: #d7e3ee;
    tab-size: 2;
  }
  .code-block pre .tok-k { color: #cbf75a; }
  .code-block pre .tok-s { color: #9fd0ff; }
  .code-block pre .tok-c { color: rgba(255, 255, 255, 0.34); font-style: italic; }
  .code-block pre .tok-n { color: #ffc861; }

  /* ---------------------------------------------------------------- faq */
  .faq-item {
    border-radius: var(--r-sm);
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.028);
    overflow: hidden;
    transition: border-color 0.18s ease, background 0.18s ease;
  }
  .faq-item[open] {
    border-color: var(--stroke-strong);
    background: rgba(255, 255, 255, 0.042);
  }
  .faq-item summary {
    padding: 16px 18px;
    font-size: 0.9rem;
    font-weight: 540;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    list-style: none;
  }
  .faq-item summary::-webkit-details-marker { display: none; }
  .faq-item summary::after {
    content: "";
    margin-left: auto;
    width: 8px; height: 8px;
    border-right: 1.6px solid var(--ink-faint);
    border-bottom: 1.6px solid var(--ink-faint);
    transform: rotate(45deg);
    transition: transform 0.22s ease;
    flex: none;
    margin-top: -3px;
  }
  .faq-item[open] summary::after { transform: rotate(-135deg); margin-top: 3px; }
  .faq-answer {
    padding: 0 18px 18px;
    font-size: 0.87rem;
    color: var(--ink-dim);
    line-height: 1.7;
  }

  /* ------------------------------------------------------------ key reveal */
  .key-reveal {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-sm);
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(203, 247, 90, 0.3);
    font-family: var(--mono);
    font-size: 0.82rem;
    word-break: break-all;
  }

  /* -------------------------------------------------------------- tickets */
  .thread { display: flex; flex-direction: column; gap: 14px; }
  .msg {
    max-width: 82%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.87rem;
    line-height: 1.62;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
  .msg-user {
    align-self: flex-end;
    background: rgba(203, 247, 90, 0.13);
    border: 1px solid rgba(203, 247, 90, 0.24);
    border-bottom-right-radius: 5px;
  }
  .msg-staff {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--stroke);
    border-bottom-left-radius: 5px;
  }
  .msg-meta {
    font-size: 0.68rem;
    color: var(--ink-ghost);
    margin-top: 6px;
    letter-spacing: 0.01em;
  }

  .list-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
  }
  .list-row:hover {
    background: rgba(255, 255, 255, 0.035);
    border-color: var(--stroke);
  }
  .avatar {
    width: 34px; height: 34px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--stroke);
    font-size: 0.76rem;
    font-weight: 620;
    color: var(--ink-dim);
    flex: none;
    text-transform: uppercase;
  }

  .bar-track {
    height: 6px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.07);
    overflow: hidden;
  }
  .bar-fill {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, #a9dd3c, var(--accent));
    transition: width 0.5s cubic-bezier(0.2, 0.9, 0.3, 1);
  }
  .bar-fill.warn { background: linear-gradient(90deg, #e0a53c, var(--warn)); }
  .bar-fill.danger { background: linear-gradient(90deg, #d94a4a, var(--danger)); }

  .segmented {
    display: inline-flex;
    padding: 3px;
    gap: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid var(--stroke);
  }
  .segmented button {
    height: 30px;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 0.79rem;
    color: var(--ink-dim);
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
  }
  .segmented button.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--ink);
  }

  .pay-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border-radius: var(--r-sm);
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.028);
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease;
    text-align: left;
    width: 100%;
  }
  .pay-option:hover { border-color: var(--stroke-strong); }
  .pay-option.selected {
    border-color: rgba(203, 247, 90, 0.45);
    background: rgba(203, 247, 90, 0.07);
  }
  .pay-logo {
    width: 38px; height: 38px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--stroke);
    flex: none;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
  }

  .amount-chips { display: flex; gap: 8px; flex-wrap: wrap; }
  .amount-chip {
    height: 36px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    color: var(--ink-dim);
    transition: all 0.15s ease;
  }
  .amount-chip:hover { border-color: var(--stroke-strong); color: var(--ink); }
  .amount-chip.active {
    background: var(--accent-soft);
    border-color: rgba(203, 247, 90, 0.45);
    color: var(--accent);
    font-weight: 600;
  }

  .kbd {
    font-family: var(--mono);
    font-size: 0.72rem;
    padding: 2px 6px;
    border-radius: 5px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink-dim);
  }

  .tg-note {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    border-radius: var(--r-sm);
    border: 1px dashed rgba(127, 184, 255, 0.3);
    background: rgba(127, 184, 255, 0.05);
    font-size: 0.82rem;
    color: #cfe2ff;
    line-height: 1.55;
  }
}

@layer views {
  .page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: 26px;
  }
  .page-title { font-size: clamp(1.45rem, 2.8vw, 1.95rem); }
  .page-desc { font-size: 0.88rem; color: var(--ink-faint); margin-top: 6px; }

  .balance-hero {
    padding: clamp(22px, 3.4vw, 34px);
    display: flex;
    flex-direction: column;
    gap: 22px;
    overflow: hidden;
  }
  .balance-amount {
    font-size: clamp(2.1rem, 5.4vw, 3.2rem);
    font-weight: 640;
    letter-spacing: -0.045em;
    font-variant-numeric: tabular-nums;
    line-height: 1;
  }
  .balance-amount span { font-size: 0.42em; color: var(--ink-faint); margin-right: 6px; }

  .cta-band {
    padding: clamp(28px, 5vw, 52px);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    overflow: hidden;
  }
  .cta-band h2 { max-width: 22ch; }
  .cta-band p { max-width: 46ch; color: var(--ink-dim); font-size: 0.95rem; }

  .steps { counter-reset: step; display: flex; flex-direction: column; gap: 20px; }
  .step { display: flex; gap: 16px; align-items: flex-start; }
  .step-num {
    counter-increment: step;
    width: 30px; height: 30px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: rgba(203, 247, 90, 0.12);
    border: 1px solid rgba(203, 247, 90, 0.26);
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 640;
    flex: none;
  }
  .step-num::before { content: counter(step); }
  .step-body { padding-top: 3px; }
  .step-body h4 { font-size: 0.92rem; margin-bottom: 4px; }
  .step-body p { font-size: 0.85rem; color: var(--ink-dim); line-height: 1.6; }

  .footer {
    border-top: 1px solid var(--stroke);
    padding-block: 36px;
    margin-top: 60px;
  }
  .footer-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: space-between;
    align-items: flex-start;
  }
  .footer-links { display: flex; flex-wrap: wrap; gap: 8px 22px; }
  .footer-links a { font-size: 0.84rem; color: var(--ink-faint); }
  .footer-links a:hover { color: var(--ink); }
}

@layer responsive {
  @media (max-width: 1080px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }

  @media (max-width: 940px) {
    .docs-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    .docs-nav {
      position: static;
      flex-direction: row;
      overflow-x: auto;
      padding: 8px;
      gap: 4px;
      scrollbar-width: none;
    }
    .docs-nav::-webkit-scrollbar { display: none; }
    .docs-nav .side-link { white-space: nowrap; padding: 8px 12px; }
  }

  /* Tablet / phone: real re-layout, not a scaled desktop. */
  @media (max-width: 860px) {
    :root { --nav-h: 60px; }

    .nav-links { display: none; }
    .menu-toggle { display: grid; }

    .shell { grid-template-columns: minmax(0, 1fr); gap: 0; padding-bottom: 96px; }
    .sidebar {
      position: static;
      flex-direction: row;
      overflow-x: auto;
      padding: 6px;
      gap: 4px;
      scrollbar-width: none;
      margin-bottom: 18px;
    }
    .sidebar::-webkit-scrollbar { display: none; }
    .sidebar .side-group { display: none; }
    .sidebar .side-link { white-space: nowrap; padding: 9px 13px; }
    .sidebar .side-link svg { display: none; }
    .side-badge { margin-left: 6px; }

    .mobile-tabs {
      display: flex;
      position: fixed;
      left: 12px; right: 12px;
      bottom: calc(12px + env(safe-area-inset-bottom, 0px));
      z-index: 70;
      padding: 6px;
      gap: 2px;
      border-radius: 20px;
      background: rgba(10, 12, 18, 0.86);
      border: 1px solid var(--stroke-strong);
      backdrop-filter: blur(28px) saturate(160%);
      -webkit-backdrop-filter: blur(28px) saturate(160%);
      box-shadow: 0 -10px 40px -14px rgba(0, 0, 0, 0.9);
    }
    .mobile-tabs a {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 3px;
      padding: 7px 2px;
      border-radius: 15px;
      font-size: 0.64rem;
      color: var(--ink-faint);
      letter-spacing: 0.01em;
    }
    .mobile-tabs a svg { width: 19px; height: 19px; }
    .mobile-tabs a.active { color: var(--accent); background: rgba(255, 255, 255, 0.06); }

    .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hero { padding-block: 40px 34px; }
    .hero-title { max-width: none; }
    .footer { margin-top: 34px; }
    .msg { max-width: 92%; }
    .toasts { left: 12px; right: 12px; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); max-width: none; }
  }

  @media (max-width: 620px) {
    .grid-2, .grid-3, .grid-4, .grid-auto { grid-template-columns: minmax(0, 1fr); }
    .topbar-inner { gap: 10px; }
    .brand span { display: none; }
    .hero-actions .btn { width: 100%; }
    .page-head { align-items: flex-start; }
    .page-head .btn { width: 100%; }
    .modal { padding: 20px; }
    table.data { min-width: 460px; font-size: 0.8rem; }
    table.data td, table.data th { padding: 10px; }
    .stat-value { font-size: 1.3rem; }
    .card { padding: 16px; }
  }

  @media (max-width: 400px) {
    .btn { padding: 0 15px; font-size: 0.85rem; }
    .amount-chips .amount-chip { flex: 1; }
  }

  /* Telegram Mini App: viewport-driven spacing, no browser chrome assumptions. */
  body.tg-app { --pad: 16px; }
  body.tg-app .topbar { display: none; }
  body.tg-app .page { padding-top: 18px; }
  body.tg-app .mobile-tabs { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
}

/* Print-free, motion-safe fade for view transitions */
.view-enter { animation: view-in 0.32s cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
}
