:root{
  --bg:#F6F3EE; --surface:#FFFFFF; --ink:#26221D; --muted:#7A7268; --line:#E4DED5;
  --accent:#5E6B3A; --accent-ink:#FFFFFF; --mine:#5E6B3A; --mine-ink:#FFFFFF;
  --agent:#FFFFFF; --chip:#ECE7DF; --danger:#A33A2B; --rec:#C2412D;
  --r:20px; --font:-apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark){
  :root:not([data-mode=light]){ --bg:#1B1916; --surface:#26231F; --ink:#F1ECE4; --muted:#A39A8E; --line:#3A352F; --accent:#A3B370; --accent-ink:#1B1916; --mine:#56633A; --mine-ink:#F6F3EE; --agent:#2A2722; --chip:#302C27; --danger:#E0796A; color-scheme:dark; }
}
:root[data-mode=dark]{ --bg:#1B1916; --surface:#26231F; --ink:#F1ECE4; --muted:#A39A8E; --line:#3A352F; --accent:#A3B370; --accent-ink:#1B1916; --mine:#56633A; --mine-ink:#F6F3EE; --agent:#2A2722; --chip:#302C27; --danger:#E0796A; color-scheme:dark; }
:root[data-mode=light]{ --bg:#F6F3EE; --surface:#FFFFFF; --ink:#26221D; --muted:#7A7268; --line:#E4DED5; --accent:#5E6B3A; --accent-ink:#FFFFFF; --mine:#5E6B3A; --mine-ink:#FFFFFF; --agent:#FFFFFF; --chip:#ECE7DF; --danger:#A33A2B; color-scheme:light; }
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent}
html,body{margin:0; height:100%; background:var(--bg); color:var(--ink); font:17px/1.4 var(--font); overscroll-behavior:none}
body{position:fixed; inset:0; overflow:hidden}
button{font:inherit; color:inherit; background:none; border:0; cursor:pointer}
[hidden]{display:none !important}
svg{fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round}
.top svg circle{fill:currentColor; stroke:none}

.screen{position:absolute; left:0; right:0; top:0; height:var(--vh,100dvh); display:flex; flex-direction:column}

/* Вход */
#pair{align-items:center; justify-content:center; padding:24px}
.pair-box{width:100%; max-width:360px; text-align:center}
.pair-icon{width:84px; height:84px; border-radius:20px}
.pair-box h1{font-size:26px; margin:16px 0 6px}
.pair-box p{color:var(--muted); margin:0 0 20px}
#pairCode{width:100%; font:600 34px/1 var(--font); letter-spacing:12px; text-align:center; padding:16px; border-radius:16px;
  border:1.5px solid var(--line); background:var(--surface); color:var(--ink); outline:none}
#pairCode:focus{border-color:var(--accent)}
.primary{background:var(--accent); color:var(--accent-ink); border-radius:16px; padding:15px 22px; font-weight:600; width:100%; margin-top:14px}
.primary:active{opacity:.85}
.err{color:var(--danger); min-height:1.4em; margin-top:12px !important}

/* Шапка */
.top{display:flex; align-items:center; justify-content:space-between; padding:calc(env(safe-area-inset-top) + 8px) 12px 8px 18px;
  border-bottom:1px solid var(--line); background:var(--bg)}
.who{display:flex; gap:10px; align-items:center}
.title{font-weight:700; font-size:19px}
.sub{font-size:13px; color:var(--muted)}
.dot{width:10px; height:10px; border-radius:50%; background:#7DA453}
.dot.off{background:#C9A13B}
.icon-btn{width:44px; height:44px; display:grid; place-items:center; border-radius:50%; color:var(--ink)}
.icon-btn:active{background:var(--chip)}

.install{display:flex; gap:8px; align-items:center; justify-content:space-between; margin:8px 12px 0; padding:10px 12px;
  background:var(--chip); border-radius:14px; font-size:14px}
.install .share{vertical-align:-3px}
.link{font-size:24px; line-height:1; padding:0 6px; color:var(--muted)}

/* Лента */
#feed{flex:1; overflow-y:auto; -webkit-overflow-scrolling:touch; padding:14px 12px 8px; display:flex; flex-direction:column; gap:8px}
.empty{margin:auto; text-align:center; color:var(--muted); max-width:300px; font-size:16px}
.empty b{color:var(--ink)}
.msg{max-width:86%; padding:10px 14px; border-radius:var(--r); white-space:pre-wrap; word-wrap:break-word; overflow-wrap:anywhere}
.msg.agent{align-self:flex-start; background:var(--agent); border:1px solid var(--line); border-bottom-left-radius:6px}
.msg.user{align-self:flex-end; background:var(--mine); color:var(--mine-ink); border-bottom-right-radius:6px}
.msg a{color:inherit; text-decoration:underline}
.msg .time{display:block; font-size:11px; opacity:.55; margin-top:4px; text-align:right}
.msg.status{align-self:flex-start; background:transparent; border:0; color:var(--muted); font-size:15px; padding:4px 6px; display:flex; gap:8px; align-items:center}
.spin{width:16px; height:16px; border-radius:50%; border:2px solid var(--line); border-top-color:var(--accent); animation:sp 0.9s linear infinite; flex:none}
@keyframes sp{to{transform:rotate(360deg)}}
.msg img.media,.msg video.media{display:block; max-width:100%; max-height:60vh; border-radius:14px; margin:-4px -8px 6px; width:calc(100% + 16px); object-fit:cover; background:var(--chip)}
.msg .file{display:flex; gap:10px; align-items:center; padding:8px 10px; border-radius:12px; background:rgba(127,127,127,.12); text-decoration:none; margin-bottom:4px}
.msg .file svg{flex:none}
.msg .file small{display:block; opacity:.7}
.voice-tag{display:flex; gap:6px; align-items:center; font-size:13px; opacity:.8; margin-bottom:2px}
.btns{display:flex; flex-direction:column; gap:6px; margin-top:10px}
.btns .row{display:flex; gap:6px}
.btns button{flex:1; background:var(--chip); border-radius:12px; padding:11px 8px; font-weight:600; font-size:15px; color:var(--ink)}
.btns button:active{background:var(--line)}

/* Быстрые кнопки */
.chips{display:flex; gap:8px; overflow-x:auto; padding:6px 12px; scrollbar-width:none}
.chips::-webkit-scrollbar{display:none}
.chips button{flex:none; background:var(--chip); border-radius:999px; padding:8px 14px; font-size:15px}
.chips button:active{background:var(--line)}

/* Поле ввода */
.composer{display:flex; align-items:flex-end; gap:6px; padding:6px 10px calc(env(safe-area-inset-bottom) + 8px); background:var(--bg)}
.kb .composer{padding-bottom:8px}
#text{flex:1; resize:none; max-height:140px; min-height:44px; padding:11px 14px; border-radius:22px; border:1px solid var(--line);
  background:var(--surface); color:var(--ink); font:17px/1.3 var(--font); outline:none}
#text:focus{border-color:var(--accent)}
.mic,.send{flex:none; width:56px; height:56px; border-radius:50%; background:var(--accent); color:var(--accent-ink); display:grid; place-items:center;
  box-shadow:0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent); touch-action:none; user-select:none; -webkit-user-select:none}
.send{width:44px; height:44px; box-shadow:none}
.mic:active{transform:scale(.94)}
.attach{color:var(--muted)}

/* Запись */
.rec{position:absolute; left:0; right:0; bottom:0; background:var(--surface); border-top:1px solid var(--line);
  border-radius:24px 24px 0 0; padding:18px 18px calc(env(safe-area-inset-bottom) + 16px); box-shadow:0 -10px 30px rgba(0,0,0,.12)}
.rec-top{display:flex; align-items:center; gap:10px; font-variant-numeric:tabular-nums; font-size:20px; font-weight:600}
.rec-dot{width:12px; height:12px; border-radius:50%; background:var(--rec); animation:pulse 1.2s ease-in-out infinite}
@keyframes pulse{50%{opacity:.3}}
#recWave{flex:1; height:40px; width:100%}
.rec-hint{color:var(--muted); margin:10px 0 14px; font-size:15px}
.rec-actions{display:flex; gap:10px}
.rec-actions .primary{margin:0; flex:2}
.ghost{flex:1; border-radius:16px; padding:15px; background:var(--chip); font-weight:600}

/* Меню */
.sheet-bg{position:fixed; inset:0; background:rgba(0,0,0,.35)}
.sheet{position:fixed; left:0; right:0; bottom:0; background:var(--surface); border-radius:24px 24px 0 0; padding:8px 12px calc(env(safe-area-inset-bottom) + 12px);
  display:flex; flex-direction:column; max-height:85vh; overflow-y:auto}
.grab{width:40px; height:5px; border-radius:3px; background:var(--line); margin:4px auto 8px}
.sheet button{text-align:left; padding:14px 10px; border-radius:12px; font-size:17px}
.sheet button:active{background:var(--chip)}
.sheet .ghost{text-align:center; margin-top:6px}
.sheet .danger{color:var(--danger)}
.sheet hr{border:0; border-top:1px solid var(--line); width:100%; margin:6px 0}

.toast{position:fixed; left:50%; transform:translateX(-50%); bottom:calc(env(safe-area-inset-bottom) + 96px); background:var(--ink); color:var(--bg);
  padding:10px 16px; border-radius:14px; font-size:15px; max-width:90%; text-align:center; z-index:9}

/* Кнопки «посмотреть» */
.quick{display:grid; grid-template-columns:repeat(3,1fr); gap:6px; padding:6px 10px 4px}
.quick button{background:var(--surface); border:1px solid var(--line); border-radius:12px; padding:9px 4px; font-size:14px; line-height:1.15; box-shadow:0 1px 2px rgba(0,0,0,.05)}
.quick button b{font-weight:600}
.quick button:active{background:var(--chip)}
/* Документы и файлы к смете */
.quick2{display:flex; gap:6px; padding:2px 10px 4px}
.quick2 button{flex:1; border-radius:12px; padding:10px 6px; font-size:14px; font-weight:600; display:flex; align-items:center; justify-content:center; gap:6px}
.docs-btn{background:transparent; border:1.5px dashed var(--accent) !important; color:var(--accent)}
.task-btn{background:var(--accent); color:var(--accent-ink)}
.up-ic{display:inline-grid; place-items:center; width:26px; height:26px; border-radius:8px; background:var(--chip); color:var(--accent); font-size:15px; flex:none}
.docs-btn .up-ic{width:20px; height:20px; background:transparent}
.sheet-h{font-weight:700; font-size:19px; padding:4px 10px 2px}
.sheet-tip{color:var(--muted); font-size:14px; margin:2px 10px 8px}
.sheet .up-row,.side-docs button{display:flex !important; flex-direction:row !important; align-items:center !important; gap:10px}
.up-t{display:flex; flex-direction:column; text-align:left}
.up-t small{font-size:12px; color:var(--muted); font-weight:400}
.up-t small.none{color:#B07A2A}
.up-t small:empty{display:none}


/* ---------- Компьютер (широкий экран) ---------- */
.side{display:none}
.drop{position:fixed; inset:0; z-index:20; background:color-mix(in srgb, var(--accent) 18%, transparent); display:grid; place-items:center; pointer-events:none}
.drop div{background:var(--surface); border:2px dashed var(--accent); border-radius:20px; padding:28px 40px; font-size:20px; font-weight:600}
@media (min-width: 1000px){
  html,body{font-size:16px}
  .screen{height:100vh !important; transform:none !important}
  #main{display:grid; grid-template-columns:300px 1fr; grid-template-rows:auto auto 1fr auto}
  #main > *:not(.side){grid-column:2}
  .side{display:flex; flex-direction:column; grid-column:1; grid-row:1 / -1; background:var(--surface); border-right:1px solid var(--line);
    padding:16px 14px; overflow-y:auto; gap:14px}
  .side-brand{display:flex; align-items:center; gap:10px; font-weight:700; font-size:20px; padding:0 6px}
  .side-brand img{width:34px; height:34px; border-radius:9px}
  .side-group{display:flex; flex-direction:column; gap:2px}
  .side-h{font-size:12px; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); padding:0 10px 6px}
  .side button{display:flex; flex-direction:column; align-items:flex-start; text-align:left; padding:7px 10px; border-radius:10px; font-size:15px}
  .side button:hover{background:var(--chip)}
  .side button small{font-size:12px; color:var(--muted); margin-top:1px; max-width:250px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
  .side button small.none{color:#B07A2A}
  .side button small:empty{display:none}
  .side .side-main{background:var(--accent); color:var(--accent-ink); padding:12px 12px}
  .side .side-main:hover{background:var(--accent); opacity:.92}
  .side .side-main small{color:var(--accent-ink); opacity:.8}
  .side-tip{font-size:13px; color:var(--muted); margin:6px 10px 0}
  .side-bottom{margin-top:auto}
  .side-info{display:grid; grid-template-columns:1fr 1fr; gap:6px}
  .side-info button{border:1px solid var(--line); background:var(--bg); align-items:center !important; text-align:center !important; padding:9px 6px !important; font-weight:600}
  .side-docs{border:1.5px dashed var(--line); border-radius:12px; padding:10px 4px 6px}
  .side-docs .top-tip{margin:0 10px 6px}
  .side .ask-link{color:var(--accent); font-size:14px}
  #chips,#docChips,#install{display:none !important}
  .top{padding:10px 24px}
  .top .who .title{font-size:17px}
  #feed{padding:24px max(24px, calc((100% - 860px) / 2)) 12px}
  .msg{max-width:78%; font-size:16px}
  .composer{padding:10px max(24px, calc((100% - 860px) / 2)) 18px}
  #text{font-size:16px}
  .rec{left:300px}
  .sheet{left:auto; right:24px; top:64px; bottom:auto; width:340px; border-radius:16px; box-shadow:0 12px 40px rgba(0,0,0,.18)}
  .grab{display:none}
  .toast{left:calc(50% + 150px); bottom:100px}
  .icon-btn:hover,.btns button:hover{background:var(--chip)}
}
.dlbtn{display:inline-block; margin:8px 0 2px; padding:8px 16px; border-radius:18px; background:var(--accent); color:var(--accent-ink) !important; text-decoration:none; font-size:15px}

.msg.paycard{display:flex; flex-direction:column; gap:8px; border:2px solid var(--accent)}
.paybtn{display:block; text-align:center; padding:12px 16px; border-radius:14px; background:var(--accent); color:var(--accent-ink) !important; font-weight:600; text-decoration:none !important}
.paymodal{position:fixed; inset:0; background:rgba(0,0,0,.45); display:flex; align-items:flex-end; justify-content:center; z-index:1000; padding:16px}
.paybox{background:var(--bg,#f6f3ee); color:var(--ink,#222); border-radius:20px; padding:20px; max-width:440px; width:100%; display:flex; flex-direction:column; gap:12px; white-space:pre-wrap; font-size:16px}
.paybox b{font-size:19px}
.paylater{background:transparent; border:0; font:inherit; color:var(--muted,#777); padding:8px; cursor:pointer}

.inv-form{display:flex; flex-direction:column; gap:10px; padding:4px 10px 8px}
.inv-form label{display:flex; flex-direction:column; gap:4px; font-size:14px; color:var(--muted)}
.inv-form input{font:inherit; font-size:17px; color:var(--ink); background:var(--bg); border:1px solid var(--line); border-radius:12px; padding:11px 12px}
.sheet .inv-go{text-align:center; background:var(--accent); color:var(--accent-ink); font-weight:600; margin-top:4px}
.inv-form select{font:inherit; font-size:17px; color:var(--ink); background:var(--bg); border:1px solid var(--line); border-radius:12px; padding:11px 12px}

/* Подпись */
.sign-prev{background:#fff; border:1px solid var(--line); border-radius:14px; margin:4px 10px 8px; min-height:110px; display:grid; place-items:center; position:relative; padding:12px}
.sign-prev::after{content:""; position:absolute; left:14%; right:14%; bottom:26px; border-bottom:1px solid #999}
.sign-prev img{max-width:100%; object-fit:contain; position:relative; z-index:1; margin-bottom:6px}
.sign-prev.off img{opacity:.3}
.sign-empty{color:var(--muted); font-size:14px}
.sheet .sign-up{background:var(--accent); color:var(--accent-ink); text-align:center; font-weight:600; margin:0 10px 6px}
.sign-grid{display:grid; grid-template-columns:repeat(3,1fr); gap:6px; margin:0 10px}
.sheet .sign-grid button{background:var(--chip); text-align:center; padding:11px 4px; font-size:15px}
.sign-colors{display:flex; align-items:center; gap:6px; margin:8px 10px 0; font-size:14px; color:var(--muted)}
.sheet .sign-colors button{flex:1; text-align:center; padding:9px 4px; font-size:14px; border:1.5px solid var(--line); background:transparent}
.sheet .sign-colors button.on{border-color:var(--accent); color:var(--ink); font-weight:600}
.c-blue::before,.c-black::before,.c-photo::before{content:""; display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:5px; vertical-align:0}
.c-blue::before{background:#162D8C}.c-black::before{background:#19191E}.c-photo::before{background:linear-gradient(135deg,#2a3a7a,#555)}
.sheet-bg{z-index:5}.sheet{z-index:6}
.quick .wide2,.side-info .wide2{grid-column:span 2}
.quick2 .docs-btn{flex:1}
.quick .wide3{grid-column:span 3}
.quick .inv-open{grid-column:1/-1}
.side-info .side-inv{grid-column:1/-1}

/* Просмотр документа */
.viewer{position:fixed; inset:0; z-index:50; background:var(--bg); display:flex; flex-direction:column}
.v-top{display:flex; align-items:center; gap:8px; padding:calc(env(safe-area-inset-top) + 8px) 10px 8px; border-bottom:1px solid var(--line); background:var(--surface)}
.v-back{display:flex; align-items:center; gap:2px; font-size:17px; font-weight:600; color:var(--accent); padding:8px 6px; background:none}
.v-back svg{fill:none; stroke:currentColor; stroke-width:2.4; stroke-linecap:round; stroke-linejoin:round}
.v-name{flex:1; min-width:0; font-size:14px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; text-align:center}
.v-x{font-size:20px; padding:8px 10px; background:none; color:var(--ink)}
.v-body{flex:1; overflow:auto; -webkit-overflow-scrolling:touch; padding:10px; background:#e9e6df}
.v-page{display:block; width:100%; max-width:900px; margin:0 auto 10px; background:#fff; box-shadow:0 1px 4px rgba(0,0,0,.15)}
.v-doc{background:#fff; max-width:900px; margin:0 auto; padding:16px; font-size:14px; color:#222}
.v-doc .vt{overflow-x:auto} .v-doc table{border-collapse:collapse; font-size:12px} .v-doc td{border:1px solid #ccc; padding:4px 6px; white-space:nowrap}
.v-doc h4{margin:10px 0 6px} .v-doc pre{white-space:pre-wrap}
.v-wait{color:var(--muted); text-align:center; padding:40px 20px}
.v-bar{display:flex; gap:8px; padding:10px 12px calc(env(safe-area-inset-bottom) + 10px); background:var(--surface); border-top:1px solid var(--line)}
.v-bar button{flex:1; border-radius:14px; padding:14px; font-size:17px; font-weight:600}
.v-primary{background:var(--accent); color:var(--accent-ink)} .v-sec{background:var(--chip); color:var(--ink)}
.v-share{display:grid; grid-template-columns:1fr 1fr; gap:6px; padding:10px 12px 0; background:var(--surface)}
.v-share a,.v-share button{display:block; text-align:center; padding:12px; border-radius:12px; background:var(--chip); color:var(--ink); text-decoration:none; font-size:15px; font-weight:600}
body.noscroll{overflow:hidden}
.v-page:not([src]){aspect-ratio:210/297}

.co-box{display:flex; flex-direction:column; gap:6px; margin:-4px 0 4px}
.co-h,.co-none{font-size:13px; color:var(--muted); padding:2px 2px}
.sheet .co-card,.co-card{display:block; text-align:left; background:var(--bg); border:1px solid var(--line); border-radius:12px; padding:9px 11px; font-size:14px; color:var(--ink); line-height:1.3}
.co-card b{display:block; font-weight:600} .co-card small{color:var(--muted); font-size:12px}
.co-card.on{border-color:var(--accent)} .co-ok{display:block; color:var(--accent); font-size:12px; font-weight:600; margin-top:4px}
.co-bad{color:var(--danger)}
.sheet .co-skip{font-size:13px; color:var(--muted); padding:6px 2px; text-align:left; background:none}
.sheet .sign-save{background:var(--accent); color:var(--accent-ink); text-align:center; font-weight:600; margin-top:8px}

.shops-info{padding:2px 10px 4px; font-size:15px; line-height:1.4; color:var(--ink); max-height:62vh; overflow:auto}
.shops-info p{margin:0 0 9px}

.look{padding:4px 10px 6px}
.look-h{font-size:14px; color:var(--muted); margin:6px 0 8px}
.modes{display:flex; gap:8px}
.sheet .modes button{flex:1; display:flex; align-items:center; justify-content:center; gap:8px; padding:10px; border:1.5px solid var(--line); border-radius:12px; font-size:15px; text-align:center}
.sheet .modes button.on{border-color:var(--accent); font-weight:600}
.modes svg{width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round}
.swatches{display:grid; grid-template-columns:repeat(9, 1fr); gap:6px}
.sheet .swatches button{aspect-ratio:1; padding:0; border-radius:50%; border:2px solid var(--surface); box-shadow:0 0 0 1.5px var(--line); position:relative}
.sheet .swatches button.on{box-shadow:0 0 0 2.5px var(--ink)}
.sw-name{font-size:13px; color:var(--muted); margin-top:6px; min-height:17px}

/* Техподдержка */
.inv-form textarea{font:inherit; font-size:17px; color:var(--ink); background:var(--bg); border:1px solid var(--line); border-radius:12px; padding:11px 12px; resize:vertical; min-height:96px}
.sup-file input{font-size:15px; color:var(--ink)}
.sup-ans{background:var(--chip); border-radius:14px; padding:12px; font-size:15px; line-height:1.4; white-space:pre-wrap; color:var(--ink)}
.sup-ans b{display:block; margin-bottom:4px}
#supSheet{max-height:88vh; overflow:auto}

.doc-dl{display:block;margin:-4px 0 8px 46px;font-size:13px;color:var(--accent,#1f6f8b);text-decoration:none;line-height:1.3}
.doc-dl[hidden]{display:none}

.up-btn{margin-left:auto; margin-right:6px; padding:8px 14px; border-radius:999px; background:var(--accent); color:var(--accent-ink); font-weight:600; font-size:14px; text-decoration:none; white-space:nowrap}
.sheet-link{display:block; text-align:left; padding:14px 10px; border-radius:12px; font-size:17px; color:var(--ink); text-decoration:none}

/* ---------- Заказчики и контрагенты, сканер ---------- */
.toast{z-index:100}
.sheet-bg{z-index:41}.sheet{z-index:42}
.sheet-bg.over{z-index:60}.sheet.over{z-index:61}
.kscr{position:fixed; inset:0; z-index:40; background:var(--bg); display:flex; flex-direction:column}
.kscr.scan{z-index:45}
.k-title{font-size:16px; font-weight:600; color:var(--ink)}
.k-body{flex:1; overflow:auto; -webkit-overflow-scrolling:touch; padding:12px; width:100%; max-width:760px; margin:0 auto; box-sizing:border-box}
.k-tools{display:flex; gap:8px}
.k-tools input{flex:1; min-width:0; font:inherit; font-size:16px; color:var(--ink); background:var(--surface); border:1px solid var(--line); border-radius:14px; padding:11px 12px}
.k-add{background:var(--accent); color:var(--accent-ink); border-radius:14px; padding:0 14px; font-weight:600; font-size:15px; white-space:nowrap}
.k-seg{display:flex; gap:6px; margin:10px 0}
.k-seg button{flex:1; padding:9px 4px; border-radius:12px; background:var(--chip); color:var(--ink); font-size:14px}
.k-seg button.on{background:var(--ink); color:var(--bg); font-weight:600}
.k-list{display:flex; flex-direction:column; gap:6px}
.k-item{display:flex; align-items:center; gap:10px; text-align:left; background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:10px 12px; color:var(--ink)}
.k-av{flex:none; width:40px; height:40px; border-radius:50%; display:grid; place-items:center; background:color-mix(in srgb, var(--accent) 22%, var(--surface)); color:var(--ink); font-weight:700; font-size:15px}
.k-av.alt{background:color-mix(in srgb, #8a6a3a 25%, var(--surface))}
.k-av.big{width:52px; height:52px; font-size:18px}
.k-it{flex:1; min-width:0; display:flex; flex-direction:column}
.k-it b,.k-dt b{font-size:16px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.k-it small,.k-dt small,.k-hn small{font-size:13px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.k-dot{flex:none; width:22px; height:22px; border-radius:50%; background:var(--danger); color:#fff; font-weight:700; font-size:13px; display:grid; place-items:center}
.k-n{flex:none; min-width:24px; padding:2px 7px; border-radius:12px; background:var(--chip); color:var(--muted); font-size:13px; text-align:center}
.k-empty{color:var(--muted); text-align:center; padding:30px 16px; line-height:1.45}
.k-scanfree{display:block; width:100%; margin-top:14px; padding:13px; border-radius:14px; border:1.5px dashed var(--line); background:none; color:var(--ink); font-size:15px}
.k-lim{color:var(--muted); font-size:13px; text-align:center; margin:10px 0 20px}
.k-head{display:flex; align-items:center; gap:12px; padding:4px 2px 12px}
.k-hn{flex:1; min-width:0; display:flex; flex-direction:column}
.k-hn b{font-size:19px; font-weight:700; line-height:1.25}
.k-editbtn{background:var(--chip); color:var(--ink); border-radius:12px; padding:9px 12px; font-size:14px; font-weight:600}
.k-acts{display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-bottom:14px}
.k-acts button{display:flex; flex-direction:column; align-items:center; gap:4px; padding:12px 4px; border-radius:16px; background:var(--accent); color:var(--accent-ink); font-size:14px; font-weight:600; line-height:1.2}
.k-acts button span{font-size:20px; line-height:1}
.k-acts button+button{background:var(--surface); color:var(--ink); border:1px solid var(--line)}
.k-sec{background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:10px 12px; margin-bottom:10px}
.k-sec-h{font-size:13px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); margin:2px 0 6px}
.k-row{display:grid; grid-template-columns:minmax(90px,38%) 1fr; gap:2px 10px; padding:7px 0; border-top:1px solid var(--line); font-size:15px}
.k-sec-h+.k-row{border-top:0}
.k-row span{color:var(--muted); font-size:14px}
.k-row b{font-weight:500; word-break:break-word}
.k-row em{grid-column:2; font-style:normal; font-size:12px; color:var(--muted)}
.k-hint{color:var(--muted); font-size:14px; margin:4px 0; line-height:1.4}
.k-conf{background:color-mix(in srgb, var(--danger) 10%, var(--surface)); border:1px solid color-mix(in srgb, var(--danger) 35%, var(--line)); border-radius:16px; padding:10px 12px; margin-bottom:10px}
.k-cf{font-size:14px; padding:6px 0; line-height:1.35}
.k-cfb{display:flex; gap:6px; margin-top:6px}
.k-cfb button{flex:1; padding:8px; border-radius:10px; background:var(--surface); color:var(--ink); border:1px solid var(--line); font-size:14px}
.k-cfb button:first-child{background:var(--accent); color:var(--accent-ink); border-color:var(--accent)}
.k-doc{display:flex; align-items:center; gap:6px; border-top:1px solid var(--line)}
.k-sec-h+.k-doc{border-top:0}
.k-dopen{flex:1; min-width:0; display:flex; align-items:center; gap:10px; text-align:left; padding:8px 0; background:none; color:var(--ink)}
.k-dt{flex:1; min-width:0; display:flex; flex-direction:column}
.k-dt b{font-size:15px}
.k-ic{flex:none; width:34px; height:40px; border-radius:6px; display:grid; place-items:center; font-weight:700; font-size:14px; background:var(--chip); color:var(--ink)}
.k-ic.t-contract{background:color-mix(in srgb, var(--accent) 25%, var(--surface))}
.k-ic.t-invoice,.k-ic.t-act{background:color-mix(in srgb, #3a6a8a 22%, var(--surface))}
.k-word{flex:none; background:none; cursor:pointer; font-size:13px; font-weight:600; color:var(--accent); text-decoration:none; padding:6px 8px; border:1px solid var(--line); border-radius:10px}
.k-upl{display:flex; align-items:center; justify-content:center; gap:8px; width:100%; padding:13px; border-radius:14px; border:1.5px dashed var(--line); background:none; color:var(--ink); font-size:15px; margin:4px 0 24px}
.tpl-h{margin-top:10px}
.sheet .tpl-row{display:flex !important; flex-direction:row !important; align-items:center !important; gap:10px}
.tpl-btns{display:flex; flex-wrap:wrap; gap:6px; padding:0 10px 6px}
.v-undo{display:flex; align-items:center; gap:10px; padding:8px 14px; background:var(--surface); border-top:1px solid var(--line); font-size:14px}
.v-undo span{flex:1}
.v-undo button{background:var(--chip); color:var(--ink); border-radius:10px; padding:8px 12px; font-weight:600}
.v-bar.more button{font-size:15px; padding:12px 6px}
.v-bar button.on{background:var(--ink); color:var(--bg)}
.v-body.signing .v-page{cursor:crosshair; outline:3px dashed var(--accent); outline-offset:-3px}
/* сканер */
.sc-tip{color:var(--muted); font-size:15px; line-height:1.45; margin:4px 2px 12px}
.sc-modes{display:flex; gap:6px; margin-bottom:12px}
.sc-modes button{flex:1; padding:9px 4px; border-radius:12px; background:var(--chip); color:var(--ink); font-size:14px}
.sc-modes button.on{background:var(--ink); color:var(--bg); font-weight:600}
.sc-pages{display:grid; grid-template-columns:repeat(auto-fill, minmax(140px,1fr)); gap:10px; margin-bottom:12px}
.sc-p{position:relative; background:#fff; border-radius:8px; box-shadow:0 1px 4px rgba(0,0,0,.18); aspect-ratio:210/297; overflow:hidden}
.sc-p img{width:100%; height:100%; object-fit:contain; display:block}
.sc-busy{height:100%; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; color:#7A7268; font-size:13px}
.sc-n{position:absolute; top:6px; left:6px; background:rgba(0,0,0,.6); color:#fff; font-size:12px; font-weight:700; border-radius:10px; padding:2px 7px}
.sc-pb{position:absolute; left:0; right:0; bottom:0; display:flex; gap:4px; padding:6px; background:linear-gradient(transparent, rgba(0,0,0,.55))}
.sc-pb button{flex:1; padding:7px 2px; border-radius:9px; background:rgba(255,255,255,.92); color:#26221D; font-size:13px; font-weight:600}
.sc-add{display:flex; flex-direction:column; gap:8px; margin-bottom:20px}
.sc-big{padding:16px; border-radius:16px; background:var(--accent); color:var(--accent-ink); font-size:17px; font-weight:600}
.sc-sec{padding:13px; border-radius:14px; background:var(--chip); color:var(--ink); font-size:15px}
.sc-name{flex:1.4; min-width:0; font:inherit; font-size:15px; color:var(--ink); background:var(--bg); border:1px solid var(--line); border-radius:14px; padding:10px 12px}
.v-primary:disabled{opacity:.45}
.crop{position:fixed; inset:0; z-index:47; background:#111; display:flex; flex-direction:column}
.crop-tip{color:#ddd; text-align:center; font-size:14px; padding:calc(env(safe-area-inset-top) + 12px) 12px 8px}
.crop-stage{flex:1; min-height:0; display:flex; align-items:center; justify-content:center; padding:20px}
.crop-wrap{position:relative; line-height:0; touch-action:none}
.crop-wrap img{max-width:calc(100vw - 40px); max-height:calc(100vh - 190px); display:block; user-select:none; -webkit-user-drag:none}
.crop-wrap svg{position:absolute; inset:0; width:100%; height:100%; pointer-events:none}
.crop-wrap polygon{fill:rgba(163,179,112,.18); stroke:#A3B370; stroke-width:2; vector-effect:non-scaling-stroke}
.crop-wrap i{position:absolute; width:30px; height:30px; margin:-15px 0 0 -15px; border-radius:50%; border:3px solid #A3B370; background:rgba(255,255,255,.35); touch-action:none; cursor:grab; box-shadow:0 0 0 1px rgba(0,0,0,.4)}
.crop-wrap i.drag{background:rgba(163,179,112,.6); transform:scale(1.2)}
.crop .v-bar{background:#1b1b1b; border-top-color:#333}

.k-saved{position:fixed; left:0; right:0; bottom:0; z-index:90; background:var(--surface); border-top:1px solid var(--line); border-radius:18px 18px 0 0;
  box-shadow:0 -8px 30px rgba(0,0,0,.18); padding:16px 14px calc(env(safe-area-inset-bottom) + 12px)}
.k-saved-t{font-size:16px; line-height:1.4; margin:0 4px 12px; font-weight:600}
.k-saved-b{display:flex; flex-direction:column; gap:8px}
.k-saved-b button{border-radius:14px; padding:14px; font-size:17px; font-weight:600}
@media (min-width:700px){.k-saved{left:50%; right:auto; transform:translateX(-50%); width:440px; bottom:20px; border-radius:18px; border:1px solid var(--line)}}

.k-sec-hb{display:flex; align-items:center; justify-content:space-between; gap:8px; margin:0 0 4px}
.k-sec-hb .k-sec-h{margin:2px 0}
.k-new{flex:none; background:none; border:1px solid var(--line); color:var(--accent); font-size:14px; font-weight:600; padding:6px 10px; border-radius:10px; cursor:pointer}
.k-sec-hb+.k-doc{border-top:0}
.k-none{margin:2px 0 4px; font-size:14px}
.k-more{flex:none; width:40px; height:40px; border-radius:12px; background:none; color:var(--ink); font-size:22px; line-height:1; font-weight:700; cursor:pointer}
.k-more:hover{background:var(--bg)}
.k-paid{flex:none; font-size:12px; padding:3px 8px; border-radius:20px; background:var(--bg); color:var(--muted); white-space:nowrap}
.k-paid.on{background:#e3efd9; color:#3d6b22}
.k-pop-bg{position:fixed; inset:0; background:rgba(0,0,0,.35); z-index:80}
.k-pop{position:fixed; left:0; right:0; bottom:0; z-index:81; background:var(--surface); border-radius:20px 20px 0 0; padding:14px 12px calc(env(safe-area-inset-bottom) + 12px); display:flex; flex-direction:column; gap:6px; max-height:85vh; overflow:auto}
.k-pop-t{font-size:16px; font-weight:700; margin:2px 6px 6px; overflow:hidden; text-overflow:ellipsis}
.k-pop-tip{font-size:14px; color:var(--muted); margin:0 6px 4px; line-height:1.4}
.k-pop button{padding:14px; border-radius:14px; background:var(--bg); color:var(--ink); font-size:16px; font-weight:600; text-align:left; cursor:pointer}
.k-pop button.del{color:#b3261e}
.k-pop button.k-pop-x{text-align:center; background:none; border:1px solid var(--line)}
.k-pop button.k-pop-go{text-align:center; background:var(--accent); color:var(--accent-ink)}
.k-pop textarea{width:100%; box-sizing:border-box; border:1px solid var(--line); border-radius:12px; padding:12px; font:inherit; font-size:16px; background:var(--bg); color:var(--ink); resize:vertical}
@media (min-width:700px){.k-pop{left:50%; right:auto; bottom:auto; top:50%; transform:translate(-50%,-50%); width:400px; border-radius:18px}}

.toast{pointer-events:none}
