:root {
  --bg: #E9EBEA;
  --sh-d: #C5CAC8;
  --sh-l: #FFFFFF;
  --text: #262A40;
  --muted: #5B6469;
  --faint: #8A9095;
  --mint: #8DB5A5;
  --mint-ink: #16302A;
  --mint-dark: #4F8571;
  --navy: #3B4466;
  --red: #C0563A;  --red-bg: #F3D9D0;  --red-ink: #7A2E1C;
  --amber: #D99A2B; --amber-bg: #F5E6C8; --amber-ink: #6B4A0F;
  --ok: #4F9A72;   --ok-bg: #D3E8DC;   --ok-ink: #245A3E;
  --line: #D5D9D7;
  --raise: 7px 7px 16px var(--sh-d), -7px -7px 16px var(--sh-l);
  --raise-sm: 4px 4px 10px var(--sh-d), -4px -4px 10px var(--sh-l);
  --inset: inset 4px 4px 10px var(--sh-d), inset -4px -4px 10px var(--sh-l);
  --inset-mint: inset 3px 3px 8px #6F9787, inset -3px -3px 8px #ABD3C3;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 600 15px/1.45 Nunito, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 800; }
h1 { font-size: 24px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.small { font-size: 13px; } .tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ----- каркас ----- */
.shell { max-width: 1240px; margin: 0 auto; padding: 22px 28px 60px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.brand { font-size: 22px; font-weight: 800; letter-spacing: .05em; white-space: nowrap; }
.brand span { color: var(--mint-dark); }
.nav { display: flex; gap: 4px; padding: 6px; border-radius: 999px; background: var(--bg); box-shadow: var(--raise-sm); }
.nav a { text-decoration: none; font-weight: 800; color: var(--muted); padding: 9px 18px; border-radius: 999px; font-size: 14px; }
.nav a.on { background: var(--mint); color: var(--mint-ink); }
.me { display: flex; align-items: center; gap: 10px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--mint); color: var(--mint-ink); display: grid; place-items: center; font-weight: 800; border: 0; cursor: pointer; box-shadow: var(--raise-sm); }
.bottomnav { display: none; }

.card { background: var(--bg); border-radius: 26px; padding: 22px; box-shadow: var(--raise); }
.well { background: var(--bg); border-radius: 18px; box-shadow: var(--inset); }
.grid { display: grid; gap: 22px; }
.grid > * { min-width: 0; }
html, body { overflow-x: hidden; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.g-main { grid-template-columns: 1.6fr 1fr; }
.row { display: flex; align-items: center; gap: 12px; } .row.wrap { flex-wrap: wrap; } .between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.mt { margin-top: 18px; }

/* ----- кнопки и поля ----- */
.btn { min-height: 44px; border: 0; border-radius: 999px; background: var(--bg); padding: 0 18px; font-weight: 800; font-size: 14px; cursor: pointer; box-shadow: var(--raise-sm); display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn:active { box-shadow: var(--inset); }
.btn.mint { background: var(--mint); color: var(--mint-ink); }
.btn.danger { color: var(--red); }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn.icon { width: 44px; padding: 0; }
.btn:disabled { opacity: .5; cursor: default; }
.seg { display: inline-flex; gap: 4px; padding: 5px; border-radius: 999px; box-shadow: var(--inset); }
.seg button { border: 0; background: transparent; padding: 8px 16px; border-radius: 999px; font-weight: 800; font-size: 13px; color: var(--muted); cursor: pointer; min-height: 36px; }
.seg button.on { background: var(--mint); color: var(--mint-ink); box-shadow: var(--raise-sm); }
.inp { min-height: 46px; border: 0; border-radius: 14px; background: var(--bg); box-shadow: var(--inset); padding: 0 14px; font-weight: 800; width: 100%; }
.inp:focus { outline: 2px solid var(--mint-dark); outline-offset: 2px; }
select.inp { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 700; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--mint-dark); }

/* ----- показатели ----- */
.kpi { padding: 18px 20px; }
.kpi .v { font-size: 26px; font-weight: 800; margin-top: 4px; white-space: nowrap; }
.kpi .l { font-size: 13px; color: var(--muted); }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.chip { display: inline-block; font-size: 12px; font-weight: 800; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.chip.red { background: var(--red-bg); color: var(--red-ink); }
.chip.amber { background: var(--amber-bg); color: var(--amber-ink); }
.chip.ok { background: var(--ok-bg); color: var(--ok-ink); }
.chip.grey { background: #DADDDC; color: var(--muted); }

/* ----- графики ----- */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 190px; padding: 8px 4px 0; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; cursor: pointer; border: 0; background: none; padding: 0; min-width: 0; }
.bar .col { width: 100%; max-width: 46px; border-radius: 8px 8px 4px 4px; background: #C9D3CF; transition: background .15s; position: relative; }
.bar.on .col { background: var(--mint-dark); }
.bar:hover .col { background: var(--mint); }
.bar.on:hover .col { background: var(--mint-dark); }
.bar .col.empty { background: transparent; border: 2px dashed #C5CAC8; }
.bar .col.fc { background: repeating-linear-gradient(135deg, #DCE3E0 0 6px, #CBD5D1 6px 9px); }
.bar .lb { font-size: 11px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.bar .vl { font-size: 11px; font-weight: 800; color: var(--text); white-space: nowrap; min-height: 15px; }
.bar.on .lb { color: var(--text); }
.bars.dense { gap: 3px; } .bars.dense .bar .vl { display: none; } .bars.dense .bar .col { border-radius: 4px 4px 2px 2px; }
.tip { position: fixed; pointer-events: none; background: var(--text); color: #fff; font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 10px; z-index: 50; white-space: nowrap; }

.progress { height: 10px; border-radius: 999px; box-shadow: var(--inset); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 999px; background: var(--ok); }
.progress i.amber { background: var(--amber); } .progress i.red { background: var(--red); } .progress i.grey { background: #B9C0BD; }

/* ----- списки ----- */
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.li:first-child { border-top: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .t { font-weight: 800; overflow: hidden; text-overflow: ellipsis; }
.li.click { cursor: pointer; } .li.click:hover .t { color: var(--mint-dark); }
.rank { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; box-shadow: var(--inset); flex: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.grp { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 18px 0 4px; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 800; padding: 8px 10px; }
table.t td { padding: 11px 10px; border-top: 1px solid var(--line); vertical-align: top; }

/* ----- загрузка ----- */
.drop { border-radius: 24px; padding: 34px 20px; text-align: center; box-shadow: var(--inset); cursor: pointer; transition: outline .1s; }
.drop.over { outline: 3px dashed var(--mint-dark); outline-offset: -10px; }
.drop svg { color: var(--mint-dark); }

/* ----- вход ----- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 18px; }
.login .card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; }
.code-inp { letter-spacing: .5em; text-align: center; font-size: 26px; min-height: 60px; }

/* ----- окно ----- */
.modal { position: fixed; inset: 0; background: rgba(38, 42, 64, .28); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.sheet { background: var(--bg); border-radius: 26px; box-shadow: 0 20px 60px rgba(0,0,0,.25); width: 100%; max-width: 620px; max-height: calc(100vh - 40px); overflow: auto; padding: 24px; }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 30px); opacity: 0; background: var(--text); color: #fff; padding: 12px 18px; border-radius: 16px; font-weight: 700; transition: .25s; z-index: 60; max-width: calc(100vw - 32px); pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.empty-state { padding: 30px 10px; text-align: center; color: var(--muted); }
.spin { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 3px solid #C9D3CF; border-top-color: var(--mint-dark); animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- телефон ----- */
@media (max-width: 900px) {
  .g4 { grid-template-columns: 1fr 1fr; }
  .g2, .g3, .g-main { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .shell { padding: calc(14px + env(safe-area-inset-top)) 16px calc(110px + env(safe-area-inset-bottom)); }
  .top { margin-bottom: 18px; }
  .top .nav { display: none; }
  .grid { gap: 16px; }
  .card { padding: 18px; border-radius: 22px; }
  .kpi { padding: 14px 16px; } .kpi .v { font-size: 21px; }
  .bars { height: 160px; gap: 5px; }
  .bar .vl { font-size: 9px; }
  .bottomnav {
    display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 30;
    height: 70px; border-radius: 26px; background: var(--bg); box-shadow: var(--raise); justify-content: space-around; align-items: center;
  }
  .bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 800; color: var(--muted); text-decoration: none; min-width: 64px; min-height: 52px; justify-content: center; border-radius: 16px; }
  .bottomnav a.on { color: var(--mint-ink); box-shadow: var(--inset); }
  .hide-phone { display: none !important; }
  .sheet { padding: 20px 18px; border-radius: 22px 22px 0 0; max-height: 92vh; }
  .modal { align-items: flex-end; padding: 0; }
  table.t.stackable thead { display: none; }
  table.t.stackable tr { display: block; border-top: 1px solid var(--line); padding: 8px 0; }
  table.t.stackable td { display: block; border: 0; padding: 3px 0; }
}
@media (min-width: 721px) { .show-phone { display: none !important; } }
