:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #dfe3e8;
  --text: #1c2530;
  --muted: #6b7684;
  --accent: #1f4e79;
  --green: #1e7d43;
  --green-bg: #e6f4ea;
  --red: #b3261e;
  --red-bg: #fdecea;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  height: 56px;
  background: var(--accent);
  color: #fff;
  flex-wrap: wrap;
}
.topbar .brand { color: #fff; font-weight: 600; font-size: 17px; }
.topbar nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.topbar nav a { color: #dce8f5; }
.topbar nav a:hover { color: #fff; text-decoration: none; }
.topbar .who { color: #9fc0e0; font-size: 14px; }
.topbar .exit { color: #ffd9d6; }

main { max-width: 1200px; margin: 0 auto; padding: 24px; }

h1 { font-size: 22px; margin: 0 0 4px; font-weight: 600; }
h2 { font-size: 17px; margin: 28px 0 10px; font-weight: 600; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.muted { color: var(--muted); font-size: 14px; }

/* кнопки */
.button, button {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.button:hover, button:hover { background: #eef1f4; text-decoration: none; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover { background: #17395a; }

/* карточки */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 18px;
}

/* сводка */
.stats { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.stat {
  flex: 1 1 140px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
}
.stat .num { font-size: 26px; font-weight: 600; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat.red .num { color: var(--red); }
.stat.green .num { color: var(--green); }

/* таблицы */
table.grid {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
table.grid th, table.grid td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.grid th {
  background: #eef1f4;
  font-weight: 600;
  font-size: 13px;
  color: #46505c;
  white-space: nowrap;
}
table.grid tr:last-child td { border-bottom: none; }
table.grid.small th, table.grid.small td { padding: 7px 10px; font-size: 13px; }
.num-cell { text-align: right; white-space: nowrap; }

tr.row-overdue td { background: var(--red-bg); }
tr.row-done td { background: var(--green-bg); }

/* статусы */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 11px;
  font-size: 12px;
  background: #eef1f4;
  color: #46505c;
  white-space: nowrap;
}
.st-в-работе { background: #e3eefb; color: #1f4e79; }
.st-выполнен { background: var(--green-bg); color: var(--green); }
.st-просрочен { background: var(--red-bg); color: var(--red); }
.st-приостановлен { background: #fff4e0; color: #8a5a00; }
.st-отменён { background: #eceff1; color: #6b7684; }

/* формы */
.form label { display: block; margin-bottom: 14px; font-size: 14px; color: #46505c; }
.form input, .form select, .form textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: 2px solid #b9d3ea;
  border-color: var(--accent);
}
.form .row { display: flex; gap: 16px; flex-wrap: wrap; }
.form .row label { flex: 1 1 220px; }
.form.narrow { max-width: 420px; }
.checks { margin-bottom: 16px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.check input { width: auto; margin: 0; }

/* сообщения */
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert.error { background: var(--red-bg); color: var(--red); border: 1px solid #f3c9c5; }
.alert.ok { background: var(--green-bg); color: var(--green); border: 1px solid #c3e3cd; }

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

/* свойства */
.props { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; margin: 0; }
.props dt { color: var(--muted); font-size: 14px; }
.props dd { margin: 0; }

/* вход */
.login-box {
  max-width: 360px;
  margin: 80px auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px;
}
.login-box h1 { font-size: 20px; margin-bottom: 2px; }
.login-box form { margin-top: 20px; }
.login-box label { display: block; margin-bottom: 14px; font-size: 14px; color: #46505c; }
.login-box input {
  display: block; width: 100%; margin-top: 5px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: 6px; font-size: 15px;
}
.login-box button { width: 100%; padding: 10px; }

@media (max-width: 700px) {
  main { padding: 14px; }
  .topbar { height: auto; padding: 10px 14px; }
  .topbar nav { gap: 12px; font-size: 14px; }
  table.grid th, table.grid td { padding: 8px; font-size: 13px; }
  .props { grid-template-columns: 1fr; }
  .props dt { margin-top: 8px; }
}

/* ---- этапы ---- */
.progress {
  height: 8px;
  background: #e6eaee;
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0 18px;
}
.progress-bar {
  height: 100%;
  background: var(--green);
  transition: width .3s;
}

table.stages td { vertical-align: middle; }
.sub-cell { padding-left: 30px !important; }
.tree { color: #b6bfc9; margin-right: 6px; }
.deps { font-size: 12px; color: var(--muted); margin-top: 3px; }
.dep-wait { color: var(--red); }
.nowrap { white-space: nowrap; }

td.actions {
  white-space: nowrap;
  text-align: right;
}
td.actions form { display: inline; }

.mini {
  display: inline-block;
  padding: 4px 9px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  margin-left: 4px;
}
.mini:hover { background: #eef1f4; text-decoration: none; }
.mini.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.mini.primary:hover { background: #17395a; }
.mini.danger { color: var(--red); border-color: #f0cfcc; }
.mini.danger:hover { background: var(--red-bg); }

@media (max-width: 700px) {
  td.actions { text-align: left; }
  .mini { margin: 2px 4px 2px 0; }
  .sub-cell { padding-left: 18px !important; }
}

/* ---- поле с кнопкой над списком ---- */
.field { margin-bottom: 14px; }
.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 14px;
  color: #46505c;
}
.field-head .mini { margin-left: 0; }

/* ---- список чекбоксов ---- */
.check-list {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  max-height: 260px;
  overflow-y: auto;
}
.form .check {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
}
.form .check:last-child { margin-bottom: 0; }
.form .check input[type=checkbox] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

/* ---- кнопки в шапке карточки ---- */
.head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.head-actions form { display: inline; }
