* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: #f2f4f8;
    color: #1c1e21;
    line-height: 1.5;
}
.container { max-width: 680px; margin: 0 auto; padding: 16px; }
.container.wide { max-width: 1100px; }
h1 { font-size: 1.5rem; margin: 12px 0; }
h2 { font-size: 1.2rem; margin: 20px 0 8px; }
a { color: #2f6fed; }
a.card { display: block; text-decoration: none; color: inherit; }
.muted { color: #6b7280; }
.card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
label { display: block; margin: 10px 0 4px; font-weight: 600; }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=tel], textarea, select {
    width: 100%;
    padding: 12px;
    font-size: 16px; /* предотвращает авто-зум на iOS */
    border: 1px solid #c9ced6;
    border-radius: 8px;
    margin-top: 4px;
    background: #fff;
}
.row select { flex: 1; width: auto; }
input:focus, textarea:focus { outline: 2px solid #2f6fed55; border-color: #2f6fed; }
.btn {
    display: inline-block;
    padding: 12px 20px;
    background: #2f6fed;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: #255ecf; }
.btn-block { display: block; width: 100%; text-align: center; margin: 16px 0; }
.btn-secondary { background: #e8ecf3; color: #1c1e21; }
.btn-secondary:hover { background: #d9dfe9; }
.btn-danger { background: #b02a37; }
.btn-danger:hover { background: #93232e; }
.btn-small { padding: 8px 12px; font-size: .9rem; }
.link-btn { background: none; border: none; color: #b02a37; cursor: pointer; font-size: .9rem; }
.option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid #c9ced6;
    border-radius: 8px;
    margin: 8px 0;
    background: #fff;
    font-weight: 400;
    cursor: pointer;
}
.option input[type=checkbox], .option input[type=radio] { transform: scale(1.4); flex: none; }
.option input[type=number] {
    flex: none;
    width: 70px;
    margin-top: 0;
    padding: 8px;
    text-align: center;
}
.option:has(input:checked) { border-color: #2f6fed; background: #eef3fe; }
.timer {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
    border-radius: 0 0 12px 12px;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    padding: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}
.timer.danger { color: #c1121f; }
.flash {
    background: #fff3cd;
    border: 1px solid #ffe08a;
    border-radius: 8px;
    padding: 10px 12px;
    margin: 10px 0;
}
.q-text { font-weight: 600; margin-bottom: 8px; }
.q-images { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.q-images img {
    width: 110px;
    height: 110px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #ddd;
}
.q-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.opt-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.opt-row input[type=text] { margin-top: 0; }
.code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 2px;
    background: #eef3fe;
    border-radius: 6px;
    padding: 4px 10px;
}
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .8rem; }
.badge-ok { background: #d7f5df; color: #1e7a34; }
.badge-bad { background: #fbdcdc; color: #a11; }
.badge-warn { background: #fff3cd; color: #8a6d00; }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    background: #fff;
    border-radius: 12px;
    padding: 10px 16px;
    margin: 12px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; font-size: 1.15rem; line-height: 1; padding: 4px 6px; border-radius: 8px; user-select: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover { background: #f1f3f7; }
.menu-list {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
    padding: 8px;
    min-width: 170px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.menu-user { padding: 4px 8px 8px; border-bottom: 1px solid #e5e7eb; margin-bottom: 4px; }
.menu-list a { padding: 6px 8px; border-radius: 6px; }
.menu-list a:hover { background: #f1f3f7; text-decoration: none; }
.score { font-size: 2.5rem; font-weight: 800; text-align: center; }
.result { text-align: center; }
.answer-correct { border-left: 4px solid #2e7d32; }
.answer-wrong { border-left: 4px solid #c1121f; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-actions form { display: flex; align-items: center; gap: 6px; }
.row-actions input[type=text] { width: 160px; padding: 8px 10px; font-size: 14px; margin-top: 0; }
.center { text-align: center; }
.row .q-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.q-actions { flex-shrink: 0; white-space: nowrap; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table-wrap { overflow-x: auto; }
.table th, .table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #e5e7eb; vertical-align: top; overflow-wrap: break-word; }
.table th { color: #6b7280; font-weight: 600; }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; white-space: nowrap; }
.bar { background: #eef0f4; border-radius: 999px; height: 8px; min-width: 60px; overflow: hidden; }
.table .badge { white-space: normal; }
.bar > div { height: 100%; border-radius: 999px; }
.bar-ok > div { background: #2e7d32; }
.bar-bad > div { background: #c1121f; }
.chart { width: 100%; height: auto; display: block; }
.chart .axis { stroke: #c9ced6; stroke-width: 1; }
.chart .grid { stroke: #eef0f4; stroke-width: 1; }
.chart .bar-fill { fill: #2f6fed; }
.chart .dot { fill: #2f6fed; fill-opacity: .65; }
.chart .ln { stroke: #2f6fed; stroke-width: 2; fill: none; }
.chart .lbl { font-size: 10px; fill: #6b7280; text-anchor: middle; }
.chart .lbl-start { text-anchor: start; }
.chart .mark { stroke: #e8590c; stroke-width: 1.2; stroke-dasharray: 4 3; }
.chart .mark-lbl { fill: #e8590c; font-weight: 600; }
.chart .qmark { stroke: #374151; stroke-width: 2; }
