:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-muted: #f0ede6;
  --ink: #20201d;
  --muted: #666258;
  --line: #ded8ce;
  --accent: #8f2432;
  --accent-strong: #721a28;
  --accent-soft: #f3dce1;
  --green: #237a45;
  --green-bg: #e5f3ea;
  --yellow: #b8741a;
  --danger: #b83232;
  --shadow: 0 16px 40px rgba(32, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(143, 36, 50, 0.08), transparent 320px),
    var(--bg);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.auth-card .brand {
  align-items: flex-start;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form .button {
  width: 100%;
}

.auth-note {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.auth-error {
  min-height: 20px;
  margin-bottom: 0;
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(16px, 4vw, 44px);
  border-bottom: 1px solid rgba(222, 216, 206, 0.85);
  background: rgba(245, 243, 238, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 7px;
  min-height: 40px;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 700;
  white-space: nowrap;
}

a.button {
  text-decoration: none;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.button:focus-visible,
.icon-button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(143, 36, 50, 0.2);
  outline-offset: 2px;
}

.primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.primary:hover {
  background: var(--accent-strong);
}

.secondary {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.danger-light {
  color: var(--danger);
  background: #fff6f5;
  border-color: #efcfca;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.workspace {
  width: min(1380px, calc(100% - 32px));
  margin: 26px auto 40px;
}

.control-band {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.task-form,
.member-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) minmax(136px, 160px) auto;
  align-items: end;
  gap: 12px;
  min-width: 0;
}

.member-form {
  grid-template-columns: minmax(220px, 1fr) auto;
  width: min(540px, 100%);
}

.member-form-wide {
  width: min(760px, 100%);
}

.utility-row {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(150px, 180px) auto auto;
  align-items: end;
  gap: 12px;
  min-width: 0;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

input::placeholder {
  color: #9b958b;
}

.submit-button {
  min-width: 106px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 72px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stat-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stat strong {
  font-size: 1.8rem;
  line-height: 1;
}

.team-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.team-list-page {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.member-chip {
  display: inline-grid;
  grid-template-columns: minmax(0, auto) auto auto auto;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 38px;
  padding: 4px 5px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.member-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-count {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.chip-action {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface-muted);
  font-size: 0.86rem;
  font-weight: 900;
}

.chip-action.danger {
  color: var(--danger);
  background: #fff6f5;
  border-color: #efcfca;
}

.team-workspace {
  max-width: 980px;
}

.team-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.team-panel {
  margin-top: 18px;
}

.team-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.team-card-main {
  min-width: 0;
}

.team-card h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1rem;
  letter-spacing: 0;
}

.team-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.task-column {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.column-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.column-heading h2 {
  margin-bottom: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 0.84rem;
  font-weight: 800;
}

.count-badge.done {
  color: var(--green);
  background: var(--green-bg);
}

.count-badge.progress {
  color: #315f82;
  background: #dfeef7;
}

.task-list {
  display: grid;
  gap: 10px;
  min-height: 220px;
  padding: 14px;
}

.task-list.drag-over {
  background: rgba(143, 36, 50, 0.04);
}

.task-card {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  min-height: 84px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.task-card.dragging {
  opacity: 0.55;
  border-color: var(--accent);
}

.task-card.done-card {
  border-color: #b9dcc5;
  background: linear-gradient(90deg, var(--green-bg), #ffffff 64%);
}

.drag-handle {
  width: 34px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
  cursor: grab;
}

.drag-handle:active {
  cursor: grabbing;
}

.done-handle {
  cursor: default;
}

.done-handle:active {
  cursor: default;
}

.task-main {
  min-width: 0;
}

.task-title {
  overflow-wrap: anywhere;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.28;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.pill.assignee {
  color: var(--accent);
  background: var(--accent-soft);
}

.pill.done-pill {
  color: var(--green);
  background: var(--green-bg);
}

.pill.progress-pill {
  color: #315f82;
  background: #dfeef7;
}

.pill.warning {
  color: var(--yellow);
  background: #fff1dd;
}

.task-actions {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.task-actions .button {
  width: 100%;
  min-height: 34px;
  padding-inline: 10px;
  font-size: 0.84rem;
}

.mini-button {
  width: 34px;
  padding: 0;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 156px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.52);
  font-weight: 700;
  text-align: center;
}

.edit-dialog {
  width: min(520px, calc(100% - 24px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(32, 32, 29, 0.25);
}

.edit-dialog::backdrop {
  background: rgba(32, 32, 29, 0.45);
}

.dialog-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialog-heading,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dialog-heading h2 {
  margin-bottom: 0;
  font-size: 1.1rem;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 4px;
}

.dialog-actions .danger-light {
  margin-right: auto;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--ink);
  background: var(--surface-muted);
  border-color: var(--line);
  font-size: 1.45rem;
  line-height: 1;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(420px, calc(100% - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 980px) {
  .topbar,
  .board,
  .task-form {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    align-items: stretch;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .task-form {
    display: grid;
  }

  .utility-row {
    grid-template-columns: minmax(0, 1fr) minmax(150px, 180px) auto auto;
  }

  .board {
    display: grid;
  }
}

@media (max-width: 680px) {
  .workspace {
    width: 100%;
    margin-top: 14px;
    padding: 0 18px 0 10px;
  }

  .topbar {
    padding: 14px 18px 14px 10px;
  }

  .control-band,
  .stat,
  .task-column {
    width: calc(100% - 10px);
  }

  .stat {
    display: grid;
    justify-content: start;
    justify-items: start;
    min-height: 82px;
  }

  .column-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions,
  .utility-row,
  .task-actions,
  .dialog-actions {
    display: grid;
    width: 100%;
  }

  .top-actions,
  .utility-row {
    grid-template-columns: 1fr;
  }

  .task-actions,
  .dialog-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-actions .button,
  .utility-row .button,
  .task-actions .button,
  .dialog-actions .button {
    width: 100%;
  }

  .task-card {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .task-actions {
    grid-column: 1 / -1;
  }

  .member-form {
    grid-template-columns: 1fr;
  }

  .team-stats {
    grid-template-columns: 1fr;
  }

  .team-card {
    grid-template-columns: 1fr;
  }

  .team-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .team-card-actions .button {
    width: 100%;
  }

  .member-chip {
    width: 100%;
    border-radius: 8px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .dialog-actions .danger-light {
    margin-right: 0;
  }
}
