:root {
  --navy: #12305a;
  --navy-2: #1b4780;
  --accent: #2f6fd0;
  --accent-soft: #e8f0fb;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1c2531;
  --muted: #6c7889;
  --line: #dde4ee;
  --ok: #17724a;
  --ok-soft: #e4f4ec;
  --warn: #a8630a;
  --warn-soft: #fdf1de;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(18, 48, 90, .06), 0 8px 24px rgba(18, 48, 90, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Шапка --------------------------------------------------------------- */
.topbar {
  background: linear-gradient(180deg, var(--navy-2), var(--navy));
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.brand {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .2px;
}
.brand span { color: #8fb6f0; }
.brand:hover { text-decoration: none; }

.nav { display: flex; align-items: center; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
  color: #d7e5fa;
  padding: 7px 12px;
  border-radius: 8px;
}
.nav a:hover { background: rgba(255, 255, 255, .1); text-decoration: none; }
.nav a.active { background: rgba(255, 255, 255, .16); color: #fff; font-weight: 600; }
.nav-soon {
  color: #8fa9c9;
  padding: 7px 12px;
  border: 1px dashed rgba(255, 255, 255, .25);
  border-radius: 8px;
  font-size: 13px;
}

.who { display: flex; align-items: center; gap: 12px; }
.who-link { display: flex; align-items: center; gap: 8px; color: #fff; }
.who-link:hover { text-decoration: none; }
.who-name { font-weight: 600; }
.badge-role { background: rgba(255, 255, 255, .18); color: #eaf2ff; }

/* --- Содержимое ---------------------------------------------------------- */
.page {
  max-width: 1140px;
  margin: 0 auto;
  padding: 26px 20px 40px;
  width: 100%;
  flex: 1;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.page-title { font-size: 24px; margin: 0 0 4px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-flush { padding: 0; overflow: hidden; }
.card-title { font-size: 16px; margin: 0 0 14px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }

/* --- Списки -------------------------------------------------------------- */
.ticks, .steps, .links { margin: 0; padding-left: 20px; }
.ticks li, .steps li, .links li { margin-bottom: 7px; }
.ticks { list-style: none; padding-left: 0; }
.ticks li::before {
  content: "✓";
  color: var(--ok);
  font-weight: 700;
  margin-right: 8px;
}

.facts { margin: 0; }
.facts dt { font-weight: 600; margin-top: 10px; }
.facts dt:first-child { margin-top: 0; }
.facts dd { margin: 2px 0 0; color: var(--muted); }

/* --- Таблица ------------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th {
  background: #f8fafd;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
}
.table tr:last-child td { border-bottom: none; }
.row-off { background: #fbfbfc; color: var(--muted); }
.cell-strong { font-weight: 600; }

/* --- Метки --------------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #eef1f6;
  color: #3c4757;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-off { background: var(--danger-soft); color: var(--danger); }

/* --- Формы --------------------------------------------------------------- */
.form-card { max-width: 640px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.field .hint { display: block; margin-top: 5px; color: var(--muted); font-size: 12.5px; font-style: normal; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font: inherit;
  background: #fff;
  color: var(--text);
  resize: vertical;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 208, .15);
}
.read-only {
  padding: 10px 12px;
  background: #f6f8fb;
  border: 1px dashed var(--line);
  border-radius: 9px;
  color: var(--muted);
}
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 20px; flex-wrap: wrap; }

/* --- Кнопки -------------------------------------------------------------- */
.btn {
  display: inline-block;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: #eef1f6;
  color: var(--text);
  line-height: 1.2;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn-warn { background: var(--warn-soft); color: var(--warn); border-color: #f0d9b4; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { display: block; width: 100%; }

.topbar .btn-ghost { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .25); color: #fff; }

/* --- Сообщения ----------------------------------------------------------- */
.flash {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.flash-ok { background: var(--ok-soft); border-color: #bfe3d0; color: #14563a; }
.flash-err { background: var(--danger-soft); border-color: #f3c8c4; color: #8c1d17; }

/* --- Вход ---------------------------------------------------------------- */
.login-wrap { display: flex; justify-content: center; padding-top: 30px; }
.login-card { width: 100%; max-width: 380px; }
.login-title { font-size: 20px; margin: 0 0 6px; }
.error-code { font-size: 44px; font-weight: 700; color: var(--accent-soft); text-shadow: 0 1px 0 #cfdcf0; }

/* --- Подвал -------------------------------------------------------------- */
.foot {
  max-width: 1140px;
  margin: 0 auto;
  padding: 18px 20px 26px;
  color: var(--muted);
  font-size: 13px;
  width: 100%;
}
/* --- Задачи -------------------------------------------------------------- */
.crumbs { margin-bottom: 8px; font-size: 14px; }
.crumbs a { color: var(--muted); }

.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.tab {
  padding: 9px 14px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.filters {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 16px 20px;
}
.field-inline { margin-bottom: 0; min-width: 150px; }
.field-grow { flex: 1; min-width: 200px; }
.filter-actions { display: flex; gap: 8px; }

.chip {
  display: inline-block;
  padding: 2px 8px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #24518f;
  font-size: 12px;
  font-weight: 600;
}
.chip-quiet { background: #eef1f6; color: #5b6675; }
.chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chips .chip { margin-left: 0; }

.badge-over { background: var(--danger-soft); color: var(--danger); }
.badge-soon { background: var(--warn-soft); color: var(--warn); }
.badge-quiet { background: #eef1f6; color: #5b6675; }

.status-new { background: #eef1f6; color: #4a5666; }
.status-in_progress { background: var(--accent-soft); color: #24518f; }
.status-review { background: var(--warn-soft); color: var(--warn); }
.status-done { background: var(--ok-soft); color: var(--ok); }

.prio-low { background: #f2f4f7; color: #67717f; }
.prio-normal { background: #eef1f6; color: #4a5666; }
.prio-urgent { background: var(--danger-soft); color: var(--danger); }

.row-overdue td { background: #fff7f6; }
.row-overdue .task-link { color: var(--danger); }
.task-link { font-weight: 600; }
.empty { text-align: center; padding: 34px 20px; }
.empty p { margin: 0 0 14px; color: var(--muted); }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  color: var(--text);
}
.stat:hover { text-decoration: none; border-color: #c9d8ee; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-alert { background: #fff7f6; border-color: #f3c8c4; }
.stat-alert .stat-value { color: var(--danger); }

.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.task-list li:last-child { border-bottom: none; }
.task-list li.over a { color: var(--danger); }
.task-meta { display: flex; align-items: center; gap: 8px; }

.task-head { align-items: flex-start; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.task-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}
.text { white-space: pre-wrap; overflow-wrap: anywhere; }
.aside-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

.form-wide { max-width: 900px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.comments { list-style: none; margin: 0 0 18px; padding: 0; }
.comment { padding: 14px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: none; }
.comment-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 5px; }
.comment-author { font-weight: 600; }
.comment-form { margin-top: 6px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: flex;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.timeline li:last-child { border-bottom: none; }

.files { list-style: none; margin: 0 0 18px; padding: 0; }
.files li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.files li:last-child { border-bottom: none; }
.file-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.upload-form { border-top: 1px dashed var(--line); padding-top: 16px; }

/* --- Маршрут задачи ------------------------------------------------------ */
.stages { list-style: none; margin: 0; padding: 0; }
.stage { padding: 12px 0; border-bottom: 1px solid var(--line); }
.stage:last-child { border-bottom: none; }
.stage-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stage-main { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.stage-number {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #eef1f6;
  color: #4a5666;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}
.stage-started .stage-number { background: var(--accent-soft); color: #24518f; }
.stage-done .stage-number { background: var(--ok-soft); color: var(--ok); }
.stage-title { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stage-done .stage-title { color: var(--muted); font-weight: 500; }
.stage-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.stage-badge-done { background: var(--ok-soft); color: var(--ok); }
.stage-badge-started { background: var(--accent-soft); color: #24518f; }
.stage-badge-current { background: var(--warn-soft); color: var(--warn); }
.stage-badge-queued { background: #eef1f6; color: #5b6675; }

.stage-edit-block { margin-top: 10px; }
.stage-edit-block summary,
.stage-add summary { cursor: pointer; list-style: none; display: inline-block; }
.stage-edit-block summary::-webkit-details-marker,
.stage-add summary::-webkit-details-marker { display: none; }
.stage-edit { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 12px; }
.stage-edit .field { margin-bottom: 0; min-width: 170px; }
.stage-add { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }

/* --- Личные и командные задачи ------------------------------------------- */
.chip-personal { background: var(--ok-soft); color: var(--ok); }
.chip-team { background: var(--accent-soft); color: #24518f; }
.row-personal td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.row-team td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.fieldset {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 4px 18px 16px;
  margin: 0 0 18px;
}
.fieldset legend { font-weight: 600; padding: 0 8px; }
.field-half { max-width: 320px; }
.danger { color: var(--danger); }

/* --- Доска --------------------------------------------------------------- */
.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.column {
  background: #eaeef5;
  border-radius: var(--radius);
  padding: 12px;
  min-height: 160px;
}
.column-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}
.column-count {
  background: #fff;
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.column-hint { margin: 2px 0 10px; }
.column-body { display: flex; flex-direction: column; gap: 10px; min-height: 70px; }
.column-body.drop-target {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
  border-radius: 10px;
}

.bcard {
  background: #fff;
  border-radius: 10px;
  border-left: 4px solid var(--accent);
  padding: 12px;
  box-shadow: var(--shadow);
  cursor: grab;
}
.bcard-personal { border-left-color: var(--ok); }
.bcard-team { border-left-color: var(--accent); }
.bcard-over { background: #fff7f6; }
.bcard[draggable="false"] { cursor: default; opacity: .92; }
.bcard.dragging { opacity: .45; }
.bcard-title { display: block; font-weight: 600; margin-bottom: 7px; }
.bcard-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 7px; }
.bcard-stage { margin-bottom: 7px; }
.bcard-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.column-empty { text-align: center; padding: 10px 0; }

.board-note {
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
}
.board-note-ok { background: var(--ok-soft); color: #14563a; }
.board-note-err { background: var(--danger-soft); color: #8c1d17; }

/* --- Уведомления --------------------------------------------------------- */
.bell {
  position: relative;
  font-size: 17px;
  line-height: 1;
  color: #fff;
  padding: 6px 9px;
  border-radius: 8px;
}
.bell:hover { background: rgba(255, 255, 255, .14); text-decoration: none; }
.bell-active { background: rgba(255, 255, 255, .1); }
.bell-count {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #e0574d;
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 5px;
}

.notes { list-style: none; margin: 0; padding: 0; }
.note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.note:last-child { border-bottom: none; }
.note-new { background: #f3f8ff; }
.note-body { display: flex; flex-direction: column; gap: 2px; color: var(--text); }
.note-body:hover { text-decoration: none; }
.note-text { font-weight: 600; }
.badge-new { background: var(--accent-soft); color: #24518f; }

@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar-inner { gap: 12px; }
  .nav { order: 3; width: 100%; }
  .who { margin-left: auto; }
  .table th, .table td { padding: 10px 12px; }
  .task-layout { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; gap: 0
  .table th, .table td { padding: 10px 12px; }
}
