@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@500;600&family=Montserrat:wght@400;500;600&family=Lora:ital,wght@0,500;1,500&display=swap');

:root {
    --beige: #f8f9ff;
    --beige-deep: #e8ecf7;
    --deep-blue: #003366;
    --accent-blue: #0057a3;
    --highlight-blue: #0077d9;
    --ink: #111111;
    --snow: #ffffff;
    --shadow: rgba(17, 17, 17, 0.08);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Montserrat', 'Segoe UI', Tahoma, sans-serif;
    background: linear-gradient(180deg, var(--beige) 0%, var(--beige-deep) 100%);
    color: var(--ink);
    display: flex;
    flex-direction: column;
}

a {
    text-decoration: none;
    color: inherit;
}

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

.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(248, 249, 255, 0.92);
    backdrop-filter: blur(8px);
    box-shadow: 0 6px 16px var(--shadow);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Playfair Display', 'Times New Roman', serif;
    font-size: 1.5rem;
    letter-spacing: 0.08em;
    color: var(--deep-blue);
    text-transform: uppercase;
}

.brand-logo {
    height: 3.2rem;
    width: auto;
    display: block;
}

.main-nav {
    position: relative;
}

.menu {
    list-style: none;
    display: flex;
    gap: 0.5rem;
    padding: 0;
    margin: 0;
}

.menu-item {
    position: relative;
}

.menu-item.has-submenu::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 14px;
}

.menu-link {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--ink);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.06em;
    border-radius: 6px;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.menu-link:hover,
.menu-link:focus {
    background: rgba(0, 87, 163, 0.1);
    color: var(--accent-blue);
    box-shadow: inset 0 0 0 1px rgba(0, 87, 163, 0.4);
}

.submenu {
    list-style: none;
    position: absolute;
    left: 0;
    top: 100%;
    background: var(--snow);
    border-radius: 10px;
    min-width: 220px;
    padding: 0.5rem 0;
    margin: 0;
    box-shadow: 0 18px 32px rgba(17, 17, 17, 0.12);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.menu-item:hover > .submenu,
.menu-item:focus-within > .submenu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.submenu li a {
    display: block;
    padding: 0.65rem 1.25rem;
    font-weight: 500;
    color: var(--deep-blue);
    text-transform: none;
    letter-spacing: 0.02em;
    transition: background 0.2s ease, color 0.2s ease;
    text-align: left;
}

.submenu li a:hover,
.submenu li a:focus {
    background: rgba(0, 119, 217, 0.12);
    color: var(--highlight-blue);
}

main {
    flex: 1;
    max-width: 1200px;
    margin: 2.5rem auto 2rem;
    padding: 0 1.5rem;
    width: 100%;
}

.page-hero {
    background: rgba(255, 255, 255, 0.85);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 25px 45px rgba(17, 17, 17, 0.1);
    margin-bottom: 2rem;
    border: 1px solid rgba(0, 87, 163, 0.1);
}

.page-hero h1 {
    margin: 0 0 1rem;
    font-family: 'Playfair Display', 'Times New Roman', serif;
    font-size: clamp(2rem, 3vw, 2.75rem);
    color: var(--deep-blue);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.page-hero p {
    margin: 0;
    font-size: 1rem;
    color: var(--ink);
    text-align: center !important;
    text-indent: 0cm;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.content-block {
    background: var(--snow);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid rgba(0, 51, 102, 0.15);
    box-shadow: 0 15px 30px rgba(17, 17, 17, 0.08);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.content-block h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.35rem;
    color: var(--accent-blue);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-align: center;
}

.body-text {
    font-family: 'Montserrat', sans-serif;
    color: var(--ink);
    font-size: 1rem;
    margin: 0;
    text-align: justify;
    text-indent: 0.5cm;
}

.highlight-text {
    font-family: 'Lora', serif;
    color: var(--highlight-blue);
    font-size: 1.05rem;
    margin: 0;
    text-align: right !important;
    text-indent: 0 !important;
    padding-right: 1px;
    line-height: 1.6;
    font-style: italic;
}

footer {
    background: rgba(17, 17, 17, 0.9);
    color: var(--snow);
    text-align: center;
    padding: 1.25rem;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
}

footer p {
    margin: 0;
}

/* === СТИЛИ ДЛЯ КАЛЬКУЛЯТОРА === */

.calculator-container {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    background: var(--snow);
    border-radius: 8px;
    box-shadow: 0 15px 30px rgba(17, 17, 17, 0.08);
}

.service-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-family: 'Montserrat', sans-serif;
    table-layout: fixed;
}

.service-table th:first-child,
.service-table td:first-child {
    width: 70%;
}

.service-table th:nth-child(2),
.service-table td:nth-child(2) {
    width: 15%;
}

.service-table th:last-child,
.service-table td:last-child {
    width: 15%;
}

.service-table th {
    font-weight: 600;
    font-size: 16px;
    color: var(--ink);
    border-bottom: 2px solid var(--shadow);
    text-align: center;
}

.service-table td {
    text-align: center;
}

.service-table tbody td:first-child {
    text-align: left;
}

.service-table select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--shadow);
    border-radius: 4px;
    background: var(--snow);
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
}

.service-table tbody tr:hover {
    box-shadow: 0 0 0 2px var(--beige-deep);
    border-radius: 6px;
}

#volume-selector {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--shadow);
    border-radius: 4px;
    background: var(--snow);
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
    box-sizing: border-box;
}

.volume-selector {
    margin: 1.5rem 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: center;
}

#calculate-btn {
    margin-top: 16px;
    width: 100%;
    padding: 1rem;
    background-color: var(--highlight-blue);
    color: var(--snow);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1.1rem;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#calculate-btn:hover:not(:disabled) {
    background-color: rgba(0, 119, 217, 0.9);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

#calculate-btn:disabled {
    background-color: rgba(0, 119, 217, 0.5);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.result-block {
    margin-top: 20px;
    padding: 15px;
    background: var(--beige);
    border-radius: 6px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--deep-blue);
}

.result-block.error {
    color: #003366;
    background: #e6f0ff;
}

.qr-section {
    text-align: center;
    margin: 3rem 0;
    padding: 2rem;
    background: var(--beige);
    border-radius: 12px;
    max-width: 300px;
    margin: 3rem auto;
}

.qr-section h2 {
    font-size: 1.1rem;
    color: var(--deep-blue);
    margin-bottom: 1rem;
    text-transform: none;
}

/* === ФОРМЫ === */

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--ink);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--shadow);
    border-radius: 6px;
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
    background: var(--snow);
    box-sizing: border-box;
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.form-group input[type="date"] {
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
}

.form-group input[type="date"]:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 87, 163, 0.1);
}

/* === КНОПКА ЗАПИСИ === */

.btn-book {
    padding: 0.75rem 1.5rem;
    background-color: var(--accent-blue);
    color: var(--snow);
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-book:hover {
    background-color: var(--highlight-blue);
}

/* === БЛОКИ УПРАВЛЕНИЯ ЗАПИСЬЮ === */

.booking-controls {
    margin-bottom: 1.5rem;
}

.booking-controls label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--ink);
}

/* === ВРЕМЕННЫЕ СЛОТЫ === */

.time-slots {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.time-slot {
    padding: 0.75rem 0.5rem;
    background-color: var(--accent-blue);
    color: var(--snow);
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s ease;
}

.time-slot:hover:not(:disabled) {
    background-color: var(--highlight-blue);
}

.time-slot:disabled,
.time-slot.disabled {
    background-color: var(--beige-deep);
    color: #999;
    cursor: not-allowed;
    opacity: 0.6;
}

.time-slot.selected {
    background-color: var(--highlight-blue);
    box-shadow: 0 0 0 3px rgba(0, 119, 217, 0.3);
    transform: scale(1.05);
}

/* === СООБЩЕНИЯ === */

.booking-message {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--beige);
    border-radius: 6px;
    font-size: 0.95rem;
    text-align: center;
    display: none;
}

.booking-message.show,
.booking-message.success,
.booking-message.error {
    display: block;
}

.char-counter {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--shadow);
    text-align: right;
}

.char-counter span {
    font-weight: 600;
    color: var(--ink);
}

/* === КАЛЕНДАРИ === */

.calendar-container {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.month-calendar {
    background: var(--snow);
    border: 1px solid rgba(0, 51, 102, 0.15);
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(17, 17, 17, 0.08);
    overflow: hidden;
    width: 300px;
}

.month-header {
    background: var(--deep-blue);
    color: var(--snow);
    text-align: center;
    padding: 0.75rem;
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--beige-deep);
    color: var(--ink);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.weekdays div {
    text-align: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(17, 17, 17, 0.1);
}

.dates {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    padding: 0.5rem;
}

.date {
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    font-size: 0.95rem;
    color: var(--ink);
    border-radius: 50%;
    cursor: default;
    transition: all 0.2s ease;
    margin: 0 auto;
}

.date:hover:not(.disabled):not(.empty) {
    background: var(--beige-deep);
    transform: scale(0.95);
}

.date.selected {
    background: var(--accent-blue);
    color: var(--snow);
    box-shadow: 0 0 0 3px rgba(0, 87, 163, 0.3);
}

.date.disabled {
    color: #ccc;
    cursor: not-allowed;
}

.date.empty {
    visibility: hidden;
}

/* === ТИП КОНСУЛЬТАЦИИ — ВЫБОР В СТРОКУ === */

.consult-type-grid {
    display: flex;
    gap: 1rem;
    flex-wrap: nowrap;
    margin-top: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: none; /* Firefox */
}

.consult-type-grid::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.type-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 90px;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    color: #555;
    background: #f9f9f9;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.type-option:hover {
    border-color: #0057a3;
    background: #eef4ff;
    color: #003366;
}

.type-option input[type="radio"] {
    margin-bottom: 0.4rem;
    transform: scale(1.2);
}

.type-label {
    line-height: 1.3;
}

.type-option input[type="radio"]:checked {
    accent-color: #0057a3;
}

.type-option input[type="radio"]:checked + .type-label,
.type-option input[type="radio"]:checked ~ .type-label {
    font-weight: 600;
    color: #003366;
}

@media (max-width: 600px) {
    .consult-type-grid {
        gap: 0.75rem;
    }
    .type-option {
        min-width: 80px;
        padding: 0.6rem 0.5rem;
        font-size: 0.9rem;
    }
}

/* === АДМИНКА: СТИЛИ ТАБЛИЦЫ И ФОРМ === */

.admin-hero {
    background: var(--snow);
    border: 1px solid var(--shadow);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 20px rgba(17, 17, 17, 0.08);
}

.admin-hero h2 {
    margin: 0 0 1rem;
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    color: var(--deep-blue);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.admin-hero p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--ink);
    text-align: justify;
    text-indent: 1.5cm;
}

.filter-form {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.filter-select {
    flex: 1;
    min-width: 200px;
    padding: 0.75rem;
    border: 1px solid var(--shadow);
    border-radius: 6px;
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
    background: var(--snow);
}

.filter-btn,
.btn-reset {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    font-family: 'Montserrat', sans-serif;
}

.filter-btn {
    background: var(--accent-blue);
    color: var(--snow);
}

.filter-btn:hover {
    background: var(--highlight-blue);
}

.btn-reset {
    background: var(--beige-deep);
    color: var(--ink);
    text-decoration: none;
    display: inline-block;
}

.btn-reset:hover {
    background: var(--shadow);
}

.admin-table-container {
    overflow-x: auto;
    margin-top: 1rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-family: 'Montserrat', sans-serif;
    background: var(--snow);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 16px rgba(17, 17, 17, 0.08);
}

.admin-table thead {
    background: var(--accent-blue);
    color: var(--snow);
}

.admin-table th,
.admin-table td {
    padding: 0.75rem;
    border: 1px solid var(--beige-deep);
    text-align: left;
    font-size: 0.95rem;
}

.admin-table th {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-table tbody tr {
    border-bottom: 1px solid var(--beige-deep);
    transition: box-shadow 0.2s ease;
}

.admin-table tbody tr:hover {
    box-shadow: 0 0 0 2px var(--beige-deep);
}

.admin-table .status-new {
    background: #e3f2fd;
    color: #1565c0;
}

.admin-table .status-in-progress {
    background: #fff3e0;
    color: #e65100;
}

.admin-table .status-done {
    background: #e8f5e9;
    color: #2e7d32;
}

.admin-table .status-cancelled {
    background: #ffebee;
    color: #c62828;
}

.admin-table .status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-block;
}

.admin-table .description-preview {
    max-height: 100px;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--ink);
    padding: 0.25rem 0;
}

.admin-table .action-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0;
}

.admin-table .action-select {
    padding: 0.5rem;
    border: 1px solid var(--shadow);
    border-radius: 4px;
    font-size: 0.9rem;
    width: 100%;
    background: var(--snow);
}

.admin-table .action-btn {
    padding: 0.5rem 1rem;
    background: var(--accent-blue);
    color: var(--snow);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s ease;
}

.admin-table .action-btn:hover {
    background: var(--highlight-blue);
}

.admin-table .no-data {
    padding: 2rem;
    text-align: center;
    color: var(--shadow);
    font-style: italic;
}

/* === МОДАЛЬНОЕ ОКНО === */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(17, 17, 17, 0.7);
    backdrop-filter: blur(4px);
    overflow: auto;
    padding: 2rem;
}

.modal-content {
    background: var(--snow);
    margin: 2rem auto;
    padding: 1.5rem;
    border-radius: 12px;
    max-width: 800px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(17, 17, 17, 0.2);
    position: relative;
    animation: slide-up 0.2s ease;
}

@keyframes slide-up {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--beige-deep);
}

.modal-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    color: var(--deep-blue);
    margin: 0;
}

/* === МОДАЛЬНОЕ ОКНО — КНОПКА ЗАКРЫТИЯ (КРЕСТИК) === */

.modal-close {
    background: var(--beige-deep);
    color: var(--deep-blue);
    border: 1px solid var(--deep-blue);
    font-size: 1.5rem;
    font-weight: 400;
    line-height: 1;
    width: 46px;
    height: 46px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0;
    padding: 0;
    text-align: center;
}

.modal-close:hover {
    background: var(--deep-blue);
    color: var(--snow);
    transform: scale(1.05);
    box-shadow: 0 0 0 2px rgba(0, 51, 102, 0.4);
}

.modal-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.modal-field {
    margin-bottom: 1rem;
}

.modal-field label {
    display: block;
    font-weight: 600;
    color: var(--deep-blue);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.modal-field value {
    display: block;
    font-size: 1rem;
    color: var(--ink);
    background: var(--beige-deep);
    padding: 0.75rem;
    border-radius: 6px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* === КНОПКИ === */

.btn-expand {
    padding: 0.5rem 1rem;
    background: var(--beige-deep);
    color: var(--deep-blue);
    border: 1px solid var(--shadow);
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-expand:hover {
    background: var(--beige);
    border-color: var(--deep-blue);
    transform: translateY(-1px);
}

.action-select-sm {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    width: 100%;
}

/* === КНОПКИ В БЛОКАХ === */
.buttons-container {
    margin: 1.5rem 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    padding: 0 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
    text-align: center;
    min-width: 180px;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
    border: 2px solid var(--accent-blue);
}

.btn-primary:hover {
    background: #0057a3;
    border-color: #0057a3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 87, 163, 0.3);
}

.btn-secondary {
    background: white;
    color: var(--accent-blue);
    border: 2px solid var(--accent-blue);
}

.btn-secondary:hover {
    background: #f0f7ff;
    color: #0057a3;
    transform: translateY(-1px);
}

/* === ШАПКА: ОБЫЧНОЕ И КОМПАКТНОЕ МЕНЮ ===
   Обычное меню: ширина от 1024px и основной указатель с наведением (мышь, тачпад).
   Во всех остальных случаях - компактное меню (кнопка «Меню», вертикальный список).
   Условие должно совпадать с NORMAL в скрипте includes/header.php. */

.nav-toggle,
.submenu-toggle {
    display: none;
}

.menu-link:focus-visible,
.submenu li a:focus-visible,
.nav-toggle:focus-visible,
.submenu-toggle:focus-visible {
    outline: 3px solid var(--highlight-blue);
    outline-offset: -3px;
}

@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
    /* Скрытые подменю не должны попадать в порядок Tab */
    .submenu {
        visibility: hidden;
        transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
    }

    .menu-item:hover > .submenu,
    .menu-item:focus-within > .submenu {
        visibility: visible;
        transition-delay: 0s;
    }
}

@media not all and (min-width: 1024px) and (hover: hover) and (pointer: fine) {
    .header-inner {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }

    .brand {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 1.15rem;
    }

    .brand-logo {
        flex: 0 0 auto;
        height: 2.6rem;
    }

    .main-nav {
        flex: 0 0 100%;
        width: 100%;
    }

    .menu {
        flex-direction: column;
        gap: 0;
        padding-bottom: 0.5rem;
    }

    .menu-item {
        display: flex;
        flex-wrap: wrap;
        align-items: stretch;
        border-top: 1px solid var(--shadow);
    }

    .menu-item.has-submenu::after {
        display: none;
    }

    .menu-link {
        flex: 1 1 0;
        min-width: 0;
        padding: 0.85rem 1rem;
        overflow-wrap: anywhere;
    }

    /* Подменю: в потоке, без наведения; без JavaScript показаны списком */
    .submenu {
        display: block;
        position: static;
        flex: 0 0 100%;
        min-width: 0;
        padding: 0.25rem 0 0.25rem 1rem;
        border-radius: 0;
        box-shadow: none;
        background: rgba(0, 87, 163, 0.05);
        opacity: 1;
        pointer-events: auto;
        transform: none;
        transition: none;
    }

    .submenu li a {
        padding: 0.7rem 1rem;
        overflow-wrap: anywhere;
    }

    .js .nav-toggle {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        padding: 0 1rem;
        border: 1px solid var(--accent-blue);
        border-radius: 6px;
        background: transparent;
        color: var(--deep-blue);
        font: inherit;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        cursor: pointer;
    }

    .js .main-nav {
        display: none;
    }

    .js .main-nav.is-open {
        display: block;
        max-height: calc(100vh - 5rem);
        max-height: calc(100dvh - 5rem);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .js .submenu {
        display: none;
    }

    .js .menu-item.is-open > .submenu {
        display: block;
    }

    .js .submenu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 3.25rem;
        min-height: 44px;
        padding: 0;
        border: 0;
        border-left: 1px solid var(--shadow);
        background: transparent;
        color: var(--deep-blue);
        cursor: pointer;
    }

    .js .submenu-toggle::before {
        content: '';
        width: 0.6rem;
        height: 0.6rem;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: translateY(-2px) rotate(45deg);
    }

    .js .submenu-toggle[aria-expanded="true"]::before {
        transform: translateY(2px) rotate(-135deg);
    }
}
