:root {
  --bg: #f4f5f7; --card: #fff; --text: #1d2330; --muted: #6b7385; --border: #e1e4ea;
  --accent: #1f6feb; --accent-dark: #1858c4;
  --ok: #1a7f37; --ok-bg: #e6f4ea; --warn: #9a6700; --warn-bg: #fff4d6;
  --bad: #c62828; --bad-bg: #fdecea; --gray-bg: #eef0f3;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

body.with-sidebar { padding-left: 232px; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 232px; background: #1d2330; color: #cdd3df; display: flex; flex-direction: column; padding: 14px 10px; overflow-y: auto; z-index: 30; }
.sidebar a { color: #cdd3df; }
.sidebar .brand { color: #fff; font-weight: 700; font-size: 16px; padding: 4px 8px 12px; }
.sidebar .brand:hover { text-decoration: none; }
.sidebar .search input { width: 100%; margin: 0 0 6px; padding: 7px 10px; border-radius: 6px; border: 0; background: #333c4f; color: #fff; }
.sidebar .search input::placeholder { color: #9aa3b5; }
.sidebar .search label { display: block; font-size: 11px; color: #9aa3b5; padding: 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .search label input { margin-top: 3px; }
.sidebar nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 7px; font-size: 14px; }
.sidebar nav a:hover { background: #2a3243; color: #fff; text-decoration: none; }
.sidebar nav a.active { background: #333c4f; color: #fff; font-weight: 600; }
.sidebar .ico { width: 20px; text-align: center; flex: none; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7c869a; padding: 14px 10px 4px; }
.sidebar .me { border-top: 1px solid #333c4f; margin-top: 10px; padding: 12px 8px 2px; font-size: 14px; color: #9aa3b5; }
.sidebar .me b { color: #fff; }
.mobilebar { display: none; }
.backdrop { display: none; }
@media (max-width: 900px) {
  body.with-sidebar { padding-left: 0; padding-top: 48px; }
  .mobilebar { display: flex; align-items: center; gap: 10px; position: fixed; inset: 0 0 auto 0; height: 48px; padding: 0 12px; background: #1d2330; z-index: 20; }
  .mobilebar .brand { color: #fff; font-weight: 700; }
  .menu-btn { border: 0; background: none; color: #fff; font-size: 22px; cursor: pointer; padding: 4px 8px; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .backdrop.open { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 25; }
}

.container { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-2 { display: grid; gap: 18px; grid-template-columns: 2fr 1fr; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.stat .value { font-size: 26px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 13px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--gray-bg); color: var(--muted); }
.b-working, .b-done { background: var(--ok-bg); color: var(--ok); }
.b-repair, .b-in_progress, .b-high { background: var(--warn-bg); color: var(--warn); }
.b-stopped, .b-critical, .b-breakdown { background: var(--bad-bg); color: var(--bad); }
.b-new { background: #e7efff; color: var(--accent); }
.b-waiting_parts { background: #f3e8ff; color: #7b3fbf; }
.b-overdue { background: var(--bad-bg); color: var(--bad); }
.b-soon { background: var(--warn-bg); color: var(--warn); }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.bad { color: var(--bad); font-weight: 600; }
a.stat:hover { border-color: var(--accent); }

.upload-box { border: 1px dashed #b9c4d8; border-radius: 10px; padding: 14px; margin-bottom: 14px; background: #f8fafd; }

.fault-filter { margin: 0 0 10px; }
.fault-list { max-height: 520px; overflow-y: auto; }
.fault-list .fault { border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.fault-list .fault[hidden] { display: none; }

/* ---------- Фото и видео, голос */
.gallery { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin-bottom: 14px; }
.gitem { margin: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.gitem img, .gitem video { display: block; width: 100%; height: 150px; object-fit: cover; background: #111; }
.gaudio { height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-size: 32px; background: var(--gray-bg); }
.gaudio audio { width: 92%; }
.gitem figcaption { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 5px 8px; }
.uploader { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.uploader label.btn { margin: 0; }
.up-progress { width: 100%; }
.up-progress[hidden] { display: none; }
.up-bar { height: 8px; border-radius: 4px; background: var(--gray-bg); overflow: hidden; margin: 6px 0 4px; }
.up-bar div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
label.btn { display: inline-block; cursor: pointer; color: #fff; font-size: inherit; }
label.btn.secondary { color: var(--accent); }
.voice-wrap { position: relative; display: block; }
.voice-wrap input { padding-right: 42px; }
.voice-wrap textarea { padding-right: 42px; }
.voice-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); margin-top: 2px; width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 50%; background: #fff; cursor: pointer; font-size: 15px; line-height: 1; padding: 0; }
.voice-wrap.area .voice-btn { top: 10px; transform: none; }
.voice-btn:hover { border-color: var(--accent); }
.voice-btn.rec { background: #e5484d; border-color: #e5484d; animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(229, 72, 77, .55); } 70% { box-shadow: 0 0 0 10px rgba(229, 72, 77, 0); } 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0); } }
.involve summary { list-style: none; margin-top: 10px; }
.involve summary::-webkit-details-marker { display: none; }

.notice-warn { background: var(--warn-bg); color: #6b4a00; padding: 10px 12px; border-radius: 7px; margin-bottom: 14px; }
table.life td { vertical-align: top; }
table.life tr.own { background: #f4fbf6; }

/* ---------- Ход работ */
.steps { list-style: none; counter-reset: st; padding: 0; margin: 10px 0; }
.step { counter-increment: st; position: relative; padding: 10px 12px 10px 46px; border: 1px solid var(--border); border-left: 4px solid #c7cdd8; border-radius: 8px; margin-bottom: 8px; background: #fff; }
.step::before { content: counter(st); position: absolute; left: 12px; top: 10px; width: 24px; height: 24px; border-radius: 50%; background: var(--gray-bg); color: var(--muted); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.step.o-ok { border-left-color: var(--ok); } .step.o-fault { border-left-color: var(--bad); } .step.o-fixed { border-left-color: var(--accent); }
.step-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 3px; }
.step-action { font-weight: 600; white-space: pre-line; }
.step-result { white-space: pre-line; color: #3b4456; }
.step-photo { display: block; max-width: 220px; max-height: 160px; border-radius: 6px; margin-top: 6px; }
.step-edit summary { cursor: pointer; color: var(--muted); margin-top: 4px; }
.b-out-ok { background: var(--ok-bg); color: var(--ok); } .b-out-fault { background: var(--bad-bg); color: var(--bad); }
.b-out-fixed { background: #e7efff; color: var(--accent); }
.step-new { border-top: 1px dashed var(--border); padding-top: 10px; }
pre.fresh { white-space: pre-wrap; background: var(--gray-bg); padding: 10px; border-radius: 6px; font: inherit; }

/* ---------- Состав оборудования */
.eq-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.eq-tile { display: block; border: 1px solid var(--border); border-left: 4px solid var(--ok); border-radius: 8px; padding: 10px 12px; color: var(--text); background: #fff; }
.eq-tile:hover { border-color: var(--accent); text-decoration: none; box-shadow: 0 2px 8px rgba(0, 0, 0, .06); }
.eq-tile.s-repair { border-left-color: var(--warn); } .eq-tile.s-stopped { border-left-color: var(--bad); } .eq-tile.s-decommissioned { border-left-color: #b8bfcc; }
.eq-tile-name { font-weight: 600; margin-bottom: 2px; }
.eq-tile-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- Ход работ в виде чата */
.wl { display: flex; flex-direction: column; }
.wl-feed { display: flex; flex-direction: column; gap: 8px; max-height: 460px; min-height: 120px; overflow-y: auto; padding: 8px 2px; }
.chat-main .wl { flex: 1; min-height: 0; padding: 0 14px 10px; }
.chat-main .wl-feed { max-height: none; flex: 1; }
.wl-empty { padding: 10px 2px; }
.wl-msg { max-width: 82%; align-self: flex-start; background: var(--gray-bg); border-radius: 12px; padding: 8px 11px; border-left: 4px solid #c7cdd8; }
.wl-msg.mine { align-self: flex-end; background: #e7efff; }
.wl-msg.k-ok { border-left-color: var(--ok); } .wl-msg.k-fault { border-left-color: var(--bad); } .wl-msg.k-fixed { border-left-color: var(--accent); }
.wl-msg.k-parts { border-left-color: #d97706; } .wl-msg.k-help { border-left-color: #7b3fbf; }
.wl-meta { display: flex; gap: 8px; align-items: center; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.wl-tag { font-weight: 700; color: var(--text); }
.wl-del { border: 0; background: none; color: var(--muted); cursor: pointer; margin-left: auto; padding: 0 2px; }
.wl-del:hover { color: var(--bad); }
.wl-body { white-space: pre-wrap; word-wrap: break-word; }
.wl-result { white-space: pre-wrap; color: #3b4456; }
.wl-msg img, .wl-msg video { display: block; max-width: 260px; max-height: 220px; border-radius: 8px; margin-top: 6px; }
.wl-msg audio { display: block; margin-top: 6px; max-width: 280px; }
.wl-compose { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 6px; }
.wl-kinds { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 6px; }
.wl-kind { flex: none; border: 1px solid var(--border); background: #fff; border-radius: 20px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.wl-kind:hover { border-color: var(--accent); }
.wl-kind.active { background: #1d2330; border-color: #1d2330; color: #fff; }
.wl-kind.k-fault.active { background: var(--bad); border-color: var(--bad); }
.wl-kind.k-ok.active { background: var(--ok); border-color: var(--ok); }
.wl-kind.k-fixed.active { background: var(--accent); border-color: var(--accent); }
.wl-attach { font-size: 13px; padding: 4px 2px; }
.wl-attach[hidden] { display: none; }
.wl-row { display: flex; gap: 6px; align-items: flex-end; }
.wl-text { flex: 1; }
.wl-text textarea { margin: 0; min-height: 42px; resize: none; }
.wl-icon { flex: none; width: 42px; height: 42px; border: 1px solid var(--border); border-radius: 50%; background: #fff; font-size: 19px; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; position: relative; }
.wl-icon:hover { border-color: var(--accent); }
.wl-rec.rec { background: #e5484d; border-color: #e5484d; animation: pulse 1.2s infinite; }
.wl-rec[data-time]::after { content: attr(data-time); position: absolute; top: -18px; font-size: 11px; color: #e5484d; font-weight: 700; }
.wl-hint { margin-top: 4px; }
.topic-filter { margin: 2px 0 4px; padding: 6px 9px; font-size: 13px; }
.topics { max-height: 260px; overflow-y: auto; }
.chat-item.topic { align-items: flex-start; }
.topic-eq { display: block; }
.chat-item[hidden] { display: none; }

/* ---------- Службы */
.sp-badge { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, #fff); border: 1px solid color-mix(in srgb, var(--c) 35%, #fff); }
.sp-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.sp-tabs a { padding: 7px 14px; border-radius: 20px; border: 1px solid var(--border); background: #fff; color: var(--text); font-weight: 600; font-size: 14px; }
.sp-tabs a:hover { text-decoration: none; border-color: var(--c, var(--accent)); }
.sp-tabs a.active { background: var(--c, var(--text)); border-color: var(--c, var(--text)); color: #fff; }
.aspect { border-left: 4px solid var(--c); }
.sp-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.sp-row input { margin: 0; padding: 5px 8px; }
.sp-row input[type=color] { width: 38px; height: 32px; padding: 2px; flex: none; }
.sp-row input[name=name] { width: 190px; flex: none; }

/* ---------- Коды ошибок */
.fault { padding: 0; margin-bottom: 8px; }
.fault summary { display: flex; align-items: baseline; gap: 10px; padding: 12px 16px; cursor: pointer; list-style: none; }
.fault summary::-webkit-details-marker { display: none; }
.fault[open] summary { border-bottom: 1px solid var(--border); }
.fcode { flex: none; font: 700 14px ui-monospace, Consolas, monospace; background: #1d2330; color: #fff; padding: 2px 9px; border-radius: 6px; }
.fcode.nocode { background: var(--gray-bg); color: var(--muted); font-weight: 600; }
.ftitle { flex: 1; font-weight: 600; }
.fwhere { flex: none; }
.fbody { padding: 4px 16px 14px; }
.fbody h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: 12px 0 4px; }
.fbody p { margin: 0; white-space: pre-line; }
.fsrc { margin-top: 12px; }
.linkbtn { border: 0; background: none; padding: 0; font: inherit; color: var(--bad); cursor: pointer; }
.hint-card { border-color: #f0d98a; background: #fffbea; }
.hint-card .fault { background: #fff; border: 1px solid var(--border); border-radius: 8px; }

/* ---------- Предложения и обучение */
.sug { display: flex; gap: 14px; padding: 14px; margin-bottom: 12px; }
.vote button { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 52px; padding: 8px 0; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--muted); font: inherit; cursor: pointer; }
.vote button b { font-size: 18px; color: var(--text); }
.vote button.voted { border-color: var(--accent); background: #e7efff; color: var(--accent); }
.vote button:hover { border-color: var(--accent); }
.sug-body { flex: 1; min-width: 0; }
.sug-title { font-weight: 600; font-size: 16px; color: var(--text); }
.b-sg-new { background: #e7efff; color: var(--accent); }
.b-sg-review { background: var(--warn-bg); color: var(--warn); }
.b-sg-accepted { background: #f3e8ff; color: #7b3fbf; }
.b-sg-implemented { background: var(--ok-bg); color: var(--ok); }
.b-sg-rejected { background: var(--bad-bg); color: var(--bad); }
.progress { height: 8px; border-radius: 4px; background: var(--gray-bg); overflow: hidden; margin-bottom: 8px; }
.progress div { height: 100%; background: var(--ok); }
.qs { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 7px; color: var(--text); }
.qs:hover { background: var(--gray-bg); text-decoration: none; }
.qs-mark { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; background: var(--gray-bg); align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--muted); flex: none; }
.qs.done { color: var(--muted); text-decoration: line-through; }
.qs.done .qs-mark { background: var(--ok-bg); color: var(--ok); }
.guide { padding: 0; margin-bottom: 10px; }
.guide summary { padding: 14px 18px; cursor: pointer; list-style: none; }
.guide summary::-webkit-details-marker { display: none; }
.guide summary::after { content: '▾'; float: right; color: var(--muted); }
.guide[open] summary { border-bottom: 1px solid var(--border); }
.guide-icon { display: inline-block; width: 28px; }
.guide h3 { font-size: 15px; margin: 14px 18px 4px; }
.guide ol { margin: 0 18px 6px; padding-left: 20px; }
.guide li { margin: 4px 0; }
.guide .btn { margin: 8px 18px 16px; }

.sug-form .card { margin-bottom: 14px; }
.stack-label { display: block; font-size: 13px; color: var(--muted); }
.sug-step { display: flex; gap: 16px; }
.sug-num { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 17px; display: flex; align-items: center; justify-content: center; }
.sug-num.small-num { width: 26px; height: 26px; font-size: 14px; }
.sug-body { flex: 1; min-width: 0; }
.sug-body h2 { margin: 4px 0 2px; }
.sug-body p { margin: 0 0 8px; }
.sug-body textarea { min-height: 100px; }
.sug-numbers { margin-top: 10px; }
.sug-sec { display: flex; gap: 12px; margin-bottom: 14px; }
.sug-sec h3 { margin: 2px 0 4px; font-size: 15px; }
.sug-sec p { margin: 0; white-space: pre-line; }
.sug-stats { margin: 12px 0 0; }
.sug-money { color: var(--ok); margin-top: 3px; }

/* ---------- Склад */
.cell-tag { display: inline-block; padding: 1px 7px; margin: 1px 3px 1px 0; border-radius: 5px; background: #eef3ff; border: 1px solid #cfdcf7; color: var(--text); font-size: 12px; font-weight: 600; white-space: nowrap; }
a.cell-tag:hover { border-color: var(--accent); text-decoration: none; }
.rack-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); align-items: start; }
.rack { margin: 0; }
.rack-cell { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid var(--border); }
.rack-name { flex: 1; min-width: 0; }
.rack-name input { margin: 0; padding: 3px 7px; font-size: 13px; border-color: transparent; background: transparent; }
.rack-name input:hover, .rack-name input:focus { border-color: var(--border); background: #fff; }
.b-mv-receipt { background: var(--ok-bg); color: var(--ok); }
.b-mv-issue { background: var(--warn-bg); color: var(--warn); }
.b-mv-writeoff { background: var(--bad-bg); color: var(--bad); }
.b-mv-transfer { background: #e7efff; color: var(--accent); }
.b-pr-new { background: #e7efff; color: var(--accent); }
.b-pr-received { background: var(--ok-bg); color: var(--ok); }
.b-pr-ordered, .b-pr-requested, .b-pr-approved { background: var(--warn-bg); color: var(--warn); }
.b-pr-rejected, .b-pr-not_found { background: var(--bad-bg); color: var(--bad); }

/* ---------- Задачи */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg a { padding: 7px 14px; color: var(--text); border-right: 1px solid var(--border); }
.seg a:last-child { border-right: 0; }
.seg a.active { background: var(--accent); color: #fff; }
.seg a:hover { text-decoration: none; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.bcol { background: #e9ecf1; border-radius: 10px; padding: 10px; min-height: 200px; transition: background .15s; }
.bcol.over { background: #dbe6fb; }
.bcol-head { margin: 2px 2px 10px; }
.bcol-body { display: flex; flex-direction: column; gap: 8px; }
.bempty { padding: 8px 4px; }
.tcard { display: block; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px; color: var(--text); cursor: grab; }
.tcard:hover { border-color: var(--accent); text-decoration: none; }
.tcard.overdue { border-left: 3px solid var(--bad); }
.tcard.dragging { opacity: .4; }
.ttitle { font-weight: 600; margin-bottom: 6px; }
.tmeta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); align-items: center; margin-top: 3px; }
.b-t-new { background: #e7efff; color: var(--accent); }
.b-t-in_progress { background: var(--warn-bg); color: var(--warn); }
.b-t-review { background: #f3e8ff; color: #7b3fbf; }
.b-t-done { background: var(--ok-bg); color: var(--ok); }
.checkitem { padding: 6px 0; border-bottom: 1px solid var(--border); }
.checkitem input:checked + span { text-decoration: line-through; color: var(--muted); }
.inline-add input { margin-top: 10px; }

/* ---------- Чат */
.nav-badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: #e5484d; color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }
.chat-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; }
@media (max-width: 760px) { .chat-layout { grid-template-columns: 1fr; } .chat-list { max-height: 220px; overflow-y: auto; } }
.chat-list { margin: 0; padding: 8px; }
.chat-list-head { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 10px 10px 4px; }
.chat-item { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 7px; color: var(--text); }
.chat-item:hover { background: var(--gray-bg); text-decoration: none; }
.chat-item.active { background: #e7efff; font-weight: 600; }
.unread { background: var(--accent); color: #fff; border-radius: 9px; font-size: 11px; font-weight: 700; padding: 0 6px; line-height: 18px; }
.unread[hidden] { display: none; }
.avatar { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: #dfe6f3; color: var(--accent); font-size: 12px; font-weight: 700; align-items: center; justify-content: center; margin-right: 6px; }
.new-channel input { margin: 4px 0 0; padding: 6px 9px; font-size: 13px; }
.chat-main { margin: 0; padding: 0; display: flex; flex-direction: column; height: calc(100vh - 120px); min-height: 460px; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.chat-feed { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.load-more { align-self: center; }
.cmsg { max-width: 75%; padding: 8px 11px; border-radius: 12px; background: var(--gray-bg); align-self: flex-start; }
.cmsg.mine { background: #e7efff; align-self: flex-end; }
.cmsg .meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.ctext { white-space: pre-wrap; word-wrap: break-word; }
.cmsg img { display: block; max-width: 280px; max-height: 240px; border-radius: 8px; margin-top: 6px; }
.cfile { display: inline-block; margin-top: 6px; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--border); }
.chat-text { flex: 1; }
.chat-text textarea { margin: 0; min-height: 40px; resize: none; }
.attach { cursor: pointer; font-size: 22px; padding: 6px 4px; line-height: 1; }
.attach input, [hidden] { display: none !important; }

/* ---------- Настройки */
.settings-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 760px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-nav { position: sticky; top: 12px; padding: 8px; display: flex; flex-direction: column; }
@media (max-width: 760px) { .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; } }
.settings-nav a { padding: 8px 10px; border-radius: 6px; color: var(--text); }
.settings-nav a:hover { background: var(--gray-bg); text-decoration: none; }
section[id] { scroll-margin-top: 12px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; }
label.check input { width: auto; margin: 0; }
.notice { background: var(--ok-bg); color: var(--ok); padding: 10px 12px; border-radius: 7px; margin-bottom: 14px; }
.ok { color: var(--ok); font-weight: 600; }

/* ---------- Просмотр схем */
.schema-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .schema-layout { grid-template-columns: 1fr; } }
.schema-viewer { padding: 10px; margin: 0; }
.viewer-toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.viewer-toolbar select { width: auto; margin: 0; padding: 4px 8px; }
.viewer-toolbar .sep { width: 8px; }
.viewer-search { flex: 1; min-width: 160px; }
.viewer-search input { margin: 0; padding: 5px 9px; }
.hl-info { min-height: 20px; margin: 2px 2px 6px; color: var(--muted); }
.hl-info a { margin: 0 2px; padding: 0 5px; border-radius: 4px; }
.hl-info a.cur { background: #fff1a8; color: var(--text); font-weight: 700; }
.viewer-scroll { cursor: grab; overflow-anchor: none; }
.viewer-scroll.loading { cursor: progress; }
.viewer-scroll { position: relative; }
.viewer-scroll.loading::before { content: 'Загружаю лист…'; position: sticky; top: 10px; left: 10px; z-index: 5; display: inline-block; margin: 10px 0 -40px 10px; padding: 4px 10px; border-radius: 6px; background: rgba(33, 37, 41, .82); color: #fff; font-size: 13px; }
.viewer-scroll.loading .viewer-page { opacity: .6; transition: opacity .15s; }
.viewer-scroll.panning, .viewer-scroll.panning .hot { cursor: grabbing; user-select: none; }
.viewer-scroll { overflow: auto; height: calc(100vh - 230px); min-height: 420px; border: 1px solid var(--border); border-radius: 8px; background: #e9ebef; }
.viewer-page { position: relative; margin: 0 auto; }
.viewer-page img { display: block; width: 100%; height: auto; background: #fff; user-select: none; }
#overlay { position: absolute; inset: 0; pointer-events: none; }
.hl { position: absolute; background: rgba(255, 213, 0, .45); outline: 2px solid #f0a400; border-radius: 2px; margin: -2px; padding: 2px; box-sizing: content-box; }

#traceSvg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tr-net line { stroke-width: 3; stroke-opacity: .6; stroke-linecap: round; }
.tr-net.faint line { stroke-opacity: .16; }
.faint-box rect { opacity: .35; }
.viewer-page { background: #fff; }
.viewer-page.dimmed img { opacity: .55; }
.tr-pulse { animation: trPulse 1.1s ease-in-out infinite; fill-opacity: .3; }
@keyframes trPulse { 50% { stroke-opacity: .25; fill-opacity: .08; } }
@media (prefers-reduced-motion: reduce) { .tr-pulse { animation: none; } }
.tr-badge { pointer-events: auto; cursor: pointer; }
.tr-badge circle { stroke: #fff; stroke-width: 1.2; }
.tr-badge text { fill: #fff; font: 700 7.4px system-ui, sans-serif; pointer-events: none; }
.tr-badge.done circle { fill: #868e96; }
.step-bar { border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 8px 10px; margin-bottom: 6px; }
.step-nav { display: flex; gap: 8px; align-items: flex-start; }
.step-nav .btn { flex: none; white-space: nowrap; }
.step-text { flex: 1; min-width: 0; border-left: 4px solid; padding-left: 10px; font-size: 14px; }
.step-foot { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; margin-top: 6px; font-size: 12px; }
.step-foot .tr-legend { margin: 0; }
@media (max-width: 700px) { .step-nav { flex-wrap: wrap; } .step-text { flex-basis: 100%; order: -1; } }
.tr-steps li { cursor: pointer; }
.tr-steps li:hover { background: #eef3fb; }
.tr-steps li.active { background: #e7efff; box-shadow: inset 0 0 0 1px #9db8ee; }
.tr-steps li.done > b::after { content: " ✓"; color: #2f9e44; }
.tr-steps li.done { opacity: .7; }
.hot { position: absolute; pointer-events: auto; cursor: pointer; border-radius: 3px; margin: -2px; padding: 2px; box-sizing: content-box; }
.hot { border-bottom: 2px dotted rgba(28, 126, 214, .75); }
.hot:hover { background: rgba(28, 126, 214, .22); outline: 2px solid #1c7ed6; }
.hot-sample { border-bottom: 2px dotted rgba(28, 126, 214, .75); }
.hot.dev { border-bottom: 2px solid #2f9e44; background: rgba(47, 158, 68, .10); }
.hot.ref, .hot-sample.ref { border-bottom: 2px solid #9c36b5; background: rgba(156, 54, 181, .12); }
.hot.ref:hover { background: rgba(156, 54, 181, .28); outline: 2px solid #9c36b5; }
.hot.ref.dead { border-bottom-style: dashed; background: none; }
.hot.wire, .hot-sample.wire { border-bottom: 2px dotted #e8590c; }
.hot.wire:hover, .hot.wire.on { background: rgba(232, 89, 12, .22); outline: 2px solid #e8590c; }
.hot.pins { border: 1px dashed #7048e8; border-radius: 4px; background: rgba(112, 72, 232, .05); margin: 0; padding: 0; }
.hot.pins:hover { background: rgba(112, 72, 232, .14); outline: none; }
.nav-chain { margin-top: 8px; padding-top: 6px; border-top: 1px dashed #d0bfff; }
.pin-table { margin-bottom: 6px; }
.pin-table summary { cursor: pointer; padding: 3px 0; }
.chain-t { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 4px 0 6px; background: #fff; }
.chain-t th, .chain-t td { border: 1px solid #e5dbff; padding: 3px 6px; text-align: left; vertical-align: top; }
.chain-t th { background: #f3f0ff; font-weight: 600; }
.chain-t tr.cur td { background: #fff4e6; }
.ref-chip { padding: 0 5px; border: 1px solid #9c36b5; border-radius: 5px; text-decoration: none; white-space: nowrap; }
.ref-chip.dead { border-style: dashed; color: #868e96; border-color: #adb5bd; }
.warn-t { color: #b35c00; }
.norms { margin: 8px 0; padding: 6px 10px; border: 1px solid #a5d8ff; background: #f1f8ff; border-radius: 8px; font-size: 13px; }
.norms summary { cursor: pointer; }
.norms ul { margin: 6px 0 2px; padding-left: 18px; }
.norms li { margin-bottom: 4px; }
.nav-box { border: 1px solid #d0bfff; background: #f8f5ff; border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.nav-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.nav-head a { margin-left: auto; }
.nav-trail { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.nav-trail i { color: #868e96; font-style: normal; }
.nav-trail a { display: inline-flex; flex-direction: column; padding: 2px 8px; border: 1px solid #d0bfff; border-radius: 6px; background: #fff; text-decoration: none; font-size: 13px; font-weight: 600; line-height: 1.2; }
.nav-trail a span { font-size: 10px; font-weight: 400; color: #868e96; }
.nav-trail a.cur { background: #7048e8; border-color: #7048e8; color: #fff; }
.nav-trail a.cur span { color: #e5dbff; }
.nav-note { margin-top: 6px; }
.nav-wire { margin-top: 8px; padding-top: 6px; border-top: 1px dashed #d0bfff; }
.nav-refs { margin-top: 8px; padding-top: 6px; border-top: 1px dashed #d0bfff; line-height: 1.9; }
.nav-refs a { padding: 1px 6px; border: 1px solid #9c36b5; border-radius: 5px; text-decoration: none; font-size: 12px; white-space: nowrap; }
.nav-refs a.dead { border-style: dashed; color: #868e96; border-color: #adb5bd; }
.hot-sample.dev { border-bottom: 2px solid #2f9e44; background: rgba(47, 158, 68, .10); }
.dev-tip { position: fixed; z-index: 50; max-width: 340px; padding: 6px 10px; border-radius: 7px; background: #212529; color: #fff; font-size: 13px; line-height: 1.35; pointer-events: none; box-shadow: 0 4px 16px rgba(0, 0, 0, .3); }
.dev-tip-hint { color: #adb5bd; font-size: 11px; margin-top: 2px; }
.dev-card { margin: 8px 0; padding: 8px 10px; border-radius: 8px; border: 1px solid #b2dfbc; background: #f1faf3; }
.dev-line { color: #2b8a3e; font-weight: 600; }
.devdocs { border-left: 4px solid #1c7ed6; }
.devdocs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.devdocs-doc { padding: 6px 0; border-bottom: 1px solid var(--border); }
@media (max-width: 800px) { .devdocs-grid { grid-template-columns: 1fr; } }
.msg.queued { background: #fff9db; border: 1px dashed #f0c36d; color: #6b5200; }
.msg.fresh { box-shadow: 0 0 0 2px #2f9e44; }
.trace-box { overflow-y: auto; flex: 1; font-size: 14px; }
.tr-head { font-size: 16px; margin-bottom: 8px; }
.tr-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; margin-bottom: 8px; }
.tr-legend i { display: inline-block; width: 14px; height: 5px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.tr-title { font-weight: 700; margin: 12px 0 6px; }
.tr-steps { margin: 0; padding-left: 0; list-style: none; counter-reset: step; }
.tr-steps li { counter-increment: step; border-left: 4px solid; background: var(--gray-bg); border-radius: 0 8px 8px 0; padding: 7px 10px; margin-bottom: 6px; }
.tr-steps li > b::before { content: counter(step) ". "; }
.tr-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.tr-chips a { border: 1px solid; border-radius: 10px; padding: 0 8px; font-size: 12px; font-weight: 600; background: #fff; color: var(--text); text-decoration: none; }
.tr-ai { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.tr-ai select { flex: 1; min-width: 150px; margin: 0; padding: 5px 8px; }
.tr-ai .small { flex-basis: 100%; }
.tr-list { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.tr-list a[data-wpage] { padding: 0 4px; }

.schema-side { margin: 0; padding: 0; display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 520px; }
@media (max-width: 1000px) { .schema-side { height: auto; } .viewer-scroll { height: 70vh; } }
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab { flex: 1; padding: 11px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-body { padding: 12px; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.tab-body[hidden] { display: none; }
.chat { flex: 1; overflow-y: auto; min-height: 200px; display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.chat-hint { line-height: 1.6; }
.msg { padding: 9px 11px; border-radius: 10px; white-space: pre-wrap; word-wrap: break-word; font-size: 14px; }
.msg .meta { font-size: 11px; color: var(--muted); margin-bottom: 3px; white-space: normal; }
.msg.q { background: #e7efff; align-self: flex-end; max-width: 90%; }
.msg.a { background: var(--gray-bg); }
.msg.pending { color: var(--muted); font-style: italic; }
.msg.err { background: var(--bad-bg); color: var(--bad); }
.msg a.des { background: #fff1a8; color: var(--text); padding: 0 3px; border-radius: 3px; font-weight: 600; }
.ask { border-top: 1px solid var(--border); padding-top: 10px; }
.ask textarea { min-height: 70px; margin: 0 0 8px; }
.comp-list { overflow-y: auto; flex: 1; }
.comp { display: flex; justify-content: space-between; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 6px; }
.comp:hover { background: #f3f6fb; }
.recognize { margin-bottom: 10px; }
.recognize .small { margin-top: 4px; }

.year-grid th.mcol, .year-grid td.mcol { text-align: center; min-width: 46px; padding: 6px 2px; border-left: 1px solid var(--border); }
.cell-mark { display: inline-block; margin: 1px; padding: 1px 6px; border-radius: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.cell-mark.done { background: var(--ok-bg); color: var(--ok); }
.cell-mark.planned { background: #e7efff; color: var(--accent); }
.cell-mark.overdue { background: var(--bad-bg); color: var(--bad); }

.btn { display: inline-block; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font: inherit; cursor: pointer; }
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--accent); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { background: #fff; color: var(--bad); border-color: var(--bad); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

form.stack label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
form.stack .row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; color: var(--text); border: 1px solid var(--border); border-radius: 7px; background: #fff; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b9d0fb; border-color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters label { font-size: 13px; color: var(--muted); }
.filters select { min-width: 160px; }

dl.props { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--border); white-space: pre-line; }
.timeline li:last-child { border-bottom: 0; }
.timeline .meta { font-size: 12px; color: var(--muted); }

.error { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: 7px; margin-bottom: 12px; }
.empty { color: var(--muted); padding: 10px 0; }

.auth { max-width: 400px; margin: 60px auto; }
.auth h1 { text-align: center; margin-bottom: 18px; }

/* Поиск по линии */
mark { background: #fff1a8; color: inherit; padding: 0 1px; border-radius: 2px; }
.ls-nav { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.ls-pages { display: grid; gap: 4px; margin-bottom: 10px; }
.ls-page { display: grid; grid-template-columns: 70px 1fr; gap: 2px 10px; padding: 6px 8px; border-radius: 6px; color: inherit; text-decoration: none; }
.ls-page:hover { background: var(--gray-bg); }
.ls-page .ls-pn { grid-row: span 2; font-weight: 600; color: var(--accent); white-space: nowrap; }

/* Схемы узла */
.scheme-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.scheme-tab { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 14px; cursor: pointer; }
.scheme-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.scheme-tab.active .muted { color: #dbe6ff; }
.scheme-tab.none { opacity: .55; }
.scheme-pane { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.scheme-link { display: inline-block; padding: 5px 11px; border-radius: 6px; background: var(--gray-bg); color: inherit; font-size: 14px; text-decoration: none; }
.scheme-link:hover { text-decoration: none; filter: brightness(.96); }
.scheme-link.own { background: #e7efff; color: var(--accent); font-weight: 600; }
#kindSelect { max-width: 190px; }

/* Дерево состава */
.ctree { list-style: none; margin: 0; padding: 0 0 0 22px; border-left: 1px dashed var(--border); }
.ctree.ctree-root { padding-left: 0; border-left: 0; }
.ctree li { margin: 2px 0; }
.ctree summary, .ctree .ctree-leaf { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 6px 8px; border-radius: 6px; border-left: 3px solid var(--ok); }
.ctree .ctree-leaf { margin-left: 18px; }
.ctree summary { cursor: pointer; list-style: none; }
.ctree summary::-webkit-details-marker { display: none; }
.ctree summary::before { content: "▸"; width: 12px; color: var(--muted); flex: none; }
.ctree details[open] > summary::before { content: "▾"; }
.ctree summary:hover, .ctree .ctree-leaf:hover { background: var(--gray-bg); }
.ctree li.s-repair > details > summary, .ctree li.s-repair > .ctree-leaf { border-left-color: var(--warn); }
.ctree li.s-stopped > details > summary, .ctree li.s-stopped > .ctree-leaf { border-left-color: var(--bad); }
.ctree li.s-decommissioned > details > summary, .ctree li.s-decommissioned > .ctree-leaf { border-left-color: #b8bfcc; }
.ctree-name { font-weight: 600; }
.ctree-meta { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.ctree-buttons { display: inline-flex; gap: 6px; }
.comp-h { margin: 14px 0 8px; font-size: 15px; }
.spec-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 44%); gap: 14px; align-items: start; }
.spec-draw { position: sticky; top: 10px; }
.spec-draw-box { position: relative; border: 1px solid var(--border); border-radius: 6px; background: #fff; overflow: hidden; }
.spec-draw-box img { display: block; width: 100%; height: auto; user-select: none; }
.pos-mark { position: absolute; aspect-ratio: 1; border-radius: 50%; transform: translate(-50%, -50%); cursor: pointer; transition: box-shadow .12s, background .12s; }
.pos-mark:hover { background: rgba(28, 126, 214, .18); }
.pos-mark.on { background: rgba(255, 213, 0, .45); box-shadow: 0 0 0 3px #f08c00, 0 0 0 9px rgba(240, 140, 0, .28); }
.spec-draw-box.picking img { opacity: .75; }
.pos-mark.sheet { pointer-events: auto; box-shadow: 0 0 0 2px rgba(28, 126, 214, .35); }
.pos-mark.sheet:hover { background: rgba(28, 126, 214, .22); box-shadow: 0 0 0 2px #1c7ed6; }
.pos-mark.sheet.on { background: rgba(255, 213, 0, .45); box-shadow: 0 0 0 3px #f08c00, 0 0 0 9px rgba(240, 140, 0, .28); }
.pos-pop { position: absolute; z-index: 6; pointer-events: auto; cursor: default; width: 260px; max-width: 80vw; margin: 18px 0; padding: 8px 10px; border-radius: 8px;
  background: #fff; border: 1px solid #f08c00; box-shadow: 0 6px 22px rgba(0, 0, 0, .22); font-size: 13px; color: var(--text); }
.pos-pop-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.pos-pop-x { border: 0; background: none; cursor: pointer; font-size: 14px; color: var(--muted); padding: 0 2px; }
.pos-pop-row { padding: 5px 0; border-top: 1px solid var(--border); }
.pos-pop-node { padding-top: 5px; border-top: 1px solid var(--border); color: var(--muted); }
#specTable tr[data-pos] { cursor: pointer; }
#specTable tr.pos-on td { background: #fff3c4; }
.pos-num { display: inline-block; min-width: 18px; padding: 0 4px; margin-left: 4px; border: 1px solid #4263eb; border-radius: 9px; color: #4263eb; font-size: 11px; text-align: center; }
@media (max-width: 900px) { .spec-wrap { grid-template-columns: 1fr; } .spec-draw { position: static; order: -1; } }

.scheme-link.sheet { display: block; flex: 1 1 100%; }
#kindSelect { max-width: 230px; }

.scheme-docs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ctree-scheme { color: var(--accent); }

/* Визуальный выбор оборудования */
.vmap-block { margin-bottom: 14px; }
.vmap { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; user-select: none; }
.vmap img { display: block; width: 100%; height: auto; }
.vmap-spot { position: absolute; border: 2px solid rgba(37, 99, 235, .55); background: rgba(37, 99, 235, .06); border-radius: 4px; }
.vmap-spot:hover { background: rgba(37, 99, 235, .22); border-color: var(--accent); z-index: 3; }
.vmap-spot.s-repair { border-color: var(--warn); background: rgba(245, 158, 11, .14); }
.vmap-spot.s-stopped { border-color: var(--bad); background: rgba(220, 38, 38, .14); }
.vmap-label { position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%); margin-bottom: 4px; background: #1d2330; color: #fff; font-size: 12px;
  padding: 3px 8px; border-radius: 4px; white-space: nowrap; display: none; pointer-events: none; }
.vmap-spot:hover .vmap-label { display: block; }
.vmap-del { display: none; position: absolute; right: -2px; top: -2px; width: 20px; height: 20px; border: 0; border-radius: 50%; background: var(--bad); color: #fff; cursor: pointer; line-height: 1; }
.vmap.editing { cursor: crosshair; }
.vmap.editing .vmap-del { display: block; }
.vmap-draft { position: absolute; border: 2px dashed var(--bad); background: rgba(220, 38, 38, .12); pointer-events: none; z-index: 4; }
.vmap-tools { margin-top: 8px; }
.vmap-new summary { cursor: pointer; color: var(--accent); }
.scheme-preview { display: flex; align-items: flex-end; gap: 10px; margin-top: 10px; color: inherit; }
.scheme-preview img { width: 260px; max-width: 60%; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.pic-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.pic-tile { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--border); border-top: 3px solid var(--ok); border-radius: 8px; padding: 8px; color: var(--text); background: #fff; }
.pic-tile:hover { border-color: var(--accent); text-decoration: none; box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }
.pic-tile.s-repair { border-top-color: var(--warn); } .pic-tile.s-stopped { border-top-color: var(--bad); }
.pic-tile img, .pic-none { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #fafbfc; border-radius: 4px; }
.pic-none { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.pic-name { font-weight: 600; font-size: 13px; line-height: 1.25; }
.ctree-buttons .btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Откуда задача */
.origin a { color: inherit; text-decoration: underline; text-decoration-color: var(--border); }
.origin-line { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 14px; }
.origin-box { margin-bottom: 14px; }
.tcard .torigin { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* Сворачиваемая карточка */
details.fold > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; cursor: pointer; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸"; color: var(--muted); }
details.fold[open] > summary::before { content: "▾"; }
details.fold > summary h2 { margin: 0; }
details.fold[open] > summary { margin-bottom: 10px; }

.sim-h { margin: 22px 0 10px; font-size: 17px; }

/* Телефон и установленное приложение (PWA) */
.bottombar { display: none; }
.install-btn { position: fixed; right: 14px; bottom: 14px; z-index: 40; border: 0; border-radius: 999px; padding: 11px 18px; background: var(--accent); color: #fff;
  font: inherit; font-weight: 600; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); cursor: pointer; }
@media (max-width: 900px) {
  body.with-sidebar { padding-top: calc(48px + env(safe-area-inset-top)); padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .mobilebar { height: calc(48px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
  .sidebar { padding-top: calc(14px + env(safe-area-inset-top)); width: min(280px, 86vw); }
  .bottombar { display: flex; position: fixed; inset: auto 0 0 0; height: calc(56px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: #fff; border-top: 1px solid var(--border); z-index: 20; }
  .bottombar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 11px; color: var(--muted); text-decoration: none; }
  .bottombar a span { font-size: 19px; line-height: 1.1; }
  .bottombar a.active { color: var(--accent); font-weight: 600; }
  .install-btn { bottom: calc(68px + env(safe-area-inset-bottom)); }
  .container { padding: 14px 10px 30px; }
  .card { padding: 13px; margin-bottom: 12px; border-radius: 9px; }
  h1 { font-size: 21px; }
  .page-head { gap: 8px; margin-bottom: 12px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; text-align: center; }
  input, select, textarea { font-size: 16px; }             /* иначе iPhone приближает страницу при вводе */
  .btn { min-height: 40px; }
  .btn.small { min-height: 34px; }
  .filters label { flex: 1 1 100%; min-width: 0; }
  .row { flex-direction: column; }
  .ctree { padding-left: 12px; }
  .ctree-meta { margin-left: 0; flex-wrap: wrap; white-space: normal; }
  .scheme-preview { flex-direction: column; align-items: flex-start; }
  .scheme-preview img { max-width: 100%; width: 100%; }
  .pic-grid { grid-template-columns: repeat(2, 1fr); }
  .viewer-scroll { height: 62vh; min-height: 300px; }
  .vmap-label { font-size: 11px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
@media (display-mode: standalone) { .install-btn { display: none; } }

/* Отчёты: столбики без сторонних библиотек */
.bars { display: grid; gap: 7px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; background: var(--gray-bg); border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; min-width: 2px; background: var(--accent); border-radius: 4px; }
.bar-value { font-weight: 600; white-space: nowrap; min-width: 34px; text-align: right; }

/* Обучение */
.news-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.news { display: flex; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; color: inherit; text-decoration: none; }
.news:hover { border-color: var(--accent); text-decoration: none; }
.news-ico { font-size: 22px; }
.news b { display: block; }
.news .small { display: block; }
li.help-hit { background: #fff7c2; border-radius: 4px; }

/* Уведомления */
.notify-ways { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.notify-list { display: grid; gap: 2px; }
.notify { display: flex; gap: 10px; padding: 10px 8px; border-radius: 8px; color: inherit; text-decoration: none; border-left: 3px solid transparent; }
.notify:hover { background: var(--gray-bg); text-decoration: none; }
.notify.unread { background: #eef4ff; border-left-color: var(--accent); }
.notify.unread .notify-text { font-weight: 600; }
.notify-ico { font-size: 20px; }
.notify-text { display: block; }
.mobilebar .bell { margin-left: auto; position: relative; font-size: 20px; text-decoration: none; padding: 4px 6px; }
.mobilebar .bell .nav-badge { position: absolute; top: -2px; right: -4px; }
/* Страница по QR-коду */
.quick { max-width: 640px; margin: 0 auto; }
.quick h1 { margin: 4px 0; }
.quick-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.quick-btn { min-height: 52px; display: flex; align-items: center; justify-content: center; font-size: 16px; text-align: center; }
.quick-buttons .quick-btn:first-child { grid-column: 1 / -1; min-height: 60px; font-size: 18px; }
.quick-row { display: block; padding: 9px 4px; border-top: 1px solid var(--border); color: inherit; text-decoration: none; }
.quick-row:first-of-type { border-top: 0; }
.quick-row b, .quick-row span { display: block; }
.quick-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick-choice label { margin: 0; }
.quick-choice input { position: absolute; opacity: 0; pointer-events: none; }
.quick-choice span { display: block; text-align: center; padding: 12px 8px; border: 2px solid var(--border); border-radius: 8px; font-weight: 600; cursor: pointer; }
.quick-choice input:checked + span { border-color: var(--accent); background: #eef4ff; }

/* Проверка схемы: список мест для ручного разбора */
.audit-kinds { display: flex; flex-wrap: wrap; gap: 8px; }
.audit-kind { padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-weight: 600; font-size: 14px; }
.audit-kind.active { border-color: var(--accent); background: #eef4ff; color: var(--accent); }
.audit-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.audit-item { border: 1px solid var(--border); border-radius: 9px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.audit-item.done { background: #f7faf7; }
.audit-item.done .audit-crop img { opacity: .6; }
.audit-crop img { display: block; width: 100%; max-height: 190px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 6px; }
.audit-text code { font-size: 16px; font-weight: 700; background: var(--gray-bg); padding: 1px 6px; border-radius: 4px; }
.audit-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.audit-actions input { flex: 1 1 120px; min-width: 0; margin: 0; padding: 6px 8px; font-family: ui-monospace, Consolas, monospace; font-size: 15px; }

/* Вопросы по схемам: по линиям и машинам */
.audit-line-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 6px; }
.audit-line-head h2 { margin: 0; }
.audit-doc { border-top: 1px solid var(--border); padding: 12px 0 4px; }
.audit-doc-head { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: flex-start; }
.audit-doc-head .actions { display: flex; gap: 8px; align-items: center; }
.audit-machines { margin-top: 8px; }
.audit-machines td, .audit-machines th { padding: 6px 8px; vertical-align: middle; }

/* место прихода по ссылке или проводу */
.arrive { position: absolute; box-sizing: content-box; margin: -5px; padding: 5px; border: 3px solid #12a150; border-radius: 6px; background: rgba(18, 161, 80, .22); pointer-events: none; z-index: 6; animation: arrivePulse 1.3s ease-out infinite; }
.arrive.big { margin: 0; padding: 0; background: none; border-style: dashed; animation: none; }
.arrive-flag { position: absolute; left: -3px; bottom: calc(100% + 6px); white-space: nowrap; background: #12a150; color: #fff; font: 700 12px/1.2 system-ui, sans-serif; padding: 4px 8px; border-radius: 6px; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.arrive-flag::after { content: ""; position: absolute; left: 10px; top: 100%; border: 6px solid transparent; border-top-color: #12a150; }
.arrive-flag.below { bottom: auto; top: calc(100% + 6px); }
.arrive-flag.below::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: #12a150; }
@keyframes arrivePulse { 0% { box-shadow: 0 0 0 0 rgba(18, 161, 80, .7); } 70% { box-shadow: 0 0 0 16px rgba(18, 161, 80, 0); } 100% { box-shadow: 0 0 0 0 rgba(18, 161, 80, 0); } }
.zone-arrive { animation: trPulse 1.6s ease-in-out infinite; }
.nav-trail a.cur { background: #12a150; color: #fff; border-color: #12a150; }
.nav-trail a.cur span { color: #e6f7ec; }
.arrive-key { background: rgba(18, 161, 80, .2); border-bottom: 2px solid #12a150; padding: 0 3px; border-radius: 3px; font-weight: 600; }

/* адреса входов и выходов контроллера */
.hot.addr { border: 1px solid #0c8599; border-radius: 3px; background: rgba(12, 133, 153, .12); }
.hot.addr:hover { background: rgba(12, 133, 153, .3); outline: 2px solid #0c8599; }
.hot-sample.addr { border: 1px solid #0c8599; border-radius: 3px; background: rgba(12, 133, 153, .12); padding: 0 2px; }

/* схема на весь экран */
body.schema-full { overflow: hidden; }
body.schema-full .schema-layout { position: fixed; inset: 0; z-index: 2000; background: #eef1f5; padding: 8px; gap: 8px; grid-template-columns: minmax(0, 1fr) 380px; align-items: stretch; }
body.schema-full.schema-noside .schema-layout { grid-template-columns: minmax(0, 1fr); }
body.schema-full.schema-noside .schema-side { display: none; }
body.schema-full .schema-viewer { margin: 0; display: flex; flex-direction: column; min-height: 0; height: calc(100vh - 16px); padding: 8px 10px; }
body.schema-full .schema-viewer > .small.muted { display: none; }
body.schema-full .viewer-scroll { flex: 1 1 auto; height: auto !important; max-height: none !important; min-height: 0; }
body.schema-full .schema-side { height: calc(100vh - 16px); min-height: 0; }
@media (max-width: 1000px) { body.schema-full .schema-layout { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 40vh; } body.schema-full .schema-viewer, body.schema-full .schema-side { height: auto; } }

.unit-bar{margin:4px 0;padding:7px 10px;border-radius:8px;background:#eaf6ee;border:1px solid #b9e0c5;color:#14532d;line-height:1.5}
.unit-bar a{font-weight:600}
