:root {
    --bg: #f2e1cf;
    --bg-strong: #e7ceb0;
    --paper: rgba(255, 252, 247, 0.86);
    --mint: #bde7d9;
    --mint-strong: #83cdb8;
    --beige: #e8d6bf;
    --text: #000000;
    --muted: #1f1f1f;
    --line: rgba(116, 106, 97, 0.16);
    --shadow: 0 20px 50px rgba(111, 93, 72, 0.12);
    --radius-lg: 28px;
    --radius-md: 20px;
    --radius-sm: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Manrope', sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(189, 231, 217, 0.78), transparent 34%),
        radial-gradient(circle at top right, rgba(232, 214, 191, 0.9), transparent 36%),
        radial-gradient(circle at bottom left, rgba(189, 231, 217, 0.55), transparent 42%),
        var(--bg);
}

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

main {
    display: grid;
    gap: 32px;
    padding-bottom: 48px;
}

.site-footer {
    padding: 20px 0 34px;
    border-top: 1px solid rgba(68, 58, 52, 0.12);
}

.site-footer__inner {
    display: grid;
    gap: 10px;
}

.site-footer__row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: baseline;
    justify-content: space-between;
}

.site-footer__brand {
    display: grid;
    gap: 4px;
}

.site-footer__contacts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: baseline;
}

.site-footer__links {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
}

.site-footer__links a {
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(68, 58, 52, 0.12);
    background: rgba(255, 255, 255, 0.5);
}

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 24px 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand span {
    display: grid;
}

.brand strong {
    font-size: 1.1rem;
}

.brand small {
    color: var(--muted);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--mint), var(--beige));
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    object-fit: contain;
    display: block;
    position: relative;
    z-index: 2;
}

.brand-mark::before,
.brand-mark::after {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 14px;
    border: 2px dashed rgba(29, 49, 41, 0.28);
    animation: brand-spin 8.5s linear infinite;
    pointer-events: none;
    z-index: 0;
}

.brand-mark::after {
    inset: 10px;
    border-radius: 10px;
    border: 1px dotted rgba(29, 49, 41, 0.22);
    animation: brand-spin 12.5s linear infinite reverse;
}

@keyframes brand-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.nav-toggle {
    display: none;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid var(--line);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.site-nav {
    display: block;
}

.site-nav > div {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
    justify-content: flex-end;
}

.site-nav .nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
}

.site-nav .nav-user-row {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    gap: 12px;
    align-items: center;
}

.site-nav a {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.45);
}

.nav-logout {
    display: inline-flex;
    margin: 0;
}

.nav-link-button {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.45);
    border: 0;
    font: inherit;
    cursor: pointer;
}

.user-mini {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.35);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.user-mini__avatar {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--mint), var(--beige));
    color: #1e2a26;
    font-size: 0.82rem;
    font-weight: 800;
}

.user-mini__name {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-nav .nav-accent {
    background: linear-gradient(135deg, var(--mint), #d3efe4);
}

.messages {
    display: grid;
    gap: 10px;
    margin-bottom: 12px;
}

.message {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
}

.hero,
.detail-layout,
.form-layout,
.panel-grid {
    display: grid;
    gap: 24px;
}

.hero {
    grid-template-columns: 1.7fr 1fr;
    align-items: stretch;
    padding: 28px 0 12px;
}

.hero-copy h1,
.page-intro h1,
.detail-layout h1,
.dashboard-header h1 {
    margin: 10px 0 16px;
    font-size: clamp(2rem, 4vw, 4rem);
    line-height: 1.02;
}

.hero-copy p,
.page-intro p,
.lead {
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.7;
}

.hero-card,
.panel,
.category-card,
.test-card {
    padding: 28px;
    background: var(--paper);
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.form-layout {
    grid-template-columns: 1fr minmax(320px, 520px);
    align-items: start;
}

.form-card {
    display: grid;
    gap: 18px;
}

.form-field {
    display: grid;
    gap: 8px;
    font-weight: 600;
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="password"],
.form-field input[type="date"],
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.85);
    font: inherit;
    color: var(--text);
}

.form-field input[type="checkbox"] {
    width: auto;
    margin-top: 4px;
    transform: scale(1.2);
}

.choice-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid var(--line);
}

.search-row {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.search-row input[type='search'] {
    flex: 1 1 320px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.85);
    font: inherit;
    color: var(--text);
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 14px 20px;
    border-radius: 16px;
    border: 0;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.button-primary {
    background: linear-gradient(135deg, var(--mint-strong), var(--mint));
}

.button-secondary {
    background: rgba(232, 214, 191, 0.65);
}

.hero-actions,
.meta-row,
.section-heading,
.dashboard-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
}

.hero-actions .button,
.hero-actions a.button {
    height: 48px;
}

.hero-actions a.button {
    display: inline-flex;
    align-items: center;
}

.hero-stats,
.category-grid,
.test-grid {
    display: grid;
    gap: 18px;
}

.hero-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 28px;
}

.hero-stats article,
.list-card {
    padding: 20px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid var(--line);
}

.hero-stats strong {
    display: block;
    font-size: 2rem;
}

.check-list,
.dashboard-list {
    display: grid;
    gap: 14px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.category-grid,
.test-grid,
.panel-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.test-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 100%;
}

.test-card h3 {
    margin: 0;
}

.test-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
    flex: 1 1 auto;
}

.test-card .meta-row {
    margin-top: 12px;
}

.test-card a.button {
    margin-top: 12px;
    align-self: flex-start;
}

.list-card span,
.muted {
    color: var(--muted);
}

.result-table {
    width: 100%;
    border-collapse: collapse;
}
.result-table th,
.result-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
.result-table thead th {
    font-weight: 900;
    background: rgba(255, 255, 255, 0.65);
}
.result-table tbody tr:last-child td {
    border-bottom: 0;
}

.journal-table {
    table-layout: fixed;
}
.journal-table th,
.journal-table td {
    padding: 8px 10px;
    font-size: 0.9rem;
    line-height: 1.25;
}
.ta-center { text-align: center; }
.ta-right  { text-align: right; }
.text-ellipsis {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 900px) {
    .hero,
    .detail-layout,
    .form-layout {
        grid-template-columns: 1fr;
    }

    .site-header {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
    }

    .nav-toggle {
        display: inline-flex;
        justify-content: center;
        align-items: center;
    }

    .site-nav {
        grid-column: 1 / -1;
    }

    #siteNav {
        display: none;
        margin-top: 10px;
        padding: 12px;
        border-radius: var(--radius-lg);
        background: rgba(255, 252, 247, 0.92);
        border: 1px solid var(--line);
        box-shadow: var(--shadow);
        justify-content: flex-start;
    }

    #siteNav a {
        width: 100%;
        justify-content: flex-start;
    }

    .nav-open #siteNav {
        display: flex;
    }

    .hero-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .page-shell {
        width: calc(100% - 24px);
    }

    .site-header {
        padding: 18px 0;
        gap: 14px;
    }

    .brand-mark {
        width: 46px;
        height: 46px;
        border-radius: 16px;
    }

    .hero-card,
    .panel,
    .category-card,
    .test-card {
        padding: 20px;
        border-radius: 22px;
    }

    .button,
    .site-nav a,
    .nav-toggle {
        padding: 12px 16px;
    }

    .hero-actions,
    .meta-row,
    .section-heading,
    .dashboard-header {
        align-items: stretch;
    }
}

/* Timer and result accordion */
.timer-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
}
.timer-chip {
    padding: 12px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid var(--line);
}
.timer-row--sticky {
    position: sticky;
    top: 12px;
    z-index: 25;
    padding: 10px 12px;
    border-radius: var(--radius-lg);
    background: rgba(247, 241, 232, 0.92);
    border: 1px solid var(--line);
    box-shadow: 0 12px 30px rgba(111, 93, 72, 0.14);
    margin-bottom: 14px;
}
.exam-mode .timer-row--sticky {
    top: 12px;
}
.expired-overlay {
    position: fixed;
    inset: 0;
    background: rgba(247, 241, 232, 0.86);
    display: grid;
    place-items: center;
    padding: 24px;
    z-index: 30;
}
.expired-overlay > * {
    width: min(560px, calc(100% - 32px));
    text-align: center;
}
.expired-overlay strong {
    display: block;
    font-size: 2rem;
    margin-bottom: 10px;
}
.expired-overlay span {
    display: block;
    color: var(--muted);
    margin-bottom: 18px;
}
.hidden { display: none; }

.result-details {
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.55);
    overflow: hidden;
}
.result-details summary {
    cursor: pointer;
    list-style: none;
    padding: 14px 14px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(255, 255, 255, 0.6);
}
.result-details summary::-webkit-details-marker { display: none; }
.result-details summary::after { content: '▾'; opacity: 0.7; }
.result-details[open] summary::after { content: '▴'; }
.result-details > *:not(summary) { padding: 14px; }
.result-text { line-height: 1.65; color: var(--text); }

.subtest-block { border: 1px solid rgba(0, 0, 0, 0.08); background: rgba(255, 255, 255, 0.55); }
.subtest-block summary { background: rgba(255, 255, 255, 0.7); position: relative; padding-right: 14px; }
.subtest-block summary::before { content: '▾'; opacity: 0.7; position: absolute; right: 14px; top: 14px; }
.subtest-block[open] summary::before { content: '▴'; }
.subtest-block--active { border-color: rgba(131, 205, 184, 0.55); box-shadow: 0 10px 24px rgba(36, 78, 67, 0.08); }
.subtest-block--locked .question-block { opacity: 0.7; pointer-events: none; }
.subtest-summary { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; }
.subtest-summary__main { display: grid; gap: 6px; }
.subtest-summary__instruction { line-height: 1.4; }
.subtest-summary__meta { white-space: nowrap; font-weight: 800; }
@media (max-width: 900px) {
    .subtest-summary { grid-template-columns: 1fr; }
    .subtest-summary__meta { white-space: normal; }
}

/* Score scale */
.score-scale {
    display: grid;
    gap: 8px;
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.55);
}
.score-scale__bar {
    position: relative;
    height: 14px;
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.65);
    display: grid;
    grid-template-columns: 34fr 33fr 33fr;
}
.score-scale__zone--low { background: rgba(62, 160, 96, 0.22); }
.score-scale__zone--mid { background: rgba(216, 139, 46, 0.20); }
.score-scale__zone--high { background: rgba(164, 24, 24, 0.16); }
.score-scale__marker {
    position: absolute;
    top: -6px;
    left: calc(var(--pct) * 1%);
    width: 2px;
    height: 26px;
    background: rgba(0, 0, 0, 0.75);
    transform: translateX(-50%);
}
.score-scale__marker::after {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.8);
    transform: translate(-50%, -20%);
}
.score-scale__legend {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-weight: 700;
    font-size: 0.9rem;
}

.chart-wrap {
    position: relative;
    height: 380px;
    min-height: 380px;
    max-height: 380px;
}

.chart-wrap--compact {
    height: 320px;
    min-height: 320px;
    max-height: 320px;
}

.chart-wrap canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
}

.chart-note {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.chart-note__title {
    font-weight: 900;
    font-size: 1rem;
}

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

.chart-note__card {
    padding: 16px 18px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.68);
    border: 1px solid var(--line);
    display: grid;
    gap: 6px;
}

.chart-note__card strong {
    font-size: 0.96rem;
}

.chart-note__card span {
    color: var(--muted);
    line-height: 1.55;
}

.chart-note__card--accent {
    background: linear-gradient(135deg, rgba(189, 231, 217, 0.52), rgba(255, 255, 255, 0.82));
}

.sociogram-shell {
    width: 100%;
    height: 860px;
    position: relative;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255,255,255,0.82), rgba(247, 241, 232, 0.88));
    border: 1px solid var(--line);
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.65);
}

.sociometry-grid {
    display: grid;
    gap: 24px;
}

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

.sociometry-section {
    display: grid;
    gap: 16px;
}

.sociometry-header-note {
    display: grid;
    gap: 8px;
}

.sociometry-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.sociometry-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid var(--line);
    font-weight: 800;
}

.sociometry-legend__dot {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    flex: 0 0 14px;
}

.sociometry-choice-groups {
    display: grid;
    gap: 14px;
}

.sociometry-choice-list {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.sociometry-choice-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid var(--line);
}

.sociometry-rank-badge {
    min-width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-weight: 900;
    color: #fff;
}

.sociometry-rank-badge--1 { background: #d9485f; }
.sociometry-rank-badge--2 { background: #4aa886; }
.sociometry-rank-badge--3 { background: #5b8def; }

.sociometry-matrix {
    min-width: 980px;
}

.sociometry-matrix th,
.sociometry-matrix td {
    text-align: center;
    vertical-align: middle;
}

.sociometry-matrix__name {
    text-align: left !important;
    white-space: nowrap;
    font-weight: 700;
}

.sociometry-matrix__self {
    background: rgba(68, 58, 52, 0.10);
}

.sociometry-matrix__cell {
    min-width: 62px;
}

.sociometry-matrix__badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
}

.sociometry-matrix__badge {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 900;
}

.sociometry-matrix__badge--1 { background: #d9485f; }
.sociometry-matrix__badge--2 { background: #4aa886; }
.sociometry-matrix__badge--3 { background: #5b8def; }

.sociometry-matrix__cell--mutual {
    background: rgba(83, 182, 149, 0.12);
}

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

.report-chart-print {
    break-inside: avoid;
    page-break-inside: avoid;
}

.print-chart-grid {
    display: grid;
    gap: 18px;
}

.print-chart-note {
    margin-top: 12px;
}

.sociometry-index-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--line);
    font-weight: 900;
}

@media (max-width: 900px) {
    .chart-wrap {
        height: 340px;
        min-height: 340px;
        max-height: 340px;
    }

    .chart-wrap--compact {
        height: 280px;
        min-height: 280px;
        max-height: 280px;
    }

    .sociogram-shell {
        height: 620px;
    }

    .sociometry-grid--double {
        grid-template-columns: 1fr;
    }
}
