/* MechaCRM — интерфейс без внешних зависимостей */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --line: #e3e6eb;
  --line-strong: #cfd4dc;
  --text: #1b1f27;
  --muted: #667085;
  --brand: #1f5eff;
  --brand-ink: #ffffff;
  --brand-soft: #e8efff;
  --ok: #138a4b;
  --ok-soft: #e3f5ea;
  --warn: #b25e00;
  --warn-soft: #fff2dd;
  --bad: #c62828;
  --bad-soft: #fde8e8;
  --side: #141922;
  --side-text: #c4cad6;
  --side-active: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
small, .muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .92em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.pre { white-space: pre-wrap; }
.strong { font-weight: 600; }
.text-ok { color: var(--ok); }
.text-bad { color: var(--bad); }
.text-warn { color: var(--warn); }

/* ---------- каркас ---------- */
.app { display: flex; min-height: 100vh; }
.side {
  width: 236px; flex: 0 0 236px; background: var(--side); color: var(--side-text);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 14px 10px 24px;
}
.side .logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 1.05rem; padding: 6px 10px 16px; }
.side .logo .mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; font-size: .85rem; }
.side .grp { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #7d8697; padding: 14px 10px 6px; }
.side a { display: flex; align-items: center; gap: 10px; color: var(--side-text); padding: 8px 10px; border-radius: 8px; font-size: .94rem; }
.side a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.side a.active { background: rgba(255, 255, 255, .1); color: var(--side-active); }
.side a .ico { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; }
.side a .count { margin-left: auto; background: var(--bad); color: #fff; font-size: .72rem; border-radius: 99px; padding: 1px 7px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.top form.search { flex: 1; max-width: 520px; }
.top form.search input { width: 100%; }
.top .burger { display: none; }
.top .spacer { flex: 1; }
.page { padding: 20px; max-width: 1400px; width: 100%; }

.page-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 991px) {
  .side { position: fixed; left: -260px; z-index: 50; transition: left .2s; box-shadow: 0 0 30px rgba(0,0,0,.3); }
  body.nav-open .side { left: 0; }
  body.nav-open .shade { display: block; }
  .shade { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  .top .burger { display: inline-flex; }
  .top { padding: 8px 12px; }
  .page { padding: 14px 12px 40px; }
  .top .uname { display: none; }
}

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer;
  white-space: nowrap; line-height: 1.2;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(.95); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); border-color: #f0b8b8; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: .88rem; }
.btn.xs { min-height: 26px; padding: 2px 8px; font-size: .82rem; }
.btn.block { width: 100%; }
.btn .ico { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- карточки и сетки ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.card > .hd { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card > .hd h2, .card > .hd h3 { margin: 0; font-size: 1rem; }
.card > .hd .actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.card > .bd { padding: 16px; }
.card > .bd.flush { padding: 0; }
.card > .ft { padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .lbl { color: var(--muted); font-size: .85rem; }
.stat .val { font-size: 1.45rem; font-weight: 700; margin-top: 2px; }
a.stat:hover { text-decoration: none; border-color: var(--brand); }

dl.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) { dl.kv { grid-template-columns: 1fr; } dl.kv dt { margin-top: 6px; } }

/* ---------- формы ---------- */
label { display: block; font-size: .88rem; font-weight: 500; margin-bottom: 4px; color: #344054; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local],
input[type=tel], input[type=search], input[type=color], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff;
  font: inherit; color: var(--text); min-height: 38px;
}
input[type=color] { padding: 3px; width: 60px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.field { margin-bottom: 12px; }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: 18px; height: 18px; }
.inline-form { display: inline; }
.req::after { content: " *"; color: var(--bad); }
input.num { text-align: right; }
.input-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.input-row > * { flex: 1 1 120px; }
.input-row > .shrink { flex: 0 0 auto; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.t th { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; background: var(--surface-2); white-space: nowrap; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: #fafbfc; }
table.t td.num, table.t th.num { text-align: right; white-space: nowrap; }
table.t tfoot td { font-weight: 600; background: var(--surface-2); }
table.t tr.dim td { color: var(--muted); }
table.t tr.dim td s { color: var(--muted); }
table.t .actions { white-space: nowrap; text-align: right; }
tr.link { cursor: pointer; }

/* ---------- бейджи, алерты ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: #eef0f3; color: #344054; white-space: nowrap; }
.badge.st { color: #fff; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--brand-soft); color: var(--brand); }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.alert.success { background: var(--ok-soft); border-color: #b7e4c7; color: #0d5c33; }
.alert.error { background: var(--bad-soft); border-color: #f4b6b6; color: #8a1c1c; }
.alert.warn { background: var(--warn-soft); border-color: #f4d29c; color: #7a4100; }
.alert.info { background: var(--brand-soft); border-color: #c4d4ff; color: #173fa8; }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* ---------- вкладки ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a, .tabs button {
  padding: 9px 14px; border: 0; background: none; font: inherit; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px;
}
.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }
.tabs .active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tabs .cnt { font-size: .75rem; background: #eef0f3; border-radius: 99px; padding: 0 6px; margin-left: 4px; color: var(--muted); }

/* ---------- фильтры и пагинация ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 14px; }
.filters .f { flex: 1 1 160px; max-width: 260px; }
.filters .f.wide { max-width: 380px; flex-basis: 240px; }
.filters label { font-size: .78rem; color: var(--muted); }
.pager { display: flex; gap: 4px; justify-content: center; padding: 14px; flex-wrap: wrap; }
.pager a, .pager span { padding: 5px 11px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); }
.pager .cur { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- галерея и загрузка ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.tile .media { display: block; aspect-ratio: 4 / 3; background: #1b1f27; cursor: zoom-in; }
.tile .media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .media.video, .tile .media.file { display: grid; place-items: center; color: #fff; font-size: .85rem; text-align: center; padding: 8px; cursor: pointer; }
.tile .media.file { background: #475467; }
.tile .meta { padding: 6px 8px; font-size: .78rem; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.tile .meta .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.tile .tag { position: absolute; top: 6px; left: 6px; }
.tile .play { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.2); display: grid; place-items: center; margin: 0 auto 6px; }

.drop {
  border: 2px dashed var(--line-strong); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted);
  background: var(--surface-2); margin-bottom: 14px;
}
.drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop .btn-row { justify-content: center; margin-top: 8px; }
.progress { height: 6px; background: #e4e7ec; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: var(--brand); width: 0; transition: width .15s; }
.up-item { font-size: .85rem; text-align: left; margin-top: 8px; }

/* ---------- просмотр ---------- */
.viewer { position: fixed; inset: 0; background: rgba(10, 12, 16, .92); z-index: 100; display: none; align-items: center; justify-content: center; }
.viewer.open { display: flex; }
.viewer img, .viewer video { max-width: 96vw; max-height: 86vh; border-radius: 6px; }
.viewer .vbar { position: absolute; top: 0; left: 0; right: 0; display: flex; gap: 8px; padding: 10px; justify-content: flex-end; }
.viewer .vbar .btn { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; }
.viewer .nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); border: 0; color: #fff; font-size: 28px; width: 48px; height: 64px; border-radius: 8px; cursor: pointer; }
.viewer .prev { left: 10px; } .viewer .next { right: 10px; }
.viewer .cap { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; color: #d0d5dd; font-size: .9rem; }

/* ---------- модальные окна ---------- */
dialog.modal { border: 0; border-radius: 12px; padding: 0; width: min(560px, 94vw); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog.modal::backdrop { background: rgba(16, 24, 40, .45); }
dialog.modal .hd { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
dialog.modal .hd h3 { margin: 0; }
dialog.modal .hd .x { margin-left: auto; }
dialog.modal .bd { padding: 18px; max-height: 70vh; overflow-y: auto; }
dialog.modal .ft { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); }

/* ---------- автодополнение ---------- */
.ac { position: relative; }
.ac-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin-top: 2px; background: #fff; border: 1px solid var(--line-strong);
  border-radius: 8px; box-shadow: 0 10px 24px rgba(16,24,40,.14); max-height: 320px; overflow-y: auto;
}
.ac-list .opt { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.ac-list .opt:last-child { border-bottom: 0; }
.ac-list .opt.on, .ac-list .opt:hover { background: var(--brand-soft); }
.ac-list .opt .s { font-size: .8rem; color: var(--muted); }
.ac-list .none { padding: 10px; color: var(--muted); }
.picked { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-2); }
.picked .grow { flex: 1; min-width: 0; }

/* ---------- лента статусов ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--dot, var(--brand)); border: 2px solid #fff; }
.timeline .when { font-size: .8rem; color: var(--muted); }

.status-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.status-pick button { border: 1px solid var(--line-strong); background: #fff; border-radius: 99px; padding: 5px 12px; cursor: pointer; font: inherit; font-size: .88rem; display: inline-flex; gap: 6px; align-items: center; }
.status-pick button .dot { width: 9px; height: 9px; border-radius: 50%; }
.status-pick button.cur { border-color: var(--text); font-weight: 600; }

/* ---------- подпись ---------- */
.sigpad { border: 2px dashed var(--line-strong); border-radius: 10px; background: #fff; touch-action: none; width: 100%; height: 260px; display: block; }

/* ---------- вход ---------- */
.auth-box { max-width: 400px; margin: 8vh auto; padding: 0 14px; }
.auth-box .brand { text-align: center; margin-bottom: 18px; font-size: 1.3rem; font-weight: 700; }
.install { max-width: 860px; margin: 30px auto; padding: 0 14px; }

.lang-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.lang-switch button { border: 0; background: #fff; padding: 6px 10px; cursor: pointer; font: inherit; font-size: .85rem; }
.lang-switch button.on { background: var(--text); color: #fff; }

.dropdown { position: relative; }
.dropdown .menu { position: absolute; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 24px rgba(16,24,40,.14); min-width: 200px; display: none; z-index: 40; padding: 6px; }
.dropdown.open .menu { display: block; }
.dropdown .menu a, .dropdown .menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; }
.dropdown .menu a:hover, .dropdown .menu button:hover { background: var(--surface-2); text-decoration: none; }

.money-box { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.money-box .lbl { color: var(--muted); }
.money-box .v { text-align: right; font-variant-numeric: tabular-nums; }
.money-box .total { font-weight: 700; font-size: 1.1rem; border-top: 1px solid var(--line); padding-top: 6px; }
.money-box .debt { color: var(--bad); font-weight: 700; }

.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; }

@media print {
  .side, .top, .no-print { display: none !important; }
  body { background: #fff; }
}

/* защита от горизонтальной прокрутки на телефоне */
.main, .page, .card, .split > *, .grid > * { min-width: 0; }
@media (max-width: 600px) {
  .page-head .actions { margin-left: 0; }
  .top form.search input { min-width: 0; }
  dialog.modal { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 14px 14px 0 0; }
}
.card > .bd.flush { overflow-x: auto; }
.filters .btn { flex: 0 0 auto; }
@media (max-width: 600px) { .filters .f, .filters .f.wide { max-width: none; flex-basis: 100%; } }

/* ---------- календарь записей ---------- */
.cal-bar { align-items: center; }
.cal-legend { display: flex; gap: 6px; flex-wrap: wrap; margin: -4px 0 12px; }
.cal-legend .ev { position: static; padding: 2px 8px; font-size: .78rem; border-radius: 6px; }
.cal-scroll { overflow-x: auto; }
.cal { display: grid; grid-template-columns: 56px repeat(var(--cols), minmax(120px, 1fr)); min-width: calc(56px + var(--cols) * 120px); }
.cal-corner, .cal-dh { position: sticky; top: 0; z-index: 3; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.cal-dh { padding: 8px 6px; text-align: center; color: var(--text); font-size: .88rem; border-left: 1px solid var(--line); }
.cal-dh:hover { text-decoration: none; background: var(--brand-soft); }
.cal-dh span { color: var(--muted); }
.cal-dh.today { background: var(--brand-soft); color: var(--brand); }
.cal-dh .badge { margin-left: 4px; font-size: .7rem; padding: 0 6px; }
.cal-times > div { height: var(--hpx); font-size: .75rem; color: var(--muted); text-align: right; padding: 2px 6px 0 0; border-top: 1px solid var(--line); }
.cal-col { position: relative; height: calc(var(--hpx) * var(--hours)); border-left: 1px solid var(--line);
  background-image: repeating-linear-gradient(to bottom, var(--line) 0, var(--line) 1px, transparent 1px, transparent calc(var(--hpx) / 2)); }
.cal-col.past { background-color: #fafafb; }
.cal-col.today { background-color: #f7f9ff; }
.cal-col[data-click] { cursor: copy; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--bad); z-index: 2; }
.cal-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.cal-ghost { position: absolute; left: 2px; right: 2px; background: var(--brand-soft); border: 1px dashed var(--brand); border-radius: 6px; font-size: .75rem; color: var(--brand); padding: 2px 6px; pointer-events: none; z-index: 1; }
.ev { position: absolute; z-index: 2; overflow: hidden; border-radius: 6px; padding: 3px 6px; font-size: .78rem; line-height: 1.25;
  color: #10213f; background: #dbe6ff; border-left: 3px solid var(--brand); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.ev:hover { text-decoration: none; filter: brightness(.97); z-index: 4; }
.ev b { font-weight: 700; }
.ev .ev-sub { display: block; color: #475467; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-k-repair { background: #ffe9cc; border-left-color: #d97706; color: #4a2a00; }
.ev-k-other { background: #ece6ff; border-left-color: #7c3aed; color: #2e1065; }
.ev-done { background: #dff3e6 !important; border-left-color: var(--ok) !important; color: #0d4a2b !important; }
.ev-cancelled { background: #eef0f3 !important; border-left-color: #98a2b3 !important; color: #667085 !important; text-decoration: line-through; }
.ev-failed { background: #fde3e3 !important; border-left-color: var(--bad) !important; color: #7a1717 !important; }

.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cm-head { padding: 8px; font-size: .8rem; color: var(--muted); text-align: center; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.cm-day { position: relative; min-height: 110px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; }
.cm-day:nth-child(7n) { border-right: 0; }
.cm-day.other { background: #fafafb; }
.cm-day.other .cm-num { color: #b0b6c1; }
.cm-day.today { background: #f2f6ff; }
.cm-num { display: inline-block; font-weight: 600; color: var(--text); padding: 0 4px; border-radius: 4px; }
.cm-day.today .cm-num { background: var(--brand); color: #fff; }
.cm-ev { position: static; display: block; margin-top: 3px; white-space: nowrap; text-overflow: ellipsis; }
.cm-more { display: block; font-size: .75rem; margin-top: 2px; }
.cm-add { position: absolute; top: 3px; right: 5px; color: var(--muted); font-size: 1.1rem; line-height: 1; opacity: 0; }
.cm-day:hover .cm-add { opacity: 1; }
@media (max-width: 700px) { .cm-day { min-height: 70px; } .cm-ev { font-size: .68rem; padding: 1px 3px; } .cm-ev b { display: none; } }

/* ---------- база знаний ---------- */
.kb-list { display: grid; gap: 12px; }
.kb-item { display: block; color: var(--text); margin: 0; }
.kb-item:hover { text-decoration: none; border-color: var(--brand); }
.kb-title { font-weight: 600; font-size: 1.05rem; margin-bottom: 4px; }
.kb-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: .82rem; margin-bottom: 6px; }
.kb-excerpt { color: var(--muted); font-size: .9rem; }
.kb-tags { margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; font-size: .82rem; color: var(--brand); }
.kb-body { font-size: 1rem; line-height: 1.6; overflow-wrap: anywhere; }
.kb-body h2 { font-size: 1.25rem; margin-top: 1.2em; } .kb-body h3 { font-size: 1.1rem; margin-top: 1em; } .kb-body h4 { font-size: 1rem; }
.kb-body h2:first-child, .kb-body h3:first-child { margin-top: 0; }
.kb-body ul, .kb-body ol { padding-left: 1.4em; margin: 0 0 .8em; }
.kb-body blockquote { margin: 0 0 .8em; padding: 8px 14px; border-left: 3px solid var(--line-strong); background: var(--surface-2); color: #344054; }
.kb-body code { font-family: var(--mono); font-size: .9em; background: #f0f2f5; padding: 1px 5px; border-radius: 4px; }
.kb-code { background: #1b1f27; color: #e6e8ec; padding: 12px 14px; border-radius: 8px; overflow-x: auto; }
.kb-code code { background: none; color: inherit; padding: 0; }
.kb-warn { background: var(--warn-soft); border: 1px solid #f4d29c; color: #7a4100; padding: 8px 12px; border-radius: 8px; margin: 0 0 .8em; }
.kb-img { max-width: 100%; max-height: 420px; border-radius: 8px; border: 1px solid var(--line); margin: 4px 0; cursor: zoom-in; }
.kb-toolbar { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }

/* ---------- задачи ---------- */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-i { margin: 0; cursor: pointer; }
.seg-i input { position: absolute; opacity: 0; pointer-events: none; }
.seg-i span { display: inline-block; padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; font-weight: 500; }
.seg-i input:checked + span { background: var(--text); color: #fff; border-color: var(--text); }
.seg-i.seg-urgent input:checked + span { background: var(--bad); border-color: var(--bad); }
.seg-i.seg-later input:checked + span { background: #475467; border-color: #475467; }
.seg-i input:focus-visible + span { outline: 2px solid var(--brand); }

.tk { display: block; font-size: .78rem; padding: 2px 6px; border-radius: 5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: #eef2ff; color: #1e2a55; border-left: 3px solid var(--brand); }
.tk:hover { text-decoration: none; filter: brightness(.96); }
.cal-legend .tk { display: inline-block; margin: 0; }
.tk-urgent { background: #fde3e3; color: #6b1212; border-left-color: var(--bad); }
.tk-later { background: #eef0f3; color: #475467; border-left-color: #98a2b3; }
.tk-s-done { background: #dff3e6 !important; color: #0d4a2b !important; border-left-color: var(--ok) !important; text-decoration: line-through; }
.tk-s-cancelled { opacity: .55; text-decoration: line-through; }
.tk-week { display: grid; grid-template-columns: repeat(7, minmax(130px, 1fr)); min-width: 910px; }
.tk-day { border-left: 1px solid var(--line); min-height: 320px; padding: 0 6px 10px; }
.tk-day:first-child { border-left: 0; }
.tk-day.today { background: #f7f9ff; }
.tk-dh { position: sticky; top: 0; padding: 8px 0; font-size: .88rem; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: flex; gap: 4px; align-items: center; }
.tk-dh span { color: var(--muted); }
.tk-day.today .tk-dh b { color: var(--brand); }
.tk-add { margin-left: auto; color: var(--muted); font-size: 1.1rem; line-height: 1; padding: 0 4px; }
.tk-card { display: block; overflow-wrap: anywhere; font-size: .83rem; padding: 6px 8px; border-radius: 7px; margin-bottom: 6px; background: #eef2ff; color: #1e2a55; border-left: 3px solid var(--brand); }
.tk-card:hover { text-decoration: none; filter: brightness(.97); }
.tk-card.tk-urgent { background: #fde3e3; color: #6b1212; border-left-color: var(--bad); }
.tk-card.tk-later { background: #eef0f3; color: #475467; border-left-color: #98a2b3; }
.tk-sub { display: block; font-size: .74rem; opacity: .8; margin-top: 2px; }
.tk-empty { color: #c0c5ce; text-align: center; padding-top: 20px; }
.tk-nodate { display: flex; flex-wrap: wrap; gap: 6px; }
.tk-nodate .tk { margin: 0; max-width: 320px; }
.tk-year { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1100px) { .tk-year { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .tk-year { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .tk-year { grid-template-columns: minmax(0, 1fr); } }
.tk-mon { margin: 0; padding: 10px; }
.tk-mon-h { display: block; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.tk-mini { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: .78rem; }
.tk-mini .h { color: var(--muted); font-size: .7rem; }
.tk-mini .d { padding: 3px 0; border-radius: 5px; color: #667085; }
.tk-mini .d.today { outline: 1.5px solid var(--brand); }
.tk-mini a.d { font-weight: 700; color: #fff; }
.tk-mini a.d:hover { text-decoration: none; filter: brightness(.9); }
.tk-mini .d.open { background: var(--brand); }
.tk-mini .d.urg { background: var(--bad); }
.tk-mini .d.done { background: var(--ok); }
.side .side-sep { height: 1px; background: rgba(255,255,255,.1); margin: 12px 10px; }
