/* Quality Toolkit — оформление в общей гамме тренажёров Iowa Solutions
   (цвета, шапка, режимы и подвал как у wbs.iowasolutions.kz). */
:root {
    --bg: #eef3f8;
    --panel: #ffffff;
    --ink: #1d2733;
    --muted: #6a7a8c;
    --line: #d5dfea;
    --brand: #0f4c81;
    --brand-soft: #e6eef7;
    --accent: #1a9e8f;
    --warn: #c2410c;
    --err: #d64545;
    --ok: #2f9e44;
    --card: #f4f8fc;
    --conf: #1a9e8f;
    --int: #e0a100;
    --ext: #d64545;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(20, 40, 70, .08), 0 6px 18px rgba(20, 40, 70, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

a { color: var(--brand); }

.wrap { max-width: 1280px; margin: 0 auto; padding: 16px 18px 40px; }

/* ---------- шапка ---------- */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding: 6px 0 14px; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.brand .mark {
    flex: 0 0 38px; width: 38px; height: 38px; border-radius: 9px; background: var(--brand); color: #fff;
    display: grid; place-items: center; font-weight: 700; font-size: 17px; letter-spacing: .5px;
}
.brand h1 { margin: 0; font-size: 19px; line-height: 1.2; }
.brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.home-link { color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.home-link:hover { color: var(--brand); }

.lang button, .mode button, .btn {
    font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
    border-radius: 8px; padding: 8px 13px; transition: background .15s, border-color .15s, color .15s, transform .1s;
    min-height: 40px;
}
.btn:hover, .lang button:hover, .mode button:hover { border-color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0c3d68; }

.mode, .lang { display: inline-flex; border: 1px solid var(--line); background: var(--panel); border-radius: 9px; overflow: hidden; }
.mode button, .lang button { border: 0; border-radius: 0; padding: 8px 14px; }
.mode button + button, .lang button + button { border-left: 1px solid var(--line); }
.mode button.on, .lang button.on { background: var(--brand); color: #fff; }

details.rules {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 12px 16px; margin-bottom: 12px;
}
details.rules summary { cursor: pointer; font-weight: 600; }
details.rules ol { margin: 10px 0 0; padding-left: 20px; }
details.rules li { margin-bottom: 5px; }

/* ---------- раунды ---------- */
.rounds { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.rounds button {
    font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid var(--line);
    background: var(--panel); color: var(--ink); border-radius: 9px; padding: 9px 14px; min-height: 40px;
}
.rounds button:hover { border-color: var(--brand); }
.rounds button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.rounds button.done:not(.on) { border-color: #bfe3c6; background: #f1fbf3; color: #1f6b2c; }
.rounds button.done::after { content: " ✓"; }

.roundIntro {
    padding: 12px 14px; margin: 0 0 12px; background: var(--brand-soft); border: 1px solid var(--line);
    border-left: 4px solid var(--brand); border-radius: var(--radius); font-size: 13.5px; line-height: 1.55;
}

.bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; background: var(--panel);
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px;
}
.bar .spacer { flex: 1; }
.score { font-size: 13.5px; color: var(--muted); }
.score b { color: var(--ink); }
.points { display: inline-block; padding: 2px 9px; border-radius: 20px; background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.points b { color: var(--brand); }
.points.low { background: #fdeaea; color: var(--err); }
.points.low b { color: var(--err); }

.msg {
    min-height: 20px; margin: 0 0 12px; padding: 10px 14px; border-radius: var(--radius); background: var(--brand-soft);
    border: 1px solid #cfe0f0; color: #1b3c5c; font-size: 14px;
}
.msg:empty { display: none; }
.msg.ok { background: #e7f6ea; border-color: #bfe3c6; color: #1f6b2c; animation: flashOk .5s; }
.msg.err { background: #fdeaea; border-color: #f3c4c4; color: #9c2b2b; animation: flashErr .5s; }
@keyframes flashOk { from { transform: scale(.98); opacity: .5; } to { transform: none; opacity: 1; } }
@keyframes flashErr { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------- поле: карточка слева, линия справа ---------- */
.board { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.stage, .line, .qcard { min-width: 0; }

.dots { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.dot {
    width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); background: var(--panel);
    cursor: pointer; padding: 0;
}
.dot.cur { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.dot.done { background: #c9d8ea; }
.dot.ok { background: var(--ok); border-color: var(--ok); }
.dot.bad { background: var(--err); border-color: var(--err); }

.qcard {
    background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
    padding: 16px 18px 18px; animation: cardIn .3s ease-out;
}
@keyframes cardIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.qcard.answeredOk { border-color: #bfe3c6; }
.qcard.answeredBad { border-color: #f3c4c4; }
.qhead { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); }
.rtag { font-weight: 600; color: var(--brand); }
.qtext { font-size: 16.5px; line-height: 1.5; margin: 8px 0 12px; }

.opts { display: grid; grid-template-columns: 1fr; gap: 8px; }
.opts.four { grid-template-columns: 1fr 1fr; }
.opt {
    font: inherit; text-align: left; cursor: pointer; min-height: 48px; padding: 10px 14px; border-radius: 10px;
    border: 1.5px solid var(--line); background: var(--card); color: var(--ink); transition: border-color .15s, background .15s, transform .1s;
}
.opt:hover:not([disabled]) { border-color: var(--brand); background: #fff; }
.opt:active:not([disabled]) { transform: scale(.99); }
.opt[disabled] { cursor: default; }
.opt.picked { border-color: var(--brand); background: var(--brand-soft); }
.opt.right { border-color: var(--ok); background: #e7f6ea; color: #1f6b2c; font-weight: 600; }
.opt.wrong { border-color: var(--err); background: #fdeaea; color: #9c2b2b; animation: flashErr .4s; }
.opt.dim { opacity: .6; }

.explain { margin-top: 14px; border-radius: 10px; padding: 12px 14px; background: #f7fafc; border: 1px solid var(--line); animation: cardIn .3s; }
.explain .verdict { font-weight: 700; margin-bottom: 8px; }
.explain.good .verdict { color: var(--ok); }
.explain.bad .verdict { color: var(--err); }
.why { padding: 8px 0; border-top: 1px dashed var(--line); }
.why:first-of-type { border-top: 0; }
.why b { font-size: 14px; }
.why.isRight b { color: #1f6b2c; }
.why.isWrong b { color: #7a3030; }
.why em { font-weight: 400; color: var(--muted); }
.why p { margin: 3px 0 0; font-size: 14px; color: #33414f; }
.cardNav { display: flex; justify-content: flex-end; margin-top: 12px; }
.cardNav:empty { display: none; }

/* ---------- графики ---------- */
.chart { margin: 4px 0 14px; background: #fbfdff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.chart svg { display: block; width: 100%; height: auto; max-height: 300px; }
.chart-target svg { max-width: 240px; margin: 0 auto; }
.chart .axis { stroke: #8fa1b5; stroke-width: 1; }
.chart .tick { font-size: 11px; fill: var(--muted); }
.chart .unit { font-size: 11px; fill: var(--muted); font-style: italic; }
.chart .lbl { font-size: 11px; fill: var(--ink); }
.chart .val { font-size: 11px; fill: #33414f; font-weight: 600; }
.chart .cum { font-size: 10.5px; fill: var(--warn); font-weight: 600; }
.chart .bar { fill: #7aa6d1; }
.chart .bar.hist { fill: #8fb3d8; }
.chart .cumline { fill: none; stroke: var(--warn); stroke-width: 2; }
.chart .cumdot { fill: var(--warn); }
.chart .ref80 { stroke: var(--warn); stroke-dasharray: 4 3; opacity: .6; }
.chart .ref { fill: var(--warn); }
.chart .cl { stroke: var(--err); stroke-width: 1.4; stroke-dasharray: 6 4; }
.chart .clT { fill: var(--err); }
.chart .mean { stroke: #4a6b8a; stroke-width: 1.2; }
.chart .spec { stroke: var(--int); stroke-width: 1.6; stroke-dasharray: 2 3; }
.chart .specT { fill: #9a6b00; font-weight: 600; }
.chart .run { fill: none; stroke: #4f7fae; stroke-width: 1.4; }
.chart .pt { fill: #0f4c81; }
.chart .sdot { fill: #0f4c81; opacity: .8; }
.chart .ring { fill: none; stroke: #9fb3c8; stroke-width: 1.5; }
.chart .ring.r0 { fill: #f2f6fa; }
.chart .bull { fill: var(--err); }
.chart .hit { fill: #0f4c81; stroke: #fff; stroke-width: 1.5; }
.checksheet { width: 100%; border-collapse: collapse; font-size: 14px; }
.checksheet td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.checksheet td.num { text-align: right; font-weight: 600; width: 48px; }
.checksheet tr.sum td { border-bottom: 0; font-weight: 700; }
.checksheet .marks { white-space: normal; }
.chart svg.tally { display: inline-block; width: 30px; height: 20px; margin-right: 4px; vertical-align: middle; }
.tally path { stroke: #1d2733; stroke-width: 1.8; stroke-linecap: round; fill: none; }

/* ---------- линия последствий ---------- */
.line {
    position: sticky; top: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
    box-shadow: var(--shadow); padding: 14px; transition: opacity .2s;
}
.line.veiled .counters, .line.veiled .coq { filter: blur(5px); opacity: .5; }
.line.shake { animation: lineShake .45s; }
@keyframes lineShake { 0%, 100% { transform: none; } 20% { transform: translateX(-5px) rotate(-.4deg); } 60% { transform: translateX(5px) rotate(.4deg); } }
.lineHead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.streak { font-size: 12px; font-weight: 700; color: #fff; background: var(--err); border-radius: 20px; padding: 2px 9px; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

.belt {
    position: relative; height: 38px; border-radius: 8px; overflow: hidden; margin-bottom: 12px;
    background: repeating-linear-gradient(90deg, #3c4b5c 0 14px, #4d5d70 14px 28px);
    background-size: 28px 100%; animation: beltMove 1.2s linear infinite;
}
@keyframes beltMove { from { background-position: 0 0; } to { background-position: 28px 0; } }
.belt .end {
    position: absolute; top: 0; bottom: 0; display: grid; place-items: center; padding: 0 8px; font-size: 11px;
    font-weight: 700; color: #fff; z-index: 2;
}
.belt .plant { left: 0; background: var(--brand); }
.belt .cust { right: 0; background: #6b3a3a; }
.tok { position: absolute; left: 56px; width: 12px; height: 12px; border-radius: 3px; z-index: 1; animation-duration: 1.4s; animation-fill-mode: both; animation-timing-function: ease-in; }
.tok.good { background: #6ee7a8; animation-name: tokCaught; }
.tok.bad { background: #ff6b6b; animation-name: tokEscape; box-shadow: 0 0 6px #ff6b6b; }
@keyframes tokCaught { 0% { transform: translate(0, 0); opacity: 1; } 60% { transform: translate(60px, 0); opacity: 1; } 100% { transform: translate(70px, 40px); opacity: 0; } }
@keyframes tokEscape { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(210px, 0) rotate(360deg); opacity: .2; } }

.counters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.ctr { border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; font-size: 12px; }
.ctr .big { font-size: 28px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ctr.good { background: #e7f6ea; color: #1f6b2c; }
.ctr.bad { background: #fdeaea; color: #9c2b2b; }
.coq { font-size: 13px; }
.coqRow { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.coqRow b { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.coqRow.ext b { color: var(--err); }
.coqRow.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; font-weight: 600; }
.sw { width: 10px; height: 10px; border-radius: 2px; flex: 0 0 10px; }
.sw-conf { background: var(--conf); }
.sw-int { background: var(--int); }
.sw-ext { background: var(--ext); }
.coqBar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: #edf1f5; margin: 6px 0; }
.coqBar i { display: block; height: 100%; transition: width .5s; }
.lineMsg { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); min-height: 1em; }

/* ---------- разбор ---------- */
.review { margin-top: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.review h3 { margin: 0 0 8px; font-size: 16px; }
.rvItem { padding: 10px 0; border-top: 1px solid var(--line); }
.rvItem.ok { border-left: 3px solid var(--ok); padding-left: 10px; }
.rvItem.bad { border-left: 3px solid var(--err); padding-left: 10px; }
.rvQ, .rvA, .rvW { margin: 0 0 4px; font-size: 14px; }
.rvA { font-weight: 600; color: #1f6b2c; }
.rvW { color: #33414f; }

.crosslink { margin: 14px 0 0; padding: 9px 14px; border: 1px solid #cfe3d6; border-radius: var(--radius); background: #f2f9f5; font-size: 13px; }
.crosslink a { font-weight: 600; }

/* ---------- итог смены ---------- */
.winBox { display: none; position: fixed; inset: 0; z-index: 90; background: rgba(16, 30, 48, .55); align-items: center; justify-content: center; padding: 16px; }
.winCard {
    position: relative; max-width: 520px; width: 100%; max-height: calc(100vh - 32px); overflow: auto; background: var(--panel);
    border-radius: 16px; padding: 26px 22px 20px; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); animation: winPop .35s ease-out;
}
@keyframes winPop { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.stamp {
    display: inline-block; border: 3px solid var(--err); color: var(--err); border-radius: 8px; padding: 3px 12px; font-weight: 800;
    letter-spacing: 1px; text-transform: uppercase; font-size: 13px; transform: rotate(-6deg); animation: stamp .5s .15s both;
}
@keyframes stamp { from { transform: rotate(-6deg) scale(2.4); opacity: 0; } to { transform: rotate(-6deg) scale(1); opacity: 1; } }
.winTitle { margin: 14px 0 6px; font-size: 24px; color: var(--brand); }
.winText { margin: 0 0 12px; font-size: 15px; }
.winStats { margin: 0 0 8px; font-size: 14px; color: #33414f; }
.winBest { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.winHook { margin: 0 0 14px; font-size: 14px; font-weight: 600; }
.winBtns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

footer { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
footer a { color: var(--muted); }
footer .legal { margin-top: 10px; font-size: 11.5px; opacity: .8; }

/* ---------- планшет и телефон ---------- */
@media (max-width: 900px) {
    .board { grid-template-columns: 1fr; }
    .line { position: static; }
}
@media (max-width: 560px) {
    .wrap { padding: 12px 12px 32px; }
    .top { gap: 10px; }
    .brand h1 { font-size: 17px; }
    .mode, .lang { width: 100%; }
    .mode button, .lang button { flex: 1; padding: 8px 6px; }
    .home-link { order: 5; }
    .rounds button { flex: 1 1 100%; text-align: left; }
    .opts.four { grid-template-columns: 1fr; }
    .qcard { padding: 14px 12px 14px; }
    .qtext { font-size: 15.5px; }
    .bar .btn { flex: 1 1 auto; }
    .bar .spacer { display: none; }
    .score { width: 100%; }
    .chart { padding: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .chart-pareto svg, .chart-control svg, .chart-histogram svg, .chart-scatter svg { min-width: 440px; }
    .ctr .big { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
