:root {
  --bg: #0b1220;
  --panel: #101a2e;
  --panel-2: #0d1626;
  --border: #22314f;
  --text: #e2e8f0;
  --muted: #8aa0bf;
  --accent: #00b6c7;
  --accent-ink: #04252a;
  --radius: 12px;
  --touch: 44px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  overflow-x: hidden;
}
body.detail-open { overflow: hidden; }

/* Topbar */
.topbar {
  background: linear-gradient(180deg, #0f1930, #0c1425);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1400px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { font-size: 26px; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 650; color: #fff; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topbar-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--border); background: var(--panel-2);
  border-radius: 999px; padding: 4px 12px; font-size: 12.5px; color: var(--text);
}
.pill-muted { color: var(--muted); }

/* Layout */
.wrap { max-width: 1400px; margin: 0 auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) and (min-width: 769px) {
  .grid { grid-template-columns: 1fr; }
  .detail.hidden-mobile { display: none; }
  .list.hidden-mobile { display: none; }
}

/* Filters */
.filters { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); width: 96px; flex-shrink: 0; }
.search { position: relative; flex: 1; min-width: 220px; }
.search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--muted); fill: none; stroke-width: 2; }
.search input {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 9px 12px 9px 34px; font-size: 14px; outline: none;
  min-height: var(--touch);
}
.search input:focus { border-color: var(--accent); }
.chip {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  border-radius: 999px; padding: 4px 12px; font-size: 12.5px; cursor: pointer; transition: all .12s;
  min-height: var(--touch); min-width: var(--touch);
  display: inline-flex; align-items: center; justify-content: center;
}
.chip:hover { border-color: #3b5175; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer;
  min-height: var(--touch); display: inline-flex; align-items: center; justify-content: center;
}
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--panel-2); }

/* Tabel — desktop / tablet */
.list { max-height: calc(100dvh - 320px); min-height: 320px; overflow: auto; }
.projects { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: fixed; }
.projects thead th {
  position: sticky; top: 0; background: var(--panel-2); text-align: left;
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--border); z-index: 5;
}
.projects td { padding: 10px 14px; border-top: 1px solid #182742; vertical-align: middle; }
.projects tbody tr { cursor: pointer; transition: background .12s ease; }
.projects tbody tr:hover { background: #14203a; }
.projects tbody tr.active {
  background: #1a3358;
  box-shadow: inset 3px 0 0 var(--accent);
}
.projects tbody tr.active .p-name { color: #7ee7f0; }
.projects .num { text-align: right; font-variant-numeric: tabular-nums; width: 4.5rem; }
.projects th:nth-child(1), .projects td:nth-child(1) { width: 38%; }
.projects th:nth-child(2), .projects td:nth-child(2) { width: 7.5rem; white-space: nowrap; }
.projects th:nth-child(3), .projects td:nth-child(3) {
  width: 8.5rem; min-width: 8.5rem; white-space: nowrap; overflow: visible;
}
.projects th:nth-child(4), .projects td:nth-child(4) { width: 22%; }
.p-name {
  display: block; font-weight: 600; color: #fff;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.p-sub {
  display: block; font-size: 12px; color: var(--muted);
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.p-last {
  color: var(--muted); font-size: 12.5px; display: block;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Mobile cards (hidden on desktop) */
.project-cards { display: none; }
.detail-backdrop { display: none; }

/* Badges — never shrink/clip */
.badge {
  display: inline-flex; align-items: center; flex-shrink: 0;
  border-radius: 6px; padding: 2px 8px; font-size: 11.5px; font-weight: 600;
  white-space: nowrap; max-width: none;
}
.b-active { background: rgba(16,185,129,.15); color: #34d399; }
.b-running { background: rgba(56,189,248,.15); color: #38bdf8; }
.b-blocked { background: rgba(245,158,11,.15); color: #fbbf24; }
.b-inactive { background: rgba(148,163,184,.12); color: #94a3b8; }
.b-done { background: rgba(167,139,250,.15); color: #a78bfa; }
.b-unknown { background: rgba(148,163,184,.12); color: #64748b; }
.g-in_git_sync { background: rgba(16,185,129,.15); color: #34d399; }
.g-in_git_dirty { background: rgba(245,158,11,.15); color: #fbbf24; }
.g-in_git_unknown { background: rgba(148,163,184,.12); color: #94a3b8; }
.g-container_only { background: rgba(249,115,22,.15); color: #fb923c; }
.g-not_in_git { background: rgba(244,63,94,.15); color: #fb7185; }
.g-n_a { background: rgba(148,163,184,.08); color: #64748b; }
.o-grok { background: rgba(99,102,241,.15); color: #818cf8; }
.o-puk { background: rgba(20,184,166,.15); color: #2dd4bf; }
.o-either { background: rgba(148,163,184,.12); color: #cbd5e1; }
.o-sander { background: rgba(217,70,239,.15); color: #e879f9; }

/* Detail */
.detail { padding: 18px; max-height: calc(100dvh - 320px); min-height: 320px; overflow: auto; }
.detail.flash { animation: detail-in .28s ease; }
@keyframes detail-in {
  from { opacity: .55; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.d-title { font-size: 17px; font-weight: 650; color: #fff; margin: 0 0 4px; word-break: break-word; }
.d-badges { display: flex; gap: 8px; margin: 8px 0 14px; flex-wrap: wrap; }
.d-desc { color: #c7d2e4; margin: 0 0 6px; }
.d-long { color: #9fb2cd; font-size: 13.5px; }
.d-section { margin-top: 18px; }
.d-section h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; display: flex; align-items: center; gap: 6px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.log li { font-size: 13.5px; color: #c7d2e4; padding-left: 14px; position: relative; }
.log li::before { content: ""; position: absolute; left: 0; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.log .when { color: var(--muted); font-size: 12px; margin-right: 6px; }
.log .actor { color: var(--accent); font-size: 12px; margin-right: 6px; }
.task {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
  background: var(--panel-2);
}
.task-title { font-weight: 600; color: #fff; font-size: 13.5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.task-brief { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; }

/* Lege en foutstates */
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.error-box { margin: 20px; padding: 16px; border: 1px solid #7f1d1d; background: rgba(127,29,29,.25); border-radius: 10px; color: #fecaca; }
.hidden { display: none !important; }

/* Footer */
.foot {
  max-width: 1400px; margin: 0 auto; padding: 12px 20px 28px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  color: #5d7395; font-size: 12px;
}
.foot code { font-size: 11.5px; }

/* Mobiel / tablet mid */
.mobile-only { display: none; }
@media (max-width: 1000px) and (min-width: 769px) {
  .mobile-only { display: inline-flex; margin-bottom: 12px; }
  .hide-md { display: none; }
  .kv { grid-template-columns: 90px 1fr; }
  .projects th:nth-child(3), .projects td:nth-child(3) { width: 7.5rem; min-width: 7.5rem; }
}

/* ===== r3: mobile-first ≤768px ===== */
@media (max-width: 768px) {
  .wrap { padding: 12px; gap: 12px; }
  .topbar-inner { padding: 10px 14px; }
  .brand h1 { font-size: 16px; }
  .filters { padding: 12px; }
  .filter-label { width: 100%; margin-bottom: 2px; }
  .filter-row { gap: 8px; }
  .search { min-width: 0; width: 100%; }
  .chip { padding: 8px 14px; font-size: 13px; }

  .grid { grid-template-columns: 1fr; gap: 0; }
  .list {
    max-height: none; min-height: 0; overflow: visible;
    border: none; background: transparent;
  }
  .list .projects { display: none; }

  .project-cards {
    display: flex; flex-direction: column; gap: 10px;
    padding: 0;
  }
  .project-card {
    display: flex; flex-direction: column; gap: 8px; align-items: stretch;
    width: 100%; text-align: left;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 14px 14px 16px;
    color: var(--text); cursor: pointer;
    min-height: var(--touch);
    -webkit-tap-highlight-color: transparent;
    transition: background .12s ease, border-color .12s ease;
  }
  .project-card:hover, .project-card:focus-visible {
    background: #14203a; outline: none; border-color: #3b5175;
  }
  .project-card.active {
    background: #1a3358;
    border-color: var(--accent);
    box-shadow: inset 3px 0 0 var(--accent);
  }
  .project-card.active .pc-name { color: #7ee7f0; }
  .pc-top {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  }
  .pc-name {
    font-weight: 650; color: #fff; font-size: 15px; line-height: 1.35;
    flex: 1; min-width: 0; word-break: break-word;
  }
  .pc-meta {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  }
  .pc-counts { font-size: 12px; color: var(--muted); }
  .pc-last {
    font-size: 12.5px; color: var(--muted);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .detail-backdrop {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(4, 10, 22, .55); opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
  }
  .detail-backdrop.open { opacity: 1; pointer-events: auto; }

  #detail-card.detail {
    position: fixed; inset: 0; z-index: 50;
    max-height: none; min-height: 0; height: 100dvh;
    border-radius: 0; border: none;
    padding: 0; display: flex; flex-direction: column;
    transform: translateY(100%);
    transition: transform .28s ease;
    background: var(--panel);
  }
  #detail-card.detail.overlay-open { transform: translateY(0); }
  #detail-card.detail.hidden-mobile { display: none; }
  #detail-card .mobile-only {
    display: inline-flex; margin: 0; flex-shrink: 0;
    width: 100%; justify-content: flex-start;
    border-radius: 0; border: none; border-bottom: 1px solid var(--border);
    min-height: var(--touch); padding: 12px 16px;
    background: var(--panel-2); font-weight: 600;
  }
  #detail { flex: 1; overflow: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
  .kv { grid-template-columns: 88px 1fr; }
  .hide-md { display: none; }
  .foot { padding: 8px 14px 20px; }
}
