/* Nielo Engineering — founder control room */

:root {
  --bg: #0d1117;
  --bg2: #151b23;
  --bg3: #1c2431;
  --border: #2a3140;
  --text: #e6edf3;
  --muted: #8b98a9;
  --green: #3fb950;
  --blue: #58a6ff;
  --amber: #d29922;
  --red: #f85149;
  --purple: #bc8cff;
  --teal: #39c5cf;
  --grey: #8b98a9;
  --accent: #58a6ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

button { font: inherit; color: inherit; }
input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
}
input:focus, textarea:focus, select:focus { outline: 1px solid var(--accent); border-color: var(--accent); }

.muted { color: var(--muted); font-weight: normal; }
.ok { color: var(--green); }
.fail { color: var(--red); }

/* ---------- header ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand { font-size: 16px; font-weight: 700; white-space: nowrap; }
.brand-sub { color: var(--muted); font-weight: 400; }
.topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }

.conn-indicator {
  font-size: 11px;
  color: #fff;
  background: var(--red);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.notif-perm-btn { white-space: nowrap; color: var(--muted); }
.notif-perm-btn:hover { color: var(--text); }

/* bell */
.bell-wrap { position: relative; }
.bell-btn {
  position: relative;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px 4px;
  cursor: pointer;
  color: var(--muted);
}
.bell-btn:hover { color: var(--text); background: var(--bg3); }
.bell-btn.has-high { color: var(--red); border-color: var(--red); }
.bell-count {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--amber);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9px;
  padding: 1px 5px;
  min-width: 17px;
  text-align: center;
}
.bell-btn.has-high .bell-count { background: var(--red); color: #fff; }

.notif-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 340px;
  max-width: 90vw;
  max-height: 60vh;
  overflow: auto;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 40;
}
.notif-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--bg3);
}
.notif-list .notif-item {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 13px;
}
.notif-list .notif-item:last-child { border-bottom: none; }
.notif-empty { padding: 14px 10px; color: var(--muted); font-size: 13px; }

/* ---------- primary nav ---------- */
.tabs {
  display: flex;
  gap: 2px;
  padding: 0 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 49px;
  z-index: 20;
  overflow-x: auto;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 11px 16px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
  font-size: 15px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-badge {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 8px;
  padding: 1px 5px;
  margin-left: 5px;
  vertical-align: 1px;
}

/* advanced sub-nav pills */
.pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  overflow-x: auto;
}
.pill {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.pill:hover { color: var(--text); }
.pill.active { color: var(--text); border-color: var(--accent); background: var(--bg3); }

/* ---------- layout ---------- */
main { padding: 16px 16px 48px; max-width: 1100px; margin: 0 auto; }
.view > * + * { margin-top: 14px; }
.dview > * + * { margin-top: 12px; }
#home-root > * + * { margin-top: 18px; }

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.card h2 { margin: 0 0 8px; font-size: 15px; }
.card h3 { margin: 0 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.inline-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }

.kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant: small-caps;
}

.section-title {
  margin: 30px 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.section-head .section-title { margin-bottom: 12px; }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- chips / badges / dots ---------- */
.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.chip-green  { background: rgba(63, 185, 80, 0.15);  color: var(--green); }
.chip-blue   { background: rgba(88, 166, 255, 0.15); color: var(--blue); }
.chip-amber  { background: rgba(210, 153, 34, 0.15); color: var(--amber); }
.chip-red    { background: rgba(248, 81, 73, 0.15);  color: var(--red); }
.chip-purple { background: rgba(188, 140, 255, 0.15); color: var(--purple); }
.chip-teal   { background: rgba(57, 197, 207, 0.15);  color: var(--teal); }
.chip-grey   { background: rgba(139, 152, 169, 0.15); color: var(--grey); }
.chip-darkred {
  background: rgba(158, 22, 22, 0.45);
  color: #ff9d97;
  border: 1px solid rgba(248, 81, 73, 0.4);
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-grey   { background: var(--grey); }
.dot-green  { background: var(--green); }
.dot-blue   { background: var(--blue); }
.dot-amber  { background: var(--amber); }
.dot-red    { background: var(--red); }
.dot-purple { background: var(--purple); }
.dot-busy   { background: var(--green); animation: pulse 1.5s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.5); }
  50% { opacity: 0.5; box-shadow: 0 0 0 4px rgba(63, 185, 80, 0); }
}
@keyframes softpulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---------- buttons ---------- */
.btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 12px;
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: #1f6feb; border-color: #1f6feb; color: #fff; font-weight: 600; }
.btn-primary:hover { background: #388bfd; }
.btn-danger { color: var(--red); border-color: rgba(248, 81, 73, 0.5); }
.btn-small { font-size: 12px; padding: 3px 8px; }

/* ================================================================
   HOME
   ================================================================ */

/* --- 1. compact status bar --- */
.status-bar {
  padding: 4px 2px 0;
}
.status-bar > * + * { margin-top: 8px; }
.status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.status-mission {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.state-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  flex-shrink: 0;
}
.state-green { background: rgba(63, 185, 80, 0.14); color: var(--green); border: 1px solid rgba(63, 185, 80, 0.4); }
.state-red   { background: rgba(248, 81, 73, 0.14); color: var(--red); border: 1px solid rgba(248, 81, 73, 0.45); }
.state-blue  { background: rgba(88, 166, 255, 0.14); color: var(--blue); border: 1px solid rgba(88, 166, 255, 0.4); }
.state-amber { background: rgba(210, 153, 34, 0.14); color: var(--amber); border: 1px solid rgba(210, 153, 34, 0.4); }
.state-grey  { background: rgba(139, 152, 169, 0.14); color: var(--grey); border: 1px solid rgba(139, 152, 169, 0.35); }

.status-progress { display: flex; align-items: center; gap: 10px; }
.status-progress .progress-bar { flex: 1; }
.status-pct { color: var(--muted); font-size: 12px; flex-shrink: 0; min-width: 34px; text-align: right; }

.progress-bar {
  height: 10px;
  background: var(--bg3);
  border-radius: 5px;
  overflow: hidden;
}
.progress-bar.thin { height: 5px; border-radius: 3px; }
.progress-fill { height: 100%; background: var(--green); border-radius: 5px; transition: width 0.4s; }
.progress-label { font-size: 13px; color: var(--muted); margin-top: 5px; }
.progress-wrap { margin-top: 4px; }

.focus-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
  min-width: 0;
}
.focus-line > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.focus-instr { flex-shrink: 0; font-size: 12px; color: var(--muted); }
.focus-instr:hover { color: var(--accent); }

.mission-full-desc {
  margin: 8px 0 0;
  padding: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
}

/* --- 1b. multi-mission strip --- */
.mission-strip { margin-top: 10px; }
.mstrip-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 4px;
  border-radius: 6px;
  cursor: pointer;
  min-width: 0;
}
.mstrip-row:hover { background: var(--bg3); }
.mstrip-name {
  flex-shrink: 0;
  max-width: 42%;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mstrip-bar { flex: 1; min-width: 60px; }
.mstrip-pct {
  color: var(--muted);
  font-size: 11px;
  flex-shrink: 0;
  min-width: 30px;
  text-align: right;
}
.mstrip-chip {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 1px 7px;
  border-radius: 9px;
  background: rgba(139, 152, 169, 0.15);
  color: var(--muted);
  opacity: 0.85;
}
.mstrip-critical { background: rgba(248, 81, 73, 0.14); color: var(--red); }

/* --- 2. needs you --- */
.quiet-line {
  color: var(--green);
  opacity: 0.75;
  font-size: 14px;
  padding: 2px 2px 0;
}
.needs-title { color: var(--red); margin-top: 22px; }

.needs-card {
  border-color: var(--red);
  border-left-width: 4px;
  background: rgba(248, 81, 73, 0.06);
}
.needs-card + .needs-card { margin-top: 10px; }
.needs-headline { font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.needs-summary { margin: 0 0 8px; color: var(--text); }
.needs-reco { color: var(--green); font-size: 14px; margin-bottom: 12px; }
.btn-review {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  font-weight: 600;
}
.btn-review:hover { background: #ff6a5e; border-color: #ff6a5e; }
.needs-full { margin-top: 12px; }
.needs-full .decision-card { border-left-width: 3px; }

.resolved-link { display: block; margin-top: 10px; color: var(--muted); font-size: 12px; }
.resolved-link:hover { color: var(--accent); }
.decisions-list { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }

/* --- 3. compact team list --- */
.team-list { padding: 0; overflow: hidden; }
.team-item { border-bottom: 1px solid var(--border); }
.team-item:last-child { border-bottom: none; }
.team-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  min-width: 0;
}
.team-row:hover { background: var(--bg3); }
.tglyph { flex-shrink: 0; font-size: 13px; width: 14px; text-align: center; }
.tg-working { color: var(--green); animation: softpulse 1.5s ease-in-out infinite; }
.tg-avail { color: var(--muted); opacity: 0.55; }
.tg-rest { color: var(--amber); }
.team-name {
  flex-shrink: 0;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 14px;
}
.crown { color: var(--purple); margin-right: 5px; font-size: 12px; opacity: 0.9; }
.team-doing {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.team-detail {
  padding: 4px 16px 14px 42px;
  font-size: 14px;
}
.team-detail > * + * { margin-top: 8px; }
.agent-role { color: var(--muted); font-size: 13px; }
.agent-status { font-size: 13px; font-weight: 600; }
.status-working { color: var(--green); }
.status-available { color: var(--muted); font-weight: 400; }
.status-resting { color: var(--amber); }
.agent-next { color: var(--muted); font-size: 13px; }

/* speech / work notes */
.speech {
  font-style: italic;
  color: var(--text);
  background: var(--bg3);
  border-left: 3px solid var(--border);
  border-radius: 0 8px 8px 0;
  padding: 8px 12px;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* stage strip */
.stage-wrap { font-size: 12px; }
.stage-strip { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.stage-step { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.stage-step.done .stage-mark, .stage-step.done .stage-name { color: var(--green); }
.stage-step.now .stage-mark { color: var(--blue); }
.stage-step.now .stage-name { color: var(--text); font-weight: 600; }
.stage-step.todo .stage-mark, .stage-step.todo .stage-name { color: var(--muted); opacity: 0.7; }
.stage-pulse { animation: softpulse 1.5s ease-in-out infinite; }
.stage-revising { margin-top: 4px; color: var(--amber); font-style: italic; }

/* --- 4. live discussion --- */
.discussion { padding: 2px 2px 0; }
.discussion > * + * { margin-top: 12px; }

.bubble-row { max-width: 720px; }
.bubble-meta { display: flex; gap: 8px; align-items: baseline; margin-bottom: 3px; }
.bubble-time { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.bubble-who { font-weight: 700; font-size: 13px; }
.bubble {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px;
  padding: 9px 13px;
  font-style: italic;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}

.dim-line {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-size: 12px;
  color: var(--muted);
  opacity: 0.8;
  padding: 0 2px;
  min-width: 0;
}
.dim-time { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; flex-shrink: 0; }
.dim-who { font-weight: 600; flex-shrink: 0; }
.dim-text { min-width: 0; word-break: break-word; }

/* --- 5. what's next --- */
.next-card { padding: 12px 16px; }
.next-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 4px 24px;
}
.next-row { padding: 7px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.next-title-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.next-title { font-weight: 600; font-size: 14px; word-break: break-word; }
.next-status { font-size: 12px; margin-top: 1px; }
.next-status-active { color: var(--blue); }
.next-status-up { color: var(--muted); }
.next-card .link-btn { margin-top: 10px; margin-right: 16px; }

/* scheduler notes */
.sched-notes { margin-top: 14px; padding: 0 4px; }
.sched-note { color: var(--muted); font-style: italic; font-size: 13px; }
.sched-note + .sched-note { margin-top: 3px; }

/* ================================================================
   PLAN TREE (Home expander + History roadmap)
   ================================================================ */

.plan-group-title {
  margin: 16px 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.plan-tree {
  border-left: 2px solid var(--border);
  margin-left: 9px;
  padding-left: 0;
}
.plan-item { position: relative; }
.plan-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 10px 10px 0;
  margin-left: -11px;
  cursor: pointer;
  border-radius: 8px;
}
.plan-row:hover { background: var(--bg3); }
.plan-ico {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 2px;
}
.ico-done   { color: var(--green); }
.ico-fail   { color: var(--red); font-weight: 700; }
.ico-you    { color: var(--red); }
.ico-todo   { color: var(--muted); opacity: 0.7; }
.ico-active { color: var(--blue); animation: softpulse 1.5s ease-in-out infinite; }

.plan-body { flex: 1; min-width: 0; }
.plan-body > * + * { margin-top: 6px; }
.plan-title-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.plan-item-title { font-size: 15px; font-weight: 600; }
.plan-status { font-size: 12px; }
.plan-status-green { color: var(--green); }
.plan-status-blue { color: var(--blue); }
.plan-status-red { color: var(--red); }
.plan-status-amber { color: var(--amber); }
.plan-status-grey { color: var(--muted); }

.plan-detail {
  margin: 0 0 10px 21px;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
}
.plan-detail-line { display: flex; gap: 10px; align-items: baseline; padding: 2px 0; }
.plan-detail-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 92px;
  flex-shrink: 0;
}

/* ================================================================
   HISTORY
   ================================================================ */

.hist-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.hist-item { padding: 0; overflow: hidden; }
.hist-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  min-width: 0;
}
.hist-row:hover { background: var(--bg3); }
.hist-name {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-when { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.hist-detail {
  border-top: 1px solid var(--border);
  padding: 12px 16px 16px;
}
.hist-detail > * + * { margin-top: 10px; }

/* ================================================================
   DECISION CARDS (inline on Home)
   ================================================================ */

.decision-card { border-left: 3px solid var(--red); }
.decision-card.resolved { border-left-color: var(--grey); opacity: 0.75; }
.decision-card h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 18px; }
.decision-sec { margin-top: 12px; }
.decision-sec h4 { margin: 0 0 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.decision-sec p { margin: 0 0 4px; white-space: pre-wrap; }
.recommended {
  background: rgba(63, 185, 80, 0.08);
  border: 1px solid rgba(63, 185, 80, 0.4);
  border-radius: 7px;
  padding: 10px 12px;
}
.alt-list { margin: 0; padding-left: 20px; }
.decision-note { width: 100%; margin-top: 12px; resize: vertical; }
.decision-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.empty-note { color: var(--muted); padding: 18px 4px; }

.decision-tech { margin-top: 12px; font-size: 13px; }
.decision-tech summary { cursor: pointer; color: var(--muted); }
.decision-tech summary:hover { color: var(--text); }
.decision-tech-body { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.action-ref { font-size: 10px; opacity: 0.85; }

/* ================================================================
   ADVANCED — tasks / activity / conversation / agents / audit /
              system / economics / capacity
   ================================================================ */

/* tasks */
.tasks-list { display: flex; flex-direction: column; gap: 10px; }
.task-card { padding: 0; overflow: hidden; }
.task-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  flex-wrap: wrap;
}
.task-head:hover { background: var(--bg3); }
.task-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); font-size: 12px; }
.task-title { font-weight: 600; flex: 1; min-width: 150px; }
.task-sub {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding: 0 14px 10px;
  color: var(--muted);
  font-size: 12px;
}
.task-sub .ok { color: var(--green); }
.task-sub .fail { color: var(--red); }
.task-detail {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  font-size: 13px;
}
.task-detail > * + * { margin-top: 10px; }
.task-detail h4 { margin: 0 0 3px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.task-detail p, .task-detail pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
.task-detail .err-text { color: var(--red); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* activity */
.activity-list { display: flex; flex-direction: column; }
.ev-row {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.ev-row .dot { position: relative; top: -1px; }
.ev-time { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; flex-shrink: 0; }
.ev-agent { color: var(--blue); font-size: 12px; flex-shrink: 0; }
.ev-msg { word-break: break-word; min-width: 0; }

/* conversation */
.conv-list { display: flex; flex-direction: column; gap: 10px; }
.msg-card { padding: 10px 12px; }
.msg-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; margin-bottom: 6px; }
.msg-route { font-weight: 600; }
.msg-route .arrow { color: var(--muted); font-weight: 400; margin: 0 3px; }
.msg-time { color: var(--muted); font-size: 12px; margin-left: auto; }
.msg-content {
  margin: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 11px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  overflow-x: auto;
}
.msg-content.clamped { max-height: 8.4em; overflow: hidden; }
.show-more { margin-top: 5px; background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 12px; }

/* agents table */
.table-wrap { overflow-x: auto; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; min-width: 760px; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; position: sticky; top: 0; background: var(--bg2); }
tr:last-child td { border-bottom: none; }
tr.dim td { opacity: 0.45; }
td .status-cell { display: inline-flex; align-items: center; gap: 6px; }
td.err-cell { color: var(--red); max-width: 260px; word-break: break-word; }

table.capacity-table { min-width: 560px; }

/* audit */
.audit-list { display: flex; flex-direction: column; gap: 8px; }
.action-row { padding: 0; overflow: hidden; }
.action-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
}
.action-head:hover { background: var(--bg3); }
.action-head .chip { flex-shrink: 0; }
.action-time {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  flex-shrink: 0;
  min-width: 62px;
}
.action-agent { color: var(--blue); font-size: 12px; flex-shrink: 0; }
.action-name {
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.action-approver { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.action-detail {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 13px;
}
.action-detail > * + * { margin-top: 8px; }
.action-detail h4 { margin: 0 0 3px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.action-detail p { margin: 0; white-space: pre-wrap; word-break: break-word; }

/* system */
#sys-dash > * + * { margin-top: 12px; }

.mission-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mission-head h2 { margin: 0; font-size: 17px; flex: 1; min-width: 120px; }
.mission-desc { color: var(--muted); margin: 8px 0 0; white-space: pre-wrap; }
.mission-meta { color: var(--muted); font-size: 12px; margin-top: 8px; display: flex; gap: 14px; flex-wrap: wrap; }

.counts-row { display: flex; gap: 8px; flex-wrap: wrap; }

.group-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.group-tile .group-line { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.group-tile .muted { font-size: 12px; }
.group-tile.attn {
  border-color: var(--red);
  background: rgba(248, 81, 73, 0.08);
}
.group-tile.attn h3, .group-tile.attn .group-line { color: var(--red); }

.tool-list { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.tool-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.tool-ok { color: var(--green); }
.tool-missing { color: var(--muted); opacity: 0.75; font-size: 12px; }

.usage-row { display: flex; gap: 24px; font-size: 15px; }
.usage-row b { font-size: 18px; }

.priority-select { font-size: 12px; padding: 4px 6px; }

.other-missions .om-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.other-missions .om-row:last-child { border-bottom: none; }
.other-missions .om-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nm-card summary { cursor: pointer; font-weight: 600; }
.nm-card.prominent { border-color: var(--accent); }
.nm-card.prominent summary { font-size: 16px; }
.mission-form { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; max-width: 640px; }
.mission-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
.form-row { display: flex; align-items: center; gap: 10px; }
.form-error { color: var(--red); font-size: 13px; }

/* economics */
.econ-card { max-width: 560px; padding: 8px 16px; }
.econ-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.econ-row:last-child { border-bottom: none; }
.econ-label { color: var(--muted); font-size: 13px; }
.econ-value { font-weight: 600; text-align: right; word-break: break-word; }

/* ---------- responsive: phone ---------- */
@media (max-width: 720px) {
  main { padding: 12px 12px 88px; }
  .topbar { padding: 8px 10px; }
  .brand-sub { display: none; }
  .notif-perm-btn { font-size: 11px; }

  /* primary nav becomes a bottom tab bar */
  .tabs {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-top: 1px solid var(--border);
    border-bottom: none;
    padding: 0;
    z-index: 50;
    background: var(--bg2);
  }
  .tab-btn {
    flex: 1;
    padding: 12px 2px calc(12px + env(safe-area-inset-bottom, 0px));
    font-size: 12px;
    border-bottom: none;
    border-top: 2px solid transparent;
    text-align: center;
  }
  .tab-btn.active { border-top-color: var(--accent); }

  .notif-dropdown { position: fixed; top: 52px; left: 8px; right: 8px; width: auto; }

  .status-mission { font-size: 15px; }
  .status-row { gap: 8px; }
  .state-chip { padding: 3px 10px; font-size: 11px; }
  .needs-headline { font-size: 17px; }
  .team-detail { padding-left: 16px; }
  .next-list { grid-template-columns: 1fr; }
  .plan-detail-line { flex-wrap: wrap; }
  .hist-row { flex-wrap: wrap; }
  .hist-name { flex-basis: 100%; white-space: normal; }

  .pills { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }

  .usage-row { gap: 16px; }
  table { min-width: 680px; }
  table.capacity-table { min-width: 480px; }

  /* audit rows collapse to stacked cards */
  .action-head { flex-wrap: wrap; row-gap: 5px; }
  .action-name {
    flex-basis: 100%;
    order: -1;
    white-space: normal;
    overflow: visible;
  }
  .action-time { min-width: 0; }
}

/* Nielo brand logo (authoritative asset; typographic fallback until dropped in) */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 20px; width: auto; display: block; }
.login-logo { height: 34px; width: auto; display: block; margin: 0 auto 10px; }

/* honest phase lines under mission cards/strip rows */
.status-lines { margin: 6px 0 2px; }
.status-line { color: var(--text-dim, #8b93a7); font-size: 13px; padding: 1px 0; }
.mstrip-lines { color: var(--text-dim, #8b93a7); font-size: 12px; padding: 0 8px 8px; }
