:root {
    --bg: #f6f3ee;
    --surface: #fffdf8;
    --text: #202124;
    --muted: #65615b;
    --line: #d9d0c3;
    --primary: #176f66;
    --primary-dark: #0f4f49;
    --accent: #c8752d;
    --danger: #b33a2f;
    --shadow: 0 18px 45px rgba(32, 33, 36, 0.10);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

a {
    color: inherit;
}

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

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 34px;
    align-items: start;
    min-height: calc(100vh - 178px);
}

.hero-copy {
    padding: clamp(24px, 7vw, 88px) 0 24px;
}

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

h1,
h2 {
    margin: 0;
    line-height: 1.08;
}

h1 {
    max-width: 820px;
    font-size: clamp(2.4rem, 6vw, 5.6rem);
}

h2 {
    font-size: 1.35rem;
}

.lead {
    max-width: 740px;
    margin: 24px 0 0;
    color: var(--muted);
    font-size: 1.18rem;
}

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

.start-form {
    display: grid;
    gap: 16px;
    margin-top: 42px;
    padding: 24px;
}

label {
    display: grid;
    gap: 7px;
    font-weight: 700;
}

label span {
    color: var(--muted);
    font-size: 0.88rem;
}

input,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid #bdb4a8;
    border-radius: 6px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    padding: 9px 11px;
}

input:focus,
select:focus {
    outline: 3px solid rgba(23, 111, 102, 0.20);
    border-color: var(--primary);
}

.primary-button,
.secondary-button,
.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border-radius: 6px;
    border: 1px solid transparent;
    padding: 10px 16px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.primary-button {
    background: var(--primary);
    color: #fff;
}

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

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

.secondary-button:hover {
    border-color: var(--primary);
}

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

.danger-button:hover {
    background: #8f2d25;
}

.instruction-band {
    max-width: 760px;
    margin-top: 28px;
    padding: 22px 0 0;
    border-top: 1px solid var(--line);
}

.instruction-band h2 {
    font-size: 1.25rem;
}

.instruction-band p,
.muted {
    color: var(--muted);
}

.alert {
    border: 1px solid rgba(179, 58, 47, 0.28);
    border-radius: 6px;
    background: rgba(179, 58, 47, 0.08);
    color: #7f2118;
    padding: 12px;
}

.alert p {
    margin: 0;
}

.content-panel {
    padding: clamp(18px, 4vw, 34px);
}

.section-heading {
    margin-bottom: 22px;
}

.section-heading p:last-child {
    max-width: 720px;
    color: var(--muted);
}

.maze-scroll {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 10px;
}

.maze-board {
    position: relative;
    min-width: 880px;
    height: var(--board-height);
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(23, 111, 102, 0.08), transparent 18%, transparent 82%, rgba(200, 117, 45, 0.10)),
        #fff;
}

.maze-lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.maze-lines path {
    fill: none;
    stroke: #30343b;
    stroke-width: 1.25;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.78;
}

.maze-node {
    position: absolute;
    z-index: 2;
    height: 32px;
    background: #fff;
    border: 1px solid #a8a096;
    border-radius: 6px;
}

.maze-node-left {
    left: 14px;
    width: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.maze-node-right {
    right: 14px;
    width: 94px;
    display: grid;
    grid-template-columns: 28px 1fr;
    align-items: center;
    gap: 6px;
    padding: 3px 5px;
}

.maze-node-right span {
    color: var(--muted);
    font-size: 0.78rem;
    text-align: center;
}

.maze-node-right input {
    min-height: 24px;
    height: 24px;
    padding: 1px 4px;
    text-align: center;
    font-weight: 700;
}

.maze-node-right strong {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    border-radius: 4px;
    background: rgba(23, 111, 102, 0.10);
}

.result-strip,
.score-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 18px 0;
}

.result-strip span,
.score-grid div {
    min-width: 210px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.score-grid strong {
    display: block;
    margin-top: 4px;
    font-size: 2rem;
}

.test-toolbar,
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 18px;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.admin-actions form {
    margin: 0;
}

.success-alert {
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid rgba(23, 111, 102, 0.28);
    border-radius: 6px;
    background: rgba(23, 111, 102, 0.10);
    color: var(--primary-dark);
    font-weight: 700;
}

.test-toolbar h1,
.admin-header h1,
.content-panel h1,
.admin-login h1 {
    font-size: clamp(2rem, 4vw, 3.6rem);
}

.timer {
    min-width: 132px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 14px 18px;
    text-align: center;
    box-shadow: var(--shadow);
}

.timer span {
    font-size: 2rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.timer.is-low {
    color: var(--danger);
}

.test-form {
    display: grid;
    gap: 16px;
}

.form-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: flex-end;
    padding: 14px 0;
    background: linear-gradient(transparent, var(--bg) 20%);
}

.admin-login {
    display: grid;
    place-items: center;
    min-height: calc(100vh - 178px);
}

.admin-login form {
    display: grid;
    width: min(420px, 100%);
    gap: 16px;
    padding: 24px;
}

.table-panel {
    overflow-x: auto;
    margin-bottom: 18px;
}

.table-panel h2 {
    padding: 18px 18px 0;
    font-size: 1.2rem;
}

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

.stat-card {
    min-height: 112px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 2rem;
    line-height: 1;
}

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

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

.chart-panel {
    margin-bottom: 18px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

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

.bar-chart {
    display: grid;
    gap: 10px;
}

.bar-row {
    display: grid;
    grid-template-columns: 68px minmax(120px, 1fr) 58px;
    align-items: center;
    gap: 10px;
}

.bar-label,
.bar-value {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.bar-value {
    text-align: right;
}

.bar-track {
    height: 18px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(101, 97, 91, 0.14);
}

.bar-fill {
    height: 100%;
    min-width: 2px;
    border-radius: inherit;
    background: var(--primary);
}

.bar-fill-alt {
    background: var(--accent);
}

.score-bars,
.question-bars {
    display: grid;
    align-items: end;
    gap: 6px;
    height: 190px;
    padding-top: 8px;
    border-bottom: 1px solid var(--line);
}

.score-bars {
    grid-template-columns: repeat(26, minmax(10px, 1fr));
}

.question-bars {
    grid-template-columns: repeat(25, minmax(10px, 1fr));
}

.score-bar,
.question-bar {
    display: grid;
    grid-template-rows: 1fr 18px;
    align-items: end;
    min-width: 0;
    height: 100%;
}

.score-fill,
.question-fill {
    width: 100%;
    min-height: 3px;
    border-radius: 4px 4px 0 0;
    background: var(--primary);
}

.question-fill {
    background: var(--accent);
}

.score-bar span,
.question-bar span {
    color: var(--muted);
    font-size: 0.68rem;
    text-align: center;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 880px;
}

table.compact-table {
    min-width: 0;
}

.data-table-tools {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 130px auto auto;
    align-items: end;
    gap: 12px;
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.data-table-search,
.data-table-size {
    margin: 0;
}

.data-table-search input,
.data-table-size select {
    min-height: 38px;
}

.data-table-info {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
    white-space: nowrap;
}

.data-table-pagination {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.data-table-pagination button,
.data-table-sort {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.data-table-pagination button {
    min-height: 36px;
    padding: 7px 10px;
}

.data-table-pagination button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.data-table-pagination span {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
    white-space: nowrap;
}

.data-table-sort {
    width: 100%;
    min-height: 28px;
    border: 0;
    background: transparent;
    padding: 0;
    color: inherit;
    text-align: left;
    text-transform: inherit;
}

th[data-sort="asc"] .data-table-sort::after {
    content: " ↑";
}

th[data-sort="desc"] .data-table-sort::after {
    content: " ↓";
}

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

th {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
}

td small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 0.82rem;
    font-weight: 700;
}

.status-in_progress {
    background: rgba(200, 117, 45, 0.14);
    color: #744012;
}

.status-completed {
    background: rgba(23, 111, 102, 0.13);
    color: var(--primary-dark);
}

.empty-state {
    color: var(--muted);
    text-align: center;
}

.site-footer {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 18px 0 28px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.86rem;
    text-align: center;
}

.site-footer p {
    margin: 3px 0;
}

@media (max-width: 820px) {
    .hero {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .start-form {
        margin-top: 0;
    }

    .test-toolbar,
    .admin-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .admin-actions {
        justify-content: flex-start;
    }

    .stats-cards,
    .stats-grid,
    .chart-grid {
        grid-template-columns: 1fr;
    }

    .data-table-tools {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .data-table-pagination {
        justify-content: space-between;
    }

    .score-bars,
    .question-bars {
        gap: 4px;
        overflow-x: auto;
    }
}
