:root {
  /* серые тона: графитовая боковая панель, основное окно на тон светлее, карточки белые */
  --bg: #eceef0; --panel: #fff; --ink: #23272c; --muted: #6b7278; --line: #d7dade; --line2: #e7e9eb;
  --accent: #3f464d; --accent-soft: #e4e7ea; --ok: #3c7d56; --ok-soft: #e7eeea; --warn: #9a7420; --warn-soft: #f4eee1;
  --bad: #b23c2e; --bad-soft: #f4e4e2; --plan: #a8afb6; --fact: #3f464d;
  --side: #23272c; --side-ink: #c9ced4; --side-muted: #8b9299; --side-active: #3a4046;
  /* material: форма, высоты (тени), длительности и кривые движения */
  --radius: 12px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-dialog: 24px; --r-pill: 999px;
  --el-1: 0 1px 2px rgba(20,22,25,.10), 0 1px 3px 1px rgba(20,22,25,.05);
  --el-2: 0 1px 2px rgba(20,22,25,.10), 0 2px 6px 2px rgba(20,22,25,.07);
  --el-3: 0 1px 3px rgba(20,22,25,.12), 0 4px 10px 3px rgba(20,22,25,.09);
  --el-4: 0 2px 6px rgba(20,22,25,.12), 0 10px 28px 6px rgba(20,22,25,.14);
  --shadow: var(--el-1);
  --dur-fast: 120ms; --dur: 200ms; --dur-slow: 320ms;
  --ease: cubic-bezier(.2, 0, 0, 1);      /* стандартная кривая material */
  --ease-out: cubic-bezier(0, 0, 0, 1);   /* появление */
  --ease-in: cubic-bezier(.3, 0, .8, .15);/* исчезновение — короче появления */
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 14px/1.4 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { color: #fff; font-weight: 700; font-size: 15px; padding: 0 10px 4px; }
.brand-sub { font-size: 12px; color: var(--side-muted); padding: 0 10px 16px; line-height: 1.3; }
.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px; cursor: pointer; border: 0; background: none; text-align: left; color: inherit; }
.nav:hover { background: rgba(255,255,255,.06); }
.nav.active { background: var(--side-active); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 #a5adb5; }
.nav .badge { margin-left: auto; }
.side-foot { margin-top: auto; font-size: 12px; color: var(--side-muted); padding: 10px; }
.main { padding: 20px 24px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin-right: auto; }

/* controls */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #b8bcc1; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #32383e; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.input, select.input, textarea.input { padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; min-width: 0; }
.input:focus, .cell-in:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 7px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
label.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel.pad { padding: 16px; }
.panel h2 { font-size: 15px; margin-bottom: 10px; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--line2); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--accent-soft); color: var(--accent); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { padding: 12px 14px; }
.kpi .k { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted); }
.bar { height: 5px; background: var(--line2); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.chart-wrap { padding: 12px 14px; margin-bottom: 12px; }
.chart-head { display: flex; gap: 14px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.chart-head b { color: var(--ink); font-size: 13px; margin-right: auto; }
.lg { display: inline-flex; align-items: center; gap: 5px; }
.lg i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }

/* work table */
.tbl-wrap { overflow: auto; max-height: calc(100vh - 150px); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.wt { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.wt th { position: sticky; top: 0; background: #e9ebed; z-index: 3; font-weight: 600; font-size: 12px; color: #4b5257; padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.wt th.num { text-align: right; }
.wt td { padding: 5px 8px; border-bottom: 1px solid var(--line2); vertical-align: middle; background: #fff; }
.wt tr.sec td { background: #e2e4e7; font-weight: 600; position: sticky; top: 31px; z-index: 2; cursor: pointer; border-bottom: 1px solid var(--line); }
.wt tr.sec .tot { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 10px; }
.wt tr.item:hover td { background: #f5f6f7; }
.wt td.name { min-width: 240px; max-width: 360px; }
.wt td.name .n { cursor: pointer; }
.wt td.name .n:hover { color: var(--accent); text-decoration: underline; }
.wt td.code { font-size: 11px; color: var(--muted); max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wt .sticky1 { position: sticky; left: 0; z-index: 1; }
.wt th.sticky1 { z-index: 4; }
.wt td.warn-cell { background: var(--bad-soft) !important; color: var(--bad); }
.wt td.done { color: var(--ok); }
.wt td.day { padding: 2px; min-width: 50px; text-align: center; }
.wt th.day { text-align: center; padding: 6px 2px; min-width: 50px; }
.wt th.day.we, .wt td.day.we { background: #f7f5f0; }
.wt th.day.today, .wt td.day.today { box-shadow: inset 0 0 0 1px var(--accent); }
.day-pf { font-size: 11px; line-height: 1.2; }
.day-pf .p { color: var(--plan); }
.day-pf .f { font-weight: 600; }
.day-pf .f.lag { color: var(--bad); }
.cell-in { width: 100%; min-width: 46px; border: 1px solid transparent; background: transparent; padding: 4px 5px; border-radius: 4px; text-align: right; font-variant-numeric: tabular-nums; }
.cell-in:hover { border-color: var(--line); background: #fff; }
.cell-in.saved { background: var(--ok-soft); transition: background .2s; }
.cell-in.plan { color: #6f777e; }
td.wide-in .cell-in { min-width: 80px; }
.pct { font-size: 12px; }
.warn-ico { color: var(--bad); cursor: help; margin-left: 4px; }
.src-ai { font-size: 10px; color: #7b4fb8; margin-left: 4px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* generic table */
table.lt { width: 100%; border-collapse: collapse; font-size: 13px; }
.lt th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); background: #f3f4f5; position: sticky; top: 0; }
.lt td { padding: 7px 8px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.lt tr.dim td { opacity: .55; }
.lt input.cell-in { text-align: left; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,25,40,.45); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 10px; width: min(760px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal.wide { width: min(1100px, 100%); }
.modal-h { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-h h3 { font-size: 16px; margin-right: auto; }
.modal-b { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }

.letter { white-space: pre-wrap; font-family: inherit; background: #f7f8f9; border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; max-height: 320px; overflow: auto; margin: 0; }
.problems { background: var(--warn-soft); color: #7a5313; border-radius: 6px; padding: 10px 12px; }
.problems ul { margin: 4px 0 0; padding-left: 18px; }
.confirm-box { background: var(--accent-soft); border-radius: 6px; padding: 10px 12px; }
.pick-list { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.pick-list label { display: flex; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line2); cursor: pointer; align-items: flex-start; }
.pick-list label:hover { background: #f5f6f7; }
.pick-list .grp { padding: 5px 10px; background: #e9ebed; font-size: 12px; font-weight: 600; color: var(--muted); position: sticky; top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--accent-soft); color: var(--accent); border-radius: 12px; padding: 2px 9px; font-size: 12px; }

.call-card { padding: 14px 16px; display: grid; grid-template-columns: 90px 1fr auto; gap: 14px; align-items: start; }
.call-date { text-align: center; border-right: 1px solid var(--line); padding-right: 12px; }
.call-date .d { font-size: 22px; font-weight: 700; }
.call-date .m { font-size: 12px; color: var(--muted); }
.call-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
/* компактный список вызовов */
.stack.calls-list { gap: 6px; }
.call-row { padding: 0; }
.cr-head { display: grid; grid-template-columns: 130px 1fr auto; gap: 14px; align-items: center; padding: 9px 14px; cursor: pointer; user-select: none; }
.cr-head:hover { background: #f3f4f5; }
.cr-when { white-space: nowrap; font-size: 13px; }
.cr-main { min-width: 0; }
.cr-work { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.cr-sub { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-status { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.cr-arrow { color: var(--muted); transition: transform .15s; }
.call-row.open .cr-arrow { transform: rotate(180deg); }
.call-row.open .cr-head { border-bottom: 1px solid var(--line); }
.cr-body { padding: 12px 14px 14px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.drop { border: 2px dashed #c4c8cc; border-radius: var(--radius); padding: 26px; text-align: center; background: #f8f9fa; cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; right: 18px; bottom: 18px; background: var(--side); color: #fff; padding: 10px 14px; border-radius: 6px; box-shadow: var(--shadow); z-index: 60; max-width: 420px; }
.toast.err { background: var(--bad); }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
  .call-card { grid-template-columns: minmax(0, 1fr); }
  .cr-head { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}

/* справочник приказов */
.orders-matrix td { vertical-align: top; }
.orders-matrix .wt-name { background: #f3f4f5; }
.signer { padding: 6px 0; border-bottom: 1px dashed var(--line2); font-size: 13px; }
.signer:last-child { border-bottom: 0; }
.signer.backup b { font-weight: 500; }
.signer .btn.sm { margin-top: 3px; }
.svc-h { font-size: 16px; margin: 20px 0 10px; }
.dim-order { opacity: .7; }
.suggest { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink); }
.sg-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-btn { border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 3px 10px; cursor: pointer; font-size: 12px; }
.chip-btn:hover { border-color: var(--accent); }
.chip-btn.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.chip-btn.backup { color: var(--muted); }

/* вызовы: разделы работ и строки работ */
.kinds-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.kind-opt { border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; background: #fff; }
.kind-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip.kind { background: #eef3ea; color: #3f6b2f; }
.works-edit { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 6px; background: #f7f8f9; }
.work-row { display: grid; grid-template-columns: 150px 1fr; grid-template-areas: "at tools" "work work" "code code"; gap: 4px; padding: 6px; background: #fff; border: 1px solid var(--line2); border-radius: 6px; }
.work-row [data-f="at"] { grid-area: at; font-size: 12px; padding: 4px 6px; }
.work-row [data-f="work"] { grid-area: work; resize: vertical; }
.work-row [data-f="code"] { grid-area: code; font-size: 12px; }
.work-row .wr-tools { grid-area: tools; display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
table.works-mini { border-collapse: collapse; font-size: 13px; }
table.works-mini td { padding: 2px 10px 2px 0; vertical-align: top; }
.preview-part { border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.pp-h { font-weight: 600; }

.side .brand { padding-bottom: 16px; line-height: 1.3; }

.input.invalid { border-color: var(--bad); outline: 2px solid var(--bad-soft); }

/* настройки: плитки разделов */
.set-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; max-width: 900px; }
.set-tile { display: flex; align-items: center; gap: 14px; padding: 16px; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.set-tile:hover { border-color: var(--accent); }
.set-tile b { display: block; font-size: 15px; margin-bottom: 3px; }
.set-tile .muted { font-size: 12px; display: block; }
.set-tile .st-icon { font-size: 26px; }
.set-tile .st-arrow { margin-left: auto; font-size: 22px; color: var(--muted); }
#setBack { align-self: flex-start; }

.search-wide { flex: 1; width: 100%; font-size: 15px; padding: 9px 12px; }

/* изменение ширины столбцов */
.col-rz { position: absolute; top: 0; right: 0; width: 8px; height: 100%; cursor: col-resize; z-index: 6; }
.col-rz::after { content: ""; position: absolute; top: 20%; bottom: 20%; right: 3px; width: 2px; border-radius: 1px; background: var(--line); }
.col-rz:hover::after, .col-rz.active::after { background: var(--accent); top: 0; bottom: 0; }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none; }
.wt.fixed { table-layout: fixed; }
.wt.fixed th, .wt.fixed td { overflow: hidden; text-overflow: ellipsis; }
.wt.fixed td.name, .wt.fixed td.code { min-width: 0; max-width: none; }
.wt.fixed td.name { white-space: normal; overflow-wrap: anywhere; }
.wt.fixed td.day, .wt.fixed th.day { min-width: 0; }
.wt.fixed .cell-in, .wt.fixed td.wide-in .cell-in { min-width: 0; }


/* приказы: службы → приказы → карточка */
.svc-tile .svc-code { min-width: 58px; height: 42px; padding: 0 8px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.order-list { gap: 8px; max-width: 1100px; }
.order-card { display: grid; grid-template-columns: 150px 1fr auto; gap: 16px; align-items: center; padding: 12px 16px; text-align: left; cursor: pointer; font: inherit; color: inherit; width: 100%; }
.order-card:hover { border-color: var(--accent); }
.oc-num b { display: block; font-size: 15px; }
.oc-num .muted, .oc-main .muted { font-size: 12px; display: block; }
.oc-main { min-width: 0; }
.oc-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 2px; }
.oc-side { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.oc-side .st-arrow { font-size: 22px; color: var(--muted); margin-left: 6px; }
.page-head h1 .btn { vertical-align: middle; margin-right: 8px; font-size: 13px; }
.page-head h1 .badge { vertical-align: middle; }
@media (max-width: 800px) { .order-card { grid-template-columns: minmax(0, 1fr); gap: 6px; } }

/* вход и пользователи */
.auth-bg { position: fixed; inset: 0; background: var(--side); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.auth-card { width: 100%; max-width: 380px; padding: 26px; }
.auth-card h2 { margin: 0 0 4px; font-size: 18px; line-height: 1.3; }
.auth-err { color: var(--bad); min-height: 18px; font-size: 13px; }
.user-box { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 10px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; }
.user-box .muted { color: var(--side-muted); font-size: 12px; }
.user-box .btn { margin-left: auto; }
.user-box + .side-foot { margin-top: 0; }
/* просмотр приказов без права правки */
.ro .input:disabled, .ro .cell-in:disabled { background: transparent; border-color: transparent; color: inherit; -webkit-text-fill-color: currentColor; opacity: 1; cursor: text; appearance: none; -webkit-appearance: none; padding-left: 0; }
.ro textarea.input:disabled { min-height: 0; }
.ro input[type=checkbox]:disabled { appearance: auto; -webkit-appearance: checkbox; }
@media (max-width: 800px) { .user-box { margin-top: 0; border-top: 0; white-space: nowrap; } }
.role-legend { display: grid; gap: 2px; font-size: 13px; margin-bottom: 8px; padding: 10px 12px; background: var(--accent-soft); border-radius: 8px; }

/* сообщения */
.main.main-chat { padding: 14px 16px; }
.chat { display: grid; grid-template-columns: 320px 1fr; gap: 12px; height: calc(100vh - 28px); min-height: 420px; }
.chat-list { display: flex; flex-direction: column; min-height: 0; padding: 12px; gap: 8px; }
.cl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cl-head h1 { font-size: 18px; margin: 0 auto 0 0; }
.cl-actions { display: flex; gap: 6px; }
.cl-items { overflow: auto; min-height: 0; margin: 0 -6px; }
.cl-item { display: flex; gap: 10px; align-items: center; width: 100%; padding: 8px 6px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.cl-item:hover { background: var(--bg); }
.cl-item.on { background: var(--accent-soft); }
.avatar { position: relative; flex: 0 0 38px; height: 38px; border-radius: 50%; background: #dcdfe3; color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.avatar.group { background: #e1e4e6; font-size: 17px; }
.avatar .dot { position: absolute; right: 0; bottom: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--ok); border: 2px solid #fff; }
.cl-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.cl-top, .cl-bottom { display: flex; gap: 6px; align-items: center; min-width: 0; }
.cl-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: auto; }
.cl-top .muted { font-size: 11px; white-space: nowrap; }
.cl-prev { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: auto; }
.chat-room { display: flex; flex-direction: column; min-height: 0; position: relative; overflow: hidden; }
.chat-empty { margin: auto; }
.cr-top { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.cr-title { margin-right: auto; min-width: 0; }
.cr-title .muted { font-size: 12px; }
.cr-back { display: none; }
.msgs { flex: 1; overflow: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 3px; background: #f3f4f5; }
.more-wrap { text-align: center; margin-bottom: 8px; }
.day-sep { text-align: center; margin: 10px 0 6px; }
.day-sep span { background: #e4e6e9; color: var(--muted); font-size: 12px; padding: 2px 10px; border-radius: 10px; }
.msg-sys { text-align: center; color: var(--muted); font-size: 12px; margin: 6px 0; }
.msg { display: flex; align-items: flex-end; gap: 4px; max-width: min(620px, 82%); margin-top: 6px; }
.msg.cont { margin-top: 0; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px 5px; min-width: 70px; overflow-wrap: anywhere; }
.msg.mine .bubble { background: #e2e5e8; border-color: #ced3d8; }
.msg-author { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }
.msg-text { white-space: normal; line-height: 1.4; }
.msg-meta { float: right; font-size: 11px; color: var(--muted); margin: 4px 0 0 10px; }
.ticks.read { color: var(--accent); }
.msg-del { opacity: 0; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 4px; }
.msg:hover .msg-del { opacity: 1; }
.atts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.att-img img { display: block; max-width: 260px; max-height: 220px; border-radius: 8px; object-fit: cover; background: #eef1f4; }
.att-file { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.7); border: 1px solid var(--line); color: inherit; text-decoration: none; max-width: 100%; width: 300px; box-sizing: border-box; }
.att-file > span:last-child { min-width: 0; }
.att-file b { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-weight: 500; overflow-wrap: anywhere; line-height: 1.3; }
.att-file .muted { font-size: 11px; }
.att-ico { display: flex; flex: 0 0 auto; }
.ficon { display: block; }
.composer { border-top: 1px solid var(--line); padding: 8px 10px; background: #fff; }
.comp-row { display: flex; gap: 6px; align-items: flex-end; }
.comp-row textarea { flex: 1; resize: none; min-height: 38px; max-height: 160px; line-height: 1.35; }
.attach { cursor: pointer; font-size: 17px; padding: 6px 10px; }
.pending { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.pend { background: #eceef0; border-radius: 6px; padding: 3px 4px 3px 8px; font-size: 12px; display: inline-flex; gap: 4px; align-items: center; }
.pend button { border: 0; background: none; cursor: pointer; color: var(--muted); }
.drop-hint { position: absolute; inset: 0; background: rgba(31,95,168,.12); border: 2px dashed var(--accent); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-weight: 600; color: var(--accent); pointer-events: none; }
.gi-member { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; border-bottom: 1px dashed var(--line2); }
.chat-toast { cursor: pointer; max-width: 320px; }
.chat-toast div { font-size: 13px; opacity: .9; margin-top: 2px; }
@media (max-width: 800px) {
  .chat { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 90px); }
  .chat.has-active .chat-list { display: none; }
  .chat:not(.has-active) .chat-room { display: none; }
  .cr-back { display: inline-flex; }
  .msg { max-width: 92%; }
}

/* рабочая документация */
.rd-sync { display: flex; align-items: center; gap: 10px; }
.rd-sync .muted { font-size: 12px; }
.rd-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0 10px; font-size: 14px; }
.rd-crumbs .sep { color: var(--muted); }
.rd-table td { vertical-align: middle; }
.rd-ico { width: 34px; text-align: center; }
.rd-ico .folder { font-size: 24px; }
.rd-name { color: inherit; text-decoration: none; overflow-wrap: anywhere; }
.rd-name:hover { color: var(--accent); text-decoration: underline; }
.rd-dir a { text-decoration: none; }
.rd-where { font-size: 12px; margin-top: 2px; }
.rd-act { white-space: nowrap; text-align: right; }
.nowrap { white-space: nowrap; }
.rd-table td:nth-child(2) { min-width: 260px; }
@media (max-width: 800px) {
  .rd-table th:nth-child(4), .rd-table td:nth-child(4) { display: none; }
  .rd-table td:nth-child(2) { min-width: 180px; }
  .rd-sync { flex-wrap: wrap; }
}

/* игры */
.snake-wrap { max-width: 480px; }
.snake-bar { display: flex; gap: 18px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.snake-bar .btn { margin-left: auto; }
.snake-board { position: relative; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); }
.snake-board canvas { display: block; width: 100%; height: auto; touch-action: none; }
.snake-over { position: absolute; inset: 0; background: rgba(22,38,58,.55); display: flex; align-items: center; justify-content: center; text-align: center; color: #fff; }
.snake-over > div { background: rgba(22,38,58,.85); padding: 20px 26px; border-radius: 12px; display: flex; flex-direction: column; gap: 10px; align-items: center; max-width: 80%; }
.snake-over b { font-size: 20px; }
.snake-over .muted { color: #ccd0d4; font-size: 13px; }
.snake-pad { display: none; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 48px); gap: 6px; justify-content: center; margin-top: 12px; }
.snake-pad button { font-size: 20px; border: 1px solid var(--line); background: #fff; border-radius: 10px; }
.snake-pad [data-dir=up] { grid-column: 2; }
.snake-pad [data-dir=left] { grid-column: 1; grid-row: 2; }
.snake-pad [data-dir=down] { grid-column: 2; grid-row: 2; }
.snake-pad [data-dir=right] { grid-column: 3; grid-row: 2; }
@media (hover: none), (max-width: 800px) { .snake-pad { display: grid; } }

/* судоку */
.sudoku { max-width: 460px; }
.sd-bar { display: flex; gap: 18px; margin-bottom: 10px; flex-wrap: wrap; }
.sd-grid { display: grid; grid-template-columns: repeat(9, 1fr); aspect-ratio: 1; background: #fff; border: 2px solid #3f464d; border-radius: 8px; overflow: hidden; user-select: none; }
.sd-cell { border: 0; border-right: 1px solid #d7dade; border-bottom: 1px solid #d7dade; background: #fff; font: inherit; font-size: clamp(16px, 4.6vw, 24px); color: var(--accent); padding: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; min-width: 0; position: relative; }
.sd-cell:nth-child(9n+3), .sd-cell:nth-child(9n+6) { border-right: 2px solid #3f464d; }
.sd-cell:nth-child(9n) { border-right: 0; }
.sd-cell:nth-child(n+19):nth-child(-n+27), .sd-cell:nth-child(n+46):nth-child(-n+54) { border-bottom: 2px solid #3f464d; }
.sd-cell:nth-child(n+73) { border-bottom: 0; }
.sd-cell.given { color: var(--ink); font-weight: 600; }
.sd-cell.peer { background: #eef0f2; }
.sd-cell.same { background: #dfe3e7; }
.sd-cell.sel { background: #cdd3d9; }
.sd-cell.wrong { color: var(--bad); background: #fde8e6; }
.sd-cell.sel.wrong { background: #f8c9c4; }
.sd-notes { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; height: 100%; padding: 1px; }
.sd-notes i { font-style: normal; font-size: clamp(8px, 1.9vw, 11px); color: var(--muted); display: flex; align-items: center; justify-content: center; line-height: 1; }
.sd-grid.done .sd-cell { background: #e3f4ea; color: var(--ok); }
.sd-tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
.sd-tools .btn { justify-content: center; font-size: 13px; padding: 7px 4px; }
.sd-tools .btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.sd-pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; }
.sd-pad button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 0 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; font: inherit; }
.sd-pad button b { font-size: 22px; color: var(--accent); line-height: 1.1; }
.sd-pad button span { font-size: 10px; color: var(--muted); min-height: 12px; }
.sd-pad button:hover { border-color: var(--accent); }
.sd-pad button.full { opacity: .35; }
@media (max-width: 520px) { .sd-tools { grid-template-columns: repeat(2, 1fr); } }

/* DOOM */
.doom-frame { background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 4 / 3; max-width: 960px; max-height: calc(100vh - 230px); box-shadow: var(--shadow); }
.doom-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.doom-help { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 16px; max-width: 960px; margin-top: 12px; font-size: 13px; }
.doom-keys td { vertical-align: middle; }
.key-btn { min-width: 150px; padding: 6px 12px; border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 7px; background: #f3f4f5; font: inherit; font-weight: 600; cursor: pointer; }
.key-btn:hover { border-color: var(--accent); }
.key-btn.listen { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); animation: keypulse 1s infinite; }
.key-btn.clash { border-color: var(--warn); background: var(--warn-soft); }
@keyframes keypulse { 50% { opacity: .6; } }

/* пасьянс «Паук» в стиле классических игр Windows */
.sp-level-icon { font-size: 20px !important; letter-spacing: 2px; min-width: 70px; }
.xp-window { border: 1px solid #0a246a; border-radius: 8px 8px 4px 4px; overflow: hidden; box-shadow: 0 6px 22px rgba(0,0,0,.25); background: #ece9d8; position: relative; }
.xp-menubar { display: flex; gap: 2px; padding: 3px 6px; background: #ece9d8; border-bottom: 1px solid #aca899; font-family: Tahoma, "Segoe UI", Verdana, sans-serif; font-size: 12px; position: relative; z-index: 5000; }
.xp-menubar > button { border: 1px solid transparent; background: none; padding: 3px 9px; font: inherit; cursor: default; color: #000; border-radius: 2px; }
.xp-menubar > button:hover, .xp-menubar > button.on { background: #316ac5; color: #fff; }
.xp-dropdown { position: absolute; top: 100%; min-width: 220px; background: #fff; border: 1px solid #aca899; box-shadow: 2px 3px 6px rgba(0,0,0,.25); padding: 2px; display: flex; flex-direction: column; animation: xpdrop .12s ease-out; }
.xp-dropdown button { display: flex; align-items: center; border: 0; background: none; font: inherit; text-align: left; padding: 4px 10px 4px 2px; cursor: default; color: #000; }
.xp-dropdown button:hover { background: #316ac5; color: #fff; }
.xp-check { width: 18px; text-align: center; font-weight: 700; }
.xp-key { margin-left: auto; padding-left: 24px; opacity: .75; }
.xp-sep { height: 1px; background: #aca899; margin: 3px 2px; }
@keyframes xpdrop { from { opacity: 0; transform: translateY(-3px); } }
.sp-felt { position: relative; height: max(520px, calc(100vh - 170px)); background: radial-gradient(ellipse at 50% 35%, #0a9b3a 0%, #007a2a 55%, #005c1f 100%); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.sp-slot { position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch); border-radius: calc(var(--cw) * .06); border: 1px solid rgba(0,0,0,.25); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); transition: background .15s, box-shadow .15s; }
.sp-slot.drop-ok { background: rgba(255,240,150,.18); box-shadow: inset 0 0 0 2px #ffe27a; }
.sp-stock-slot { cursor: pointer; z-index: 1; }
.spc { position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch); will-change: transform; transition: transform .32s cubic-bezier(.22,.85,.3,1); perspective: 900px; }
.spc-in { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .34s cubic-bezier(.3,.7,.3,1); }
.spc.up .spc-in { transform: rotateY(180deg); }
.spc img { position: absolute; inset: 0; width: 100%; height: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: calc(var(--cw) * .06); box-shadow: 0 1px 2px rgba(0,0,0,.35); background: #fff; pointer-events: none; }
.spc-front { transform: rotateY(180deg); }
.spc-back { object-fit: fill; }
.spc.movable { cursor: pointer; }
.spc.dragging { transition: none; cursor: grabbing; }
.spc.dragging img { box-shadow: 0 10px 22px rgba(0,0,0,.4); }
.spc.hint img, .spc.hint-target img { box-shadow: 0 0 0 3px #ffd54a, 0 0 16px 3px #ffd54a; transition: box-shadow .2s; }
.spc.shake .spc-in { animation: spshake .32s; }
@keyframes spshake { 20% { transform: rotateY(180deg) translateX(-4px); } 60% { transform: rotateY(180deg) translateX(4px); } }
.sp-felt.no-anim .spc, .sp-felt.no-anim .spc-in { transition: none !important; }
.sp-status { position: absolute; left: 0; top: 0; z-index: 1; min-width: 150px; padding: 8px 18px; text-align: center; font-family: Tahoma, Verdana, sans-serif; font-size: 13px; line-height: 1.5; color: #000; background: #c1d2b3; border: 1px solid #fff; outline: 1px solid #4a6b3a; box-shadow: 1px 1px 0 #000; }
@media (max-width: 800px) { .sp-felt { height: max(420px, calc(100vh - 230px)); } .sp-status { min-width: 110px; font-size: 11px; padding: 4px 10px; } }

/* лаборатория */
.lab-tiles .lab-tile { align-items: flex-start; }
.lab-ico { width: 44px; height: 44px; flex: none; border-radius: 10px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--accent); }
.lab-tile-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.lab-tile-main .badge { align-self: flex-start; margin-top: 3px; }
.lab-tile .st-arrow { align-self: center; }
.lab-add { border-style: dashed; box-shadow: none; background: transparent; }
.lab-add .lab-ico { background: #fff; border: 1px dashed var(--line); font-weight: 700; }
.lab-code { font-weight: 400; font-size: 15px; }
.lab-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lab-actions a.btn, .lab-toolbar a.btn { text-decoration: none; color: inherit; }
.lab-full { font-size: 12px; margin: -6px 0 14px; max-width: 900px; }
.lab-tabs { display: flex; flex-wrap: wrap; gap: 2px 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.lab-tab { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 9px 12px; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; color: var(--muted); white-space: nowrap; margin-bottom: -1px; }
.lab-tab:hover { color: var(--ink); }
.lab-tab.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.lab-count { font-size: 11px; background: var(--line2); color: var(--muted); border-radius: 9px; padding: 0 6px; font-weight: 600; }
.lab-tab.on .lab-count { background: var(--accent-soft); color: var(--accent); }
.lab-search { min-width: 240px; flex: 0 1 340px; }
.lab-wrap { overflow-x: auto; }
.lab-table td { vertical-align: top; }
.lab-row { cursor: pointer; transition: background .15s; }
.lab-row:hover td, .lab-row:focus td { background: #f2f3f5; }
.lab-row:focus { outline: none; }
.lab-row.flash td { background: #fff7d6; }
.lab-seq { font-weight: 700; color: var(--muted); width: 36px; }
.lab-name { min-width: 220px; max-width: 460px; }
.lab-sub { font-size: 12px; margin-top: 2px; }
.lab-sub .chip { font-size: 11px; padding: 0 7px; }
.lab-note { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lab-prot { font-size: 12px; white-space: nowrap; color: var(--muted); }
.due-tip { max-width: 150px; }
.badge.fix { background: #efe7fb; color: #6b3fb3; }
.badge.off { background: var(--line2); color: #8f959b; text-decoration: line-through; }
.due-today { color: var(--accent); font-weight: 700; }
.due-soon { color: var(--warn); font-weight: 600; }
.due-late { color: var(--bad); font-weight: 600; }
.due-tip { font-size: 11px; font-weight: 400; }
.lab-legend { font-size: 12px; margin-top: 8px; }
.lab-legend span { margin-left: 8px; }
.lab-legend span:first-child { margin-left: 0; }
.lab-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.lab-form .lab-wide { grid-column: 1 / -1; }
.lab-form small { font-size: 11px; }
.lab-calc { padding: 7px 9px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-weight: 600; min-height: 34px; }
.lab-calc .muted { font-weight: 400; }
.lab-result { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #f7f8f9; }
.lab-result-h { font-weight: 600; font-size: 13px; margin-bottom: 10px; }
.lab-result .lab-form { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.lab-service { font-size: 12px; }
.lab-import-res { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--ok-soft); display: flex; flex-direction: column; gap: 3px; }
.modal-h h3 .badge { vertical-align: middle; margin-left: 6px; }
@media (max-width: 800px) {
  .lab-search { min-width: 0; flex: 1 1 100%; }
  .lab-name { min-width: 180px; }
  .lab-form, .lab-result .lab-form { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------------ задачи */
.tk-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 6px; }
.tk-col { background: #e5e7ea; border: 1px solid var(--line); border-radius: var(--radius); min-height: 160px; display: flex; flex-direction: column; }
.tk-col.over { background: var(--accent-soft); border-color: var(--accent); }
.tk-col-h { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.tk-col-h b { font-weight: 600; }
.tk-col-h .lab-count { margin-left: auto; background: #fff; }
.tk-cards { display: flex; flex-direction: column; gap: 8px; padding: 10px; min-height: 60px; }
.tk-drop-hint { color: var(--muted); font-size: 12px; text-align: center; padding: 14px 4px; border: 1px dashed var(--line); border-radius: 6px; }
.tk-card { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 6px; padding: 9px 10px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.tk-card:hover { border-color: #b8bcc1; }
.tk-card.dragging { opacity: .45; }
.tk-card.p-high { border-left-color: var(--bad); }
.tk-card.p-normal { border-left-color: var(--plan); }
.tk-card.p-low { border-left-color: var(--line); }
.tk-card.mine { background: #f9fafb; }
.tk-card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11px; }
.tk-card-top:empty { display: none; }
.tk-title { font-weight: 600; line-height: 1.3; }
.tk-link { font-size: 12px; color: var(--accent); display: flex; align-items: center; gap: 6px; background: var(--accent-soft); border-radius: 6px; padding: 3px 7px; }
.tk-card-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.tk-who { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.tk-who span, .tk-card-foot .tk-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-ava { flex: 0 0 22px; height: 22px; border-radius: 50%; background: #dcdfe3; color: var(--accent); font-size: 10px; font-weight: 700; font-style: normal; display: inline-flex; align-items: center; justify-content: center; }
.tk-meta { margin-left: auto; white-space: nowrap; }
.tk-due { white-space: nowrap; }

.tk-detail { display: grid; grid-template-columns: 1fr 260px; gap: 16px; }
.tk-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tk-h { font-weight: 600; }
.tk-side .field span { font-size: 12px; }
.tk-side .tk-service { font-size: 12px; line-height: 1.5; }
.tk-feed { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #f7f8f9; }
.tk-msg { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
.tk-msg.mine { background: var(--accent-soft); border-color: #d3d7db; }
.tk-msg-h { font-size: 12px; margin-bottom: 3px; }
.tk-composer { display: flex; flex-direction: column; gap: 6px; }
.tk-composer-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
@media (max-width: 800px) {
  .tk-detail { grid-template-columns: minmax(0, 1fr); }
  .tk-board { grid-auto-columns: minmax(78vw, 1fr); }
}
.tk-card .tk-link { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* ==================================================================== material design
   Слои состояния (наведение/нажатие), волна нажатия, высоты и движение окон.
   Правила идут последними, поэтому переопределяют базовые стили выше. */

/* фокус клавиатуры виден всегда — требование доступности */
:where(button, a, [tabindex], .input, .cell-in):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- кнопки: форма-«таблетка», слой состояния, тень по высоте --- */
.btn {
  position: relative; overflow: hidden; isolation: isolate;
  min-height: 36px; padding: 8px 16px; border-radius: var(--r-pill);
  font-weight: 500; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn::after {            /* слой состояния: 8 % при наведении, 12 % при нажатии */
  content: ""; position: absolute; inset: 0; z-index: -1; background: currentColor; opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.btn:hover::after { opacity: .08; }
.btn:active { transform: scale(.97); }
.btn:active::after { opacity: .12; }
.btn:disabled { transform: none; }
.btn:disabled::after { opacity: 0; }
.btn.sm { min-height: 28px; padding: 4px 12px; }
.btn.primary { box-shadow: var(--el-1); }
.btn.primary:hover { box-shadow: var(--el-2); }
.btn.primary:active { box-shadow: var(--el-1); }
.x { border-radius: var(--r-pill); width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; position: relative; overflow: hidden; transition: background-color var(--dur) var(--ease); }
.x:hover { background: var(--line2); }

/* --- переключатели, вкладки, поля --- */
.seg { border-radius: var(--r-pill); overflow: hidden; }
.seg button { position: relative; overflow: hidden; transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.seg button:hover { background: var(--line2); }
.lab-tab { position: relative; overflow: hidden; border-radius: var(--r-sm) var(--r-sm) 0 0; transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease); }
.lab-tab:hover { background: var(--line2); }
.input, select.input, textarea.input, .cell-in { border-radius: var(--r-sm); transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.input:focus, .cell-in:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.chip, .chip-btn, .badge { border-radius: var(--r-pill); }

/* --- боковое меню: пункт-«таблетка» со слоем состояния --- */
.nav { position: relative; overflow: hidden; border-radius: var(--r-pill); min-height: 40px; -webkit-tap-highlight-color: transparent;
       transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.nav.active { box-shadow: none; }
.nav:active { background: rgba(255,255,255,.12); }

/* --- поверхности: скругление и высота --- */
.panel, .modal, .kpi, .call-card, .set-tile, .tk-card, .tk-col, .order-card, .lab-tile, .auth-card { border-radius: var(--r-md); }
.set-tile, .order-card, .svc-tile, .lab-tile, .call-card, .tk-card, .cl-item {
  position: relative; overflow: hidden; -webkit-tap-highlight-color: transparent;
  transition: box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.set-tile:hover, .order-card:hover, .svc-tile:hover, .lab-tile:hover, .tk-card:hover { box-shadow: var(--el-2); }
.set-tile:active, .order-card:active, .svc-tile:active, .lab-tile:active, .tk-card:active { transform: scale(.995); box-shadow: var(--el-1); }

/* --- волна нажатия (ripple) --- */
.ripple {
  position: absolute; border-radius: 50%; pointer-events: none; z-index: 0;
  background: currentColor; opacity: .16; transform: scale(0);
  animation: m-ripple 520ms var(--ease-out) forwards;
}
.nav .ripple, .btn.primary .ripple { background: #fff; opacity: .22; }
@keyframes m-ripple { to { transform: scale(2.4); opacity: 0; } }

/* --- раскрытие окон: затемнение и само окно --- */
.modal-bg { background: rgba(20,22,25,.4); animation: m-scrim-in var(--dur) var(--ease-out) both; }
.modal { border-radius: var(--r-dialog); box-shadow: var(--el-4); transform-origin: top center;
         animation: m-dialog-in var(--dur-slow) var(--ease-out) both; }
.modal-bg.closing { animation: m-scrim-out var(--dur) var(--ease-in) both; }
.modal-bg.closing .modal { animation: m-dialog-out var(--dur) var(--ease-in) both; }
@keyframes m-scrim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes m-scrim-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes m-dialog-in { from { opacity: 0; transform: translateY(14px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes m-dialog-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px) scale(.97); } }

/* --- раскрытие строк (вызовы, разделы) --- */
.cr-head { position: relative; overflow: hidden; transition: background-color var(--dur) var(--ease); }
.cr-arrow { transition: transform var(--dur) var(--ease); }
.call-row.open .cr-arrow { transform: rotate(90deg); }
.cr-body { overflow: hidden; }

/* --- всплывающие подсказки --- */
.toast { border-radius: var(--r-sm); box-shadow: var(--el-3); animation: m-toast-in var(--dur) var(--ease-out) both; }
.toast.hide { animation: m-toast-out var(--dur-fast) var(--ease-in) both; }
@keyframes m-toast-in { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes m-toast-out { to { opacity: 0; transform: translateY(8px); } }

/* --- уважаем системную настройку «меньше движения» --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .ripple { display: none; }
  .btn:active, .tk-card:active, .set-tile:active { transform: none; }
}
/* переход между разделами и раскрытие настроек — короткое проявление */
.m-enter { animation: m-fade-through var(--dur-slow) var(--ease-out) both; }
@keyframes m-fade-through { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* кнопка выхода в боковой панели остаётся компактной */
.user-box .btn { margin-left: auto; min-height: 26px; padding: 3px 10px; font-size: 12px; }
/* ссылки, оформленные как кнопки (PDF заявки, выгрузки), не подчёркиваются */
a.btn { text-decoration: none; color: inherit; }
/* настройки → факсограмма: стороны и их бланки */
.fax-role { border: 1px solid var(--line); box-shadow: none; }
.fax-role-h { display: flex; align-items: center; gap: 10px; }
.fax-role-h .badge { margin-left: auto; }
.fax-tpl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
/* поле ввода тянется только по высоте: растягивание вширь ломало разметку раздела */
textarea.input { resize: vertical; max-width: 100%; width: 100%; }
.comp-row textarea, .tk-composer textarea { resize: none; }  /* поля сообщений растут сами по мере набора */

/* надпись всегда по центру кнопки; в боковой панели кнопку не сжимает длинное имя */
.btn { justify-content: center; }
.user-box { gap: 10px; }
.user-box > div { min-width: 0; overflow-wrap: anywhere; }
.user-box .btn { flex: 0 0 auto; }

/* подтверждение рядом с кнопкой */
.popc { position: fixed; z-index: 70; width: 240px; padding: 14px; display: flex; flex-direction: column; gap: 12px;
        background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-md);
        box-shadow: var(--el-3); animation: m-pop-in 160ms var(--ease-out) both; }
.popc-text { font-size: 13px; line-height: 1.35; }
.popc-row { display: flex; gap: 8px; justify-content: flex-end; }
@keyframes m-pop-in { from { opacity: 0; transform: scale(.94) translateY(4px); } to { opacity: 1; transform: none; } }

/* --- иконки разделов и выезжающее меню на узком экране --- */
.ni { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav .nl { min-width: 0; }
.menu-btn, .side-scrim { display: none; }

@media (max-width: 900px) {
  /* боковое меню слева, скрыто; открывается кнопкой с тремя полосками в левом верхнем углу */
  .side { position: fixed; top: 0; bottom: 0; left: 0; width: min(288px, 86vw); height: 100dvh; z-index: 46; overflow-y: auto; overscroll-behavior: contain;
          padding-top: calc(18px + env(safe-area-inset-top)); padding-bottom: calc(14px + env(safe-area-inset-bottom));
          transform: translateX(-102%); visibility: hidden; transition: transform var(--dur-slow) var(--ease), visibility 0s linear var(--dur-slow); }
  .side.open { transform: none; visibility: visible; box-shadow: var(--el-4); transition-delay: 0s; }
  .side-scrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(15,25,40,.45); opacity: 0; pointer-events: none; transition: opacity var(--dur-slow) var(--ease); }
  .side-scrim.open { opacity: 1; pointer-events: auto; }
  .menu-btn { display: flex; align-items: center; justify-content: center; position: fixed; z-index: 44; top: calc(10px + env(safe-area-inset-top)); left: 12px; width: 44px; height: 44px;
              border: 0; border-radius: 50%; background: var(--side); color: #fff; box-shadow: var(--el-2); cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .menu-btn .ni { width: 24px; height: 24px; }
  .menu-btn:active { background: var(--side-active); }
  body.menu-open { overflow: hidden; }
  .user-box { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); white-space: normal; }
  .main, .main.main-chat { padding-top: calc(64px + env(safe-area-inset-top)); }
  .chat { height: calc(100dvh - 64px - 14px - env(safe-area-inset-top)); }
}
@media (prefers-reduced-motion: reduce) { .side, .side-scrim { transition: none; } }

.attach { display: inline-flex; align-items: center; justify-content: center; }
.attach .ni { width: 20px; height: 20px; }

/* длинное содержимое (пункты списков, даты) не должно раздвигать колонки и окна на узких экранах */
.tk-detail > *, .tk-side, .field, .grid2 > *, .grid3 > *, .modal-b > * { min-width: 0; }
select.input, .field .input, input[type="date"].input { max-width: 100%; }
select.input { text-overflow: ellipsis; }
input[type="date"].input { width: 100%; min-width: 0; -webkit-appearance: none; appearance: none; min-height: 36px; }

/* структура подчинения в «Пользователях» */
.org-tree, .org-tree ul { list-style: none; margin: 0; padding-left: 20px; }
.org-tree { padding-left: 0; }
.org-tree li { position: relative; padding: 4px 0 4px 14px; }
.org-tree li::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; border-left: 1px solid var(--line); }
.org-tree li::after { content: ""; position: absolute; left: 0; top: 16px; width: 10px; border-top: 1px solid var(--line); }

.org-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; padding-bottom: 10px; border-bottom: 1px solid var(--line2); }
.org-row .field { min-width: 0; }
.org-act { display: flex; gap: 10px; align-items: center; min-height: 36px; }

/* логотип вместо названия объекта */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.brand { padding: 4px 10px 14px; }
.brand-logo { display: block; height: 30px; width: auto; max-width: 100%; }
.auth-logo { display: block; height: 36px; width: auto; max-width: 100%; margin: 2px 0 10px; }

/* ответ на сообщение и «печатает…» */
.msg-reply { display: inline-flex; align-items: center; }
.msg-reply .ni { width: 18px; height: 18px; }
.msg-reply:hover { color: var(--accent); }
.msg-quote { display: flex; flex-direction: column; gap: 1px; margin: 0 0 4px; padding: 3px 8px; border-left: 3px solid var(--accent); background: rgba(63,70,77,.08); border-radius: 4px; cursor: pointer; font-size: 12px; min-width: 0; }
.msg-quote b { font-weight: 600; color: var(--accent); }
.msg-quote span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
.msg.flash .bubble { animation: msg-flash 1.4s var(--ease) 1; }
@keyframes msg-flash { 0%, 40% { box-shadow: 0 0 0 3px rgba(63,70,77,.35); } 100% { box-shadow: none; } }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin-bottom: 6px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 6px; font-size: 13px; }
.reply-bar .rb-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.reply-bar .rb-text span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar .rb-x { border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.typing-text { font-style: italic; color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .msg.flash .bubble { animation: none; } }
/* на сенсорных экранах наведения нет: кнопки действий всегда видны, но приглушены */
@media (hover: none) { .msg-del { opacity: .55; } }
@media (hover: none) { .msg-reply { min-width: 38px; min-height: 34px; justify-content: center; } }
