:root {
    --bg: #0b1220;
    --card-bg: rgba(20, 27, 43, 0.92);
    --text: #f8fafc;
    --muted: #94a3b8;
    --accent: #38bdf8;
    --success: #22c55e;
    --pending: #f59e0b;
    --danger: #ef4444;
    --border: rgba(148, 163, 184, 0.18);
    --radius: 16px;
    font-synthesis: none;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: radial-gradient(120% 140% at 10% 10%, rgba(56, 189, 248, 0.12), transparent),
                radial-gradient(90% 130% at 90% 0%, rgba(99, 102, 241, 0.18), transparent),
                var(--bg);
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
}

body {
    display: flex;
    justify-content: center;
    padding: 24px;
    overflow-x: hidden;
}

.app {
    width: min(1100px, 100%);
    display: grid;
    grid-template-columns: 230px 1fr;
    gap: 24px;
    align-items: flex-start;
}

.sidebar {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 20px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
}

.sidebar__brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar__logo {
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.sidebar__subtitle {
    font-size: 12px;
    color: var(--muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

.sidebar__item {
    width: 100%;
    border: 1px solid transparent;
    background: rgba(15, 23, 42, 0.55);
    color: var(--muted);
    border-radius: 12px;
    padding: 12px 16px;
    text-align: left;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar__item:hover,
.sidebar__item:focus-visible {
    border-color: rgba(56, 189, 248, 0.25);
    color: var(--accent);
}

.sidebar__item.active {
    background: rgba(56, 189, 248, 0.12);
    color: var(--accent);
    border-color: rgba(56, 189, 248, 0.35);
}

.content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.view {
    display: none;
}

.view--active {
    display: block;
}

.content__header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
}

.sidebar-toggle {
    appearance: none;
    border: 1px solid rgba(56, 189, 248, 0.3);
    background: rgba(56, 189, 248, 0.12);
    color: var(--accent);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    align-self: flex-start;
    margin-bottom: 16px;
    position: sticky;
    top: 12px;
    z-index: 5;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
    background: rgba(56, 189, 248, 0.2);
    border-color: rgba(56, 189, 248, 0.5);
}


@media (min-width: 821px) {
    .app.sidebar-hidden {
        grid-template-columns: 1fr;
    }

    .app.sidebar-hidden .sidebar {
        display: none;
    }
}

.app.sidebar-hidden #sidebar-toggle {
    background: rgba(15, 23, 42, 0.7);
    color: var(--muted);
    border-color: rgba(148, 163, 184, 0.25);
}

.app.sidebar-hidden #sidebar-toggle::after,
.app:not(.sidebar-hidden) #sidebar-toggle::after {
    content: '';
}

.content__title h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 600;
}

.content__title p {
    margin: 8px 0 0;
    color: var(--muted);
}

.content__status {
    align-self: flex-start;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.12);
    color: var(--accent);
    font-size: 13px;
    font-weight: 500;
}

.content__status--ok {
    background: rgba(34, 197, 94, 0.16);
    color: var(--success);
}

.content__status--error {
    background: rgba(239, 68, 68, 0.16);
    color: var(--danger);
}

.cards {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 1px solid transparent;
    background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.22), transparent 55%);
    z-index: 0;
    pointer-events: none;
}

.card__label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.card__value {
    font-size: 30px;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.card__description {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
    position: relative;
    z-index: 1;
}

.network-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
}

.network-list__item {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--text);
}

.section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.28);
    min-width: 0;
}

.section__header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
}

.section__header h2 {
    margin: 0;
    font-size: 22px;
}

.filters {
    display: inline-flex;
    background: rgba(15, 23, 42, 0.65);
    border-radius: 20px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    padding: 4px;
    gap: 6px;
    flex-wrap: wrap;
}

.filters__btn {
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.filters__btn.active {
    background: rgba(56, 189, 248, 0.16);
    color: var(--accent);
}

.filters__btn:focus-visible {
    outline: 2px solid rgba(56, 189, 248, 0.32);
}

.table {
    position: relative;
    width: 100%;
    max-width: 100%;
    border-radius: calc(var(--radius) - 8px);
    border: 1px solid rgba(148, 163, 184, 0.12);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.table__content {
    min-width: 100%;
    width: max(680px, 100%);
    display: flex;
    flex-direction: column;
}

.table__head,
.table__row {
    display: grid;
    grid-template-columns: 130px 1fr 130px 150px;
    gap: 12px;
    align-items: center;
}

.table__head {
    background: rgba(15, 23, 42, 0.72);
    padding: 14px 18px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(148, 163, 184, 0.8);
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.table__body {
    display: flex;
    flex-direction: column;
}

.table__head .table__cell {
    flex-direction: row;
    align-items: center;
    font-weight: 600;
    gap: 6px;
}

.table__head .table__cell--amount,
.table__head .table__cell--meta {
    justify-content: flex-end;
}

.table__placeholder {
    padding: 40px 0;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.table__row {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.table__row:last-child {
    border-bottom: none;
}

.table__cell {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.table__cell--status {
    align-items: flex-start;
}

.table__cell--amount {
    font-size: 18px;
    font-weight: 600;
    text-align: right;
    align-items: flex-end;
}

.table__cell--meta {
    color: var(--muted);
    font-size: 12px;
    text-align: right;
    align-items: flex-end;
}

.table__title {
    font-weight: 600;
}

.table__subtitle {
    font-size: 13px;
    color: var(--text);
}

.table__subtitle--muted {
    color: var(--muted);
}

.badge {
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge--success {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.badge--pending {
    background: rgba(245, 158, 11, 0.2);
    color: var(--pending);
}

.badge--failed {
    background: rgba(239, 68, 68, 0.18);
    color: var(--danger);
}

.users {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.user-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
}

.user-controls__filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.users__pagination {
    margin-top: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.users__pagination-info {
    font-size: 13px;
    color: var(--muted);
}

.users__pagination-btn {
    min-width: 108px;
}

.user-search {
    display: flex;
    width: 100%;
    max-width: 420px;
}

.user-search__input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15, 23, 42, 0.75);
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.user-search__input:focus {
    outline: none;
    border-color: rgba(56, 189, 248, 0.45);
}

.user-card {
    padding: 18px;
    border-radius: calc(var(--radius) - 6px);
    border: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(15, 23, 42, 0.72);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-card__title {
    font-weight: 600;
}

.user-card__meta {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.4;
}

.user-card__footer {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(148, 163, 184, 0.95);
}

.user-card__actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.user-card__btn {
    border: 1px solid rgba(56, 189, 248, 0.3);
    background: rgba(56, 189, 248, 0.12);
    color: var(--accent);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.user-card__btn:hover,
.user-card__btn:focus-visible {
    background: rgba(56, 189, 248, 0.2);
    border-color: rgba(56, 189, 248, 0.5);
}

.users__placeholder {
    padding: 24px;
    border-radius: calc(var(--radius) - 6px);
    background: rgba(15, 23, 42, 0.6);
    text-align: center;
    color: var(--muted);
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.section--details {
    padding: 24px;
}

.user-detail {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.user-detail__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.user-detail__back {
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15, 23, 42, 0.55);
    color: var(--muted);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.user-detail__back:hover,
.user-detail__back:focus-visible {
    border-color: rgba(56, 189, 248, 0.4);
    color: var(--accent);
}

.user-detail__headline h2 {
    margin: 0 0 6px;
}

.user-detail__headline p {
    margin: 0;
    color: var(--muted);
}

.user-detail__summary {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.user-detail__summary-item {
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 12px;
    padding: 14px;
    background: rgba(15, 23, 42, 0.6);
}

.user-detail__summary-item span {
    display: block;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.user-detail__summary-item strong {
    font-size: 16px;
    font-weight: 600;
}

.user-detail__subscription {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    align-items: start;
}

.user-detail__subscription-info {
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 12px;
    padding: 16px;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
}

.subscription-form,
.subscription-cancel {
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.55);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.subscription-cancel.is-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
}

.form-row input,
.subscription-cancel textarea {
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 10px;
    background: rgba(12, 19, 32, 0.8);
    color: var(--text);
    padding: 10px 12px;
    font-size: 14px;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
}

.form-checkbox input {
    width: 16px;
    height: 16px;
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.btn--secondary {
    background: rgba(148, 163, 184, 0.12);
    border-color: rgba(148, 163, 184, 0.32);
    color: rgba(226, 232, 240, 0.85);
}

.btn--secondary:hover,
.btn--secondary:focus-visible {
    background: rgba(148, 163, 184, 0.18);
    border-color: rgba(148, 163, 184, 0.42);
}

.btn--secondary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn--primary {
    background: rgba(56, 189, 248, 0.18);
    border-color: rgba(56, 189, 248, 0.35);
    color: var(--accent);
}

.btn--primary:hover,
.btn--primary:focus-visible {
    background: rgba(56, 189, 248, 0.28);
}

.btn--danger {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.35);
    color: var(--danger);
}

.btn--danger:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn--danger:hover:not(:disabled),
.btn--danger:focus-visible:not(:disabled) {
    background: rgba(239, 68, 68, 0.28);
}

.user-detail__payments,
.user-detail__referrals {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.referral-link {
    margin-top: 18px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 12px;
    padding: 12px 14px;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.referral-link--copied {
    border-color: rgba(34, 197, 94, 0.45);
}

.referral-link__label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.referral-link__value {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: var(--accent);
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    word-break: break-all;
    transition: color 0.2s ease;
}

.referral-link__value:hover:not(:disabled),
.referral-link__value:focus-visible:not(:disabled) {
    text-decoration: underline;
}

.referral-link__value:disabled,
.referral-link__value.is-disabled {
    color: var(--muted);
    cursor: not-allowed;
    text-decoration: none;
}

.referral-link__hint {
    font-size: 12px;
    color: var(--muted);
}

.referral-link__hint--success {
    color: var(--success);
}

.referral-link__hint--error {
    color: var(--danger);
}

.user-detail__list {
    display: grid;
    gap: 10px;
}

.user-detail__list--payments {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.user-detail__list-item {
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 12px;
    padding: 14px;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
}

.user-detail__list-item strong {
    font-size: 15px;
}

.user-detail__list-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.empty-state {
    padding: 36px 0;
    text-align: center;
    color: var(--muted);
}

@media (max-width: 820px) {
    body {
        padding: 18px 16px 32px;
    }

    .app {
        display: flex;
        flex-direction: column;
        gap: 18px;
    }

    .sidebar {
        position: static;
        flex-direction: column;
        max-height: none;
        padding: 20px;
        gap: 16px;
    }

    .sidebar__nav {
        flex-direction: row;
        gap: 8px;
    }

    .sidebar__item {
        flex: 1;
        text-align: center;
        padding: 10px 12px;
    }

    .content {
        gap: 20px;
    }

    .sidebar-toggle {
        padding: 10px 12px;
    }
}

@media (max-width: 640px) {
    body {
        padding: 16px 12px 28px;
    }

    .content__header {
        padding: 20px;
    }

    .section {
        padding: 20px;
    }

    .card {
        padding: 18px;
    }

    .sidebar__nav {
        flex-direction: column;
    }

    .sidebar-toggle {
        width: 100%;
    }

    .content__status {
        align-self: stretch;
        text-align: center;
    }

    .filters {
        width: 100%;
        justify-content: center;
    }

    .filters__btn {
        flex: 1 1 45%;
    }

    .user-controls {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .user-controls__filters {
        width: 100%;
        justify-content: center;
    }

    .table__content {
        width: max(620px, 100%);
    }

    .user-detail__summary {
        grid-template-columns: 1fr;
    }

    .user-detail__subscription {
        grid-template-columns: 1fr;
    }

    .user-detail__list--payments {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    html, body {
      font-size: 14px; /* чуть меньше базовый размер */
      padding-top: calc(env(safe-area-inset-top, 0px));
    }
  
    .content__header { padding: 14px; gap: 8px; }
    .content__title h1 { font-size: 20px; }
    .content__title p { font-size: 12px; margin-top: 4px; }
  
    .cards { gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
    .card { padding: 14px; }
    .card__value { font-size: 22px; }
    .card__label { font-size: 11px; }
    .card__description { font-size: 12px; }
  
    .section { padding: 14px; }
    .filters { width: 100%; justify-content: center; padding: 3px; gap: 4px; }
    .filters__btn { padding: 6px 12px; font-size: 12px; }
  
    /* Заголовок таблицы скрываем — на карточках не нужен */
    .table__head { display: none; }
  
    /* Каждая строка таблицы превращается в компактную карточку */
    .table__row {
      display: grid;
      grid-template-columns: 1fr auto; /* слева текст, справа сумма */
      grid-template-areas:
        "status amount"
        "title  amount"
        "meta   amount";
      gap: 6px 10px;
      padding: 12px 12px;
    }
  
    .table__cell--status { grid-area: status; align-items: flex-start; }
    .table__cell:nth-child(2) { grid-area: title; }            /* ячейка с title/subtitle */
    .table__cell--amount { grid-area: amount; font-size: 16px; }
    .table__cell--meta { grid-area: meta; font-size: 11px; }
  
    /* Чуть уменьшаем бейджи */
    .badge { padding: 4px 8px; font-size: 11px; border-radius: 8px; }
  
    /* Перенастройка текста, чтобы не вылазил */
    .table__title {
      font-size: 14px;
      line-height: 1.2;
      word-break: break-all;        /* длинные email/tx_hash не ломают верстку */
      overflow-wrap: anywhere;
    }
    .table__subtitle { font-size: 12px; }
    .table__cell--meta { text-align: left; align-items: flex-start; color: var(--muted); }
  
    /* Контейнеры таблицы без фиксированных ширин */
    .table { border-radius: 12px; }
    .table__content { min-width: 0; width: 100%; }
  
    /* Сайдбар и кнопка */
    .sidebar-toggle { padding: 8px 10px; font-size: 12px; top: 8px; }
  }

  @media (min-width: 481px) and (max-width: 640px) {
    .table__head { display: none; }
    .table__row {
      display: grid;
      grid-template-columns: 1fr auto;
      grid-template-areas:
        "status amount"
        "title  amount"
        "meta   amount";
      gap: 8px 12px;
      padding: 14px 14px;
    }
    .table__title { word-break: break-all; overflow-wrap: anywhere; }
  }

@media (max-width: 820px) {
    .app {
        position: relative;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(86vw, 320px);
        max-width: 92vw;
        height: 100vh;
        border-radius: 0;
        border-right: 1px solid var(--border);
        transform: translateX(-102%);
        transition: transform 0.28s ease;
        z-index: 70;
        display: block;
    }

    .app.sidebar-hidden .sidebar {
        transform: translateX(-102%);
        pointer-events: none;
    }

    .app:not(.sidebar-hidden) .sidebar {
        transform: translateX(0);
        pointer-events: auto;
    }

    .app::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(2, 6, 23, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        z-index: 65;
    }

    .app:not(.sidebar-hidden)::before {
        opacity: 1;
        pointer-events: auto;
    }
}
  
.table, .section, .content { overflow-x: hidden; }
