/* Reset и базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f7;
    color: #1d1d1f;
    line-height: 1.6;
}

/* Синий фон для body когда показывается экран установки */
body:has(.install-screen),
body.install-screen-active {
    background: linear-gradient(180deg, #007aff 0%, #0056b3 100%);
    min-height: 100vh;
    overflow: hidden;
}

/* Loading screen */
.loading-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f7;
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e5e7;
    border-top-color: #007aff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

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

/* Основное приложение */
.main-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: 80px; /* Место для нижнего меню */
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

/* Нижнее меню */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #e5e5e7;
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    color: #86868b;
    transition: color 0.2s;
}

.nav-item.active {
    color: #007aff;
}

.nav-icon {
    font-size: 24px;
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
}

/* Общие компоненты */
.screen {
    padding: 20px;
    max-width: 100%;
}

.card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #007aff;
    color: #fff;
}

.btn-primary:hover {
    background: #0051d5;
}

.btn-secondary {
    background: #f5f5f7;
    color: #1d1d1f;
}

.btn-secondary:hover {
    background: #e5e5e7;
}

.input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 16px;
}

.input:focus {
    outline: none;
    border-color: #007aff;
}

.label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #1d1d1f;
}

/* Заголовки */
h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 16px;
}

h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

/* Метрики */
.metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    color: #1d1d1f;
}

.metric-value.negative-balance {
    color: #ff3b30;
}

.metric-label {
    font-size: 14px;
    color: #86868b;
}

.metric-change {
    font-size: 14px;
    color: #34c759;
}

.metric-change.negative {
    color: #ff3b30;
}

/* Воронка */
.funnel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.funnel-step {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: #f5f5f7;
    border-radius: 8px;
}

.funnel-step-label {
    font-weight: 500;
}

.funnel-step-value {
    font-size: 20px;
    font-weight: 700;
}

.funnel-step-conversion {
    font-size: 12px;
    color: #86868b;
    margin-top: 4px;
}

/* Графики */
.chart-container {
    height: 200px;
    background: #f5f5f7;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #86868b;
}

/* Список */
.list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.list-item {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Статусы */
.status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

.status-paused {
    background: #fff3cd;
    color: #856404;
}

.status-draft {
    background: #e5e5e7;
    color: #86868b;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-error {
    background: #f8d7da;
    color: #721c24;
}

.status-cancelled {
    background: #e5e5e7;
    color: #86868b;
}

/* Плавающая кнопка */
.fab {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #007aff;
    color: #fff;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
    z-index: 999;
}

.fab:hover {
    background: #0051d5;
}

/* Фильтры */
.filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-chip {
    padding: 8px 16px;
    border: 1px solid #d2d2d7;
    border-radius: 20px;
    background: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-chip.active {
    background: #007aff;
    color: #fff;
    border-color: #007aff;
}

/* Период */
.period-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.period-item {
    padding: 8px 16px;
    border: 1px solid #d2d2d7;
    border-radius: 20px;
    background: #fff;
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.period-item.active {
    background: #007aff;
    color: #fff;
    border-color: #007aff;
}

/* Онбординг */
.onboarding-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    position: relative;
}

.onboarding-content {
    max-width: 400px;
    width: 100%;
    text-align: center;
    color: #fff;
    position: relative;
    padding-top: 48px;
}

.onboarding-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px;
}

.lang-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    min-width: 120px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    padding: 8px 32px 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23fff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.lang-select option {
    background: #4a5568;
    color: #fff;
}

.skip-btn {
    color: #fff;
    cursor: pointer;
    opacity: 0.9;
    background: none;
    border: none;
    font-size: 14px;
}

.slide-container {
    margin-bottom: 40px;
}

.slide-icon {
    font-size: 80px;
    margin-bottom: 24px;
}

.slide-container h1 {
    color: #fff;
    margin-bottom: 16px;
    font-size: 28px;
}

.slide-container p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    line-height: 1.6;
}

.slide-indicators {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 32px;
}

.indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.3s;
}

.indicator.active {
    background: #fff;
    width: 24px;
    border-radius: 4px;
}

/* Логин */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #f5f5f7;
}

.login-container {
    max-width: 400px;
    width: 100%;
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.login-top {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.lang-select--light {
    background: #f5f5f7;
    border-color: rgba(0, 0, 0, 0.15);
    color: #1d1d1f;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231d1d1f' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.lang-select--light option {
    background: #fff;
    color: #1d1d1f;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    margin-bottom: 8px;
}

.login-header p {
    color: #86868b;
    font-size: 14px;
}

.login-form {
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 14px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.forgot-link {
    color: #007aff;
    text-decoration: none;
}

.login-footer {
    text-align: center;
    padding-top: 24px;
    border-top: 1px solid #e5e5e7;
    font-size: 12px;
    color: #86868b;
    line-height: 1.6;
}

/* Верификация кода */
.verify-info {
    text-align: center;
    margin-bottom: 24px;
}

.verify-info p {
    color: #86868b;
    font-size: 14px;
}

.verify-email {
    font-weight: 600;
    color: #1d1d1f;
    font-size: 16px;
    margin: 4px 0 8px;
}

.change-email-btn {
    background: none;
    border: none;
    color: #007aff;
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
}

.code-inputs {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 16px;
}

.code-input {
    width: 48px;
    height: 56px;
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    border: 2px solid #e5e5e7;
    border-radius: 12px;
    outline: none;
    transition: border-color 0.2s;
}

.code-input:focus {
    border-color: #007aff;
}

.code-input:disabled {
    background: #f5f5f7;
}

.error-message {
    color: #ff3b30;
    font-size: 14px;
    text-align: center;
    margin-top: 12px;
    padding: 8px;
    background: #fff5f5;
    border-radius: 8px;
}

.btn-secondary {
    background: #f5f5f7;
    color: #1d1d1f;
    border: none;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #e5e5e7;
}

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

/* Дополнительные стили */
.welcome-section {
    margin-bottom: 24px;
}

.main-metric {
    text-align: center;
    padding: 24px;
    background: #fff;
    border-radius: 12px;
    margin-top: 16px;
}

.earnings-summary {
    text-align: center;
}

.progress-bar {
    height: 8px;
    background: #e5e5e7;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #007aff;
    transition: width 0.3s;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #e5e5e7;
}

.info-item:last-child {
    border-bottom: none;
}

.profile-header {
    margin-bottom: 20px;
}

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

.link-item {
    color: #007aff;
    text-decoration: none;
    padding: 12px 0;
    border-bottom: 1px solid #e5e5e7;
}

.link-item:last-child {
    border-bottom: none;
}

.source-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.source-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    border: 2px solid #e5e5e7;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.source-btn.active {
    border-color: #007aff;
    background: #f0f7ff;
}

.earnings-breakdown {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.breakdown-item {
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e5e7;
}

.breakdown-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* Модальное окно */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e5e7;
}

.modal-header h2 {
    font-size: 18px;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #86868b;
    padding: 0;
    line-height: 1;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid #e5e5e7;
}

.modal-footer .btn {
    flex: 1;
}

/* Созданная ссылка */
.created-link-info {
    text-align: center;
}

.success-icon {
    width: 60px;
    height: 60px;
    background: #34c759;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 16px;
}

.link-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.link-url-box {
    background: #f5f5f7;
    padding: 12px;
    border-radius: 8px;
    word-break: break-all;
}

.link-url-box code {
    font-size: 14px;
    color: #007aff;
}

/* FAB кнопка */
.fab {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #007aff;
    color: #fff;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.fab:hover {
    background: #0056b3;
}

/* Пустой список */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #86868b;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

/* Выбор типа компенсации */
.compensation-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.compensation-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border: 2px solid #e5e5e7;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.compensation-option:hover {
    border-color: #c5c5c7;
}

.compensation-option.active {
    border-color: #007aff;
    background: #f0f7ff;
}

.compensation-option input[type="radio"] {
    margin-top: 2px;
}

.compensation-content {
    flex: 1;
}

.compensation-label {
    font-weight: 600;
    margin-bottom: 2px;
}

.compensation-desc {
    font-size: 12px;
    color: #86868b;
}

/* Бейдж типа компенсации */
.compensation-badge {
    font-size: 10px;
    padding: 4px 6px;
    border-radius: 4px;
    font-weight: 500;
}


.compensation-first_payment {
    background: #e3f2fd;
    color: #1565c0;
}

.compensation-recurring {
    background: #fff3e0;
    color: #ef6c00;
}

.compensation-per_registration {
    background: #f3e5f5;
    color: #7b1fa2;
}

/* Кнопка outline */
.btn-outline {
    background: transparent;
    color: #007aff;
    border: 1px solid #007aff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-outline:hover {
    background: #007aff;
    color: #fff;
}

/* Модальное окно детализации - полный экран */
.modal-large {
    max-width: 100%;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    display: flex;
    flex-direction: column;
}

.modal-large .modal-body {
    flex: 1;
    overflow-y: auto;
}

.modal-overlay:has(.modal-large) {
    padding: 0;
}

.detail-section {
    margin-bottom: 24px;
}

.detail-section h3 {
    font-size: 14px;
    color: #86868b;
    margin-bottom: 8px;
    font-weight: 500;
}

.detail-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.detail-stat {
    text-align: center;
    flex: 1;
}

.detail-stat-value {
    font-size: 20px;
    font-weight: 600;
}

.detail-stat-label {
    font-size: 11px;
    color: #86868b;
}

.detail-stat-conversion {
    font-size: 10px;
    color: #34c759;
    margin-top: 2px;
}

.detail-stat-arrow {
    color: #c5c5c7;
    font-size: 14px;
}

.detail-revenue {
    font-size: 32px;
    font-weight: 700;
    color: #34c759;
}

/* Экран установки PWA */
.install-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    padding-top: 60px;
    padding-bottom: 120px;
    background: linear-gradient(180deg, #007aff 0%, #0056b3 100%);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 9999;
}

.install-container {
    text-align: center;
    color: #fff;
    max-width: 320px;
    position: relative;
    padding-top: 50px;
    margin-top: 40px;
    margin-bottom: 80px;
}

.install-lang-selector {
    position: absolute;
    top: 0;
    right: 0;
    margin-bottom: 24px;
}

.lang-select--install {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    min-width: 120px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    padding: 10px 36px 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23fff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: all 0.2s ease;
}

.lang-select--install:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
}

.lang-select--install:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.lang-select--install option {
    background: #4a5568;
    color: #fff;
}

.install-icon {
    margin-bottom: 24px;
}

.install-icon img {
    width: 120px;
    height: 120px;
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.install-screen h1 {
    font-size: 28px;
    margin-bottom: 12px;
}

.install-screen p {
    font-size: 16px;
    opacity: 0.9;
    margin-bottom: 32px;
    line-height: 1.5;
}

.install-instructions {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 20px;
    text-align: left;
}

.install-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.install-step:last-child {
    border-bottom: none;
}

.step-number {
    width: 28px;
    height: 28px;
    background: #fff;
    color: #007aff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.install-step i {
    font-size: 18px;
}

.install-actions {
    margin-top: 24px;
}

.install-screen .btn-primary {
    background: #fff;
    color: #007aff;
}

.install-screen .btn-primary:hover {
    background: #f0f0f0;
}

/* ApexCharts стили для полной ширины */
.chart-container {
    width: 100% !important;
}

.chart-container #activityChart {
    width: 100% !important;
    max-width: 100% !important;
}

.chart-container .apexcharts-inner,
.chart-container .apexcharts-graphical,
.chart-container .apexcharts-canvas,
.chart-container svg {
    width: 100% !important;
    max-width: 100% !important;
}

.chart-container .apexcharts-svg {
    width: 100% !important;
    max-width: 100% !important;
}

.chart-container .apexcharts-inner.apexcharts-graphical {
    transform: translate(10px, 30px) !important;
}

