:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --blue: #3b82f6;
  --accent: #6366f1;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(1rem + var(--safe-bottom));
}

a { color: #93c5fd; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(26, 35, 50, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1rem;
}

.header-main h1 {
  font-size: 1.1rem;
  font-weight: 700;
}

.tagline {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 0.15rem;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.meta-pill {
  font-size: 0.68rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--surface2);
  color: var(--muted);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  overflow-x: auto;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.5rem;
  text-align: center;
  min-width: 4.5rem;
}

.summary-card.warn .val { color: var(--red); }

.summary-card .val {
  font-size: 1.25rem;
  font-weight: 700;
}

.summary-card .lbl {
  font-size: 0.62rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.filter-bar {
  display: flex;
  gap: 0.4rem;
  padding: 0 1rem 0.75rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.filter {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-size: 0.78rem;
  cursor: pointer;
  min-height: 2.5rem;
}

.filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

main {
  padding: 0 1rem 1.25rem;
  max-width: 1200px;
  margin: 0 auto;
}

.section { margin-bottom: 1.25rem; }

.section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.project-list {
  display: grid;
  gap: 0.75rem;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.project-card:active,
.project-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.project-name {
  font-size: 1rem;
  font-weight: 600;
}

.project-stage {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.card-badges {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: flex-end;
}

.pill, .status-pill, .infra-pill {
  display: inline-block;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
}

.pill.green, .infra-pill.live { background: rgba(34,197,94,0.18); color: var(--green); }
.pill.yellow, .infra-pill.warn { background: rgba(234,179,8,0.18); color: var(--yellow); }
.pill.red, .infra-pill.bad { background: rgba(239,68,68,0.18); color: var(--red); }
.pill.blue { background: rgba(59,130,246,0.18); color: var(--blue); }
.infra-pill.muted { background: var(--surface2); color: var(--muted); }

.status-pill.in-progress { background: rgba(99,102,241,0.2); color: #a5b4fc; }
.status-pill.waiting { background: rgba(59,130,246,0.2); color: var(--blue); }
.status-pill.blocked { background: rgba(239,68,68,0.2); color: var(--red); }
.status-pill.complete { background: rgba(34,197,94,0.2); color: var(--green); }

.progress-row { margin: 0.75rem 0; }

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.metric {
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.5rem 0.55rem;
  font-size: 0.72rem;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.62rem;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.mini-list {
  list-style: none;
  padding: 0;
  margin: 0;
  color: var(--red);
  font-size: 0.68rem;
}

.mini-list li { margin-bottom: 0.15rem; }

.muted-text { color: var(--muted); font-size: 0.72rem; }

.count-badge {
  background: rgba(59,130,246,0.2);
  color: var(--blue);
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem;
}

.card-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.timestamp { font-size: 0.68rem; color: var(--muted); }

.card-links, .detail-links {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.link-btn {
  display: inline-block;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 0.75rem;
  min-height: 2.25rem;
  line-height: 1.4;
}

.link-btn.primary {
  background: rgba(99,102,241,0.2);
  border-color: var(--accent);
  color: #c7d2fe;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.panel.danger { border-color: rgba(239,68,68,0.4); }

.panel-head {
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.85rem;
}

.alerts { padding: 0.5rem; }

.alert {
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.45rem;
  font-size: 0.78rem;
  cursor: pointer;
  border-left: 3px solid;
}

.alert.high { border-color: var(--red); background: rgba(239,68,68,0.08); }
.alert.medium { border-color: var(--yellow); background: rgba(234,179,8,0.08); }
.alert.low { border-color: var(--muted); background: var(--surface2); }

.alert .proj { font-weight: 600; margin-bottom: 0.15rem; }

.owner-list { padding: 0.5rem; }

.owner-item {
  padding: 0.7rem;
  border-radius: 8px;
  margin-bottom: 0.45rem;
  background: var(--surface2);
  cursor: pointer;
  font-size: 0.8rem;
}

.owner-item.blocking { border-left: 3px solid var(--red); }

.owner-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.owner-id { color: var(--muted); font-size: 0.72rem; }
.owner-rec { color: var(--muted); font-size: 0.75rem; margin-top: 0.2rem; }

.owner-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.4rem;
  font-size: 0.68rem;
  color: var(--muted);
}

.detail.hidden { display: none; }

.detail-header {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.back-btn {
  align-self: flex-start;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  min-height: 2.5rem;
}

.detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
}

.stat-box .label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
}

.stat-box .value {
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 0.2rem;
}

.stat-box .value.small { font-size: 0.95rem; }

.stat-box .note { font-size: 0.68rem; color: var(--muted); margin-top: 0.25rem; }

.audit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: 0.45rem;
  padding: 0.75rem;
}

.audit-item {
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.72rem;
}

.audit-item .name { color: var(--muted); margin-bottom: 0.2rem; }
.audit-item.pass { color: var(--green); }
.audit-item.warning { color: var(--yellow); }
.audit-item.fail { color: var(--red); }

.list-block {
  padding: 0.75rem 0.9rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.list-block ul { padding-left: 1.1rem; }
.list-block li { margin-bottom: 0.3rem; }

.stop-note {
  color: var(--red);
  font-size: 0.82rem;
  margin-bottom: 0.75rem;
}

.empty {
  padding: 0.85rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.load-error {
  padding: 2rem 1rem;
  font-family: var(--font);
}

.hidden { display: none !important; }

/* Tablet */
@media (min-width: 640px) {
  .site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
  }

  .header-meta { margin-top: 0; }

  .project-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .detail-header {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .header-main h1 { font-size: 1.35rem; }

  .summary-strip {
    grid-template-columns: repeat(4, 1fr);
    max-width: 720px;
    margin: 0 auto;
    padding-top: 1rem;
  }

  .filter-bar {
    justify-content: center;
    max-width: 720px;
    margin: 0 auto 0.5rem;
  }

  .project-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .detail-stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1280px) {
  .project-list {
    grid-template-columns: repeat(3, 1fr);
  }
}
