/* AperioFlow theme (dark only). Colours are sampled from the AperioFlow logo files; see
   brand/README.md. Status colours (green, amber, red) stay separate from the brand colours,
   and magenta is never used for status so it cannot be mistaken for red. */
:root {
  --ink: #05060a; /* Night */
  --ink-2: #0d1120;
  --navy: #111629;
  --cyan: #38e8ff; /* Signal cyan */
  --violet: #7d5cfe;
  --magenta: #e75ce6;
  --mint: #34e0a1;
  --grad: linear-gradient(90deg, #41d5ff 0%, #7d5cfe 60%, #e75ce6 100%);

  --bg: var(--ink);
  --surface: var(--ink-2);
  --surface-2: #161c33;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eef1f8; /* Off-white */
  --body: #c9d0dd;
  --muted: #97a1b5;
  --faint: #7d879b;
  --accent: var(--cyan);
  --accent-soft: rgba(56, 232, 255, 0.12);
  --danger: #ff6b81;
  --shadow: none;

  --s-todo: var(--muted);
  --s-todo-bg: rgba(255, 255, 255, 0.06);
  --s-in_progress: #8fa0ff;
  --s-in_progress-bg: rgba(79, 107, 255, 0.16);
  --s-blocked: #ffb45c;
  --s-blocked-bg: rgba(255, 180, 92, 0.13);
  --s-done: var(--mint);
  --s-done-bg: rgba(52, 224, 161, 0.13);
  --s-cancelled: var(--faint);
  --s-cancelled-bg: rgba(255, 255, 255, 0.04);

  --radius: 18px;
  --radius-sm: 12px;
  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(900px 420px at 88% -160px, rgba(79, 107, 255, 0.22), transparent 70%),
    radial-gradient(700px 360px at -10% 0, rgba(34, 211, 238, 0.08), transparent 70%), var(--bg);
  background-repeat: no-repeat;
  background-color: var(--bg);
  color: var(--body);
  font: 14px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
::selection {
  background: rgba(34, 211, 238, 0.3);
}
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
  border-radius: 4px;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.015em;
}
h1 {
  font-size: 28px;
  letter-spacing: -0.03em;
}
h2 {
  font-size: 16px;
}
h3 {
  font-size: 15px;
}
a {
  color: var(--accent);
}
code,
pre {
  font-family: var(--font-mono);
  font-size: 12.5px;
}
code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
}
pre {
  background: var(--surface-2);
  padding: 12px 14px;
  border-radius: 8px;
  overflow-x: auto;
}
pre code {
  background: none;
  padding: 0;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 12px;
}
.warn-text {
  color: var(--s-blocked);
  font-weight: 600;
}
.danger-text {
  color: var(--danger);
  font-weight: 600;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 60px;
  background: rgba(7, 10, 18, 0.72);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  min-width: 0;
}
.brand-name {
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-mark {
  flex: none;
  width: 30px;
  height: 30px;
  background: url('icons/icon.svg') center/contain no-repeat;
}
.topbar nav {
  display: flex;
  gap: 4px;
}
.topbar nav a {
  position: relative;
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s, background 0.2s;
}
.topbar nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}
.topbar nav a.active {
  color: var(--text);
}
.topbar nav a.active::after {
  content: '';
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 1px;
  height: 2px;
  border-radius: 2px;
  background: var(--grad);
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

#notify svg {
  width: 15px;
  height: 15px;
}
#notify.on {
  color: var(--s-done);
  border-color: color-mix(in srgb, var(--s-done) 40%, transparent);
}
.notify-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 4px;
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

/* ---------- buttons & inputs ---------- */

[hidden] {
  display: none !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.btn svg {
  width: 14px;
  height: 14px;
}
.btn.small {
  padding: 5px 12px;
  font-size: 13px;
}
.btn.primary {
  background: var(--grad);
  color: var(--ink);
  box-shadow: 0 8px 30px -8px rgba(34, 211, 238, 0.55);
}
.btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 40px -10px rgba(34, 211, 238, 0.7);
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.32);
}
.btn.danger {
  color: var(--danger);
}
.btn:disabled {
  opacity: 0.6;
  cursor: default;
}
button.link {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
button.link:hover {
  color: var(--text);
}
button.icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  flex: none;
}
button.icon svg {
  width: 16px;
  height: 16px;
}
button.icon:hover {
  background: var(--surface-2);
  color: var(--text);
}
button.icon.danger:hover {
  color: var(--danger);
}
.caret svg {
  transition: transform 0.15s;
}
.caret.open svg {
  transform: rotate(90deg);
}

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: rgba(7, 10, 18, 0.6);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input::placeholder,
textarea::placeholder {
  color: var(--faint);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.14);
}
textarea {
  resize: vertical;
}

/* ---------- status & tags ---------- */

.pill,
.status-select {
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
}
.pill {
  padding: 2px 10px;
}
.status-select {
  appearance: none;
  border: none;
  padding: 3px 24px 3px 10px;
  cursor: pointer;
  flex: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23888' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 12px;
}
.status-select option {
  background: var(--surface);
  color: var(--text);
}
.s-todo.pill,
.status-select.s-todo {
  color: var(--s-todo);
  background-color: var(--s-todo-bg);
}
.s-in_progress.pill,
.status-select.s-in_progress {
  color: var(--s-in_progress);
  background-color: var(--s-in_progress-bg);
}
.s-blocked.pill,
.status-select.s-blocked {
  color: var(--s-blocked);
  background-color: var(--s-blocked-bg);
}
.s-done.pill,
.status-select.s-done {
  color: var(--s-done);
  background-color: var(--s-done-bg);
}
.s-cancelled.pill,
.status-select.s-cancelled {
  color: var(--s-cancelled);
  background-color: var(--s-cancelled-bg);
}

.tags {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.tag {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  white-space: nowrap;
  text-decoration: none;
}
.tag.link:hover {
  color: var(--accent);
}
.tag.overdue {
  background: var(--s-blocked-bg);
  color: var(--s-blocked);
  font-weight: 600;
}
.tag.p-high {
  color: var(--s-blocked);
}
.tag.p-critical {
  background: var(--danger);
  color: var(--ink);
  font-weight: 600;
}
.tag.p-low {
  opacity: 0.8;
}

/* ---------- progress ---------- */

.progress {
  flex: 1;
  height: 6px;
  min-width: 60px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress.small {
  height: 4px;
  min-width: 48px;
}
.progress.large {
  flex: none;
  height: 10px;
  width: 100%;
}
.progress-fill {
  height: 100%;
  background: var(--grad);
  border-radius: inherit;
  transition: width 0.3s;
}
.progress-fill.complete {
  background: var(--s-done);
}
.progress-row,
.phase-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.id-badge {
  flex: none;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.phase-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  min-width: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- layout pieces ---------- */

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01)), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-head p {
  margin: 4px 0 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  display: flex;
  flex-direction: column;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01)), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-value small {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}
.stat-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat.warn .stat-value {
  color: var(--s-blocked);
}
.stat-issues {
  --tone: var(--s-done);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.stat-issues.bad {
  --tone: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}
.stat-issues:hover {
  border-color: var(--tone);
}
.stat-issues .stat-value {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--tone);
}
.indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tone);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 22%, transparent);
}
.stat-issues.pulse {
  animation: stat-pulse 1.2s ease-out 4;
}
.stat-issues.pulse .indicator {
  animation: dot-pulse 1.2s ease-out 4;
}
@keyframes stat-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--tone) 55%, transparent);
  }
  100% {
    box-shadow: 0 0 0 14px transparent;
  }
}
@keyframes dot-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.5);
  }
}
@media (prefers-reduced-motion: reduce) {
  .stat-issues.pulse,
  .stat-issues.pulse .indicator {
    animation: none;
  }
}

.dash-issues {
  margin-bottom: 20px;
  scroll-margin-top: 80px;
}
.dash-issues.all-clear {
  border-left: 3px solid var(--s-done);
}
.dash-issues .issue-list {
  max-height: 420px;
  overflow-y: auto;
}
.dash-issue-row {
  width: 100%;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.dash-issue-row:hover {
  background: rgba(255, 255, 255, 0.03);
}
.dash-issue-row:hover .issue-title {
  color: var(--accent);
}
.issue-project {
  color: var(--accent);
  font-weight: 500;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.toolbar input {
  flex: 1;
  min-width: 0;
  max-width: 360px;
}
.toolbar select {
  min-width: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 14px;
}
.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 22px;
  color: inherit;
  text-decoration: none;
  overflow-wrap: anywhere;
  transition: transform 0.25s ease, background 0.25s ease;
}
.project-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: var(--grad);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.project-card:hover {
  transform: translateY(-3px);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)), var(--surface);
}
.project-card:hover::before {
  opacity: 1;
}
.project-card p {
  margin: 0;
}
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.card-top h3 {
  min-width: 0;
}
.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 12.5px;
  color: var(--muted);
}
.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
}
.empty h2 {
  margin-bottom: 6px;
}

/* ---------- project view ---------- */

.crumbs {
  display: flex;
  gap: 8px;
  color: var(--muted);
  margin-bottom: 14px;
  font-size: 13px;
}
.crumbs a {
  color: var(--muted);
  text-decoration: none;
}
.crumbs a:hover {
  color: var(--accent);
}

.project-head {
  display: grid;
  /* minmax(0, 1fr): a long unbroken word (a file path) must not widen the card past the page. */
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 28px;
  padding: 22px 24px;
  margin-bottom: 20px;
}
.project-head-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.description {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.project-head-main,
.project-head-side {
  min-width: 0;
}
.description-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.description-short {
  white-space: normal;
}
.link-btn {
  background: none;
  border: 0;
  padding: 4px 0;
  min-height: 24px;
  color: var(--accent);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.link-btn:hover {
  text-decoration: underline;
}
.link-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.project-head-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.big-pct {
  font-family: var(--font-display);
  color: var(--text);
  font-size: 38px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.big-pct small {
  font-size: 18px;
  color: var(--muted);
}
.btn-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.project-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
.phases {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.item-name {
  cursor: pointer;
}
.item-name:hover {
  color: var(--accent);
}

.phase-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 10px;
}
.phase-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.phase-progress {
  width: 160px;
}
.phase-body {
  border-top: 1px solid var(--border);
  padding: 8px 10px 10px;
}
.phase-body > .description {
  padding: 6px 8px 10px;
}

.items {
  list-style: none;
  margin: 0;
  padding: 0;
}
.item-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 6px 6px;
  border-radius: 8px;
  min-height: 40px;
}
.item-row:hover {
  background: var(--surface-2);
}
/* The name keeps a readable width; when the controls leave less than that, they wrap to a second line. */
.item-row .item-name {
  flex: 1 1 260px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.item.s-done > .item-row .item-name,
.item.s-cancelled > .item-row .item-name {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent);
}
.row-actions {
  display: inline-flex;
  opacity: 0;
  transition: opacity 0.1s;
}
.item-row:hover .row-actions,
.phase-head:hover .row-actions,
.row-actions:focus-within {
  opacity: 1;
}
.mini-progress {
  width: 64px;
  display: flex;
}
.subtasks {
  margin: 0 0 6px 36px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
}
.subtasks > .description {
  margin: 4px 6px 6px;
}
.subtask .item-row {
  min-height: 34px;
}

.quick-add {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 6px;
}
.quick-add-icon {
  display: grid;
  place-items: center;
  width: 28px;
  color: var(--muted);
}
.quick-add-icon svg {
  width: 14px;
  height: 14px;
}
.quick-add input {
  flex: 1;
  border-color: transparent;
  background: transparent;
  padding: 6px 8px;
}
.quick-add input:hover {
  background: var(--surface-2);
}

/* ---------- sections (awaiting owner, awaiting response, regular) ---------- */

.sec-awaiting_owner {
  --sec: var(--s-blocked);
}
.sec-awaiting_response {
  --sec: var(--s-in_progress);
}
.sec-regular {
  --sec: var(--accent);
}
.sections {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.phase.section,
.waiting-group {
  border-left: 3px solid var(--sec);
}
.section-name {
  margin: 0;
  font-size: 15px;
  color: var(--text);
}
.sec-count {
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  color: var(--sec, var(--muted));
  background: color-mix(in srgb, var(--sec, var(--muted)) 14%, transparent);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.return-btn {
  display: block; /* inline-flex ignores text-overflow, so the label ran past max-width */
  flex: none;
  max-width: 220px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.return-name {
  font-weight: 600;
}
.task:focus {
  outline: none;
}
.task:focus-visible,
.task.flash {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}
.move-group {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.move-group legend {
  padding: 0 0 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
}
.move-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.move-option {
  width: 100%;
  min-height: 44px;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  white-space: normal;
  border-radius: var(--radius-sm);
}
.move-option[disabled] {
  opacity: 0.6;
}

/* The Waiting page: every project's sections. */
.waiting-toolbar {
  flex-wrap: wrap;
  align-items: center;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  cursor: pointer;
}
.check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}
.waiting-total {
  margin-left: auto;
}
.waiting-group {
  padding: 14px 14px 10px;
  margin-bottom: 14px;
  min-width: 0;
}
.waiting-head {
  padding: 0 6px 8px;
}
.waiting-head h2 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 2px;
}
.waiting-head p {
  margin: 0;
}
.waiting-list {
  border-top: 1px solid var(--border);
  padding-top: 4px;
}
.waiting-row {
  flex-wrap: wrap;
}
.waiting-name {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.waiting-name:hover {
  text-decoration: underline;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- issues ---------- */

.issues {
  padding: 14px 14px 10px;
  min-width: 0;
}
.issues.has-open {
  border-left: 3px solid var(--danger);
}
.security {
  padding: 6px 10px;
  min-width: 0;
}
.security-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 4px;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
}
.security-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.security-toggle h2 {
  flex: 1;
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.security-note {
  margin: 4px 4px 8px;
}
.issues-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}
.issues-empty p {
  margin: 2px 0 0;
}
.issues-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 2px 10px 4px;
}
.issues-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.count-badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}
.issues-none {
  margin: 4px 6px 8px;
}
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  padding: 2px;
}
.seg-btn {
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.seg-btn.active {
  background: var(--surface-2);
  color: var(--text);
}
.seg-count {
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
/* Done-phase filter above the phase list on the project page. */
.phase-filter {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 2px 4px;
}
.phase-filter-title {
  margin: 0;
}
.phase-filter-note {
  flex: 1;
  min-width: 0;
}
.phase-filter .seg-btn {
  min-height: 32px;
}
.phases-all-done {
  padding: 32px 24px;
}
.phases-all-done p {
  margin: 0 0 14px;
}
.issue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}
.issue {
  border-bottom: 1px solid var(--border);
}
.issue:last-child {
  border-bottom: none;
}
.issue-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  min-height: 44px;
}
.issue-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
}
.issue-title {
  font-weight: 500;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.issue-main:hover .issue-title {
  color: var(--accent);
}
.is-resolved .issue-title,
.is-ignored .issue-title {
  color: var(--muted);
}
.issue-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}
.issue-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.issue-count {
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.issue-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.lvl {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 7px;
  border-radius: 4px;
}
.lvl-fatal {
  color: var(--ink);
  background: var(--danger);
}
.lvl-error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}
.lvl-warning {
  color: var(--s-blocked);
  background: var(--s-blocked-bg);
}
.lvl-info {
  color: var(--s-in_progress);
  background: var(--s-in_progress-bg);
}
.issue-detail {
  margin: 0 4px 12px 42px;
  min-width: 0;
}
.issue-detail h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 12px 0 6px;
}
.issue-pre {
  margin: 0;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 14px;
  margin: 0;
  font-size: 12.5px;
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.issue-links {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  overflow-wrap: anywhere;
}
.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12.5px;
}
.event-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}
dialog pre {
  margin: 6px 0 0;
  max-height: 260px;
}
dialog.wide {
  width: min(820px, calc(100vw - 32px));
}
.issue-card-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px 24px;
}
.issue-card-body h2 {
  text-transform: none;
  overflow-wrap: anywhere;
}
.issue-card-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.issue-card-body .issue-detail {
  margin: 0;
}
.issue-card-body .dialog-actions {
  flex-wrap: wrap;
}
.issue-card-body .spacer {
  flex: 1;
}

/* ---------- activity ---------- */

.activity {
  position: sticky;
  top: 76px;
  padding: 16px 18px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}
.activity h2 {
  margin-bottom: 10px;
}
.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.act {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.act:last-child {
  border-bottom: none;
}
.act-name {
  font-weight: 500;
}
.act-detail {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
}
.act-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
}
.src {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 6px;
  border-radius: 4px;
}
.src-api {
  background: var(--accent-soft);
  color: var(--accent);
}
.src-web {
  background: var(--surface-2);
  color: var(--muted);
}

/* ---------- docs ---------- */

.docs {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 960px;
}
.docs .card {
  padding: 20px 22px;
}
.docs h2 {
  margin-bottom: 10px;
}
.endpoints {
  width: 100%;
  border-collapse: collapse;
}
.endpoints th,
.endpoints td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.endpoints th {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.method {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
}
details summary {
  cursor: pointer;
  margin: 8px 0;
}

/* ---------- dialogs & toast ---------- */

dialog {
  width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--body);
  box-shadow: 0 30px 80px -20px rgb(0 0 0 / 0.7);
}
dialog::backdrop {
  background: rgb(7 10 18 / 0.7);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
dialog form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 24px;
}
dialog h2 {
  font-size: 20px;
  text-transform: capitalize;
}
dialog p {
  margin: 0;
}
dialog label,
dialog .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 500;
  font-size: 13px;
  color: var(--muted);
}
.derived {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
  font-weight: 400;
}
dialog label .muted {
  font-weight: 400;
  color: var(--faint);
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.error {
  color: var(--danger);
  font-size: 13px;
}

#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--ink);
  font-weight: 500;
  z-index: 100;
  max-width: calc(100vw - 32px);
}
#toast.error {
  background: var(--danger);
  color: var(--ink);
}

/* ---------- responsive ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

@media (max-width: 960px) {
  .project-body,
  .project-head {
    grid-template-columns: minmax(0, 1fr);
  }
  .activity {
    position: static;
    max-height: none;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 16px;
    gap: 12px;
  }
  #whoami {
    display: none;
  }
  #notify .notify-label {
    display: none;
  }
  .topbar nav a {
    padding: 6px 8px;
  }
  main {
    padding: 20px 16px 48px;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .stat-issues {
    grid-column: 1 / -1;
  }
  .issue-card-body {
    padding: 18px 16px;
  }
  .grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .page-head {
    flex-direction: column;
    align-items: stretch;
  }
  .phase-head {
    flex-wrap: wrap;
  }
  .phase-progress {
    width: 100%;
    order: 5;
  }
  .phase-title {
    flex-basis: calc(100% - 60px);
  }
  .item-row {
    flex-wrap: wrap;
    row-gap: 4px;
  }
  /* Controls share the first line; the name gets its own full-width line so it never squeezes to one character. */
  .item-row .item-name {
    order: 10;
    flex: 1 1 100%;
    padding: 0 4px 2px;
  }
  .item-row .tags:empty {
    display: none;
  }
  .row-actions {
    opacity: 1;
    margin-left: auto;
  }
  .mini-progress {
    display: none;
  }
  .grid2 {
    grid-template-columns: 1fr;
  }
  .issues-empty {
    flex-direction: column;
    align-items: stretch;
  }
  .issues-head h2 {
    flex-basis: 100%;
  }
  .phase-filter-note {
    order: 3;
    flex-basis: 100%;
  }
  .phase-filter .seg {
    margin-left: auto;
  }
  .return-btn {
    max-width: 100%;
  }
  .waiting-total {
    margin-left: 0;
    flex-basis: 100%;
  }
  .waiting-toolbar select {
    flex: 1 1 140px;
  }
  /* On a phone the task name follows the status and id, above the project tags and buttons. */
  .waiting-row > * {
    order: 3;
  }
  .waiting-row > .status-select,
  .waiting-row > .id-badge {
    order: 0;
  }
  .waiting-row > .item-name {
    order: 1;
  }
  .waiting-row > .tags {
    order: 2;
  }
  .issue-row {
    flex-wrap: wrap;
  }
  .issue-main {
    flex-basis: calc(100% - 150px);
  }
  .issue-stats {
    flex-direction: row;
    gap: 10px;
    margin-left: 38px;
  }
  .issue-actions {
    margin-left: auto;
  }
  .issue-detail {
    margin-left: 4px;
  }
  .endpoints td:first-child {
    white-space: normal;
  }
}

@media (max-width: 480px) {
  .brand-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* ---------- GitHub Actions minutes ---------- */

.progress-fill.warn {
  background: var(--s-blocked);
}
.progress-fill.over {
  background: var(--danger);
}
.minutes-account,
.minutes-projects,
.minutes-other {
  padding: 14px 16px;
  margin-bottom: 14px;
  min-width: 0;
}
.minutes-projects h2,
.minutes-other h2 {
  margin: 0 0 4px;
  font-size: 16px;
}
.minutes-account {
  display: grid;
  gap: 8px;
}
.minutes-account p {
  margin: 0;
}
.minutes-account .progress {
  height: 10px;
}
.table-wrap {
  overflow-x: auto;
}
.minutes-table {
  width: 100%;
  border-collapse: collapse;
}
.minutes-table th,
.minutes-table td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--surface-2);
  vertical-align: middle;
}
.minutes-table th[scope='row'] {
  font-weight: 500;
}
.minutes-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.minutes-repo {
  display: block;
  font-family: var(--font-mono);
}
.minutes-allow {
  white-space: nowrap;
}
.minutes-allow input {
  width: 6.5em;
}
.minutes-bar {
  min-width: 90px;
}
.minutes-table tr.over th[scope='row'] a {
  color: var(--danger);
}
.minutes-list {
  margin: 0;
  padding-left: 18px;
}
@media (max-width: 640px) {
  .minutes-table .minutes-bar {
    display: none;
  }
  .minutes-table th,
  .minutes-table td {
    padding: 8px 4px;
  }
  .minutes-allow input {
    width: 5.75em;
  }
  .minutes-repo {
    overflow-wrap: anywhere;
  }
}

.brand-flow {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- accounts ---------- */
.auth-card {
  max-width: 440px;
  margin: 48px auto;
  padding: 28px;
}
.auth-card h1 {
  font-size: 1.4rem;
  margin: 0 0 8px;
}
.auth-card form label,
.account-card form label {
  display: block;
  margin: 14px 0 0;
}
.auth-card form input,
.account-card form input,
.account-card form select {
  width: 100%;
  max-width: 100%;
  margin-top: 6px;
}
.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
.account-card {
  padding: 22px;
}
.account-card h2 {
  font-size: 1.05rem;
  margin: 0 0 10px;
}
.account-wide {
  grid-column: 1 / -1;
}
.account-card .btn-row {
  margin-top: 14px;
}
.session-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.session-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.session-list li:first-child {
  border-top: 0;
}
.session-list .muted {
  display: block;
  margin-top: 2px;
}
.account-card .secret {
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  word-break: break-all;
}
.account-card pre.recovery {
  font-family: var(--font-mono);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  columns: 2;
}
.account-card .steps {
  padding-left: 20px;
}
.org-switch {
  max-width: 200px;
  padding: 6px 10px;
}
@media (max-width: 640px) {
  .org-switch {
    max-width: 130px;
  }
}

/* Viewers read only: hide the controls that change things (the server refuses them anyway). */
body[data-role='viewer'] :is([data-action='new'], [data-action='delete'], [data-action='move-task'], [data-action='move-to'],
  [data-action='return-task'], [data-action='issue-status'], [data-action='issue-card-status'], [data-action='issue-delete'],
  [data-action='rotate-ingest-key'], [data-action='minutes-save'], [data-action='minutes-refresh'], .quick-add, .status-select) {
  display: none !important;
}
body[data-role='viewer'] [data-action='edit'] {
  pointer-events: none;
}
.member-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-form {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 12px;
  align-items: end;
  margin-top: 8px;
}
.key-form .btn-row {
  margin: 0;
}
@media (max-width: 640px) {
  .key-form {
    grid-template-columns: 1fr;
  }
}

.secrets-card {
  margin-top: 16px;
}
.secret-row {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.secret-row .block {
  display: block;
  margin-top: 4px;
}
.secret-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.secret-form input {
  flex: 1;
}
.account-card textarea,
.account-card select {
  width: 100%;
  margin-top: 6px;
}
.account-card .grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
#settings-form label {
  display: block;
  margin: 14px 0 0;
}
#settings-form input {
  width: 100%;
  margin-top: 6px;
}

.billing-card {
  margin-top: 16px;
}
.meter-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  display: grid;
  gap: 12px;
}
.meter-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
}
.meter-list li > :last-child:not(span) {
  grid-column: 1 / -1;
}
