/* Компоненты Centurion CRM. Цвета, скругления, тени — только токены из tokens.css. */

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 700; }
h1 { font-size: 22px; letter-spacing: -.01em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 .8em; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: var(--radius-sm); }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- каркас ---- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--nav-bg); color: var(--nav-text); border-right: 1px solid var(--nav-border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: var(--nav-text-active); font-weight: 800; letter-spacing: .02em; }
.sidebar .brand img { height: 28px; width: auto; }
.sidebar .brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: 15px; }
.sidebar .brand small { display: block; font-weight: 500; font-size: 11px; color: var(--nav-text); letter-spacing: 0; }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-group { margin: 14px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--nav-text); opacity: .7; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--nav-text); font-weight: 500; }
.nav a:hover { color: var(--nav-text-active); background: var(--nav-active-bg); }
.nav a.active { color: var(--nav-text-active); background: var(--nav-active-bg); }
.nav a.active .icon { color: var(--accent); }
.sidebar-foot { padding: 12px 18px; font-size: 12px; border-top: 1px solid var(--nav-active-bg); }
.sidebar-foot a { color: var(--nav-text); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--border); }
.topbar .burger { display: none; }
.search { flex: 1; max-width: 520px; position: relative; }
.search input[type=search] { width: 100%; padding: 8px 12px 8px 36px; border: 1px solid var(--border); border-radius: var(--radius-btn); background: var(--surface); color: var(--text); font: inherit; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar .spacer { flex: 1; }
.content { padding: 22px 24px 40px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 700; color: var(--eyebrow); margin: 0 0 4px; }

/* ---- элементы ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-btn); border: 1px solid transparent; font: inherit; font-weight: 700; cursor: pointer; background: var(--accent); color: var(--on-accent); transition: background-color .15s, border-color .15s, transform .15s; white-space: nowrap; }
.btn:hover { background: var(--accent-hover); color: var(--on-accent); transform: translateY(-1px); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn.ghost:hover { border-color: var(--text); background: transparent; color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); color: #fff; }
.btn.success:hover { background: color-mix(in srgb, var(--success) 85%, black); color: #fff; }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: var(--radius-sm); display: inline-flex; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=tel], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
select[multiple] { min-height: 90px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-weight: 600; font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
.field-error, .error { color: var(--danger); font-size: 12px; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 16px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-card); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.panel-body { padding: 16px 18px; }
.panel + .panel { margin-top: 16px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge.pill { background: var(--pill-bg); color: var(--pill-text); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; flex: none; letter-spacing: .02em; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.av-0 { background: #5b6bd6; } .av-1 { background: #2e8b6e; } .av-2 { background: #c2552f; } .av-3 { background: #8a55c9; }
.av-4 { background: #b8860b; } .av-5 { background: #3a7ca5; } .av-6 { background: #b03a5b; } .av-7 { background: #5f6b2e; }
.person { display: inline-flex; align-items: center; gap: 8px; }

/* таблица */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-hover); }
.table .title-cell a { color: var(--text); font-weight: 600; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 150px; }
.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 12px 14px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 9px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-btn); padding: 3px; gap: 2px; }
.segmented a { padding: 5px 12px; border-radius: var(--radius-btn); color: var(--muted); font-weight: 600; font-size: 13px; }
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .empty-mark { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.empty .empty-mark .icon { width: 26px; height: 26px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--success-soft); color: var(--success); margin-bottom: 6px; }
.messages li.error { background: var(--danger-soft); color: var(--danger); }

/* ---- карточка записи ---- */
.record { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.record-head { margin-bottom: 14px; }
.record-head h1 { margin-bottom: 6px; }
.record-meta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 13px; }
.stagebar { display: flex; gap: 3px; margin: 14px 0 16px; overflow-x: auto; padding-bottom: 2px; }
.stagebar button { flex: 1 0 auto; min-width: 92px; border: 0; padding: 8px 10px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; background: var(--surface-2); color: var(--muted); border-radius: 4px; text-align: center; white-space: nowrap; }
.stagebar button:first-child { border-radius: var(--radius-btn) 4px 4px var(--radius-btn); }
.stagebar button:last-child { border-radius: 4px var(--radius-btn) var(--radius-btn) 4px; }
.stagebar button.done { background: color-mix(in srgb, var(--stage) 22%, var(--surface)); color: var(--text); }
.stagebar button.current { background: var(--stage); color: #fff; }
.stagebar button:hover:not(.current) { outline: 1px solid var(--stage); }
.stage-final { display: flex; gap: 6px; }
.fields { display: grid; grid-template-columns: 200px 1fr; gap: 8px 16px; }
.fields dt { color: var(--muted); font-size: 13px; }
.fields dd { margin: 0; word-break: break-word; }
.section-title { margin: 0 0 10px; }
.related-list { list-style: none; margin: 0; padding: 0; }
.related-list li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 8px; }
.related-list li:last-child { border-bottom: 0; }

/* лента */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.tl-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.tl-icon .icon { width: 15px; height: 15px; }
.tl-icon.call { background: var(--success-soft); color: var(--success); }
.tl-icon.missed { background: var(--danger-soft); color: var(--danger); }
.tl-icon.system { background: var(--accent-soft); color: var(--accent); }
.tl-head { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.tl-text { white-space: pre-wrap; word-break: break-word; }
.comment-form textarea { min-height: 64px; resize: vertical; margin-bottom: 8px; }

/* задачи */
.task-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.task-row:last-child { border-bottom: 0; }
.task-check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong); background: none; cursor: pointer; flex: none; margin-top: 1px; display: grid; place-items: center; color: transparent; }
.task-check:hover { border-color: var(--success); color: var(--success); }
.task-done .task-check { background: var(--success); border-color: var(--success); color: #fff; }
.task-done .task-title { text-decoration: line-through; color: var(--muted); }
.overdue { color: var(--danger); font-weight: 600; }

/* ---- канбан ---- */
.board { display: flex; gap: 10px; overflow-x: auto; align-items: flex-start; padding-bottom: 12px; min-height: calc(100vh - 210px); }
.column { flex: 0 0 272px; background: var(--surface-2); border-radius: var(--radius-md); display: flex; flex-direction: column; max-height: calc(100vh - 200px); }
.column.over { outline: 2px dashed var(--accent); }
.column header { padding: 10px 12px; border-top: 3px solid; border-radius: var(--radius-md) var(--radius-md) 0 0; background: var(--surface); }
.column .name { font-weight: 700; }
.column .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.cards { padding: 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 60px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; box-shadow: var(--shadow-card); cursor: grab; }
.card.dragging { opacity: .4; }
.card .title { font-weight: 600; color: var(--text); display: block; }
.card .contact { color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.card .kv { font-size: 12px; color: var(--muted); margin-top: 4px; }
.card .kv span { color: var(--text-2); }
.card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12px; }
.call-btn { background: none; border: 0; cursor: pointer; padding: 2px; color: var(--muted); display: inline-flex; }
.call-btn:hover { color: var(--accent); }
.call-btn .icon { width: 14px; height: 14px; }
.call-btn:disabled { opacity: .4; }

/* ---- окно ---- */
.modal { position: fixed; inset: 0; background: rgba(10, 12, 16, .5); display: flex; align-items: center; justify-content: center; z-index: 900; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--surface); color: var(--text); border-radius: var(--radius-lg); padding: 22px 24px; width: 460px; max-width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: var(--shadow-pop); }
.modal-box h2 { margin: 0 0 6px; }
.modal-form .field { display: block; margin: 12px 0; }
.modal-form .field > span { display: block; font-weight: 600; margin-bottom: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* меню */
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-pop); padding: 6px; z-index: 100; }
.menu-pop[hidden] { display: none; }
.menu-pop a, .menu-pop button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); }
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.menu-pop .menu-label { padding: 6px 10px 2px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.theme-option.active { color: var(--accent); font-weight: 700; }

/* вход */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.auth-box { width: 380px; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow-card); }
.auth-box h1 { margin-bottom: 18px; }
.auth-box .btn { width: 100%; margin-top: 6px; }
.auth-shape { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 800; font-size: 20px; margin-bottom: 16px; }

/* ---- конструктор карточки ---- */
.constructor { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; align-items: start; }
.cs-section { background: var(--surface-2); border-radius: var(--radius-md); padding: 10px; min-height: 80px; }
.cs-section.over { outline: 2px dashed var(--accent); }
.cs-section h3 { padding: 4px 6px 8px; display: flex; justify-content: space-between; }
.cs-field { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 6px; cursor: grab; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.cs-field.dragging { opacity: .4; }
.cs-field .badge { font-weight: 500; }

/* ---- адаптив ---- */
@media (max-width: 1100px) {
  .record { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 200; transform: translateX(-100%); transition: transform .2s; }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-pop); }
  .topbar { padding: 10px 16px; }
  .topbar .burger { display: inline-flex; }
  .topbar .label { display: none; }
  .search { min-width: 0; }
  .content { padding: 16px; }
  .fields { grid-template-columns: 1fr; gap: 2px 0; }
  .fields dd { margin-bottom: 8px; }
  .column { flex-basis: 84vw; }
}
.lookup { position: relative; }
.lookup-pop { left: 0; right: 0; max-height: 260px; overflow-y: auto; }
ul.errorlist { list-style: none; padding: 0; margin: 4px 0 0; color: var(--danger); font-size: 12px; }
label.field ul { list-style: none; padding: 0; margin: 0; columns: 2; }
label.field ul label { font-weight: 400; }
.table select { min-width: 168px; padding: 5px 6px; }
.bell { position: relative; }
.bell-count { position: absolute; top: 0; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 10px; font-weight: 700; display: grid; place-items: center; }
/* чаты */
.chat-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr) 260px; gap: 12px; height: calc(100vh - 110px); }
.chat-list { overflow-y: auto; }
.chat-list .related-list li { padding: 8px 14px; }
.chat-list .chat-active { background: var(--accent-soft); }
.chat-main { display: flex; flex-direction: column; min-height: 0; }
.chat-messages { flex: 1; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.msg { max-width: 72%; padding: 8px 12px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--border); align-self: flex-start; }
.msg-out { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.msg-text { white-space: pre-wrap; word-break: break-word; }
.msg-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.chat-send { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-send textarea { flex: 1; resize: vertical; }
.chat-send select { width: 150px; }
.chat-side { overflow-y: auto; }
@media (max-width: 1100px) { .chat-layout { grid-template-columns: 260px 1fr; } .chat-side { display: none; } }
@media (max-width: 860px) { .chat-layout { grid-template-columns: 1fr; height: auto; } .chat-main { min-height: 70vh; } }
.chat-list .segmented { flex-wrap: wrap; }
/* отчёты */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat-row > .panel + .panel { margin-top: 0; }
.filters input[type="checkbox"] { min-width: 0; width: auto; }
.filters .check { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.stat { padding: 14px 16px; }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.report-table th.num, .report-table td.num { text-align: right; white-space: nowrap; }
.report-table th { white-space: normal; }
@media (max-width: 1100px) { .bar-track { display: none; } }
.report-table .sub-row td { color: var(--text-2); font-size: 13px; }
.bar-cell { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar-track { display: inline-block; width: 64px; flex: none; }
.bar { display: block; height: 10px; background: var(--chart-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-value { min-width: 54px; text-align: right; }

/* Окно чатов: переключатель «Все / Общие / Мои личные» */
.chat-modes { gap: 8px; }
.chat-modes .segmented { flex: 1; }
.steps { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 10px; }

/* Почта */
.mail-thread { display: grid; gap: 12px; align-content: start; }
.mail-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface); }
.mail-item.out { background: var(--surface-2); }
.mail-item header { margin-bottom: 8px; overflow: hidden; }
.mail-body { white-space: normal; overflow-wrap: anywhere; line-height: 1.5; }
.chat-list .segmented { display: flex; width: 100%; }
.chat-list .segmented a { flex: 1 1 auto; text-align: center; padding: 5px 8px; white-space: nowrap; }
.mail-layout { grid-template-columns: 340px minmax(0, 1fr); }
@media (max-width: 1100px) { .mail-layout { grid-template-columns: 300px minmax(0, 1fr); } }
@media (max-width: 860px) { .mail-layout { grid-template-columns: 1fr; } }
.board-more { display: block; text-align: center; padding: 8px; font-size: 13px; color: var(--muted); }
.board-more:hover { color: var(--accent); }

/* Юрпрактика: предпросмотр документа как на листе */
.doc-preview { font-family: "Times New Roman", Georgia, serif; font-size: 16px; line-height: 1.5; color: var(--text); max-width: 760px; }
.doc-preview .doc-header { margin: 0 0 2px 45%; }
.doc-preview .doc-title { text-align: center; font-size: 18px; margin: 22px 0 2px; letter-spacing: .02em; }
.doc-preview .doc-subtitle { text-align: center; margin: 0 0 14px; }
.doc-preview .doc-heading { text-align: center; font-size: 16px; margin: 16px 0 6px; }
.doc-preview .doc-para, .doc-preview .doc-bullet { text-align: justify; text-indent: 2em; margin: 0 0 6px; }
.doc-preview .doc-bullet::before { content: "– "; }
.doc-preview .cite { font-size: 14px; }
.doc-preview mark { background: var(--warning-soft); color: var(--warning); padding: 0 2px; border-radius: 3px; }

/* Календарь записей (лиды) */
.calendar-head { flex-wrap: wrap; gap: 8px; }
.calendar-nav { display: flex; align-items: center; gap: 8px; }
.calendar-nav h2 { margin: 0; min-width: 150px; text-align: center; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); }
.calendar-weekday { padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); }
.calendar-day { min-height: 112px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day.other { background: var(--surface-2); }
.calendar-day.other .calendar-date { color: var(--muted); }
.calendar-day.today .calendar-date span:first-child { background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 0 7px; }
.calendar-date { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; }
.calendar-count { font-size: 11px; color: var(--muted); font-weight: 500; }
.calendar-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text); padding: 2px 4px; border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.calendar-item:hover { background: var(--accent-soft); }
.calendar-item .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.calendar-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-more { font-size: 12px; color: var(--muted); padding: 0 4px; }
@media (max-width: 560px) {
  .calendar-day { min-height: 64px; padding: 4px; }
  .calendar-item-title { display: none; }
  .calendar-item { padding: 0; background: none; }
}
.overdue-people { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* Графики отчётов */
.chart-controls { flex-wrap: wrap; gap: 10px; }
.chart-metric { margin: 0; }
.chart-metric select { margin-left: 6px; }
.chart-root { position: relative; }
.chart-root.is-donut { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.chart-root.is-donut .chart-canvas { flex: 0 0 auto; width: min(260px, 100%); }
.chart-canvas { width: 100%; }
.chart-canvas svg { display: block; overflow: visible; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-pop); border-radius: var(--radius-sm); padding: 6px 10px; font-size: 12px; display: grid; gap: 2px; z-index: 5; color: var(--text-2); white-space: nowrap; }
.chart-tip b { color: var(--text); font-size: 13px; }
.chart-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; min-width: 220px; flex: 1; }
.chart-legend li { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; font-size: 13px; color: var(--text-2); }
.chart-legend .swatch { width: 12px; height: 12px; border-radius: 3px; }
.chart-legend .val { color: var(--text); font-variant-numeric: tabular-nums; }
.chart-tip[hidden] { display: none; }

/* Лента карточки: закреп, фильтры, файлы, звонки */
.feed-pinned { display: grid; gap: 6px; margin-bottom: 12px; }
.pin-card { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); }
.pin-card.overdue { border-left-color: var(--danger); }
.pin-card:hover { background: var(--accent-soft); }
.pin-icon { color: var(--muted); display: grid; place-items: center; }
.pin-body { display: grid; min-width: 0; }
.pin-body b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.pin-tag { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.feed-form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.feed-form-actions .file-names { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-btn { cursor: pointer; }
.feed-filters { display: flex; gap: 4px; flex-wrap: wrap; margin: 12px 0 8px; }
.feed-filters a { font-size: 12px; padding: 3px 9px; border-radius: 999px; color: var(--muted); background: var(--surface-2); }
.feed-filters a.active { background: var(--accent); color: var(--on-accent); }
.feed-item { min-width: 0; }
.feed-audio { width: 100%; height: 34px; margin-top: 6px; }
.feed-transcript { margin-top: 6px; }
.feed-transcript summary { cursor: pointer; font-size: 12px; color: var(--accent); }
.feed-transcript div { margin-top: 6px; padding: 8px; background: var(--surface-2); border-radius: var(--radius-sm); max-height: 260px; overflow: auto; }
.feed-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.feed-thumb img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; }
.feed-video { width: 100%; max-height: 260px; border-radius: var(--radius-sm); background: #000; }
.inline-form { display: inline; margin: 0; }

/* Совет ИИ в карточке и помощник */
.ai-summary { text-align: left; border: 1px solid var(--border); border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius-md); padding: 10px 14px; margin-bottom: 12px; display: grid; gap: 2px; }
.ai-summary.empty { background: var(--surface); }
.ai-summary-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--eyebrow); }
.ai-summary p { margin: 0; font-size: 14px; line-height: 1.45; }
.ai-text { font-size: 13px; line-height: 1.5; white-space: normal; }
.card-ai { font-size: 12px; color: var(--text-2); background: var(--accent-soft); border-radius: var(--radius-sm); padding: 4px 6px; margin: 4px 0; line-height: 1.35; }

/* журнал действий */
.audit-changes { list-style: none; margin: 0; padding: 0; font-size: 13px; line-height: 1.5; }
.audit-changes li { overflow-wrap: anywhere; }
a.task-title { color: inherit; text-decoration: none; display: block; }
a.task-title:hover { color: var(--accent); text-decoration: underline; }

/* карточка: данные уже, лента шире (на узких экранах — одна колонка, см. «адаптив») */
@media (min-width: 1101px) {
  .record { grid-template-columns: minmax(340px, 2fr) minmax(0, 3fr); }
}

/* закреплённые комментарии и правка */
.feed-pinned-comments { display: grid; gap: 8px; margin-bottom: 12px; }
.pinned-comment { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius-btn); padding: 10px 12px; background: var(--surface-2); }
.pinned-comment .tl-head svg { width: 14px; height: 14px; vertical-align: -2px; color: var(--accent); }
.comment-tools { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: flex-start; margin-top: 4px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--accent); }
.comment-edit summary { list-style: none; display: inline; }
.comment-edit summary::-webkit-details-marker { display: none; }
.comment-edit[open] { flex-basis: 100%; }
.comment-edit form { display: grid; gap: 6px; margin-top: 6px; }
.comment-edit textarea { width: 100%; }

/* конструктор воронок */
.pipeline-head .panel-body, .panel-body.pipeline-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; }
.pipeline-head label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.pipeline-head label.check { display: flex; align-items: center; gap: 6px; }
.stage-table input[type=text] { width: 100%; min-width: 180px; }
.stage-table input[type=color] { width: 44px; height: 32px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: none; cursor: pointer; }
input.short { width: 80px; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.stage-delete summary { list-style: none; }
.stage-delete summary::-webkit-details-marker { display: none; }
.stage-delete-box { display: grid; gap: 6px; margin-top: 6px; min-width: 220px; }
.new-row td { background: var(--surface-2); }

/* выбор нескольких людей галочками (соисполнители, наблюдатели) */
.check-list { list-style: none; margin: 0; padding: 6px 8px; max-height: 168px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.check-list div, .check-list li { margin: 0; }
.check-list label { display: flex; gap: 8px; align-items: center; padding: 3px 0; font-size: 14px; cursor: pointer; }

/* график судов и консультации на день */
.schedule-day { margin-bottom: 14px; }
.consult-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.consult-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.consult-row:last-child { border-bottom: 0; }
.consult-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.consult-office .panel-head { border-top: 3px solid var(--accent); }
.consult-phone .panel-head { border-top: 3px solid var(--success); }
.schedule-day table { table-layout: fixed; }
.schedule-day th:nth-child(1) { width: 70px; } .schedule-day th:nth-child(2) { width: 22%; } .schedule-day th:nth-child(3) { width: 30%; }
.schedule-day th:nth-child(4) { width: 16%; } .schedule-day th:nth-child(5) { width: 11%; }
.schedule-day td { overflow-wrap: anywhere; }
@media (max-width: 860px) { .schedule-day table { table-layout: auto; } }

/* меню «Документы» в шапке карточки */
.menu-pop-wide { min-width: 340px; max-width: min(420px, 92vw); padding: 12px; right: 0; left: auto; }
.doc-generate { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; margin-bottom: 8px; }
.doc-generate p { grid-column: 1 / -1; margin: 0; }
.doc-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.doc-list li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--border); font-size: 13px; }
.menu-pop .doc-list a { display: inline; width: auto; padding: 0; color: var(--accent); }
.menu-pop .doc-generate .btn { width: auto; justify-content: center; background: var(--accent); color: #fff; }
.menu-pop .link-btn { width: auto; padding: 4px 0; text-decoration: underline; color: var(--muted); }
.menu-pop select { width: 100%; }

/* график платежей: строки правятся прямо в таблице */
.schedule-table input { width: 100%; min-width: 0; padding: 4px 6px; font-size: 13px; }
.schedule-table input.money { text-align: right; min-width: 90px; }
.schedule-table td { padding: 4px 6px; vertical-align: middle; }
.schedule-table tr.sched-paid td { background: color-mix(in srgb, var(--success) 8%, transparent); }
.schedule-table tr.sched-late td:first-child input { border-color: var(--danger); }
.schedule-table tfoot td { border-top: 1px solid var(--border-strong); }

/* редактор документа: лист A4 */
.doc-toolbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.doc-toolbar button[data-cmd] { min-width: 32px; height: 30px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm); cursor: pointer; font: inherit; color: var(--text); }
.doc-toolbar button[data-cmd]:hover { background: var(--surface-2); }
.doc-toolbar .sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.doc-toolbar .spacer { flex: 1; }
.doc-page { max-width: 21cm; min-height: 29.7cm; margin: 16px auto; padding: 2cm 1.5cm 2cm 2.5cm; background: #fff; color: #111; box-shadow: 0 1px 6px rgba(0,0,0,.12); font-family: "Times New Roman", serif; font-size: 12pt; line-height: 1.35; overflow-wrap: anywhere; }
.doc-page:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.doc-page table { border-collapse: collapse; max-width: 100%; }
.doc-page td, .doc-page th { vertical-align: top; }
@media (max-width: 860px) { .doc-page { padding: 1cm; min-height: auto; } }

/* меню по правому клику */
.ctx-menu { position: fixed; z-index: 1000; min-width: 220px; max-width: 320px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-pop); padding: 4px; }
.ctx-menu button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; background: none; border-radius: var(--radius-sm); font: inherit; font-size: 14px; color: var(--text); cursor: pointer; }
.ctx-menu button:hover, .ctx-menu button:focus { background: var(--surface-2); outline: none; }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.ctx-toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 8px 14px; border-radius: var(--radius-btn); font-size: 13px; z-index: 1001; }
.danger-zone { border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border)); }
.danger-zone h2 { color: var(--danger); }
.danger-text { color: var(--danger); }
