/* === ЦВЕТОВЫЕ ПЕРЕМЕННЫЕ === */
:root {
    --bg: #f8fafc;
    --card-bg: white;
    --text: #2d3748;
    --text-secondary: #4a5568;
    --border: #e2e8f0;
    --button-bg: #3182ce;
    --button-hover: #2c5282;
    --status-valid-bg: #f0fff4;
    --status-valid-text: #2f855a;
    --status-invalid-bg: #fff5f5;
    --status-invalid-text: #c53030;
    --tab-bg: #edf2f7;
    --tab-active-bg: #3182ce;
    --tab-active-text: white;
    --footer-bg: white;
    --loader-text: #3182ce;
}

:root.dark {
    --bg: #1a202c;
    --card-bg: #2d3748;
    --text: #e2e8f0;
    --text-secondary: #a0aec0;
    --border: #4a5568;
    --button-bg: #4299e1;
    --button-hover: #3182ce;
    --status-valid-bg: #2f3b34;
    --status-valid-text: #68d391;
    --status-invalid-bg: #4d3235;
    --status-invalid-text: #fc8181;
    --tab-bg: #2d3748;
    --tab-active-bg: #4299e1;
    --tab-active-text: white;
    --footer-bg: #2d3748;
    --loader-text: #63b3ed;
    --search-form-container: #2d3748;
}

/* ОБЩИЕ СТИЛИ */
body {
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    transition: background 0.3s, color 0.3s;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    padding-bottom: 80px; /* отступ под футбар */
}

h1 {
    text-align: center;
    color: var(--text);
    margin: 20px 0;
    font-size: 24px;
}

/* ТАБЫ */
.tabs {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.tab {
    padding: 10px 8px;
    background: var(--tab-bg);
    border-radius: 8px;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    text-align: center;
    flex: 1;
    min-width: 90px;
    max-width: 180px;
    box-sizing: border-box;
    color: var(--text);
    border: 1px solid rgba(0, 0, 0, 0.12);
}


@media (min-width: 768px) {
    .tab {
        flex: none;
        padding: 12px 14px;
        font-size: 15px;
    }
}

.tab.active {
    background: var(--tab-active-bg);
    color: var(--tab-active-text);
}

.tab:hover:not(.active) {
    background: var(--border);
}

/* СОДЕРЖИМОЕ */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ФОРМЫ */


.mode-row {
    width: 100%;
    margin-bottom: 12px;
}

.mode-row > label {
    font-weight: bold;
    margin-bottom: 6px;
    display: block;
    color: var(--text);
}

.mode-row > select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--card-bg);
    color: var(--text);
}

.date-number-row {
    display: flex;
    gap: 12px;
    width: 100%;
    margin-bottom: 16px;
}

.date-number-row > input:nth-child(1) {
    flex: 0 0 15%;
    min-width: 100px;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--card-bg);
    color: var(--text);
    text-align: center;
}

.date-number-row > input:nth-child(2) {
    flex: 1;
    min-width: 200px;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--card-bg);
    color: var(--text);
}

.simple-number-row {
    width: 100%;
    margin-bottom: 16px;
}

.simple-number-row > input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--card-bg);
    color: var(--text);
    box-sizing: border-box;
}

/* КНОПКА */
.search-btn {
    min-width: 220px;
    padding: 12px 24px;
    background: var(--button-bg);
    color: white;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.search-btn:hover:not(:disabled) {
    background: var(--button-hover);
}

.search-btn:disabled {
    background: #a0aec0;
    cursor: not-allowed;
}

/* ЗАГРУЗКА */
.loader {
    text-align: center;
    margin: 15px 0;
    font-weight: bold;
    color: var(--loader-text);
    min-height: 24px;
}

.loader.htmx-request {
    display: block;
}

/* РЕЗУЛЬТАТЫ */
.results {
    margin-top: 20px;
}

.result-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.doc-number {
    font-size: 18px;
    font-weight: bold;
    color: var(--text);
    word-break: break-word;
    min-width: 0;
}

.country-code {
    font-size: 16px;
    font-weight: bold;
    color: var(--button-bg);
    background: var(--status-valid-bg);
    padding: 2px 10px;
    border-radius: 6px;
    white-space: nowrap;
}

.registry {
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 12px;
}

.period-status {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.period {
    color: var(--text);
    font-weight: 500;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: bold;
    display: inline-block;
    white-space: nowrap;
}

.status-valid {
    background: var(--status-valid-bg);
    color: var(--status-valid-text);
}

.status-invalid {
    background: var(--status-invalid-bg);
    color: var(--status-invalid-text);
}

.applicant {
    color: var(--text);
    font-weight: 500;
}

.error {
    color: var(--status-invalid-text);
    font-weight: bold;
    margin-top: 15px;
}

.info-text {
    color: var(--text);
    font-weight: bold;
    margin-bottom: 8px;
}

.info-sub {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 10px;
}

/* === ИСТОРИЯ ПОИСКА === */
.search-history {
    width: 100%;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.history-header h3 {
    font-size: 16px;
    color: var(--text);
    margin: 0;
}

.clear-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.clear-btn:hover {
    background: var(--status-valid-bg);
    color: var(--status-invalid-text);
}

.history-empty {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 10px 0;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--status-valid-bg);
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.history-item:hover {
    background: #ebf8ff;
}

.history-query {
    font-weight: 500;
    color: var(--text);
    word-break: break-word;
}

.history-date {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
}

/* === FOOTER BAR === */
.footer-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--footer-bg);
    padding: 10px 20px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    box-sizing: border-box;
}

.footer-left,
.footer-right {
    display: flex;
    align-items: center;
    min-width: 0;
}

/* Кнопка "Переключить тему" */
.theme-toggle-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s, color 0.2s;
}

.theme-toggle-btn:hover {
    background: var(--button-bg);
    color: white;
}

/* Кнопка истории — по центру ВСЕГО ЭКРАНА */
.center-btn {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
}

/* Кнопка "История поиска" */
.history-toggle-btn {
    background: var(--button-bg);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.history-toggle-btn:hover {
    background: var(--button-hover);
}

/* Версия */
.version-label {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
    text-align: right;
}

/* === MODAL === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    color: var(--text);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-close:hover {
    color: var(--status-invalid-text);
}

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
    color: var(--text);
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    text-align: right;
}

.clear-history-btn {
    background: var(--status-invalid-text);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
}

.clear-history-btn:hover {
    background: #c53030;
}

/* Элемент истории внутри модального окна */
.modal-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.modal-history-item:hover {
    background: var(--status-valid-bg);
}

.modal-history-query {
    font-weight: 500;
    color: var(--text);
    word-break: break-word;
    text-align: left;
}

.modal-history-registry {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
    text-align: right;
}

/* ФЛАГИ */
.tab-flag {
    width: 20px;
    height: 15px;
    vertical-align: middle;
    margin-left: 6px;
    border: 1px solid var(--border);
    border-radius: 2px;
}

/* === TOPBAR === */
:root {
    --topbar-bg: #f8f9fa;
    --topbar-text: #495057;
    --topbar-active: #0d6efd;
    --topbar-border: #dee2e6;
}

.dark {
    --topbar-bg: #212529;
    --topbar-text: #adb5bd;
    --topbar-active: #6ea8fe;
    --topbar-border: #343a40;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    padding: 0.35rem 1.2rem;
    font-size: 0.78rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    line-height: 1.3;

    display: flex;
    align-items: center;
    justify-content: space-between;
}


.topbar-nav {
    display: flex;
    gap: 1.4rem;
    align-items: center;
    flex-wrap: wrap;
}

.topbar-link {
    color: var(--topbar-text);
    text-decoration: none;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: all 0.15s ease;
    font-weight: 500;
    white-space: nowrap;
}

.topbar-link:hover,
.topbar-link.active {
    color: var(--topbar-active);
    background-color: rgba(13, 110, 253, 0.08);
}

.dark .topbar-link:hover,
.dark .topbar-link.active {
    background-color: rgba(110, 168, 254, 0.12);
}
.topbar-inner {
    display: flex;
    align-items: center;
    width: 100%;
}

/* меню слева */
.topbar-nav {
    display: flex;
    gap: 1.4rem;
    align-items: center;
}

/* кнопка — ПРИЛИПАЕТ К ПРАВОМУ КРАЮ */
.topbar-theme-btn {
    margin-left: auto;
    font-size: 12px;
    padding: 6px 12px;
    white-space: nowrap;
}

/* === ЛЕВОЕ РАСПОЛОЖЕНИЕ КНОПКИ МАССОВОЙ ПРОВЕРКИ === */

/* Якорь — ТОЛЬКО форма */
.search-layout {
    position: relative;
}

.container {
    position: relative;
}

.search-section {
    position: relative;
}


/********************
/* Контейнер для отступа */
.search-mode-container {
    width: 100%;
    margin-bottom: 20px;
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    color: var(--text-secondary);
}

.drop-zone:hover {
    background: rgba(49, 130, 206, 0.05);
    border-color: var(--button-bg);
}

.mass-textarea {
    width: 100%;
    box-sizing: border-box; /* 🔴 ВАЖНО */
    min-height: 100px;
    max-height: 400px;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
}

.mass-textarea::first-line {
    text-indent: 0;
}

/* Контейнер-обертка для плотной стыковки */
.search-mode-wrapper {
    padding: 0 0px; /* выравнивание по краям */
    margin-bottom: -1px; /* «склейка» с нижним блоком */
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: flex-start;
}
.dark .segmented-glider {
    background: var(--button-bg);
}

/* Логика перемещения */
#multiple-global:checked ~ .segmented-glider {
    transform: translateX(100%);
}

/* Контейнер формы теперь не имеет верхних скруглений, если над ним переключатель */
.search-form {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
}
.search-form {
    padding: 20px;
}


/* единственный визуальный контейнер */
.search-form-container {
    background: #fff;
    border-radius: 14px;
    padding: 24px;
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.06),
        0 2px 6px rgba(0, 0, 0, 0.04);
}



/* Segmented control container */
.segmented-control {
    position: relative;
    display: flex;
    width: 100%;
    max-width: 100%;
    height: 32px;
    background-color: #e3e3e4;
    border-radius: 12px;
    padding: 4px;
    box-sizing: border-box;
    overflow: hidden;
}

/* Dark theme container */
.dark .segmented-control {
    background-color: #374151;
}

/* Hide radio buttons */
.segmented-control input {
    display: none;
}

/* Labels */
.segmented-control label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    z-index: 2;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    transition: color 0.2s ease;
    color: #475569; /* light theme inactive */
}

/* Dark theme inactive text */
.dark .segmented-control label {
    color: #8e8e93;
}

/* Active text (both themes) */
.segmented-control input:checked + label {
    color: #ffffff;
}

/* Glider */
.segmented-glider {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background-color: var(--button-bg);
    border-radius: 10px;
    transition: transform 0.25s ease;
    z-index: 1;
}

/* Move glider to second segment */
.segmented-control input:nth-of-type(2):checked ~ .segmented-glider {
    transform: translateX(100%);
}

/* позиционирование */
#single-global:checked ~ .segmented-glider,
#single-arm:checked ~ .segmented-glider,
#single-by:checked ~ .segmented-glider,
#single-kz:checked ~ .segmented-glider,
#single-kg:checked ~ .segmented-glider,
#single-eaeu:checked ~ .segmented-glider {
    transform: translateX(0%);
}

#multiple-global:checked ~ .segmented-glider,
#multiple-arm:checked ~ .segmented-glider,
#multiple-by:checked ~ .segmented-glider,
#multiple-kz:checked ~ .segmented-glider,
#multiple-kg:checked ~ .segmented-glider,
#multiple-eaeu:checked ~ .segmented-glider {
    transform: translateX(100%);
}

/* Убираем верхние скругления у формы для бесшовности */


/* Стили для массового ввода */
.mass-section {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}





/* === MULTIPLE RESULTS TABLE === */

.multi-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 12px;
}

.multi-table thead {
    background: var(--tab-bg);
}

.multi-table th,
.multi-table td {
    padding: 6px 8px;
    border: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.multi-table th {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.multi-table td {
    color: var(--text);
    line-height: 1.3;
}

.multi-table tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

.dark .multi-table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.04);
}

/* статус — компактно */
.multi-status-valid {
    color: var(--status-valid-text);
    font-weight: 600;
}

.multi-status-invalid {
    color: var(--status-invalid-text);
    font-weight: 600;
}

/* кнопка под таблицей */
.multi-actions {
    display: flex;
    gap: 12px;
    margin-top: 14px;
}

.multi-status-not-found {
    color: #e53e3e;
    font-weight: 600;
}


/* === PROGRESS BAR (современный стиль) === */
.progress-container {
    margin: 20px 0;
    padding: 16px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.progress-text {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: linear-gradient(90deg, var(--border) 0%, var(--border) 100%);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--button-bg) 0%, #4fd1c7 100%);
    border-radius: 4px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

/* Анимация полосы прогресса */
.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background-image: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.15) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.15) 75%,
        transparent 75%,
        transparent
    );
    background-size: 1rem 1rem;
    animation: progress-stripes 1s linear infinite;
}

@keyframes progress-stripes {
    0% {
        background-position-x: 1rem;
    }
}

/* Индикатор для одиночного поиска */
.single-search-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    margin: 20px 0;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(var(--button-bg-rgb), 0.2);
    border-top-color: var(--button-bg);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Для темной темы */
.dark .progress-bar {
    background: #2d3748;
}

.dark .progress-fill {
    background: linear-gradient(90deg, var(--button-bg) 0%, #38a169 100%);
}

.dark .single-search-indicator {
    background: #2d3748;
    border-color: #4a5568;
}


/* === СТИЛИ ДЛЯ ПОИСКОВОЙ ФОРМЫ В ТЕМНОЙ ТЕМЕ === */

/* Основной контейнер */
.search-form-container {
    background: #fff;
    border-radius: 14px;
    padding: 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.04);
    transition: background 0.3s, box-shadow 0.3s;
}

.dark .search-form-container {
    background: #2d3748;
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.3),
        0 2px 6px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.search-mode-wrapper {
    padding: 24px 24px 12px 24px; /* верх формы */
}

.search-form {
    padding: 0 24px 24px 24px;    /* сама форма */
}

.mass-section {
    padding: 0 24px 24px 24px;    /* массовый режим */
}
/* Элементы формы внутри контейнера */
.search-form-container input,
.search-form-container select,
.search-form-container textarea {
    background: var(--card-bg);
    border-color: var(--border);
    color: var(--text);
    transition: all 0.2s;
}

.dark .search-form-container input,
.dark .search-form-container select,
.dark .search-form-container textarea {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

.dark .search-form-container input:focus,
.dark .search-form-container select:focus,
.dark .search-form-container textarea:focus {
    border-color: var(--button-bg);
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
    background: #4b5563;
}

/* Placeholder для темной темы */
.dark .search-form-container input::placeholder,
.dark .search-form-container textarea::placeholder {
    color: #9ca3af;
    opacity: 0.7;
}



/* Заголовки и текст внутри контейнера */
.search-form-container .info-text,
.search-form-container .info-sub,
.search-form-container label,
.search-form-container .mode-row > label {
    color: var(--text);
}

.dark .search-form-container .info-text,
.dark .search-form-container .info-sub,
.dark .search-form-container label,
.dark .search-form-container .mode-row > label {
    color: #e5e7eb;
}

/* Кнопка поиска внутри контейнера */
.search-form-container .search-btn {
    background: var(--button-bg);
    color: white;
}

.dark .search-form-container .search-btn {
    background: #4299e1;
}

.dark .search-form-container .search-btn:hover:not(:disabled) {
    background: #3182ce;
}

/* Зона загрузки файлов */
.drop-zone {
    border-color: var(--border);
    color: var(--text-secondary);
    background: var(--card-bg);
}

.dark .drop-zone {
    border-color: #4b5563;
    color: #9ca3af;
    background: #374151;
}

.dark .drop-zone:hover {
    background: rgba(66, 153, 225, 0.1);
    border-color: #4299e1;
}

/* Textarea для массового ввода */
.mass-textarea {
    background: var(--card-bg);
    border-color: var(--border);
    color: var(--text);
}

.dark .mass-textarea {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

/* Спиннеры и индикаторы */
.htmx-indicator {
    color: var(--button-bg);
}

.dark .htmx-indicator {
    color: #63b3ed;
}

/* Радио-кнопки и чекбоксы */
.search-form-container input[type="radio"],
.search-form-container input[type="checkbox"] {
    accent-color: var(--button-bg);
}

.dark .search-form-container input[type="radio"],
.dark .search-form-container input[type="checkbox"] {
    accent-color: #4299e1;
}

/* Подсказки и хинты */
.search-form-container .hint {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 4px;
}

.dark .search-form-container .hint {
    color: #9ca3af;
}

/* Иконки внутри формы */
.search-form-container .icon {
    color: var(--text-secondary);
}

.dark .search-form-container .icon {
    color: #9ca3af;
}

/* Границы и разделители */
.search-form-container .divider {
    border-color: var(--border);
}

.dark .search-form-container .divider {
    border-color: #4b5563;
}

/* Адаптивные стили для мобильных */
@media (max-width: 768px) {
    .search-form-container {
        padding: 16px;
        border-radius: 12px;
    }

    .dark .search-form-container {
        background: #2d3748;
    }
}

/* Анимация при фокусе */
.search-form-container input:focus,
.search-form-container select:focus,
.search-form-container textarea:focus {
    outline: none;
    transform: translateY(-1px);
    transition: transform 0.2s, box-shadow 0.2s;
}

.dark .search-form-container input:focus,
.dark .search-form-container select:focus,
.dark .search-form-container textarea:focus {
    box-shadow:
        0 0 0 3px rgba(66, 153, 225, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.1);
}

/*************************************************/

/* === СТИЛИ ДЛЯ КНОПКИ В СОСТОЯНИИ ЗАГРУЗКИ === */

/* Основные стили кнопки при загрузке */
.search-btn.loading,
.search-btn[disabled] {
    opacity: 0.7 !important;
    cursor: wait !important;
    background-color: #a0aec0 !important;
    transition: all 0.3s ease !important;
}

/* Для темной темы */
.dark .search-btn.loading,
.dark .search-btn[disabled] {
    background-color: #4a5568 !important;
}

/* Контейнер для индикатора загрузки внутри кнопки */
.search-btn .loading-content {
    display: none;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

/* Показываем индикатор при загрузке */
.search-btn.loading .loading-content,
.search-btn[disabled] .loading-content {
    display: inline-flex !important;
}

/* Скрываем обычный текст при загрузке */
.search-btn.loading .normal-text,
.search-btn[disabled] .normal-text {
    display: none !important;
}

/* Windows-стиль спиннера */
.windows-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: windowsSpin 1s linear infinite;
    flex-shrink: 0;
}

@keyframes windowsSpin {
    to { transform: rotate(360deg); }
}

/* Анимация точек для текста "Выполнение..." */
.loading-dots {
    position: relative;
}

.loading-dots::after {
    content: '';
    animation: loadingDots 1.5s infinite;
    position: absolute;
}

@keyframes loadingDots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* Для HTMX индикатора */
.search-btn .htmx-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

/* Когда HTMX делает запрос, показываем индикатор */
.search-btn.htmx-request .htmx-indicator {
    display: inline-flex !important;
}

/* Скрываем обычный текст при HTMX запросе */
.search-btn.htmx-request .normal-text {
    display: none !important;
}

/* Плавный переход между состояниями */
.search-btn {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Эффект при наведении на обычную кнопку */
.search-btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(49, 130, 206, 0.2);
}

.dark .search-btn:not(:disabled):hover {
    box-shadow: 0 4px 12px rgba(66, 153, 225, 0.2);
}

/* Эффект при нажатии */
.search-btn:not(:disabled):active {
    transform: translateY(0);
    transition: transform 0.1s;
}

/* === СТИЛИ ДЛЯ КНОПОК В СОСТОЯНИИ ЗАГРУЗКИ === */

/* Контейнеры для текста кнопки */
.search-btn .btn-normal-text {
    display: inline;
}

.search-btn .btn-loading-text {
    display: none;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

/* Кнопка в состоянии загрузки */
.search-btn.loading {
    opacity: 0.7 !important;
    background-color: #a0aec0 !important;
    cursor: wait !important;
    transition: all 0.3s ease !important;
}

.search-btn.loading .btn-normal-text {
    display: none;
}

.search-btn.loading .btn-loading-text {
    display: inline-flex;
}

/* Для темной темы */
.dark .search-btn.loading {
    background-color: #4a5568 !important;
}

/* Windows-стиль спиннера */
.windows-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Анимация точек для текста "Выполнение..." */
.loading-dots {
    position: relative;
}

.loading-dots::after {
    content: '';
    animation: loadingDots 1.5s infinite;
    position: absolute;
    right: -20px;
}

@keyframes loadingDots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* === СТИЛИ ДЛЯ DRAG & DROP === */

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    color: var(--text-secondary);
    background: var(--card-bg);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
}

.drop-zone:hover {
    border-color: var(--button-bg);
    background: rgba(49, 130, 206, 0.05);
}

.drop-zone.dragover {
    border-color: var(--button-bg) !important;
    background: rgba(49, 130, 206, 0.1) !important;
    border-style: solid;
}

.drop-zone.success {
    border-color: #48bb78 !important;
    background: rgba(72, 187, 120, 0.1) !important;
}

.drop-zone.error {
    border-color: #f56565 !important;
    background: rgba(245, 101, 101, 0.1) !important;
}

.drop-zone-text {
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.drop-zone-text.success {
    color: #48bb78 !important;
    font-weight: 600;
}

.drop-zone-text.error {
    color: #f56565 !important;
    font-weight: 600;
}

.drop-zone-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

/* Информация о файле */
.file-info {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
}

.file-info-size {
    background: var(--border);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
}

/* === MULTIPLE SEARCH – TABLE STYLE (INTEGRATED) === */

.multi-result {
    padding: 0;
}

.multi-table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
}

.multi-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    min-width: 900px;
}

/* header */
.multi-table thead th {
    position: sticky;
    top: 0;
    background: var(--tab-bg);
    color: var(--text);
    font-weight: 600;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

/* body cells */
.multi-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    color: var(--text);
    line-height: 1.4;
}

/* zebra */
.multi-table tbody tr:nth-child(even) {
    background: rgba(0,0,0,0.02);
}

.dark .multi-table tbody tr:nth-child(even) {
    background: rgba(255,255,255,0.04);
}

/* hover */
.multi-table tbody tr:hover {
    background: rgba(49,130,206,0.08);
}

/* first / last column radius */
.multi-table thead th:first-child {
    border-top-left-radius: 12px;
}
.multi-table thead th:last-child {
    border-top-right-radius: 12px;
}

/* status */
.multi-table .status-valid {
    color: var(--status-valid-text);
    font-weight: 600;
}

.multi-table .status-invalid {
    color: var(--status-invalid-text);
    font-weight: 600;
}

/* compact columns */
.multi-col-country {
    width: 60px;
    text-align: center;
    font-weight: bold;
}

.multi-col-date {
    width: 110px;
    white-space: nowrap;
}

.multi-col-status {
    width: 120px;
    white-space: nowrap;
}
.multi-summary {
    position: sticky;
    top: 58px; /* под topbar */
    z-index: 5;
    background: var(--card-bg);
    padding: 10px 14px;
    margin-bottom: 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.multi-table-wrapper {
    max-height: 420px;
    overflow: auto;
    border-radius: 10px;
}

.multi-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--tab-bg);
}
.multi-table tr.status-invalid {
    background: rgba(245, 101, 101, 0.08);
}

.dark .multi-table tr.status-invalid {
    background: rgba(245, 101, 101, 0.15);
}
.multi-table tr.status-invalid {
    background: var(--status-invalid-bg);
}



/******************************************************************************/
/***********************************TNVED**************************************/
/******************************************************************************/
.tnved-suggestions {
    margin-top: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--card-bg);
    display: none;
}

.tnved-suggestion {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

.tnved-suggestion:last-child {
    border-bottom: none;
}

.tnved-suggestion:hover {
    background: rgba(49,130,206,0.08);
}
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.card-types {
    margin-top: 12px;
}

.card-types ul {
    margin: 6px 0 0;
    padding-left: 18px;
}

.card-types li {
    font-size: 13px;
    line-height: 1.4;
}
.tnved-suggestion mark {
    background: rgba(49, 130, 206, 0.2);
    color: inherit;
    padding: 0 2px;
    border-radius: 3px;
}
.info-text a {
    color: var(--button-bg);
    font-weight: 600;
    text-decoration: none;
}

.info-text a:hover {
    text-decoration: underline;
}
/* ===== TNVED INPUT ===== */

.tnved-input-wrapper {
    position: relative;
    width: 100%;
}

#tnved-input {
    width: 100%;
    height: 48px;
    padding: 0 44px 0 14px; /* место под крестик */
    font-size: 18px;
    font-weight: 500;
    border-radius: 10px;
    border: 2px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#tnved-input::placeholder {
    font-size: 15px;
    color: var(--text-secondary);
}

#tnved-input:focus {
    outline: none;
    border-color: var(--button-bg);
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.15);
}

/* Тёмная тема */
.dark #tnved-input {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

.dark #tnved-input:focus {
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.25);
}

/* Кнопка очистки */
.tnved-clear-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.tnved-clear-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text);
}

.dark .tnved-clear-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Показываем крестик, когда есть текст */
.tnved-input-wrapper.has-value .tnved-clear-btn {
    display: flex;
}

/* ===== TNVED CARD ===== */

.tnved-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.45;
}

.tnved-row {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.tnved-row:last-child {
    border-bottom: none;
}

.tnved-main {
    font-weight: 500;
    padding: 14px 16px;
    margin-bottom: 12px;
    background: rgb(143 215 255);
    border-radius: 0px;
    font-size: 20px;
    line-height: 1.4;
}
.dark .tnved-main {
    background: rgb(42 128 175);
}
.tnved-code {
    font-weight: 700;
    margin-right: 6px;
}

.tnved-title {
    font-weight: 500;
}
.tnved-cols-3,
.tnved-cols-2 {
    display: grid;
    gap: 12px;
}

.tnved-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.tnved-cols-2 {
    grid-template-columns: 2fr 1fr;
}

/* Адаптив */
@media (max-width: 768px) {
    .tnved-cols-3,
    .tnved-cols-2 {
        grid-template-columns: 1fr;
    }
}
.tg-cell {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 4px; /* 🔴 ключевой момент */
}

.tg-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

/* Тёмная тема — повышаем контраст */
.dark .tg-icon {
    filter: brightness(1.4) contrast(1.25);
}

/* Заголовки колонок ТГ */
.tnved-cols-header {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

/* Строка одной ТГ */
.tnved-group-row {
    padding: 12px 8px;
    border-bottom: 1px dashed var(--border);
}

/* Последнюю линию можно убрать */
.tnved-group-row:last-child {
    border-bottom: none;
}

/* Ячейка ТГ с иконкой */


/* SVG */
.tg-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

/* Значения — акцент */
.tnved-group-row > div {
    font-size: 14px;
    color: var(--text);
}
/* Блок с типами карточек */
.tnved-meta {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.02);
    border-radius: 0px;
    padding: 16px;
}

.dark .tnved-meta {
    background: rgba(255, 255, 255, 0.04);
}
/* ===== Типы карточек ===== */

.tnved-types-title {
    margin-bottom: 10px;
}

.tnved-types-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px 16px;
    margin-bottom: 5px;
}

.card-type {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

/* Иконки типов карточек */
.card-type img {
    width: 22px;
    height: 22px;
}

/* Тёмная тема — делаем заметнее */
.dark .card-type img {
    filter: brightness(1.35) contrast(1.25);
}




/* Блок типа КТ */
.tnved-multi-type {
    border-top: 1px solid var(--border);
    padding-top: 10px;
    font-size: 14px;
}
/* ✅ Единица товара — насыщенный синий */
.card-type-unit_regular img {
    filter: brightness(1.3) contrast(1.4) sepia(1)
            hue-rotate(200deg) saturate(2);
}

/* 📦 Групповая упаковка — ОСТАВЛЯЕМ как есть (она тебе нравится) */
.card-type-unit_pack img {
    filter: none;
}

/* 🎁 Набор — зелёный */
.card-type-unit_set img {
    filter: brightness(1.3) contrast(1.4) sepia(1)
            hue-rotate(90deg) saturate(2);
}

/* 🛠 Техническая карточка — оранжевый */
.card-type-unit_tech img {
    filter: brightness(1.3) contrast(1.4) sepia(1)
            hue-rotate(20deg) saturate(2);
}

/* ===== OKPD2 BLOCK ===== */

.tnved-okpd2 {
    border-top: 1px solid var(--border);
}

/* Строка-раскрытие */
.okpd2-summary {
    list-style: none;
    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 16px;
    width: 100%;

    font-size: 13px;
    font-weight: 600;

    color: #0d95fc;
    background: var(--card-bg);

    transition: background 0.15s;
}

/* убираем стандартную стрелку браузера */


.okpd2-summary:hover {
    background: rgba(0, 0, 0, 0.04);
}

.dark .okpd2-summary:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* стрелка */
.okpd2-chevron {
    margin-left: 12px;
    font-size: 18px;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

/* поворот стрелки */
.okpd2-root[open] .okpd2-chevron {
    transform: rotate(180deg);
}

/* Контент */
.okpd2-content {
    padding: 12px 16px 8px 16px;
}

/* Группы ОКПД2 */
.okpd2-group {
    margin-bottom: 12px;
}

.okpd2-group > summary {
    cursor: pointer;
    font-weight: 500;
    padding: 6px 0;
}

.okpd2-group ul {
    margin: 6px 0 0 18px;
}


/* ===== TNVED PDF LINK ===== */

.tnved-pdf-link {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed var(--border);

    display: flex;
    align-items: center;
    gap: 8px;

    font-size: 14px;
}

.tnved-pdf-link a {
    color: var(--button-bg);
    font-weight: 500;
    text-decoration: none;
}

.tnved-pdf-link a:hover {
    text-decoration: underline;
}

/* Иконка */
.tnved-pdf-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.8;
}
/* ===== Section labels (как заголовки колонок) ===== */

.tnved-section-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}
.tnved-meta .tnved-section-label {
    margin-top: 6px;
}
