* {
    box-sizing: border-box;
    font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

body {
    margin: 0;
    background: #f5f6f8;
    color: #1c1e21;
    font-size: 15px;
}

.topnav {
    display: flex;
    align-items: center;
    background: #202124;
    color: #fff;
    padding: 10px 20px;
    position: relative;
}

.topnav a {
    color: #fff;
    text-decoration: none;
}

/* Кнопка-меню — единственное, что всегда видно в шапке (без названия
   проекта), на любом размере экрана. Список инструментов — выпадающая
   панель, открывается по клику (см. assets/nav.js). */
.nav-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 6px 10px;
    cursor: pointer;
}

.nav-toggle-icon {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.nav-toggle-label {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

/* На планшете/десктопе — аккуратное компактное меню под кнопкой, а не на
   всю ширину экрана. На телефоне ширина переопределяется ниже. */
.nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 10px;
    min-width: 220px;
    max-width: calc(100vw - 20px);
    flex-direction: column;
    align-items: stretch;
    background: #202124;
    padding: 8px 15px;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.nav-menu.open {
    display: flex;
}

.nav-menu a {
    padding: 10px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.nav-menu a:last-child {
    border-bottom: none;
}

.nav-menu a:hover {
    background: rgba(255, 255, 255, 0.08);
}

.nav-menu a.active {
    color: #6ba5f5;
}

/* Название текущего инструмента — между кнопкой-меню и «Выйти», по центру
   оставшегося пространства между ними. */
.nav-title {
    flex: 1;
    text-align: center;
    margin: 0 10px;
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Кнопка выхода — отдельно от меню инструментов, всегда видна справа
   в верхней строке (не нужно открывать меню, чтобы выйти). */
.nav-logout {
    flex-shrink: 0;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    padding: 6px 14px;
    border-radius: 5px;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
}

.nav-logout:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-toggle-bar {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
}

main {
    max-width: 900px;
    margin: 30px auto;
    padding: 0 20px;
}

.page-title {
    text-align: center;
}

.card {
    background: #fff;
    border: 1px solid #dcdfe3;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

/* Разделитель перед необязательными полями формы (страна/город/время) —
   отделяет их от важных полей (имя/фамилия/дата рождения) визуально,
   без отдельной карточки. */
.form-section-label {
    margin: 4px 0 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

input[type=text], input[type=password], textarea, select {
    padding: 8px;
    border: solid 1px #787878;
    border-radius: 5px;
    max-width: 100%;
    width: 100%;
    margin-bottom: 15px;
}

button, input[type=submit] {
    padding: 8px 20px;
    border: none;
    border-radius: 5px;
    background: #1a73e8;
    color: #fff;
    cursor: pointer;
    font-size: 15px;
}

button:hover, input[type=submit]:hover {
    background: #1558b0;
}

.error {
    color: #c5221f;
    background: #fce8e6;
    border: 1px solid #f6aea9;
    border-radius: 5px;
    padding: 10px;
    margin-bottom: 15px;
}

.notice {
    color: #7a5b00;
    background: #fef7e0;
    border: 1px solid #f6d777;
    border-radius: 5px;
    padding: 10px;
    margin-bottom: 15px;
}

.tools-grid {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.tool-card {
    display: block;
    text-decoration: none;
    color: inherit;
    flex: 1;
    min-width: 220px;
}

.tool-card h3 {
    margin-top: 0;
    color: #1a73e8;
}

table.results {
    width: 100%;
    border-collapse: collapse;
}

table.results td {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

table.results td.label {
    font-weight: 600;
    width: 45%;
}

table.results td.hint {
    color: #666;
    font-size: 13px;
}

.inline-form {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.inline-form label {
    margin-bottom: 5px;
}

.inline-form input {
    margin-bottom: 0;
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header-row h3 {
    margin: 0;
}

.card-header-actions {
    display: flex;
    gap: 8px;
}

.button-like {
    display: inline-block;
    padding: 8px 20px;
    border: none;
    border-radius: 5px;
    background: #1a73e8;
    color: #fff;
    text-decoration: none;
    font-size: 15px;
    text-align: center;
    cursor: pointer;
}

.button-like:hover {
    background: #1558b0;
}

.button-secondary {
    background: #e8eaed;
    color: #1c1e21;
}

.button-secondary:hover {
    background: #d5d8dc;
}

.action-row {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

.action-row > * {
    flex: 1;
}

/* Выпадающий список подсказок клиента под полем "Быстрый расчёт /
   Поиск клиента" — см. assets/client-autocomplete.js. */
.autocomplete-box {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    background: #fff;
    border: 1px solid #dcdfe3;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    margin-top: 4px;
    max-height: 280px;
    overflow-y: auto;
}

.autocomplete-item {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 4px 10px;
    padding: 8px 12px;
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid #f0f1f3;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.is-active {
    background: #f3f6fb;
}

.autocomplete-name {
    font-weight: 600;
}

.autocomplete-meta {
    color: #666;
    font-size: 12px;
    white-space: nowrap;
}

/* Компактные группы параметров расчёта — задача: уместить весь расчёт
   на одном мобильном экране без вертикального скролла. */
.param-groups {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.param-group {
    background: #f3f6fb;
    border: 1px solid #e3e9f2;
    border-radius: 6px;
    padding: 4px 10px;
}

.param-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 90px;
    align-items: baseline;
    gap: 10px;
    padding: 3px 0;
    border-bottom: 1px solid #e3e9f2;
    font-size: 13px;
}

.param-row:last-child {
    border-bottom: none;
}

.param-label {
    font-weight: 600;
    color: #444;
}

.param-value {
    text-align: center;
    white-space: nowrap;
}

.notice-compact {
    font-size: 12px;
    padding: 6px 10px;
    margin: 8px 0 0;
}

/* Таблица участников группы — широкая (все параметры расчёта колонками),
   поэтому на маленьких экранах скроллится горизонтально сама, без
   расплющивания в блоки, как обычная table.results. */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.group-table {
    white-space: nowrap;
}

table.group-table th {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid #dcdfe3;
    font-size: 13px;
    color: #444;
}

table.group-table td {
    font-size: 13px;
}

table.group-table form {
    margin: 0;
}

table.group-table .button-like {
    padding: 4px 10px;
    font-size: 12px;
}

/* Планшеты и меньше */
@media (max-width: 768px) {
    main {
        max-width: 100%;
        margin: 15px auto;
        padding: 0 15px;
    }

    .topnav {
        padding: 10px 15px;
    }

    .tool-card {
        min-width: 100%;
    }

    table.results td.label {
        width: 40%;
    }
}

/* Телефоны */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }

    /* На телефоне меню — во всю ширину экрана (места мало, компактный
       якорь под кнопкой был бы слишком узким/неудобным для тапа). */
    .nav-menu {
        left: 0;
        right: 0;
        min-width: 0;
        max-width: none;
        border-radius: 0 0 8px 8px;
    }

    .card {
        padding: 15px;
    }

    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .inline-form > div {
        width: 100%;
    }

    .inline-form input {
        width: 100%;
    }

    button, input[type=submit] {
        width: 100%;
        padding: 12px 20px;
    }

    table.results:not(.group-table),
    table.results:not(.group-table) tbody,
    table.results:not(.group-table) tr,
    table.results:not(.group-table) td {
        display: block;
        width: 100%;
    }

    table.results:not(.group-table) tr {
        margin-bottom: 10px;
    }

    table.results td.label {
        width: 100%;
        border-bottom: none;
        padding-bottom: 2px;
    }

    table.results:not(.group-table) td:not(.label) {
        padding-top: 0;
    }

    /* Экран расчёта нумерологии должен помещаться на телефоне без
       вертикального скролла — сжимаем отступы карточек и групп. */
    main {
        margin: 8px auto;
    }

    h1 {
        font-size: 18px;
        margin: 10px 0;
    }

    .card {
        padding: 10px 12px;
        margin-bottom: 10px;
    }

    .card h3 {
        margin: 0 0 8px;
        font-size: 14px;
    }

    input[type=text], input[type=password], input[type=time], textarea, select {
        padding: 6px;
        margin-bottom: 8px;
    }

    label {
        margin-bottom: 2px;
        font-size: 13px;
    }

    .param-groups {
        gap: 5px;
    }

    .param-group {
        padding: 2px 8px;
    }

    .param-row {
        grid-template-columns: minmax(0, 1fr) 60px;
        padding: 2px 0;
        font-size: 12px;
    }

    .action-row {
        margin-top: 4px;
    }

    .action-row button,
    .action-row .button-like {
        padding: 10px;
        width: auto;
    }
}
