/* ===== Base / Reset ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-200: #bfdbfe;
    --blue-300: #93c5fd;
    --blue-400: #60a5fa;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --radius: 10px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .08);
}

html {
    font-size: 15px;
}

body {
    font-family: "Segoe UI", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--blue-50);
    color: var(--gray-800);
    min-height: 100vh;
}

/* ===== Header ===== */
header {
    background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
    color: #fff;
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(37, 99, 235, .3);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.logo b {
    font-weight: 700;
}

/* ===== Main ===== */
main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ===== Card ===== */
.search-card,
.results-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 1.75rem 2rem;
    margin-bottom: 1.25rem;
}

.search-card h2,
.results-card h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 1.25rem;
}

.results-card h2 span {
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--gray-500);
}

/* ===== Sources switcher ===== */
.sources-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--gray-100);
}
.sources-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.sources-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.sources-chips .chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    background: var(--blue-50);
    border: 1.5px solid var(--blue-200);
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    color: var(--gray-700);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.sources-chips .chip:hover { border-color: var(--blue-300); background: var(--blue-100); }
.sources-chips .chip:has(input:checked) {
    background: var(--blue-100);
    border-color: var(--blue-400);
    color: var(--blue-700);
}
.sources-chips .chip input { display: none; }

.th-source { width: 100px; }

.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
}
.source-badge.hh { background: #dbeafe; color: #1d4ed8; }
.source-badge.linkedin { background: #e0e7ff; color: #3730a3; }

/* ===== Search Form Layout ===== */
.search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.search-header h2 {
    margin-bottom: 0;
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Поиск + Навыки — чёткое разделение, checkbox привязан к полю */
.search-row-main {
    display: grid;
    grid-template-columns: 1fr minmax(200px, 320px);
    gap: 1.5rem;
    align-items: end;
}

.form-group-search {
    flex: 1;
}

.search-input-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-top: 0.4rem;
}

.search-input-row input {
    flex: 1;
    min-width: 0;
}

.cb-attached {
    flex-shrink: 0;
    white-space: nowrap;
    margin: 0;
}

.form-group-skills {
    min-width: 0;
}

.form-group-skills input {
    margin-top: 0.4rem;
}

/* Блок исключений */
.search-row-exclude {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--blue-50);
    border-radius: 8px;
    border: 1px solid var(--blue-100);
    flex-wrap: wrap;
}

.search-row-label {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.search-row-exclude input {
    flex: 1;
    min-width: 180px;
    padding: 0.5rem 0.85rem;
    border: 1.5px solid var(--blue-200);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--gray-800);
    background: #fff;
    outline: none;
}

.search-row-exclude input:focus {
    border-color: var(--blue-400);
    box-shadow: 0 0 0 2px rgba(96, 165, 250, .2);
}

/* Фильтры: опыт + регион/период/кол-во */
.search-row-filters {
    display: flex;
    align-items: flex-end;
    gap: 2rem;
    flex-wrap: wrap;
}

.form-group-experience {
    flex: 1;
    min-width: 280px;
}

.experience-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.4rem;
}

.experience-chips .chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    background: var(--blue-50);
    border: 1.5px solid var(--blue-200);
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    color: var(--gray-700);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.experience-chips .chip:hover {
    border-color: var(--blue-300);
    background: var(--blue-100);
}

.experience-chips .chip:has(input:checked) {
    background: var(--blue-100);
    border-color: var(--blue-400);
    color: var(--blue-700);
}

.experience-chips .chip input {
    accent-color: var(--blue-600);
    width: 16px;
    height: 16px;
    min-height: 16px;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
}

.experience-chips .chip span {
    font-weight: 400;
    text-transform: none;
}

.filters-inline {
    display: flex;
    gap: 1.25rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filters-inline .form-group {
    min-width: 0;
}

.filters-inline .form-group select {
    min-width: 130px;
}

.form-group-count {
    min-width: 0;
}

.count-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.4rem;
}

.count-input-wrap input {
    width: 80px;
}

.form-group-count .hint {
    margin: 0;
    font-size: 0.8rem;
}

/* ===== Form Grid (legacy / account) ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.25rem;
}

.full-width {
    grid-column: 1 / -1;
}

.form-group label:first-child {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Чипы опыта — отключаем наследование от label:first-child */
.form-group-experience .experience-chips .chip {
    display: inline-flex;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.88rem;
    color: var(--gray-700);
    margin-bottom: 0;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1.5px solid var(--blue-200);
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--gray-800);
    background: var(--blue-50);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--blue-400);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, .2);
}

.hint {
    font-size: 0.78rem;
    color: var(--gray-400);
    display: inline-block;
}

/* ===== Checkboxes ===== */
.exclude-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.4rem;
}

.exclude-row input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1.5px solid var(--blue-200);
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--gray-800);
    background: var(--blue-50);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.exclude-row input:focus {
    border-color: var(--blue-400);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, .2);
}

.checkbox-row,
.checkbox-col {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.5rem;
    align-items: center;
}

.checkbox-col {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
}

.cb-label {
    font-size: 0.82rem;
    color: var(--gray-500);
    font-weight: 500;
    margin-right: 0.25rem;
}

.cb {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--gray-700);
    user-select: none;
}

.cb input[type="checkbox"] {
    accent-color: var(--blue-500);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ===== Buttons ===== */
.actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.65rem 1.6rem;
    background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(37, 99, 235, .3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(37, 99, 235, .4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.2rem;
    background: #fff;
    color: var(--blue-600);
    border: 1.5px solid var(--blue-300);
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn-outline:hover {
    background: var(--blue-50);
    border-color: var(--blue-400);
}

.btn-sm {
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
}

.btn-outline:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Results ===== */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.results-header h2 {
    margin-bottom: 0;
}

.results-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-100);
    font-size: 0.9rem;
    color: var(--gray-500);
}

.pagination-buttons {
    display: flex;
    gap: 0.5rem;
}

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--blue-100);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

thead {
    background: var(--blue-100);
}

th {
    padding: 0.65rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    border-bottom: 2px solid var(--blue-200);
}

td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
    color: var(--gray-700);
}

tbody tr:hover {
    background: var(--blue-50);
}

.th-photo {
    width: 52px;
}

td img.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--blue-200);
}

.no-photo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--blue-100);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--blue-300);
    font-size: 1rem;
}

td a {
    color: var(--blue-600);
    text-decoration: none;
    font-weight: 500;
}

td a:hover {
    text-decoration: underline;
}

/* ===== Loader ===== */
.loader {
    text-align: center;
    padding: 3rem 0;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--blue-200);
    border-top-color: var(--blue-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 0.75rem;
}

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

.loader p {
    color: var(--gray-500);
    font-size: 0.95rem;
}

/* ===== Error ===== */
.error-box {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #b91c1c;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .search-row-main {
        grid-template-columns: 1fr;
    }
    .search-input-row {
        flex-direction: column;
        align-items: stretch;
    }
    .search-row-exclude {
        flex-direction: column;
        align-items: stretch;
    }
    .search-row-exclude input {
        min-width: 0;
    }
    .search-row-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    .form-group-experience {
        min-width: 0;
    }
    .filters-inline {
        flex-direction: column;
        align-items: stretch;
    }
    .filters-inline .form-group select {
        min-width: 0;
        width: 100%;
    }
    .count-input-wrap input {
        width: 100%;
    }
    .search-header {
        flex-direction: column;
        align-items: stretch;
    }
    .search-header .btn-primary {
        width: 100%;
        justify-content: center;
    }
    .results-pagination {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
        text-align: center;
    }
    .pagination-buttons {
        justify-content: center;
    }
    .search-card,
    .results-card {
        padding: 1.25rem;
    }
    main {
        padding: 1rem;
    }
}
