/* Reserve Ledger: всё своё поверх общей основы тренажёров (styles.css). */
:root {
    --cr: #1a9e8f;
    --mr: #f2b134;
    --wp: #0f4c81;
    --over: #d64545;
}

.bar .btn:disabled { opacity: .45; cursor: default; }

.msg.pop { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(.98); opacity: .4; } 100% { transform: none; opacity: 1; } }

/* ---------- сцена: карточка слева, панель справа ---------- */
.stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 14px;
    align-items: start;
}
.stage.noSide { grid-template-columns: minmax(0, 1fr); }
.stage.noSide .side { display: none; }
.main, .side { min-width: 0; }

.side > div {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
    margin-bottom: 12px;
}
.side h3 { margin: 0 0 10px; font-size: 14.5px; }
.side .hint { margin: 10px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---------- прогресс по карточкам ---------- */
.dots { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.dot {
    font: inherit; font-size: 13px; font-weight: 600;
    min-width: 36px; height: 36px; padding: 0 6px;
    border-radius: 18px; cursor: pointer;
    border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
.dot.cur { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.dot.ok { background: #e7f6ea; border-color: #bfe3c6; color: #1f6b2c; }
.dot.late { background: #fff6e0; border-color: #f0d79b; color: #7a5600; }
.dot.bad { background: #fdeaea; border-color: #f3c4c4; color: #9c2b2b; }
.dot.ans { background: var(--brand-soft); color: var(--brand); }

/* ---------- карточка ---------- */
.qcard {
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 5px solid var(--brand);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
    animation: cardIn .3s ease;
}
.qcard.solved { border-left-color: var(--ok); }
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.qcard.shake, .shake { animation: shake .4s ease; }
@keyframes shake {
    20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); } 80% { transform: translateX(3px); }
}
.qnum { font-size: 12px; color: var(--muted); letter-spacing: .4px; text-transform: uppercase; }
.qnum b { color: var(--ink); text-transform: none; }
.q { font-size: 16.5px; font-weight: 600; line-height: 1.45; margin: 6px 0 12px; }

table.facts { width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 13.5px; }
table.facts th, table.facts td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.facts th { background: var(--brand-soft); color: var(--brand); font-weight: 600; font-size: 12.5px; }
table.facts .n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.opts { display: grid; gap: 8px; }
.opt, .tri {
    font: inherit; text-align: left; cursor: pointer;
    border: 1px solid var(--line); background: var(--card); color: var(--ink);
    border-radius: 9px; padding: 11px 14px; min-height: 44px;
    transition: background .15s, border-color .15s, transform .1s;
}
.opt:hover:not(:disabled), .tri:hover:not(:disabled) { border-color: var(--brand); background: #fff; }
.opt:active:not(:disabled), .tri:active:not(:disabled) { transform: scale(.99); }
.opt:disabled, .tri:disabled { cursor: default; }
.opt.picked, .tri.picked { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.opt.right, .tri.right { border-color: #bfe3c6; background: #e7f6ea; box-shadow: inset 3px 0 0 var(--ok); color: #1f6b2c; }
.opt.wrong, .tri.wrong { border-color: #f3c4c4; background: #fdeaea; box-shadow: inset 3px 0 0 var(--err); color: #9c2b2b; }

.numRow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.numIn {
    font: inherit; font-size: 18px; width: 160px; max-width: 100%;
    padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
}
.numIn:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.unit { color: var(--muted); font-size: 14px; }

.triad { display: grid; gap: 12px; }
.tgroup { margin-bottom: 4px; }
.tlabel { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.topts, .setup { display: flex; flex-wrap: wrap; gap: 8px; }
.topts .tri { flex: 1 1 160px; }
.setup .tri { flex: 1 1 100%; }

.note { margin: 10px 0 0; padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.note.bad { background: #fdf1f1; border: 1px solid #f3c4c4; color: #9c2b2b; }
.verdictLine { margin: 12px 0 0; font-weight: 600; }
.verdictLine.ok { color: var(--ok); }
.verdictLine.bad { color: var(--err); }

.explain {
    margin-top: 14px; padding: 12px 14px;
    background: #f6f9fc; border: 1px solid var(--line); border-radius: 9px;
    animation: cardIn .3s ease;
}
.explain h4 { margin: 0 0 6px; font-size: 13px; color: var(--brand); text-transform: uppercase; letter-spacing: .5px; }
.explain p { margin: 0; line-height: 1.55; }
.why { margin: 10px 0 0; padding-left: 18px; font-size: 13.5px; }
.why li { margin-bottom: 4px; }
.why li.ok b { color: var(--ok); }
.why li.bad b { color: var(--err); }

.nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; }
.nav .btn:disabled { opacity: .4; cursor: default; }

/* ---------- стек бюджета ---------- */
.stackWrap { display: flex; gap: 8px; align-items: flex-end; }
.stack { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.layer {
    position: relative; border-radius: 6px;
    border: 2px dashed #b9c8d8; background: transparent; color: var(--muted);
    display: flex; align-items: center; justify-content: space-between; gap: 6px;
    padding: 0 8px; font-size: 12px; overflow: hidden;
    transition: background .4s, color .4s, border-color .4s;
}
.layer span { overflow: hidden; line-height: 1.1; font-size: 11.5px; }
.layer.on { border-style: solid; color: #fff; }
.layer.cr.on { background: var(--cr); border-color: var(--cr); }
.layer.mr.on { background: var(--mr); border-color: var(--mr); color: #3d2c00; }
.layer.wp { flex-direction: column; align-items: stretch; padding: 0; gap: 0; }
.layer.wp.on, .layer.wp.act { border-style: solid; border-color: var(--wp); }
.wpseg {
    display: flex; align-items: center; justify-content: space-between; position: relative;
    padding: 0 8px; border-top: 1px solid rgba(15, 76, 129, .15); min-height: 0;
}
.wpseg.on { background: var(--wp); color: #fff; border-top-color: rgba(255, 255, 255, .25); }
.wpseg span, .wpseg b { position: relative; z-index: 1; }
.wpseg .acts { position: absolute; inset: 4px 46px 4px 46px; display: flex; gap: 2px; font-style: normal; }
.wpseg .acts em { background: rgba(255, 255, 255, .32); border-radius: 2px; }
.layerLabel { font-size: 11px; text-align: center; padding: 2px 4px; background: rgba(15, 76, 129, .08); color: var(--brand); }
.layer.wp.on .layerLabel { background: #0b3a63; color: #fff; }
.layer.drop, .br.drop, .fundBox.drop { animation: dropIn .6s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes dropIn { 0% { transform: translateY(-40px); opacity: 0; } 100% { transform: none; opacity: 1; } }

.msg:empty { display: none; }
/* скобки справа от стека: внутренняя — базовый план (пакеты + резерв), внешняя во всю высоту — бюджет */
.brackets { width: 112px; display: flex; align-items: flex-end; gap: 4px; align-self: stretch; }
.br.cb { flex: 1; min-width: 0; }
.br.bud { width: 30px; align-self: stretch; justify-content: center; padding: 6px 0; }
.br.bud span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.br.bud b { display: inline; font-size: 13px; }
.br {
    border: 2px dashed #b9c8d8; border-left: 0; border-radius: 0 8px 8px 0;
    display: flex; align-items: center; padding-left: 6px; font-size: 11px; color: var(--muted); line-height: 1.25;
}
.br b { display: block; font-size: 15px; color: var(--ink); }
.br.on { border-style: solid; border-color: var(--brand); color: var(--brand); }

.fund { display: flex; gap: 10px; height: 150px; align-items: flex-end; padding-top: 18px; }
.fund .q { flex: 1; margin: 0; display: flex; flex-direction: column; align-items: center; height: 100%; font-size: 12px; font-weight: 400; }
.fund .bars { flex: 1; width: 100%; display: flex; align-items: flex-end; gap: 3px; }
.fund .bars i { flex: 1; position: relative; border-radius: 4px 4px 0 0; transition: height .6s ease; }
.fund .bars b { position: absolute; top: -17px; left: -4px; right: -4px; text-align: center; font-size: 11px; font-weight: 600; font-style: normal; }
.fund i.plan { background: var(--wp); }
.fund i.plan.over { background: var(--over); }
.fund i.limit { background: repeating-linear-gradient(45deg, #c7d4e2, #c7d4e2 4px, #e6eef7 4px, #e6eef7 8px); }
.fundBox .legend { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.legend i { display: inline-block; width: 12px; height: 10px; margin: 0 4px 0 8px; border-radius: 2px; vertical-align: middle; }
.legend i.plan { background: var(--wp); }
.legend i.limit { background: #c7d4e2; }

/* ---------- три кармана и шпаргалка ---------- */
.pocket { border-left: 4px solid var(--cr); padding: 4px 10px; margin-bottom: 10px; font-size: 13px; }
.pocket p { margin: 3px 0 0; color: var(--ink); line-height: 1.45; }
.pocket.p-mr { border-color: var(--mr); }
.pocket.p-chg { border-color: var(--brand); }
.crib dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; }
.crib dt { color: var(--muted); }
.crib dd { margin: 0; font-weight: 600; font-family: Consolas, Menlo, monospace; }

/* ---------- 12 месяцев ---------- */
.months { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; margin-bottom: 12px; }
.months i {
    font-style: normal; text-align: center; font-size: 11px; padding: 4px 0;
    border-radius: 4px; background: #eef3f8; color: var(--muted);
}
.months i.cur { background: var(--brand); color: #fff; animation: pulse 1.4s infinite; }
.months i.ok { background: #e7f6ea; color: #1f6b2c; }
.months i.bad { background: #fdeaea; color: #9c2b2b; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px var(--brand-soft); } }
.gauge { margin-bottom: 10px; }
.glabel { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); }
.glabel b { color: var(--ink); white-space: nowrap; }
.gbar { height: 12px; background: #eef3f8; border-radius: 6px; overflow: hidden; margin-top: 3px; }
.gbar i { display: block; height: 100%; border-radius: 6px; transition: width .7s ease; }
.g-cr .gbar i { background: var(--cr); }
.g-mr .gbar i { background: var(--mr); }
.g-pad .gbar i { background: repeating-linear-gradient(45deg, #b59cd6, #b59cd6 4px, #d8c9ec 4px, #d8c9ec 8px); }
.g-over .gbar i { background: var(--over); }
.g-over.hot .glabel b { color: var(--over); }
.kv { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 6px 0; border-top: 1px solid var(--line); }
.mood { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); padding-top: 6px; border-top: 1px solid var(--line); }
.mood b { color: var(--ink); }
.thermo { display: flex; gap: 3px; }
.thermo i { width: 16px; height: 10px; border-radius: 3px; background: #eef3f8; }
.thermo i.on { background: #f2b134; }
.mood.a3 .thermo i.on, .mood.a4 .thermo i.on, .mood.a5 .thermo i.on { background: var(--over); }
.mood.a5 b { color: var(--over); text-transform: uppercase; }

.mail {
    margin-top: 14px; border: 1px solid var(--line); border-radius: 9px; background: #fff;
    padding: 10px 14px; animation: mailIn .45s ease;
}
@keyframes mailIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
.mail .mhead { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 12px; color: var(--muted); }
.mail .mhead b { font-size: 14px; color: var(--ink); }
.mail .ib { background: var(--brand-soft); color: var(--brand); border-radius: 10px; padding: 1px 8px; font-size: 11px; }
.mail p { margin: 6px 0 0; }
.mail.ok { border-left: 4px solid var(--ok); }
.mail.watch { border-left: 4px solid var(--mr); }
.mail.angry { border-left: 4px solid var(--over); }
.mail.angry.lvl4, .mail.angry.lvl5 { background: #fff5f5; }
.mail.angry.lvl5 p { font-weight: 700; color: #9c2b2b; }

/* ---------- итог года ---------- */
.verdict {
    display: none; position: fixed; inset: 0; z-index: 90;
    background: rgba(15, 32, 56, .55); padding: 16px;
    align-items: center; justify-content: center;
}
.verdict.show { display: flex; }
.vcard {
    position: relative; width: 100%; max-width: 620px; max-height: 92vh; overflow: auto;
    background: var(--panel); border-radius: 14px; padding: 22px 22px 18px;
    box-shadow: 0 18px 50px rgba(15, 32, 56, .35); animation: dropIn .5s cubic-bezier(.3, 1.4, .5, 1);
}
.vcard h2 { margin: 6px 0 4px; font-size: 20px; }
.vcard h3 { margin: 16px 0 8px; font-size: 14px; }
.vtier {
    display: inline-block; padding: 4px 12px; border-radius: 20px; font-weight: 700;
    background: var(--brand); color: #fff; letter-spacing: .3px;
}
.vtier.t0 { background: var(--ok); }
.vtier.t2 { background: #c2410c; }
.vtier.t3 { background: var(--over); }
.vscore { font-size: 18px; font-weight: 700; margin: 0; }
.vline { margin: 6px 0; }
.vstats, .vbest { font-size: 13px; color: var(--muted); margin: 4px 0; }
.vhook { font-weight: 600; color: var(--brand); }
.vrounds { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.vrounds li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.badge { border: 1px dashed #b9c8d8; border-radius: 9px; padding: 8px 10px; font-size: 12px; color: var(--muted); opacity: .7; }
.badge b { display: block; font-size: 13.5px; }
.badge.got { border-style: solid; border-color: var(--mr); background: #fff8e6; color: var(--ink); opacity: 1; animation: pop .4s ease; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i {
    position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px;
    background: var(--mr); animation: fall 2.4s ease-in 2;
}
.confetti i:nth-child(3n) { background: var(--cr); }
.confetti i:nth-child(3n+1) { background: var(--brand); }
@keyframes fall { to { transform: translateY(600px) rotate(540deg); opacity: 0; } }

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

/* ---------- узкие экраны ---------- */
@media (max-width: 960px) {
    .stage { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
    .wrap { padding: 12px 10px 30px; }
    .top { gap: 10px; }
    .brand { margin-right: 0; }
    .brand h1 { font-size: 17px; }
    .mode button, .lang button { padding: 8px 10px; }
    .qcard { padding: 14px 12px; }
    .q { font-size: 15.5px; }
    table.facts { font-size: 12.5px; }
    table.facts th, table.facts td { padding: 5px 4px; }
    table.facts .n { white-space: normal; }
    .brackets { width: 100px; }
    .vcard { padding: 18px 14px; }
    .topts .tri { flex-basis: 100%; }
    .months { grid-template-columns: repeat(6, 1fr); }
}
