:root {
  --green: #33493a;
  --green-dark: #24342a;
  --green-soft: #e4ebe4;
  --ivory: #f4efe6;
  --paper: #fbf9f5;
  --ink: #1f2a22;
  --muted: #6b766d;
  --line: #e2ddd2;
  --card: #ffffff;
  --shadow: 0 1px 2px rgba(20, 30, 22, .08), 0 4px 14px rgba(20, 30, 22, .06);
  --shadow-lg: 0 20px 60px rgba(10, 20, 14, .35);
  --radius: 12px;

  --p-low: #8a9a8c;
  --p-normal: #5b7a8c;
  --p-high: #c98a2b;
  --p-urgent: #b84a3a;

  --serif: 'Cormorant Garamond', 'Georgia', serif;
  --sans: 'Manrope', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--ivory);
  display: flex;
  flex-direction: column;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Верхняя панель ---------- */
.topbar {
  height: 64px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--green);
  color: #fff;
  position: relative;
  z-index: 20;
  box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 6px 20px rgba(0,0,0,.15);
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand img { width: 42px; height: 42px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255,255,255,.15); }
.brand-text { font-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: .04em; line-height: 1; text-transform: uppercase; }
.brand-text small { display: block; font-family: var(--sans); font-size: 10.5px; letter-spacing: .18em; opacity: .7; margin-top: 3px; font-weight: 500; }
.topbar-board { display: flex; align-items: center; gap: 14px; min-width: 0; }
.divider { width: 1px; height: 30px; background: rgba(255,255,255,.2); }
.board-title-input {
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  color: #fff; font-family: var(--serif); font-size: 24px; font-weight: 600;
  padding: 2px 8px; min-width: 120px; width: 26ch; max-width: 40vw;
}
.board-title-input:hover { background: rgba(255,255,255,.08); }
.board-title-input:focus { outline: none; background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.3); }
.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.1); border-radius: 999px; padding: 0 14px; height: 36px;
  border: 1px solid rgba(255,255,255,.12);
}
.search svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; opacity: .7; }
.search input { background: none; border: 0; outline: none; color: #fff; width: 240px; }
.search input::placeholder { color: rgba(255,255,255,.6); }
.topbar select {
  height: 36px; border-radius: 999px; padding: 0 12px;
  background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.12);
}
.topbar select option { color: var(--ink); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: rgba(255,255,255,.1); color: #fff;
}
.icon-btn:hover { background: rgba(255,255,255,.2); }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }

main { flex: 1; min-height: 0; position: relative; }

/* ---------- Фоны ---------- */
.bg-green    { background: #2f4436 url(/assets/bg-green.png) center / cover; }
.bg-oak      { background: #cdb48f url(/assets/bg-oak.png) center / cover; }
.bg-plaster  { background: #ece4d6 url(/assets/bg-plaster.png) center / cover; }
.bg-workshop { background: #26302a url(/assets/bg-workshop.png) center / cover; }

/* ---------- Главная: список досок ---------- */
.home {
  height: 100%; overflow: auto;
  background: linear-gradient(90deg, rgba(36,52,42,.92) 0%, rgba(36,52,42,.7) 45%, rgba(36,52,42,.25) 100%),
              #2f4436 url(/assets/hero.png) center / cover fixed;
  color: #fff;
}
.home-inner { max-width: 1180px; margin: 0 auto; padding: 56px 32px 80px; }
.home h1 { font-family: var(--serif); font-weight: 600; font-size: 54px; margin: 0; letter-spacing: .01em; line-height: 1.05; }
.home .lead { margin: 12px 0 40px; font-size: 16px; opacity: .8; max-width: 520px; line-height: 1.55; }
.boards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 22px; }
.board-tile {
  position: relative; height: 150px; border-radius: 16px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 18px; color: #fff; text-decoration: none;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); transition: transform .18s, box-shadow .18s;
  border: 1px solid rgba(255,255,255,.12);
}
.board-tile::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 20%, rgba(20,30,22,.75)); }
.board-tile > * { position: relative; }
.board-tile:hover { transform: translateY(-3px); box-shadow: 0 16px 40px rgba(0,0,0,.35); }
.board-tile h3 { margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 600; line-height: 1.1; }
.board-tile span { font-size: 12.5px; opacity: .8; margin-top: 4px; }
.board-tile.new {
  background: rgba(255,255,255,.08); border: 1.5px dashed rgba(255,255,255,.35); box-shadow: none;
  align-items: center; justify-content: center; font-size: 15px; font-weight: 600; cursor: pointer;
  backdrop-filter: blur(6px);
}
.board-tile.new::before { display: none; }
.board-tile.new:hover { background: rgba(255,255,255,.14); }

/* ---------- Доска ---------- */
.board { height: 100%; display: flex; flex-direction: column; }
.board-scroll {
  flex: 1; min-height: 0; overflow-x: auto; overflow-y: hidden;
  display: flex; align-items: flex-start; gap: 14px; padding: 20px;
}
.column {
  flex: none; width: 290px; max-height: 100%;
  display: flex; flex-direction: column;
  background: rgba(244, 239, 230, .9);
  backdrop-filter: blur(10px);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.12);
  border: 1px solid rgba(255,255,255,.5);
}
.column.dragging { opacity: .4; }
.column-head { display: flex; align-items: center; gap: 6px; padding: 12px 10px 6px 14px; cursor: grab; }
.column-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.column.done .column-head .dot { background: #4f8a5b; box-shadow: 0 0 0 3px rgba(79,138,91,.2); }
.column-title {
  flex: 1; min-width: 0; border: 1px solid transparent; background: transparent; border-radius: 6px;
  font-weight: 700; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; padding: 4px 6px;
}
.column-title:focus { outline: none; background: #fff; border-color: var(--line); text-transform: none; letter-spacing: 0; }
.column-count { font-size: 12px; color: var(--muted); background: rgba(51,73,58,.08); padding: 2px 8px; border-radius: 999px; }
.column-menu { width: 28px; height: 28px; border: 0; background: transparent; border-radius: 6px; color: var(--muted); font-size: 18px; line-height: 1; }
.column-menu:hover { background: rgba(0,0,0,.06); color: var(--ink); }
.column-sum { padding: 0 20px 6px; font-size: 12px; color: var(--muted); }
.card-list { flex: 1; min-height: 12px; overflow-y: auto; padding: 4px 10px 6px; display: flex; flex-direction: column; gap: 8px; }
.add-card { margin: 4px 10px 10px; padding: 9px 10px; border: 0; background: transparent; border-radius: 8px; color: var(--muted); text-align: left; font-weight: 600; }
.add-card:hover { background: rgba(51,73,58,.08); color: var(--green); }
.add-card-form { padding: 4px 10px 10px; }
.add-card-form textarea {
  width: 100%; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-height: 64px;
  box-shadow: var(--shadow); outline: none;
}
.add-card-form textarea:focus { border-color: var(--green); }
.form-row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }

.add-column {
  flex: none; width: 290px; padding: 14px 16px; border-radius: 14px; border: 0;
  background: rgba(255,255,255,.22); color: #fff; font-weight: 600; text-align: left;
  backdrop-filter: blur(8px); text-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.add-column:hover { background: rgba(255,255,255,.32); }
.bg-plaster .add-column, .bg-oak .add-column { background: rgba(51,73,58,.12); color: var(--green-dark); text-shadow: none; }

/* ---------- Карточка на доске ---------- */
.card {
  background: var(--card); border-radius: 10px; box-shadow: var(--shadow);
  cursor: pointer; overflow: hidden; border: 1px solid transparent; position: relative;
  transition: box-shadow .15s, transform .15s;
}
.card:hover { box-shadow: 0 2px 4px rgba(20,30,22,.1), 0 8px 20px rgba(20,30,22,.1); border-color: rgba(51,73,58,.18); }
.card.dragging { opacity: .35; transform: rotate(2deg); }
.card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--prio); }
.card[data-priority=low]    { --prio: var(--p-low); }
.card[data-priority=normal] { --prio: var(--p-normal); }
.card[data-priority=high]   { --prio: var(--p-high); }
.card[data-priority=urgent] { --prio: var(--p-urgent); }
.card-cover { height: 120px; background: #eee center / cover; }
.card-inner { padding: 10px 12px 10px 14px; }
.card-title { font-weight: 600; line-height: 1.35; word-wrap: break-word; }
.card-client { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px; background: #f1efe9; color: #4f5a52; white-space: nowrap;
}
.chip svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }
.chip.prio { color: #fff; background: var(--prio); }
.chip.overdue { background: #f8e1dc; color: #a2392a; }
.chip.soon { background: #fbefd9; color: #8d5c10; }
.chip.done { background: #dfeedd; color: #3c7046; }
.chip.amount { background: var(--green-soft); color: var(--green); }
.drop-placeholder { border-radius: 10px; background: rgba(51,73,58,.12); border: 2px dashed rgba(51,73,58,.3); flex: none; }
.column-placeholder { flex: none; width: 290px; border-radius: 14px; background: rgba(255,255,255,.18); border: 2px dashed rgba(255,255,255,.5); align-self: stretch; }
.card.hidden-by-filter { display: none; }

.empty-board {
  margin: auto; text-align: center; color: var(--ink); background: rgba(251,249,245,.92); padding: 30px 40px; border-radius: 18px;
}
.empty-board img { width: 180px; border-radius: 12px; }

/* ---------- Поповер ---------- */
.popover {
  position: fixed; z-index: 50; background: var(--paper); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 12px; min-width: 240px; border: 1px solid var(--line);
}
.popover-title { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; margin: 2px 4px 10px; }
.bg-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.bg-picker button { height: 58px; border-radius: 8px; border: 2px solid transparent; }
.bg-picker button.active { border-color: var(--green); box-shadow: 0 0 0 2px #fff inset; }
.menu-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 8px; }
.menu-item:hover { background: rgba(0,0,0,.05); }
.menu-item.danger { color: #a2392a; }

/* ---------- Кнопки и поля ---------- */
.btn { border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 600; background: #ebe7de; color: var(--ink); }
.btn:hover { background: #e0dbd0; }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); }
.btn.ghost { background: transparent; }
.btn.danger { background: #f8e1dc; color: #a2392a; }
.btn.danger:hover { background: #f2cdc5; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.link-btn { border: 0; background: none; color: var(--muted); font-size: 12.5px; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--ink); }

/* ---------- Модальное окно карточки ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(15, 22, 17, .55); backdrop-filter: blur(3px);
  overflow-y: auto; padding: 48px 16px;
}
.modal {
  position: relative; max-width: 1000px; margin: 0 auto; background: var(--paper);
  border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal-close {
  position: absolute; right: 14px; top: 12px; z-index: 3; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: rgba(255,255,255,.85); font-size: 24px; line-height: 1; color: var(--ink);
}
.modal-close:hover { background: #fff; }
.modal-cover { height: 200px; background: var(--green) center / cover; }
.modal-header { padding: 22px 28px 6px; display: flex; gap: 14px; align-items: flex-start; }
.modal-header .badge { flex: none; margin-top: 10px; width: 12px; height: 12px; border-radius: 50%; background: var(--prio); }
.modal-title {
  flex: 1; border: 1px solid transparent; background: transparent; border-radius: 8px; resize: none; overflow: hidden;
  font-family: var(--serif); font-size: 32px; font-weight: 600; line-height: 1.15; padding: 2px 6px; margin-right: 40px;
}
.modal-title:hover { background: rgba(0,0,0,.03); }
.modal-title:focus { outline: none; background: #fff; border-color: var(--line); }
.modal-sub { padding: 0 34px; color: var(--muted); font-size: 13px; }
.modal-sub b { color: var(--green); }
.modal-grid { display: grid; grid-template-columns: 1fr 290px; gap: 28px; padding: 18px 28px 28px; }
.section { margin-bottom: 26px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.section-head h4 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--green); font-weight: 700; }
.section-head .spacer { flex: 1; }
.desc {
  width: 100%; min-height: 110px; resize: vertical; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; background: #fff; line-height: 1.55; outline: none;
}
.desc:focus { border-color: var(--green); }

.side { display: flex; flex-direction: column; gap: 14px; }
.side-box { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.field input, .field select {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--paper); outline: none; width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--green); background: #fff; }
.prio-group { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.prio-group button {
  border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 7px 6px; font-size: 12.5px; font-weight: 600;
  display: flex; align-items: center; gap: 6px; justify-content: center;
}
.prio-group button i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.prio-group button.active { background: var(--c); border-color: var(--c); color: #fff; }
.prio-group button.active i { background: #fff; }
.deadline-row { display: flex; gap: 6px; }
.deadline-row input { flex: 1; }
.deadline-state { font-size: 12px; margin-top: 2px; font-weight: 600; }
.deadline-state.overdue { color: #a2392a; }
.deadline-state.soon { color: #8d5c10; }
.deadline-state.ok { color: var(--muted); }

/* Вложения */
.dropzone {
  border: 1.5px dashed #cfc8ba; border-radius: 12px; padding: 16px; text-align: center; color: var(--muted);
  background: #fff; transition: background .15s, border-color .15s;
}
.dropzone.over { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.dropzone b { color: var(--green); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.attachments { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.att {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column;
}
.att-preview { height: 104px; background: #f1eee7 center / cover; display: grid; place-items: center; cursor: pointer; position: relative; }
.att-preview video { width: 100%; height: 100%; object-fit: cover; }
.att-preview .play { position: absolute; width: 38px; height: 38px; border-radius: 50%; background: rgba(0,0,0,.55); display: grid; place-items: center; }
.att-preview .play::after { content: ''; border-left: 12px solid #fff; border-top: 8px solid transparent; border-bottom: 8px solid transparent; margin-left: 3px; }
.att-ext { font-weight: 800; font-size: 15px; letter-spacing: .06em; color: #fff; padding: 10px 12px; border-radius: 8px; background: var(--c, #7c857e); }
.att-info { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.att-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-size { font-size: 11px; color: var(--muted); }
.att-actions { display: flex; gap: 10px; padding: 0 10px 8px; flex-wrap: wrap; }
.att-actions a, .att-actions button { font-size: 11.5px; color: var(--muted); border: 0; background: none; padding: 0; text-decoration: none; }
.att-actions a:hover, .att-actions button:hover { color: var(--green); }
.att-actions .del:hover { color: #a2392a; }
.att.cover { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.upload-progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 10px; }
.upload-progress div { height: 100%; background: var(--green); width: 0; transition: width .2s; }

/* Таблица-спецификация */
.spec-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.spec { border-collapse: collapse; width: 100%; font-size: 13px; }
.spec th, .spec td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0; min-width: 90px; position: relative; }
.spec th:last-child, .spec td:last-child { border-right: 0; }
.spec tr:last-child td { border-bottom: 0; }
.spec th { background: var(--green-soft); color: var(--green-dark); font-weight: 700; text-align: left; }
.spec [contenteditable] { padding: 7px 9px; outline: none; min-height: 32px; }
.spec [contenteditable]:focus { background: #fffbe9; box-shadow: inset 0 0 0 2px var(--p-high); }
.spec .rm { width: 30px; min-width: 30px; text-align: center; border-right: 0; }
.spec .rm button { border: 0; background: none; color: #b9b2a5; font-size: 16px; padding: 4px; }
.spec .rm button:hover { color: #a2392a; }
.spec tfoot td { background: var(--paper); font-weight: 700; padding: 7px 9px; }
.spec-empty { padding: 16px; text-align: center; color: var(--muted); }

/* Активность */
.comment-form textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; resize: vertical; min-height: 44px; outline: none; background: #fff;
}
.comment-form textarea:focus { border-color: var(--green); }
.activity { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.activity li { display: flex; gap: 10px; font-size: 13px; }
.activity .av { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--green-soft); display: grid; place-items: center; color: var(--green); }
.activity .av svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.activity li.comment .av { background: var(--green); color: #fff; }
.activity .body { flex: 1; min-width: 0; }
.activity .comment-text { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; white-space: pre-wrap; word-wrap: break-word; }
.activity .time { color: var(--muted); font-size: 11.5px; margin-top: 3px; display: flex; gap: 10px; }

/* Лайтбокс */
.lightbox {
  position: fixed; inset: 0; z-index: 60; background: rgba(10,14,11,.92); display: grid; place-items: center; padding: 40px;
}
.lightbox img, .lightbox video { max-width: 100%; max-height: calc(100vh - 80px); border-radius: 8px; box-shadow: var(--shadow-lg); }
.lightbox .lb-close { position: absolute; top: 16px; right: 20px; color: #fff; background: none; border: 0; font-size: 34px; }
.lightbox .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); color: #fff; background: rgba(255,255,255,.1); border: 0; width: 48px; height: 48px; border-radius: 50%; font-size: 24px; }
.lightbox .lb-nav:hover { background: rgba(255,255,255,.2); }
.lightbox .prev { left: 20px; } .lightbox .next { right: 20px; }
.lightbox .lb-caption { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: rgba(255,255,255,.75); font-size: 13px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 70;
  background: var(--green-dark); color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 600;
}
.toast.error { background: #8f2f22; }

/* ---------- Пользователь в шапке ---------- */
.user-chip {
  display: flex; align-items: center; gap: 10px; border: 0; background: rgba(255,255,255,.08); color: #fff;
  padding: 4px 14px 4px 4px; border-radius: 999px; margin-left: 4px; text-align: left;
}
.topbar-tools[hidden] + .user-chip { margin-left: auto; }
.user-chip:hover { background: rgba(255,255,255,.16); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--ivory); color: var(--green); font-weight: 700; font-size: 13px;
}
.user-chip-text { display: flex; flex-direction: column; line-height: 1.15; }
.user-chip-text b { font-size: 13px; font-weight: 600; }
.user-chip-text small { font-size: 11px; opacity: .7; }
a.menu-item { color: inherit; text-decoration: none; }
.badge-count { background: var(--p-urgent); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: 6px; }

/* ---------- Вход / регистрация ---------- */
.auth {
  height: 100%; overflow: auto; display: flex; align-items: center; padding: 32px 16px;
  background: linear-gradient(90deg, rgba(36,52,42,.9) 0%, rgba(36,52,42,.55) 55%, rgba(36,52,42,.15) 100%),
              #2f4436 url(/assets/hero.png) center / cover;
}
.auth-card {
  width: 100%; max-width: 400px; margin-left: max(16px, 10vw); background: var(--paper); border-radius: 20px;
  padding: 34px 32px 28px; box-shadow: var(--shadow-lg);
}
.auth-card .logo { width: 84px; height: 84px; border-radius: 50%; display: block; margin-bottom: 18px; }
.auth-card h1 { font-family: var(--serif); font-size: 34px; font-weight: 600; margin: 0 0 6px; line-height: 1.1; }
.auth-card p.hint { color: var(--muted); margin: 0 0 22px; line-height: 1.5; }
.auth-card .field input { padding: 11px 12px; font-size: 15px; }
.auth-card .btn.primary { width: 100%; padding: 12px; font-size: 15px; margin-top: 6px; }
.auth-switch { margin-top: 18px; text-align: center; color: var(--muted); }
.auth-switch button { border: 0; background: none; color: var(--green); font-weight: 700; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.auth-msg { padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 13.5px; line-height: 1.45; }
.auth-msg.error { background: #f8e1dc; color: #8f2f22; }
.auth-msg.ok { background: #dfeedd; color: #2f6339; }

/* ---------- Пользователи ---------- */
.page { height: 100%; overflow: auto; background: var(--ivory); }
.page-inner { max-width: 1100px; margin: 0 auto; padding: 36px 24px 80px; }
.page h1 { font-family: var(--serif); font-size: 42px; font-weight: 600; margin: 0 0 6px; }
.page .lead { color: var(--muted); margin: 0 0 24px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .spacer { flex: 1; }
.roles-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 26px; }
.roles-legend div { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.roles-legend b { display: block; color: var(--ink); margin-bottom: 2px; }
.users-table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.users-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 12px 14px; background: var(--paper); border-bottom: 1px solid var(--line); }
.users-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.users-table tr:last-child td { border-bottom: 0; }
.users-table tr.pending td { background: #fffaf0; }
.users-table .who { display: flex; align-items: center; gap: 10px; }
.users-table .who .avatar { background: var(--green-soft); }
.users-table .who small { display: block; color: var(--muted); }
.users-table select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--paper); }
.status { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.status.active { background: #dfeedd; color: #2f6339; }
.status.pending { background: #fbefd9; color: #8d5c10; }
.status.blocked { background: #f1e1de; color: #8f2f22; }
.users-table .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.boards-access { font-size: 12.5px; color: var(--muted); max-width: 220px; }

.dialog {
  position: fixed; inset: 0; z-index: 55; background: rgba(15,22,17,.55); display: grid; place-items: center; padding: 16px;
}
.dialog-box { background: var(--paper); border-radius: 18px; padding: 24px; width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); max-height: calc(100vh - 32px); overflow: auto; }
.dialog-box h3 { font-family: var(--serif); font-size: 26px; margin: 0 0 16px; font-weight: 600; }
.dialog-box .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.check-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow: auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.field .check-row input, .check-list input { width: auto; flex: none; margin: 0; accent-color: var(--green); }
.field .check-list label, .field .check-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 500; }

/* Ограничения по правам */
.readonly .field input:disabled, .readonly .field select:disabled, .desc:read-only { background: var(--paper); color: var(--ink); cursor: default; }
.prio-group button:disabled { cursor: default; }
.activity .author { font-weight: 700; color: var(--ink); }
.activity .av { font-size: 11px; font-weight: 700; }
.role-hint { color: var(--muted); font-size: 12px; }

/* Telegram */
.dialog-text { font-size: 14px; line-height: 1.5; margin: 0 0 14px; color: var(--ink); }
.dialog-text.muted { color: var(--muted); font-size: 13px; }
.dialog-text code { background: var(--green-soft); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }
.dialog-text.steps { padding-left: 20px; }
.dialog-text.steps li { margin-bottom: 4px; }
.tg-open { display: flex; justify-content: center; text-decoration: none; margin-bottom: 12px; }
.tg-admin { display: flex; align-items: center; gap: 16px; background: #fff; border: 1px solid var(--line); border-left: 4px solid #2a9fd8; border-radius: 12px; padding: 12px 16px; margin-bottom: 20px; }
.tg-admin.error { border-left-color: var(--p-urgent); }
.tg-admin > div { flex: 1; font-size: 14px; }
.tg-admin small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; line-height: 1.45; }
.tg-mark { color: #2a8bc0; font-weight: 600; }

@media (max-width: 860px) {
  .user-chip-text { display: none; }
  .user-chip { padding: 4px; }
  .users-table .hide-sm { display: none; }
  .modal-grid { grid-template-columns: 1fr; }
  .search input { width: 140px; }
  .brand-text small { display: none; }
  .home h1 { font-size: 40px; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .brand-text { display: none; }
  .topbar-tools #priorityFilter { display: none; }
  .search input { width: 100px; }
  .board-title-input { font-size: 19px; width: 14ch; }
  .modal-backdrop { padding: 0; }
  .modal { border-radius: 0; }
  .modal-header, .modal-grid { padding-left: 16px; padding-right: 16px; }
  .modal-sub { padding: 0 22px; }
  .home-inner { padding: 36px 16px 60px; }
}
