*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;overflow:hidden;background:#dfe8f2;font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",Roboto,sans-serif;color:#14203a;font-size:15px}
button{font:inherit;color:inherit;border:0;background:none;cursor:pointer}
input,textarea,select{font:inherit;color:#14203a}
.hidden{display:none!important}
#c{position:fixed;left:0;top:0;width:100%;height:100%;display:block;touch-action:none}
.glass{background:rgba(22,30,52,.62);backdrop-filter:blur(14px) saturate(1.3);-webkit-backdrop-filter:blur(14px) saturate(1.3);border:1px solid rgba(255,255,255,.14);color:#fff;box-shadow:0 6px 24px rgba(0,0,0,.22)}

/* верхняя панель */
#topbar{position:fixed;top:calc(8px + env(safe-area-inset-top));left:8px;right:8px;z-index:20;display:flex;align-items:center;gap:8px;padding:6px 6px 6px 14px;border-radius:18px}
#topbar .ttl{font-weight:800;font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1}
#topbar .ttl small{display:block;font-weight:500;font-size:11px;opacity:.75}
#userBtn{display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:14px;background:rgba(255,255,255,.14);font-size:13px;max-width:46%}
#userBtn span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#netDot{width:8px;height:8px;border-radius:50%;background:#35d07f;flex:none}
#netDot.off{background:#e5484d}

/* слои и легенда */
#layers{position:fixed;top:calc(62px + env(safe-area-inset-top));left:8px;z-index:15;display:flex;gap:4px;padding:4px;border-radius:14px}
#layers button{padding:7px 11px;border-radius:11px;font-size:13px;font-weight:600;opacity:.7}
#layers button.on{background:rgba(255,255,255,.22);opacity:1}
#legend{position:fixed;top:calc(108px + env(safe-area-inset-top));left:8px;z-index:14;padding:6px 10px;border-radius:12px;font-size:11.5px;display:flex;gap:10px;flex-wrap:wrap;max-width:calc(100% - 80px)}
.sandleg{display:inline-block;width:18px;height:4px;vertical-align:middle;background:repeating-linear-gradient(90deg,#7a4a1e 0 5px,transparent 5px 9px);border-radius:2px}
#fab{position:fixed;right:10px;top:calc(62px + env(safe-area-inset-top));z-index:15;display:flex;flex-direction:column;gap:8px}
#fab button{width:46px;height:46px;border-radius:50%;font-size:20px;display:flex;align-items:center;justify-content:center}
#fab .plus{background:#2f6fe4;color:#fff;font-size:28px;font-weight:300;box-shadow:0 6px 18px rgba(47,111,228,.45);border:0}
#tool{position:fixed;left:8px;right:64px;top:calc(108px + env(safe-area-inset-top));z-index:18;padding:10px 34px 10px 12px;border-radius:14px;font-size:13.5px;line-height:1.4}
#tool .x{position:absolute;right:6px;top:6px;width:26px;height:26px;border-radius:50%;background:rgba(255,255,255,.18)}
.gchips{display:flex;gap:5px;flex-wrap:wrap;margin-top:7px}.gchips button,.gact button{padding:7px 10px;border-radius:11px;background:rgba(255,255,255,.15);font-size:12.5px;font-weight:600}
.gchips button.on{background:#2f6fe4}.gact{display:flex;gap:6px;margin-top:8px}.gact .pri{background:#35b86b}
#attr{position:fixed;right:6px;bottom:2px;font-size:10px;opacity:.7;z-index:3;color:#fff;text-shadow:0 1px 2px #000}

/* нижние вкладки (телефон) */
#tabs{position:fixed;left:8px;right:8px;bottom:calc(8px + env(safe-area-inset-bottom));margin:auto;max-width:560px;z-index:30;display:flex;gap:2px;padding:5px;border-radius:20px}
#tabs button{flex:1;position:relative;display:flex;flex-direction:column;align-items:center;padding:6px 2px;border-radius:14px;font-size:20px;line-height:1.1}
#tabs small{font-size:10.5px;opacity:.85;margin-top:2px}
#tabs button.on{background:rgba(47,111,228,.9)}
.badge{position:absolute;top:2px;right:calc(50% - 22px);min-width:18px;height:18px;padding:0 5px;border-radius:9px;background:#e5484d;color:#fff;font-size:11px;font-weight:800;line-height:18px;text-align:center}

/* боковая панель / полноэкранные вкладки */
#side{position:fixed;left:0;right:0;top:0;bottom:0;z-index:25;background:#f1f4f9;display:flex;flex-direction:column;padding-top:calc(60px + env(safe-area-inset-top));padding-bottom:calc(76px + env(safe-area-inset-bottom))}
#sideBody{flex:1;overflow-y:auto;padding:4px 12px 20px;-webkit-overflow-scrolling:touch}
.seg{display:flex;background:#e3e8f0;border-radius:12px;padding:3px;margin:6px 0 10px}
.seg button{flex:1;padding:9px 6px;border-radius:10px;font-weight:700;font-size:14px;color:#5a6580}
.seg button.on{background:#fff;color:#14203a;box-shadow:0 1px 3px rgba(0,0,0,.1)}
.card{background:#fff;border-radius:16px;padding:14px;margin:0 0 10px;box-shadow:0 1px 2px rgba(0,0,0,.05)}
.card.warn{background:#fff6e8}
.ct{font-weight:800;font-size:15px;margin-bottom:8px;display:flex;align-items:center;justify-content:space-between;gap:8px}
.big{font-size:28px;font-weight:800}.big small{font-size:14px;font-weight:600;color:#7a849c}
.bar{height:10px;border-radius:5px;background:#f0d9d9;overflow:hidden;margin:6px 0}.bar i{display:block;height:100%;background:#2fb36b}
.muted{font-size:12.5px;color:#7a849c;line-height:1.4}
.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.pchips{display:flex;gap:6px;overflow-x:auto;margin:6px 0;padding-bottom:2px}
.pchips button,.chip{white-space:nowrap;padding:7px 11px;border-radius:12px;background:#fff;border:1px solid #dfe4ec;font-size:13px}
.pchips button.on{background:#2f6fe4;color:#fff;border-color:#2f6fe4}
.search{width:100%;padding:11px 12px;border-radius:12px;border:1px solid #d6dbe6;font-size:15px;background:#fff}
.li{display:flex;align-items:center;gap:10px;background:#fff;border-radius:14px;padding:11px 12px;margin:6px 0;cursor:pointer;box-shadow:0 1px 2px rgba(0,0,0,.05);position:relative}
.li .ic{width:38px;height:38px;border-radius:12px;display:flex;align-items:center;justify-content:center;font-size:20px;flex:none}
.lt{flex:1;min-width:0}.lt b{display:block;font-size:14.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.lt small{display:block;font-size:12px;color:#7a849c;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.li .nd{position:absolute;left:4px;top:4px;width:9px;height:9px;border-radius:50%;background:#e5484d}
.sd{width:12px;height:12px;border-radius:50%;flex:none}.sd.none{background:#e5484d}.sd.done{background:#2fb36b}.sd.off{background:#c3ccd8}
.st{font-size:11.5px;font-weight:800;padding:3px 8px;border-radius:8px;white-space:nowrap}
.st.new{background:#e8effd;color:#2f6fe4}.st.work{background:#fff2dc;color:#b26b00}.st.done{background:#e6f6ed;color:#1e8c50}.st.accepted{background:#dff3e8;color:#14683b}.st.over{background:#fde8e8;color:#c0392b}
.pr2{color:#c0392b;font-weight:800}.pr1{color:#d9771a;font-weight:800}
.wbtn{display:block;width:100%;margin-top:10px;padding:13px;border-radius:13px;background:#2f6fe4;color:#fff;font-weight:700;font-size:15px;text-align:center;text-decoration:none}
.wbtn.sec{background:#eef1f7;color:#14203a}.wbtn.danger{background:#fdecec;color:#c0392b}
.tg{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:6px}.tg button{padding:13px 8px;border-radius:13px;background:#eef1f7;font-weight:700;font-size:13.5px}
.ur{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 0;border-bottom:1px solid #eef1f7}.ur:last-child{border-bottom:0}
.ur b{display:block;font-size:14px}.ur small{font-size:12px;color:#7a849c}.ur button{padding:7px 11px;border-radius:10px;background:#eef1f7;font-size:13px;flex:none}
.empty{text-align:center;color:#7a849c;padding:30px 10px;font-size:14px}

/* карточка (объект / задача) */
#sheet{position:fixed;left:0;right:0;bottom:0;margin:auto;max-width:560px;z-index:28;background:#fff;border-radius:22px 22px 0 0;box-shadow:0 -10px 40px rgba(0,0,0,.3);display:flex;flex-direction:column;max-height:72vh;padding-bottom:calc(72px + env(safe-area-inset-bottom))}
#sheet .sh{padding:10px 16px 6px;position:relative}
#sheet .grab{width:40px;height:5px;border-radius:3px;background:#d4d9e3;margin:0 auto 10px}
#sheet .x{position:absolute;right:12px;top:12px;width:32px;height:32px;border-radius:50%;background:#eef1f7;color:#5a6580;font-size:15px}
#sheet h3{margin:0;font-size:19px;padding-right:40px;display:flex;gap:8px;align-items:flex-start}
#sheet .sub{font-size:13px;color:#5a6580;margin-top:6px;display:flex;gap:6px;flex-wrap:wrap;align-items:center}
#sheet .sb{overflow-y:auto;padding:4px 16px 16px;flex:1}
.lbl{font-size:12px;color:#5a6580;margin:12px 0 4px;font-weight:600}
.form label{display:block;font-size:12px;color:#5a6580;margin:10px 0 0}
.form input:not([type=checkbox]):not([type=range]):not([type=file]),.form textarea,.form select,#modal input:not([type=checkbox]),#modal textarea,#modal select{display:block;width:100%;padding:10px 11px;border:1px solid #d6dbe6;border-radius:11px;font-size:15px;margin-top:4px;background:#fafbfd}
.form input[type=range]{width:100%;accent-color:#2f6fe4}
.ck{display:flex!important;align-items:center;gap:8px;font-size:14px!important;color:#14203a!important;margin-top:10px!important}
.ck input{width:20px;height:20px;accent-color:#2f6fe4}
.chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}
.chips button{padding:8px 11px;border-radius:11px;background:#eef1f7;font-size:13px}
.chips button.on{background:#2f6fe4;color:#fff}
.wk{display:flex;align-items:center;gap:10px;padding:10px;border-radius:14px;background:#fbeaea;margin-top:8px}.wk.ok{background:#e6f6ed}
.wk .wi{font-size:22px}.wk .wt{flex:1;min-width:0}.wk .wt b{display:block;font-size:14.5px}.wk .wt small{font-size:12px;color:#5a6580;line-height:1.35}
.wk button{padding:11px 14px;border-radius:12px;background:#2fb36b;color:#fff;font-weight:800;font-size:14px}.wk button.sec{background:#fff;color:#5a6580;font-weight:600}
.dn{color:#1e8c50}.df{color:#c0392b;font-weight:700}.dw{color:#9a7a2a}
.offplan{margin-top:10px;padding:10px 12px;border-radius:12px;background:#eef1f6;color:#5a6580;font-size:13px}
.acts{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}
.acts button{flex:1;min-width:120px;padding:13px 10px;border-radius:13px;font-weight:800;font-size:14.5px;background:#eef1f7}
.acts .go{background:#2f6fe4;color:#fff}.acts .ok{background:#2fb36b;color:#fff}.acts .warnb{background:#fff1e6;color:#b25a00}
.descr{white-space:pre-wrap;font-size:14.5px;line-height:1.45;margin:10px 0 0}
.photos{display:flex;gap:8px;flex-wrap:wrap;margin-top:6px}
.photos img{width:84px;height:84px;object-fit:cover;border-radius:12px;background:#eef1f7;cursor:pointer}
.photos .add{width:84px;height:84px;border-radius:12px;border:2px dashed #c7cfdc;color:#7a849c;font-size:12px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px}
.photos .add b{font-size:22px}
.feed{margin-top:6px}
.ev{padding:8px 0;border-bottom:1px solid #f0f2f6;font-size:13.5px;line-height:1.4}
.ev .who{font-weight:700}.ev .when{color:#9aa3b5;font-size:11.5px;margin-left:4px}
.ev.sys{color:#7a849c;font-size:12.5px}
.ev .txt{white-space:pre-wrap;margin-top:2px}
.ev.cm .txt{background:#f3f6fb;border-radius:10px;padding:8px 10px;margin-top:4px}
.cbox{display:flex;gap:8px;margin-top:10px;align-items:flex-end}
.cbox textarea{flex:1;min-height:42px;max-height:140px;padding:10px;border:1px solid #d6dbe6;border-radius:12px;font-size:15px;resize:vertical}
.cbox button{padding:11px 14px;border-radius:12px;background:#2f6fe4;color:#fff;font-weight:800}

/* модальные окна */
#modal{position:fixed;inset:0;background:rgba(10,16,30,.55);z-index:60;display:flex;align-items:center;justify-content:center;padding:16px}
#modal .box{background:#fff;border-radius:22px;width:100%;max-width:440px;max-height:90vh;overflow-y:auto;padding:20px;box-shadow:0 20px 60px rgba(0,0,0,.4)}
#modal .box.wideb{max-width:560px}
#modal h3{margin:0 0 8px;font-size:19px}
#modal p{font-size:14px;line-height:1.5;color:#3a4560;margin:6px 0}
.mbtns{display:flex;gap:8px;margin-top:16px}
.mbtns button{flex:1;padding:13px;border-radius:13px;font-weight:800;font-size:15px;background:#2f6fe4;color:#fff}
.mbtns .sec{background:#eef1f7;color:#14203a}.mbtns .danger{background:#c0392b}
#modal textarea.err,#modal input.err{border-color:#e5484d}
.qr{display:flex;justify-content:center;margin:10px 0}.qr img{width:220px;height:220px;image-rendering:pixelated}
.urlbox{font:12px ui-monospace,Menlo,monospace;background:#f3f6fb;border-radius:10px;padding:10px;word-break:break-all}
.lightbox{position:fixed;inset:0;background:rgba(0,0,0,.92);z-index:70;display:flex;align-items:center;justify-content:center}
.lightbox img{max-width:96vw;max-height:92vh;border-radius:8px}

#toast{position:fixed;left:50%;top:40%;transform:translate(-50%,-50%) scale(.95);background:rgba(20,28,48,.92);color:#fff;padding:13px 18px;border-radius:16px;font-size:15px;font-weight:600;z-index:80;opacity:0;pointer-events:none;transition:.22s;text-align:center;max-width:84vw}
#toast.show{opacity:1;transform:translate(-50%,-50%) scale(1)}
#toast small{font-weight:500;opacity:.8}

/* вход */
#login{position:fixed;inset:0;z-index:90;background:linear-gradient(160deg,#16203a,#2a4f86);display:flex;align-items:center;justify-content:center;padding:20px}
#login .box{background:#fff;border-radius:24px;padding:26px 22px;width:100%;max-width:380px;box-shadow:0 30px 80px rgba(0,0,0,.4)}
#login h2{margin:4px 0 4px;font-size:22px}#login p{color:#5a6580;font-size:14px;margin:0 0 14px}
#login input{display:block;width:100%;padding:13px 12px;border:1px solid #d6dbe6;border-radius:12px;font-size:16px;margin:8px 0}
#login button{width:100%;padding:14px;border-radius:13px;background:#2f6fe4;color:#fff;font-weight:800;font-size:16px;margin-top:8px}
#login .err{color:#c0392b;font-size:13.5px;min-height:18px;margin-top:6px}
#loading{position:fixed;inset:0;z-index:95;background:#16203a;color:#fff;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px}
#loading .sp{width:34px;height:34px;border-radius:50%;border:3px solid rgba(255,255,255,.2);border-top-color:#fff;animation:sp 1s linear infinite}
@keyframes sp{to{transform:rotate(360deg)}}

/* ===== компьютер: панель слева, карта справа ===== */
body.wide #side{right:auto;width:430px;box-shadow:4px 0 20px rgba(0,0,0,.08);padding-top:62px;padding-bottom:0}
body.wide #side.mapmode #sideBody{padding-top:6px}
body.wide #c{left:430px;width:calc(100% - 430px)}
body.wide #topbar{right:auto;width:414px}
body.wide #tabs{left:438px;right:auto;top:10px;bottom:auto;margin:0;max-width:none;width:auto;gap:4px;padding:5px}
body.wide #tabs button{flex-direction:row;gap:6px;padding:8px 14px;font-size:17px}
body.wide #tabs small{font-size:13.5px;margin:0}
body.wide .badge{position:static;margin-left:2px}
body.wide #layers{left:438px;top:64px}
body.wide #legend{left:438px;top:110px}
body.wide #tool{left:438px;right:70px;top:110px}
body.wide #sheet{left:0;right:auto;width:430px;top:62px;bottom:0;max-height:none;border-radius:0;box-shadow:4px 0 20px rgba(0,0,0,.12);padding-bottom:0}
body.wide #sheet .grab{display:none}
body.wide #fab{top:64px}

input[type=file][hidden],input[hidden]{display:none!important}
body.wide #topbar{background:rgba(22,30,52,.92);z-index:36}
#layers .filt{opacity:.85;border-left:1px solid rgba(255,255,255,.2);border-radius:0 11px 11px 0}
#layers .filt.on{background:#2f6fe4;opacity:1}
.cdot{display:inline-block;width:10px;height:10px;border-radius:50%;vertical-align:middle;margin-right:3px}
img.emo{width:1.2em;height:1.2em;vertical-align:-.25em;display:inline-block;margin:0 .05em;pointer-events:none}
.li .qk{width:40px;height:40px;border-radius:12px;background:#2fb36b;color:#fff;font-weight:900;font-size:20px;flex:none}
.li .qd{min-width:40px;text-align:center}
.li .qsel{display:flex;align-items:center;padding:6px;flex:none}.li .qsel input{width:24px;height:24px}
.grp .gh{display:flex;justify-content:space-between;align-items:center;cursor:pointer;padding:2px 0 6px}
.selbar{position:sticky;bottom:0;display:flex;gap:6px;align-items:center;flex-wrap:wrap;background:#fff;padding:10px;border-radius:14px;box-shadow:0 -4px 16px rgba(0,0,0,.12);margin-top:8px}
.selbar span{flex:1;min-width:90px}.selbar button{padding:10px 12px;border-radius:11px;background:#eef1f6;font-weight:700}.selbar button.ok{background:#2fb36b;color:#fff}
.pal{display:grid;grid-template-columns:repeat(auto-fill,minmax(92px,1fr));gap:6px}
.pal button{display:flex;flex-direction:column;align-items:center;gap:3px;padding:8px 4px;border-radius:12px;background:#f1f4f9;font-size:12px;font-weight:600;line-height:1.15;text-align:center}
.pal button span{font-size:22px}.pal button span img.emo{width:26px;height:26px}
.pal button.on{background:#2f6fe4;color:#fff}
.row2{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.ck.big{font-size:16px;font-weight:700;padding:10px 12px;background:#eef8f1;border-radius:12px;margin:6px 0}
.ck.big input{width:22px;height:22px}
.li.mnt{padding:6px 8px}
#evChip{max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
body.wide.evmode #sheet{left:auto;right:70px;width:360px;top:110px;bottom:auto;max-height:calc(100vh - 130px);border-radius:18px}
body.wide.evmode #tool{right:440px}
.rc{color:#e5484d;font-weight:900;font-size:1.15em}
.row3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px}
.li.mnt.picked{background:#e8f0ff}
select{width:100%;padding:11px 10px;border-radius:12px;border:1px solid #d9e0ea;background:#fff;font-size:15px}
