:root {
  color-scheme: light;
  --bg: #eef0f6; --surface: #ffffff; --surface2: #f5f6fa; --border: #e9ebf2;
  --text: #15172b; --text2: #6b7085; --muted: #9a9fb3;
  --blue: #4b5cf5; --blue-d: #3a49d6; --blue-l: #dfe3ff; --grey: #dfe2ec;
  --green: #22a06b; --green-bg: #e3f6ec; --red: #e5484d; --red-bg: #fde9ea; --orange: #eb6834; --amber: #eda100; --amber-bg: #fff4dc;
  --sky: #8fb4ff; --dark: #15172b;
  --r: 16px; --sh: 0 1px 2px rgba(20,22,43,.04), 0 6px 20px rgba(20,22,43,.05);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13.5px/1.45 Inter, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: inherit; text-decoration: none; }
b { font-weight: 600; }
button, select, input { font: inherit; }
code { background: var(--surface2); padding: 1px 6px; border-radius: 6px; }

.app { display: grid; grid-template-columns: 232px 1fr; gap: 20px; padding: 20px; min-height: 100vh; max-width: 1560px; margin: 0 auto; }

/* ---------- sidebar ---------- */
.side { background: var(--surface); border-radius: 22px; padding: 22px 16px; box-shadow: var(--sh); display: flex; flex-direction: column; position: sticky; top: 20px; height: calc(100vh - 40px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.side::-webkit-scrollbar { width: 6px; }
.side::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.side-card { flex-shrink: 0; }
.cnt.demo { background: var(--amber-bg); color: #a06a00; font-weight: 600; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 8px 18px; }
.logo-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--dark); color: #fff; font-size: 17px; }
.side-sec { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 6px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; color: var(--text2); font-weight: 500; cursor: pointer; transition: .15s; }
.nav:hover { background: var(--surface2); color: var(--text); }
.nav.active { background: var(--blue); color: #fff; box-shadow: 0 6px 14px rgba(75,92,245,.35); }
.nav i, .kpi-top i { display: inline-grid; place-items: center; width: 20px; height: 20px; }
.nav svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cnt { margin-left: auto; font-size: 11px; background: var(--surface2); color: var(--text2); padding: 1px 7px; border-radius: 999px; }
.cnt:empty { display: none; }
.cnt.warn { background: var(--amber-bg); color: #a06a00; }
.nav.active .cnt { background: rgba(255,255,255,.22); color: #fff; }
.side-card { margin-top: auto; background: var(--dark); color: #fff; border-radius: 18px; padding: 16px; }
.side-card-title { font-weight: 600; margin-bottom: 8px; }
.conn { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #c9cbe0; padding: 3px 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7085; }
.conn.ok .dot { background: #3ddc97; } .conn.err .dot { background: #ff6b6b; }
.side-card button { margin-top: 12px; width: 100%; border: 0; border-radius: 10px; padding: 9px; background: var(--blue); color: #fff; font-weight: 600; cursor: pointer; }
.side-card button:disabled { opacity: .6; }

/* ---------- header ---------- */
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
h1 { margin: 0; font-size: 22px; font-weight: 700; }
.sub { color: var(--text2); font-size: 12.5px; margin-top: 2px; }
.head-r { display: flex; align-items: center; gap: 12px; }
.date-pick input { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 8px 12px; color: var(--text); }
.mode { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; background: var(--amber-bg); color: #a06a00; padding: 4px 10px; border-radius: 999px; }
.mode.live { background: var(--green-bg); color: var(--green); }
.user { display: flex; align-items: center; gap: 10px; background: var(--surface); padding: 6px 14px 6px 6px; border-radius: 999px; box-shadow: var(--sh); }
.user img, .ava { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--blue-l); }
.user small { display: block; color: var(--text2); font-size: 11px; }

/* ---------- layout ---------- */
.page { display: none; } .page.active { display: block; }
.dash { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: start; }
.col-l, .col-r { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card { background: var(--surface); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--sh); min-width: 0; }
.card-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card h3 { margin: 0; font-size: 15px; font-weight: 600; }
.hint { color: var(--text2); font-size: 12px; }
.link { color: var(--blue); font-weight: 500; font-size: 12.5px; cursor: pointer; }
.chip { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 5px 10px; font-size: 12px; color: var(--text2); }
.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.search, select { border: 1px solid var(--border); border-radius: 10px; padding: 7px 12px; background: var(--surface2); color: var(--text); min-width: 200px; }
select { min-width: 0; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text2); align-items: center; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.kpis.three { grid-template-columns: repeat(3, 1fr); margin-bottom: 16px; }
.kpis.four { grid-template-columns: repeat(4, 1fr); margin-bottom: 16px; }
.kpi { background: var(--surface); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--sh); min-width: 0; }
.kpi.primary { background: var(--blue); color: #fff; box-shadow: 0 10px 24px rgba(75,92,245,.35); }
.kpi-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.kpi-top i { width: 34px; height: 34px; border-radius: 10px; background: var(--surface2); }
.kpi-top svg { width: 18px; height: 18px; stroke: var(--text); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.kpi.primary .kpi-top i { background: rgba(255,255,255,.2); } .kpi.primary .kpi-top svg { stroke: #fff; }
.kpi-lbl { font-size: 12.5px; color: var(--text2); } .kpi.primary .kpi-lbl { color: rgba(255,255,255,.85); }
.kpi-val { display: flex; align-items: baseline; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.kpi-val b { font-size: clamp(17px, 1.5vw, 24px); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; }
.kpi-val small { font-size: 11px; color: var(--muted); line-height: 1.2; } .kpi.primary .kpi-val small { color: rgba(255,255,255,.7); }
.badge { font-size: 11px; font-weight: 600; padding: 3px 7px; border-radius: 999px; background: var(--green-bg); color: var(--green); }
.badge.neg { background: var(--red-bg); color: var(--red); } .badge:empty { display: none; }
.kpi.primary .badge { background: var(--green); color: #fff; } .kpi.primary .badge.neg { background: var(--red); color: #fff; }

/* ---------- charts ---------- */
.chart { position: relative; height: 260px; } .chart.sm { height: 200px; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; }
.row .ic { width: 36px; height: 36px; border-radius: 10px; background: var(--surface2); display: grid; place-items: center; font-size: 18px; flex: none; }
.row .t { flex: 1; min-width: 0; } .row .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t small { color: var(--text2); font-size: 11.5px; }
.row .v { text-align: right; font-variant-numeric: tabular-nums; } .row .v b { display: block; }
.bar { height: 5px; border-radius: 3px; background: var(--surface2); margin-top: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--blue); }
.ava-i { display: grid; place-items: center; font-weight: 600; font-size: 13px; color: var(--dark); }

/* rings */
.rings { position: relative; display: flex; justify-content: center; margin: 4px 0 10px; }
.rings svg { width: 200px; height: 200px; }
.rings-txt { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; pointer-events: none; }
.rings-txt b { display: block; font-size: 22px; } .rings-txt small { display: block; color: var(--text2); font-size: 11.5px; margin-bottom: 4px; }
.sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* bubbles */
.bubbles { position: relative; height: 170px; }
.bub { position: absolute; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; text-align: center; line-height: 1.15; }
.bub small { display: block; font-weight: 500; font-size: 10.5px; opacity: .85; }

/* ---------- tables ---------- */
.tablewrap { overflow: auto; max-height: 560px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--text2); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--surface); }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.longopen td { background: var(--amber-bg); }
tr.check { cursor: pointer; } tr.check:hover td { background: var(--surface2); }
tr.detail td { background: var(--surface2); color: var(--text2); white-space: normal; padding-left: 24px; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500; }
.tag.in { background: var(--green-bg); color: var(--green); } .tag.out { background: #fdeee6; color: var(--orange); }
.empty { color: var(--muted); padding: 16px; text-align: center; }

/* ---------- waiters ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.wcard { background: var(--surface); border-radius: var(--r); padding: 20px; box-shadow: var(--sh); }
.wcard .who { display: flex; gap: 14px; align-items: center; }
.wcard .who > div { min-width: 0; }
.wcard .who img, .wcard .who .ava { width: 60px; height: 60px; border-radius: 18px; }
.wcard .who b { font-size: 15px; display: block; } .wcard .who small { color: var(--text2); }
.wstat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 12px; }
.wstat div { background: var(--surface2); border-radius: 12px; padding: 10px; text-align: center; }
.wstat b { display: block; font-size: 16px; } .wstat small { color: var(--text2); font-size: 11px; }
.wcard .spark { height: 44px; margin-bottom: 8px; }
.wtop { font-size: 12.5px; color: var(--text2); display: flex; justify-content: space-between; padding: 4px 0; border-top: 1px solid var(--border); }
.wtop b { color: var(--text); font-weight: 500; }
.open-pill { margin-left: auto; flex: none; white-space: nowrap; font-size: 11.5px; background: var(--blue-l); color: var(--blue-d); padding: 3px 9px; border-radius: 999px; font-weight: 600; }

/* ---------- products ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--border); background: var(--surface2); border-radius: 999px; padding: 6px 12px; color: var(--text2); cursor: pointer; font-size: 12.5px; }
.chips button.active { background: var(--dark); color: #fff; border-color: var(--dark); }
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.prod { border: 1px solid var(--border); border-radius: 14px; padding: 12px; position: relative; }
.prod .img { height: 84px; border-radius: 10px; background: var(--surface2); display: grid; place-items: center; font-size: 42px; margin-bottom: 10px; }
.prod.low .img { background: var(--amber-bg); } .prod.zero .img { background: var(--red-bg); }
.prod .nm { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prod .cat { color: var(--muted); font-size: 11px; }
.prod .qty { display: flex; justify-content: space-between; align-items: baseline; margin-top: 6px; }
.prod .qty b { font-size: 17px; } .prod .qty small { color: var(--text2); }
.prod .st { position: absolute; top: 18px; right: 18px; }
.prod .st.low { background: var(--amber-bg); color: #a06a00; } .prod .st.zero { background: var(--red-bg); color: var(--red); }

.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings div { background: var(--surface2); border-radius: 12px; padding: 14px; }
.settings b { display: block; margin-bottom: 4px; }

@media (max-width: 1180px) { .dash { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; padding: 12px; }
  .side { position: static; height: auto; }
  .kpis.four, .kpis.three, .grid2, .settings { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) { .kpis, .kpis.four, .kpis.three, .grid2, .settings { grid-template-columns: 1fr; } }

/* ---------- period range ---------- */
.range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex-basis: 100%; }
.range[hidden] { display: none; }
.head-r { flex: 1; justify-content: flex-end; }
.mode.sheet { background: var(--green-bg); color: var(--green); }
.range input[type=date], .range select { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 8px 10px; color: var(--text); min-width: 0; }
.range .sep { color: var(--muted); }
.quick { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.quick button { border: 0; background: transparent; padding: 5px 10px; border-radius: 9px; color: var(--text2); cursor: pointer; font-size: 12.5px; }
.quick button.active { background: var(--dark); color: #fff; }
.chk { display: flex; align-items: center; gap: 6px; color: var(--text2); font-size: 12.5px; }
.tablewrap.tall { max-height: 70vh; }
td.neg { color: var(--red); } td.pos { color: var(--green); }
.wcard .big { font-size: 22px; font-weight: 700; margin: 10px 0 2px; }
.wcard .big.neg { color: var(--red); }
.wrow { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text2); padding: 3px 0; }
.wrow b { color: var(--text); font-weight: 500; }

/* ---------- ИИ-помощник ---------- */
.ai-fab { position: fixed; right: 22px; bottom: 22px; z-index: 50; display: flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; padding: 12px 18px; background: var(--dark); color: #fff; font-weight: 600; box-shadow: 0 10px 28px rgba(20,22,43,.3); cursor: pointer; }
.ai-fab span { color: #9db2ff; font-size: 16px; }
.ai-fab:hover { background: var(--blue); }
.ai-panel { position: fixed; right: 22px; bottom: 22px; z-index: 60; width: min(440px, calc(100vw - 32px)); height: min(640px, calc(100vh - 44px)); background: var(--surface); border-radius: 20px; box-shadow: 0 18px 60px rgba(20,22,43,.25); display: flex; flex-direction: column; overflow: hidden; }
.ai-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 14px 12px 16px; border-bottom: 1px solid var(--border); background: var(--dark); color: #fff; }
.ai-title { display: flex; align-items: center; gap: 10px; }
.ai-title small { display: block; color: #c9cbe0; font-size: 11.5px; }
.ai-dot { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--blue); font-size: 16px; }
.ai-icon { border: 0; background: transparent; color: #c9cbe0; font-size: 15px; cursor: pointer; padding: 6px; border-radius: 8px; }
.ai-icon:hover { background: rgba(255,255,255,.12); color: #fff; }
.ai-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.ai-msg { max-width: 92%; padding: 10px 13px; border-radius: 14px; line-height: 1.5; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.ai-msg.bot { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; align-self: flex-start; white-space: normal; }
.ai-msg.user { background: var(--blue); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.ai-msg.err { background: var(--red-bg); color: var(--red); border-color: transparent; }
.ai-msg.bot p { margin: 0 0 8px; } .ai-msg.bot p:last-child { margin: 0; }
.ai-msg.bot ul, .ai-msg.bot ol { margin: 4px 0 8px; padding-left: 20px; }
.ai-msg.bot table { border-collapse: collapse; font-size: 12.5px; margin: 6px 0; } .ai-msg.bot th, .ai-msg.bot td { padding: 4px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.ai-msg.bot code { font-size: 12px; }
.ai-tools { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.ai-tools span { font-size: 10.5px; color: var(--muted); background: var(--surface2); border-radius: 999px; padding: 1px 7px; }
.ai-chips { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.ai-chips button { border: 1px solid var(--border); background: var(--surface); color: var(--blue-d); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; text-align: left; }
.ai-chips button:hover { border-color: var(--blue); }
.ai-typing { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; }
.ai-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: aiBlink 1.2s infinite; } .ai-typing i:nth-child(2) { animation-delay: .2s } .ai-typing i:nth-child(3) { animation-delay: .4s }
@keyframes aiBlink { 0%, 80%, 100% { opacity: .25 } 40% { opacity: 1 } }
.ai-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.ai-form textarea { flex: 1; resize: none; border: 1px solid var(--border); border-radius: 12px; padding: 9px 12px; background: var(--surface2); color: var(--text); max-height: 120px; line-height: 1.4; }
.ai-form button { border: 0; border-radius: 12px; width: 42px; background: var(--blue); color: #fff; font-size: 16px; cursor: pointer; }
.ai-form button:disabled { opacity: .5; cursor: default; }
@media (max-width: 600px) { .ai-panel { right: 8px; bottom: 8px; width: calc(100vw - 16px); height: calc(100vh - 16px); } }

/* ---------- настройки / telegram ---------- */
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: 7px 14px; cursor: pointer; font-weight: 500; }
.btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }
#tSched input, #tSched select, #tChats select { border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; background: var(--surface2); color: var(--text); font: inherit; }
#tSched input[type=text] { width: 100%; min-width: 240px; }
#tSched input[type=time] { width: 90px; }
#tSched td { white-space: normal; vertical-align: middle; }
.days { display: flex; gap: 2px; }
.days label { font-size: 11px; color: var(--text2); display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.preview { background: var(--surface2); border-radius: 12px; padding: 14px; white-space: pre-wrap; font: 12.5px/1.5 inherit; margin-top: 12px; }
.chip.ok { color: var(--green); background: var(--green-bg); border-color: transparent; }
.chip.err { color: var(--red); background: var(--red-bg); border-color: transparent; }
.ai-panel[hidden], .ai-fab[hidden] { display: none; }

/* ---------- задолженность ---------- */
.inv-form { display: grid; grid-template-columns: 2fr 1.2fr 1fr 1fr 1fr 2fr auto; gap: 8px; align-items: center; }
.inv-form input, .inv-form select { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--surface2); color: var(--text); min-width: 0; width: 100%; }
.inv-form .hint { grid-column: 1 / -1; }
@media (max-width: 1100px) { .inv-form { grid-template-columns: 1fr 1fr; } }
td.debt { font-weight: 600; } td.debt.pos { color: var(--red); }
tr.overdue td:first-child::before { content: '⚠ '; color: var(--red); }
.main { min-width: 0; }
.page { min-width: 0; }

.cls { display: inline-block; min-width: 22px; text-align: center; padding: 2px 6px; border-radius: 6px; font-size: 11.5px; font-weight: 700; }
.cls.A { background: #dcfce7; color: #166534; } .cls.B { background: #dbeafe; color: #1e40af; } .cls.C { background: var(--surface2); color: var(--text2); }
td.neg { color: var(--red); }

/* ---------- проверка расчётов ---------- */
.banner { background: var(--red-bg); color: var(--red); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-weight: 500; }
.banner a { text-decoration: underline; cursor: pointer; }
.vf { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); align-items: flex-start; }
.vf:first-child { border-top: 0; }
.vf .st { flex: none; width: 74px; text-align: center; font-size: 11px; font-weight: 700; padding: 3px 0; border-radius: 999px; }
.vf .st.ok { background: var(--green-bg); color: var(--green); } .vf .st.warn { background: var(--amber-bg); color: #a06a00; } .vf .st.fail { background: var(--red-bg); color: var(--red); } .vf .st.skip { background: var(--surface2); color: var(--muted); }
.vf b { display: block; } .vf details { color: var(--text2); font-size: 12.5px; } .vf summary { cursor: pointer; } .vf ul { margin: 4px 0 0; padding-left: 18px; }
tr.total td { font-weight: 600; background: var(--surface2); }

tr.sec td { background: var(--surface2); font-weight: 600; }
tr.sub td:first-child { padding-left: 24px; color: var(--text2); }
.days-strip { display: inline-flex; gap: 1px; }
.days-strip i { display: inline-block; width: 6px; height: 12px; border-radius: 2px; background: var(--surface2); } .days-strip i.on { background: var(--blue); }
td.pos { color: var(--green); } td.neg { color: var(--red); }
.kpi-sub { margin-top: 8px; font-size: 12px; line-height: 1.5; color: rgba(255,255,255,.85); border-top: 1px solid rgba(255,255,255,.18); padding-top: 6px; }
.kpi:not(.primary) .kpi-sub { color: var(--text2); border-top-color: var(--border); }

/* закреплённые первые колонки в таблице реестра под ЗП */
#tPz th:nth-child(-n+3), #tPz td:nth-child(-n+3) { position: sticky; background: var(--surface); z-index: 1; }
#tPz th:nth-child(1), #tPz td:nth-child(1) { left: 0; min-width: 190px; }
#tPz th:nth-child(2), #tPz td:nth-child(2) { left: 190px; min-width: 110px; }
#tPz th:nth-child(3), #tPz td:nth-child(3) { left: 300px; min-width: 90px; box-shadow: 2px 0 0 var(--border); }
#tPz th { z-index: 2; }
#tPz tr.total td { background: var(--surface2); }

/* индикатор обновления и кнопка «Применить» */
.busy { position: fixed; right: 20px; bottom: 84px; z-index: 70; background: var(--dark); color: #fff; border-radius: 999px; padding: 8px 16px; font-size: 13px; font-weight: 500; box-shadow: 0 8px 20px rgba(20,22,43,.3); display: flex; align-items: center; gap: 8px; }
.busy[hidden] { display: none; }
.busy.done { background: var(--green); }
.busy .sp { width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.dirty { background: var(--blue); color: #fff; border-color: var(--blue); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(75,92,245,.45); } 50% { box-shadow: 0 0 0 6px rgba(75,92,245,0); } }

/* строки пояснений в карточке долга и в блоке сверки */
.dbt { padding: 7px 0; border-top: 1px solid var(--border); }
.dbt:first-child { border-top: 0; }
.dbt b { display: block; font-weight: 600; }
.dbt span { display: block; font-size: 12px; margin-top: 2px; color: var(--muted); }
.kpi-sub .dbt { padding: 6px 0; border-top: 1px solid var(--border); }
.kpi-sub .dbt:first-child { border-top: 0; padding-top: 2px; }
.kpi-sub .dbt b { display: block; font-weight: 600; }
.kpi-sub .dbt span { display: block; font-size: 11.5px; margin-top: 1px; }
.kpi.primary .kpi-sub, .kpi.primary .kpi-sub b { color: #fff; }
.kpi.primary .kpi-sub .dbt { border-top-color: rgba(255,255,255,.22); }
.kpi.primary .kpi-sub .dbt span { color: rgba(255,255,255,.88); }
.kpi.primary .kpi-sub .wrow, .kpi.primary .kpi-sub .wrow span { color: #fff; }
.kpi.primary .kpi-sub .wrow b { color: #fff; }

/* ===== вход и роли ===== */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); padding: 20px; }
.login-card { width: 360px; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 26px 24px; box-shadow: 0 18px 50px rgba(20,25,60,.10); }
.login-card h2 { margin: 0 0 6px; font-size: 19px; }
.login-card .hint { margin: 0 0 16px; }
.login-card label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.login-card input { display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit; background: var(--surface2); }
.login-card input:focus { outline: none; border-color: var(--blue); background: var(--surface); }
.login-card .btn { width: 100%; justify-content: center; margin-top: 4px; }
.login-card .err { color: var(--red); font-size: 12.5px; min-height: 18px; margin-top: 10px; text-align: center; }
body.role-viewer .admin-only { display: none !important; }
.role-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface2); color: var(--muted); }
.role-badge.org { background: rgba(75,92,245,.12); color: var(--blue); }
.banner.demo { background: var(--amber-bg); color: #8a5b00; font-weight: 500; }
