:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-2: #18212d;
  --border: #243041;
  --text: #e8eef7;
  --muted: #8b9bb0;
  --accent: #5b9dff;
  --warning: #f0b429;
  --danger: #ff6b6b;
  --ok: #3dd68c;
  --comment: #a78bfa;
  --status: #60a5fa;
  --people: #34d399;
  --subtask: #2dd4bf;
  --stuck: #fbbf24;
  --other: #94a3b8;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1600px 700px at 8% -10%, #152033 0%, var(--bg) 50%);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}
.shell-wide {
  max-width: min(1680px, 98vw);
  padding: 16px 20px 48px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.brand { display: flex; flex-direction: column; gap: 1px; }
.project-kicker {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 650;
}
.brand span { color: var(--muted); font-size: 0.82rem; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: rgba(61, 214, 140, 0.08);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 0.76rem;
}
.live-pill.error { background: rgba(255, 107, 107, 0.08); }
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  animation: pulse 2.2s infinite;
}
.live-pill.error .live-dot { background: var(--danger); animation: none; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(61, 214, 140, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(61, 214, 140, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 214, 140, 0); }
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 9px;
  padding: 7px 11px;
  font-size: 0.86rem;
  cursor: pointer;
}
.btn:hover { border-color: #3a4d68; }
.btn.primary {
  background: linear-gradient(180deg, #4d8ef5, #3a74d4);
  border-color: #3a74d4;
  color: white;
  font-weight: 600;
}
.btn.ghost { background: transparent; }

.stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  min-width: 84px;
}
.stat strong { display: block; font-size: 1.05rem; }
.stat span { color: var(--muted); font-size: 0.72rem; }

.filters-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.last-check {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding: 4px 2px;
}
.chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.78rem;
  cursor: pointer;
}
.chip:hover { border-color: #3a4d68; color: var(--text); }
.chip.active {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(91, 157, 255, 0.12);
  font-weight: 600;
}
.chip .n {
  opacity: 0.7;
  margin-left: 3px;
  font-variant-numeric: tabular-nums;
}

/* Compact single-row feed */
.feed {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  min-height: 0;
  transition: border-color 0.15s;
}
.card:hover { border-color: #354860; }
.card.unread {
  background: #141c28;
}
.card.fresh {
  animation: fadeIn 0.3s ease both;
}
.card.type-comments { --type: var(--comment); }
.card.type-status { --type: var(--status); }
.card.type-people { --type: var(--people); }
.card.type-subtasks { --type: var(--subtask); }
.card.type-stuck { --type: var(--stuck); }
.card.type-other { --type: var(--other); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--type, var(--muted));
  white-space: nowrap;
}
.type-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--type, var(--muted));
  flex-shrink: 0;
}

.card-mid {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.card-board {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.subtask-tag {
  flex-shrink: 0;
  max-width: 220px;
  font-size: 0.7rem;
  font-weight: 650;
  color: #9fd0ff;
  background: rgba(91, 157, 255, 0.1);
  border: 1px solid rgba(91, 157, 255, 0.28);
  border-radius: 6px;
  padding: 2px 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.time-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
  line-height: 1.15;
}
.time-today {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #86efac;
}
.card-line {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.4;
  color: #b8c5d6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-line.comment {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  color: #d5def0;
  margin-top: 1px;
  padding-top: 2px;
}

/* Author name chip */
.who-name {
  display: inline-block;
  color: #fff;
  font-weight: 700;
  background: rgba(91, 157, 255, 0.2);
  border: 1px solid rgba(91, 157, 255, 0.4);
  border-radius: 5px;
  padding: 1px 7px;
  margin-right: 4px;
  font-size: 0.8rem;
  line-height: 1.35;
  vertical-align: baseline;
}
.who-sep {
  color: var(--muted);
  font-weight: 500;
  margin-right: 2px;
}
/* @mention only — does not wrap surrounding sentence */
.mention {
  display: inline;
  color: #f3e8ff;
  font-weight: 700;
  background: rgba(167, 139, 250, 0.28);
  border: 1px solid rgba(167, 139, 250, 0.45);
  border-radius: 4px;
  padding: 0 4px;
  margin: 0 1px;
  white-space: nowrap;
  line-height: inherit;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.comment-text {
  color: #e4ebf7;
  font-weight: 400;
}

/* Section as small subtask-style chip */
.section-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 200px;
  font-size: 0.72rem;
  color: #c9b27a;
  background: rgba(201, 178, 122, 0.08);
  border: 1px solid rgba(201, 178, 122, 0.22);
  border-radius: 6px;
  padding: 4px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.section-chip::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: #c9b27a;
  flex-shrink: 0;
  opacity: 0.85;
}

.card-right {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: end;
}

.meta-time {
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 0.92;
}
.time-stack .meta-time {
  font-size: 0.95rem;
}

.asana-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}
.asana-link:hover {
  border-color: #f06a6a;
  background: rgba(240, 106, 106, 0.1);
  text-decoration: none;
}
.asana-link svg {
  width: 18px;
  height: 18px;
  display: block;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
  border: 1px dashed var(--border);
  border-radius: 12px;
}

/* Sync panel + terminal */
.sync-panel {
  background: #0a0e13;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px 14px;
  margin-bottom: 14px;
}
.sync-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.sync-head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
}
.sync-sub {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}
.sync-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge.run {
  color: #86efac;
  border-color: rgba(134, 239, 172, 0.35);
  background: rgba(34, 197, 94, 0.1);
}
.badge.idle {
  color: var(--muted);
}
.badge.err {
  color: #fca5a5;
  border-color: rgba(252, 165, 165, 0.35);
  background: rgba(239, 68, 68, 0.1);
}
.sync-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.sync-stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  min-width: 72px;
}
.sync-stat strong {
  display: block;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}
.sync-stat span {
  font-size: 0.68rem;
  color: var(--muted);
}
.sync-body {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(0, 1.6fr);
  gap: 10px;
}
@media (max-width: 900px) {
  .sync-body { grid-template-columns: 1fr; }
}
.queue-box, .term-box {
  background: #070a0e;
  border: 1px solid #1c2736;
  border-radius: 8px;
  overflow: hidden;
  min-height: 160px;
  display: flex;
  flex-direction: column;
}
.box-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7a8aa0;
  padding: 6px 10px;
  border-bottom: 1px solid #1c2736;
  background: #0d1218;
}
.queue-list {
  padding: 8px 10px;
  overflow: auto;
  max-height: 200px;
  font-size: 0.78rem;
  line-height: 1.4;
}
.queue-list .q-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(28, 39, 54, 0.6);
  color: #c5d0df;
}
.queue-list .q-item span {
  color: #8b9bb0;
  white-space: nowrap;
}
.queue-list .muted { color: var(--muted); }
.term {
  margin: 0;
  padding: 8px 10px 12px;
  max-height: 220px;
  overflow: auto;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 0.74rem;
  line-height: 1.45;
  color: #9fefb0;
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
}
.term .t-time { color: #5a6a80; }
.term .t-ok { color: #86efac; }
.term .t-error { color: #fca5a5; }
.term .t-warn { color: #fde68a; }
.term .t-info { color: #93c5fd; }
.btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

@media (max-width: 900px) {
  .card {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "badge time"
      "mid mid"
      "section asana";
    gap: 6px 10px;
    padding: 10px 12px;
  }
  .type-badge { grid-area: badge; }
  .card-mid { grid-area: mid; }
  .section-chip { grid-area: section; max-width: none; }
  .card-right {
    grid-area: time;
    gap: 8px;
  }
  .asana-link {
    grid-area: asana;
    justify-self: end;
  }
  .card-board, .card-line { white-space: normal; }
}

/* Login / admin */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-card h1 { margin: 0 0 6px; font-size: 1.35rem; }
.login-card p { margin: 0 0 20px; color: var(--muted); font-size: 0.92rem; }
label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}
input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 12px;
  margin-bottom: 14px;
  font-size: 1rem;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,157,255,0.15);
}
.msg {
  min-height: 1.2em;
  font-size: 0.85rem;
  margin: 0 0 10px;
  color: var(--muted);
}
.msg.error { color: var(--danger); }
.msg.ok { color: var(--ok); }

.admin-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admin-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.row input { margin: 0; flex: 1; min-width: 180px; }
