:root {
  --accent: #2563eb;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --border: #e3e8ef;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --weekend: #fff7ed;
  --today: color-mix(in srgb, var(--accent) 14%, transparent);
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --radius: 10px;
  --pad: 16px;
  --row-h: 40px;
  --fs: 14px;
}
:root[data-theme="dark"] {
  --bg: #0b1120;
  --panel: #111827;
  --panel-2: #0f172a;
  --border: #1f2a3c;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --weekend: #1c1917;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}
:root[data-density="compact"] { --pad: 10px; --row-h: 32px; }
:root[data-density="comfortable"] { --pad: 22px; --row-h: 48px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: var(--fs)/1.45 var(--font, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif); }
a { color: var(--accent); }
h1 { font-size: 1.5em; margin: 0; }
h2 { font-size: 1.15em; margin: 0 0 12px; }
h3 { font-size: 1em; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .86em; }
.hidden { display: none !important; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
code { background: var(--panel-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; word-break: break-all; }
pre { background: var(--panel-2); border: 1px solid var(--border); padding: 10px; border-radius: 8px; overflow: auto; font-size: .85em; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex: none; background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; transition: width .15s; }
.app.collapsed .sidebar { width: 64px; }
.app.collapsed .sidebar .label, .app.collapsed .sidebar .nav-group, .app.collapsed .brand .label { display: none; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px; font-weight: 700; border-bottom: 1px solid var(--border); }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.brand .logo.has-img, .login .logo.has-img { background: #fff; border: 1px solid var(--border); padding: 2px; overflow: hidden; width: 40px; height: 40px; }
.logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.app.collapsed .brand .logo.has-img { width: 36px; height: 36px; }
.logo-preview { width: 88px; height: 88px; border: 1px dashed var(--border); border-radius: 12px; display: grid; place-items: center; background: #fff; overflow: hidden; flex: none; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.nav { padding: 8px; flex: 1; }
.nav-group { font-size: .72em; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; white-space: nowrap; }
.nav a:hover { background: var(--panel-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .ico { width: 22px; text-align: center; flex: none; display: inline-flex; justify-content: center; }

/* Иконки Hosmans: контур цвета текста + деталь с лёгкой заливкой (в активном пункте — насыщеннее) */
.ic { display: inline-flex; align-items: center; justify-content: center; flex: none; line-height: 0; }
.ic svg { width: 1.3em; height: 1.3em; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.ic .d { fill: currentColor; fill-opacity: .12; }
.ic .f { fill: currentColor; stroke: none; }
.btn .ic svg { width: 1.15em; height: 1.15em; }
/* Фото объекта (окно объекта) и ссылка страницы бронирования (Интеграции) */
.ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.ph { position: relative; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: var(--panel-2); border: 1px solid var(--border); }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph.cover { outline: 2px solid var(--accent); outline-offset: 1px; }
.ph-tag { position: absolute; left: 6px; top: 6px; background: var(--accent); color: #fff; font-size: .7em; font-weight: 700; border-radius: 6px; padding: 1px 6px; }
.ph-act { position: absolute; right: 4px; top: 4px; display: flex; gap: 4px; }
.ph-act button { width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .55); color: #fff; cursor: pointer; font-size: .85em; }
.ph-add { display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; border-style: dashed; color: var(--muted); gap: 2px; }
.ph-add span { font-size: 1.6em; line-height: 1; }
.ph-add:hover { border-color: var(--accent); color: var(--accent); }
.bp-link { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; word-break: break-all; }
.bp-link code { font-size: .88em; }
/* Поле поиска: лупа из набора Hosmans вместо эмодзи 🔍 */
input.search-ico { padding-left: 32px !important; background: var(--panel) no-repeat 10px 50% / 16px 16px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b918a' stroke-width='1.9' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5l5 5'/%3E%3C/svg%3E"); }
/* Иконка вместо эмодзи в надписи (кнопки, вкладки, заголовки, подсказки) */
.ic-inline { vertical-align: -.2em; margin-right: .38em; }
.btn .ic-inline, .tabs button .ic-inline { margin-right: 0; }
.ic-inline.ic-tight { margin-right: .12em; }
.ic-inline.ic-tight svg { width: 1em; height: 1em; }
.chat-human .ic svg { width: 1.05em; height: 1.05em; }
.tabs button { display: inline-flex; align-items: center; gap: 6px; }
h1 .ic-inline svg, h2 .ic-inline svg, h3 .ic-inline svg { width: 1.1em; height: 1.1em; }
.note .ic-inline svg, .badge .ic-inline svg, label .ic-inline svg { width: 1.05em; height: 1.05em; }
.nav a .ic { color: var(--muted); transition: color .15s, transform .15s; }
.nav a:hover .ic { color: var(--text); }
.nav a.active .ic { color: var(--accent); }
.nav a.active .ic .d { fill-opacity: .28; }
.nav a:active .ic { transform: scale(.92); }
.side-foot { border-top: 1px solid var(--border); padding: 10px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar .spacer { flex: 1; }
/* Поиск по CRM */
.gs { position: relative; flex: 0 1 360px; min-width: 120px; }
.gs-input { width: 100%; }
.gs-panel { position: absolute; top: calc(100% + 6px); left: 0; width: min(520px, 92vw); max-height: 70vh; overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0,0,0,.18); z-index: 60; padding: 6px; }
.gs-group { font-size: .75em; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 8px 4px; font-weight: 600; }
.gs-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.gs-item.active, .gs-item:hover { background: var(--accent-soft); }
.gs-empty { padding: 12px 8px; }
@media (max-width: 900px) {
  .gs { flex: 1 1 auto; }
  .gs-panel { position: fixed; top: 58px; left: 8px; right: 8px; width: auto; }
}
@media (max-width: 600px) {
  .topbar #page-title { display: none; }
  /* Всё в одну строку на телефоне: компактный выбор языка, меньше отступов */
  .topbar { gap: 6px; padding: 8px 10px; }
  .topbar select { width: auto; max-width: 72px; padding-left: 6px; padding-right: 2px; }
  .gs { min-width: 80px; }
}
.content { padding: 24px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }

/* Controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--text); padding: 7px 13px; border-radius: 8px; cursor: pointer; font: inherit; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 9px; font-size: .9em; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* «Кнопки в рамках» (Настройки → Интерфейс): у всех кнопок, вкладок и пунктов меню — чёткая рамка */
:root[data-boxed="1"] { --box-line: color-mix(in srgb, var(--text) 30%, var(--border)); }
:root[data-boxed="1"] .btn:not(.primary):not(.solid) { border-color: var(--box-line); }
:root[data-boxed="1"] .btn.ghost { background: var(--panel); }
:root[data-boxed="1"] .btn:hover { border-color: var(--accent); }
:root[data-boxed="1"] .tabs { gap: 6px; border-bottom: 0; }
:root[data-boxed="1"] .tabs button { border: 1px solid var(--box-line); border-radius: 8px; margin-bottom: 0; padding: 7px 13px; background: var(--panel); }
:root[data-boxed="1"] .tabs button.active { border-color: var(--accent); background: var(--accent-soft); }
:root[data-boxed="1"] .nav a { border: 1px solid var(--box-line); margin-bottom: 4px; }
:root[data-boxed="1"] .bottom-nav a { border: 1px solid var(--box-line); border-radius: 8px; margin: 3px; }
:root[data-boxed="1"] .pop-menu button { border: 1px solid var(--box-line); border-radius: 6px; margin: 2px 0; }
:root[data-boxed="1"] table.sh td.rn .row-menu { border: 1px solid var(--box-line); opacity: 1; }

/* «Таблицы с сеткой»: линии между всеми ячейками, как в Excel */
:root[data-grid="1"] { --grid-line: color-mix(in srgb, var(--text) 22%, var(--border)); }
:root[data-grid="1"] table.t, :root[data-grid="1"] table.linked { border-collapse: collapse; }
:root[data-grid="1"] table.t th, :root[data-grid="1"] table.t td,
:root[data-grid="1"] table.linked th, :root[data-grid="1"] table.linked td { border: 1px solid var(--grid-line); }
:root[data-grid="1"] table.sh th, :root[data-grid="1"] table.sh td { border-right-color: var(--grid-line); border-bottom-color: var(--grid-line); }
:root[data-grid="1"] .table-wrap { border-color: var(--grid-line); }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
input[type="color"] { padding: 2px; height: 36px; width: 56px; }
textarea { min-height: 90px; resize: vertical; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: .86em; color: var(--muted); margin-bottom: 4px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.grid { display: grid; gap: 12px; }
.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)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { background: none; border: none; padding: 10px 14px; cursor: pointer; color: var(--muted); font: inherit; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* Cards & tables */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--pad); box-shadow: var(--shadow); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .v { font-size: 1.7em; font-weight: 700; }

/* Главная-конструктор */
.dash { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; align-items: start; }
.dash > .wide { grid-column: 1 / -1; }
.dash-w { min-width: 0; }
.dash-head { margin-bottom: 8px; }
.dash-head h2 { margin: 0; }
.dash-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.dash-stat { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.dash-line { padding: 7px 0; border-bottom: 1px solid var(--border); gap: 8px; }
.dash-line:last-child { border-bottom: none; }
.dash-line.click { cursor: pointer; }
.dash-line.click:hover { background: var(--panel-2); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-bars { display: flex; flex-direction: column; gap: 10px; margin: 8px 0; }
.plan-row .row { gap: 6px; margin-bottom: 4px; }
.plan-track { position: relative; height: 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); margin-top: 4px; }
.plan-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.plan-fill.ok { background: var(--ok); }
.plan-fill.warn { background: var(--warn); }
.plan-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text, #333); opacity: .45; }
.dash-editor { display: flex; flex-direction: column; gap: 4px; }
.dash-ed-row { padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); gap: 8px; }
.dash-ed-row.off { opacity: .55; }
.dash-ed-ico { width: 1.6em; text-align: center; }
@media (max-width: 600px) {
  .dash { grid-template-columns: 1fr; }
  .dash-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .dash-stat { padding: 8px 10px; }
  .dash-stat .v { font-size: 1.4em; }
}
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.t th { background: var(--panel-2); font-weight: 600; font-size: .86em; color: var(--muted); position: sticky; top: 0; z-index: 1; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--panel-2); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .8em; font-weight: 600; background: var(--panel-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.badge.err { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.note { padding: 12px 14px; border-radius: 8px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); margin-bottom: 14px; }
.note.warn { background: color-mix(in srgb, var(--warn) 10%, transparent); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.note.err { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal.wide { max-width: 900px; }
.modal.xwide { max-width: 1200px; }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 10px; }
.modal-head h2 { margin: 0; flex: 1; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* Toast */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #0f172a; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 420px; animation: tin .2s; white-space: pre-line; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes tin { from { transform: translateY(10px); opacity: 0; } }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-col { width: 100%; max-width: 560px; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.login { width: 100%; max-width: 380px; }

/* Фирменная надпись Hosmans: «Hosmans.», подзаголовок, слоган в плашке */
.hm-brand { text-align: center; color: var(--text); font-family: "Manrope", var(--font, system-ui), sans-serif; }
.hm-name { font-weight: 800; letter-spacing: -.02em; line-height: 1; color: var(--accent); }
.hm-dot { color: var(--accent); }
.hm-sub { text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: .5em; }
.hm-pill { display: inline-block; text-transform: uppercase; letter-spacing: .06em; color: var(--text); background: color-mix(in srgb, var(--muted) 18%, transparent); border-radius: 999px; padding: .45em 1.3em; margin-top: .8em; font-weight: 500; }
.hm-brand.lg .hm-name { font-size: 3.4em; }
.hm-brand.lg .hm-sub { font-size: 1.05em; }
.hm-brand.lg .hm-pill { font-size: .9em; }
.hm-hero { background: var(--panel); border: 1px solid var(--border); border-radius: 28px; padding: 30px 36px 26px; width: 100%; box-shadow: var(--shadow); }
.side-brand { padding: 6px 4px 10px; }
.hm-brand.sm .hm-name { font-size: 1.15em; }
.hm-brand.sm .hm-sub { font-size: .58em; letter-spacing: .05em; }
.hm-brand.sm .hm-pill { font-size: .58em; padding: .35em .9em; margin-top: .5em; }
@media (max-width: 520px) { .hm-brand.lg .hm-name { font-size: 2.5em; } .hm-brand.lg .hm-sub { font-size: .78em; } .hm-hero { padding: 22px 16px 18px; } }

/* Chessboard */
.chess-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.chess-toolbar input[type="date"] { width: auto; }
.chess { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); max-height: calc(100vh - 210px); user-select: none; }
.chess-inner { display: grid; position: relative; }
.chess .c-corner, .chess .c-name { position: sticky; left: 0; background: var(--panel); z-index: 3; border-right: 1px solid var(--border); }
.chess .c-corner { top: 0; z-index: 5; display: flex; align-items: flex-end; padding: 8px 12px; font-weight: 600; border-bottom: 1px solid var(--border); }
.chess .c-head { position: sticky; top: 0; z-index: 4; background: var(--panel); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; }
.chess .c-month { display: flex; height: 22px; border-bottom: 1px solid var(--border); }
.chess .c-month div { font-size: .78em; font-weight: 600; padding: 3px 6px; border-right: 1px solid var(--border); overflow: hidden; white-space: nowrap; color: var(--muted); }
.chess .c-days { display: flex; }
.chess .c-day { flex: none; text-align: center; font-size: .78em; padding: 3px 0; border-right: 1px solid var(--border); line-height: 1.2; }
.chess .c-day b { display: block; font-size: 1.15em; }
.chess .c-day.we { background: var(--weekend); color: var(--danger); }
.chess .c-day.td { background: var(--accent); color: #fff; }
.chess .c-name { height: var(--row-h); display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; }
.chess .c-name .cap { margin-left: auto; color: var(--muted); font-size: .8em; }
/* Цвет объекта: мягкая заливка ячейки названия + насыщенная полоска слева */
.chess .c-name.tinted { background: color-mix(in srgb, var(--oc) 24%, var(--panel)); box-shadow: inset 4px 0 0 var(--oc); }
.chess .c-name.tinted .c-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.chess .c-name.tinted .cap { color: color-mix(in srgb, var(--oc) 45%, var(--text)); }
.chess .c-group { position: sticky; left: 0; background: var(--panel-2); font-weight: 600; font-size: .8em; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 4px 12px; border-bottom: 1px solid var(--border); z-index: 2; }
.chess .c-group-fill { background: var(--panel-2); border-bottom: 1px solid var(--border); }
.chess .c-row { position: relative; height: var(--row-h); display: flex; border-bottom: 1px solid var(--border); }
.chess .c-cell { flex: none; height: 100%; border-right: 1px solid var(--border); cursor: cell; }
.chess .c-cell.we { background: var(--weekend); }
.chess .c-cell.td { background: var(--today); }
.chess .c-cell.sel { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.chess .c-cell.ro { cursor: default; }
.chess .bar { position: absolute; top: 4px; bottom: 4px; border-radius: 6px; color: #fff; font-size: .8em; padding: 0 8px; display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; cursor: pointer; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); z-index: 1; line-height: 1.15; }
.chess .bar:hover { filter: brightness(1.1); z-index: 2; }
.chess .bar .t2 { opacity: .85; font-size: .9em; }
.chess .bar.conflict { outline: 2px solid var(--danger); outline-offset: 1px; background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, .18) 0 6px, transparent 6px 12px); }
.chess .bar.cut-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.chess .bar.cut-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.chess .c-free { display: flex; position: sticky; bottom: 0; background: var(--panel-2); border-top: 1px solid var(--border); z-index: 2; }
.chess .c-free div { flex: none; text-align: center; font-size: .78em; padding: 4px 0; border-right: 1px solid var(--border); font-weight: 600; }
.chess .c-free-name { position: sticky; left: 0; bottom: 0; background: var(--panel-2); z-index: 4; padding: 4px 12px; font-size: .8em; font-weight: 600; border-top: 1px solid var(--border); border-right: 1px solid var(--border); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: .86em; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.tip { position: fixed; z-index: 150; background: #0f172a; color: #fff; padding: 8px 12px; border-radius: 8px; font-size: .85em; pointer-events: none; max-width: 320px; white-space: pre-line; }

/* Finance grid */
.fin-layout { display: grid; grid-template-columns: 184px minmax(0, 1fr); gap: 12px; align-items: start; }
.fin-layout.collapsed { grid-template-columns: 26px minmax(0, 1fr); }
.fin-list { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; position: sticky; top: 8px; max-height: calc(100vh - 110px); overflow: auto; font-size: .88em; }
.fin-list.collapsed { padding: 0; overflow: visible; }
.fin-list .fl-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 4px; font-size: .78em; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.fin-list .fl-head + a, .fin-list a + .fl-head { margin-top: 2px; }
.fin-list a + .fl-head { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
.fin-list a { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; text-decoration: none; color: var(--text); line-height: 1.3; }
.fin-list .fl-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-list .fl-meta { flex: none; font-size: .8em; color: var(--muted); font-variant-numeric: tabular-nums; }
.fin-list a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.fin-list a.active .fl-meta { color: var(--accent); }
.fin-list a:hover { background: var(--panel-2); }
.fin-list .fl-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.fin-list .fl-actions .btn { flex: 1; justify-content: center; padding: 3px 6px; font-size: .92em; }
.fl-toggle { border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; border-radius: 6px; padding: 0 6px; font: inherit; font-size: 1.1em; line-height: 1.4; }
.fl-toggle:hover { border-color: var(--border); color: var(--text); background: var(--panel-2); }
.fin-list.collapsed .fl-toggle { width: 26px; height: 40px; border: 1px solid var(--border); background: var(--panel); }
/* Строка инструментов таблицы учёта */
.fin-toolbar { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; }
.fin-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px; flex-wrap: wrap; }
.fin-title { margin: 0 6px 0 2px; font-size: 1.1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.fin-head .spacer { flex: 1; }
.fin-search { width: 190px; padding: 4px 8px; font-size: .9em; }
.fin-toolbar .fin-bar { border: 0; border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); margin: 0; padding: 4px 8px; font-size: .9em; background: transparent; }
.fin-toolbar .fin-bar select, .fin-toolbar .fin-bar input { padding: 3px 6px; font-size: .95em; }
.fin-info { margin-top: 6px; }
.pop-menu { position: fixed; z-index: 120; min-width: 200px; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(0, 0, 0, .2); padding: 4px; display: flex; flex-direction: column; }
.pop-menu button { text-align: left; border: 0; background: none; color: inherit; font: inherit; padding: 7px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.pop-menu button:hover { background: var(--panel-2); }
.pop-menu button.danger { color: var(--danger); }
/* Аналитика из Кассы */
/* ===== Аналитические отчёты ===== */
/* Цвета серий: слоты 1–3 проверенной палитры (дальтонизм — проверено скриптом для светлой и тёмной темы) */
:root { --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --chart-grid: #e6e2d8; --chart-axis: #c3c2b7; --good: #006300; --bad: #b5483a; }
:root[data-theme="dark"] { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --chart-grid: #2c3444; --chart-axis: #4b5563; --good: #0ca30c; --bad: #e66767; }
.rp-title { min-width: 0; }
.rp-title h1 { margin: 2px 0 2px; font-size: 1.45em; letter-spacing: -.01em; }
.rp-kicker { font-size: .72em; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.rp-period { font-weight: 600; margin-bottom: 2px; }
.rp-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 10px; margin: 8px 0; }
.rp-kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.rp-kpi-label { font-size: .8em; color: var(--muted); font-weight: 600; }
.rp-kpi-value { font-size: 1.55em; font-weight: 700; margin: 4px 0 2px; white-space: nowrap; }
.rp-kpi-value.neg { color: var(--bad); }
.rp-kpi-sub { font-size: .8em; color: var(--muted); }
.rp-delta { font-size: .8em; margin-top: 4px; color: var(--muted); }
.rp-delta.up { color: var(--good); }
.rp-delta.down { color: var(--bad); }
.rp-charts { margin-bottom: 0; }
.ch-svg svg { width: 100%; height: auto; display: block; }
.ch-svg rect:hover { opacity: .8; }
.ch-grid { stroke: var(--chart-grid); stroke-width: 1; }
.ch-axis { stroke: var(--chart-axis); stroke-width: 1; }
.ch-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ch-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85em; color: var(--muted); margin-bottom: 4px; }
.ch-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ch-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.ch-table { margin-top: 6px; font-size: .85em; }
.ch-table summary { cursor: pointer; color: var(--muted); }
.ch-htable { width: 100%; }
.ch-htable td { white-space: nowrap; }
.ch-htable td.ch-hlabel { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.ch-htable td.ch-hbar { width: 40%; min-width: 80px; }
.ch-htrack { height: 10px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.ch-hfill { height: 100%; border-radius: 0 3px 3px 0; min-width: 2px; }
/* Справочник финансов — блоки рядом, как столбцы вкладки «Справочник» в Google Таблице */
.dict-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 10px; margin-top: 8px; align-items: start; }
.dict-card { padding: 10px 12px; min-width: 0; }
.dict-card[data-key="articles"] { grid-column: 1 / -1; }
.dict-table input, .dict-table select { padding: 3px 6px; font-size: inherit; min-width: 110px; }
.dict-table td.dict-act { white-space: nowrap; width: 1%; }
.dict-table td.dict-act .btn { padding: 2px 7px; margin-left: 2px; }
.dict-add { display: flex; gap: 6px; margin-top: 8px; }
.dict-add input { padding: 4px 8px; }
/* ===== Чаты с гостями ===== */
.chat-layout { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 12px; height: calc(100vh - 190px); min-height: 420px; }
.chat-list { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-list-head { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border); }
.chat-list-head input { flex: 1; padding: 5px 8px; }
.chat-list-head select { width: auto; padding: 5px 6px; }
.chat-items { overflow: auto; flex: 1; }
.chat-item { display: flex; gap: 10px; padding: 9px 10px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.chat-item:hover { background: var(--panel-2); }
.chat-item.active { background: var(--accent-soft); }
.chat-item.unread .chat-name, .chat-item.unread .chat-last { font-weight: 700; color: var(--text); }
.chat-ava { width: 36px; height: 36px; border-radius: 50%; background: var(--panel-2); display: flex; align-items: center; justify-content: center; flex: none; font-size: 1.1em; }
.chat-meta { flex: 1; min-width: 0; }
.chat-row1, .chat-row2 { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.chat-name, .chat-last { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-last { color: var(--muted); font-size: .87em; }
.chat-badge, .nav-badge { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; font-size: .75em; font-weight: 700; line-height: 18px; flex: none; }
.nav-badge { margin-left: auto; }
.bottom-nav .nav-badge { position: absolute; top: 2px; right: 18%; margin: 0; }
.bottom-nav a { position: relative; }
.chat-thread { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-width: 0; }
.chat-empty { margin: auto; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.chat-back { display: none; }
.chat-msgs { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.chat-msg { max-width: 75%; align-self: flex-start; }
.chat-msg.out { align-self: flex-end; }
.chat-bubble { background: var(--panel); border: 1px solid var(--border); border-radius: 12px 12px 12px 4px; padding: 7px 11px; white-space: pre-wrap; word-wrap: break-word; }
.chat-msg.out .chat-bubble { background: var(--accent); color: #fff; border-color: var(--accent); border-radius: 12px 12px 4px 12px; }
.chat-msg.failed .chat-bubble { background: var(--panel); color: var(--text); border-color: var(--danger); }
.chat-info { font-size: .72em; color: var(--muted); margin-top: 2px; padding: 0 4px; }
.chat-msg.out .chat-info { text-align: right; }
.chat-err { color: var(--danger); }
.chat-compose { display: flex; gap: 8px; padding: 8px; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-compose textarea { flex: 1; resize: vertical; min-height: 42px; max-height: 200px; }
/* Лицензия */
.install-code { font-size: 1.25em; letter-spacing: .08em; padding: 6px 10px; background: var(--panel-2); border-radius: 8px; user-select: all; }
.card.activation { max-width: 460px; }
/* Безопасность */
.sec-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.qr-box { display: flex; justify-content: center; padding: 8px; background: #fff; border-radius: 8px; width: fit-content; margin: 0 auto; }
.recovery-codes { font-size: 1.15em; letter-spacing: .08em; background: var(--panel-2); padding: 12px 16px; border-radius: 8px; columns: 2; }
/* ИИ-помощник в чатах */
.chat-human { font-size: .9em; flex: none; }
.chat-msg.by-ai .chat-bubble { background: color-mix(in srgb, var(--accent) 82%, #6250d6); }
.chat-teach { border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0 0 0 6px; }
.chat-teach:hover { text-decoration: underline; }
.chat-draft { margin: 0 8px; padding: 8px 10px; border: 1px dashed var(--accent); border-radius: 10px; background: var(--accent-soft); }
.chat-draft-text { white-space: pre-wrap; margin-top: 4px; }
.chat-note { margin: 6px 8px 0; }
.btn.ai-on { border-color: var(--accent); color: var(--accent); }
.ai-test-msgs { height: 320px; border: 1px solid var(--border); border-radius: 10px; }
.ai-knowledge { white-space: pre-wrap; max-height: 420px; overflow: auto; background: var(--panel-2); padding: 10px; border-radius: 8px; }
@media (max-width: 760px) {
  .chat-layout { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 210px); }
  .chat-layout.has-chat .chat-list { display: none; }
  .chat-layout:not(.has-chat) .chat-thread { display: none; }
  .chat-back { display: inline-flex; }
  .chat-msg { max-width: 88%; }
}
/* Периоды блоков — в шапке отчёта */
.lk-periods { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.lk-periods .lk-period { margin: 0; }
.lk-period-name { display: inline-block; width: 300px; max-width: 40vw; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lk-card-period { margin-left: 8px; font-size: .78em; font-weight: 400; color: var(--muted); white-space: nowrap; }
.lk-card-period-edit { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; white-space: normal; }
.lk-card-period-edit select, .lk-card-period-edit input { width: auto; padding: 3px 6px; font-size: 1em; }
table.linked td.paid-cell { text-align: center; white-space: nowrap; }
table.linked td.paid-cell input { width: auto; margin: 0; vertical-align: middle; }
.rp-section { font-size: 1.05em; margin: 18px 0 4px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
@media (max-width: 760px) { .lk-period-name { width: 100%; max-width: none; } }
.update-bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 200; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.2); padding: 8px 12px; display: flex; gap: 10px; align-items: center; }
/* Режим презентации: полоса над рабочей областью и выбор демо-сотрудника */
.demo-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 24px; background: color-mix(in srgb, var(--warn) 18%, var(--panel)); border-bottom: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); font-size: .9em; }
.demo-bar .spacer { flex: 1; }
.demo-users { display: grid; gap: 8px; margin-top: 10px; }
.btn.demo-user { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 10px 14px; text-align: left; }
@media (max-width: 600px) { .demo-bar { padding: 6px 12px; } }
/* Отчёт о прибылях и убытках — как финансовая отчётность */
.rp-statement table.linked { font-size: .9em; }
.rp-statement table.linked th { text-transform: none; }
table.linked tr.lk-head td { font-weight: 700; font-size: 1.02em; background: var(--panel-2); border-top: 2px solid var(--text); }
table.linked tr.lk-subtotal td { font-weight: 700; border-top: 1px solid var(--text); background: var(--panel-2); }
table.linked tr.lk-grand td { font-weight: 800; border-top: 1px solid var(--text); border-bottom: 3px double var(--text); background: var(--accent-soft); }
.rp-statement table.linked tr.lk-total td { border-top: 1px solid var(--text); border-bottom: 1px solid var(--text); }
.rp-statement table.linked tr.lk-item td { color: var(--muted); }
.rp-statement table.linked tr.lk-item td:first-child { color: var(--text); }
table.linked td.delta { font-size: .9em; }
table.linked td.delta.up { color: var(--good); }
table.linked td.delta.down { color: var(--bad); }
table.linked td.pct-bar { background-image: linear-gradient(to left, color-mix(in srgb, var(--series-1) 18%, transparent) var(--w), transparent var(--w)); }
@media print {
  .sidebar, .topbar, .fin-list, .tabs, .no-print, .fin-toolbar .btn, .bottom-nav, .lk-period select { display: none !important; }
  .fin-layout, .fin-layout.collapsed { display: block !important; }
  body, .main, .content { background: #fff !important; }
  .card, .rp-kpi, .fin-toolbar { box-shadow: none !important; break-inside: avoid; }
  .linked-grid { display: block; }
  .linked-grid .card { margin-bottom: 10px; }
}
.lk-period { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin: -4px 0 8px; font-size: .85em; }
.lk-period select, .lk-period input { width: auto; padding: 2px 5px; font-size: inherit; }
.fin-list .fl-archive { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 4px; }
.fin-list .fl-archive summary { cursor: pointer; list-style: none; }
.fin-list .fl-archive summary::before { content: '▸ '; }
.fin-list .fl-archive[open] summary::before { content: '▾ '; }
.fin-list .fl-archive a { opacity: .75; }
.linked-inputs { margin-top: 8px; padding: 10px 12px; }
.linked-inputs summary { cursor: pointer; margin-bottom: 8px; }
.linked-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 10px; margin-top: 8px; }
.linked-grid .card { margin: 0; min-width: 0; }
.linked-grid .card.wide { grid-column: 1 / -1; }
.linked-grid h3 { margin: 0 0 10px; }
.linked-grid .card { padding: 10px 12px; }
.linked-grid h3 { font-size: 1em; }
table.linked { font-size: .87em; }
table.linked th, table.linked td { padding: 4px 8px; }
table.linked input, table.linked select { padding: 3px 6px; font-size: inherit; min-width: 120px; }
table.linked th.num, table.linked td.num { text-align: right; white-space: nowrap; }
table.linked td.neg { color: var(--danger); }
table.linked tr.lk-total td { font-weight: 700; background: var(--panel-2); }
table.linked tr.lk-group td { font-weight: 600; background: var(--accent-soft); }
table.linked tr.lk-item td:first-child { padding-left: 26px; }
.sheet { overflow: auto; max-height: calc(100vh - 250px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
table.sh { border-collapse: separate; border-spacing: 0; min-width: 100%; }
table.sh { font-size: .87em; }
table.sh th, table.sh td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 0; height: 26px; }
table.sh th { background: var(--panel-2); position: sticky; top: 0; z-index: 2; font-size: .92em; text-align: left; padding: 4px 6px; cursor: pointer; white-space: nowrap; }
table.sh td .cell { padding: 3px 7px; min-height: 25px; max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: text; line-height: 19px; }
/* Ячейки со справочником — видно, что это выпадающий список */
table.sh td.dict .cell { position: relative; padding-right: 18px; cursor: pointer; }
table.sh td.dict .cell::after { content: '▾'; position: absolute; right: 5px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .85em; }
table.sh td.dict:hover .cell::after { color: var(--accent); }
/* Группы строк (по месяцу и т.п.) */
table.sh tr.grp td { background: var(--panel-2) !important; cursor: pointer; font-weight: 600; border-bottom: 1px solid var(--border); }
table.sh tr.grp td .cell { overflow: visible; cursor: pointer; }
table.sh tr.grp td.rn { color: var(--accent); font-size: 1em; }
/* «Год → Месяц»: год — главная группа, месяц — с отступом внутри года */
table.sh tr.grp-year td { background: color-mix(in srgb, var(--accent) 12%, var(--panel-2)) !important; font-weight: 700; }
table.sh tr.grp-month td .grp-label { padding-left: 22px; }
table.sh tr.grp-month td { font-weight: 600; }
table.sh tr.grp:hover td { background: var(--accent-soft) !important; }
table.sh td.off-dict .cell { color: var(--warn); text-decoration: underline wavy color-mix(in srgb, var(--warn) 60%, transparent); text-underline-offset: 3px; }
table.sh td select { width: 100%; min-width: 140px; }
table.sh tbody tr:nth-child(even) td:not(.rn) { background: color-mix(in srgb, var(--panel-2) 45%, var(--panel)); }
table.sh td.num .cell { text-align: right; font-variant-numeric: tabular-nums; }
/* Касса: расход без минуса — выделен цветом, приход — обычным */
table.sh td.amt-out .cell { color: var(--danger); }
table.sh td.formula .cell { background: color-mix(in srgb, var(--accent) 5%, transparent); cursor: default; }
table.sh td input, table.sh td select { border-radius: 0; border: 2px solid var(--accent); height: 26px; padding: 2px 5px; font-size: inherit; }
table.sh td.rn .check { font-size: .95em; }
table.sh td.rn, table.sh th.rn { width: 44px; text-align: center; color: var(--muted); font-size: .8em; position: sticky; left: 0; background: var(--panel-2); z-index: 1; }
table.sh th.rn { z-index: 3; }
table.sh td.rn:has(.rn-in), table.sh thead th.rn { width: 62px; min-width: 62px; }
table.sh td.rn .rn-in { display: flex; align-items: center; justify-content: center; gap: 2px; white-space: nowrap; }
table.sh td.rn .row-menu { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 3px; font-size: 1.15em; line-height: 1; border-radius: 4px; opacity: .55; }
table.sh tr:hover td.rn .row-menu, table.sh td.rn .row-menu:focus-visible { opacity: 1; }
table.sh td.rn .row-menu:hover { background: var(--accent-soft); color: var(--text); }
@media (hover: none) { table.sh td.rn .row-menu { opacity: 1; } }
table.sh tfoot td { position: sticky; bottom: 0; background: var(--panel-2); font-weight: 700; padding: 3px 7px; text-align: right; z-index: 2; }
/* Строка ввода новой записи — внизу, над итогами (как пустая строка в Excel) */
table.sh tfoot tr.entry td { padding: 0; font-weight: 400; text-align: left; background: var(--panel); border-top: 2px solid var(--accent); }
table.sh tfoot tr.entry td.rn { background: var(--accent-soft); z-index: 3; padding: 2px; }
table.sh tfoot tr.entry td.rn .btn { padding: 1px 9px; min-height: 0; line-height: 20px; }
table.sh tfoot tr.entry td.formula { background: var(--panel-2); }
table.sh tfoot tr.entry input, table.sh tfoot tr.entry select { width: 100%; min-width: 0; border: 1px solid transparent; background: transparent; height: 28px; border-radius: 0; padding: 2px 6px; font-size: inherit; }
table.sh tfoot tr.entry input:focus, table.sh tfoot tr.entry select:focus { border: 2px solid var(--accent); background: var(--panel); outline: none; }
table.sh tfoot tr.entry td.num input { text-align: right; }
table.sh tfoot tr.entry input[type=checkbox] { width: auto; height: auto; margin: 6px; }
table.sh tbody tr.flash td { animation: row-flash 2s ease-out; }
@keyframes row-flash { from { background: color-mix(in srgb, var(--ok, #16a34a) 30%, var(--panel)); } }
table.sh tr.auto td.rn { color: var(--accent); }
table.sh tr.selrow td { background: var(--accent-soft); }

/* Таблицы учёта: панель периода, фильтры столбцов, закрепление */
.fin-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 10px; }
.fin-bar input[type="date"] { width: auto; }
.sheet { max-height: calc(100vh - 200px); }
.th-in { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.th-filter { border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; border-radius: 6px; padding: 0 4px; font: inherit; line-height: 1.4; }
.th-filter:hover { border-color: var(--border); color: var(--text); }
.th-filter.on { color: #fff; background: var(--accent); }
.col-filter { position: fixed; z-index: 120; width: 280px; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .2); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.cf-list { max-height: 220px; overflow: auto; display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }
.cf-list .check { font-size: .9em; }
.sheet.freeze table.sh td:nth-child(2), .sheet.freeze table.sh th:nth-child(2) { position: sticky; left: 44px; z-index: 1; background: var(--panel); box-shadow: 2px 0 0 var(--border); }
.sheet.freeze table.sh th:nth-child(2) { z-index: 3; background: var(--panel-2); }
.sheet.freeze table.sh tfoot td:nth-child(2) { z-index: 3; background: var(--panel-2); }
table.sh tbody tr:hover td { background: color-mix(in srgb, var(--accent) 5%, var(--panel)); }

/* Permissions matrix */
.matrix th.rot { writing-mode: vertical-rl; transform: rotate(180deg); text-align: left; white-space: nowrap; padding: 10px 6px; min-width: 40px; }
.matrix td.c { text-align: center; }
.matrix tr.grp td { background: var(--panel-2); font-weight: 700; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.bars .b { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; }
.bars .b span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: .7em; color: var(--muted); white-space: nowrap; }
.bars-x { display: flex; gap: 6px; font-size: .75em; color: var(--muted); }
.bars-x div { flex: 1; text-align: center; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); background: var(--panel-2); padding: 3px 8px; border-radius: 6px; cursor: pointer; font-size: .82em; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip-x { border: 0; background: none; color: inherit; cursor: pointer; font: inherit; padding: 0 0 0 4px; }
.task-people { max-height: 200px; margin-top: 6px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; }
.swatch.active { border-color: var(--text); }
.copy { display: flex; gap: 6px; }
.copy input { font-family: ui-monospace, Consolas, monospace; font-size: .85em; }

/* Вид списков: список и плитка */
.view-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.view-switch .btn { border: none; border-radius: 0; }
.list-view { display: flex; flex-direction: column; gap: 8px; }
.lv-row { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 10px 14px; }
.lv-row.click { cursor: pointer; }
.lv-row.click:hover { border-color: var(--accent); }
.lv-icon, .cv-icon { font-size: 1.4em; flex: none; }
.lv-main { flex: 1; min-width: 0; }
.lv-title { font-weight: 600; }
.lv-sub { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .88em; margin-top: 2px; }
.lv-badge { flex: none; }
.lv-foot { margin-top: 10px; padding: 10px 14px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); font-weight: 600; }
.card-view { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.cv-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.cv-card.click { cursor: pointer; }
.cv-card.click:hover { border-color: var(--accent); transform: translateY(-1px); }
.cv-strip { height: 5px; }
.cv-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 6px; }
.cv-title { font-weight: 700; flex: 1; min-width: 0; }
.cv-fields { padding: 0 14px 12px; display: grid; gap: 4px; }
.cv-field { display: flex; justify-content: space-between; gap: 10px; font-size: .9em; }
.cv-field > span:last-child { text-align: right; }
.prio-high { color: var(--danger); font-weight: 700; }

/* Индикатор живой синхронизации */
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; opacity: .6; }
.refresh-btn .refresh-ico { display: inline-block; }
.refresh-btn.spinning .refresh-ico { animation: refresh-spin .8s linear infinite; }
@keyframes refresh-spin { to { transform: rotate(360deg); } }
.live-dot.on { background: var(--ok); opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }

/* Нижнее меню и фон под выезжающим меню — только на телефоне */
.bottom-nav, .mobile-backdrop { display: none; }

@media (max-width: 900px) {
  .vs-label, .role-label { display: none; }
  .topbar { gap: 6px; }
  .topbar h1 { font-size: 1.15em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: var(--panel); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -2px 12px rgba(0, 0, 0, .08); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .72em; padding: 4px 0; border-radius: 8px; }
  .bottom-nav a.active { color: var(--accent); font-weight: 600; background: var(--accent-soft); }
  .bn-ico { font-size: 1.5em; line-height: 1; display: inline-flex; }
  .bn-ico .ic svg { width: 24px; height: 24px; stroke-width: 1.6; }
  .bottom-nav a.active .ic .d { fill-opacity: .3; }
  .app.mobile-open .sidebar { z-index: 70; }
  .app.mobile-open .mobile-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 45; }
  .modal-bg { padding: 0; align-items: stretch; }
  .modal, .modal.wide, .modal.xwide { max-width: none; border-radius: 0; min-height: 100%; }
  .modal-foot { position: sticky; bottom: 0; background: var(--panel); }
  .btn { min-height: 38px; }
  .page-head { gap: 8px; }
  .chess { max-height: calc(100vh - 230px); }
  .toasts { bottom: calc(var(--bn-h, calc(80px + env(safe-area-inset-bottom))) + 8px); left: 12px; right: 12px; }
  .sidebar { position: fixed; z-index: 50; left: 0; transform: translateX(-100%); transition: transform .2s; }
  .app.mobile-open .sidebar { transform: none; }
  /* Низ страницы не прячется под нижним меню (с запасом на «Кнопки в рамках» и полоску iPhone) */
  .content { padding: 16px 16px calc(var(--bn-h, calc(80px + env(safe-area-inset-bottom))) + 24px); }
  .topbar { padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .fin-layout, .fin-layout.collapsed { grid-template-columns: minmax(0, 1fr); }
  .fin-list { position: static; max-height: 260px; }
  .fin-list.collapsed .fl-toggle { width: 100%; height: 30px; }
  .fin-search { width: 100%; order: 10; }
}

/* ---------- Сотрудники и отделы ---------- */
.dept-list { display: flex; flex-direction: column; gap: 10px; }
.dept-group { padding: 10px 14px; }
.dept-head { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.dept-caret { width: 12px; color: var(--muted); }
.dept-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dept-table { margin-top: 8px; }
.dept-table td { padding: 6px 8px; }
.dept-table tr.clickable { cursor: pointer; }
.dept-table tr.clickable:hover td { background: var(--accent-soft); }
.dept-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.dept-btn { --dc: var(--accent); border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 999px; padding: 4px 12px; cursor: pointer; font: inherit; font-size: 13px; }
.dept-btn:hover { border-color: var(--dc); }
.dept-btn.on { border-color: var(--dc); background: color-mix(in srgb, var(--dc) 14%, transparent); font-weight: 600; }
.chip.dept { background: var(--accent-soft); }

/* ---------- Типы задач, чек-листы, объявления ---------- */
.type-switch { display: flex; gap: 4px; padding: 3px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; }
.type-switch button { flex: 1; border: 0; background: transparent; color: var(--text); padding: 8px 10px; border-radius: 8px; cursor: pointer; font: inherit; }
.type-switch button.on { background: var(--panel); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; color: var(--accent); }
.cl-edit { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.cl-edit-row { display: flex; align-items: center; gap: 4px; width: 100%; }
.cl-edit-row input { flex: 1; }
.cl-num { width: 22px; text-align: right; }
.cl-items { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.cl-item { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); }
.cl-item.done > span:first-of-type { text-decoration: line-through; color: var(--muted); }
.mini-bar { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; vertical-align: middle; }
.mini-bar i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.mini-bar.wide { width: 100%; margin-top: 4px; }
.progress-cell { white-space: nowrap; }
.ack-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ack { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); font-size: 13px; }
.ack.yes { border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: color-mix(in srgb, var(--ok) 8%, transparent); }
.tpl-row { display: flex; align-items: center; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--border); }
@media (max-width: 700px) {
  .dept-table, .dept-table tbody { display: block; }
  .dept-table tr { display: flex; flex-wrap: wrap; gap: 2px 10px; padding: 6px 4px; border-bottom: 1px solid var(--border); }
  .card .dept-table.t td { padding: 0; border: 0; background: none; }
  .dept-table td:empty { display: none; }
  .dept-table td:first-child { width: 100%; }
  .dept-head { flex-wrap: wrap; }
}
