/* PM Board — «синька»: тёмно-синяя чертёжная навигация и холст схем,
   спокойная каменная рабочая область для текста и таблиц. */

:root {
  --bg: #ECEEE9;
  --surface: #FFFFFF;
  --surface-2: #F5F6F3;
  --ink: #18222D;
  --muted: #5B6570;
  --line: #D6DAD2;
  --line-strong: #B9C0B7;
  --accent: #1F5A8F;
  --accent-hover: #174A78;
  --accent-soft: #E1EAF3;
  --amber: #9A640C;
  --amber-soft: #FBEFD4;
  --red: #B23A3A;
  --red-soft: #F8E3E1;
  --green: #2C7655;
  --green-soft: #DFF0E7;
  --side-bg: #143D66;
  --side-ink: #D6E8FA;
  --side-muted: #8FB3D6;
  --side-hover: rgba(214, 232, 250, .09);
  --focus: #F2C14E;

  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SFMono-Regular", ui-monospace, Menlo, monospace;

  --r-sm: 6px;
  --r: 10px;
  --side-w: 248px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11171E;
    --surface: #18212B;
    --surface-2: #1D2732;
    --ink: #E3E9EF;
    --muted: #97A3AF;
    --line: #2A3643;
    --line-strong: #3B4957;
    --accent: #78AEE0;
    --accent-hover: #93C0EA;
    --accent-soft: #1E3247;
    --amber: #E4B25A;
    --amber-soft: #3A2E17;
    --red: #EE8D86;
    --red-soft: #3E2222;
    --green: #74CCA3;
    --green-soft: #183328;
    --side-bg: #0D2A47;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14px/1.5 var(--font);
  color: var(--ink);
  background: var(--bg);
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
}
h1, h2, h3 { margin: 0; line-height: 1.25; font-family: var(--font-display); }
h1 { font-size: 26px; font-weight: 650; letter-spacing: -.012em; }
h2 { font-size: 16px; font-weight: 620; }
h3 { font-size: 14px; font-weight: 620; }
p { margin: 0 0 .6em; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: .93em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- Боковая панель ---------- */

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background-color: var(--side-bg);
  /* Сетка чертежа — тот же мотив, что и на холсте схем. */
  background-image:
    linear-gradient(rgba(214, 232, 250, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(214, 232, 250, .05) 1px, transparent 1px);
  background-size: 20px 20px;
  color: var(--side-ink);
  padding: 16px 12px 12px;
  z-index: 30;
}
.brand { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 16px; }
.brand-link { display: flex; gap: 10px; align-items: center; color: inherit; text-decoration: none; font: 650 17px var(--font-display); letter-spacing: -.01em; }
.sidebar .menu-toggle { display: none; color: var(--side-ink); }

.search { position: relative; margin-bottom: 14px; }
.search input {
  width: 100%; padding: 8px 30px 8px 11px;
  background: rgba(6, 22, 40, .45); border: 1px solid rgba(214, 232, 250, .18); border-radius: var(--r-sm);
  color: var(--side-ink);
}
.search input::placeholder { color: var(--side-muted); }
.search input:focus { outline: none; border-color: var(--focus); }
.search input:not(:placeholder-shown) + kbd { display: none; }
.search kbd { position: absolute; right: 8px; top: 7px; font: 11px var(--mono); color: var(--side-muted); border: 1px solid rgba(214, 232, 250, .25); border-radius: 4px; padding: 0 5px; }
#search-results {
  position: absolute; left: 0; top: calc(100% + 6px); width: min(420px, 86vw); z-index: 40;
  list-style: none; margin: 0; padding: 6px; max-height: 70vh; overflow: auto;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 12px 32px rgba(10, 30, 50, .22);
}
#search-results a { display: grid; grid-template-columns: 72px 1fr; column-gap: 8px; padding: 7px 8px; border-radius: var(--r-sm); color: inherit; text-decoration: none; }
#search-results [aria-selected="true"] a, #search-results a:hover { background: var(--accent-soft); }
.sr-kind { grid-row: span 2; color: var(--muted); font-size: 12px; padding-top: 1px; }
.sr-title { font-weight: 600; display: flex; align-items: center; gap: 6px; min-width: 0; }
.sr-sub { color: var(--muted); font-size: 12.5px; }
.sr-none { padding: 10px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--r-sm);
  color: var(--side-ink); text-decoration: none;
}
.nav-link:hover { background: var(--side-hover); }
.nav-link[aria-current] { background: rgba(214, 232, 250, .16); box-shadow: inset 3px 0 0 var(--focus); }
.nav-link[data-status="done"] .nav-name, .nav-link[data-status="paused"] .nav-name { opacity: .62; }
.nav-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-link .count { font: 11.5px var(--mono); color: var(--side-muted); }
.nav-section { display: flex; align-items: center; justify-content: space-between; margin: 18px 4px 4px 10px; }
.nav-section h2 { font: 600 12.5px var(--font); color: var(--side-muted); }
.nav-section .icon-btn { color: var(--side-ink); }
.project-nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.nav-empty { padding: 6px 10px; color: var(--side-muted); font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 2.5px; flex: none; display: inline-block; }
.sidebar .dot { box-shadow: 0 0 0 1.5px rgba(214, 232, 250, .35); }
.sidebar-foot { display: flex; align-items: center; gap: 4px; padding: 8px 4px 0; border-top: 1px solid rgba(214, 232, 250, .14); margin-top: 8px; }
.sidebar-foot .icon-btn { color: var(--side-muted); }
.me {
  flex: 1; min-width: 0; text-align: left; border: 0; background: transparent; color: var(--side-ink);
  padding: 7px 8px; border-radius: var(--r-sm); cursor: pointer; font-weight: 560;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.me:hover { background: var(--side-hover); }
.env-badge { font: 700 10.5px var(--mono); letter-spacing: .04em; color: #143D66; background: var(--focus); border-radius: 4px; padding: 1px 5px; }

/* ---------- Кнопки и поля ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 560; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
@media (prefers-color-scheme: dark) { .btn-primary, .btn-primary:hover { color: #0C1B2B; } }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); border-color: transparent; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.92); background: var(--red); border-color: var(--red); }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--red); margin-right: auto; }
.btn-danger-ghost:hover { background: var(--red-soft); border-color: transparent; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted);
  font-size: 18px; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.sidebar .icon-btn:hover { background: var(--side-hover); color: #fff; }
.link { border: 0; padding: 0; background: none; color: var(--accent); cursor: pointer; text-align: left; font-weight: 600; }
.link:hover { text-decoration: underline; }

input, select, textarea {
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); padding: 7px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
textarea { resize: vertical; line-height: 1.5; }
.form { display: flex; flex-wrap: wrap; gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 100%; }
.field.half { flex: 1 1 calc(50% - 7px); min-width: 180px; }
.field > span, .roles-edit .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field .hint { color: var(--muted); }
.form-error { flex-basis: 100%; color: var(--red); background: var(--red-soft); padding: 8px 10px; border-radius: var(--r-sm); margin: 0; }
.check { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.color-opt { position: relative; width: 28px; height: 28px; border-radius: 7px; background: var(--c); cursor: pointer; }
.color-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.color-opt:has(input:checked) { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.color-opt:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 4px; }

.roles-edit { flex-basis: 100%; display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px dashed var(--line-strong); border-radius: var(--r-sm); }
.roles-edit .btn { align-self: flex-start; }
.role-row { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr 28px; gap: 6px; align-items: center; }

/* ---------- Основная область ---------- */

main { padding: 28px clamp(16px, 3vw, 40px) 48px; min-width: 0; outline: none; }
main:focus, main:focus-visible { outline: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.lede { color: var(--muted); margin: 4px 0 0; max-width: 70ch; font-size: 15px; }

.project-head { padding-left: 16px; border-left: 4px solid var(--pc); margin-bottom: 18px; }
.ph-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.status { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--green-soft); color: var(--green); white-space: nowrap; }
.status[data-s="paused"] { background: var(--amber-soft); color: var(--amber); }
.status[data-s="done"] { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tab {
  padding: 9px 14px; color: var(--muted); text-decoration: none; font-weight: 560; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; display: flex; gap: 7px; align-items: center;
}
.tab:hover { color: var(--ink); }
.tab[aria-current] { color: var(--ink); border-bottom-color: var(--accent); }
.count { font: 12px var(--mono); color: var(--muted); }
.tab .count { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar > .muted { margin: 0; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-q { min-width: 240px; }
.chip { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 3px 12px; cursor: pointer; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.empty { text-align: center; padding: 56px 20px; border: 1px dashed var(--line-strong); border-radius: var(--r); background: var(--surface-2); }
.empty h2 { font-size: 18px; margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 52ch; margin: 0 auto 16px; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 36px)); }
.toast { display: flex; gap: 12px; align-items: center; justify-content: space-between; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--r-sm); box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.toast[data-kind="error"] { background: var(--red); color: #fff; }
.toast .btn-ghost { color: inherit; border: 1px solid currentColor; }

/* ---------- Таблицы «реестр» ---------- */

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.ledger { width: 100%; border-collapse: collapse; }
.ledger th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line-strong); background: var(--surface-2); white-space: nowrap; }
.ledger td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: baseline; }
.ledger tbody tr:last-child td { border-bottom: 0; }
.ledger .num { text-align: right; font-variant-numeric: tabular-nums; }
.ledger tbody tr:hover { background: var(--surface-2); }
.ledger.is-editing td { padding: 6px; }
.ledger.is-editing input, .ledger.is-editing select { width: 100%; }
.ledger.is-editing tbody tr:hover { background: transparent; }
.ledger.net td.mono { white-space: nowrap; }
.proj-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 620; color: var(--ink); text-decoration: none; }
.proj-name:hover { color: var(--accent); }
tr:has(.proj-name) { cursor: pointer; }
.overdue { color: var(--red); font-size: 12.5px; }
.copy { font: inherit; border: 0; background: transparent; color: var(--ink); cursor: copy; padding: 1px 4px; margin: -1px -4px; border-radius: 4px; }
.copy:hover { background: var(--accent-soft); color: var(--accent); }
.env { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); }
.env[data-e="prod"] { background: var(--green-soft); color: var(--green); border-color: transparent; }
.env[data-e="test"] { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.env[data-e="dev"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.avatar {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .02em;
}
.avatar.lg { width: 36px; height: 36px; font-size: 13px; }
.avatars { display: flex; }
.avatars .avatar { border: 2px solid var(--surface); margin-left: -6px; }
.avatars .avatar:first-child { margin-left: 0; }

.tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; text-decoration: none;
  padding: 1px 8px; border-radius: 4px; color: var(--ink); white-space: nowrap;
  background: color-mix(in srgb, var(--c, var(--muted)) 13%, var(--surface));
}
.tag::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--c, var(--muted)); flex: none; }
a.tag:hover { background: color-mix(in srgb, var(--c, var(--muted)) 24%, var(--surface)); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.due-list { list-style: none; margin: 0; padding: 0; }
.link-row { width: 100%; display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: baseline; padding: 8px 4px; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; cursor: pointer; border-radius: 0; }
.due-list li:first-child .link-row { border-top: 0; }
.link-row:hover .title { color: var(--accent); text-decoration: underline; }
.due { font: 12.5px var(--mono); color: var(--muted); white-space: nowrap; }
.due.is-late { color: var(--red); font-weight: 600; }

/* ---------- Обзор проекта ---------- */

.overview { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.ov-main, .ov-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.notes > .panel-head { margin-bottom: 12px; }
.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 10px; display: flex; flex-direction: column; min-width: 0; }
.note.is-pinned { border-color: var(--amber); box-shadow: inset 0 3px 0 var(--amber); }
.note header { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.note-tools { display: flex; align-items: center; gap: 2px; flex: none; }
.note-tools [aria-pressed="true"] { color: var(--amber); }
.note .prose { flex: 1; max-height: 260px; overflow: auto; }
.note footer { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }

.prose { max-width: 75ch; overflow-wrap: anywhere; }
.prose > :last-child { margin-bottom: 0; }
.prose h3, .prose h4, .prose h5 { margin: 1em 0 .4em; }
.prose h3 { font-size: 17px; } .prose h4 { font-size: 15px; } .prose h5 { font-size: 14px; }
.prose ul, .prose ol { margin: 0 0 .7em; padding-left: 1.3em; }
.prose li { margin: .15em 0; }
.prose code { font: .9em var(--mono); background: var(--surface-2); border: 1px solid var(--line); padding: 0 4px; border-radius: 4px; }
.prose pre { background: var(--surface-2); border: 1px solid var(--line); padding: 10px 12px; border-radius: var(--r-sm); overflow: auto; }
.prose pre code { border: 0; padding: 0; background: none; }
.prose ul.tasks { list-style: none; padding-left: 0; }
.prose ul.tasks li { display: flex; gap: 8px; align-items: baseline; }
.prose .box { display: inline-block; width: 12px; height: 12px; border: 1.5px solid var(--line-strong); border-radius: 3px; flex: none; transform: translateY(1px); }
.prose li.done { color: var(--muted); text-decoration: line-through; }
.prose li.done .box { background: var(--green); border-color: var(--green); }
.md-edit { width: 100%; font-family: var(--mono); font-size: 13.5px; margin-bottom: 10px; }

.link-list, .mini-people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.link-list li { display: grid; grid-template-columns: 1fr 28px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); column-gap: 6px; }
.link-list li:first-child { border-top: 0; }
.link-list li a { font-weight: 560; overflow-wrap: anywhere; }
.link-list li .muted { grid-column: 1; grid-row: 2; }
.link-list .icon-btn { grid-row: span 2; grid-column: 2; }
.mini-people li { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-top: 1px solid var(--line); }
.mini-people li:first-child { border-top: 0; }

/* ---------- Ответственные ---------- */

.areas { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.area { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.area h2 { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.people-list { list-style: none; margin: 0; padding: 0; }
.person { display: grid; grid-template-columns: 36px 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.person:first-child { border-top: 0; }
.person .contacts { grid-column: 2; }
.person > .btn { grid-column: 3; grid-row: 1; }
.person-name { font-size: 14.5px; }
.contacts { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 13px; }
.contacts a { text-decoration: none; }
.contacts a:hover { text-decoration: underline; }
.who { display: flex; gap: 10px; align-items: flex-start; }
.role-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.ledger.people td { padding-top: 12px; padding-bottom: 12px; }

/* ---------- Канбан ---------- */

.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; min-height: 260px; display: flex; flex-direction: column; transition: border-color .12s, background-color .12s; }
.col.is-over { border-color: var(--accent); background: var(--accent-soft); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; }
.col-head h2 { font-size: 14px; }
.col-head .icon-btn { margin-left: auto; }
.col[data-status="done"] .card h3 { color: var(--muted); }
.col-archive { background: transparent; border-style: dashed; }
.col-archive .card { opacity: .72; }
.col-archive .card:hover { opacity: 1; }
.col-hint { margin-left: auto; text-align: right; line-height: 1.25; max-width: 120px; }
.archive-more { margin-top: 8px; align-self: center; }
.col-cards { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 40px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  cursor: grab; display: flex; flex-direction: column; gap: 6px;
}
.card:hover { border-color: var(--line-strong); }
.card[data-prio="high"] { box-shadow: inset 3px 0 0 var(--amber); }
.card[data-prio="low"] h3 { font-weight: 500; }
.card.is-dragging { opacity: .4; }
.card h3 { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.card-top { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.card-top:empty { display: none; }
.card-meta { display: flex; justify-content: space-between; align-items: center; min-height: 22px; }
.card-meta .avatar { width: 22px; height: 22px; font-size: 10px; }
.prio { font-size: 11.5px; font-weight: 700; color: var(--amber); }
.prio-low { color: var(--muted); font-weight: 600; }
.card-dod { margin: 0; font-size: 12.5px; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.from-chat { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 999px; }
.bot-badge { display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 999px; vertical-align: 1px; }
.chat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.chat-list li { display: flex; justify-content: space-between; gap: 8px; }
.field.check { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; }
.field.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.field.check .hint { flex-basis: 100%; }
.drop-marker { height: 3px; border-radius: 2px; background: var(--accent); margin: -2px 0; }

/* ---------- Модальные окна ---------- */

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(12, 24, 38, .46); display: grid; place-items: start center; padding: 8vh 16px 16px; overflow-y: auto; }
.modal { width: min(480px, 100%); background: var(--surface); border-radius: 12px; box-shadow: 0 24px 60px rgba(8, 20, 34, .35); display: flex; flex-direction: column; max-height: 86vh; }
.modal-wide { width: min(680px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 0; }
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }

/* ---------- Редактор схем ---------- */

.dg-host { min-height: 560px; }
.dg { display: flex; flex-direction: column; border: 1px solid #0E2D4D; border-radius: var(--r); overflow: hidden; background: #143D66; }
.dg-bar { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.dg-add { display: flex; gap: 2px; flex-wrap: wrap; }
.dg-tool { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border: 0; background: transparent; border-radius: var(--r-sm); color: var(--ink); cursor: pointer; font-size: 13px; }
.dg-tool:hover { background: var(--accent-soft); color: var(--accent); }
.dg-actions { display: flex; gap: 2px; align-items: center; }
.dg-status { font-size: 12.5px; color: var(--muted); margin-left: 8px; min-width: 110px; text-align: right; }
.dg-status[data-kind="ok"] { color: var(--green); }
.dg-status[data-kind="error"] { color: var(--red); font-weight: 600; }
.dg-body { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 270px; height: calc(100vh - 250px); min-height: 480px; }
.dg-canvas { width: 100%; height: 100%; display: block; cursor: default; touch-action: none; user-select: none; }
.dg-canvas:focus { outline: none; }
.dg-canvas.is-panning { cursor: grabbing; }
.dg-node { cursor: move; }
.dg-node .dg-link { opacity: 0; cursor: crosshair; transition: opacity .1s; }
.dg-node:hover .dg-link, .dg-node.is-selected .dg-link { opacity: 1; }
.dg-node.is-target > rect:first-child { stroke: #F2C14E; stroke-width: 2.5; }
.dg-resize { cursor: nwse-resize; }
.dg-edge { cursor: pointer; }
.dg-edge:hover path:nth-child(2) { stroke-width: 2.4; }
.dg-empty { position: absolute; left: 50%; top: 50%; transform: translate(calc(-50% - 135px), -50%); max-width: 360px; text-align: center; color: #D6E8FA; pointer-events: none; }
.dg-empty p { margin: 0 0 6px; }
.dg-panel { background: var(--surface); border-left: 1px solid var(--line); padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.dg-panel h3 { font-size: 15px; }
.dg-panel .field { flex: none; }
.dg-panel .field input, .dg-panel .field textarea, .dg-panel .field select { width: 100%; }
.dg-panel .btn { align-self: flex-start; }
.dg-panel .btn-danger { margin-top: 4px; }
.hints { margin: 0; padding-left: 1.1em; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.swatches { display: flex; flex-direction: column; gap: 2px; }
.swatch { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border: 0; border-radius: var(--r-sm); background: transparent; cursor: pointer; font-size: 13px; text-align: left; }
.swatch::before { content: ""; width: 16px; height: 16px; border-radius: 4px; background: #143D66; box-shadow: inset 0 0 0 2.5px var(--c); }
.swatch:hover { background: var(--surface-2); }
.swatch[aria-checked="true"] { background: var(--accent-soft); font-weight: 600; }

/* ---------- Лента изменений ---------- */

.activity-panel { margin-top: 16px; }
.activity-panel h2 { margin-bottom: 8px; }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: grid; grid-template-columns: 116px 150px 1fr; gap: 12px; align-items: baseline; padding: 7px 0; border-top: 1px solid var(--line); }
.activity li:first-child { border-top: 0; }
.activity li.muted { display: block; }
.activity .who { font-weight: 600; display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.activity a { color: var(--ink); text-decoration: none; }
.activity a:hover { color: var(--accent); text-decoration: underline; }
.via { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 5px; }

/* ---------- Страница входа ---------- */

.login-page {
  display: block;
  background-color: var(--side-bg);
  background-image:
    linear-gradient(rgba(214, 232, 250, .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(214, 232, 250, .06) 1px, transparent 1px),
    linear-gradient(rgba(214, 232, 250, .1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(214, 232, 250, .1) 1px, transparent 1px);
  background-size: 20px 20px, 20px 20px, 100px 100px, 100px 100px;
}
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(380px, 100%); background: var(--surface); border-radius: 12px; padding: 28px 28px 22px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 24px 60px rgba(4, 16, 30, .45);
}
.login-brand { display: flex; gap: 14px; align-items: center; color: var(--accent); margin-bottom: 6px; }
.login-brand h1 { font-size: 22px; color: var(--ink); }
.login-brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.login-card .field input { padding: 9px 11px; font-size: 15px; }
.login-submit { padding: 10px 14px; font-size: 15px; margin-top: 4px; }
.login-hint { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; text-align: center; }

/* ---------- Адаптивность ---------- */

@media (max-width: 1100px) {
  .overview { grid-template-columns: 1fr; }
  .dg-body { grid-template-columns: 1fr; height: auto; }
  .dg-canvas { height: 60vh; }
  .dg-panel { border-left: 0; border-top: 1px solid var(--line); }
  .dg-empty { transform: translate(-50%, -50%); top: 30vh; }
}
@media (max-width: 860px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: sticky; height: auto; max-height: 100vh; z-index: 50; padding: 10px 12px; }
  .brand { padding-bottom: 0; }
  .sidebar .menu-toggle { display: inline-grid; }
  .sidebar .search, .sidebar .nav, .sidebar-foot { display: none; }
  body.nav-open .sidebar .search, body.nav-open .sidebar .nav { display: flex; }
  body.nav-open .sidebar .search { display: block; margin-top: 12px; }
  body.nav-open .sidebar .sidebar-foot { display: flex; }
  .split { grid-template-columns: 1fr; }

  .activity li { grid-template-columns: 1fr; gap: 2px; }
  .kanban { grid-template-columns: repeat(4, 82vw); scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
  .areas { grid-template-columns: 1fr; }
  .filter-q { min-width: 0; width: 100%; }
  main { padding-top: 20px; }
  h1 { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
