/* ============================================================
   Atlas — адаптивный слой.
   Подключается последним и перекрывает фиксированную вёрстку темы.
   ============================================================ */

:root {
    --bg: #f3f4f6;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --accent: #f59e0b;
    --accent-dark: #b45309;
    --brand: #0f766e;
    --brand-dark: #115e59;
    --brand-soft: #f0fdfa;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(17, 24, 39, .06), 0 8px 24px rgba(17, 24, 39, .05);
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    min-width: 0 !important;
    background: var(--bg) !important;
    color: var(--text);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif !important;
    overflow-x: clip;
}

img {
    max-width: 100%;
    height: auto;
}

/* ---------- Общая рамка ---------- */

#wrapper {
    position: relative;
    z-index: 1;
    width: 100% !important;
    min-height: 0 !important;
    padding: 0 0 24px !important;
    overflow: visible !important;
}

/* Картинка — подложка под контентом, а не баннер сверху. */
.slider {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    margin: 0 !important;
    z-index: 0 !important;
    display: block !important;
    overflow: hidden !important;
    pointer-events: none !important;
    opacity: .85;
    background: var(--bg);
}

#riva-slider-12-shell,
#riva-slider-12-shell picture {
    display: block;
    width: 100%;
    height: 100%;
}

.hero-image {
    display: block;
    width: 100%;
    height: 100%;
    max-height: none !important;
    object-fit: cover;
    object-position: center center;
    filter: saturate(1.12) contrast(1.03);
}

#header {
    position: static !important;
    width: 100% !important;
    max-width: 1200px;
    height: auto !important;
    margin: 0 auto !important;
    padding: 10px 16px;
    background: transparent !important;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

body.login-page #header {
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 18px !important;
    padding: 28px 16px 18px !important;
}

body.login-page #logo {
    margin: 0 auto !important;
}

body.login-page .login-card {
    margin: 0 auto !important;
}

#logo {
    float: none !important;
    width: auto !important;
    margin: 0 !important;
    overflow: visible;
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid #cce8e2;
    border-radius: 14px;
    background: var(--brand-soft) !important;
    box-shadow: 0 8px 24px rgba(15, 118, 110, .12);
}

#logo img {
    width: 190px;
    height: auto;
}

/* ---------- Верхняя панель пользователя и категорий ---------- */

.Page {
    width: 100% !important;
    max-width: 1200px;
    min-width: 0;
    flex: 1 1 100%;
    margin: 0 auto 18px !important;
    padding: 10px 12px !important;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--text) !important;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 10px;
}

.Page details.panel {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}

.Page details.panel > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    list-style: none;
    user-select: none;
}

.Page details.panel > summary::-webkit-details-marker {
    display: none;
}

.Page details.panel > summary::marker {
    content: '';
}

.Page details.panel > summary::after {
    content: '▾';
    margin-left: 8px;
    color: var(--muted);
    transition: transform .2s ease;
}

.Page details.panel[open] > summary::after {
    transform: rotate(180deg);
}

.Page .panel-title {
    font-size: 10px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    flex: 0 0 auto;
}

.Page .panel-summary {
    margin-left: auto;
    min-width: 0;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}

.Page .panel-body {
    padding: 0 12px 12px;
}

.Page form {
    min-width: 0;
}

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

.Page .user-form {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 48px minmax(0, 1fr);
    gap: 8px;
    align-items: stretch;
    width: 100%;
}

.Page .user-form .user-badge {
    grid-column: 1 / -1;
    width: 100%;
}

.Page .user-form .button {
    width: 100% !important;
    min-width: 0;
}

.Page .user-form .help-link {
    width: 100% !important;
}

.Page .category-form {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    flex: none;
    width: 100%;
}

.Page .category-form .button {
    width: 100% !important;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
}

.Page .category-form .edit-toggle {
    grid-column: 1 / -1;
}

.user-badge {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    margin-right: 0;
    min-width: 0;
    width: 100%;
}

.user-name {
    font-weight: 700;
    font-size: 14px;
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: normal;
}

.user-role {
    font-size: 10px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}

.category-form {
    flex: 1 1 680px;
    min-width: 0;
}

/* ---------- Кнопки ---------- */

.button {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: auto !important;
    min-height: 38px;
    margin: 0 !important;
    padding: 8px 14px !important;
    border: 1px solid transparent !important;
    border-radius: 999px !important;
    background: #f3f4f6 !important;
    color: var(--text) !important;
    font-family: inherit !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.button:hover {
    background: #e5e7eb !important;
}

.button.primary {
    background: var(--brand) !important;
    color: #fff !important;
}

.button.primary:hover {
    background: var(--brand-dark) !important;
}

.button.ghost {
    background: transparent !important;
    border-color: #d1d5db !important;
    color: #374151 !important;
}

.button.exit {
    background: #fee2e2 !important;
    color: #991b1b !important;
}

.button.is-active {
    background: var(--accent) !important;
    color: #111827 !important;
}

.button.small {
    min-height: 28px;
    padding: 4px 9px !important;
    font-size: 11px !important;
}

.button.edit-toggle {
    background: #fff7ed !important;
    color: #9a3412 !important;
    border-color: #fed7aa !important;
}

.button.edit-toggle.is-active {
    background: #fdba74 !important;
    color: #7c2d12 !important;
}

.help-link {
    width: 38px !important;
    padding: 0 !important;
}

/* ---------- Страница и контент ---------- */

#page,
#page.bigslider {
    position: static !important;
    top: auto !important;
    left: auto !important;
    width: auto !important;
    max-width: 1200px;
    margin: 0 auto 18px !important;
    padding: 16px !important;
    background: var(--card) !important;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: visible !important;
}

#content {
    width: 100% !important;
    font-size: 14px;
    line-height: 1.5;
    overflow: visible !important;
}

/* ---------- Таблица ---------- */

.table-responsive {
    width: 100%;
    overflow: visible !important;
}

table.data-table {
    width: 100% !important;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0 !important;
}

/* Фильтр/поиск всегда остаётся вверху при прокрутке данных. */
table.data-table thead {
    position: sticky;
    top: 0;
    z-index: 30;
    background: #f9fafb;
}

table.data-table thead th {
    background: #f9fafb !important;
    font-size: 12px;
    font-weight: 700;
    color: #374151;
    white-space: nowrap;
    vertical-align: top !important;
}

.file-heading {
    display: block;
}

.records-summary {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: 0;
    text-transform: none !important;
    white-space: nowrap;
}

.records-summary strong {
    display: inline !important;
    color: var(--text) !important;
    font-weight: 700;
}

/* Старый счётчик tabsort2.js; вместо него — #records-summary в шапке. */
#num_res {
    display: none !important;
}

table.data-table th,
table.data-table td {
    border: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    vertical-align: middle;
    text-align: left;
    overflow-wrap: anywhere;
}

table.data-table thead th:first-child {
    border-top-left-radius: 10px;
}

table.data-table thead th:last-child {
    border-top-right-radius: 10px;
}

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

table.data-table tbody tr:hover td {
    background: #f9fbff;
}

table.data-table td.column1 {
    width: 50% !important;
    padding: 10px 12px !important;
    font-weight: 600;
    color: #111827;
}

table.data-table td.column2 {
    width: 28%;
    color: #4b5563;
}

table.data-table td.column3 {
    width: 22%;
    white-space: nowrap;
}

table.data-table td.column3 a {
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

table.data-table td.column3 img {
    display: block;
    max-width: 200px;
    height: auto;
    border-radius: 8px;
}

table.data-table td.column3 .pdf-link img,
table.data-table td.column3 .edit-row img {
    width: 28px;
    height: 28px;
    border-radius: 0;
}

/* Поля поиска, которые вставляет tabsort2.js */
table.data-table thead th input.str,
table.data-table thead th input.num {
    width: 100% !important;
    max-width: 100%;
    margin-top: 6px;
    padding: 8px 10px;
    border: 1px solid #d1d5db !important;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
}

table.data-table thead th input.str:focus,
table.data-table thead th input.num:focus {
    outline: 2px solid rgba(245, 158, 11, .45);
    border-color: var(--accent) !important;
}

/* Фильтр tabsort2.js */
.disnone,
.disnone_child .disnone_if {
    display: none !important;
}

/* ---------- Подвал ---------- */

#bottom-top-container {
    width: 100% !important;
    height: auto !important;
    margin: 16px 0 0 !important;
    padding: 10px 14px !important;
    overflow: visible !important;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-align: center;
    border-top: 1px solid var(--line);
    font-size: 12px;
}

.copyrightleft,
.copyrightmiddle {
    float: none !important;
    width: 100% !important;
    padding: 0 !important;
    background: none !important;
    text-align: center !important;
}

.copyrightleft .textwidget,
.copyrightmiddle .textwidget {
    text-align: center;
}

.lecoaddress {
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 10px 14px 4px !important;
    background: transparent !important;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
    overflow: visible !important;
    overflow-wrap: anywhere;
}

.lecoaddress .textwidget {
    line-height: 1.5;
}

.scrollup {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 50;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(17, 24, 39, .8);
    color: #fff;
    font-size: 12px;
    text-decoration: none;
}

/* ---------- Форма входа ---------- */

.login-card {
    flex: 0 0 100%;
    width: 100%;
    min-width: 0;
    max-width: 420px;
    margin: 24px auto;
    padding: 26px 24px;
    background: var(--card);
    border-radius: 18px;
    box-shadow: var(--shadow);
    color: var(--text);
}

.login-card h1 {
    margin: 0 0 4px;
    font-size: 24px;
    line-height: 1.2;
}

.login-subtitle {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 13px;
}

.login-error {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fef2f2;
    color: #991b1b;
    font-size: 13px;
}

.flash-error {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fef2f2;
    color: #991b1b;
    font-size: 13px;
}

.login-form label,
.modal-form label {
    display: block;
    margin: 10px 0 4px;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
}

.login-form input[type="text"],
.login-form input[type="password"],
.modal-form input[type="text"],
.modal-form input[type="password"],
.modal-form input[type="email"],
.modal-form input[type="file"],
.modal-form select {
    width: 100% !important;
    max-width: none !important;
    min-height: 42px;
    padding: 10px 12px !important;
    border: 1px solid #d1d5db !important;
    border-radius: 10px !important;
    background: #fff;
    font-size: 15px;
    color: var(--text);
}

.login-form input:focus,
.modal-form input:focus,
.modal-form select:focus {
    outline: 2px solid rgba(245, 158, 11, .45);
    border-color: var(--accent) !important;
}

.login-form .checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-weight: 400;
}

.login-form .checkbox input {
    width: 18px;
    height: 18px;
}

.login-form .button {
    width: 100% !important;
    min-height: 46px;
    margin-top: 16px !important;
    font-size: 15px !important;
}

.login-note {
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

/* ---------- Модальные окна ---------- */

.popup_block {
    max-width: calc(100vw - 24px) !important;
    border-radius: 16px !important;
    box-sizing: border-box !important;
}

.popup_block .close {
    position: absolute;
    top: 10px;
    right: 12px;
}

.Adm_Modal,
.Help_Modal,
.ChangePass,
.AddUser {
    width: 100% !important;
    height: auto !important;
    max-height: 68vh;
    overflow: auto;
    float: none !important;
}

.Adm_Modal h1,
.ChangePass h1,
.Help_Modal h1 {
    margin: 0 0 10px;
    font-size: 20px;
}

.Adm_Modal h2,
.ChangePass h2,
.AddUser h2 {
    margin: 14px 0 8px;
    font-size: 15px;
}

.Adm_Users {
    width: 100% !important;
    height: auto !important;
    max-height: 320px;
    margin: 0 0 12px !important;
    overflow: auto;
}

/* Журнал входа: заголовок остаётся на месте, прокручивается сама таблица. */
#Adm_Log .table-responsive {
    max-height: 240px;
    overflow-x: auto !important;
    overflow-y: auto !important;
}

.modal-subtitle {
    color: var(--muted);
    font-size: 12px;
    margin: 0 0 12px;
}

.modal-form {
    margin: 0;
}

.modal-form .button {
    margin-top: 12px !important;
}

.status,
.statusPass {
    margin-top: 10px;
    font-size: 12px;
    line-height: 1.4;
}

.admin-hint {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.password-mask {
    display: inline-block;
    min-width: 76px;
    letter-spacing: .08em;
    color: #6b7280;
}

.admin-table td.ua-cell {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: #4b5563;
}

/* ---------- Мобильная версия ---------- */

@media (max-width: 900px) {
    .hero-image {
        max-height: 150px;
    }

    #header {
        padding: 8px 14px;
    }

    #logo img {
        width: 165px;
    }

    .Page {
        border-radius: 12px;
        padding: 10px 12px !important;
    }

    .category-form {
        flex-basis: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .Page .category-form {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        flex: 1 1 100%;
        min-width: 0;
        width: 100%;
    }

    .Page .category-form .button {
        min-width: 0;
        white-space: normal;
        overflow-wrap: anywhere;
        font-size: 12px !important;
        padding: 8px 6px !important;
    }

    .Page .user-form {
        display: grid !important;
        grid-template-columns: 1fr 1fr 44px;
        gap: 8px;
        width: 100%;
    }

    .Page .user-form .user-badge {
        grid-column: 1 / -1;
    }

    .Page .user-form .button {
        width: 100% !important;
    }

    .Page .user-form .admin-link {
        grid-column: 1 / -1;
    }

    .Page .user-form .help-link {
        width: 100% !important;
    }

    .category-form .button {
        width: 100% !important;
        min-height: 42px;
    }

    .category-form .edit-toggle {
        grid-column: 1 / -1;
    }

    #page,
    #page.bigslider {
        padding: 12px !important;
        border-radius: 12px;
    }
}

@media (max-width: 760px) {
    .slider {
        opacity: .75;
    }

    .hero-image {
        object-position: 70% center;
    }

    body {
        font-size: 14px;
    }

    body.login-page #header {
        padding: 18px 14px 14px !important;
    }

    body.login-page .login-card {
        width: 100%;
        margin: 0 auto !important;
    }

    /* Таблица превращается в карточки */
    table.data-table,
    table.data-table thead,
    table.data-table tbody,
    table.data-table tr,
    table.data-table th,
    table.data-table td {
        display: block;
        width: 100% !important;
    }

    table.data-table thead {
        position: sticky;
        top: 0;
        z-index: 40;
        margin-bottom: 12px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: #f9fafb;
        padding: 10px;
        box-shadow: 0 6px 14px rgba(17, 24, 39, .08);
    }

    table.data-table thead tr {
        display: grid;
        grid-template-columns: 1fr;
        gap: 6px;
    }

    table.data-table thead th {
        border: 0;
        padding: 0;
        background: transparent;
        border-radius: 0;
        font-size: 11px;
        color: var(--muted);
        text-transform: uppercase;
        letter-spacing: .04em;
    }

    table.data-table thead th:last-child {
        display: none;
    }

    table.data-table thead th.file-head {
        display: block !important;
        width: 100% !important;
        padding: 6px 2px 0 !important;
        border: 0;
        white-space: normal;
    }

    table.data-table thead th.file-head .file-heading {
        display: none;
    }

    table.data-table thead th.file-head .records-summary {
        margin-top: 4px;
        text-align: left;
    }

    table.data-table thead th input.str {
        max-width: none;
        margin-top: 4px;
        font-size: 16px;
        text-transform: none;
        letter-spacing: 0;
    }

    table.data-table tbody tr {
        margin: 0 0 12px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: #fff !important;
        box-shadow: 0 1px 2px rgba(17, 24, 39, .04);
    }

    table.data-table tbody tr:hover td {
        background: transparent;
    }

    table.data-table td {
        border: 0;
        padding: 4px 0 !important;
        width: 100% !important;
    }

    table.data-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 2px;
        font-size: 10px;
        font-weight: 700;
        letter-spacing: .06em;
        text-transform: uppercase;
        color: #9ca3af;
    }

    table.data-table td.column1 {
        width: 100% !important;
        max-width: none;
        font-size: 17px;
        line-height: 1.3;
        padding-top: 0 !important;
    }

    table.data-table td.column2 {
        width: 100% !important;
        max-width: none;
        color: #4b5563;
        font-size: 14px;
    }

    table.data-table td.column3 {
        width: 100% !important;
        max-width: none;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
        margin-top: 8px;
        padding-top: 8px !important;
        border-top: 1px dashed var(--line);
        white-space: normal;
    }

    table.data-table td.column3::before {
        flex-basis: 100%;
    }

    table.data-table td.column3 img {
        max-width: 100%;
        max-height: 260px;
        object-fit: contain;
        margin: 0 auto;
    }

    table.data-table td.column3 .thumb-link {
        display: block;
        width: 100%;
        margin: 0;
    }

    table.data-table td.column3 .pdf-link img,
    table.data-table td.column3 .edit-row img {
        width: 34px;
        height: 34px;
    }

    table.data-table td.column3 .edit-row {
        margin-left: auto;
        padding: 6px;
        border: 1px solid var(--line);
        border-radius: 10px;
        background: #f9fafb;
    }

    #bottom-top-container {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .scrollup {
        display: none;
    }

    .login-card {
        margin: 14px 12px;
        padding: 22px 18px;
    }

    .popup_block {
        max-height: 88vh !important;
        padding: 12px !important;
        border-radius: 14px !important;
    }

    .popup_block .close {
        top: 8px;
        right: 8px;
        width: 40px;
        height: 40px;
    }

    .popup_block .close:before {
        font-size: 25px;
    }

    .Adm_Modal,
    .Help_Modal,
    .ChangePass,
    .AddUser {
        max-height: 80vh;
    }

    .Adm_Users {
        max-height: 260px;
    }

    #Adm_Log .table-responsive {
        max-height: 200px;
    }

    .admin-table td.ua-cell {
        white-space: normal;
        max-width: none;
        word-break: break-word;
    }

    table.admin-table thead {
        display: none;
    }
}

@media (max-width: 340px) {
    .Page .category-form {
        grid-template-columns: 1fr;
    }

    .category-form .edit-toggle {
        grid-column: auto;
    }

    .Page form {
        width: 100%;
    }

    .user-badge {
        width: 100%;
    }

    .user-name {
        max-width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}


/* ---------- Просмотр изображения запчасти ---------- */

.image-viewer {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, .86);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    overscroll-behavior: contain;
}

.image-viewer.is-open {
    display: flex;
}

.image-viewer img {
    display: block;
    width: auto;
    height: auto;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 48px);
    object-fit: contain;
    /* Карточки в таблице строятся из «сырых» пикселей без EXIF-поворота,
       поэтому большое фото показываем в той же ориентации. */
    image-orientation: none !important;
    border-radius: 10px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .45);
}

.image-viewer-close {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 100001;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 50%;
    background: rgba(15, 23, 42, .72);
    color: #fff;
    font: 400 28px/1 Arial, sans-serif;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .3);
}

.image-viewer-close:hover {
    background: rgba(15, 23, 42, .95);
}

html.image-viewer-open,
html.image-viewer-open body {
    overflow: hidden !important;
}
