:root {
  --bg: #F5F6F8; --panel: #fff; --line: #E5E7EB; --line2: #D1D5DB; --text: #111827; --muted: #4B5563; --soft: #F3F4F6;
  --accent: #2563EB; --accent-d: #1D4ED8; --accent-bg: #EFF6FF; --accent-bd: #93C5FD; --indigo-bg: #EEF2FF; --indigo: #3730A3;
  --green: #15803D; --green-bg: #DCFCE7; --green-fg: #166534; --amber-bg: #FEF3C7; --amber-fg: #92400E; --red: #DC2626; --red-bg: #FEE2E2; --red-fg: #991B1B;
  --orange-bg: #FFEDD5; --orange-fg: #9A3412; --orange-bd: #FDBA74;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-d); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.sp { flex: 1; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.wrap { max-width: 2200px; margin: 0 auto; padding: 0 clamp(14px, 2.4vw, 40px); }
.main { padding-top: 22px; padding-bottom: 48px; display: flex; flex-direction: column; gap: 16px; }
h1 { margin: 0; font-size: 26px; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 17px; }
h3 { margin: 0; font-size: 15px; }

/* кнопки */
.btn { height: 40px; padding: 0 14px; border: 1px solid var(--line2); border-radius: 10px; background: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 500; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { border-color: #9CA3AF; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.pri:hover { background: var(--accent-d); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn.warn { color: var(--orange-fg); border-color: var(--orange-bd); font-weight: 600; }
.btn.danger { color: var(--red-fg); }
.btn.big { height: 44px; border-radius: 12px; padding: 0 18px; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.ib { width: 40px; height: 40px; border: none; border-radius: 10px; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; position: relative; text-decoration: none; }
.ib:hover { background: var(--soft); color: var(--text); }
.ib.bd { border: 1px solid var(--line2); background: #fff; }
.cnt { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--green); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.ib > .cnt, .bell > .cnt { position: absolute; top: -7px; right: -7px; border: 2px solid #fff; min-width: 22px; height: 22px; }
.chip { height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--line2); background: #fff; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.chip .n { font-size: 12px; font-weight: 700; padding: 0 7px; border-radius: 10px; background: var(--soft); }
.chip.on { background: var(--text); border-color: var(--text); color: #fff; }
.chip.on .n { background: #374151; }
.pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; display: inline-block; }
.t-done { background: var(--green-bg); color: var(--green-fg); }
.t-progress, .t-ready { background: #DBEAFE; color: #1E40AF; }
.t-soon { background: var(--amber-bg); color: var(--amber-fg); }
.t-late { background: var(--red-bg); color: var(--red-fg); }
.t-wait, .t-locked { background: var(--soft); color: var(--muted); }
.t-rework { background: var(--orange-bg); color: var(--orange-fg); }
.role { font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 8px; white-space: nowrap; flex: none; }
.role.cur { background: var(--indigo-bg); color: var(--indigo); }
.role.exec, .role.guest { background: var(--soft); color: #374151; }
.av { width: var(--s); height: var(--s); border-radius: 50%; color: #fff; font-size: calc(var(--s) * .36); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; flex: none; }
img.av { object-fit: cover; background: #E5E7EB; display: inline-block; }
.av.none { background: #E5E7EB; color: #6B7280; }
.avs { display: flex; align-items: center; }
.avs .av { border: 2px solid #fff; margin-left: -8px; }
.avs .av:first-child { margin-left: 0; }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], input:not([type]), select, textarea { border: 1px solid var(--line2); border-radius: 10px; padding: 0 10px; height: 40px; background: #fff; min-width: 0; }
textarea { padding: 8px 10px; height: auto; resize: vertical; }
label.f { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.f > input, label.f > select, label.f > textarea { color: var(--text); font-size: 14px; }
.search { height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); }
.search input { border: none; outline: none; height: 40px; flex: 1; padding: 0; background: transparent; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1F2937; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 60; max-width: calc(100vw - 32px); }
.toast.err { background: var(--red); }

/* вход */
.auth { width: min(400px, calc(100vw - 32px)); margin: 10vh auto 0; background: #fff; padding: 28px; border-radius: 16px; display: grid; gap: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.08); }
.auth h1 { font-size: 22px; }
.auth p { margin: 0; color: var(--muted); }
.pin { font-size: 28px; letter-spacing: 16px; text-align: center; height: 56px !important; }
.linkbtn { border: none; background: none; color: var(--accent-d); cursor: pointer; padding: 8px 0; }

/* шапка */
.top { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.topin { display: flex; align-items: center; gap: 14px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.logo i { width: 32px; height: 32px; border-radius: 9px; background: #111827; color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { height: 40px; padding: 0 14px; border-radius: 10px; color: #374151; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.nav a.on { background: var(--indigo-bg); color: #1E40AF; font-weight: 600; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--green-fg); white-space: nowrap; }
.live i { width: 8px; height: 8px; border-radius: 4px; background: #16A34A; }
.live.off { color: var(--red-fg); }
.live.off i { background: var(--red); }
.pop { position: absolute; right: 0; top: 52px; width: 400px; max-width: calc(100vw - 24px); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 40px rgba(17,24,39,.14); z-index: 40; overflow: hidden; }
.pop-h { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px; border-bottom: 1px solid var(--line); }
.pop-list { max-height: 420px; overflow-y: auto; }
.note { width: 100%; display: flex; gap: 12px; padding: 12px 16px; border: none; border-bottom: 1px solid var(--soft); background: #fff; text-align: left; cursor: pointer; }
.note.new { background: #F0FDF4; }
.note .dot { width: 10px; height: 10px; border-radius: 5px; flex: none; margin-top: 4px; }
.note.new .dot { background: var(--green); }
.relw { position: relative; }
.menu { width: 240px; padding: 6px; }
.menu button { width: 100%; text-align: left; height: 40px; border: none; background: none; border-radius: 8px; padding: 0 10px; cursor: pointer; }
.menu button:hover { background: var(--soft); }

/* проекты */
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ph p { margin: 4px 0 0; color: var(--muted); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar .search { flex: 1 1 280px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.plist { display: flex; flex-direction: column; gap: 12px; }
.pcard { background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.phead { display: flex; align-items: center; }
.fh { flex: 1; min-width: 0; display: grid; grid-template-columns: 30px minmax(0, 1fr) 210px 130px 118px 20px; align-items: center; column-gap: 14px; padding: 14px 12px 14px 20px; background: transparent; border: none; text-align: left; cursor: pointer; }
.fh .nm { display: flex; align-items: center; gap: 8px; min-width: 0; }
.fh .nm b { font-size: 16px; }
.prog { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 12px; color: var(--muted); }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: #16A34A; }
.pact { display: flex; gap: 8px; margin-right: 16px; flex: none; }
.pact .btn { width: 156px; }
.stages { border-top: 1px solid var(--line); padding: 14px 20px 20px; display: flex; flex-direction: column; gap: 8px; background: #FAFAFB; }
.stage { border-radius: 12px; background: #fff; border: 1px solid var(--line); display: flex; flex-direction: column; }
.stage.m-done { background: #F0FDF4; border-color: #BBF7D0; }
.stage.m-soon { background: #FFFBEB; border-color: #FDE68A; }
.stage.m-late { background: #FEF2F2; border-color: #FECACA; }
.stage.m-ready { background: var(--accent-bg); border-color: var(--accent-bd); }
.stage.m-progress { border-color: #BFDBFE; }
.stage.m-rework { background: #FFF7ED; border-color: var(--orange-bd); }
.sr-g { display: grid; grid-template-columns: 70px minmax(0, 1fr) 150px 462px; align-items: center; column-gap: 12px; row-gap: 8px; padding: 10px 14px; }
.sact { display: grid; grid-template-columns: 160px 290px; column-gap: 12px; align-items: center; min-width: 0; }
.step { justify-self: start; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--soft); padding: 2px 8px; border-radius: 8px; white-space: nowrap; }
.step.par { background: var(--indigo-bg); color: var(--indigo); }
.sname { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sname b { font-size: 14px; }
.meta { font-size: 12px; color: var(--muted); display: flex; gap: 4px 12px; flex-wrap: wrap; align-items: center; }
.meta span { display: inline-flex; align-items: center; gap: 4px; }
.remind { font-size: 12px; color: var(--amber-fg); }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; color: #374151; }
.acts { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.retnote { margin: 0 14px 12px; padding: 10px 12px; border-radius: 10px; background: #FFF7ED; border: 1px solid #FED7AA; font-size: 13px; color: #7C2D12; }
.retform { border-top: 1px solid #FED7AA; background: #FFF7ED; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; border-radius: 0 0 12px 12px; }
.panel { border-top: 1px solid var(--line); padding: 14px; display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.pfiles { flex: 1 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 150px; padding: 28px 16px; border: 2px dashed #BFC6D1; border-radius: 14px; background: #fff; color: #374151; cursor: pointer; text-align: center; font-size: 15px; }
.drop:hover { border-color: var(--accent); background: #FAFCFF; }
.drop svg { width: 36px; height: 36px; }
.drop.over { border-color: var(--accent); background: var(--accent-bg); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.up { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.up .bar { flex: 1; }
.fgrid { display: grid; grid-template-columns: minmax(0, 1fr) 64px 64px 64px 96px; align-items: center; }
.fhead { padding: 0 8px; font-size: 12px; color: var(--muted); }
.fhead span { text-align: center; }
.file { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.file .fgrid { padding: 2px 8px; min-height: 48px; }
.fname { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ext { width: 38px; height: 38px; border-radius: 8px; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; background: var(--soft); color: #374151; }
.ext.pdf { background: var(--red-bg); color: var(--red-fg); }
.ext.dwg, .ext.dxf { background: #DBEAFE; color: #1E40AF; }
.ext.xls, .ext.xlsx, .ext.csv { background: var(--green-bg); color: var(--green-fg); }
.ext.jpg, .ext.jpeg, .ext.png { background: #F3E8FF; color: #6B21A8; }
.vb { height: 24px; padding: 0 8px; border: 1px solid #C7D2FE; border-radius: 12px; background: var(--indigo-bg); color: var(--indigo); font-size: 11px; font-weight: 700; cursor: pointer; flex: none; }
.vb.one { border-color: var(--line); background: var(--soft); color: var(--muted); cursor: default; }
.cell { display: flex; justify-content: center; }
.sw { width: 64px; height: 44px; border: none; background: transparent; padding: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.sw i { width: 40px; height: 24px; border-radius: 12px; padding: 2px; background: #C4C9D2; display: flex; justify-content: flex-start; transition: background .15s; }
.sw i::after { content: ""; width: 20px; height: 20px; border-radius: 10px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.sw.on i { background: var(--accent); justify-content: flex-end; }
.sw:disabled { opacity: .4; cursor: not-allowed; }
.sub { border-top: 1px solid var(--line); background: #F9FAFB; padding: 6px 8px 8px; display: flex; flex-direction: column; gap: 2px; }
.sub .fgrid { min-height: 40px; }
.vrow { display: flex; align-items: center; gap: 10px; min-height: 36px; padding-left: 48px; font-size: 12px; color: #374151; }
.vrow b { width: 92px; flex: none; color: var(--indigo); }
.finish { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 4px; }
.empty { padding: 40px; text-align: center; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 16px; }

/* модальные окна */
.ov { position: fixed; inset: 0; background: rgba(20,22,26,.4); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 16px; padding: 20px; width: min(560px, 100%); max-height: 100%; overflow: auto; display: grid; gap: 12px; }
.modal.wide { width: min(900px, 100%); }
.m-h { display: flex; align-items: center; gap: 8px; }
.m-h h2 { flex: 1; font-size: 20px; }
.seg { display: inline-flex; padding: 3px; background: var(--line); border-radius: 12px; }
.seg button { height: 34px; padding: 0 12px; border: none; border-radius: 9px; background: transparent; cursor: pointer; font-weight: 500; }
.seg button.on { background: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.prev { background: #F8F8FA; border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.prev ol { margin: 6px 0; padding-left: 22px; }
.team { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tchip { height: 34px; border-radius: 17px; padding: 0 12px 0 4px; border: 1px solid var(--line2); background: #fff; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.tchip.on { background: var(--indigo-bg); border-color: #A5B4FC; color: var(--indigo); }
.erow { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.erow.over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bd); }
.erow .l1, .erow .l2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.erow .l2 { padding-left: 36px; }
.grip { width: 28px; height: 40px; display: inline-flex; align-items: center; justify-content: center; color: #6B7280; cursor: grab; flex: none; }
.tg { height: 34px; padding: 0 10px; border: 1px solid var(--line2); border-radius: 17px; background: #fff; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.tg.on { background: var(--indigo-bg); border-color: #A5B4FC; color: var(--indigo); }
.tg:disabled { opacity: .45; cursor: not-allowed; }

/* календарь-шкала */
.tlbar { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.rib { width: 230px; height: 40px; overflow: hidden; flex: none; }
.rib div { display: flex; flex-direction: column; will-change: transform; }
.rib span { height: 40px; flex: none; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.ribi { height: 20px; overflow: hidden; padding-left: 4px; }
.ribi div { display: flex; flex-direction: column; will-change: transform; }
.ribi span { height: 20px; flex: none; line-height: 20px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swl { height: 40px; padding: 0 12px 0 8px; border: 1px solid var(--line2); border-radius: 20px; background: #fff; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.swl i { width: 36px; height: 22px; border-radius: 11px; padding: 2px; background: #C4C9D2; display: flex; }
.swl i::after { content: ""; width: 18px; height: 18px; border-radius: 9px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.swl.on i { background: var(--accent); justify-content: flex-end; }
.tlwrap { display: flex; flex-direction: column; gap: 14px; outline-offset: 4px; }
.tl { background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; user-select: none; }
.tlwrap.drag .tlv { cursor: grabbing; }
.tlh .tll.tlp { flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; cursor: pointer; }
.tll.lane { cursor: default; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; }
.tll.lane b { font-size: 13px; }
.tlr { display: flex; border-top: 1px solid #F1F2F4; }
.tlr.f { border-top-color: var(--line); }
.tll { width: 280px; flex: none; border-right: 1px solid var(--line); background: #fff; display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 44px; border-top: none; border-bottom: none; border-left: none; text-align: left; cursor: pointer; min-width: 0; }
.tlr.f .tll { height: 52px; background: #FAFAFB; }
.tlr.s .tll { padding-left: 38px; }
.tlv { flex: 1; position: relative; overflow: hidden; cursor: grab; touch-action: pan-y; }
.tli { position: absolute; top: 0; bottom: 0; left: 0; width: calc(var(--dw) * var(--R)); transform: translateX(var(--tx)); will-change: transform; }
.tlh .tll { height: 62px; cursor: default; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; }
.tlh .tli { display: grid; grid-template-columns: repeat(var(--R), 1fr); }
.dh { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 4px 0 6px; border-left: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.dh b { font-size: 13px; color: var(--text); }
.dh em { font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: .04em; color: var(--accent-d); height: 14px; }
.dh.off { background: #EEF0F3; }
.dh.hol { background: #DFE2E7; }
.dh.hol b { color: #B91C1C; }
.dh.tod { background: var(--accent); color: #fff; }
.dh.tod b, .dh.tod em { color: #fff; }
.dh.m1 { border-left: 2px solid #6B7280; }
.tday { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: .45; }
.tb { position: absolute; top: 0; height: 44px; padding: 0; border: none; background: transparent; cursor: pointer; display: flex; align-items: center; }
.tb > span { width: 100%; height: 30px; display: flex; align-items: center; gap: 6px; padding: 0 8px 0 3px; border-radius: 15px; font-size: 12px; font-weight: 600; overflow: hidden; white-space: nowrap; box-shadow: 0 1px 3px rgba(17,24,39,.2); border: 1px solid transparent; }
.tb .lab { display: flex; align-items: center; gap: 6px; min-width: 0; will-change: transform; }
.tb .lab span:last-child { overflow: hidden; text-overflow: ellipsis; }
.b-done > span { background: #64748B; color: #fff; border-color: #475569; }
.b-doneMine > span { background: var(--green-bg); color: var(--green-fg); }
.b-progress > span { background: #DBEAFE; color: #1E40AF; border-color: #60A5FA; }
.b-ready > span { background: var(--accent-bg); color: #1E40AF; border-color: var(--accent); }
.b-soon > span { background: var(--amber-bg); color: var(--amber-fg); border-color: #F59E0B; }
.b-late > span { background: var(--red-bg); color: var(--red-fg); border-color: #F87171; }
.b-locked > span { background: #fff; color: #374151; border: 1px dashed #6B7280; }
.b-rework > span { background: var(--orange-bg); color: var(--orange-fg); border-color: var(--orange-bd); }
.b-gov > span { background-image: repeating-linear-gradient(135deg, rgba(17,24,39,.09) 0 6px, transparent 6px 12px); }
.b-mine > span { border: 2px solid #111827; }
.b-sel > span { box-shadow: 0 0 0 3px var(--accent-bd), 0 1px 3px rgba(17,24,39,.2); }
.legend { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(300px, 2fr) minmax(220px, 1fr); gap: 16px 28px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px 20px 16px; }
.lg-g { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.lg-g + .lg-g { border-left: 1px solid var(--line); padding-left: 28px; }
.lg-g h4 { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.lg-items { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.lg-i { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: #374151; white-space: nowrap; }
.lgb { display: inline-flex; width: 36px; height: 20px; flex: none; }
:where(.lgb) > span { width: 100%; height: 100%; border-radius: 10px; border: 1px solid transparent; box-shadow: 0 1px 2px rgba(17,24,39,.18); } /* :where — чтобы рамки из .b-* (как на шкале) были важнее */
.lgd { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line); flex: none; display: inline-flex; align-items: center; justify-content: center; font-style: normal; font-size: 10px; font-weight: 700; position: relative; }
.lgd.off { background: #EEF0F3; }
.lgd.hol { background: #DFE2E7; color: #B91C1C; }
.lgd.tod { background: #EFF6FF; border-color: #BFDBFE; }
.lgd.tod::after { content: ""; position: absolute; top: 3px; bottom: 3px; left: 50%; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--accent); }
@media (max-width: 1000px) { .legend { grid-template-columns: 1fr; } .lg-g + .lg-g { border-left: none; padding-left: 0; border-top: 1px solid var(--line); padding-top: 12px; } }
.selcard { display: flex; flex-direction: column; gap: 6px; padding: 10px 14px 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.sel-top { display: flex; align-items: center; gap: 8px; }
.sel-name { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sel-name b { font-size: 18px; line-height: 1.3; }
.sel-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.selwho { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; background: #F9FAFB; border-radius: 12px; min-width: 210px; max-width: 280px; font-size: 14px; }

/* чаты */
.chatbox { display: flex; height: calc(100vh - 170px); min-height: 560px; background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.clist { width: 340px; flex: none; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.clist-top { padding: 12px 12px 10px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.clist-top .search { height: 40px; background: var(--soft); border: none; }
.clist .chip { height: 32px; font-size: 12px; padding: 0 10px; }
.cscroll { flex: 1; min-height: 0; overflow-y: auto; }
.csec { position: sticky; top: 0; z-index: 1; padding: 8px 14px 4px; background: #fff; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.cgrp { border-bottom: 1px solid var(--soft); }
.cgrp-h { display: flex; align-items: center; }
.cgrp-h.cur { background: #F8FAFF; }
.cgrp-b { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 9px 4px 9px 10px; border: none; background: transparent; text-align: left; cursor: pointer; }
.cline { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.cline b, .cline .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cline small { font-size: 11px; color: var(--muted); flex: none; }
.citem { width: 100%; display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 38px; border: none; border-left: 3px solid transparent; background: transparent; text-align: left; cursor: pointer; }
.citem.on { background: var(--accent-bg); border-left-color: var(--accent); }
.gicon { width: 28px; height: 28px; border-radius: 8px; background: var(--indigo-bg); color: var(--indigo); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.conv { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.conv-h { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 18px; background: #FCFCFD; display: flex; flex-direction: column; gap: 8px; }
.day { align-self: center; margin: 8px 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--soft); padding: 3px 12px; border-radius: 10px; }
.newline { display: flex; align-items: center; gap: 8px; margin: 4px 0; color: var(--green); font-size: 12px; font-weight: 600; }
.newline::before, .newline::after { content: ""; flex: 1; height: 1px; background: #86EFAC; }
.sysm { align-self: center; max-width: 80%; text-align: center; font-size: 12px; color: var(--muted); }
.msg { display: flex; gap: 8px; align-items: flex-end; }
.msg.own { flex-direction: row-reverse; }
.msg.cont { margin-top: -4px; }
.msg.cont .av { visibility: hidden; }
.mbody { max-width: 72%; min-width: 0; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.msg.own .mbody { align-items: flex-end; }
.mname { font-size: 12px; padding: 0 4px; }
.bub { padding: 8px 12px; border-radius: 4px 16px 16px 16px; background: var(--soft); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.msg.own .bub { border-radius: 16px 4px 16px 16px; background: #DBEAFE; }
.bub .tx { font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bub .tm { align-self: flex-end; font-size: 11px; color: var(--muted); }
.fchip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; min-width: 220px; }
.typing { padding: 4px 18px; font-size: 12px; color: var(--muted); font-style: italic; background: #FCFCFD; min-height: 22px; }
.compose { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.compose textarea { flex: 1; min-width: 0; height: 44px; resize: none; padding: 11px 14px; border-radius: 12px; font-size: 14px; line-height: 20px; }
.compose .ib { width: 44px; height: 44px; border: 1px solid var(--line2); border-radius: 12px; background: #fff; }
.compose .send.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.people { width: 280px; flex: none; border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.people-l { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.prow { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.addp { margin-top: 6px; height: 44px; border: 1px dashed var(--accent); border-radius: 12px; background: var(--accent-bg); color: #1E40AF; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; }
.picker { margin-top: 6px; border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 4px; background: #F9FAFB; }
.nochat { flex: 1; display: grid; place-items: center; color: var(--muted); padding: 24px; text-align: center; }

/* админ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs button { height: 44px; padding: 0 14px; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; background: transparent; cursor: pointer; font-weight: 500; color: #374151; }
.tabs button.on { border-bottom-color: var(--accent); color: #1E40AF; font-weight: 600; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl td:last-child { text-align: right; white-space: nowrap; }
.grid-f { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end; background: #F8F8FA; padding: 14px; border-radius: 12px; }
.grid-f > .full { grid-column: 1 / -1; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 8px; background: var(--soft); color: #374151; margin-left: 4px; }
.badge.own { background: var(--indigo-bg); color: var(--indigo); }
.badge.cc { background: var(--green-bg); color: var(--green-fg); }
.badge.off { background: var(--red-bg); color: var(--red-fg); }
.tplw { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.tpll { flex: 1 1 240px; max-width: 290px; display: flex; flex-direction: column; gap: 8px; }
.tplb { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; text-align: left; cursor: pointer; }
.tplb.on { background: var(--indigo-bg); border-color: #A5B4FC; }
.info { display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--accent-bg); color: #1E3A8A; font-size: 13px; }
.hols { columns: 2; font-size: 13px; }
.hols span { display: block; }

@media (max-width: 1180px) {
  .fh { grid-template-columns: 30px minmax(0, 1fr) 190px 120px 20px; }
  .fh .tm { display: none; }
  .sr-g { grid-template-columns: 70px minmax(0, 1fr) 150px; }
  .sact { grid-column: 2 / -1; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
}
@media (max-width: 1000px) {
  .fh { grid-template-columns: 30px minmax(0, 1fr) 180px 20px; }
  .fh .pg { display: none; }
  .pact .btn { width: auto; }
  .pact .btn .bt { display: none; }
}
@media (min-width: 1600px) {
  .clist { width: 380px; }
  .people { width: 300px; }
}
@media (max-width: 900px) {
  .fh { grid-template-columns: 30px minmax(0, 1fr) 20px; }
  .fh .opt { display: none !important; }
  .sr-g { grid-template-columns: minmax(0, 1fr); }
  .sact { grid-column: auto; }
  .chatbox { flex-direction: column; height: auto; }
  .clist, .people { width: auto; max-height: 360px; border: none; border-bottom: 1px solid var(--line); }
  .conv { min-height: 520px; }
  .tll { width: 160px; }
  .hols { columns: 1; }
}
/* телефон: шапка в две строки (вверху логотип и кнопки, ниже — разделы с прокруткой), компактнее заголовки */
@media (max-width: 700px) {
  .topin { gap: 8px; padding-top: 8px; padding-bottom: 6px; }
  .nav { order: 5; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; }
  .nav a { height: 36px; padding: 0 12px; flex: none; }
  .live { font-size: 0; gap: 0; }
  h1 { font-size: 22px; }
  .main { padding-top: 14px; }
  .tll { width: 120px; padding: 0 8px; }
  .tlr.s .tll { padding-left: 10px; }
  .pact { margin-right: 10px; gap: 6px; }
  .stages { padding: 10px; }
  .chips .chip { height: 34px; }
  .fh { padding-left: 12px; column-gap: 10px; }
  .fh .role { display: none; }
  .rib { width: 160px; }
  .rib span { font-size: 19px; }
  .tll.lane .muted { display: none; }
  .tll.lane b { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
