html {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: #f3f5f7;
    color: #1f2937;
}

.container {
    max-width: min(980px, 100%);
    margin: 0 auto;
    padding: 24px;
    overflow-x: hidden;
    box-sizing: border-box;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
    flex-shrink: 0;
}

.main-nav {
    display: flex;
    gap: 14px;
    align-items: center;
    font-size: 15px;
}

.main-nav a {
    color: #2563eb;
    text-decoration: none;
}

.main-nav a:hover {
    text-decoration: underline;
}

.user-box {
    display: flex;
    gap: 12px;
    align-items: center;
}

.card {
    background: #fff;
    border-radius: 10px;
    padding: 18px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    margin-bottom: 16px;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.card.wizard {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.wizard-body {
    min-width: 0;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Область с прокруткой кнопок забирает свободную высоту окна */
.wizard-body > .vk-scroll,
.wizard-body > .vk-grid.vk-scroll {
    flex: 1 1 auto;
    min-height: 6rem;
    max-height: none !important;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.wizard-body > .field-hint:first-child {
    flex-shrink: 0;
}

.wizard-meta-footer {
    flex-shrink: 0;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.auth-card {
    max-width: 420px;
    margin: 24px auto;
}

.form-grid {
    display: grid;
    gap: 12px;
}

label {
    display: grid;
    gap: 6px;
    font-size: 14px;
}

input,
select,
button {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
}

button {
    cursor: pointer;
    background: #2563eb;
    color: #fff;
    border: none;
}

button:hover {
    background: #1d4ed8;
}

.alerts {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.alert {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    white-space: pre-line;
}

.alert-success {
    background: #ecfdf3;
    color: #065f46;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
}

.hidden {
    display: none;
}

.balances-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.hint {
    font-size: 14px;
}

/* ——— Опросник и «виртуальная клавиатура» ——— */

.wizard-head {
    margin-bottom: 16px;
    flex-shrink: 0;
}

.wizard-summary {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.summary-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 12px;
    font-size: 14px;
    line-height: 1.35;
}

.summary-label {
    color: #64748b;
    min-width: 7.5rem;
    flex-shrink: 0;
}

.summary-value {
    color: #1f2937;
    font-weight: 500;
    word-break: break-word;
}

.summary-row-date .summary-value {
    flex: 1 1 auto;
    min-width: 0;
}

.summary-edit-date {
    font-size: 13px;
    color: #2563eb;
    text-decoration: none;
    white-space: nowrap;
}

.summary-edit-date:hover {
    text-decoration: underline;
}

.wizard-question {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 12px 0;
}

.wizard-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
}

.wizard-form-comment {
    flex: 0 0 auto;
    max-width: 100%;
}

.wizard-form-comment .field-hint {
    margin-top: 4px;
}

.field-label {
    font-size: 14px;
    font-weight: 500;
}

.field-input {
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 16px;
}

.field-hint {
    font-size: 13px;
    color: #64748b;
    margin: 8px 0 4px 0;
}

.field-error {
    color: #b91c1c;
    font-size: 14px;
}

.wizard-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.wizard-actions-split {
    justify-content: flex-start;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px 18px;
    font-size: 15px;
    cursor: pointer;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #e2e8f0;
    color: #1e293b;
    border: none;
    border-radius: 10px;
    padding: 12px 18px;
    font-size: 15px;
    cursor: pointer;
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-inline {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.btn-ghost {
    background: transparent;
    color: #64748b;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    cursor: pointer;
}

.btn-ghost:hover {
    border-color: #94a3b8;
    color: #334155;
}

.btn-confirm {
    width: 100%;
    max-width: 420px;
}

/* Виртуальная клавиатура — CSS Grid, без горизонтального скролла */
.vk-form {
    display: block;
    margin: 0;
    padding: 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
}

.vk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), max-content));
    justify-content: start;
    justify-items: start;
    gap: 8px;
    margin: 12px 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Режимы — компактно, без растягивания на всю ширину */
.vk-grid-mode {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 10rem), max-content));
    justify-content: start;
}

/* Быстрые даты — плотная сетка, перенос строк */
.vk-grid-dates {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 4.75rem), 1fr));
}

.vk-grid-dates .vk-btn {
    font-size: 13px;
}

/* Имена — компактная сетка без «размазывания» по ширине окна */
.vk-grid-tight {
    max-width: 100%;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), max-content));
    justify-content: start;
}

/* Базовые стили прокрутки; внутри .wizard-body высота задаётся flex (см. выше) */
.vk-scroll {
    max-height: clamp(6rem, calc(100dvh - 14rem), 28rem);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
    -webkit-overflow-scrolling: touch;
}

/* Много категорий — ячейки переносятся, текст внутри кнопки переносится */
.vk-categories {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 7.5rem), max-content));
    justify-content: start;
}

.vk-btn {
    min-height: 44px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 10px 10px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
    font-size: 14px;
    cursor: pointer;
    color: #0f172a;
    line-height: 1.3;
    word-break: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
}

.vk-btn:hover {
    border-color: #2563eb;
    background: #eff6ff;
}

.vk-btn-wide {
    text-align: center;
}

.vk-btn-large {
    font-size: 16px;
    font-weight: 600;
}

.vk-btn-cat {
    font-size: 13px;
    text-align: left;
}

@media (max-width: 420px) {
    .vk-grid-tight {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 100%), max-content));
    }
}

.review-list {
    display: grid;
    grid-template-columns: minmax(0, 140px) minmax(0, 1fr);
    gap: 8px 16px;
    margin: 0 0 20px 0;
    font-size: 15px;
    min-width: 0;
}

@media (max-width: 520px) {
    .review-list {
        grid-template-columns: 1fr;
    }

    .review-list dt {
        margin-top: 8px;
    }

    .review-list dt:first-child {
        margin-top: 0;
    }
}

.review-list dt {
    color: #64748b;
    margin: 0;
}

.review-list dd {
    margin: 0;
    font-weight: 500;
}

.wizard-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 16px;
    padding-top: 0;
    border-top: none;
    flex-shrink: 0;
}

.nav-form {
    display: inline;
    margin: 0;
}

.date-bar {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
    margin: 0 0 12px 0;
}

.date-bar-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    font-size: 15px;
}

.date-bar-label {
    color: #64748b;
}

.date-bar-value {
    font-variant-numeric: tabular-nums;
}

.date-bar-link {
    color: #2563eb;
    font-size: 14px;
    text-decoration: none;
}

.date-bar-link:hover {
    text-decoration: underline;
}

.cache-meta {
    font-size: 13px;
    color: #64748b;
    margin: 0;
    line-height: 1.5;
}

.cache-line {
    margin: 0 0 8px 0;
}

.cache-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin: 0;
}

.cache-sep {
    color: #94a3b8;
    user-select: none;
}

.inline-refresh {
    display: inline-block;
    margin: 0;
    padding: 0;
    vertical-align: baseline;
}

.link-button {
    background: none;
    border: none;
    color: #2563eb;
    cursor: pointer;
    font: inherit;
    padding: 0;
    text-decoration: underline;
}

.link-button:hover {
    color: #1d4ed8;
}

.balances-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.btn-link {
    color: #2563eb;
    text-decoration: none;
    font-size: 15px;
}

.btn-link:hover {
    text-decoration: underline;
}
