:root {
  --bg: #14161a;
  --panel: #1e2127;
  --panel-deep: #0f1114;
  --line: #30343c;
  --text: #e8e8ea;
  --muted: #9aa0aa;
  --faded: #666c76;
  --late: #ff2d2d;
  --blocked: #f0b429;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 system-ui, sans-serif;
}

.top {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 12px 20px 0;
}
.top h1 { margin: 0; font-size: 18px; }
#today { color: var(--muted); }
#offline { color: var(--late); font-weight: 700; }

#filter { display: flex; gap: 8px; margin-left: auto; }
.filter-badge {
  padding: 3px 12px;
  border: 1px solid var(--badge);
  border-radius: 12px;
  background: var(--badge);
  color: #111;
  font: 600 13px system-ui, sans-serif;
  cursor: pointer;
}
.filter-badge.off { background: none; color: var(--badge); opacity: .6; }
.filter-badge.off:hover { opacity: 1; }

#board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 12px 20px 20px;
}

.team {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.team-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.team-head h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.team-head .spacer { flex: 1; }

.overdue {
  border: 0;
  border-radius: 4px;
  padding: 4px 10px;
  background: var(--late);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.list {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  scrollbar-color: #3a3e46 transparent;
}

.row {
  display: grid;
  grid-template-columns: 20px 58px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px 10px;
  margin-bottom: 4px;
  border-radius: 6px;
  cursor: pointer;
}
.row:hover { background: #ffffff0d; }
.row .check { width: 18px; height: 18px; margin: 2px 0 0; cursor: pointer; }
.row .due { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.row .tag {
  display: inline-block;
  margin-bottom: 3px;
  padding: 1px 8px;
  border-radius: 10px;
  color: #111;
  font-size: 12px;
  font-weight: 600;
}
.row .title { display: block; overflow-wrap: anywhere; }

.row.done .title, .row.done .due { color: var(--faded); text-decoration: line-through; }
.row.done .tag { background: #3a3e46 !important; color: #888; }

.row.late, .row.late:hover { background: var(--late); color: #fff; font-weight: 600; }
.row.late .due { color: #fff; }

.row.next { outline: 1px solid var(--text); outline-offset: -1px; }

.row.flash { animation: flash 1.4s; }
@keyframes flash {
  0%, 60% { box-shadow: 0 0 0 3px var(--blocked); }
  100% { box-shadow: 0 0 0 3px transparent; }
}

.blk {
  margin-top: 6px;
  padding: 3px 9px;
  border: 1px solid var(--blocked);
  border-radius: 4px;
  background: #f0b42922;
  color: var(--blocked);
  font: 600 12px system-ui, sans-serif;
  cursor: pointer;
}
.blk.clear { border-color: #555; background: none; color: #888; }
.row.late .blk { border-color: #fff; background: #fff; color: #b00000; }

.pop {
  margin-top: 8px;
  padding: 6px;
  border: 1px solid var(--blocked);
  border-radius: 6px;
  background: var(--panel-deep);
  color: var(--text);
  font-weight: 400;
  cursor: default;
}
.pop-item {
  display: block;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.pop-item:hover { background: var(--panel); }
.pop-item small { display: block; color: var(--muted); }
.pop-item.done span { color: var(--faded); text-decoration: line-through; }
.pop-item.late small { color: #ff6b6b; font-weight: 700; }

button.add, .actions button {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
button.add:hover, .actions button:hover { background: #ffffff14; }
.actions .primary { border-color: var(--text); background: var(--text); color: #111; font-weight: 600; }
.actions .primary:hover { background: #fff; }
.actions .danger { border-color: var(--late); color: #ff6b6b; }

dialog {
  width: min(640px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}
dialog::backdrop { background: #000a; }
dialog h2 { margin: 0 0 14px; font-size: 18px; }
dialog label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
dialog input:not([type=checkbox]), dialog select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-deep);
  color: var(--text);
  font: inherit;
}
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

#blocker-list {
  max-height: 240px;
  overflow-y: auto;
  margin: -6px 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-deep);
}
#blocker-list label {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin: 0;
  padding: 6px 8px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
#blocker-list label:hover { background: var(--panel); }
#blocker-list small { color: var(--muted); white-space: nowrap; }
#blocker-list .empty { padding: 8px; color: var(--muted); font-size: 14px; }

#editor-error { margin: 0 0 12px; color: #ff6b6b; font-weight: 600; }

.actions { display: flex; gap: 8px; }
.actions .spacer { flex: 1; }

@media (max-width: 900px) {
  body { height: auto; }
  #board { grid-template-columns: 1fr; }
  .team { max-height: 80vh; }
}
