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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--tg-theme-bg-color, #ffffff);
    color: var(--tg-theme-text-color, #000);
    padding: 16px 16px 90px;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

.screen { display: none; animation: fadeIn 0.3s ease; }
.screen.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* HERO заголовок */
.hero { margin-bottom: 24px; padding: 8px 4px; }
.hero h1 { font-size: 28px; font-weight: 800; margin-bottom: 4px; }
.subtitle { font-size: 14px; color: var(--tg-theme-hint-color, #999); }

/* HEADER (с кнопкой назад) */
.header {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--tg-theme-hint-color, #e0e0e0);
}
.header h1 { font-size: 22px; font-weight: 700; }
.back-btn {
    background: none;
    border: none;
    color: var(--tg-theme-link-color, #2481cc);
    font-size: 16px;
    cursor: pointer;
    margin-bottom: 8px;
    padding: 0;
}

/* СТАТИСТИКА (сетка) */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
}

.stat-icon { font-size: 28px; margin-bottom: 4px; }
.stat-value { font-size: 28px; font-weight: 800; margin: 4px 0; }
.stat-label { font-size: 12px; color: var(--tg-theme-hint-color, #999); }

/* КАРТОЧКА */
.card {
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
}

.card h3 { font-size: 16px; margin-bottom: 16px; }

/* СПИСОК КАНАЛОВ */
.channels-list { display: flex; flex-direction: column; gap: 12px; }

.channel-card {
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    border-radius: 14px;
    padding: 16px;
    cursor: pointer;
    transition: transform 0.15s;
    border: 1px solid transparent;
}

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

.channel-card h3 { font-size: 17px; margin-bottom: 8px; }

.channel-card .info {
    font-size: 13px;
    color: var(--tg-theme-hint-color, #999);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
}

.channel-stats {
    display: flex;
    gap: 16px;
    padding-top: 8px;
    border-top: 1px solid var(--tg-theme-hint-color, #e0e0e0);
    font-size: 12px;
}

.channel-stats span { display: flex; align-items: center; gap: 4px; }

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
}

.badge.on { background: rgba(52, 199, 89, 0.15); color: #34c759; }
.badge.off { background: rgba(255, 59, 48, 0.15); color: #ff3b30; }

/* ТАБЫ */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    padding: 4px;
    border-radius: 12px;
}

.tab {
    flex: 1;
    background: none;
    border: none;
    padding: 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--tg-theme-hint-color, #999);
    cursor: pointer;
    transition: all 0.2s;
}

.tab.active {
    background: var(--tg-theme-bg-color, #fff);
    color: var(--tg-theme-text-color, #000);
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.2s; }

/* ФОРМЫ */
.setting { margin-bottom: 20px; }
.setting:last-child { margin-bottom: 0; }

.setting label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

.setting input[type="text"],
.setting textarea,
.setting select {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--tg-theme-hint-color, #ddd);
    background: var(--tg-theme-bg-color, #fff);
    color: var(--tg-theme-text-color, #000);
    font-size: 15px;
    font-family: inherit;
    margin-bottom: 8px;
}

.setting input[type="range"] {
    width: 100%;
    margin-bottom: 8px;
    accent-color: var(--tg-theme-button-color, #2481cc);
}

.setting textarea { resize: vertical; min-height: 80px; }

.save-btn {
    background: var(--tg-theme-button-color, #2481cc);
    color: var(--tg-theme-button-text-color, #fff);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.save-btn:active { opacity: 0.7; }

/* ПЕРЕКЛЮЧАТЕЛИ */
.toggles {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--tg-theme-hint-color, #e0e0e0);
}

.toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    font-weight: 500;
}

.switch { position: relative; display: inline-block; width: 50px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider { background-color: var(--tg-theme-button-color, #34c759); }
input:checked + .slider:before { transform: translateX(22px); }

/* ПРЕСЕТЫ СТИЛЕЙ */
.presets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.preset-btn {
    padding: 12px 8px;
    background: var(--tg-theme-bg-color, #fff);
    border: 1px solid var(--tg-theme-hint-color, #ddd);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--tg-theme-text-color, #000);
    transition: all 0.15s;
}

.preset-btn:active {
    background: var(--tg-theme-button-color, #2481cc);
    color: white;
}

/* КНОПКИ ДЕЙСТВИЙ */
.actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.btn-primary {
    background: var(--tg-theme-button-color, #2481cc);
    color: var(--tg-theme-button-text-color, #fff);
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.btn-primary:active { opacity: 0.7; }

.btn-danger {
    background: rgba(255, 59, 48, 0.1);
    color: #ff3b30;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.btn-danger:active { background: rgba(255, 59, 48, 0.2); }

/* ПОСТЫ */
.posts-list { display: flex; flex-direction: column; gap: 10px; }

.post-card {
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 13px;
}

.post-card a {
    color: var(--tg-theme-link-color, #2481cc);
    text-decoration: none;
    word-break: break-all;
}

.post-time { color: var(--tg-theme-hint-color, #999); font-size: 11px; margin-top: 4px; }

/* МОДЕРАЦИЯ */
.moderation-list { display: flex; flex-direction: column; gap: 12px; }

.mod-card {
    background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    border-radius: 14px;
    padding: 16px;
}

.mod-text {
    font-size: 14px;
    margin-bottom: 12px;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.5;
}

.mod-buttons { display: flex; gap: 8px; }

.mod-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.mod-btn.approve { background: #34c759; color: white; }
.mod-btn.reject { background: rgba(255, 59, 48, 0.15); color: #ff3b30; }

/* НИЖНЯЯ НАВИГАЦИЯ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--tg-theme-bg-color, #fff);
    border-top: 1px solid var(--tg-theme-hint-color, #e0e0e0);
    display: flex;
    justify-content: space-around;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    z-index: 100;
}

.nav-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--tg-theme-hint-color, #999);
    font-size: 11px;
    font-weight: 600;
    transition: color 0.15s;
    position: relative;
}

.nav-btn.active { color: var(--tg-theme-link-color, #2481cc); }
.nav-btn .nav-icon { display: block; font-size: 22px; margin-bottom: 2px; }

.nav-badge {
    position: absolute;
    top: 0;
    right: 25%;
    background: #ff3b30;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
}

/* TOAST */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
    pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ВСПОМОГАТЕЛЬНОЕ */
.loader { text-align: center; padding: 40px; color: var(--tg-theme-hint-color, #999); }
.empty { text-align: center; padding: 60px 20px; color: var(--tg-theme-hint-color, #999); }
.empty .icon { font-size: 48px; margin-bottom: 12px; }

.theme-presets {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.theme-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--tg-theme-bg-color, #fff);
    border: 1px solid var(--tg-theme-hint-color, #ddd);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    width: 100%;
    color: var(--tg-theme-text-color, #000);
    font-family: inherit;
}

.theme-btn:active {
    background: var(--tg-theme-button-color, #2481cc);
    color: white;
    transform: scale(0.98);
}

.theme-btn.applied {
    border-color: #34c759;
    background: rgba(52, 199, 89, 0.1);
}

.theme-icon {
    font-size: 28px;
    flex-shrink: 0;
}

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

.theme-name {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 2px;
}

.theme-topics {
    font-size: 12px;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.theme-check {
    color: #34c759;
    font-size: 20px;
    flex-shrink: 0;
}