/**
 * CRM: стили для страницы входа и панели.
 * Шрифт: Inter. Минималистичный адаптивный интерфейс.
 */

/* --- Базовые переменные и сброс --- */
:root {
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.1);
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    margin: 0;
    min-height: 100vh;
}

/* --- Страница входа --- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
}

.login-title {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.login-subtitle {
    margin: 0 0 1.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.login-form label {
    display: block;
    margin-bottom: 1rem;
}

.login-form label span {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.login-form input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 1rem;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-block {
    width: 100%;
    margin-top: 0.5rem;
}

.login-hint {
    margin: 1rem 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

/* --- Алерты --- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

/* --- Кнопки --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, color .15s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: var(--bg);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.85rem;
}

.btn-sm + .btn-sm {
    margin-left: 0.35rem;
}

/* --- Dashboard --- */
.dashboard {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.dashboard-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.header-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
}

.header-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.nav-tab {
    padding: 0.5rem 0.85rem;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .15s, color .15s;
}

.nav-tab:hover {
    color: var(--text);
    background: var(--bg);
}

.nav-tab.active {
    color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
}

.header-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-user span {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* --- Основной контент --- */
.dashboard-main {
    flex: 1;
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.panel {
    display: none;
}

.panel.active {
    display: block;
}

.panel-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 600;
}

/* --- Таблицы --- */
.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg);
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-active { background: #dbeafe; color: #1d4ed8; }
.badge-won { background: #dcfce7; color: #166534; }
.badge-lost { background: #fee2e2; color: #991b1b; }
.badge-task-pending { background: #fef3c7; color: #92400e; }
.badge-task-in_progress { background: #dbeafe; color: #1d4ed8; }
.badge-task-done { background: #dcfce7; color: #166534; }
.badge-priority-low { background: #f1f5f9; color: #64748b; }
.badge-priority-medium { background: #dbeafe; color: #1d4ed8; }
.badge-priority-high { background: #fee2e2; color: #991b1b; }

.cell-notes { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

/* --- Формы в модалке --- */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="url"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.95rem;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* --- Модальное окно --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 0.25rem;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 1.25rem;
}

.modal-body .btn {
    margin-top: 0.5rem;
}

/* --- Аналитика --- */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.analytics-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.analytics-card h3 {
    margin: 0 0 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
}

.analytics-card canvas {
    max-height: 220px;
}

/* --- Интеграции --- */
.integrations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.integration-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.integration-card h3 {
    margin: 0 0 0.35rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.integration-card p {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.integration-card .btn {
    margin-top: 0.5rem;
}

.integration-actions {
    margin-top: 1rem;
}

.integration-note {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* --- Адаптив --- */
/* --- Онбординг --- */
.onboarding-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.onboarding-overlay.hidden {
    display: none;
}
.onboarding-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}
.onboarding-card {
    position: relative;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 100%;
    padding: 1.75rem;
}
.onboarding-content h2 {
    margin: 0 0 0.75rem;
    font-size: 1.35rem;
    font-weight: 600;
}
.onboarding-content p {
    margin: 0 0 1.25rem;
    color: var(--text-muted);
    line-height: 1.6;
}
.onboarding-steps {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.25rem;
}
.onboarding-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.2s;
}
.onboarding-dot.active {
    background: var(--primary);
    transform: scale(1.2);
}
.onboarding-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-nav {
        width: 100%;
    }

    .header-user {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem 0.65rem;
        font-size: 0.85rem;
    }
}
