:root {
  --navy: #14213d;
  --navy-2: #1d2f57;
  --orange: #e8741a;
  --orange-soft: #fff1e4;
  --bg: #f4f5f8;
  --card: #ffffff;
  --line: #dfe3ea;
  --text: #1b2230;
  --muted: #5d6779;
  --good: #1f7a4d;
  --good-soft: #e3f4ea;
  --warn: #b4540a;
  --bad: #b3261e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 33, 61, .08), 0 2px 8px rgba(20, 33, 61, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* вход */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--navy); }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 14px; padding: 28px 24px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 18px; color: var(--muted); }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, button:focus-visible {
  outline: 2px solid var(--orange); outline-offset: 1px;
}
.btn {
  border: 0; border-radius: 8px; padding: 10px 16px; font-weight: 600;
  background: var(--orange); color: #fff;
}
.btn:hover { filter: brightness(.95); }
.btn.ghost { background: transparent; color: var(--navy); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); }
.btn.small { padding: 6px 10px; font-size: 14px; }
.btn:disabled { opacity: .6; cursor: default; }
.error { color: var(--bad); font-size: 14px; min-height: 20px; margin: 4px 0 8px; }

/* каркас */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 14px; padding: 10px 18px; }
.topbar .brand { font-weight: 700; font-size: 18px; }
.topbar .brand b { color: var(--orange); }
.topbar .sp { flex: 1; }
.topbar .who { font-size: 14px; opacity: .85; }
.topbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.3); }
.layout { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 54px); }
.side { background: #fff; border-right: 1px solid var(--line); padding: 14px; }
.side h2 { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 6px 6px 8px; }
.proj {
  display: block; width: 100%; text-align: left; background: transparent; border: 1px solid transparent;
  border-radius: 8px; padding: 10px; margin-bottom: 4px;
}
.proj:hover { background: var(--bg); }
.proj.active { background: var(--orange-soft); border-color: #f5cfa8; }
.proj .t { font-weight: 600; display: block; }
.proj .s { font-size: 13px; color: var(--muted); display: block; }
.bar { height: 6px; border-radius: 3px; background: var(--line); margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--good); }
.proj .n { font-size: 12px; color: var(--muted); margin-top: 4px; display: block; }
.main { padding: 18px; min-width: 0; }
.main-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.main-head h1 { margin: 0; font-size: 22px; }
.main-head .sub { color: var(--muted); }
.main-head .sp { flex: 1; }

/* доска */
.board { display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)); gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 8px; }
.col { background: #e9ecf2; border-radius: var(--radius); padding: 10px; min-height: 120px; }
.col.over { outline: 2px dashed var(--orange); }
.col-head { display: flex; align-items: center; gap: 8px; margin: 2px 4px 10px; font-weight: 700; }
.col-head .cnt { font-weight: 600; font-size: 13px; background: #fff; border-radius: 10px; padding: 1px 8px; color: var(--muted); }
.col-head .add { margin-left: auto; width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line); background: #fff; font-size: 18px; line-height: 1; }
.col[data-col="wait"] .col-head { color: var(--warn); }
.col[data-col="done"] .col-head { color: var(--good); }
.card {
  background: var(--card); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow);
  border: 1px solid transparent; cursor: pointer; text-align: left; width: 100%; display: block;
}
.card:hover { border-color: #f5cfa8; }
.card.dragging { opacity: .4; }
.card .ttl { display: block; font-weight: 600; margin-bottom: 4px; overflow-wrap: anywhere; }
.card .meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.chip { background: var(--bg); border-radius: 6px; padding: 1px 7px; }
.chip.late { background: #fde8e6; color: var(--bad); }
.chip.proj-chip { background: var(--orange-soft); color: var(--warn); }

/* лента */
.feed { margin-top: 22px; background: #fff; border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.feed h2 { margin: 0 0 8px; font-size: 16px; }
.feed ul { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.feed li:first-child { border-top: 0; }
.feed .at { color: var(--muted); min-width: 110px; }
.empty { color: var(--muted); padding: 8px 4px; font-size: 14px; }

/* окно задачи */
.modal-back { position: fixed; inset: 0; background: rgba(20, 33, 61, .55); display: grid; place-items: start center; padding: 24px 12px; overflow-y: auto; z-index: 10; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 640px; padding: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal h2 { margin: 0 0 12px; font-size: 20px; overflow-wrap: anywhere; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.modal .actions .sp { flex: 1; }
.body-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 12px; }
.sect { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.sect h3 { margin: 0 0 8px; font-size: 15px; }
.cm { background: var(--bg); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.cm .by { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.cm .by b { color: var(--text); }
.cm p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.hist { font-size: 13px; color: var(--muted); margin: 0; padding-left: 18px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; overflow-x: auto; padding: 10px; }
  .side h2 { display: none; }
  .proj { min-width: 200px; margin: 0; }
  .board { grid-template-columns: repeat(4, 82vw); scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
  .row { grid-template-columns: 1fr; }
  .topbar .who { display: none; }
}
