:root {
    --tg-bg: var(--tg-theme-bg-color, #ffffff);
    --tg-text: var(--tg-theme-text-color, #000000);
    --tg-hint: var(--tg-theme-hint-color, #999999);
    --tg-button: var(--tg-theme-button-color, #3390ec);
    --tg-button-text: var(--tg-theme-button-text-color, #ffffff);
    --tg-secondary-bg: var(--tg-theme-secondary-bg-color, #f0f0f0);
    --tg-link: var(--tg-theme-link-color, #3390ec);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: var(--tg-bg);
    color: var(--tg-text);
    padding-bottom: 100px;
    overflow-x: hidden;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Хедер */
.header {
    padding: 20px 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--tg-secondary-bg);
    margin-bottom: 16px;
}

.header h1 {
    font-size: 22px;
    font-weight: 600;
}

.user-info {
    font-size: 13px;
    color: var(--tg-hint);
}

/* Dashboard */
.dashboard {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--tg-secondary-bg);
    border-radius: 12px;
    padding: 14px;
    text-align: center;
}

.stat-value {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 4px;
    line-height: 1.2;
}

.stat-label {
    font-size: 11px;
    color: var(--tg-hint);
}

/* Навигация */
.nav-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    background: var(--tg-secondary-bg);
    color: var(--tg-text);
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    flex-shrink: 0;
}

.tab.active {
    background: var(--tg-button);
    color: var(--tg-button-text);
}

/* Контент */
#content {
    min-height: 300px;
}

/* Список карточек */
.card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card {
    background: var(--tg-secondary-bg);
    border-radius: 12px;
    padding: 14px;
    position: relative;
    transition: transform 0.1s;
}

.card:active {
    transform: scale(0.98);
}

.card-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 15px;
    line-height: 1.3;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--tg-hint);
    gap: 8px;
}

.card-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    background: var(--tg-button);
    color: var(--tg-button-text);
}

.card-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.btn {
    background: var(--tg-button);
    color: var(--tg-button-text);
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: opacity 0.2s;
    flex: 1;
}

.btn:active {
    opacity: 0.7;
}

.btn-secondary {
    background: transparent;
    color: var(--tg-text);
    border: 1px solid var(--tg-hint);
}

.btn-danger {
    background: #ff3b30;
    color: white;
}

/* FAB кнопка */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--tg-button);
    color: var(--tg-button-text);
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: transform 0.2s;
}

.fab:active {
    transform: scale(0.95);
}

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

.funnel-stage {
    background: var(--tg-secondary-bg);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.funnel-stage-name {
    font-weight: 500;
    font-size: 14px;
}

.funnel-stage-count {
    background: var(--tg-button);
    color: var(--tg-button-text);
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--tg-bg);
    border-radius: 16px;
    padding: 20px;
    max-width: 400px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

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

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
}

.form-input, .form-select {
    width: 100%;
    background: var(--tg-secondary-bg);
    color: var(--tg-text);
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 15px;
    font-family: inherit;
}

.form-input:focus, .form-select:focus {
    outline: 2px solid var(--tg-button);
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

/* Лоадер */
.loader {
    text-align: center;
    padding: 60px 20px;
    color: var(--tg-hint);
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--tg-secondary-bg);
    border-top-color: var(--tg-button);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}

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

.empty-state {
    text-align: center;
    padding: 60px 20px;
}

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

.empty-state-text {
    color: var(--tg-hint);
    margin-bottom: 16px;
}

/* Статистика */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.stats-card {
    background: var(--tg-secondary-bg);
    border-radius: 12px;
    padding: 14px;
}

.stats-card-title {
    font-size: 12px;
    color: var(--tg-hint);
    margin-bottom: 6px;
}

.stats-card-value {
    font-size: 20px;
    font-weight: bold;
}

/* Анимации */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    animation: fadeIn 0.3s ease;
}
