:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #5b7fff;
  --primary-hover: #4a6ef5;
  --danger: #ef4444;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --pending-bg: #f3f4f6;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --purple: #8b5cf6;
  --orange: #f97316;
  --blue: #3b82f6;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.logo { margin: 0; font-size: 1.15rem; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.user-badge { color: var(--muted); font-size: .95rem; }
.back-link { color: var(--muted); margin-right: auto; }

.page { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.page.narrow { max-width: 760px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.page-header h2 { margin: 0; font-size: 1.5rem; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.card-pending {
  background: var(--pending-bg);
  border: 1px solid #e0e4ea;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.board-card {
  display: block;
  transition: transform .15s ease, box-shadow .15s ease;
  min-height: 120px;
}
.board-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.1);
}
.board-card-top { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.board-card-title { margin: 0; font-size: 1.05rem; font-weight: 600; }

.priority-badge, .status-badge {
  font-size: .75rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-weight: 600;
}
.priority-high { background: #fee2e2; color: #b91c1c; }
.priority-medium { background: #fef3c7; color: #b45309; }
.priority-low { background: #e0e7ff; color: #4338ca; }
.status-badge { background: #e5e7eb; color: #4b5563; }

.markers { display: flex; gap: .35rem; margin-top: .75rem; }
.inline-markers { margin-top: 0; }
.marker {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  color: #fff;
  font-weight: 700;
}
.marker-new_agreement { background: var(--blue); }
.marker-new_agreement::after { content: "+"; }
.marker-edited { background: var(--orange); }
.marker-edited::after { content: "✎"; }
.marker-new_shortcoming { background: var(--red); }
.marker-new_shortcoming::after { content: "!"; }
.marker-shortcoming_reply { background: var(--purple); }
.marker-shortcoming_reply::after { content: "↩"; }

.btn {
  border: none;
  border-radius: 10px;
  padding: .55rem 1rem;
  font-size: .95rem;
  cursor: pointer;
  background: #eef2ff;
  color: var(--text);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-ghost { background: transparent; border: 1px solid var(--border); }
.btn-sm { padding: .35rem .65rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.4rem; line-height: 1;
}

.form label { display: block; margin-bottom: 1rem; }
.form label span { display: block; margin-bottom: .35rem; color: var(--muted); font-size: .9rem; }
.form input, .form textarea, .form select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .65rem .75rem;
  font: inherit;
  background: #fff;
}
.form-card { display: grid; gap: .25rem; }
.form-actions { display: flex; gap: .75rem; margin-top: .5rem; }
.inline-form { display: inline; }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { margin: 0 0 .25rem; }
.muted { color: var(--muted); }
.alert-error {
  background: #fee2e2;
  color: #991b1b;
  padding: .75rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}
.empty-state { text-align: center; color: var(--muted); }

.detail-header { margin-bottom: 1rem; }
.detail-meta { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .75rem; }
.detail-header h2 { margin: .25rem 0; }
.detail-description { color: var(--muted); margin: .5rem 0 1rem; }
.detail-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }

.tabs {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
}
.tab {
  padding: .5rem 1rem;
  border-radius: 999px;
  background: #e8edf5;
  color: var(--muted);
}
.tab.active { background: var(--primary); color: #fff; }

.subtabs {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.subtab {
  padding: .45rem .9rem;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  font-size: .9rem;
}
.subtab.active { background: #dbeafe; color: #1e40af; font-weight: 600; }

.user-items-block { margin-bottom: 1.5rem; }
.user-items-block h4 { margin: 0 0 .75rem; font-size: 1.05rem; }
.user-items-block h5 {
  margin: 1rem 0 .5rem;
  font-size: .9rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.approval-block { margin-bottom: 1rem; border-left: 4px solid var(--orange); }
.approval-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.freeze-note { font-size: .9rem; margin-bottom: 1rem; }

.item-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.depth-1 { padding-left: 1rem; }
.depth-2 { padding-left: 2rem; }
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .65rem .75rem;
  border-radius: 10px;
  margin-bottom: .35rem;
  background: #fafbfc;
  border: 1px solid var(--border);
}
.item-row.status-marked { background: #fffbeb; border-color: #fde68a; }
.item-row.status-confirmed { background: #ecfdf5; border-color: #86efac; }
.item-row.item-overdue { background: #fef2f2; border-color: #fecaca; }
.item-main { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.item-deadline, .item-waiting, .item-done { font-size: .85rem; color: var(--muted); }
.item-done { color: var(--green); font-weight: 600; }
.overdue-tag {
  font-size: .75rem;
  color: #b91c1c;
  background: #fee2e2;
  padding: .1rem .45rem;
  border-radius: 999px;
}
.item-actions { display: flex; gap: .25rem; align-items: center; }

.checklist-section { margin: 1.25rem 0; }
.checklist-section h3, .checklist-section h4 { margin: 0 0 .75rem; font-size: 1rem; }
.section-label { font-size: 1.05rem; }
.section-hint { font-size: .85rem; margin: -.35rem 0 .75rem; }
.partner-section {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}
.readonly-item-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.readonly-item-list .readonly-item-list { padding-left: 1rem; margin-top: .35rem; }
.readonly-item {
  padding: .5rem .65rem;
  margin-bottom: .25rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}
.checklist-tree { display: grid; gap: .5rem; margin-bottom: .5rem; }
.tree-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem;
  background: #fafbfc;
}
.tree-item .row { display: flex; gap: .5rem; flex-wrap: wrap; }
.tree-item input[type="text"] { flex: 1; min-width: 160px; }
.tree-children { margin-top: .5rem; padding-left: 1rem; border-left: 2px solid #e8edf5; }

.shortcoming-group { margin: 1rem 0 1.5rem; }
.shortcoming-card {
  border-radius: 12px;
  padding: .9rem;
  margin-bottom: .65rem;
  background: #fff;
  border: 1px solid var(--border);
}
.shortcoming-card.accent-green {
  background: #ecfdf5;
  border-color: #86efac;
}
.shortcoming-card.accent-yellow {
  background: #fffbeb;
  border-color: #fde68a;
}
.shortcoming-card.accent-red {
  background: #fef2f2;
  border-color: #fecaca;
}
.shortcoming-head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .35rem; }
.severity-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.severity-green { background: var(--green); }
.severity-yellow { background: var(--yellow); }
.severity-red { background: var(--red); }
.disagree-comment { color: #7c2d12; background: #fff7ed; padding: .5rem .75rem; border-radius: 8px; }
.shortcoming-actions { display: flex; gap: .5rem; margin-top: .65rem; flex-wrap: wrap; }
.group-label { font-size: .8rem; color: var(--muted); }
.edit-details summary { cursor: pointer; color: var(--primary); margin-top: .5rem; }

.modal.hidden { display: none; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1rem; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.35); }
.modal-card { position: relative; width: 100%; max-width: 480px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

@media (max-width: 640px) {
  .topbar-inner, .page { padding-left: 1rem; padding-right: 1rem; }
  .item-row { flex-direction: column; align-items: flex-start; }
  .approval-actions { flex-direction: column; }
  .approval-actions .btn, .approval-actions form { width: 100%; }
  .approval-actions .btn { text-align: center; }
}
