* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #475569;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Auth Page */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 28px;
}

.auth-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 16px;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    background: var(--bg-input);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: none;
}

.error-message.show {
    display: block;
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: var(--bg-card);
    padding: 24px;
    border-right: 1px solid var(--border);
}

.sidebar-logo {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 32px;
    color: var(--primary);
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 8px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--bg-input);
    color: var(--text);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-name {
    font-weight: 500;
}

.user-tier {
    font-size: 12px;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.page-header p {
    color: var(--text-muted);
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

.stat-label {
    color: var(--text-muted);
    font-size: 14px;
}

/* Toggle Switch */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.toggle-row:last-child {
    border-bottom: none;
}

.toggle-info h4 {
    margin-bottom: 4px;
}

.toggle-info p {
    color: var(--text-muted);
    font-size: 14px;
}

.toggle {
    position: relative;
    width: 52px;
    height: 28px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-input);
    border-radius: 28px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
    background: var(--success);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* VK Connection */
.vk-status {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-input);
    border-radius: 8px;
}

.vk-status.connected {
    border-left: 4px solid var(--success);
}

.vk-status.disconnected {
    border-left: 4px solid var(--warning);
}

.vk-status-icon {
    width: 48px;
    height: 48px;
    background: #0077ff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
}

.vk-status-info {
    flex: 1;
}

.vk-status-info h4 {
    margin-bottom: 4px;
}

.vk-status-info p {
    color: var(--text-muted);
    font-size: 14px;
}

/* Subscription Badge */
.subscription-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.subscription-badge.basic {
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-muted);
}

.subscription-badge.advanced {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
}

.subscription-badge.full {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Вкладки */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tab {
    padding: 8px 16px;
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Панель инструментов над таблицей */
.toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
}

.toolbar input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Таблицы */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table .cell-actions {
    white-space: nowrap;
    text-align: right;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 13px;
    margin-left: 6px;
}

.empty-state {
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    color: var(--text-muted);
    font-size: 14px;
}

/* Поля настроек */
.field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.field-row:last-child {
    border-bottom: none;
}

.field-row label {
    color: var(--text);
    font-size: 14px;
}

.field-row input {
    width: 120px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
}

.field-row input:focus {
    outline: none;
    border-color: var(--primary);
}

.field-hint {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 12px;
}

/* Модальное окно */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-header h3 {
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text);
}

.modal textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

.modal textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

/* Всплывающее уведомление */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--success);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    z-index: 200;
    max-width: 380px;
}

.toast.error {
    border-left-color: var(--danger);
}

/* Поля вне модалок: форма предложения и выбор тарифа */
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Счётчик непроверенных предложений в меню */
.nav-badge {
    display: inline-block;
    min-width: 20px;
    margin-left: 8px;
    padding: 1px 6px;
    background: var(--danger);
    border-radius: 10px;
    color: #fff;
    font-size: 12px;
    text-align: center;
}

/* Публичная страница отправки вопроса */
.public-page {
    max-width: 640px;
    margin: 0 auto;
    padding: 48px 20px;
}

.public-page h1 {
    margin-bottom: 8px;
}

.public-page .subtitle {
    color: var(--text-muted);
    margin-bottom: 28px;
}

/* Hidden */
.hidden {
    display: none !important;
}
