:root {
  --green: #2E7D5B;
  --green-dark: #24634a;
  --green-soft: #e3efe8;
  --gold: #F0A500;
  --gold-soft: #fdf1d3;
  --ink: #16281E;
  --ink-soft: #4d5c53;
  --muted: #7d8a82;
  --paper: #F6F4ED;
  --card: #ffffff;
  --line: #e2ded2;
  --line-strong: #cfc9b8;
  --red: #C4513D;
  --red-soft: #f9e3df;
  --blue: #3B6FD4;
  --shadow: 0 1px 2px rgba(22, 40, 30, .08), 0 4px 14px rgba(22, 40, 30, .06);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
[hidden] { display: none !important; }
h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 19px; margin: 0; }
h3 { font-size: 16px; margin: 0 0 10px; }
p { margin: 0 0 8px; }
a { color: var(--green); }
input, select, textarea, button { font: inherit; color: inherit; }
input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="password"],
input:not([type]), select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  outline: none;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 3px solid rgba(46, 125, 91, .35);
  outline-offset: 1px;
}
textarea { resize: vertical; line-height: 1.45; }
label { font-size: 13.5px; font-weight: 600; color: var(--ink-soft); display: block; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; color: var(--ink); font-size: 15.5px; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 16px;
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: #fff; color: var(--ink); font-weight: 600; cursor: pointer;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { background: #fbfaf6; border-color: #b8b19c; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); }
.btn.danger { color: var(--red); border-color: #e7c3bc; }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.btn.big { min-height: 48px; font-size: 17px; }
.btn.toggle.on { background: var(--green-soft); border-color: var(--green); color: var(--green-dark); }
.link { background: none; border: none; color: var(--green); cursor: pointer; padding: 6px 4px; font-weight: 600; }
.link:hover { text-decoration: underline; }
.icon-btn { background: none; border: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); width: 42px; height: 42px; border-radius: 9px; }
.icon-btn:hover { background: var(--paper); color: var(--ink); }

/* ---------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -0.01em; }
.brand.big { font-size: 26px; justify-content: center; margin-bottom: 6px; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--green); position: relative; flex: none; }
.logo::before { content: ""; position: absolute; left: 5px; top: 6px; width: 4px; height: 14px; border-radius: 2px; background: var(--paper); box-shadow: 6px 0 0 0 var(--paper), 12px 0 0 0 var(--gold); }
.logo::after { content: ""; position: absolute; left: 11px; top: 14px; width: 4px; height: 6px; background: var(--green); box-shadow: 6px -3px 0 0 var(--green); }
.tabs { display: flex; gap: 4px; }
.tabs button {
  min-height: 40px; padding: 6px 14px; border: none; border-radius: 9px; background: none;
  font-weight: 600; color: var(--ink-soft); cursor: pointer;
}
.tabs button:hover { background: var(--paper); color: var(--ink); }
.tabs button.on { background: var(--green-soft); color: var(--green-dark); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.me { display: flex; align-items: center; gap: 8px; }

/* ---------- avatars, chips */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--muted); color: #fff; font-weight: 700; font-size: 13.5px; letter-spacing: .02em;
}
.avatar.sm { width: 28px; height: 28px; font-size: 12.5px; }
.avatar.none { background: #fff; color: var(--muted); border: 1.5px dashed var(--line-strong); }
.key { font-size: 13.5px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.pts { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 24px; padding: 0 7px; border-radius: 12px; background: var(--paper); border: 1px solid var(--line); font-size: 13.5px; font-weight: 700; color: var(--ink-soft); }
.label { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--green-soft); color: var(--green-dark); font-size: 13.5px; font-weight: 600; }
.labels { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.flag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--red-soft); color: var(--red); font-size: 13.5px; font-weight: 700; }
.prio { font-size: 13.5px; font-weight: 700; text-transform: capitalize; }
.prio-high .prio { color: #b07700; }
.prio-urgent .prio { color: var(--red); }
.count { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.chip {
  min-height: 36px; padding: 4px 12px; border-radius: 18px; border: 1px solid var(--line-strong);
  background: #fff; cursor: pointer; font-weight: 600; font-size: 14px;
}
.chip:hover:not(:disabled) { border-color: var(--green); color: var(--green-dark); }
.chip.on { background: var(--green); border-color: var(--green); color: #fff; }
.chip:disabled { cursor: default; }
.cc { font-size: 13.5px; color: var(--muted); font-weight: 600; }

/* ---------- popover tips: no native title attributes */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 5px 9px; border-radius: 6px;
  font-size: 13.5px; font-weight: 500; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .12s; z-index: 30;
}
[data-tip]:hover::after, [data-tip]:has(:focus-visible)::after, [data-tip]:focus-visible::after { opacity: 1; }

/* ---------- layout */
main { padding: 22px 20px 60px; max-width: 1500px; margin: 0 auto; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-head .count { margin-left: auto; }
.hint { color: var(--muted); font-size: 14px; }
.empty { text-align: center; padding: 60px 20px; max-width: 480px; margin: 40px auto; }
.empty p { color: var(--ink-soft); margin-bottom: 18px; }
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.head-actions input[type="search"] { width: 200px; }
.spacer { flex: 1; }

/* ---------- sprint header on the board */
.sprint-head { display: flex; align-items: flex-start; gap: 24px; flex-wrap: wrap; margin-bottom: 16px; }
.sprint-head h1 { margin-bottom: 2px; }
.goal { color: var(--ink-soft); font-size: 16px; }
.dates { color: var(--muted); font-size: 14px; margin: 0; }
.dates strong { color: var(--green-dark); }
.dates strong.over { color: var(--red); }
.progress-wrap { min-width: 220px; flex: 1; max-width: 360px; padding-top: 8px; }
.progress { height: 12px; border-radius: 6px; background: #e8e4d8; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--green), #4aa77f); border-radius: 6px; transition: width .3s; }
.progress-label { font-size: 13.5px; color: var(--ink-soft); font-weight: 600; margin-top: 6px; }
.sprint-head .head-actions { margin-left: auto; }

/* ---------- board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.column { background: #edeae0; border-radius: var(--radius); padding: 10px; min-height: 60vh; display: flex; flex-direction: column; }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 10px; font-weight: 700; }
.lane { flex: 1; min-height: 80px; display: flex; flex-direction: column; gap: 8px; border-radius: 9px; transition: background .12s; }
.lane.over { background: rgba(46, 125, 91, .08); }
.card {
  background: var(--card); border-radius: 10px; padding: 10px 12px 10px 14px;
  box-shadow: 0 1px 2px rgba(22, 40, 30, .1); cursor: grab; border-left: 4px solid var(--line-strong);
  user-select: none;
}
.card:hover { box-shadow: 0 2px 8px rgba(22, 40, 30, .16); }
.card:active { cursor: grabbing; }
.card.dragging, .row.dragging { opacity: .4; }
.card.prio-high, .row.prio-high .prio-dot { border-left-color: var(--gold); }
.card.prio-urgent, .row.prio-urgent .prio-dot { border-left-color: var(--red); }
.card.prio-medium { border-left-color: #a9c7f1; }
.card.blocked { background: #fff8f6; }
.card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.card-title { font-weight: 600; margin-bottom: 8px; line-height: 1.35; }
.card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card .meta { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
.placeholder { height: 46px; border: 2px dashed var(--green); border-radius: 10px; background: rgba(46, 125, 91, .06); }
.list .placeholder { height: 44px; }
.add-inline { min-height: 42px; border: 1.5px dashed var(--line-strong); border-radius: 10px; background: none; color: var(--ink-soft); font-weight: 600; cursor: pointer; }
.add-inline:hover { border-color: var(--green); color: var(--green-dark); background: rgba(255, 255, 255, .5); }

/* ---------- backlog lists */
.backlog-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.backlog-head h1 { margin: 0; }
.quick-add { display: flex; gap: 8px; flex: 1; min-width: 280px; max-width: 640px; }
.quick-add input { flex: 1; }
.list { display: flex; flex-direction: column; gap: 6px; }
.row {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 10px 6px 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 9px; cursor: grab;
}
.row:hover { border-color: var(--line-strong); box-shadow: 0 1px 4px rgba(22, 40, 30, .1); }
.row.blocked { background: #fff8f6; }
.list.static .row { cursor: pointer; }
.grip { color: #c9c3b3; font-size: 15px; letter-spacing: -3px; padding: 0 2px; }
.row-title { flex: 1; font-weight: 600; min-width: 140px; }
.prio-dot { width: 10px; height: 10px; border-radius: 50%; border: 5px solid #c9d8ee; flex: none; }
.row.prio-low .prio-dot { border-color: #d6d2c4; }
.row.prio-high .prio-dot { border-color: var(--gold); }
.row.prio-urgent .prio-dot { border-color: var(--red); }
.lane-empty { padding: 18px; text-align: center; color: var(--muted); border: 1.5px dashed var(--line-strong); border-radius: 9px; }
.plan { border-color: #cfe3d8; background: #f8fbf9; }
.plan .panel-head > div:first-child { flex: 1; min-width: 240px; }
.inline-title { font-size: 20px; font-weight: 800; border-color: transparent; background: transparent; padding-left: 6px; }
.inline-title:hover, .inline-goal:hover { border-color: var(--line-strong); }
.inline-goal { border-color: transparent; background: transparent; padding-left: 6px; color: var(--ink-soft); }
.plan-meta { display: flex; align-items: center; gap: 14px; }
.plan-meta label { display: flex; align-items: center; gap: 8px; }
.plan-meta input[type="date"] { width: auto; margin: 0; }
.plan-actions { display: flex; gap: 8px; }
.empty-plan { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: space-between; }

/* ---------- sprints view */
.sprint-list details > summary { list-style: none; display: flex; align-items: center; gap: 14px; cursor: pointer; flex-wrap: wrap; }
.sprint-list summary::-webkit-details-marker { display: none; }
.sprint-list summary strong { font-size: 18px; }
.sprint-list summary .count { margin-left: auto; }
.sprint-list details[open] > summary { margin-bottom: 12px; }
.badge { padding: 3px 9px; border-radius: 6px; font-size: 13.5px; font-weight: 700; background: var(--paper); color: var(--muted); }
.state-active .badge { background: var(--green-soft); color: var(--green-dark); }
.state-planning .badge { background: var(--gold-soft); color: #8a5f00; }
.activity { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.activity li { font-size: 14.5px; color: var(--ink-soft); }
.activity .when { color: var(--muted); font-size: 13.5px; display: inline-block; min-width: 64px; }
.activity .detail { color: var(--muted); }

/* ---------- team view */
.members { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.member { display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; flex-wrap: wrap; }
.member.inactive { opacity: .55; }
.member-name { max-width: 240px; }
.swatches { display: flex; gap: 6px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatch.on { border-color: var(--ink); }
.member .btn { margin-left: auto; }

/* ---------- modal */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal-back { position: fixed; inset: 0; background: rgba(22, 40, 30, .45); }
.modal-card { position: relative; width: 100%; max-width: 720px; background: #fff; border-radius: 16px; padding: 18px 22px 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.modal-head h2 { font-size: 22px; }
.where { font-size: 13.5px; font-weight: 600; color: var(--green-dark); background: var(--green-soft); padding: 3px 9px; border-radius: 6px; }
.task-title { font-size: 21px; font-weight: 700; border-color: transparent; padding-left: 8px; margin: 0 -8px 10px; width: calc(100% + 16px); }
.task-title:hover, .task-title:focus { border-color: var(--line-strong); }
.move-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.move-row .lbl { font-size: 13.5px; font-weight: 700; color: var(--muted); margin-right: 4px; }
.fields { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.fields .wide { grid-column: span 4; }
.fields .check { display: flex; align-items: center; gap: 8px; align-self: end; min-height: 42px; font-size: 15.5px; color: var(--ink); }
.fields .check input { width: 20px; height: 20px; }
.notes { margin-bottom: 16px; }
.comments { border-top: 1px solid var(--line); padding-top: 14px; margin-bottom: 12px; }
.comment { display: flex; gap: 10px; margin-bottom: 12px; }
.c-head { font-size: 14px; margin-bottom: 2px; }
.c-body { white-space: pre-wrap; }
.when { color: var(--muted); font-size: 13.5px; }
.history summary { cursor: pointer; font-weight: 600; color: var(--ink-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.radio label { display: flex; align-items: center; gap: 10px; font-size: 15.5px; color: var(--ink); font-weight: 500; min-height: 40px; }
.radio input { width: 20px; height: 20px; }

/* ---------- login */
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 440px; background: #fff; border-radius: 16px; padding: 30px 28px; box-shadow: var(--shadow); text-align: center; }
.login-card p { color: var(--ink-soft); margin-bottom: 16px; }
.who { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 18px; }
.who-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 6px 14px 6px 6px; border-radius: 26px; border: 1.5px solid var(--line-strong); background: #fff; cursor: pointer; font-weight: 600; }
.who-btn:hover, .who-btn.on { border-color: var(--c, var(--green)); background: var(--paper); }
#loginForm { display: flex; flex-direction: column; gap: 10px; }
.login-error { color: var(--red); font-weight: 600; min-height: 22px; margin: 0; }

/* ---------- toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 9px; font-weight: 600; box-shadow: var(--shadow); }
.toast.err { background: var(--red); }

/* ---------- phones */
@media (max-width: 760px) {
  .topbar { gap: 10px; padding: 8px 12px; flex-wrap: wrap; }
  .brand span:not(.logo) { display: none; }
  .tabs { order: 3; width: 100%; justify-content: space-between; }
  .tabs button { flex: 1; padding: 6px 4px; }
  main { padding: 14px 12px 60px; }
  .board { grid-auto-columns: 82vw; }
  .fields { grid-template-columns: 1fr 1fr; }
  .fields .wide { grid-column: span 2; }
  .modal { padding: 12px 8px; }
  .modal-card { padding: 14px; }
  .head-actions input[type="search"] { width: 140px; }
  .sprint-head .head-actions { margin-left: 0; }
  .card { cursor: default; }
}
