/* Общие стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #ffffff;
    color: #333333;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 0 15px;
}

/* Шапка */
.header {
    background-color: #f5f5f5;
    border-bottom: 2px solid #e0e0e0;
    padding: 15px 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.header-left {
    display: flex;
    align-items: center;
}

.header-user {
    display: flex;
    align-items: center;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.user-name {
    color: #2c3e50;
    font-weight: 600;
    font-size: 14px;
}

.login-link,
.logout-link {
    color: #2c3e50;
    text-decoration: none;
    font-size: 13px;
    padding: 4px 10px;
    border: 1px solid #2c3e50;
    border-radius: 4px;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.login-link:hover,
.logout-link:hover {
    background-color: #2c3e50;
    color: #ffffff;
}

.logo-placeholder,
.site-logo {
    width: 100px !important;
    height: 100px !important;
    min-width: 100px;
    min-height: 100px;
    max-width: 100px;
    max-height: 100px;
    object-fit: contain;
    margin-right: 15px;
    display: block;
}

.logo-placeholder {
    background-color: #d0d0d0;
    border: 1px solid #b0b0b0;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.site-title {
    font-size: 36px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.brand-link {
    text-decoration: none;
    color: inherit;
}

.brand-link:focus {
    outline: none;
}

.brand-link:focus .logo-placeholder,
.brand-link:focus .site-logo,
.brand-link:focus .site-title {
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.12);
    border-radius: 4px;
}

/* Основной контейнер */
.container {
    display: flex;
    flex: 1;
    width: 100%;
    margin: 0;
    padding: 0;
}

/* Боковое меню */
.sidebar {
    width: 250px;
    background-color: #f8f8f8;
    border-right: 1px solid #e0e0e0;
    padding: 20px 0;
    min-height: calc(100vh - 140px);
    flex-shrink: 0;
}

.menu {
    padding: 0 15px;
}

.menu-link {
    display: block;
    padding: 10px 12px;
    color: #2c3e50;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}

.menu-link:hover {
    background-color: #e8eaed;
    color: #1a252f;
}

.menu-link:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.25);
}

.menu-link--active {
    background-color: #e0e6ec;
    color: #1a252f;
}

/* Основной контент */
.main-content {
    flex: 1;
    padding: 30px 40px;
    background-color: #ffffff;
    min-height: calc(100vh - 140px);
}

/* Хлебные крошки */
.breadcrumbs {
    font-size: 12px;
    color: #666666;
    margin: 0 0 14px 0;
}

.breadcrumbs a {
    color: #2c3e50;
    text-decoration: none;
    border-bottom: 1px dotted rgba(44, 62, 80, 0.35);
}

.breadcrumbs a:hover {
    border-bottom-color: rgba(44, 62, 80, 0.7);
}

/* Приветственное сообщение */
.welcome-message {
    text-align: center;
    padding: 40px 20px 20px 20px;
}

.welcome-message h2 {
    font-size: 32px;
    font-weight: 500;
    color: #2c3e50;
    margin: 0;
}

/* Статистика */
.statistics {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.stat-item {
    background-color: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 15px;
}

.stat-item p {
    font-size: 16px;
    color: #333333;
    margin: 0;
}

.stat-item strong {
    font-size: 20px;
    color: #2c3e50;
    font-weight: 600;
}

/* Верхняя часть: ИНН и фильтр — два варианта поиска */
.home-search-blocks {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px 32px;
}

.inn-check-block {
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px 24px;
}

.inn-check-block h3 {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 12px 0;
}

.home-search-divider {
    text-align: center;
    margin: 24px 0;
    font-size: 15px;
    font-weight: 700;
    color: #2c3e50;
    position: relative;
}

.home-search-divider::before,
.home-search-divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: calc(50% - 2.5em);
    height: 3px;
    background: #2c3e50;
}

.home-search-divider::before {
    left: 0;
}

.home-search-divider::after {
    right: 0;
}

.inn-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.inn-input {
    flex: 1;
    min-width: 260px;
    max-width: 420px;
    padding: 10px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 16px;
    outline: none;
}

.inn-input:focus {
    border-color: #b0b0b0;
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.08);
}

.inn-button {
    padding: 10px 16px;
    border: 1px solid #2c3e50;
    background-color: #2c3e50;
    color: #ffffff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
}

.inn-button:hover {
    background-color: #243445;
    border-color: #243445;
}

/* Блок фильтра */
.filter-section {
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 24px 24px 28px;
    margin-top: 0;
}

.filter-section-title {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 20px 0;
}

.filter-fields {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.filter-actions {
    margin-top: 24px;
    padding-top: 4px;
}

.filter-apply-btn {
    padding: 10px 20px;
    border: 1px solid #2c3e50;
    background-color: #2c3e50;
    color: #ffffff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
}

.filter-apply-btn:hover {
    background-color: #243445;
    border-color: #243445;
}

.filter-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-hint {
    font-size: 13px;
    color: #6b7280;
    margin: 0 0 10px 0;
    line-height: 1.4;
}

.filter-row--financial .filter-financial-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
}

.filter-financial-label {
    font-size: 13px;
    font-weight: 500;
    color: #2c3e50;
    white-space: nowrap;
}

.filter-label {
    font-size: 14px;
    font-weight: 500;
    color: #2c3e50;
}

.filter-input {
    padding: 10px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 15px;
    outline: none;
    font-family: inherit;
}

.filter-input:focus {
    border-color: #2c3e50;
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.12);
}

.filter-input--text {
    max-width: 420px;
}

.filter-input--select {
    min-width: 200px;
    max-width: 320px;
    cursor: pointer;
    background-color: #fff;
}

.filter-input--number {
    width: 140px;
}

.filter-financial-compare-value {
    display: flex;
    align-items: center;
    gap: 16px;
}

.filter-radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    border: none;
}

.filter-value-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-radio-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
}

.filter-radio {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #2c3e50;
}

/* Страница результатов фильтра */
.filter-result-page {
    max-width: 900px;
}

.filter-result-confirm {
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 28px 32px;
    margin-top: 16px;
}

.filter-result-message {
    font-size: 16px;
    color: #2c3e50;
    margin: 0 0 20px 0;
}

.filter-result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.filter-result-continue-form {
    display: inline;
}

.filter-result-btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
}

.filter-result-btn--cancel {
    background: #fff;
    border-color: #d1d5db;
    color: #374151;
}

.filter-result-btn--cancel:hover {
    background: #f3f4f6;
}

.filter-result-btn--continue {
    background: #2c3e50;
    border-color: #2c3e50;
    color: #fff;
}

.filter-result-btn--continue:hover {
    background: #243445;
    border-color: #243445;
}

.filter-result-title {
    font-size: 22px;
    font-weight: 600;
    color: #2c3e50;
    margin: 16px 0 12px 0;
}

.filter-result-count {
    font-size: 14px;
    color: #6b7280;
    margin: 0 0 12px 0;
}

.filter-result-table {
    margin-top: 0;
}

.filter-result-empty,
.filter-result-error {
    margin: 16px 0;
    color: #374151;
}

.filter-result-error {
    color: #b91c1c;
}

.filter-result-back {
    margin-top: 20px;
}

.filter-result-back a {
    color: #2c3e50;
    text-decoration: none;
    border-bottom: 1px dotted rgba(44, 62, 80, 0.35);
}

.filter-result-back a:hover {
    border-bottom-color: rgba(44, 62, 80, 0.7);
}

/* Страница контрактов */
.contracts-page {
    width: 100%;
}

.contracts-page-title {
    font-size: 26px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 20px 0;
}

.contracts-filter {
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 20px;
}

.contracts-filter-fields {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.contracts-filter-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.contracts-filter-row--inline {
    flex-direction: row;
    align-items: center;
}

.contracts-filter-row--amount {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.contracts-filter-label,
.contracts-filter-amount-label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.contracts-filter-input {
    padding: 10px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
    max-width: 420px;
}

.contracts-filter-input:focus {
    border-color: #2c3e50;
    outline: none;
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.12);
}

.contracts-filter-input--number {
    width: 140px;
    max-width: none;
}

.contracts-filter-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.contracts-filter-checkbox {
    width: 18px;
    height: 18px;
}

.contracts-filter-radio-group {
    display: flex;
    flex-direction: row;
    gap: 16px;
    border: none;
    margin: 0;
    padding: 0;
}

.contracts-filter-radio-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
}

.contracts-filter-radio {
    width: 18px;
    height: 18px;
}

.contracts-filter-actions {
    margin-top: 8px;
}

.contracts-filter-btn {
    padding: 10px 20px;
    border: 1px solid #2c3e50;
    background-color: #2c3e50;
    color: #fff;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.contracts-filter-btn:hover {
    background-color: #243445;
    border-color: #243445;
}

.contracts-divider {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 24px 0;
}

.contracts-statistics {
    width: 100%;
    padding: 20px 0;
}

.contracts-stat-item {
    background-color: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 18px 20px;
    margin-bottom: 14px;
}

.contracts-stat-item p {
    margin: 0;
    font-size: 15px;
    color: #374151;
}

.contracts-results-title {
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 16px 0;
}

.contracts-results-table-wrap {
    overflow-x: auto;
}

.contracts-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.contracts-results-table th,
.contracts-results-table td {
    padding: 10px 14px;
    text-align: left;
    border: 1px solid #e5e7eb;
}

.contracts-results-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #374151;
}

.contracts-results-table tbody tr:hover {
    background-color: #f8f9fa;
}

.contracts-th-good-name,
.contracts-cell-good-name {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 320px;
}

.contracts-results-empty {
    color: #6b7280;
    font-size: 15px;
    margin: 16px 0;
}

/* Страница ИНН */
.inn-detail h2 {
    font-size: 28px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.inn-sections {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.inn-section {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

.inn-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 12px 16px;
    background-color: #f8f8f8;
    border-bottom: 1px solid #e0e0e0;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.inn-section-header .inn-section-title {
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
}

.inn-section-header .inn-section-more {
    margin: 0;
}

.inn-section-title {
    margin: 0;
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    background-color: #f8f8f8;
    border-bottom: 1px solid #e0e0e0;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.inn-section-title .inn-section-link {
    font-weight: 400;
    font-size: 14px;
    color: #2c3e50;
    text-decoration: none;
    border-bottom: 1px solid #2c3e50;
}

.inn-section-title .inn-section-link:hover {
    color: #1a252f;
}

.inn-section-body {
    padding: 14px 16px;
    font-size: 14px;
    color: #333333;
}

.inn-section-empty {
    color: #666666;
    margin: 0;
}

.inn-section-action {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.inn-section-action-btn {
    padding: 8px 14px;
    border: 1px solid #2c3e50;
    background-color: #2c3e50;
    color: #ffffff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.inn-section-action-btn:hover {
    background-color: #243445;
    border-color: #243445;
}

.inn-section-more {
    margin-top: 12px;
    margin-bottom: 0;
}

.inn-section-more a {
    color: #2c3e50;
    text-decoration: none;
    font-size: 14px;
    border-bottom: 1px solid #2c3e50;
}

.inn-section-more a:hover {
    color: #1a252f;
}

/* Детальная страница финансов */
.inn-finance-detail h2 {
    margin-bottom: 8px;
}

.inn-finance-inn {
    color: #666666;
    margin-bottom: 12px;
}

.inn-finance-back {
    color: #2c3e50;
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 24px;
    display: inline-block;
}

.inn-finance-back:hover {
    text-decoration: underline;
}

.inn-finance-section {
    margin-bottom: 32px;
}

.inn-finance-section .data-table {
    margin-top: 0;
}

.data-table .td-summa {
    text-align: right;
}

.arbitrage-instance-cell[title] {
    cursor: help;
}

.fssp-subject-cell[title] {
    cursor: help;
}

/* Жирная черта между группами кодов (смена первой цифры) на детальной странице финансов */
tr.finance-code-separator td {
    padding: 0;
    height: 0;
    border: none;
    border-top: 3px solid #2c3e50;
    line-height: 0;
    vertical-align: top;
}

tr.finance-code-separator {
    border: none;
}

/* Таблица данных */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 8px;
}

.data-table thead {
    background-color: #f8f8f8;
}

.data-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #e0e0e0;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e0e0e0;
    color: #333333;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background-color: #fafafa;
}

/* Главный вид деятельности на странице ОКВЭД */
.data-table tbody tr.okved-row-main td,
.data-table .okved-cell-main {
    font-weight: 700;
}

.kv-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kv-row {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 14px;
    align-items: start;
}

.kv-row--finance {
    grid-template-columns: 260px 16ch 1fr;
}

.kv-empty {
    /* третья колонка всегда пустая */
}

.kv-key {
    color: #2c3e50;
    font-weight: 600;
    font-size: 13px;
}

.kv-val {
    color: #333333;
    font-size: 13px;
    word-break: break-word;
}

.kv-val--right {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.kv-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 12px 0;
}

@media (max-width: 768px) {
    .kv-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .kv-row--finance {
        grid-template-columns: 1fr;
    }

    .kv-empty {
        display: none;
    }
}

/* Модальное окно (вместо системного alert) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 9999;
}

.modal-overlay.is-open {
    display: flex;
}

.modal {
    width: 100%;
    max-width: 520px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.modal-close {
    border: none;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #666666;
    padding: 0 4px;
}

.modal-close:hover {
    color: #2c3e50;
}

.modal-body {
    padding: 16px;
    font-size: 15px;
}

.modal-body--error {
    color: #b91c1c;
}

.modal-actions {
    padding: 0 16px 16px 16px;
    display: flex;
    justify-content: flex-end;
}

.modal-ok {
    padding: 10px 16px;
    border: 1px solid #2c3e50;
    background-color: #2c3e50;
    color: #ffffff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
}

.modal-ok:hover {
    background-color: #243445;
    border-color: #243445;
}

.modal-cancel {
    padding: 10px 16px;
    border: 1px solid #d0d0d0;
    background-color: #ffffff;
    color: #333333;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    margin-right: 10px;
}

.modal-cancel:hover {
    background-color: #f5f5f5;
    border-color: #b0b0b0;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Футер */
.footer {
    background-color: #f5f5f5;
    border-top: 1px solid #e0e0e0;
    padding: 15px 30px;
    text-align: center;
    margin-top: auto;
}

.footer p {
    color: #666666;
    font-size: 14px;
    margin: 0;
}

/* Страница авторизации */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 40px 20px;
}

.login-box {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.login-box h2 {
    color: #2c3e50;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 30px;
    text-align: center;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    color: #2c3e50;
    font-weight: 600;
    font-size: 14px;
}

.form-input {
    padding: 10px 14px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 15px;
    color: #333333;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #2c3e50;
}

.form-input::placeholder {
    color: #999999;
}

.login-button {
    padding: 12px 24px;
    background-color: #2c3e50;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 10px;
}

.login-button:hover {
    background-color: #243445;
}

.form-errors,
.field-errors {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.error-message {
    color: #d32f2f;
    font-size: 13px;
    margin-top: 4px;
}

/* Адаптивность */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        min-height: auto;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .header-content {
        padding: 10px 15px;
    }
    
    .site-title {
        font-size: 30px;
    }
}
