/* Unified Project Control Board — one stylesheet, one status palette. Dark is default. */

:root {
  --bg: #0b1016;
  --bg-elev: #121a24;
  --bg-elev-2: #182231;
  --line: #24313f;
  --text: #e6edf5;
  --text-dim: #93a4b8;
  --accent: #4c8dff;

  /* status palette (§ style rules: GREEN healthy, YELLOW warning, RED critical,
     GRAY unknown, BLUE informational) */
  --status-green: #35c26a;
  --status-yellow: #e0b23c;
  --status-red: #e2564d;
  --status-gray: #6c7a8c;
  --status-blue: #4c8dff;

  --radius: 10px;
  --gap: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Noto Sans Thai", "Segoe UI", system-ui, -apple-system, sans-serif;
}

#board-root {
  max-width: 1680px;
  margin: 0 auto;
  padding: 18px 20px 40px;
  display: grid;
  gap: var(--gap);
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  flex-wrap: wrap;
  padding: 14px 16px;
  background: linear-gradient(180deg, var(--bg-elev-2), var(--bg-elev));
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.topbar__left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar__title { font-size: 17px; font-weight: 650; letter-spacing: .2px; }
.topbar__badge {
  font-size: 11px; font-weight: 700; letter-spacing: .8px;
  padding: 3px 8px; border-radius: 999px;
  color: #0b1016; background: var(--status-yellow);
}
.topbar__right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar__cycle { font-size: 12px; color: var(--text-dim); letter-spacing: 1px; }
.topbar__status { font-size: 12px; color: var(--text-dim); }

.notice {
  margin: 0;
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--status-yellow);
  background: rgba(224, 178, 60, .08);
  border: 1px solid rgba(224, 178, 60, .35);
  border-radius: var(--radius);
}

/* ---------- health ---------- */
.health { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.health__tile {
  padding: 10px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-left: 3px solid var(--status-gray);
  border-radius: var(--radius);
  display: grid; gap: 4px;
}
.health__tile--green { border-left-color: var(--status-green); }
.health__tile--yellow { border-left-color: var(--status-yellow); }
.health__tile--red { border-left-color: var(--status-red); }
.health__tile--blue { border-left-color: var(--status-blue); }
.health__label { font-size: 11.5px; color: var(--text-dim); }
.health__value { font-size: 21px; font-weight: 680; }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter__control, .filter__clear {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
}
.filter__clear { cursor: pointer; color: var(--text-dim); }
.filter__clear:hover { color: var(--text); border-color: var(--accent); }

/* ---------- breadcrumb ---------- */
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.breadcrumb__item {
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 12.5px; padding: 4px 6px; border-radius: 6px;
}
.breadcrumb__item:hover { color: var(--text); background: var(--bg-elev); }
.breadcrumb__item--current { color: var(--text); font-weight: 650; }
.breadcrumb__sep { color: var(--text-dim); }

/* ---------- zones ---------- */
.zones { display: grid; grid-template-columns: minmax(320px, 1.15fr) minmax(380px, 1.5fr) minmax(320px, 1.1fr); gap: var(--gap); }
.zone, .detail-zone {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  min-width: 0;
}
.zone__stack { display: grid; gap: var(--gap); }
.zone__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.zone__meta { display: grid; gap: 4px; min-width: 190px; }
.zone__meta-label { font-size: 11.5px; color: var(--text-dim); }
.section__title { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .3px; color: var(--text); }
.dep__title { margin: 14px 0 8px; font-size: 12px; font-weight: 700; color: var(--text-dim); letter-spacing: .4px; }
.empty { margin: 6px 0; font-size: 12.5px; color: var(--text-dim); }

/* ---------- map ---------- */
.map__bulk { display: flex; gap: 6px; margin-bottom: 6px; }
.map__bulk-btn { background: var(--bg-elev-2); border: 1px solid var(--line); color: var(--text-dim); font-size: 11px; padding: 3px 8px; border-radius: 999px; cursor: pointer; }
.map__bulk-btn:hover { color: var(--text); border-color: var(--accent); }
.map__node { margin-left: 0; }
.map__row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px; border-radius: 8px; border: 1px solid transparent;
}
.map__row:hover { background: var(--bg-elev-2); }
.map__row.is-selected { border-color: var(--accent); background: rgba(76, 141, 255, .12); }
.map__row.is-ancestor { border-color: rgba(76, 141, 255, .35); }
.map__toggle {
  width: 20px; height: 20px; flex: none;
  background: var(--bg-elev-2); color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-size: 11px; line-height: 1;
}
.map__toggle--leaf { background: none; border: none; cursor: default; }
.map__label { display: flex; align-items: baseline; gap: 7px; background: none; border: none; cursor: pointer; color: var(--text); text-align: left; min-width: 0; }
.map__level { font-size: 10.5px; color: var(--text-dim); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; flex: none; }
.map__name { font-size: 13px; }
.map__progress { margin-left: auto; font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.map__children { margin-left: 14px; border-left: 1px dashed var(--line); padding-left: 8px; }

/* ---------- chips + progress ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; padding: 2px 7px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--text-dim); flex: none;
}
.chip__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--status-gray); }
.chip--green { color: var(--status-green); border-color: rgba(53, 194, 106, .4); }
.chip--green .chip__dot { background: var(--status-green); }
.chip--yellow { color: var(--status-yellow); border-color: rgba(224, 178, 60, .4); }
.chip--yellow .chip__dot { background: var(--status-yellow); }
.chip--red { color: var(--status-red); border-color: rgba(226, 86, 77, .45); }
.chip--red .chip__dot { background: var(--status-red); }
.chip--blue { color: var(--status-blue); border-color: rgba(76, 141, 255, .4); }
.chip--blue .chip__dot { background: var(--status-blue); }

.progress { display: grid; gap: 4px; }
.progress__bars { display: grid; gap: 3px; }
.progress__track { height: 6px; background: var(--bg-elev-2); border-radius: 999px; overflow: hidden; }
.progress__fill { height: 100%; border-radius: 999px; }
.progress__fill--declared { background: var(--status-blue); }
.progress__fill--verified { background: var(--status-green); }
.progress__legend { display: flex; justify-content: space-between; gap: 8px; font-size: 10.5px; color: var(--text-dim); }
.progress__num--verified { color: var(--status-green); }
.progress--compact .progress__legend { font-size: 10px; }

/* ---------- execution monitor ---------- */
.exec__table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.exec__table th { text-align: left; font-size: 11px; color: var(--text-dim); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.exec__table td { padding: 8px; border-bottom: 1px solid rgba(36, 49, 63, .6); vertical-align: top; }
.exec__task { background: none; border: none; color: var(--text); cursor: pointer; padding: 0; font-size: 12.5px; text-align: left; }
.exec__task:hover { color: var(--accent); }
.exec__path { display: block; font-size: 10.5px; color: var(--text-dim); }
.exec__agent { font-size: 12px; }
.exec__state { font-size: 10.5px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line); }
.exec__state--running { color: var(--status-blue); border-color: rgba(76, 141, 255, .4); }
.exec__state--blocked { color: var(--status-red); border-color: rgba(226, 86, 77, .45); }
.exec__state--failed { color: var(--status-red); border-color: rgba(226, 86, 77, .45); }
.exec__state--completed { color: var(--status-green); border-color: rgba(53, 194, 106, .4); }
.exec__time { font-size: 10.5px; color: var(--text-dim); }
.exec__blocker-link { background: none; border: none; color: var(--status-red); cursor: pointer; font-size: 11.5px; padding: 0; text-align: left; }
.exec__none { color: var(--text-dim); }
.exec__cell--progress { min-width: 130px; }

.agent--orchestrator { border-color: rgba(76, 141, 255, .45); }
.agent__children { display: grid; gap: 6px; margin: 6px 0 0 12px; padding-left: 10px; border-left: 1px dashed var(--line); }
.agent--child { margin-bottom: 0; }
.agent { display: grid; gap: 4px; padding: 8px 10px; background: var(--bg-elev-2); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; }
.agent__head { display: flex; gap: 8px; align-items: baseline; }
.agent__name { font-weight: 650; font-size: 12.5px; }
.agent__role { font-size: 11px; color: var(--text-dim); }
.agent__counts { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; color: var(--text-dim); }

.blocker { display: grid; gap: 5px; padding: 9px 10px; border: 1px solid var(--line); border-left: 3px solid var(--status-gray); border-radius: 8px; margin-bottom: 6px; }
.blocker--critical { border-left-color: var(--status-red); background: rgba(226, 86, 77, .06); }
.blocker--high { border-left-color: var(--status-yellow); }
.blocker--medium { border-left-color: var(--status-blue); }
.blocker.is-selected { outline: 1px solid var(--status-red); }
.blocker__head { display: flex; gap: 8px; align-items: baseline; }
.blocker__severity { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; }
.blocker--critical .blocker__severity { color: var(--status-red); }
.blocker--high .blocker__severity { color: var(--status-yellow); }
.blocker__title { font-size: 12.5px; font-weight: 600; }
.blocker__body { display: grid; gap: 2px; font-size: 11.5px; color: var(--text-dim); }
.blocker__downstream { display: flex; flex-wrap: wrap; gap: 6px; }
.blocker__downstream-item { background: var(--bg-elev-2); border: 1px solid var(--line); color: var(--text-dim); font-size: 11px; padding: 2px 7px; border-radius: 999px; cursor: pointer; }
.blocker__downstream-item:hover { color: var(--text); border-color: var(--status-red); }

.critical__step { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 8px; }
.critical__step:hover { background: var(--bg-elev-2); }
.critical__index { width: 18px; height: 18px; flex: none; display: grid; place-items: center; font-size: 10.5px; border-radius: 50%; background: var(--bg-elev-2); border: 1px solid var(--line); color: var(--text-dim); }
.critical__name { background: none; border: none; color: var(--text); cursor: pointer; font-size: 12.5px; padding: 0; }
.critical__progress { margin-left: auto; font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ---------- dependency graph ---------- */
.dep__context { display: flex; gap: 8px; font-size: 12px; margin-bottom: 6px; }
.dep__context-label { color: var(--text-dim); }
.dep__grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.dep__column { background: var(--bg-elev-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; min-width: 0; }
.dep__column--self { border-color: rgba(76, 141, 255, .45); }
.dep__node { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.dep__label { background: none; border: none; color: var(--text); cursor: pointer; font-size: 12px; padding: 0; text-align: left; }
.dep__label:hover { color: var(--accent); }
.dep__node--upstream .dep__label { color: var(--text-dim); }
.dep__parallel { margin-top: 8px; }
.dep__group { display: flex; align-items: center; gap: 8px; font-size: 11.5px; padding: 5px 8px; border: 1px dashed var(--line); border-radius: 8px; margin-bottom: 5px; }
.dep__group-sources { white-space: pre-line; color: var(--text-dim); }
.dep__group-arrow { color: var(--accent); }
.dep__group-target { font-weight: 600; }

/* ---------- validation ---------- */
.val__scope { display: grid; gap: 6px; margin-bottom: 10px; }
.val__list { display: grid; gap: 4px; }
.val__row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 5px 7px; border-radius: 8px; border: 1px solid var(--line); font-size: 11.5px; }
.val__row--verified { border-left: 3px solid var(--status-green); }
.val__row--partial_match { border-left: 3px solid var(--status-yellow); }
.val__row--not_verified { border-left: 3px solid var(--status-gray); }
.val__row--verification_failed { border-left: 3px solid var(--status-red); }
.val__row-name { flex: 1 1 180px; }
.val__row-progress { margin-left: auto; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.val__panel { display: grid; gap: 8px; }
.val__warning { margin: 0; padding: 8px 10px; font-size: 12px; color: var(--status-yellow); background: rgba(224, 178, 60, .08); border: 1px solid rgba(224, 178, 60, .35); border-radius: 8px; }
.val__evidence { display: grid; gap: 5px; }
.evidence { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; padding: 5px 8px; background: var(--bg-elev-2); border: 1px solid var(--line); border-radius: 8px; font-size: 11.5px; }
.evidence__type { font-weight: 650; color: var(--status-blue); }
.evidence__platform { color: var(--text-dim); }
.evidence__ref { color: var(--text-dim); flex: 1 1 200px; }

/* ---------- key/value ---------- */
.kv { display: flex; gap: 10px; font-size: 12.5px; padding: 3px 0; border-bottom: 1px solid rgba(36, 49, 63, .5); }
.kv__k { flex: 0 0 148px; color: var(--text-dim); font-size: 11.5px; }
.kv__v { flex: 1 1 auto; min-width: 0; }

/* ---------- detail ---------- */
.detail { display: grid; gap: 8px; }
.detail__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail__name { font-size: 14px; font-weight: 650; }
.detail__blocker { display: grid; gap: 2px; padding: 6px 8px; border-left: 3px solid var(--status-red); background: rgba(226, 86, 77, .06); border-radius: 6px; font-size: 11.5px; }
.detail__links { display: flex; flex-wrap: wrap; gap: 6px; }
.detail__link { background: var(--bg-elev-2); border: 1px solid var(--line); color: var(--text-dim); font-size: 11px; padding: 2px 8px; border-radius: 999px; cursor: pointer; }
.detail__link:hover { color: var(--text); border-color: var(--accent); }

/* ---------- footer ---------- */
.footer { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11px; color: var(--text-dim); border-top: 1px solid var(--line); padding-top: 10px; }

/* ---------- responsive (mobile-first behaviour on small screens) ---------- */
@media (max-width: 1180px) {
  .zones { grid-template-columns: 1fr; }
  .dep__grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  #board-root { padding: 12px; }
  .health { grid-template-columns: repeat(2, 1fr); }
  .exec__table { font-size: 12px; }
  .exec__table th:nth-child(6), .exec__table td:nth-child(6) { display: none; }
  .kv { flex-direction: column; gap: 2px; }
  .kv__k { flex: none; }
}
