:root {
    --bg: #f4f9fc;
    --panel: #ffffff;
    --ink: #333333;
    --muted: #666666;
    --line: #d9e4ea;
    --primary: #04a4e4;
    --primary-dark: #0388bd;
    --accent: #cc3366;
    --selected: #2fb344;
    --selected-bg: #f0fbf3;
    --danger: #b42318;
    --success: #126b3a;
    --shadow: 0 18px 45px rgba(51, 51, 51, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: linear-gradient(180deg, #edf8fd 0%, var(--bg) 42%);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a {
    color: var(--primary-dark);
}

.site-shell,
.admin-shell,
.admin-login {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
}

.site-shell {
    padding: 42px 0;
}

.form-panel,
.login-card,
.table-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.form-panel {
    padding: clamp(22px, 4vw, 42px);
}

.brand-row,
.admin-header,
.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand-row {
    align-items: center;
    flex-direction: column;
    text-align: center;
}

.form-actions {
    justify-content: center;
    margin-top: 22px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.brand-logo {
    display: block;
    width: min(270px, 68vw);
    height: auto;
    margin: 0 auto 14px;
}

h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.5rem);
    line-height: 1.05;
}

.step-indicator {
    color: var(--muted);
    font-weight: 700;
    white-space: nowrap;
}

.progress {
    height: 8px;
    margin: 28px 0;
    overflow: hidden;
    background: #e2edf3;
    border-radius: 999px;
}

.progress span {
    display: block;
    width: 25%;
    height: 100%;
    background: var(--primary);
    transition: width .2s ease;
}

fieldset {
    margin: 0;
    padding: 0;
    border: 0;
}

legend {
    width: 100%;
    margin-bottom: 28px;
    font-size: clamp(1.55rem, 3vw, 2.45rem);
    font-weight: 800;
    line-height: 1.15;
    text-align: center;
}

h2 {
    margin: 0;
    font-size: 1.08rem;
    line-height: 1.3;
}

.form-step {
    display: none;
}

.form-step.is-active {
    display: block;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.choice-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.category-grid {
    gap: 18px;
}

.persons-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-button {
    min-height: 156px;
    border: 2px solid var(--line);
    border-radius: 18px;
    padding: 24px 18px;
    color: var(--ink);
    background: #fff;
    font: inherit;
    font-weight: 800;
    text-align: center;
    cursor: pointer;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease, background .18s ease;
}

.choice-button:hover {
    border-color: var(--primary);
    box-shadow: 0 14px 28px rgba(51, 51, 51, .1);
    transform: translateY(-1px);
}

.choice-button.is-selected {
    border-color: var(--selected);
    color: var(--ink);
    background: var(--selected-bg);
    box-shadow: 0 12px 28px rgba(47, 179, 68, .16);
}

.category-choice {
    min-height: 178px;
}

.choice-card {
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 12px;
}

.choice-card strong {
    font-size: clamp(1rem, 2vw, 1.35rem);
    line-height: 1.2;
}

.choice-card > span:not(.choice-icon) {
    color: var(--muted);
    font-size: .95rem;
    font-weight: 700;
}

.choice-card.is-selected > span:not(.choice-icon) {
    color: var(--primary-dark);
}

.choice-icon {
    display: block;
    width: 64px;
    height: 64px;
    color: #333333;
    object-fit: contain;
}

.choice-button.is-selected .choice-icon {
    filter: brightness(0) saturate(100%) invert(46%) sepia(49%) saturate(859%) hue-rotate(81deg) brightness(93%) contrast(88%);
}

.compact-card {
    min-height: 132px;
}

.compact-card .choice-icon {
    width: 56px;
    height: 56px;
}

.field-icon {
    width: 34px;
    height: 34px;
    margin: 2px 0 -2px;
}

.question-block {
    display: grid;
    gap: 14px;
    margin-bottom: 28px;
    padding-bottom: 26px;
    border-bottom: 1px solid var(--line);
}

.question-block:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

.question-block.has-error .choice-button,
.form-step.has-error .choice-button {
    border-color: rgba(180, 35, 24, .7);
}

.form-step.has-error > .choice-grid .choice-button {
    border-color: rgba(180, 35, 24, .7);
}

.field-error {
    display: none;
    margin: 0;
    color: var(--danger);
    font-weight: 700;
}

.question-block.has-error .field-error {
    display: block;
}

.form-step.has-error > .field-error {
    display: block;
    margin-top: 14px;
    text-align: center;
}

.conditional-field {
    margin: 2px 0 0;
}

.conditional-field[hidden] {
    display: none;
}

.placeholder-box {
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f6f9fa;
}

.placeholder-box h2 {
    font-size: clamp(1.4rem, 3vw, 2rem);
}

label {
    display: grid;
    gap: 7px;
    margin-bottom: 16px;
    color: #2a3840;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #c7d1d6;
    border-radius: 6px;
    padding: 12px 13px;
    color: var(--ink);
    background: #fff;
    font: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(4, 164, 228, .22);
    border-color: var(--primary);
}

.check-row {
    grid-template-columns: 22px 1fr;
    align-items: start;
    font-weight: 600;
}

.check-row input {
    width: 18px;
    height: 18px;
    margin-top: 3px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 1px solid var(--primary);
    border-radius: 6px;
    padding: 0 18px;
    color: #fff;
    background: var(--primary);
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

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

.button:disabled {
    border-color: #c9d3d8;
    color: #7c8991;
    background: #e9eef0;
    cursor: not-allowed;
}

.button:disabled:hover {
    background: #e9eef0;
}

.button.secondary {
    color: var(--ink);
    background: #fff;
    border-color: var(--line);
}

.button.secondary:hover {
    background: #f0f4f5;
}

.button.small {
    min-height: 34px;
    padding: 0 12px;
    font-size: .85rem;
}

.button[hidden] {
    display: none;
}

.choice-button[hidden] {
    display: none;
}

.form-message {
    min-height: 28px;
    margin: 18px 0 8px;
    font-weight: 700;
}

.form-message.error,
.alert.error {
    color: var(--danger);
}

.form-message.success {
    color: var(--success);
}

.review-box {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.review-item {
    padding: 12px;
    background: #f6f9fa;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.review-item span {
    display: block;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 700;
}

.notice {
    margin: 18px 0 0;
    color: var(--muted);
}

.check-list {
    display: grid;
    gap: 10px;
    margin-top: 24px;
}

.check-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f6f9fa;
}

.check-item strong {
    min-width: 70px;
}

.check-item.ok strong {
    color: var(--success);
}

.check-item.fail strong {
    color: var(--danger);
}

.admin-login {
    display: grid;
    min-height: 100vh;
    place-items: center;
}

.login-card {
    width: min(420px, 100%);
    padding: 28px;
}

.login-card h1 {
    margin-bottom: 22px;
    font-size: 2rem;
}

.admin-shell {
    padding: 32px 0;
}

.admin-header {
    margin-bottom: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stats-grid article {
    padding: 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.stats-grid strong {
    display: block;
    font-size: 2rem;
    line-height: 1;
}

.stats-grid span {
    color: var(--muted);
    font-weight: 700;
}

.table-panel {
    overflow: hidden;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.detail-panel {
    padding: 20px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.detail-panel h2 {
    margin-bottom: 16px;
    font-size: 1.2rem;
}

.detail-panel dl {
    display: grid;
    grid-template-columns: minmax(150px, .45fr) minmax(0, 1fr);
    gap: 10px 16px;
    margin: 0;
}

.detail-panel dt {
    color: var(--muted);
    font-weight: 800;
}

.detail-panel dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.json-box {
    overflow-x: auto;
    margin: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f6f9fa;
    font-size: .9rem;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
    font-size: .93rem;
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    background: #f6f9fa;
    font-size: .78rem;
    text-transform: uppercase;
}

.status {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 9px;
    background: #e8f2f1;
    color: var(--primary-dark);
    font-weight: 800;
}

@media (max-width: 760px) {
    .brand-row,
    .admin-header,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .grid.two,
    .choice-grid,
    .choice-grid.three,
    .persons-grid,
    .review-box,
    .detail-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .detail-panel dl {
        grid-template-columns: 1fr;
    }

    .category-choice {
        min-height: 146px;
    }

    .form-actions .button {
        width: 100%;
    }
}
