/* ============================================================
   TPP.CSS — Кабинет ТПП и Управление ТПП
   ============================================================ */

.tpp-page {
    background: #fff;
    padding-bottom: 10px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    table-layout: fixed;
    word-wrap: break-word;
}
/* Заголовок — компактный и серый */
.tpp-page-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 22px; /* Было 28 */
    font-weight: 600;
    color: #4b5563; /* Серый, не черный */
    margin-bottom: 20px;
    letter-spacing: 0.5px;
}

/* Табы — строгие, как кнопки */
.tpp-tabs {
    display: flex;
    gap: 24px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 24px;
}

.tpp-tab {
    background: none;
    border: none;
    padding: 10px 4px; /* Компактнее */
    font-family: 'Montserrat', sans-serif;
    font-weight: 500; /* Не жирный */
    font-size: 14px; /* Меньше шрифт */
    color: #6b7280; /* Серый */
    cursor: pointer;
    border-bottom: 2px solid transparent; /* Тонкая полоска */
    margin-bottom: -1px;
    transition: all .2s;
}

.tpp-tab:hover {
    color: #3ca5a9;
}

.tpp-tab.is-active {
    color: #3ca5a9; /* Фирменный цвет */
    border-bottom-color: #3ca5a9; /* Бирюзовая полоска вместо черной */
}

.tpp-tab-content {
    display: none;
}
.tpp-tab-content.is-active {
    display: block;
}

/* --- Таблицы --- */
.tpp-table {
    width: 100%;
    border-collapse: collapse; /* Убирает двойные рамки */
    margin-top: 16px;
    font-size: 14px;
    border: 1px solid var(--c-border); /* Внешняя рамка */
}

.tpp-table th,
.tpp-table td {
    padding: 12px;
    text-align: left;
    border: 1px solid var(--c-border); /* Внутренние рамки (сетка) */
}

.tpp-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--c-text-soft);
}

/* Убираем hover, чтобы строки не выделялись серым, если сетка */
.tpp-table tr:hover {
    background: transparent; 
}

/* --- Формы --- */
.tpp-form-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    margin-top: 16px;
    flex-wrap: wrap;
}
.tpp-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 200px;
}
.tpp-form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text);
}
.tpp-form-group input,
.tpp-form-group select {
    padding: 10px;
    border: 1.5px solid var(--c-border);
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    width: 100%;
    box-sizing: border-box;
}
.tpp-form-group input:focus,
.tpp-form-group select:focus {
    border-color: var(--c-accent);
}

/* --- Кнопки --- */
.tpp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 6px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s;
    border: none;
}
.tpp-btn--primary {
    background: linear-gradient(135deg, #67c9cc, #3ca5a9);
    color: #fff;
    box-shadow: 0 4px 12px rgba(60,165,169,.2);
}
.tpp-btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(60,165,169,.3);
}
.tpp-btn--secondary {
    background: #fff;
    color: var(--c-accent);
    border: 2px solid var(--c-accent);
}
.tpp-btn--secondary:hover {
    background: var(--c-accent);
    color: #3ca5a9;
}
.tpp-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

/* --- Кабинет ТПП (Сетка) --- */
.tpp-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 32px;
    align-items: start;
}
@media (max-width: 768px) {
    .tpp-layout {
        grid-template-columns: 1fr;
    }
}

.tpp-sidebar {
    background: var(--c-bg-soft);
    padding: 24px;
    border-radius: 12px;
    height: fit-content;
}
.tpp-sidebar h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 4px 0;
    color: var(--c-text);
}
.tpp-sidebar p {
    font-size: 13px;
    color: var(--c-text-mute);
    margin-bottom: 20px;
}
.tpp-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.tpp-menu-link {
    display: block;
    padding: 10px 14px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--c-text);
    font-weight: 600;
    font-size: 14px;
    transition: background .2s;
}
.tpp-menu-link:hover {
    background: #fff;
    color: var(--c-accent);
}
.tpp-menu-link.is-active {
    background: #fff;
    color: var(--c-accent);
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
}

/* --- Статистика --- */
.tpp-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 16px;
}
@media (max-width: 600px) {
    .tpp-stats-grid {
        grid-template-columns: 1fr;
    }
}
.tpp-stat-card {
    background: var(--c-bg-soft);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--c-border);
    text-align: center;
}
.tpp-stat-card div {
    font-size: 13px;
    color: var(--c-text-mute);
    margin-bottom: 8px;
}
.tpp-stat-card strong {
    font-family: 'Montserrat', sans-serif;
    font-size: 22px;
    color: var(--c-accent-dark);
}

/* --- Статусы --- */
.tpp-status {
    display: none;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-top: 12px;
}
.tpp-status--success {
    display: block;
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}
.tpp-status--error {
    display: block;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

/* --- Модалка --- */
.tpp-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw; /* Строго на весь экран */
    height: 100vh;
    z-index: 99999;
    display: flex;
    align-items: center;     /* Центрируем по вертикали */
    justify-content: center; /* Центрируем по горизонтали */
    background: rgba(0,0,0,0.6);
    box-sizing: border-box;
}
.tpp-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(4px);
}

.tpp-modal__content {
    position: relative;
    background: #fff;
    border-radius: 14px;
    padding: 28px;
    width: 100%;
    max-width: 480px; /* Ограничитель ширины */
    max-height: 90vh;
    overflow-y: auto; /* Вертикальный скролл, если форма длинная */
    overflow-x: hidden; /* Убираем горизонтальный скролл! */
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    z-index: 2;
    box-sizing: border-box; /* Чтобы padding не увеличивал ширину */
    margin: 16px; /* Отступы от краев экрана на мобилке */
}
.tpp-modal__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,.06);
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tpp-modal__content h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 20px;
    margin: 0 0 20px 0;
    color: var(--c-text);
}

.tpp-table th,
.tpp-table td {
    border: 1px solid var(--c-border); /* Добавили рамку со всех сторон */
    padding: 10px 14px; /* Чуть уменьшили отступ для сетки */
}
.tpp-table th {
    background: #f8fafc;
    color: var(--c-text-soft);
    font-weight: 600;
}

.tpp-table {
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden; /* Скрывает углы у ячеек */
    border: 1px solid var(--c-border);
}

/* Исправление ховера для кнопок в таблице */
.tpp-table .tpp-btn--secondary:hover {
    background: var(--c-accent) !important;
    color: rgba(60,165,169,.1);
    border-color: var(--c-accent) !important;
}
.tpp-table .tpp-btn--secondary:hover .om-icon {
    stroke: rgba(60,165,169,.1);
}

/* Красивая кнопка "Отвязать" */
.tpp-btn--danger-outline {
    background: transparent;
    color: #ef4444;
    border: 1px solid #ef4444;
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    transition: all .2s;
}
.tpp-btn--danger-outline:hover {
    background: #ef4444;
    color: #fff;
}

/* Карточки сотрудников */
.tpp-staff-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.tpp-staff-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--c-bg-soft);
    border: 1px solid var(--c-border);
    padding: 16px;
    border-radius: 10px;
}
.tpp-staff-card__name {
    font-weight: 700;
    font-size: 15px;
    color: var(--c-text);
    margin-bottom: 4px;
}
.tpp-staff-card__role {
    font-size: 12px;
    color: var(--c-accent);
    font-weight: 600;
    margin-bottom: 6px;
}
.tpp-staff-card__stats {
    font-size: 12px;
    color: var(--c-text-mute);
}

/* Блоки офисов */
.tpp-offices-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 32px;
}
.tpp-office-block {
    border: 1px solid var(--c-border);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}
.tpp-office-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 24px;
    background: #f8fafc;
    border-bottom: 1px solid var(--c-border);
}
.tpp-office-info h3 {
    font-family: 'Montserrat', sans-serif;
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 4px 0;
    color: var(--c-text);
}
.tpp-office-address {
    font-size: 13px;
    color: var(--c-text-mute);
    margin-bottom: 12px;
}
.tpp-office-contacts {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: var(--c-text-soft);
    align-items: center;
}
.tpp-office-contacts span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.tpp-office-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 20px;
}

.tpp-office-price {
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}
.tpp-office-price small {
    font-size: 11px;
    color: #6b7280;
    font-weight: 400;
}

/* Делаем кнопки одинаковой высоты и строгими */
.tpp-office-actions .tpp-btn {
    padding: 0 12px;
    height: 36px; /* Фиксированная высота */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    width: 170px; /* Одинаковая ширина */
}

.tpp-office-actions .tpp-btn--secondary {
    background: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
    box-shadow: none;
}

.tpp-office-actions .tpp-btn--secondary:hover {
    background: #f9fafb;
    color: #111827;
    border-color: #9ca3af;
}

/* Аккордеон сотрудников */
.tpp-office-staff-toggle {
    padding: 12px 24px;
    background: #f8fafc;
    border-top: 1px solid #e5e7eb;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--c-text-soft);
    transition: background 0.2s;
    user-select: none;
}

.tpp-office-staff-toggle:hover {
    background: #f1f5f9;
}

/* Треугольник вниз (пирамидка) */
.tpp-accordion-arrow {
    width: 0; 
    height: 0; 
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #9ca3af;
    transition: transform 0.3s ease;
}

.tpp-office-staff-toggle.is-open .tpp-accordion-arrow {
    transform: rotate(180deg);
}

/* Контейнер сотрудников */
.tpp-office-staff {
    padding: 20px 24px;
    border-top: 1px solid #e5e7eb;
}

/* Сотрудники внутри офиса */
.tpp-office-staff {
    padding: 5px 24px;
}
.tpp-office-staff__title {
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--c-text-soft);
    margin: 0 0 16px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tpp-offices-footer {
    padding-top: 24px;
    border-top: 2px dashed var(--c-border);
}

@media (max-width: 768px) {
    .tpp-office-header {
        flex-direction: column;
    }
    .tpp-office-actions {
        margin-left: 0;
        margin-top: 16px;
        align-items: flex-start;
    }
}

/* ИКОНКИ ДЕЙСТВИЙ В ТАБЛИЦЕ (КОРЗИНА И КАРАНДАШ) */
.company-item__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: transparent; /* Убрал серый фон по умолчанию */
    border: none !important; /* Убрал черную обводку */
    outline: none;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    text-decoration: none;
}
.company-item__btn:hover {
    transform: scale(1.15); /* Легкая анимация */
    background: rgba(60,165,169,.1); /* Легкий фон при наведении */
}
.company-item__btn--danger:hover {
    background: rgba(239,68,68,.1);
}
/* Ширина таблицы, чтобы влезали иконки */
.tpp-table {
    width: 100%;
    table-layout: fixed;
    word-wrap: break-word;
}

/* === АДАПТИВНАЯ ШАПКА ОФИСОВ === */
.tpp-offices-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap; /* Позволяет переносить элементы на мобильных */
    gap: 16px;
}

.tpp-offices-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
}

.tpp-offices-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
}

.tpp-search-form {
    display: flex;
    margin: 0;
    gap: 8px;
    align-items: center;
}

.tpp-search-input {
    padding: 9px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 6px;
    outline: none;
    font-size: 14px;
    width: 260px;
}

.tpp-search-select {
    padding: 9px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 6px;
    outline: none;
    font-size: 14px;
    max-width: 180px;
    background: #fff;
}

.tpp-search-btn, .tpp-add-btn {
    height: 40px;
}

.tpp-search-reset {
    font-size: 13px;
    color: #6b7280;
    text-decoration: underline;
}

/* --- МОБИЛЬНАЯ ВЕРСИЯ --- */
@media (max-width: 992px) {
    .tpp-offices-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .tpp-offices-toolbar {
        flex-direction: column;
        width: 100%;
        align-items: stretch;
    }

    .tpp-search-form {
        flex-direction: column;
        width: 100%;
        align-items: stretch;
    }

    .tpp-search-input, 
    .tpp-search-select, 
    .tpp-search-btn {
        width: 100%;
        max-width: 100%;
    }
    
    .tpp-add-btn {
        width: 100%;
        margin-top: 8px;
    }
    
    .tpp-search-reset {
        text-align: center;
        margin-top: 4px;
    }
}

/* ============================================================
   МОБИЛЬНЫЕ ОТСТУПЫ
   ============================================================ */
@media (max-width: 768px) {
    /* Добавляем отступы для всего контента внутри страницы */
    .tpp-page .container {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
    
    /* Чуть уменьшаем заголовок, чтобы влезал */
    .tpp-page-title {
        font-size: 20px !important;
    }
    
    /* Отступы для вкладок */
    .tpp-tabs {
        margin-left: -16px;
        margin-right: -16px;
        padding-left: 16px;
        padding-right: 16px;
        overflow-x: auto; /* Оставляем возможность скролла, если не влезет */
        white-space: nowrap; /* Чтобы табы не переносились на новую строку */
        
        /* СКРЫВАЕМ СКРОЛЛБАР */
        scrollbar-width: none; /* Для Firefox */
        -ms-overflow-style: none; /* Для IE и Edge */
    }
    
    /* Скрываем скроллбар для Chrome, Safari и Opera */
    .tpp-tabs::-webkit-scrollbar {
        display: none;
    }
}

/* --- МОБИЛЬНАЯ ВЕРСИЯ --- */
@media (max-width: 992px) {
    .tpp-offices-header {
        flex-direction: column;
        align-items: stretch; /* Растягиваем на всю ширину */
        gap: 16px;
    }
    
    .tpp-offices-toolbar {
        flex-direction: column;
        width: 100%;
        align-items: stretch;
        gap: 12px;
    }

    .tpp-search-form {
        flex-direction: column;
        width: 100%;
        align-items: stretch;
        padding: 0; /* Убираем лишние отступы */
        gap: 12px;
    }

    .tpp-search-input, 
    .tpp-search-select, 
    .tpp-search-btn {
        width: 100%;
        max-width: 100%;
        margin: 0; /* Убираем возможные внешние отступы */
    }
    
    .tpp-add-btn {
        width: 100%;
        margin-top: 0;
    }
}

/* Светофор для компаний */
.company-traffic-light {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 13px;
}
.company-traffic-light--green { color: #10b981; }
.company-traffic-light--yellow { color: #f59e0b; }
.company-traffic-light--red { color: #ef4444; }