/* Раздел ЛК «Честный знак (HoReCa)» (/crpt*): современный UI в дизайн-токенах МАНГО ЛК.
   Подключается напрямую в views/layouts/lk.hbs. */

.lk-crpt {
    --crpt-radius: 16px;
    --crpt-radius-sm: 12px;
    --crpt-border: rgba(26, 26, 26, 0.08);
    --crpt-shadow: 0 1px 2px rgba(26, 26, 26, 0.04), 0 6px 20px rgba(26, 26, 26, 0.05);
    --crpt-ring: 0 0 0 3px rgba(239, 127, 26, 0.2);
    max-width: 1360px;
    margin: 0 auto;
    padding: 16px 12px 32px;
    color: var(--mp-text);
}

@media (min-width: 768px) {
    .lk-crpt {
        padding: 20px 20px 40px;
    }
}

.lk-crpt .num,
.lk-crpt .font-monospace {
    font-variant-numeric: tabular-nums;
}

/* ——— Шапка раздела ——— */

.lk-crpt__header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.lk-crpt__title-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.lk-crpt__title {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.lk-crpt__pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    border: 1px solid var(--crpt-border);
    background: var(--mp-surface);
    color: var(--mp-gray-600);
}

.lk-crpt__pill--prod {
    background: #e9f7ef;
    border-color: rgba(35, 149, 90, 0.25);
    color: #166534;
}

.lk-crpt__pill--sandbox {
    background: #fff4e5;
    border-color: rgba(239, 127, 26, 0.35);
    color: #9a4a05;
}

.lk-crpt__snapshot-pill {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--mp-surface);
    border: 1px solid var(--crpt-border);
    box-shadow: 0 1px 2px rgba(26, 26, 26, 0.04);
    font-size: 0.82rem;
    color: var(--mp-muted);
}

.lk-crpt__snapshot-pill strong {
    color: var(--mp-text);
    font-weight: 700;
}

/* ——— Панель True API / УКЭП ——— */

.lk-crpt__card {
    background: var(--mp-surface);
    border: 1px solid var(--crpt-border);
    border-radius: var(--crpt-radius);
    box-shadow: var(--crpt-shadow);
}

.lk-crpt__auth-bar {
    padding: 12px 16px;
    margin-bottom: 16px;
}

.lk-crpt__auth-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: center;
}

@media (min-width: 992px) {
    .lk-crpt__auth-grid {
        grid-template-columns: minmax(240px, 1.1fr) minmax(260px, 1.5fr) auto;
    }
}

.lk-crpt__status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.lk-crpt__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: none;
    background: var(--mp-gray-400);
}

.lk-crpt__dot--ok {
    background: var(--mp-pine);
    box-shadow: 0 0 0 4px rgba(35, 149, 90, 0.16);
}

.lk-crpt__plugin-msg {
    font-size: 0.78rem;
    margin-top: 3px;
}

.lk-crpt__cert-group .form-select,
.lk-crpt__cert-group .btn {
    min-height: 38px;
    border-color: var(--mp-gray-200);
}

.lk-crpt__auth-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

@media (min-width: 992px) {
    .lk-crpt__auth-actions {
        justify-content: flex-end;
    }
}

/* ——— Кнопки и инпуты ——— */

.lk-crpt .form-control,
.lk-crpt .form-select {
    border-color: var(--mp-gray-200);
    border-radius: 10px;
    min-height: 38px;
    font-size: 0.88rem;
}

.lk-crpt .form-control:focus,
.lk-crpt .form-select:focus {
    border-color: var(--mp-orange);
    box-shadow: var(--crpt-ring);
}

.lk-crpt__btn-primary {
    background: linear-gradient(135deg, var(--mp-orange) 0%, var(--mp-orange-dark) 100%);
    border: 0;
    color: #fff;
    font-weight: 600;
    border-radius: 10px;
    min-height: 38px;
    padding: 0 16px;
    box-shadow: 0 4px 12px rgba(239, 127, 26, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.lk-crpt__btn-primary:hover:not(:disabled) {
    color: #fff;
    box-shadow: 0 6px 16px rgba(239, 127, 26, 0.35);
    transform: translateY(-1px);
}

.lk-crpt__btn-primary:disabled {
    opacity: 0.5;
    box-shadow: none;
}

.lk-crpt__btn-soft {
    border-radius: 10px;
    min-height: 38px;
    font-weight: 600;
}

/* ——— Навигация по вкладкам раздела (1 строка со скроллом) ——— */

.lk-crpt__nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    padding: 4px;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--crpt-border);
    border-radius: 14px;
    scrollbar-width: none;
}

.lk-crpt__nav::-webkit-scrollbar {
    display: none;
}

.lk-crpt__nav-link {
    position: relative;
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--mp-gray-600);
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.lk-crpt__nav-link:hover {
    background: var(--mp-peach-light);
    color: var(--mp-orange-dark);
}

.lk-crpt__nav-link[aria-current="page"] {
    background: var(--mp-surface);
    color: var(--mp-text);
    box-shadow: 0 1px 3px rgba(26, 26, 26, 0.08);
}

.lk-crpt__nav-link[aria-current="page"]::after {
    content: "";
    position: absolute;
    inset-inline: 12px;
    inset-block-end: 0;
    border-block-end: 3px solid var(--mp-orange);
    border-radius: 3px 3px 0 0;
}

/* ——— Панель фильтров и быстрые пилюли ——— */

.lk-crpt__filters {
    padding: 14px 16px;
    margin-bottom: 16px;
}

.lk-crpt__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.lk-crpt__chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid var(--mp-gray-200);
    background: var(--mp-surface);
    color: var(--mp-gray-600);
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s ease;
}

.lk-crpt__chip:hover {
    border-color: var(--mp-orange);
    color: var(--mp-orange-dark);
    background: var(--mp-peach-light);
}

.lk-crpt__chip.is-active {
    background: var(--mp-text);
    border-color: var(--mp-text);
    color: #fff;
}

.lk-crpt__chip-cnt {
    font-size: 0.72rem;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(128, 128, 128, 0.15);
}

.lk-crpt__chip.is-active .lk-crpt__chip-cnt {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

/* ——— KPI-карточки ——— */

.lk-crpt__kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.lk-crpt__kpi {
    background: var(--mp-surface);
    border: 1px solid var(--crpt-border);
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: 0 1px 2px rgba(26, 26, 26, 0.03);
    border-top: 3px solid var(--mp-gray-200);
}

.lk-crpt__kpi--ok {
    border-top-color: var(--mp-pine);
}

.lk-crpt__kpi--warn {
    border-top-color: var(--mp-orange);
}

.lk-crpt__kpi--danger {
    border-top-color: var(--mp-berry);
}

.lk-crpt__kpi--info {
    border-top-color: var(--mp-blue);
}

.lk-crpt__kpi-label {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--mp-muted);
    margin-bottom: 4px;
}

.lk-crpt__kpi-val {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.lk-crpt__kpi-sub {
    font-size: 0.74rem;
    color: var(--mp-muted);
    margin-top: 3px;
}

/* ——— Адаптивные таблицы с липким заголовком (@container) ——— */

.lk-crpt__table-card {
    overflow: hidden;
}

.lk-crpt__table-wrap {
    overflow: auto;
    max-inline-size: 100%;
    max-block-size: min(68vh, 720px);
    container-type: inline-size;
}

.lk-crpt__table-wrap:focus-visible {
    outline: 2px solid var(--mp-orange);
    outline-offset: -2px;
}

.lk-crpt__table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}

.lk-crpt__table thead {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
}

.lk-crpt__table thead th {
    background: #f8f7f5;
    border-bottom: 1px solid var(--mp-gray-200);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--mp-gray-600);
    padding: 10px 12px;
    white-space: nowrap;
}

.lk-crpt__table tbody th,
.lk-crpt__table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1efec;
    vertical-align: middle;
    font-weight: 400;
}

.lk-crpt__table tbody tr:last-child th,
.lk-crpt__table tbody tr:last-child td {
    border-bottom: 0;
}

.lk-crpt__table tbody tr:hover td,
.lk-crpt__table tbody tr:hover th {
    background-color: #faf8f5;
}

.lk-crpt__table tbody tr.is-danger td,
.lk-crpt__table tbody tr.is-danger th {
    background-color: #fff4f4;
}

.lk-crpt__table tbody tr.is-warn td,
.lk-crpt__table tbody tr.is-warn th {
    background-color: #fffaf0;
}

.lk-crpt__table tbody tr.is-info td,
.lk-crpt__table tbody tr.is-info th {
    background-color: #f3f8ff;
}

/* Бейджи расхождения остатков */
.lk-crpt__diff {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.lk-crpt__diff--surplus {
    background: #fff1db;
    color: #9a4a05;
    border: 1px solid rgba(239, 127, 26, 0.3);
}

.lk-crpt__diff--shortage {
    background: #eaf2ff;
    color: #17407f;
    border: 1px solid rgba(47, 128, 237, 0.3);
}

.lk-crpt__diff--match {
    background: #e9f7ef;
    color: #166534;
    border: 1px solid rgba(35, 149, 90, 0.25);
}

.lk-crpt__diff--zero {
    background: var(--mp-gray-100);
    color: var(--mp-muted);
}

/* Карточный режим на узких контейнерах (< 680px) по гайду responsive-table */
@container (width < 680px) {
    .lk-crpt__table-wrap {
        max-block-size: none;
    }

    .lk-crpt__table,
    .lk-crpt__table thead,
    .lk-crpt__table tbody,
    .lk-crpt__table tr,
    .lk-crpt__table th,
    .lk-crpt__table td {
        display: block;
    }

    .lk-crpt__table thead {
        display: none;
    }

    .lk-crpt__table tbody tr {
        margin: 10px;
        border: 1px solid var(--mp-gray-200);
        border-radius: 12px;
        background: var(--mp-surface);
        overflow: hidden;
    }

    .lk-crpt__table tbody th {
        background: #f8f7f5;
        border-bottom: 1px solid var(--mp-gray-200);
        font-weight: 700;
    }

    .lk-crpt__table tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        text-align: right !important;
        padding: 8px 12px;
    }

    .lk-crpt__table tbody td[data-label]::before {
        content: attr(data-label);
        font-size: 0.76rem;
        font-weight: 600;
        color: var(--mp-muted);
        text-align: left;
    }

    .lk-crpt__table tbody td.lk-crpt__td-empty {
        display: block;
        text-align: center !important;
    }
}

/* Callout-подсказка при пустом снимке */
.lk-crpt__callout {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    margin-bottom: 16px;
    border-radius: 14px;
    background: linear-gradient(135deg, #fff8ee 0%, #fff 100%);
    border: 1px solid rgba(239, 127, 26, 0.35);
}
