:root {
  --navy: #142644; --navy-2: #1d3560; --ink: #142644; --muted: #5b6b82; --line: #dce3ee; --soft: #f4f7fb;
  --lime: #d5ff69; --lime-2: #c2f23f; --lime-soft: #f4ffd6; --pink: #ff6c88; --pink-ink: #c2334f; --pink-soft: #ffe8ed;
  --green: #1f9d61; --green-soft: #e3f6ec; --amber: #b7791f; --amber-soft: #fff3d6; --red: #c2334f; --red-soft: #ffe3e8;
  --radius: 14px; --shadow: 0 1px 2px rgba(20, 38, 68, .06), 0 6px 24px rgba(20, 38, 68, .06);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: "Montserrat", Arial, sans-serif; font-size: 15px; line-height: 1.5; color: var(--ink); background: #fff; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h2 { font-size: 22px; font-weight: 800; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- шапка */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 40; } /* таймер в шапке виден при прокрутке */
.topbar .wrap { display: flex; align-items: center; gap: 16px; padding-top: 14px; padding-bottom: 14px; }
.brand-label { color: var(--pink); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.brand-title { color: var(--lime); font-size: 20px; font-weight: 800; }
.topbar .spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.chip-group { background: var(--lime); color: var(--navy); }
.chip-timer { background: rgba(255, 255, 255, .12); color: #fff; }
.chip-timer.late { background: var(--pink); color: var(--navy); }

/* ---------- шаги и вкладки */
.steps { display: flex; gap: 6px; padding: 14px 0 6px; overflow-x: auto; scrollbar-width: none; }
.step { flex: 1 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--soft); color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.step b { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 1px solid var(--line); font-size: 12px; }
.step.done { color: var(--navy); }
.step.done b { background: var(--lime); border-color: var(--lime); }
.step.now { background: var(--navy); color: #fff; }
.step.now b { background: var(--lime); color: var(--navy); border-color: var(--lime); }
.step .t { font-weight: 500; opacity: .8; }
.tabs { position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .96); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.tabs .wrap { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tab { border: 0; background: none; padding: 14px 14px 12px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tab.active { color: var(--navy); border-bottom-color: var(--lime-2); }
.tab:disabled { opacity: .4; cursor: default; }
main { padding: 24px 0 120px; }

/* ---------- карточки */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card.soft { background: var(--soft); box-shadow: none; }
.card.lime { background: var(--lime-soft); border-color: var(--lime-2); box-shadow: none; }
.card.pink { border-left: 5px solid var(--pink); }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: #fff; }
.tile h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--navy); margin-bottom: 6px; }
.tile .num { font-size: 28px; font-weight: 800; color: var(--pink-ink); line-height: 1; margin-right: 8px; }
.kicker { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--pink-ink); margin-bottom: 6px; }
.quote { font-style: italic; }
.quote .who { font-style: normal; font-weight: 700; color: var(--muted); margin-top: 8px; font-size: 13px; }
.hero { display: grid; grid-template-columns: 340px 1fr; gap: 22px; align-items: center; }
.hero img { width: 100%; border-radius: 14px; display: block; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { background: var(--lime); text-align: left; padding: 10px 12px; font-weight: 700; }
table.data td { border-bottom: 1px solid var(--line); padding: 10px 12px; vertical-align: top; }
.budget-strip { margin-top: 14px; background: var(--lime); border-radius: 12px; padding: 12px 16px; font-weight: 700; }
ul.clean { margin: 0; padding-left: 18px; }
ul.clean li { margin-bottom: 6px; }
.timeline { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.timeline .tile b { display: block; font-size: 13px; color: var(--pink-ink); margin-bottom: 4px; }

/* ---------- кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 13px 20px; font-weight: 800; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--lime); color: var(--navy); }
.btn-primary:hover { background: var(--lime-2); }
.btn-dark { background: var(--navy); color: #fff; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--navy); }
.btn-danger { background: var(--pink-soft); color: var(--pink-ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- вход */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login .left { background: var(--navy); display: grid; place-items: center; padding: 40px; }
.login .left img { max-width: 420px; width: 100%; }
.login .right { display: grid; place-items: center; padding: 40px 24px; }
.login form { width: 100%; max-width: 380px; }
.login h1 { font-size: 30px; font-weight: 800; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; }
.input { width: 100%; padding: 13px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; outline: none; }
.input:focus { border-color: var(--navy); }
.error { color: var(--red); font-weight: 600; margin-top: 8px; }
.groups-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-top: 20px; }
.groups-pick a { display: block; padding: 26px 18px; border-radius: var(--radius); border: 1.5px solid var(--line); text-decoration: none; font-weight: 800; font-size: 22px; text-align: center; background: #fff; box-shadow: var(--shadow); }
.groups-pick a:hover { border-color: var(--navy); background: var(--lime-soft); }

/* ---------- роли */
.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.role-btn { text-align: left; padding: 16px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; font-weight: 700; }
.role-btn:hover { border-color: var(--navy); }
.role-card .facts li { margin-bottom: 10px; }

/* ---------- план */
.plan-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
.side { position: sticky; top: 64px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.mgmt-note { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.mgmt-note b { color: var(--navy); }
.q { padding: 14px 0; border-top: 1px dashed var(--line); }
.q:first-of-type { border-top: 0; }
.q-label { font-weight: 700; margin-bottom: 10px; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.q-note { font-size: 13px; color: var(--muted); margin-top: 6px; }
.value-badge { background: var(--navy); color: #fff; border-radius: 8px; padding: 3px 10px; font-size: 14px; font-weight: 800; white-space: nowrap; }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row span { font-size: 12px; color: var(--muted); min-width: 28px; text-align: center; }
input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; height: 8px; border-radius: 99px; background: linear-gradient(90deg, var(--lime-2) var(--p, 50%), var(--line) var(--p, 50%)); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: var(--lime); border: 3px solid var(--navy); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--lime); border: 3px solid var(--navy); cursor: pointer; }
.mgmt-mark { font-size: 12px; color: var(--muted); margin-top: 4px; }
.opts { display: grid; gap: 8px; }
.opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; background: #fff; }
.opt:hover { border-color: #b9c6da; }
.opt input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--navy); flex: 0 0 auto; }
.opt.checked { border-color: var(--navy); background: var(--lime-soft); }
.opt .txt { flex: 1; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; margin-left: 6px; vertical-align: 1px; white-space: nowrap; }
.tag-mgmt { background: var(--pink-soft); color: var(--pink-ink); }
.tag-cost { background: var(--soft); color: var(--navy); border: 1px solid var(--line); }
textarea.input { min-height: 84px; resize: vertical; }
.budget .big { font-size: 26px; font-weight: 800; }
.meter { height: 12px; border-radius: 99px; background: var(--soft); overflow: hidden; border: 1px solid var(--line); margin: 10px 0; }
.meter > i { display: block; height: 100%; background: var(--navy); }
.meter.over > i { background: var(--red); }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.save-state { font-size: 12px; color: var(--muted); margin-top: 8px; }
.mobile-bar { display: none; }

/* ---------- модальное окно */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 38, 68, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 16px; max-width: 560px; width: 100%; padding: 24px; max-height: 90vh; overflow: auto; }

/* ---------- дашборд */
.dash-top { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; }
.kpis { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.kpi { text-align: center; padding: 16px 10px; border-radius: 14px; background: var(--soft); }
.kpi .v { font-size: 46px; font-weight: 800; line-height: 1; }
.kpi .l { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-top: 8px; }
.arrow { font-size: 28px; color: var(--muted); }
.zone-green { color: var(--green); } .zone-amber { color: var(--amber); } .zone-red { color: var(--red); }
.bg-green { background: var(--green-soft); } .bg-amber { background: var(--amber-soft); } .bg-red { background: var(--red-soft); }
.badge { display: inline-block; padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.badge.protected { background: var(--green-soft); color: var(--green); }
.badge.partial { background: var(--amber-soft); color: var(--amber); }
.badge.hit { background: var(--red-soft); color: var(--red); }
.event-card .imp { font-size: 30px; font-weight: 800; }
.event-card ul { margin: 6px 0 0; padding-left: 18px; }
.event-card li { margin-bottom: 4px; }
.plus { color: var(--green); font-weight: 800; white-space: nowrap; }
.minus { color: var(--red); font-weight: 800; white-space: nowrap; }
.expo-row { display: grid; grid-template-columns: minmax(150px, 1.2fr) 2fr 60px 160px; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.expo-row:last-child { border-bottom: 0; }
.expo-bar { height: 14px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.expo-bar i { display: block; height: 100%; border-radius: 99px; }
.happened { font-size: 11px; font-weight: 800; background: var(--navy); color: #fff; border-radius: 99px; padding: 2px 8px; margin-left: 6px; }
.drivers { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 14px; }
.driver { background: var(--soft); border-radius: 12px; padding: 12px; }
.driver b { display: block; font-size: 20px; }
.driver span { font-size: 12px; color: var(--muted); font-weight: 600; }
.codes { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.code-input { text-transform: uppercase; letter-spacing: .25em; font-weight: 800; font-size: 22px; text-align: center; }
svg text { font-family: "Montserrat", Arial, sans-serif; }

/* ---------- события квартала: карты и выбор */
.deck { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-top: 8px; }
.draw-card { height: 150px; border: 0; border-radius: 14px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #fff;
  background: var(--navy) repeating-linear-gradient(45deg, rgba(213, 255, 105, .09) 0 10px, transparent 10px 20px); box-shadow: var(--shadow); transition: transform .15s; }
.draw-card .q { font-size: 42px; font-weight: 800; color: var(--lime); line-height: 1; }
.draw-card .n { font-size: 13px; font-weight: 700; }
.draw-card .t { font-size: 11px; font-weight: 600; }
.draw-card:hover:not(:disabled) { transform: translateY(-3px); }
.draw-card.on { background: var(--lime); color: var(--navy); outline: 3px solid var(--navy); outline-offset: 2px; }
.draw-card.on .q { color: var(--navy); }
.draw-card:disabled { background: #e6ebf2; color: var(--muted); cursor: not-allowed; box-shadow: none; }
.draw-card:disabled .q { color: #b8c3d3; }
.opt.pick { width: 100%; text-align: left; align-items: center; font: inherit; }
.opt .box { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--navy); display: inline-grid; place-items: center; font-weight: 800; flex: 0 0 auto; }
.opt.checked .box { background: var(--navy); color: var(--lime); }

/* ---------- уведомления и режим просмотра */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); max-width: min(560px, 92vw); background: var(--navy); color: #fff;
  padding: 12px 18px; border-radius: 12px; box-shadow: 0 10px 30px rgba(20, 38, 68, .25); font-size: 14px; font-weight: 600; opacity: 0;
  pointer-events: none; transition: opacity .25s, transform .25s; z-index: 70; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
input:disabled, textarea:disabled { cursor: default; }
.opt:has(input:disabled) { cursor: default; }
textarea.input:disabled { background: var(--soft); color: var(--ink); }

/* ---------- тренер */
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; padding: 8px; border-bottom: 2px solid var(--line); }
.admin-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.status { font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 99px; background: var(--soft); }
.status.draft { background: var(--amber-soft); color: var(--amber); }
.status.approved { background: var(--lime-soft); color: var(--navy); border: 1px solid var(--lime-2); }
.status.results { background: var(--green-soft); color: var(--green); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.screen-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.screen-card h2 { font-size: 28px; }
.screen-big { font-size: 64px; font-weight: 800; line-height: 1; }
.footer { color: var(--muted); font-size: 11px; padding: 24px 0 40px; border-top: 1px solid var(--line); margin-top: 30px; }

/* ---------- мобильная версия */
@media (max-width: 900px) {
  .plan-layout { grid-template-columns: 1fr; }
  .side { display: none; }
  .mobile-bar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(20, 38, 68, .08); padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); gap: 12px; align-items: center; }
  .mobile-bar .info { flex: 1; font-size: 13px; line-height: 1.3; }
  .mobile-bar .info b { font-size: 16px; }
  .dash-top, .hero, .g3, .g2 { grid-template-columns: 1fr; }
  .timeline { grid-template-columns: 1fr 1fr; }
  .login { grid-template-columns: 1fr; }
  .deck { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .draw-card { height: 120px; }
  .login .left { padding: 24px; }
  .login .left img { max-width: 220px; }
  .expo-row { grid-template-columns: 1fr 70px; }
  .expo-row .expo-bar { grid-column: 1 / -1; order: 3; }
  .expo-row .st { display: none; }
}
@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .wrap { padding: 0 14px; }
  .brand-title { font-size: 16px; }
  .brand-label { display: none; }
  .card { padding: 16px; }
  h2 { font-size: 19px; }
  .kpi .v { font-size: 36px; }
  .codes { grid-template-columns: 1fr 1fr; }
  .codes .btn { grid-column: 1 / -1; }
  .timeline { grid-template-columns: 1fr; }
  table.data thead { display: none; }
  table.data tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.data td { display: block; border: 0; padding: 2px 4px; }
  table.data td:first-child { font-weight: 700; }
  table.data td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-weight: 600; }
}
@media print {
  .topbar, .tabs, .steps, .mobile-bar, .no-print { display: none !important; }
  .card { box-shadow: none; break-inside: avoid; }
  main { padding: 0; }
}

/* открытые карты событий: переворот при появлении */
.reveal-card { border-top: 6px solid var(--lime); animation: flip-in .6s ease both; transform-origin: center; }
.reveal-card h2 { margin-top: 4px; }
.reveal-card h3 { margin: 14px 0 4px; font-size: 15px; }
@keyframes flip-in { from { transform: perspective(900px) rotateY(90deg); opacity: 0; } to { transform: perspective(900px) rotateY(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .reveal-card { animation: none; } }
