/* ---------- Основа ---------- */
:root {
  --bg: #f6f6f8;
  --panel: #ffffff;
  --border: #e3e3e8;
  --border-strong: #cfcfd6;
  --text: #1b1b1f;
  --text-2: #50505a;
  --muted: #84848f;
  --accent: #5b5bd6;
  --accent-hover: #4c4cc4;
  --accent-weak: #eeeefd;
  --danger: #d93d42;
  --danger-weak: #fdecec;
  --ok: #2b9a5d;
  --warn: #c27c0e;
  --warn-weak: #fff6e2;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 20, 40, .06), 0 8px 24px rgba(20, 20, 40, .12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.4 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
#app { height: 100%; display: flex; flex-direction: column; }
.boot { margin: auto; color: var(--muted); }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.spacer { flex: 1 1 auto; }
.push-right { margin-left: auto; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 13px; }
.placeholder { color: #b0b0ba; }
.pre { white-space: pre-wrap; word-break: break-word; }
.hint { color: var(--muted); font-size: 12.5px; }
.hint.error, .error { color: var(--danger); }
kbd { font: 12px var(--mono); background: #f1f1f4; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; white-space: nowrap; }

.ic { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.ic-space { display: inline-block; width: 16px; flex: none; }

/* ---------- Кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--border); background: var(--panel); border-radius: 7px; cursor: pointer;
  white-space: nowrap; text-decoration: none; color: var(--text); transition: background .12s, border-color .12s;
}
.btn:hover { background: #f4f4f7; border-color: var(--border-strong); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #ededf2; border-color: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #c4343a; }
.btn-danger-ghost { border-color: transparent; background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-weak); }
.btn-block { width: 100%; justify-content: center; height: 38px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex: none;
  border: none; background: transparent; border-radius: 6px; cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { background: #ececf1; color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }

.input, .select {
  height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 7px; background: #fff; width: 100%;
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 91, 214, .18); }
.input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(217, 61, 66, .15); }
.input-sm, .select-sm { height: 28px; font-size: 13px; padding: 0 8px; }
.select { padding-right: 24px; cursor: pointer; }
.select-sm { width: auto; }
.textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; min-height: 90px; }
.label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin: 10px 0 4px; }
.form > .label:first-child { margin-top: 0; }
.check-line { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; cursor: pointer; font-size: 13.5px; }
.form p { margin: 0 0 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.notice { display: flex; gap: 8px; align-items: flex-start; background: var(--warn-weak); color: #7a4f06; border-radius: 7px; padding: 10px 12px; font-size: 13px; margin-bottom: 6px; }
.tag { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 10px; background: #eeeef2; color: var(--text-2); vertical-align: 1px; }
.tag-red { background: var(--danger-weak); color: var(--danger); }
.tag-indigo { background: var(--accent-weak); color: var(--accent); }

/* ---------- Верхняя панель ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 14px; flex: none;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 15px; margin-right: 6px; }
.logo-mark {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 15px;
}
.view-slot { display: flex; align-items: center; gap: 10px; min-width: 0; }
.view-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 10px; max-width: 360px;
  border: 1px solid var(--border); border-radius: 8px; background: #fafafc; cursor: pointer; font-weight: 600;
}
.view-btn:hover { background: #f1f1f5; }
.view-btn .view-kind { color: var(--muted); }
.view-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dirty-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none; }
.dirty-bar { display: flex; align-items: center; gap: 6px; }
.dirty-text { font-size: 12.5px; color: var(--warn); font-weight: 600; margin-right: 2px; }
.conn { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(43, 154, 93, .15); }
.conn.bad { color: var(--danger); font-weight: 600; background: var(--danger-weak); padding: 4px 10px; border-radius: 14px; }
.conn.bad .conn-dot { background: var(--danger); box-shadow: none; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .3; } }
.online { display: flex; align-items: center; }
.online .avatar { margin-left: -6px; box-shadow: 0 0 0 2px #fff; }
.online-more { font-size: 12px; color: var(--muted); margin-left: 4px; }
.user-btn { display: flex; align-items: center; gap: 8px; border: none; background: transparent; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.user-btn:hover { background: #f1f1f5; }
.user-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Панель инструментов ---------- */
.toolbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; flex: none; flex-wrap: wrap;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.tb-group { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.search { position: relative; display: flex; align-items: center; margin-right: 4px; color: var(--muted); }
.search .ic { position: absolute; left: 9px; pointer-events: none; }
.search-input {
  height: 32px; width: 260px; padding: 0 10px 0 30px; border: 1px solid var(--border); border-radius: 7px; background: #f7f7f9; outline: none;
}
.search-input:focus { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 91, 214, .15); }
.tool-btn {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  border: 1px solid transparent; background: transparent; border-radius: 7px; cursor: pointer; color: var(--text-2);
}
.tool-btn:hover { background: #f0f0f4; color: var(--text); }
.tool-btn.active { background: var(--accent-weak); color: var(--accent); }
.badge { font-size: 11px; font-weight: 700; background: var(--accent); color: #fff; border-radius: 9px; padding: 0 6px; line-height: 17px; }
.tool-btn:not(.active) .badge { background: #e4e4ea; color: var(--text-2); }
.counts { font-size: 13px; color: var(--text-2); white-space: nowrap; }
.counts .sep { margin: 0 6px; color: var(--muted); }
.bulk-bar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 400;
  display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 16px; border-radius: 12px;
  background: #25252c; color: #fff; box-shadow: var(--shadow); animation: toastIn .14s ease-out;
}
.bulk-count { font-weight: 600; margin-right: 8px; white-space: nowrap; }
.bulk-bar .btn { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .18); color: #fff; }
.bulk-bar .btn:hover { background: rgba(255, 255, 255, .2); }
.bulk-bar .btn-danger-ghost { color: #ffb4b6; }
.bulk-bar .bulk-clear { background: transparent; border-color: transparent; color: #c9c9d3; }
body.drawer-open .bulk-bar { left: calc((100vw - min(640px, 100vw)) / 2); }

/* ---------- Таблица ---------- */
.grid-wrap { position: relative; flex: 1 1 auto; min-height: 0; }
.grid { position: absolute; inset: 0; }
.loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: var(--bg); color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid #dcdce6; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.ag-theme-quartz {
  --ag-font-family: var(--font);
  --ag-font-size: 13px;
  --ag-foreground-color: var(--text);
  --ag-header-foreground-color: var(--text-2);
  --ag-header-background-color: #fafafc;
  --ag-background-color: #fff;
  --ag-odd-row-background-color: #fff;
  --ag-row-hover-color: #f6f6fb;
  --ag-selected-row-background-color: #eeeefd;
  --ag-border-color: var(--border);
  --ag-row-border-color: #ececf0;
  --ag-secondary-border-color: #ececf0;
  --ag-header-column-separator-display: block;
  --ag-header-column-separator-color: #e6e6ec;
  --ag-header-column-resize-handle-color: #d4d4dc;
  --ag-cell-horizontal-padding: 10px;
  --ag-active-color: var(--accent);
  --ag-input-focus-border-color: var(--accent);
  --ag-range-selection-border-color: var(--accent);
  --ag-value-change-value-highlight-background-color: rgba(255, 196, 0, .35);
  --ag-wrapper-border-radius: 0;
  --ag-borders: none;
  --ag-checkbox-checked-color: var(--accent);
}
.ag-theme-quartz .ag-root-wrapper { border: none; }
.ag-theme-quartz .ag-header { border-bottom: 1px solid var(--border); }
.ag-theme-quartz .ag-header-cell { padding-right: 4px; }
.ag-theme-quartz .ag-cell { display: flex; align-items: center; line-height: 1.3; }
.ag-theme-quartz .ag-cell-focus:not(.ag-cell-range-selected):focus-within { border-color: var(--accent) !important; }
.ag-theme-quartz .ag-row-selected .ag-cell { background: transparent; }
.ag-pinned-left-cols-container .ag-cell:last-child, .ag-pinned-left-header .ag-header-cell:last-child { border-right: 1px solid var(--border) !important; }

.hdr { display: flex; align-items: center; gap: 5px; width: 100%; height: 100%; cursor: pointer; min-width: 0; font-weight: 600; font-size: 12.5px; }
.hdr-ic { color: var(--muted); display: inline-flex; }
.hdr-ic .ic { width: 14px; height: 14px; }
.hdr-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; min-width: 0; }
.hdr-review { color: var(--warn); display: inline-flex; }
.hdr-review .ic { width: 14px; height: 14px; }
.hdr-sort { color: var(--accent); font-weight: 700; font-size: 13px; white-space: nowrap; }
.hdr-sort sup { font-size: 9px; margin-left: 1px; }
.hdr-menu { display: inline-flex; border: none; background: transparent; border-radius: 5px; padding: 3px; cursor: pointer; color: var(--muted); opacity: 0; }
.ag-header-cell:hover .hdr-menu, .hdr-menu:focus { opacity: 1; }
.hdr-menu:hover { background: #e8e8ef; color: var(--text); }

.cell { display: flex; align-items: center; gap: 4px; width: 100%; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.t-longtext .cell, .t-text .cell { display: block; }
.rows-tall .t-longtext .cell, .rows-tall .t-text .cell, .rows-tall .t-url .cell {
  white-space: normal; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; word-break: break-word;
}
.rows-tall .chips, .rows-tall .people { flex-wrap: wrap; max-height: 100%; }
.rows-compact .ag-cell { font-size: 12.5px; }
.row-done .cell { color: #8d8d97; }
.row-done .t-longtext.ag-cell[col-id="title"] .cell { text-decoration: line-through; text-decoration-color: #c4c4cc; }
.cell-vse { overflow: visible; }
.vse-link { font-weight: 600; color: var(--accent); text-decoration: none; font-variant-numeric: tabular-nums; }
.vse-link:hover { text-decoration: underline; }
.row-open { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: inline-flex; border: none; background: #f0f0f6; border-radius: 5px; padding: 3px; cursor: pointer; color: var(--text-2); opacity: 0; }
.ag-row-hover .row-open, .ag-cell-focus .row-open { opacity: 1; }
.row-open:hover { background: var(--accent-weak); color: var(--accent); }
.row-open .ic { width: 13px; height: 13px; }
.row-viewers { display: inline-flex; }
.row-viewers .avatar { margin-left: -4px; box-shadow: 0 0 0 1.5px #fff; }
.presence-cell { box-shadow: inset 0 0 0 2px var(--who); }
.who-tag {
  position: absolute; right: 2px; top: 1px; font-size: 10px; line-height: 14px; padding: 0 5px; border-radius: 4px;
  background: var(--who); color: #fff; font-weight: 600; pointer-events: none;
}
.no-rows { color: var(--muted); text-align: center; line-height: 1.6; }
.no-rows span { font-size: 12.5px; }
.ag-theme-quartz .ag-tooltip { white-space: pre-wrap; max-width: 420px; font-size: 12.5px; background: #24242b; color: #fff; border: none; border-radius: 6px; }

/* ---------- Значения ---------- */
.chips { display: inline-flex; gap: 4px; min-width: 0; overflow: hidden; }
.chip {
  display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; line-height: 18px; white-space: nowrap;
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; flex: none;
}
.c-gray { background: #ececef; color: #3f3f46; }
.c-brown { background: #f1e6dc; color: #6b4a33; }
.c-orange { background: #fde6cf; color: #96450a; }
.c-yellow { background: #faf0c6; color: #6f5300; }
.c-green { background: #d9f2e1; color: #1d6638; }
.c-teal { background: #d3f0ee; color: #0e5d59; }
.c-blue { background: #d9e8fd; color: #1c4b96; }
.c-indigo { background: #e1e3fb; color: #393d9e; }
.c-purple { background: #ece0fa; color: #682c9f; }
.c-pink { background: #fae0ed; color: #96215d; }
.c-red { background: #fcdedd; color: #a02127; }
.people { display: inline-flex; gap: 8px; min-width: 0; overflow: hidden; }
.person { display: inline-flex; align-items: center; gap: 5px; min-width: 0; flex: none; }
.person-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person.inactive { opacity: .55; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: var(--sz, 20px); height: var(--sz, 20px); border-radius: 50%;
  background: var(--av, #868e96); color: #fff; font-size: calc(var(--sz, 20px) * .42); font-weight: 650; letter-spacing: .02em;
}
.me-avatar { background: var(--accent); }
.cb {
  display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; flex: none;
  border: 1.5px solid #c3c3cc; border-radius: 4px; background: #fff;
}
.cb.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.cb svg, .cb .ic { width: 12px; height: 12px; }
.cb-grid { cursor: pointer; }
.t-bool .cell { justify-content: center; }
.date { font-variant-numeric: tabular-nums; }
.date.overdue { color: var(--danger); font-weight: 600; }
.date.due-today { color: var(--warn); font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.t-duration .cell, .t-number .cell, .t-computed .cell { justify-content: flex-end; }
.link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-opt { display: inline-flex; align-items: center; gap: 7px; color: var(--text); }
.field-opt .ic { color: var(--muted); }

/* ---------- Всплывающие панели и меню ---------- */
.popover {
  position: fixed; z-index: 1000; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); overflow: auto; animation: pop .1s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-3px); } }
.menu { padding: 5px; }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 9px; border: none; background: none;
  border-radius: 6px; cursor: pointer; text-align: left; font-size: 13.5px;
}
.menu-item:hover:not(:disabled) { background: #f1f1f6; }
.menu-item:disabled { opacity: .4; cursor: default; }
.menu-item.danger { color: var(--danger); }
.menu-item .ic { color: var(--muted); }
.menu-item.danger .ic { color: var(--danger); }
.menu-label { flex: 1 1 auto; }
.menu-hint { color: var(--muted); font-size: 12px; }
.menu-check { color: var(--accent) !important; }
.menu-divider { height: 1px; background: var(--border); margin: 5px 4px; }
.menu-header { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 9px 4px; }

.picker { display: flex; flex-direction: column; max-height: inherit; }
.picker-pop { display: flex; flex-direction: column; overflow: hidden; }
.picker-search-wrap { position: relative; display: flex; align-items: center; border-bottom: 1px solid var(--border); flex: none; }
.picker-search-ic { position: absolute; left: 10px; color: var(--muted); display: inline-flex; }
.picker-search { width: 100%; height: 38px; border: none; outline: none; padding: 0 10px 0 32px; background: transparent; }
.picker-list { overflow: auto; padding: 4px; flex: 1 1 auto; max-height: 340px; }
.picker-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; min-height: 32px; }
.picker-item.active { background: #f1f1f6; }
.picker-item.selected .picker-label { font-weight: 600; }
.picker-label { flex: 1 1 auto; min-width: 0; overflow: hidden; }
.picker-check { color: var(--accent); }
.picker-create { color: var(--accent); }
.picker-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.picker-foot { display: flex; align-items: center; gap: 6px; padding: 6px; border-top: 1px solid var(--border); flex: none; }
.picker-foot .btn-primary { margin-left: auto; }

.date-editor, .duration-editor, .text-editor { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.date-row { display: flex; align-items: center; gap: 8px; }
.date-cap { width: 18px; color: var(--muted); font-size: 12.5px; }
.quick-row { display: flex; flex-wrap: wrap; gap: 5px; }
.editor-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.editor-actions .hint { margin-right: auto; }
.text-editor .textarea { min-height: 120px; }
.duration-editor .hint.error { color: var(--danger); }

/* ---------- Фильтры, сортировка, столбцы ---------- */
.filter-builder, .sort-panel { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.fb-title { font-weight: 650; }
.fb-empty { color: var(--muted); font-size: 13px; }
.fb-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fb-conj-label, .fb-conj { width: 64px; flex: none; color: var(--muted); font-size: 13px; }
.fb-conj .select { width: 64px; }
.fb-field { max-width: 230px; justify-content: space-between; }
.fb-field span { overflow: hidden; text-overflow: ellipsis; }
.fb-field .ic:first-child { color: var(--muted); }
.fb-op { max-width: 210px; }
.fb-value { display: flex; align-items: center; gap: 6px; flex: 1 1 180px; min-width: 160px; }
.fb-value .input { flex: 1 1 auto; }
.fb-multi { max-width: 100%; overflow: hidden; flex: 1 1 auto; justify-content: flex-start; }
.fb-group { flex: 1 1 auto; border: 1px dashed var(--border-strong); background: #fafafc; border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.fb-actions { display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.fb-missing { color: var(--danger); font-size: 13px; flex: 1; }

.columns-panel { display: flex; flex-direction: column; max-height: inherit; }
.columns-list { overflow: auto; padding: 4px; max-height: 440px; }
.col-item { display: flex; align-items: center; gap: 7px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 13.5px; border-top: 2px solid transparent; border-bottom: 2px solid transparent; }
.col-item:hover { background: #f4f4f8; }
.col-item.dragging { opacity: .4; }
.col-item.drop-before { border-top-color: var(--accent); }
.col-item.drop-after { border-bottom-color: var(--accent); }
.grip { color: #b5b5bf; cursor: grab; display: inline-flex; }
.col-ic { color: var(--muted); display: inline-flex; }
.col-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-pin, .col-review { display: inline-flex; color: var(--muted); }
.col-review { color: var(--warn); }

.views-menu { display: flex; flex-direction: column; }
.views-list { padding: 4px; max-height: 420px; overflow: auto; }
.view-item { display: flex; align-items: center; gap: 8px; padding: 6px 4px 6px 10px; border-radius: 6px; cursor: pointer; }
.view-item:hover { background: #f3f3f7; }
.view-item.active { background: var(--accent-weak); }
.view-item.active .view-item-name { color: var(--accent); font-weight: 600; }
.view-item-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-more { opacity: 0; }
.view-item:hover .view-more { opacity: 1; }

/* ---------- Модальные окна ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 900; background: rgba(24, 24, 32, .38); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; overflow: auto; }
.modal { background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); max-width: 100%; display: flex; flex-direction: column; max-height: 84vh; animation: pop .12s ease-out; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px; }
.modal-title { font-size: 16px; font-weight: 650; flex: 1; }
.modal-body { padding: 4px 16px 16px; overflow: auto; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.modal-foot .spacer { flex: 1; }
.confirm-text { color: var(--text-2); white-space: pre-line; }
.hotkeys td { padding: 5px 12px 5px 0; vertical-align: top; }

/* ---------- Уведомления ---------- */
.toasts { position: fixed; left: 16px; bottom: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; max-width: min(460px, calc(100vw - 32px)); }
.toast {
  position: relative; background: #25252c; color: #fff; padding: 11px 36px 11px 14px; border-radius: 9px; box-shadow: var(--shadow);
  font-size: 13.5px; animation: toastIn .16s ease-out; transition: opacity .18s, transform .18s;
}
.toast.leaving { opacity: 0; transform: translateY(6px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
.toast-error { background: #a8262c; }
.toast-success { background: #1f7a49; }
.toast-warn { background: #fff; color: var(--text); border: 1px solid #f0c674; border-left: 4px solid var(--warn); }
.toast-msg { line-height: 1.45; }
.toast-actions { display: flex; gap: 6px; margin-top: 8px; }
.toast-btn { border: 1px solid rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .12); color: inherit; border-radius: 6px; padding: 3px 10px; cursor: pointer; font-size: 13px; }
.toast-warn .toast-btn { border-color: var(--accent); background: var(--accent); color: #fff; }
.toast-close { position: absolute; right: 6px; top: 8px; border: none; background: transparent; color: inherit; opacity: .6; cursor: pointer; padding: 2px; }
.toast-close:hover { opacity: 1; }

/* ---------- Карточка задачи ---------- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 500; width: min(640px, 100vw); background: var(--panel);
  border-left: 1px solid var(--border); box-shadow: -10px 0 30px rgba(20, 20, 40, .1);
  display: flex; flex-direction: column; transform: translateX(105%); transition: transform .18s ease-out; visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); flex: none; }
.drawer-nav { display: flex; }
.drawer-vse { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.drawer-viewers { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; }
.drawer-viewers .avatar { margin-left: -4px; box-shadow: 0 0 0 2px #fff; }
.tabs { display: inline-flex; background: #f0f0f4; border-radius: 8px; padding: 2px; }
.tab { border: none; background: transparent; padding: 4px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.tab.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.drawer-banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; background: var(--danger-weak); color: var(--danger); font-weight: 600; }
.drawer-title-wrap { padding: 14px 16px 6px; flex: none; }
.drawer-title {
  width: 100%; border: 1px solid transparent; border-radius: 7px; padding: 6px 8px; resize: none; outline: none;
  font-size: 18px; font-weight: 650; line-height: 1.35; background: transparent; overflow: hidden;
}
.drawer-title:hover { background: #f6f6f9; }
.drawer-title:focus { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 91, 214, .15); overflow: auto; }
.drawer-body { flex: 1 1 auto; overflow: auto; padding: 4px 16px 24px; }
.fsection { display: flex; flex-direction: column; gap: 1px; margin-bottom: 8px; }
.fsection-title { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 14px 0 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.frow { display: grid; grid-template-columns: 200px 1fr; gap: 8px; align-items: start; }
.fl { display: flex; align-items: center; gap: 7px; color: var(--text-2); font-size: 13px; padding: 7px 0; min-width: 0; }
.fl span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fl .ic { color: var(--muted); }
.fl-review { color: var(--warn) !important; }
.fv { min-height: 34px; padding: 6px 8px; border-radius: 7px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-width: 0; word-break: break-word; }
.fv .chips, .fv .people { flex-wrap: wrap; overflow: visible; }
.fv .chip { max-width: 100%; }
.fv-editable { cursor: pointer; }
.fv-editable:hover { background: #f4f4f8; }
.fv-editable:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.fv-readonly { color: var(--text-2); }
.fv-flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: rgba(255, 196, 0, .4); } }
.drawer-meta { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--text-2); font-size: 12.5px; display: flex; flex-direction: column; gap: 3px; }
.drawer-danger { margin-top: 14px; }

.history { padding-top: 8px; display: flex; flex-direction: column; }
.hist-item { position: relative; display: flex; gap: 10px; padding: 0 0 14px 0; }
.hist-item::before { content: ''; position: absolute; left: 4px; top: 12px; bottom: 0; width: 1px; background: var(--border); }
.hist-item:last-child::before { display: none; }
.hist-dot { width: 9px; height: 9px; border-radius: 50%; background: #c9c9d3; margin-top: 6px; flex: none; }
.hist-origin { color: var(--muted); font-size: 12.5px; }
.hist-main { flex: 1; min-width: 0; }
.hist-head { display: flex; align-items: center; gap: 8px; }
.hist-who { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.hist-when { color: var(--muted); font-size: 12px; }
.hist-what { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.hist-diff { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.hist-old { opacity: .65; text-decoration: line-through; text-decoration-color: #b0b0ba; max-width: 45%; }
.hist-new { max-width: 45%; }
.hist-old .chips, .hist-new .chips, .hist-old .people, .hist-new .people { flex-wrap: wrap; }
.hist-arrow { color: var(--muted); }

/* ---------- Администрирование ---------- */
.admin-tabs { margin-bottom: 12px; }
.admin-bar { display: flex; align-items: center; gap: 16px; justify-content: space-between; margin-bottom: 10px; }
.admin-bar .hint { max-width: 640px; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 8px; max-height: 56vh; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th { position: sticky; top: 0; background: #fafafc; text-align: left; font-size: 12px; color: var(--text-2); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.admin-table td { padding: 7px 10px; border-bottom: 1px solid #efeff3; vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr.inactive td { opacity: .6; }
.admin-table .actions { text-align: right; white-space: nowrap; width: 1%; }
.admin-sub { margin: 20px 0 4px; font-size: 14px; }
.deleted-fields { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.deleted-fields .row { justify-content: space-between; max-width: 480px; }
.opt-list { display: flex; flex-direction: column; gap: 5px; }
.opt-row { display: flex; align-items: center; gap: 6px; }
.opt-row .input { flex: 1 1 auto; }
.opt-count { width: 110px; text-align: right; flex: none; }
.color-dot { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, .08); cursor: pointer; flex: none; }

/* ---------- Вход ---------- */
.login-page { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(1200px 600px at 50% -10%, #e9e9fb, var(--bg)); }
.login-form { width: 360px; max-width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; }
.login-logo { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; }
.login-sub { color: var(--muted); font-size: 13px; margin: 8px 0 14px; }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 10px 0 6px; }
.login-hint { color: var(--muted); font-size: 12.5px; margin-top: 14px; text-align: center; }

/* ---------- Узкие экраны ---------- */
@media (max-width: 900px) {
  .brand-name, .user-name, .tool-label, .dirty-text { display: none; }
  .search-input { width: 180px; }
  .frow { grid-template-columns: 1fr; gap: 0; }
  .fl { padding-bottom: 0; }
}
