:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e3e6ea;
  --text: #1a1d21;
  --muted: #6b7280;
  --accent: #2563eb;
  --danger: #dc2626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}

button:hover { border-color: #c9ced5; }

input, select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  width: 100%;
}

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label.row { display: flex; gap: 8px; align-items: center; }
label.row input { width: auto; }

h1 { font-size: 20px; }
h2 { font-size: 18px; margin: 12px 0 8px; }
h3 { font-size: 14px; color: var(--muted); margin: 18px 0 8px; text-transform: uppercase; }

.link {
  border: none;
  background: none;
  color: var(--accent);
  padding: 4px 0;
}

.error { color: var(--danger); font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; }

/* Auth ---------------------------------------------------------------- */
.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 380px;
}

.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tabs .active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Shell --------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { font-weight: 600; }
.tabs { display: flex; gap: 6px; flex: 1; }
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.who { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }

.status {
  position: fixed;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 40;
}

.layout {
  display: flex;
  gap: 16px;
  max-width: 1080px;
  margin: 16px auto;
  padding: 0 16px;
  align-items: flex-start;
}

.list-pane {
  flex: 1;
  min-width: 0;
}

.view {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.quick { display: flex; gap: 8px; margin-bottom: 14px; }
.quick input[type="date"] { width: 150px; }
.quick button { white-space: nowrap; }

/* Tasks --------------------------------------------------------------- */
.tasks { list-style: none; margin: 0; padding: 0; }

.tasks li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid #eef0f3;
  cursor: pointer;
}

.tasks li:last-child { border-bottom: none; }
.tasks li:hover { background: #fafbfc; }
.tasks li.done .title { color: var(--muted); text-decoration: line-through; }
.tasks li input[type="checkbox"] { width: auto; cursor: pointer; }

.title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  margin-left: 4px;
}

.due { font-size: 12px; color: var(--muted); }
.due.overdue { color: var(--danger); }

/* Projects ------------------------------------------------------------ */
.projects { list-style: none; margin: 0; padding: 0; }
.projects li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid #eef0f3;
  cursor: pointer;
}
.projects li:hover { background: #fafbfc; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags .tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
}

.members { list-style: none; margin: 0; padding: 0; }
.members li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border-bottom: 1px solid #eef0f3;
  font-size: 14px;
}
.members .muted { color: var(--muted); font-size: 12px; }
.members button { padding: 4px 10px; font-size: 12px; }

/* Detail pane --------------------------------------------------------- */
.detail {
  width: 340px;
  flex-shrink: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  position: sticky;
  top: 70px;
}

.detail-head { display: flex; justify-content: space-between; align-items: center; }
.detail-head h3 { margin: 0; }
.detail button[type="submit"] { width: 100%; background: var(--accent); border-color: var(--accent); color: #fff; }

#detail-tags { display: flex; flex-wrap: wrap; gap: 8px; }
#detail-tags label {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
#detail-tags input { width: auto; }

/* Mobile: детали — отдельный экран ----------------------------------- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding-inline: 12px; }
  .topbar .tabs { order: 3; flex-basis: 100%; }
  .who { flex: 1; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
  .layout { flex-direction: column; margin-top: 8px; }
  .detail {
    position: fixed;
    inset: 0;
    width: auto;
    border-radius: 0;
    z-index: 30;
    overflow-y: auto;
    top: 0;
  }
  .who span { display: none; }
  .quick { flex-wrap: wrap; }
  .quick input[type="date"] { width: 100%; }
}

/* Controls added by the task workflow. */
[hidden] { display: none !important; }
button:disabled { cursor: wait; opacity: .65; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.project-quick { margin-block: 14px; }
.quick-row { display: flex; gap: 8px; }
.quick-row button { white-space: nowrap; }
.project-quick fieldset, #detail-form fieldset {
  margin: 10px 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.tag-options { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-options label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 2px 6px;
  color: var(--text);
}
.tag-options input { width: auto; }
.task-row .task-title, .projects button {
  text-align: left;
  border: none;
  background: transparent;
  padding: 4px 0;
}
.task-row .task-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.task-row .tag-chips { display: flex; flex-wrap: wrap; gap: 4px; justify-content: end; }
.task-row .chip { margin-left: 0; }
.project-token { min-width: 0; max-width: 19rem; }
.members .member-name { overflow-wrap: anywhere; }

@media (max-width: 520px) {
  .topbar { gap: 8px; flex-wrap: wrap; padding: 8px 12px; }
  .topbar .who { margin-left: auto; }
  .topbar .tabs { order: 1; flex-basis: 100%; }
  .topbar .tabs button { flex: 1; padding: 8px 4px; }
  .layout { padding: 0 10px; }
  .view { padding: 12px; }
  .members li { flex-wrap: wrap; }
}
