:root {
  --bg: #ffffff; --fg: #1b1d21; --muted: #6b7079; --line: #e3e5e8; --soft: #f5f6f8;
  --accent: #1f5fbf; --accent-fg: #ffffff; --red: #b3261e; --notice: #fff8e1; --was: #8a8f98;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16181c; --fg: #e6e7ea; --muted: #9aa0a9; --line: #2c3036; --soft: #1e2126;
          --accent: #6a9eea; --accent-fg: #0d1117; --red: #f08a82; --notice: #2b2616; --was: #7d828b; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
main { padding: 16px; max-width: 1400px; margin: 0 auto; }
h1 { font-size: 22px; margin: 8px 0 12px; }
h2 { font-size: 17px; margin: 24px 0 8px; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 8px 16px;
  border-bottom: 1px solid var(--line); background: var(--soft); }
.top .brand { font-weight: 600; color: var(--fg); }
.top nav { display: flex; flex-wrap: wrap; gap: 4px 12px; flex: 1; }
.top .me { display: flex; gap: 8px; align-items: center; }
.envbar { background: #c77700; color: #fff; text-align: center; font-size: 12px; padding: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.error { color: var(--red); }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: var(--bg); }
.card.narrow { max-width: 420px; margin: 40px auto; }
.card.notice { background: var(--notice); margin-bottom: 16px; }
.card label { display: block; margin: 10px 0; }
.card input:not([type=checkbox]) { display: block; width: 100%; margin-top: 4px; }
input, select, textarea, button, .button { font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
textarea { width: 100%; resize: vertical; }
button, .button { cursor: pointer; background: var(--soft); display: inline-block; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.danger { color: var(--red); }
button.link { border: none; background: none; color: var(--accent); padding: 0; }
button.small, .button.small { padding: 2px 8px; font-size: 12px; }
form.inline { display: inline; }
label.check { display: inline-flex; gap: 6px; align-items: center; }
.bar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; }
.bar h1 { margin-right: auto; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.scroll { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; font-size: 14px; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
table.grid th { background: var(--soft); font-weight: 600; position: sticky; top: 0; }
table.history td.was, .was { color: var(--was); text-decoration: line-through; }
table.history tr.first td { border-top: 2px solid var(--line); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; color: var(--fg); }
.tile .num { font-size: 28px; font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 8px 0 16px; }
.tabs a { padding: 6px 12px; border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; color: var(--fg); }
.tabs a.on { border-color: var(--line); background: var(--bg); margin-bottom: -1px; font-weight: 600; }
form.record { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px 16px; margin-bottom: 16px; }
form.record .field { display: flex; flex-direction: column; gap: 4px; }
form.record .field.wide { grid-column: 1 / -1; }
form.record .field label { font-size: 12px; color: var(--muted); }
form.record .actions { grid-column: 1 / -1; }
.ro { padding: 6px 0; white-space: pre-wrap; }
.tag { font-size: 12px; padding: 1px 6px; border-radius: 4px; border: 1px solid; vertical-align: middle; }
.tag.red { color: var(--red); }
.crumbs { margin: 0; font-size: 13px; }
.qr svg { width: 200px; height: 200px; }
input.copy { width: 100%; }
@media (max-width: 700px) {
  main { padding: 12px 16px; }
  .top nav { order: 3; width: 100%; }
  table.grid { font-size: 13px; }
}

/* --- CP2: живой трекер --------------------------------------------------- */
main.wide { max-width: none; }
.gridbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.gridbar h1 { margin: 0 8px 0 0; font-size: 20px; }
.hint { margin-top: 6px; }
.live { padding: 1px 6px; border-radius: 10px; border: 1px solid var(--line); }
.live.sse { color: #0a7a2f; border-color: #0a7a2f; }
.live.poll { color: #b26a00; border-color: #b26a00; }
.live.off { color: var(--red); border-color: var(--red); }
.presence { color: #7a3fb5; }
.colpanel { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 8px; }
.bulkbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px; background: var(--notice); border-radius: 6px; margin-bottom: 8px; }
#grid { border: 1px solid var(--line); border-radius: 6px; }
.tabulator { font-size: 13px; background: var(--bg); color: var(--fg); }
.tabulator .tabulator-header, .tabulator .tabulator-header .tabulator-col { background: var(--soft); color: var(--fg); }
.tabulator .tabulator-tableholder .tabulator-table { background: var(--bg); color: var(--fg); }
.tabulator-row { background: var(--bg); }
.tabulator-row.tabulator-row-even { background: var(--soft); }
.tabulator-row.overdue .tabulator-cell { color: var(--red); }
.tabulator-row.changed { box-shadow: inset 3px 0 0 #1f5fbf; }
.tabulator-row.flash, .card-row.flash, .kb-card.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { background: #ffe58a; } 100% { background: transparent; } }
.tabulator .tabulator-cell.tabulator-range-selected:not(.tabulator-range-only-cell-selected) { background: rgba(31, 95, 191, .12); }
.tabulator-group { background: var(--soft) !important; color: var(--fg); }
button.exp { border: none; background: none; padding: 0 2px; font-size: 16px; line-height: 1; cursor: pointer; color: var(--accent); }
.pdot, .rdot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 2px; vertical-align: middle; }
.pdot { background: #7a3fb5; }
.rdot { background: #c77700; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--bg); border-left: 1px solid var(--line);
  box-shadow: -4px 0 16px rgba(0,0,0,.12); z-index: 40; overflow-y: auto; padding: 12px 16px; }
.drawer-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.drawer h3 { font-size: 14px; margin: 12px 0 6px; }
.review { background: var(--notice); padding: 8px; border-radius: 6px; }
.modal, .palette, .sheet { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; display: flex; align-items: flex-start; justify-content: center; }
.modal[hidden], .palette[hidden], .sheet[hidden], .drawer[hidden], .toast[hidden] { display: none; }
.modal-box { background: var(--bg); margin-top: 6vh; padding: 16px; border-radius: 8px; width: min(900px, calc(100vw - 32px)); max-height: 84vh; overflow: auto; }
.modal-actions { margin-top: 12px; display: flex; gap: 8px; }
tr.err td { color: var(--red); }
tr.same td { color: var(--muted); }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: #1b1d21; color: #fff; padding: 8px 14px; border-radius: 6px; z-index: 60; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--red); }
.palette-box { background: var(--bg); margin-top: 10vh; width: min(640px, calc(100vw - 32px)); border-radius: 8px; overflow: hidden; }
.palette-box input { width: 100%; border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: 12px; font-size: 16px; }
#palette-list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow-y: auto; }
#palette-list li { padding: 8px 12px; cursor: pointer; }
#palette-list li.on { background: var(--soft); }
#palette-list li.disabled { color: var(--muted); cursor: default; }
#palette-list .k { display: inline-block; min-width: 88px; font-size: 12px; color: var(--muted); }
.sheet { align-items: flex-end; }
.sheet-box { background: var(--bg); width: 100%; padding: 12px 16px 20px; border-radius: 12px 12px 0 0; }
.sheet-box .opt { display: block; width: 100%; text-align: left; margin: 6px 0; padding: 12px; font-size: 16px; }
.sheet-box .opt.on { border-color: var(--accent); font-weight: 600; }
.cards { display: flex; flex-direction: column; gap: 8px; }
.card-row { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.card-row .t { font-weight: 600; }
.card-row .o, .card-row .m { font-size: 13px; color: var(--muted); }
.card-row .n { font-size: 13px; margin-top: 4px; }
.card-row .st { margin: 6px 0; padding: 8px 12px; font-size: 15px; }
.card-row.overdue { border-color: var(--red); }
.kanban { overflow-x: auto; }
.kb-head, .kb-lane { display: grid; gap: 6px; min-width: max-content; }
.kb-head { position: sticky; top: 0; background: var(--bg); z-index: 2; }
.kb-col { font-weight: 600; font-size: 13px; padding: 6px; background: var(--soft); border-radius: 6px; }
.kb-lane { margin-top: 6px; }
.kb-lane-title { font-weight: 600; font-size: 13px; padding: 6px; }
.kb-cell { min-height: 48px; max-height: 360px; overflow-y: auto; background: var(--soft); border-radius: 6px; padding: 4px; display: flex; flex-direction: column; gap: 4px; }
.kb-card { overflow-wrap: anywhere; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px; font-size: 13px; cursor: grab; }
.kb-card.overdue { border-color: var(--red); }
.merge { margin: 12px 0; }
tr.overdue td { color: var(--red); }

/* организация: таргеты внутри строки */
.subrows { padding: 2px 8px 6px 76px; font-size: 12px; white-space: normal; }
.subrows .sub { padding: 1px 0; }
.subrows .sub.paused { color: var(--muted); }
.card-row .subrows { padding: 4px 0 0; }
/* канбан: одинаковая ширина колонок во всех дорожках */
.kb-card a + * { overflow-wrap: anywhere; }
