/* Партнёрская панель — светлая тема.
 *
 * Своя палитра, без внешних CDN: панель уходит на российский сервер и
 * показывает деньги, лишняя внешняя зависимость тут ни к чему.
 * Переменные --tg-theme-* Telegram подставляет сам, наши значения — фолбэк.
 */

:root {
    --bg: #faf8f5;
    --bg-card: #ffffff;
    --bg-soft: #f3efe9;
    --text: #2f2a24;
    --text-muted: #7d7266;
    --line: #e8e1d8;
    --accent: #c19a4b;
    --accent-soft: #f6efe0;
    --accent-text: #ffffff;
    --shadow: 0 2px 12px rgba(63, 51, 36, 0.06);
    --shadow-lift: 0 6px 24px rgba(63, 51, 36, 0.1);
    --radius: 18px;
    --radius-sm: 12px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding: 16px 16px calc(28px + var(--safe-bottom));
    max-width: 640px;
    margin: 0 auto;
}

/* ===== Карточки ===== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 14px;
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 14px;
}

/* ===== Профиль ===== */

.profile {
    display: flex;
    align-items: center;
    gap: 16px;
}

.avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-soft);
    border: 2px solid var(--line);
    display: block;
}

.avatar-placeholder {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--accent-soft);
    border: 2px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 600;
    color: var(--accent);
}

.avatar-edit {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-text);
    border: 2px solid var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    cursor: pointer;
    padding: 0;
}

.profile-info {
    min-width: 0;
    flex: 1;
}

.profile-name {
    font-size: 19px;
    font-weight: 600;
    margin: 0 0 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-username {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0 0 8px;
}

.id-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    font-size: 13px;
}

.id-value {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    color: var(--text-muted);
}

.copy-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    padding: 0;
}

.copy-btn.done {
    color: #4a8b5c;
}

/* ===== Баланс ===== */

.balance-amount {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.balance-currency {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-muted);
    margin-left: 4px;
}

.balance-extra {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-muted);
}

/* ===== Сеть ===== */

.stats {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.stat {
    flex: 1;
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.levels {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 6px;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
}

.level-btn {
    flex-shrink: 0;
    min-width: 52px;
    background: var(--bg-soft);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    cursor: pointer;
    font-family: inherit;
    color: var(--text);
    text-align: center;
    transition: background 0.15s, border-color 0.15s;
}

.level-btn[aria-selected="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}

.level-btn-num {
    display: block;
    font-size: 11px;
    opacity: 0.75;
}

.level-btn-count {
    display: block;
    font-size: 16px;
    font-weight: 600;
}

.members {
    list-style: none;
    margin: 0;
    padding: 0;
}

.member {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
}

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

.member-name {
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.member-date {
    font-size: 13px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ===== Состояния ===== */

.muted {
    color: var(--text-muted);
    font-size: 14px;
}

.empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    padding: 22px 12px;
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-soft) 25%, #ece6de 50%, var(--bg-soft) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 6px;
    color: transparent;
}

@keyframes shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .skeleton { animation: none; }
}

.notice {
    background: var(--accent-soft);
    border: 1px solid #e6d5ae;
    border-radius: var(--radius-sm);
    padding: 13px 15px;
    font-size: 14px;
    margin-bottom: 14px;
}

.error {
    background: #fdf0ee;
    border: 1px solid #f0cdc6;
    border-radius: var(--radius-sm);
    padding: 13px 15px;
    font-size: 14px;
    margin-bottom: 14px;
}

.sync-note {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.hidden {
    display: none !important;
}

/* Панель сделана под светлую тему намеренно. При тёмной схеме Telegram
 * подтягиваем фон, чтобы карточки не резали глаз белым на чёрном. */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #f3efe9;
    }
}
