/*
  Стиль «Свечного ящика».

  Написан от телефона: базовые правила рассчитаны на узкий экран и палец,
  а расширения для больших экранов добавляются в @media ниже. Так и должно
  быть — за ящиком чаще стоят с телефоном, чем сидят за компьютером.

  Требования, которые здесь закреплены: базовый шрифт 18px, кнопки не
  меньше 48px, высокий контраст, заметная рамка фокуса, ничего не
  подгружается извне.
*/

:root {
    --color-bg: #ffffff;
    --color-text: #1a1a1a;
    --color-muted: #5a5a5a;
    --color-border: #c9c2b8;
    --color-border-light: #e6e1da;
    --color-accent: #7a1f2b;      /* приглушённый бордовый — уместен для церковного интерфейса */
    --color-accent-hover: #611821;
    --color-health: #2f5d3f;      /* о здравии — зелёный */
    --color-repose: #3a3f66;      /* о упокоении — приглушённый синий */
    --color-error-bg: #fbe3e3;
    --color-error-text: #7a1f1f;
    --color-warning-bg: #fdf3dd;
    --color-warning-text: #7a5a12;
    --color-ok-bg: #e6f2e9;
    --color-ok-text: #2f5d3f;
    --color-notice-bg: #f4f1ec;
    --color-focus: #1a56db;
    --font-size-base: 18px;
    --radius: 10px;
    --tap: 48px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: "Segoe UI", Tahoma, Verdana, Arial, sans-serif;
    font-size: var(--font-size-base);
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

h1 {
    font-size: 1.5em;
    margin: 0 0 0.3em;
}

h2 {
    font-size: 1.2em;
    margin: 1.4em 0 0.4em;
}

a {
    color: var(--color-accent);
}

.subtitle, .muted {
    color: var(--color-muted);
}

.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }

.note {
    margin-top: 1.2em;
    font-size: 0.9em;
    max-width: 62ch;
}

.empty {
    padding: 1.5em 0;
    color: var(--color-muted);
}

/* Заголовок для читалки с экрана, невидимый глазами. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* --------------------------------------------------------------------- */
/* Поля и кнопки                                                          */
/* --------------------------------------------------------------------- */

label {
    display: block;
    font-weight: 600;
    margin-top: 1em;
    margin-bottom: 0.3em;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    /* 16px и больше — иначе iOS увеличивает страницу при фокусе в поле. */
    font-size: 1em;
    font-family: inherit;
    padding: 0.6em 0.8em;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--color-text);
    min-height: var(--tap);
}

textarea {
    min-height: 6em;
    line-height: 1.6;
}

.input-narrow { max-width: 8em; }

label.checkbox {
    display: flex;
    align-items: center;
    gap: 0.6em;
}

label.checkbox input {
    width: 24px;
    height: 24px;
    min-height: 24px;
}

input:focus,
select:focus,
textarea:focus,
button:focus,
a:focus {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05em;
    font-family: inherit;
    font-weight: 600;
    min-height: var(--tap);
    min-width: var(--tap);
    padding: 0.6em 1.3em;
    margin-top: 1.2em;
    border: none;
    border-radius: var(--radius);
    background: var(--color-accent);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    text-align: center;
}

button:hover,
.button:hover {
    background: var(--color-accent-hover);
    color: #fff;
}

/* Главная кнопка формы: на телефоне во всю ширину и повыше — по ней
   попадают не глядя, держа очередь. */
.button-big {
    width: 100%;
    min-height: 60px;
    font-size: 1.2em;
    margin-top: 1.5em;
}

button.secondary,
.button-secondary {
    background: transparent;
    color: var(--color-text);
    border: 2px solid var(--color-border);
    margin-top: 0;
}

button.secondary:hover,
.button-secondary:hover {
    background: #f2ede6;
    color: var(--color-text);
}

.button-danger {
    background: transparent;
    color: var(--color-error-text);
    border: 2px solid var(--color-error-text);
}

.button-danger:hover {
    background: var(--color-error-text);
    color: #fff;
}

.form-actions {
    display: flex;
    gap: 0.6em;
    align-items: center;
    margin-top: 1.5em;
    flex-wrap: wrap;
}

.form-actions .button-secondary { margin-top: 0; }

.form-row {
    display: flex;
    gap: 0.8em;
    flex-wrap: wrap;
}

.form-cell { flex: 1 1 100%; }
.form-cell-wide { flex: 1 1 100%; }

.form-narrow { max-width: 560px; }

.field-hint {
    margin: 0.35em 0 0;
    font-size: 0.85em;
    color: var(--color-muted);
}

.password-row {
    display: flex;
    gap: 0.5em;
    align-items: stretch;
}

.password-row input {
    flex: 1;
    min-width: 0;
}

button.show-password {
    margin-top: 0;
    font-size: 0.9em;
    padding: 0 1em;
    white-space: nowrap;
}

.search-row {
    display: flex;
    gap: 0.5em;
    margin: 1em 0;
}

.search-row input {
    flex: 1;
    min-width: 0;
}

.search-row button { margin-top: 0; }

/* --------------------------------------------------------------------- */
/* Сообщения                                                              */
/* --------------------------------------------------------------------- */

.error {
    background: var(--color-error-bg);
    color: var(--color-error-text);
    border: 2px solid var(--color-error-text);
    border-radius: var(--radius);
    padding: 0.7em 0.9em;
    font-weight: 600;
}

.notice {
    background: var(--color-notice-bg);
    border-left: 5px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.8em 1em;
    max-width: 70ch;
}

.notice-warning {
    background: var(--color-warning-bg);
    border-left-color: var(--color-warning-text);
    color: var(--color-warning-text);
    font-weight: 600;
}

.notice-ok {
    background: var(--color-ok-bg);
    border-left-color: var(--color-ok-text);
    color: var(--color-ok-text);
    font-weight: 600;
}

.tag {
    display: inline-block;
    font-size: 0.75em;
    font-weight: 700;
    padding: 0.15em 0.6em;
    border-radius: 999px;
    background: var(--color-border-light);
    color: var(--color-muted);
    vertical-align: middle;
}

.tag-warning { background: var(--color-warning-bg); color: var(--color-warning-text); }
.tag-danger { background: var(--color-error-bg); color: var(--color-error-text); }

/* --------------------------------------------------------------------- */
/* Вход                                                                   */
/* --------------------------------------------------------------------- */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1em;
}

.card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.2em;
}

.login-form {
    width: 100%;
    max-width: 420px;
}

/* --------------------------------------------------------------------- */
/* Верхняя панель и меню                                                  */
/* --------------------------------------------------------------------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8em;
    padding: 0.7em 1em;
    border-bottom: 1px solid var(--color-border);
}

.topbar-info {
    display: flex;
    flex-direction: column;
    gap: 0.1em;
    text-decoration: none;
    color: var(--color-text);
    min-width: 0;
}

.topbar-info strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-info .muted { font-size: 0.85em; }

.topbar form { flex-shrink: 0; }

.topbar button {
    margin-top: 0;
    padding: 0.4em 0.9em;
    font-size: 0.9em;
    min-height: 44px;
}

/* Меню на телефоне прокручивается вбок: пунктов много, экран узкий. */
.mainnav {
    display: flex;
    gap: 0.25em;
    padding: 0.5em 1em;
    border-bottom: 1px solid var(--color-border);
    background: #faf8f5;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    min-height: 44px;
    padding: 0 0.9em;
    border-radius: var(--radius);
    color: var(--color-text);
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
}

.nav-link:hover { background: #efe9e1; }

.nav-link-active {
    background: var(--color-accent);
    color: #fff;
}

.nav-link-active:hover { background: var(--color-accent-hover); color: #fff; }

.content {
    padding: 1em;
    max-width: 1200px;
}

.page-head { margin-bottom: 1em; }

.page-actions {
    display: flex;
    gap: 0.5em;
    flex-wrap: wrap;
    margin-top: 0.8em;
}

.page-actions .button { margin-top: 0; }

/* --------------------------------------------------------------------- */
/* Плитки на главной                                                      */
/* --------------------------------------------------------------------- */

.tiles {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.8em;
    margin-top: 1.2em;
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 0.25em;
    padding: 1.1em;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--color-text);
    background: #fff;
    min-height: 76px;
    justify-content: center;
}

.tile:hover { background: #f7f3ee; border-color: var(--color-accent); }

/* Главные действия выделены: за ними приходят чаще всего. */
.tile-primary {
    border-color: var(--color-accent);
    border-width: 3px;
}

.tile-title { font-size: 1.15em; font-weight: 700; }
.tile-hint { color: var(--color-muted); font-size: 0.9em; }

/* --------------------------------------------------------------------- */
/* Приём записки                                                          */
/* --------------------------------------------------------------------- */

.note-form { max-width: 800px; }

/* Радиокнопки типа записки не видны, но остаются доступными с клавиатуры:
   переключение нарисовано на подписях к ним. */
.kind-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.kind-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5em;
    margin-bottom: 1.2em;
}

.kind-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 58px;
    margin: 0;
    padding: 0.5em;
    border: 3px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1.1em;
    font-weight: 700;
    color: var(--color-muted);
    background: #fff;
    cursor: pointer;
    text-align: center;
}

#kind-health:checked ~ .kind-switch .kind-tab-health {
    background: var(--color-health);
    border-color: var(--color-health);
    color: #fff;
}

#kind-repose:checked ~ .kind-switch .kind-tab-repose {
    background: var(--color-repose);
    border-color: var(--color-repose);
    color: #fff;
}

/* Фокус с клавиатуры должен быть виден, хотя сама радиокнопка скрыта. */
#kind-health:focus-visible ~ .kind-switch .kind-tab-health,
#kind-repose:focus-visible ~ .kind-switch .kind-tab-repose {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}

/* Молебен служится о здравии, панихида — о упокоении: лишнее прячем,
   чтобы его нельзя было выбрать по ошибке. */
#kind-health:checked ~ .type-picker .type-panikhida,
#kind-repose:checked ~ .type-picker .type-moleben {
    display: none;
}

#kind-health:checked ~ .rank-buttons .ranks-repose,
#kind-repose:checked ~ .rank-buttons .ranks-health {
    display: none;
}

.type-picker {
    border: none;
    margin: 0 0 1em;
    padding: 0;
}

.type-picker legend {
    font-weight: 600;
    padding: 0;
    margin-bottom: 0.4em;
}

.type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5em;
}

.type-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.type-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15em;
    min-height: 62px;
    margin: 0;
    padding: 0.6em 0.5em;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    background: #fff;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}

.type-input:checked + .type-option {
    border-color: var(--color-accent);
    border-width: 3px;
    background: #f7efef;
}

.type-input:focus-visible + .type-option {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}

.type-name { font-size: 0.98em; }
.type-amount { font-size: 0.82em; color: var(--color-muted); font-weight: 400; }

.rank-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35em;
    margin-bottom: 0.5em;
}

.rank-buttons-label {
    font-size: 0.85em;
    color: var(--color-muted);
    width: 100%;
}

.ranks {
    display: contents;
}

.rank-chip {
    margin-top: 0;
    min-height: 44px;
    min-width: 44px;
    padding: 0.3em 0.75em;
    font-size: 0.92em;
    font-weight: 600;
    background: #f2ede6;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.rank-chip:hover {
    background: var(--color-accent);
    color: #fff;
}

/* Подсказка имён под полем ввода. Крупные цели: на телефоне по ним
   попадают пальцем, не глядя. */
.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4em;
    margin-top: 0.5em;
    padding: 0.5em;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    background: #faf8f5;
}

.suggestion {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-top: 0;
    min-height: 44px;
    padding: 0.25em 0.9em;
    line-height: 1.2;
    background: #fff;
    color: var(--color-text);
    border: 2px solid var(--color-accent);
}

.suggestion-name {
    font-size: 1em;
    font-weight: 600;
}

/* Показывает, по какому слову нашлось: «Георгия» под ним «Юрий».
   Иначе непонятно, почему на «Юрий» предлагают «Георгия». */
.suggestion-via {
    font-size: 0.72em;
    font-weight: 400;
    color: var(--color-muted);
}

.suggestion:hover {
    background: var(--color-accent);
    color: #fff;
}

.suggestion:hover .suggestion-via {
    color: #f0dede;
}

/* --------------------------------------------------------------------- */
/* Вход по PIN на общем устройстве                                        */
/* --------------------------------------------------------------------- */

.pin-page {
    max-width: 560px;
    margin: 0 auto;
    padding: 1.5em 1em 3em;
    text-align: center;
}

.pin-lead {
    font-size: 1.15em;
    margin: 0.5em 0 1.2em;
}

.people {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.6em;
}

.person {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    padding: 0.6em 1em;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--color-text);
    font-size: 1.15em;
    font-weight: 600;
    text-decoration: none;
}

.person:hover {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

.pin-form label { text-align: left; }

/* Цифры PIN — крупно и вразрядку: набирают их вслепую, глядя на очередь. */
.pin-input {
    font-size: 2em;
    letter-spacing: 0.4em;
    text-align: center;
    min-height: 64px;
}

.pin-footer {
    margin-top: 1.5em;
    font-size: 0.95em;
}

/* --------------------------------------------------------------------- */
/* Отпуск предметов                                                       */
/* --------------------------------------------------------------------- */

.release-head {
    display: flex;
    gap: 0.6em;
    align-items: stretch;
    flex-wrap: wrap;
    margin-bottom: 1em;
}

.item-search {
    flex: 1 1 14em;
    min-width: 0;
    font-size: 1.1em;
}

.undo-form { flex: 0 0 auto; }

.undo-form button {
    margin-top: 0;
    height: 100%;
    flex-direction: column;
    gap: 0.1em;
    font-size: 0.95em;
    padding: 0.4em 1em;
}

.undo-sum { font-size: 0.85em; opacity: 0.85; }

.tile-group h2 { margin: 1em 0 0.5em; font-size: 1.05em; }

.item-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5em;
}

/* Плитка предмета: крупная цель под палец, сумма всегда видна. */
.item-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15em;
    margin-top: 0;
    min-height: 82px;
    padding: 0.6em 0.5em;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--color-text);
    text-align: center;
    line-height: 1.25;
}

.item-tile:hover {
    background: #f7efef;
    border-color: var(--color-accent);
    color: var(--color-text);
}

.item-tile-name { font-weight: 600; font-size: 0.98em; }
.item-tile-amount { font-size: 0.95em; color: var(--color-accent); font-weight: 700; }

/* Предмет, которого нет по учёту, отпускать не запрещаем: в храме
   бумажный остаток важнее программного. Только помечаем. */
.item-tile[data-empty] { border-style: dashed; }

.item-tile-warning {
    font-size: 0.72em;
    color: var(--color-warning-text);
    background: var(--color-warning-bg);
    border-radius: 999px;
    padding: 0 0.5em;
}

/* --- Корзина: прижата к низу и всегда на виду --- */

.cart {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 1.2em -1em 0;
    padding: 0.6em 1em 0.8em;
    background: #fff;
    border-top: 3px solid var(--color-accent);
    box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.09);
}

.cart-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 0;
    padding: 0.4em 0.2em;
    background: none;
    border: none;
    color: var(--color-text);
    font-size: 1em;
    font-weight: 600;
    min-height: 44px;
}

.cart-toggle:hover { background: none; color: var(--color-text); }
.cart-caret { color: var(--color-muted); }

.cart-lines { width: 100%; border-collapse: collapse; }

.cart-lines td {
    padding: 0.35em 0.2em;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
}

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

.cart-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3em;
    white-space: nowrap;
}

.cart-step {
    margin-top: 0;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    font-size: 1.3em;
    font-weight: 700;
    background: #f2ede6;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.cart-step:hover { background: var(--color-accent); color: #fff; }

.cart-count { min-width: 2em; text-align: center; font-weight: 700; }
.cart-sum { white-space: nowrap; font-weight: 600; }

.cart-payment {
    display: flex;
    gap: 0.4em;
    flex-wrap: wrap;
    margin-top: 0.7em;
}

.cart-radio {
    display: flex;
    align-items: center;
    gap: 0.4em;
    margin: 0;
    padding: 0.4em 0.8em;
    min-height: 44px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
}

.cart-radio input { width: 20px; height: 20px; min-height: 20px; }

.cart-actions {
    display: flex;
    gap: 0.5em;
    align-items: stretch;
    margin-top: 0.7em;
}

.cart-actions .button-big { flex: 1; margin-top: 0; min-height: 56px; }
.cart-actions .secondary { margin-top: 0; flex: 0 0 auto; }

/* --------------------------------------------------------------------- */
/* Требы: крупные кнопки                                                  */
/* --------------------------------------------------------------------- */

.rite-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.7em;
    margin-top: 1em;
}

.rite-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2em;
    min-height: 110px;
    padding: 0.9em 0.6em;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--color-text);
    text-decoration: none;
    text-align: center;
}

.rite-button:hover {
    background: #f7f3ee;
    border-color: var(--color-accent);
}

.rite-icon { font-size: 1.9em; line-height: 1; }
.rite-name { font-weight: 700; font-size: 1.02em; }
.rite-amount { color: var(--color-muted); font-size: 0.88em; }

.rite-chosen {
    display: flex;
    align-items: center;
    gap: 0.5em;
    margin: 0 0 0.5em;
    font-size: 1.3em;
    font-weight: 700;
}

.inline-form { display: inline; }

.link-button {
    margin: 0;
    padding: 0.2em 0.5em;
    min-height: 44px;
    background: none;
    border: none;
    color: var(--color-accent);
    font-size: 0.95em;
    text-decoration: underline;
}

.link-button:hover { background: none; color: var(--color-accent-hover); }

/* Блок настройки одного вида поминовения. */
.rate-block {
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius);
    padding: 0.8em 1em 1em;
    margin: 0 0 1em;
}

.rate-block legend {
    font-weight: 700;
    padding: 0 0.4em;
}

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

.error-page {
    max-width: 560px;
    margin: 0 auto;
    padding: 3em 1.2em;
}

.error-message {
    font-size: 1.15em;
    margin: 0.5em 0 1em;
}

.error-page .page-actions { margin-top: 1.5em; }

.readonly-value {
    margin: 0;
    padding: 0.6em 0.8em;
    border: 2px solid var(--color-border-light);
    border-radius: var(--radius);
    background: #f7f5f2;
    color: var(--color-muted);
}

/* --------------------------------------------------------------------- */
/* Записка: карточка и списки                                             */
/* --------------------------------------------------------------------- */

.note-card {
    border: 3px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1em;
    margin-bottom: 1em;
    background: #fff;
}

.note-card-health { border-color: var(--color-health); }
.note-card-repose { border-color: var(--color-repose); }

.note-card-head {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
    align-items: baseline;
    margin-bottom: 0.6em;
    padding-bottom: 0.6em;
    border-bottom: 1px solid var(--color-border-light);
}

.note-kind { font-size: 1.2em; font-weight: 700; }
.note-commemoration { color: var(--color-muted); }

.note-names {
    margin: 0;
    padding-left: 1.4em;
    font-size: 1.15em;
}

.note-names li { margin-bottom: 0.25em; }

.rank {
    font-style: italic;
    font-size: 0.85em;
    color: var(--color-muted);
}

.note-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.note-row {
    border: 1px solid var(--color-border-light);
    border-left: 5px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 0.5em;
}

.note-row-health { border-left-color: var(--color-health); }
.note-row-repose { border-left-color: var(--color-repose); }
.note-row-reversed { opacity: 0.55; }

.note-row a {
    display: flex;
    flex-direction: column;
    gap: 0.2em;
    padding: 0.8em 1em;
    text-decoration: none;
    color: var(--color-text);
    min-height: var(--tap);
}

.note-row a:hover { background: #faf8f5; }

.note-row-head {
    display: flex;
    gap: 0.5em;
    align-items: baseline;
    flex-wrap: wrap;
    font-size: 0.88em;
}

.note-kind-small { font-weight: 700; }
.note-row-names { font-size: 1.05em; }
.note-row-dates { font-size: 0.85em; }

/* --------------------------------------------------------------------- */
/* Календарь поминовения                                                  */
/* --------------------------------------------------------------------- */

.day-nav {
    display: flex;
    gap: 0.5em;
    flex-wrap: wrap;
    margin-bottom: 1.2em;
}

.day-nav .button { margin-top: 0; }

.two-columns {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5em;
}

.commemoration-names {
    margin: 0;
    padding-left: 1.5em;
    font-size: 1.1em;
}

.commemoration-names li { margin-bottom: 0.2em; }

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

/* На узком экране широкая таблица прокручивается вбок, а не ломает
   страницу. */
.grid {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1em;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
}

.grid th,
.grid td {
    padding: 0.65em 0.7em;
    border-bottom: 1px solid var(--color-border-light);
    text-align: left;
    vertical-align: middle;
}

.grid thead th {
    border-bottom: 2px solid var(--color-border);
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-muted);
}

.grid tfoot th {
    border-top: 2px solid var(--color-border);
    border-bottom: none;
    font-size: 1em;
}

.grid .num { text-align: right; white-space: nowrap; }

.grid tbody tr:hover { background: #faf8f5; }

.row-inactive td { color: var(--color-muted); }
.row-low { background: var(--color-warning-bg); }
.row-negative { background: var(--color-error-bg); }

.lines-table td input,
.lines-table td select { margin: 0; }

/* --------------------------------------------------------------------- */
/* Карточка фактов и отмена                                               */
/* --------------------------------------------------------------------- */

.facts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.15em;
    margin: 1em 0;
}

.facts dt {
    font-weight: 600;
    color: var(--color-muted);
    font-size: 0.9em;
}

.facts dd { margin: 0 0 0.6em; }

.danger-zone {
    display: flex;
    flex-direction: column;
    gap: 0.6em;
    margin-top: 2.5em;
    padding-top: 1.5em;
    border-top: 1px solid var(--color-border-light);
}

.danger-zone button { margin-top: 0; }
.danger-zone .muted { font-size: 0.9em; }

/* --------------------------------------------------------------------- */
/* Планшет и компьютер                                                    */
/* --------------------------------------------------------------------- */

@media (min-width: 640px) {
    h1 { font-size: 1.8em; }
    h2 { font-size: 1.25em; }

    .content { padding: 1.5em; }
    .topbar { padding: 1em 1.5em; }
    .mainnav { padding: 0.6em 1.5em; flex-wrap: wrap; overflow-x: visible; }

    .card { padding: 2em; }

    .form-cell { flex: 1 1 12em; }
    .form-cell-wide { flex: 2 1 20em; }

    .page-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1em;
        flex-wrap: wrap;
    }

    .page-actions { margin-top: 0; }

    .tiles { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

    .people { grid-template-columns: 1fr 1fr; }

    .rite-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

    .button-big { width: auto; min-width: 280px; }

    .facts {
        grid-template-columns: max-content 1fr;
        gap: 0.4em 1.2em;
    }

    .facts dd { margin-bottom: 0; }

    .danger-zone {
        flex-direction: row;
        align-items: center;
        gap: 1em;
    }

    /* На широком экране таблица снова обычная. */
    .grid {
        display: table;
        white-space: normal;
    }

    .note-row a {
        flex-direction: row;
        align-items: baseline;
        gap: 1em;
    }

    .note-row-head { flex: 0 0 14em; }
    .note-row-names { flex: 1; }
}

@media (min-width: 900px) {
    .two-columns { grid-template-columns: 1fr 1fr; gap: 2.5em; }
}

/* --------------------------------------------------------------------- */
/* Печать обычных страниц (акт инвентаризации и прочее)                   */
/* --------------------------------------------------------------------- */

@media print {
    .topbar,
    .mainnav,
    .page-actions,
    .danger-zone,
    .day-nav,
    .search-row,
    .notice {
        display: none !important;
    }

    body { font-size: 12pt; }

    .content { padding: 0; max-width: none; }

    .grid {
        display: table;
        white-space: normal;
    }

    .grid th,
    .grid td { border-bottom: 1px solid #999; }

    .row-low,
    .row-negative { background: none; }
}
