/* ============================================================
   Steadymade AI OS — Operating Interface
   Design language: editorial minimalism, dark green surfaces,
   vivid green accents, apricot for warnings. No gradients,
   no shadows, depth via borders / spacing / color surfaces.
   ============================================================ */

:root {
  --bg: #FAFBFA;
  --surface-dark: #0B2218;
  --card-dark: #1A3328;
  --green: #2EE66A;
  --green-light: #148A3F;
  --apricot: #F08C55;
  --apricot-deep: #C46A38;
  --body: #474B47;
  --headline: #1C1F1D;
  --border: #E4E7E4;
  --border-dark: #4A6B54;
  --muted: #8A918A;
  --white: #FFFFFF;
  --green-tint: #EAF8EE;
  --apricot-tint: #FBEFE7;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --sidebar-w: 232px;
  --drawer-w: 440px;

  /* Light-theme surfaces (clean design, ported from agent-setup) */
  --sidebar-bg: #F3F6F3;
  --primary-press: #0F6E31;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

.hidden { display: none !important; }

::selection { background: var(--green); color: var(--surface-dark); }

/* mono label utility */
.mono-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ============ Top strip (slim dark bar) ============ */

.topstrip {
  height: 46px;
  min-height: 46px;
  background: var(--surface-dark);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px 0 20px;
  flex-shrink: 0;
}
.ts-brand { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.ts-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--white);
  letter-spacing: 0.01em;
}
.ts-sub {
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.14em;
  color: var(--green);
}
.ts-divider {
  width: 1px;
  height: 16px;
  background: rgba(74, 107, 84, 0.55);
  flex-shrink: 0;
}
.topstrip #view-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  color: var(--white);
  white-space: nowrap;
}
.ts-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

@media (max-width: 860px) {
  .ts-sub { display: none; }
}

/* ============ Sidebar ============ */

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 12px;
  flex: 1;
}

.nav-item {
  background: none;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--body);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  padding: 9px 12px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.nav-item:hover { color: var(--headline); border-color: var(--border); }
.nav-item.active {
  color: var(--green-light);
  background: var(--green-tint);
  border-color: #BFE8CC;
}

.sidebar-status {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.status-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
}
.status-row span:first-child { color: var(--muted); }
.status-row span:last-child { color: var(--body); }

/* ============ Main column ============ */

.main-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.main-col-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  container-type: inline-size;
  container-name: maincol;
}



@media (max-width: 900px) {
  
  
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(520px, 100%);
  flex-shrink: 1;
  min-width: 160px;
  border: 1px solid rgba(74, 107, 84, 0.55);
  border-radius: 7px;
  padding: 0 11px;
  background: rgba(255, 255, 255, 0.06);
  color: #9FB3A6;
  transition: border-color 0.15s, background 0.15s;
}
.search-wrap:focus-within { border-color: var(--green); background: rgba(255, 255, 255, 0.09); }
.search-wrap input {
  border: none; outline: none;
  background: none;
  padding: 5px 0;
  flex: 1;
  font-size: 12px;
  color: var(--white);
}
.search-wrap input::placeholder { color: #9FB3A6; }
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  width: min(640px, calc(100vw - 32px));
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 360px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 60;
}
.search-results.hidden { display: none; }
.search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 9px 14px;
  text-align: left;
  font-size: 13px;
  color: var(--headline);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--green-tint); }
.search-result .mono-label { min-width: 52px; flex-shrink: 0; }
.search-result span:last-child {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-mode-switch {
  display: inline-flex;
  border: 1px solid rgba(74, 107, 84, 0.55);
  border-radius: 7px;
  overflow: hidden;
  background: transparent;
  flex-shrink: 0;
}
/* keep the switch's space reserved on non-chat views so the search
   field never jumps when the toggle appears/disappears */
.topstrip .chat-mode-switch.hidden {
  display: inline-flex !important;
  visibility: hidden;
  pointer-events: none;
}
.chat-mode-btn {
  border: none;
  background: transparent;
  color: #9FB3A6;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 7px 11px;
  border-right: 1px solid rgba(74, 107, 84, 0.55);
}
.chat-mode-btn:last-child { border-right: none; }
.chat-mode-btn.active {
  background: var(--card-dark);
  color: var(--green);
}

.btn {
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--headline);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--green-light); }
.btn-primary {
  background: var(--green-light);
  color: var(--white);
  border-color: var(--green-light);
}
.btn-primary:hover { background: var(--primary-press); border-color: var(--primary-press); }
.btn-ghost { background: none; }
.btn-small { padding: 5px 10px; font-size: 11.5px; }
.btn-green {
  background: var(--green);
  border-color: var(--green);
  color: var(--surface-dark);
}
.btn-green:hover { background: #29cf5f; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-fullscreen { padding: 7px 10px; font-size: 15px; line-height: 1; }

.badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  padding: 5px 9px;
  border-radius: 5px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge-mode {
  color: var(--green-light);
  border-color: var(--green-light);
  background: var(--green-tint);
}
.badge-green { color: var(--green-light); border-color: #BFE8CC; background: var(--green-tint); }
.badge-gray { color: var(--muted); border-color: var(--border); background: #F3F4F3; }
.badge-apricot { color: var(--apricot-deep); border-color: #EFCDB6; background: var(--apricot-tint); }
.badge-dark { color: var(--green-light); border-color: #BFE8CC; background: var(--green-tint); }

/* ============ View container ============ */

.view {
  flex: 1;
  overflow-y: auto;
  position: relative;
}
.view-pad { padding: 28px; }

.view-enter { animation: viewIn 0.25s ease both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* ============ Cards / shared ============ */

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  transition: border-color 0.15s;
}
.card:hover { border-color: #C9D2C9; }
.card-dark {
  background: var(--white);
  border-color: var(--border);
  color: var(--body);
}
.card-dark:hover { border-color: #C9D2C9; }

.section-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ============ Command Center ============ */

.cc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  color: var(--headline);
  line-height: 1.1;
  margin: 6px 0 2px;
}
.stat-card.card-dark .stat-value { color: var(--green-light); }
/* stat-note is used as the generic small helper text across all views —
   one global size keeps Settings / Skill Hub / Workflows consistent */
.stat-note { font-size: 12px; color: var(--muted); line-height: 1.55; white-space: normal; }
.stat-link { cursor: pointer; transition: border-color 0.15s, transform 0.15s; }
.stat-link:hover { border-color: var(--green-light); transform: translateY(-1px); }

.cc-cols {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

/* responsive: react to the main column's actual width (drawer open shrinks it) */
@container maincol (max-width: 1080px) {
  .cc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container maincol (max-width: 860px) {
  .cc-cols { grid-template-columns: minmax(0, 1fr); }
  .badge-mode { display: none; }
}
@container maincol (max-width: 700px) {
  .cc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Command Center: live activity + run history (n8n-style) ---- */
.cc-activity { margin-bottom: 18px; }
.cc-live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); flex-shrink: 0;
}
.cc-live-dot.live {
  background: var(--apricot);
  box-shadow: 0 0 0 0 rgba(240, 140, 85, .5);
  animation: ccPulse 1.4s infinite;
}
@keyframes ccPulse {
  0% { box-shadow: 0 0 0 0 rgba(240, 140, 85, .45); }
  70% { box-shadow: 0 0 0 6px rgba(240, 140, 85, 0); }
  100% { box-shadow: 0 0 0 0 rgba(240, 140, 85, 0); }
}
.run-live-strip {
  border: 1px solid #EFCDB6;
  background: var(--apricot-tint);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.run-live-strip > .mono-label { margin-bottom: 2px; }
.run-list { display: flex; flex-direction: column; }
.run-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1.6fr) auto auto auto 76px auto;
  align-items: center;
  gap: 12px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
}
.run-list .run-row:last-child { border-bottom: none; }
.run-live-strip .run-row { border-bottom: none; padding: 5px 4px; }
.run-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.run-dot.run-ok { background: var(--green-light); }
.run-dot.run-running { background: var(--apricot); animation: ccPulse 1.4s infinite; }
.run-dot.run-warn { background: var(--apricot-deep); }
.run-dot.run-error { background: #C0392B; }
.run-name {
  font-weight: 600; color: var(--headline); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.run-trigger {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px;
  white-space: nowrap;
}
.run-when, .run-dur { font-family: var(--font-mono); font-size: 10px; color: var(--muted); white-space: nowrap; text-align: right; }
.run-pill {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .04em;
  padding: 3px 9px; border-radius: 999px; text-align: center;
  border: 1px solid var(--border); color: var(--muted); background: #F3F4F3;
}
.run-pill.run-ok { color: var(--green-light); border-color: #BFE8CC; background: var(--green-tint); }
.run-pill.run-running { color: var(--apricot-deep); border-color: #EFCDB6; background: var(--apricot-tint); }
.run-pill.run-warn { color: var(--apricot-deep); border-color: #EFCDB6; background: var(--apricot-tint); }
.run-pill.run-error { color: #C0392B; border-color: #E6C3BE; background: #FBEDEB; }

@container maincol (max-width: 760px) {
  .run-row { grid-template-columns: 14px minmax(0, 1fr) auto auto; }
  .run-trigger, .run-dur { display: none; }
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
  background: none;
  border-left: none; border-right: none; border-top: none;
  width: 100%;
  text-align: left;
  font-size: 13px;
  color: var(--headline);
}
.list-row:last-child { border-bottom: none; }

.usage-row { flex-direction: column; align-items: stretch; gap: 4px; }
.usage-row-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.usage-row-top .list-title { flex: 1; }
.usage-row-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.list-row:hover .list-title { color: var(--green-light); }
.list-title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-meta { font-family: var(--font-mono); font-size: 9.5px; color: var(--muted); letter-spacing: 0.06em; white-space: nowrap; }

.agent-pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.agent-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: 7px;
  padding: 7px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--headline);
  transition: border-color 0.15s;
}
.agent-pill:hover { border-color: var(--green-light); }
.agent-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }

.kh-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.kh-row:last-child { border-bottom: none; }
.kh-link { cursor: pointer; }
.kh-link:hover span:first-child { color: var(--green-light) !important; }
.kh-bar {
  height: 4px; border-radius: 2px; background: var(--border);
  flex: 1; margin: 0 14px; max-width: 160px;
  overflow: hidden; position: relative;
}
.kh-bar i {
  position: absolute; inset: 0 auto 0 0;
  background: var(--green-light);
  border-radius: 2px;
}

/* ============ Agent Map ============ */

.map-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 46%, rgba(20, 138, 63, 0.05) 0%, transparent 55%),
    var(--bg);
}
.map-svg { width: 100%; height: 100%; display: block; }

.map-legend {
  position: absolute;
  left: 20px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.legend-row { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }
.legend-swatch { width: 14px; height: 0; border-top: 2px solid var(--border-dark); }
.legend-swatch.green { border-color: var(--green-light); }
.legend-swatch.dashed { border-top-style: dashed; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; border: 1px solid var(--border-dark); }
.legend-dot.folder { border-radius: 50%; border-color: var(--green-light); }

.map-hint {
  position: absolute;
  top: 16px;
  left: 20px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* SVG node styles */
.edge {
  stroke: #D6DCD6;
  stroke-width: 1;
  fill: none;
  transition: stroke 0.2s, stroke-width 0.2s, opacity 0.2s;
}
.edge.hub { stroke: #CBD6CD; }
.edge.lit {
  stroke: var(--green-light);
  stroke-width: 1.6;
  stroke-dasharray: 5 4;
  animation: edgeFlow 1.2s linear infinite;
}
@keyframes edgeFlow { to { stroke-dashoffset: -9; } }
.edge.dim { opacity: 0.18; }

.node { cursor: pointer; }
.node .node-box {
  fill: var(--white);
  stroke: var(--border);
  stroke-width: 1;
  transition: stroke 0.15s, fill 0.15s;
  rx: 9;
}
.node:hover .node-box { stroke: var(--green-light); }
.node.selected .node-box { stroke: var(--green-light); stroke-width: 1.6; }
.node.dim { opacity: 0.3; }
.node text { pointer-events: none; }
.node .node-name {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  fill: var(--headline);
}
.node .node-role {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  fill: var(--muted);
  text-transform: uppercase;
}
.node .node-dot { fill: var(--green); }

.node-folder .node-box {
  fill: var(--bg);
  stroke: var(--border);
  rx: 18;
}
.node-folder.lit .node-box { stroke: var(--green-light); fill: var(--green-tint); }
.node-folder .node-name { font-size: 11.5px; }
.node-folder .node-role { font-size: 7px; }

.hub { cursor: pointer; }
.hub .hub-box {
  fill: var(--green-tint);
  stroke: var(--green-light);
  stroke-width: 1.5;
  transition: stroke 0.15s;
}
.hub:hover .hub-box, .hub.selected .hub-box { stroke: var(--green); }
.hub .hub-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  fill: var(--headline);
}
.hub .hub-role {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.16em;
  fill: var(--apricot-deep);
  text-transform: uppercase;
}
.hub .hub-desc { font-family: var(--font-body); font-size: 9.5px; fill: var(--muted); }
.hub-ring {
  fill: none;
  stroke: #BFE8CC;
  stroke-width: 1;
  opacity: 0.6;
}
.hub-pulse {
  fill: none;
  stroke: var(--green);
  stroke-width: 1;
  opacity: 0;
  animation: hubPulse 4s ease-out infinite;
  transform-origin: center;
}
@keyframes hubPulse {
  0% { opacity: 0.5; }
  70%, 100% { opacity: 0; }
}

.dept-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  fill: #C8D0C8;
  text-transform: uppercase;
}
.dept-arc {
  fill: none;
  stroke: var(--green);
  stroke-width: 3.5;
  stroke-linecap: round;
  opacity: 0.22;
}

/* ============ Knowledge Docs ============ */

.kn-layout {
  display: grid;
  --kn-col-1: 215px;
  --kn-col-2: 285px;
  --kn-resizer: 8px;
  grid-template-columns: var(--kn-col-1) var(--kn-resizer) var(--kn-col-2) var(--kn-resizer) minmax(0, 1fr);
  height: 100%;
}
@container maincol (max-width: 1080px) {
  .kn-layout {
    --kn-col-1: 180px;
    --kn-col-2: 235px;
  }
}
.kn-folders, .kn-docs {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 10px;
}
.kn-folders { background: #F4F6F4; }
.kn-docs { border-right: none; }

.kn-resizer {
  cursor: col-resize;
  position: relative;
  background: transparent;
}
.kn-resizer::before {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 2px;
  height: calc(100% - 20px);
  background: var(--border);
  border-radius: 2px;
  transition: background 0.15s;
}
.kn-resizer:hover::before,
.kn-layout.resizing .kn-resizer::before {
  background: var(--green-light);
}

.kn-controls {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.filter-tabs.compact .filter-tab {
  padding: 4px 7px;
  font-size: 9px;
  letter-spacing: 0.06em;
}

/* breadcrumb path of the current folder level */
.kn-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 0 12px 10px;
}
.kn-crumb {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: none;
  border: none;
  padding: 2px 1px;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kn-crumb:hover { color: var(--headline); text-decoration: underline; }
.kn-crumb.current { color: var(--headline); font-weight: 700; }
.kn-crumb-sep { font-family: var(--font-mono); font-size: 10px; color: var(--muted); opacity: 0.5; }

.kn-chev { font-family: var(--font-mono); color: var(--muted); margin-left: auto; padding-left: 8px; }
.kn-up .kn-folder-name { color: var(--muted); }

.kn-folder-btn {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 4px;
  transition: border-color 0.15s, background 0.15s;
}
.kn-folder-btn:hover { border-color: var(--border); background: var(--white); }
.kn-folder-btn.active { background: var(--white); border-color: var(--green-light); }
.kn-folder-name { font-weight: 600; font-size: 13px; color: var(--headline); display: flex; align-items: center; gap: 8px; }
.kn-folder-meta { font-family: var(--font-mono); font-size: 9px; color: var(--muted); letter-spacing: 0.07em; }

.kn-doc-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 4px;
  transition: border-color 0.15s, background 0.15s;
}
.kn-doc-btn:hover { background: var(--green-tint); }
.kn-doc-btn.active { border-color: var(--green-light); background: var(--green-tint); }
.kn-doc-title { font-weight: 600; font-size: 12.5px; color: var(--headline); line-height: 1.35; }
.kn-doc-meta { font-family: var(--font-mono); font-size: 8.5px; color: var(--muted); margin-top: 4px; letter-spacing: 0.06em; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* editor */
.kn-editor {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}
.kn-editor-empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-size: 13px;
}
.kn-meta-bar {
  border-bottom: 1px solid var(--border);
  padding: 14px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kn-meta-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.kn-doc-h {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--headline);
  line-height: 1.3;
}
.kn-path { font-family: var(--font-mono); font-size: 9.5px; color: var(--muted); margin-top: 3px; letter-spacing: 0.04em; word-break: break-all; }
.kn-meta-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kn-meta-controls select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  color: var(--headline);
  background: var(--white);
  text-transform: uppercase;
}
.kn-agents-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 7px;
  background: var(--white);
  color: var(--body);
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.15s;
}
.chip:hover { border-color: var(--green-light); color: var(--green-light); }

.kn-edit-area {
  flex: 1;
  display: flex;
  min-height: 0;
}
.kn-textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  padding: 20px 24px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--headline);
  background: var(--white);
  tab-size: 2;
}
.kn-preview {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  background: var(--white);
}
.kn-actions-row { display: flex; align-items: center; gap: 8px; }
.kn-ask-row { display: flex; gap: 6px; flex-wrap: wrap; }
.save-state { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }
.save-state.dirty { color: var(--apricot-deep); }

/* markdown preview */
.md { color: var(--body); font-size: 14px; max-width: 760px; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--font-display); color: var(--headline); margin: 1.4em 0 0.5em; line-height: 1.25; }
.md h1:first-child, .md h2:first-child { margin-top: 0; }
.md h1 { font-size: 24px; } .md h2 { font-size: 19px; } .md h3 { font-size: 16px; } .md h4 { font-size: 14px; }
.md p { margin: 0.7em 0; }
.md ul, .md ol { margin: 0.7em 0 0.7em 1.4em; }
.md li { margin: 0.25em 0; }
.md code { font-family: var(--font-mono); font-size: 12px; background: #F1F3F1; border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
.md pre { background: #F2F4F2; color: var(--headline); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; overflow-x: auto; margin: 1em 0; }
.md pre code { background: none; border: none; color: inherit; padding: 0; font-size: 12px; line-height: 1.6; }
.md blockquote { background: var(--green-tint); border: 1px solid #BFE8CC; border-radius: 8px; padding: 8px 14px; color: var(--headline); margin: 0.8em 0; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 1.6em 0; }
.md a { color: var(--green-light); }
.md table { border-collapse: collapse; margin: 1em 0; width: 100%; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; font-size: 13px; }
.md th { background: #F4F6F4; font-weight: 600; color: var(--headline); }
.md .fm { background: #F4F6F4; border: 1px dashed var(--border); border-radius: 8px; padding: 10px 14px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); white-space: pre-wrap; margin-bottom: 1em; }

/* ============ Workflows ============ */

.wf-card { margin-bottom: 14px; }
.wf-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.wf-name { font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--headline); }
.wf-desc { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
.wf-chain {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  padding-bottom: 4px;
}
.wf-step {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 13px;
  background: var(--white);
  min-width: 108px;
  text-align: left;
  transition: border-color 0.15s;
  flex-shrink: 0;
}
button.wf-step:hover { border-color: var(--green-light); }
.wf-step.dark {
  background: var(--green-tint);
  border-color: #BFE8CC;
}
.wf-step.dark .wf-step-name { color: var(--green-light); }
.wf-step.dark .wf-step-role { color: var(--muted); }
.wf-step.terminal { background: var(--apricot-tint); border-color: #EFCDB6; }
.wf-step.terminal .wf-step-name { color: var(--apricot-deep); }
.wf-step.terminal .wf-step-role { color: var(--apricot-deep); opacity: 0.65; }
.wf-step-name { font-family: var(--font-display); font-weight: 600; font-size: 13px; color: var(--headline); }
.wf-step-role { font-family: var(--font-mono); font-size: 7.5px; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }
.wf-arrow {
  display: flex; align-items: center;
  color: #B5BFB5;
  padding: 0 7px;
  flex-shrink: 0;
}

/* ============ Automations (fused Workflows + Scheduler) ============ */
.flows-layout {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  gap: 20px;
  padding: 28px;
  align-items: start;
}
.flows-rail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
}
.flows-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  padding: 11px 13px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.flows-group:hover { border-color: #C9D2C9; }
.flows-group.active {
  border-color: var(--green-light);
  background: var(--green-tint);
}
.flows-group .fg-name { font-family: var(--font-display); font-weight: 600; font-size: 13.5px; color: var(--headline); }
.flows-group .fg-sub { font-size: 11px; color: var(--muted); line-height: 1.35; }
.flows-group .fg-count { font-family: var(--font-mono); font-size: 9px; letter-spacing: .06em; color: var(--muted); margin-top: 3px; }
.flows-group.active .fg-count { color: var(--green-light); }

.flows-main { display: flex; flex-direction: column; min-width: 0; }
.flows-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.flows-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 6px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.flows-main .wf-card:last-of-type { margin-bottom: 4px; }

@media (max-width: 860px) {
  .flows-layout { grid-template-columns: 1fr; }
  .flows-rail { position: static; flex-direction: row; flex-wrap: wrap; }
  .flows-group { flex: 1 1 160px; }
  .flows-group .fg-sub { display: none; }
}

/* ============ Projects ============ */

.pj-mobile-switcher { display: none; }

.projects-layout {
  display: flex;
  height: 100%;
  min-height: 0;
}

.pj-sidebar {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: #F4F6F4;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.pj-sidebar-header {
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pj-sidebar-search {
  padding: 0 16px 12px;
}

.pj-project-list {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pj-project-row {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  padding: 10px;
}
.pj-project-row:hover { border-color: var(--border); background: #EAEFEA; }
.pj-project-row.active { border-color: var(--green-light); background: var(--green-tint); }
.pj-project-name { display: block; font-weight: 600; color: var(--headline); font-size: 13px; }
.pj-project-meta { display: block; margin-top: 3px; font-family: var(--font-mono); font-size: 9px; color: var(--muted); letter-spacing: 0.08em; }

.pj-main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.pj-workspace-header {
  padding: 24px 32px 0;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
}

.pj-workspace-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}

.pj-desktop-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--headline);
}

.pj-tabs {
  display: flex;
  gap: 24px;
}

.pj-tab {
  background: none;
  border: none;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  padding-bottom: 12px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s;
}
.pj-tab:hover { color: var(--headline); }
.pj-tab.active { color: var(--green-light); border-bottom-color: var(--green-light); }

.pj-workspace-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 24px 32px;
}

.pj-sub-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.pj-filters-panel {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
}

.pj-tasks-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pj-list {
  flex: 1;
  overflow-y: auto;
}

.pj-stream-grid { margin-top: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@container maincol (max-width: 720px) {
  .pj-stream-grid { grid-template-columns: minmax(0, 1fr); }
}
.pj-stream-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding: 6px 0;
  font-size: 12px;
}
.pj-stream-row span:last-child { font-family: var(--font-mono); font-size: 9px; color: var(--muted); letter-spacing: 0.06em; white-space: nowrap; }

.pj-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  height: 100%;
  align-items: flex-start;
}
.pj-col { border: 1px solid var(--border); border-radius: 8px; background: #FBFCFB; min-width: 260px; width: 260px; flex-shrink: 0; display: flex; flex-direction: column; max-height: 100%; }
.pj-col-head {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.09em;
  color: var(--muted);
}
.pj-col-body { padding: 8px; display: flex; flex-direction: column; gap: 8px; flex: 1; overflow-y: auto; }

/* Refined Task Card */
@keyframes fadeInCard {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.pj-task-card {
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: 8px;
  text-align: left;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
  outline: none;
  animation: fadeInCard 0.25s ease-out forwards;
}
.pj-task-card:hover, .pj-task-card:focus-visible { border-color: var(--green-light); box-shadow: 0 2px 4px rgba(0,0,0,0.03); }
.pj-task-card.is-blocked { border-left: 3px solid var(--apricot-deep); }

.pj-task-header { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.pj-task-title { font-weight: 600; color: var(--headline); font-size: 13px; line-height: 1.4; flex: 1; }
.pj-task-blocked-badge { 
  font-family: var(--font-mono); font-size: 9px; 
  background: var(--apricot-tint); color: var(--apricot-deep); 
  border: 1px solid #EFCDB6; border-radius: 4px; padding: 2px 6px; 
  letter-spacing: 0.05em; text-transform: uppercase; flex-shrink: 0;
}

.pj-task-planning { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pj-tag {
  font-family: var(--font-mono); font-size: 9.5px;
  border-radius: 4px; padding: 2px 6px;
  white-space: nowrap; border: 1px solid transparent;
}
.tag-type { background: var(--surface-dark); color: var(--green); }
.tag-prio, .tag-sprint, .tag-points, .tag-comp, .tag-due { background: #F3F4F3; color: var(--muted); border-color: var(--border); }
.tag-due.is-overdue { background: var(--apricot-tint); color: var(--apricot-deep); border-color: #EFCDB6; }
.text-overdue { color: var(--apricot-deep); font-weight: 600; }

.pj-task-execution { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; border-top: 1px dashed var(--border); }
.pj-task-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-comp-name { font-size: 9px; background: var(--bg); color: var(--muted); border-color: var(--border); }

.pj-task-owners { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pj-task-assignee { font-size: 11px; display: flex; align-items: center; gap: 6px; color: var(--headline); font-weight: 500; }
.pj-task-avatar { width: 18px; height: 18px; border-radius: 4px; background: var(--green-tint); color: var(--green-light); display: grid; place-items: center; font-size: 10px; font-weight: 700; font-family: var(--font-display); }
.pj-task-exec-state { margin-left: auto; }

.task-move-btn {
  background: none; border: 1px solid transparent; color: var(--muted); border-radius: 4px;
  width: 22px; height: 22px; display: grid; place-items: center; font-size: 14px; line-height: 1; transition: background 0.15s; outline: none;
}
.task-move-btn:hover, .task-move-btn:focus-visible { background: var(--border); color: var(--headline); }

/* Dashboard Metrics CSS */
.pj-dashboard { padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.pj-dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.pj-dash-card { background: #FBFCFB; border: 1px solid var(--border); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.pj-dash-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }
.pj-dash-value { font-family: var(--font-display); font-size: 24px; font-weight: 600; color: var(--headline); line-height: 1; margin-top: 4px; }

.dash-span-2 { grid-column: span 2; }
.seg-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--border); margin: 8px 0; }
.seg-chunk { transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.seg-labels { display: flex; gap: 12px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.seg-labels i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.dash-progress-wrap { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin: 8px 0; }
.dash-progress-bar { height: 100%; background: var(--green-light); transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.dash-progress-text { font-size: 16px; font-weight: 700; color: var(--headline); }
.dash-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; font-size: 12px; }
.dash-list div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.dash-list div:last-child { border-bottom: none; }
.pj-dash-card.warn { border-color: var(--apricot-deep); background: var(--apricot-tint); }
.pj-dash-card.warn .pj-dash-value { color: var(--apricot-deep); }

.clickable { cursor: pointer; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s, background 0.2s; outline: none; }
.pj-dash-card.clickable:hover, .pj-dash-card.clickable:focus-visible { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.06); border-color: var(--green-light); }
.dash-list .clickable { padding: 4px 6px; margin: -4px -6px; border-radius: 4px; border-bottom: none; }
.dash-list .clickable:hover, .dash-list .clickable:focus-visible { background: var(--green-tint); color: var(--green-light); }
span.clickable:hover, span.clickable:focus-visible { background: var(--green-tint); color: var(--green-light); }
.seg-chunk.clickable:hover, .seg-chunk.clickable:focus-visible { filter: brightness(0.9); transform: scaleY(1.1); }

.pj-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  z-index: 50;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pj-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 12px;
}
.pj-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--green-tint);
  border: 1px solid var(--green-light);
  color: var(--green-light);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: background 0.15s;
}
.pj-filter-chip:hover, .pj-filter-chip:focus-visible { background: #d3eadb; }

.pj-empty { font-size: 12px; color: var(--muted); padding: 8px 2px; }

.pj-col-empty-zone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
  padding: 16px;
  background: rgba(255,255,255,0.4);
  transition: background 0.2s, border-color 0.2s;
}
.drag-over .pj-col-empty-zone { background: var(--green-tint); border-color: var(--green-light); }
.dragging { transform: rotate(3deg) scale(1.02); opacity: 0.9; box-shadow: 0 8px 24px rgba(0,0,0,0.12); z-index: 100; }

/* Desktop-only helpers */
.pj-desktop-only { display: inline-flex; }

/* Mobile overwrites for global layout / boards */
@media (max-width: 980px) {
  body { flex-direction: column; }
  #app { flex-direction: column; }
  .sidebar { width: 100%; min-width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border); overflow-x: auto; flex-shrink: 0; }
  .sidebar-nav { flex-direction: row; padding: 10px 14px; gap: 8px; }
  .sidebar-status { display: none; }
  .nav-item { white-space: nowrap; }

  .pj-mobile-switcher { display: block; width: 100%; min-width: 100%; font-weight: 600; margin-bottom: 12px; }
  .pj-sidebar { display: none; }
  .pj-desktop-title-row { display: none !important; }
  .pj-desktop-only { display: none !important; }
  .pj-workspace-header { padding: 16px 16px 0; }
  .pj-workspace-content { padding: 16px; }
  .dash-span-2 { grid-column: span 1; }
  .pj-tabs { gap: 16px; }
  
  .task-move-btn { width: 40px; height: 40px; font-size: 18px; margin: -8px -8px -8px 0; }
}

.exec-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 10px;
}
.exec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #EEF2EE;
}
.exec-dot.on { border-color: var(--green-light); background: var(--green-light); }
.exec-dot.pulse { animation: execPulse 1s ease-in-out infinite; }
.exec-line { width: 26px; height: 2px; background: var(--border); border-radius: 2px; }
.exec-line.on { background: var(--green-light); }
.exec-progress.is-fail .exec-dot.on,
.exec-progress.is-fail .exec-line.on { background: var(--apricot-deep); border-color: var(--apricot-deep); }
@keyframes execPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.65; }
}

.pj-exec-grid {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 6px 10px;
  align-items: start;
  font-size: 12px;
}
.pj-exec-grid > span:nth-child(odd) {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}
.pj-exec-grid > span:nth-child(even) { color: var(--body); word-break: break-word; }

/* ============ Departments ============ */

/* Editorial layout: numbered info column left, agent list right. */
.dept-list .dept-row {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 28px;
  margin-bottom: 14px;
  padding: 22px 24px;
}
@container maincol (max-width: 860px) {
  .dept-list .dept-row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}
.dept-idx {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--apricot-deep);
  margin-bottom: 10px;
}
.dept-info .dept-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--headline);
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.dept-info .dept-sub {
  font-size: 12.5px;
  color: var(--body);
  line-height: 1.55;
  margin-top: 6px;
}
.dept-count {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-top: 12px;
}
.dept-agents { display: flex; flex-direction: column; }
.dept-agent-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 11px 6px;
  text-align: left;
  transition: background 0.15s;
}
.dept-agent-row:last-child { border-bottom: none; }
.dept-agent-row:hover { background: #F5F8F5; }
.dept-agent-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--green-tint);
  color: var(--green-light);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.dept-agent-name { font-weight: 600; font-size: 13px; color: var(--headline); }
.dept-agent-role { font-size: 11.5px; color: var(--muted); line-height: 1.4; }

/* ============ Artifacts ============ */

.art-type-tabs { margin-top: 10px; }
.art-type-tabs .filter-tabs { flex-wrap: wrap; border: none; gap: 6px; }
.art-type-tabs .filter-tab {
  border: 1px solid var(--border);
  border-radius: 7px;
}
.art-type-tabs .filter-tab.active { border-color: var(--green-light); }
.ft-count {
  font-size: 8.5px;
  color: var(--muted);
  margin-left: 2px;
}
.filter-tab.active .ft-count { color: inherit; opacity: 0.8; }

/* type tile — shared by grid cards and list rows */
.art-tile {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.art-tile svg { display: block; }
.art-tone-green   { background: var(--green-tint);   color: var(--green-light); }
.art-tone-apricot { background: var(--apricot-tint); color: var(--apricot-deep); }
.art-tone-neutral { background: #F1F3F1;             color: var(--body); }

/* grid view */
.art-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}
.art-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: left;
  transition: border-color 0.15s, transform 0.15s;
}
.art-card:hover { border-color: var(--green-light); transform: translateY(-1px); }
.art-card .art-tile { margin-bottom: 8px; }
.art-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--headline);
  line-height: 1.35;
  width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.art-folder {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--muted);
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.art-card-meta {
  display: flex;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 8px;
}
.art-card-meta span:not(:last-child)::after { content: '·'; margin-left: 6px; color: var(--border); }
.art-card-time {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-top: 2px;
}

/* list view */
.art-list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 11px 4px;
  text-align: left;
  transition: background 0.15s;
}
.art-list-row:last-child { border-bottom: none; }
.art-list-row:hover { background: #F5F8F5; }
.art-list-row .art-tile { width: 34px; height: 34px; border-radius: 8px; }
.art-list-row .art-tile svg { width: 17px; height: 17px; }
.art-list-main { flex: 1; min-width: 0; }
.art-list-name {
  display: block;
  font-weight: 600;
  font-size: 13px;
  color: var(--headline);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ Settings ============ */

.simple-list .card { margin-bottom: 10px; }
/* Unified content width for list/settings views — fills the screen, caps on ultra-wide for readability */
.view-pad.simple-list { max-width: 1320px; }
.settings-block { max-width: 1320px; }
.settings-block .card { margin-bottom: 14px; }
.settings-block .section-title { margin-bottom: 10px; }
.kv-row > span:first-child { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kv-row { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.kv-row:last-child { border-bottom: none; }
.kv-row > span:first-child { color: var(--muted); }
.kv-row > span:last-child { font-family: var(--font-mono); font-size: 11px; color: var(--headline); text-align: right; word-break: break-all; }

.ks-path-edit-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.ks-path-edit-row .filter-input {
  flex: 1;
  min-width: 260px;
}

.ks-row-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

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

.provider-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #FBFCFB;
}

.provider-card .section-title {
  margin-bottom: 8px;
}

.provider-card .form-check label {
  align-items: flex-start;
}

.provider-card-full {
  grid-column: 1 / -1;
}

.provider-env-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.provider-env-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.provider-env-mask {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
}

.provider-note {
  margin-top: 8px;
  white-space: normal;
}

.provider-actions {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.provider-setup {
  display: none;
}

/* ============ Drawer ============ */

/* The drawer takes layout space (pushes the main view) instead of
   overlaying it, so map and content never get covered or clipped. */
.drawer {
  width: 0;
  min-width: 0;
  flex-shrink: 0;
  background: var(--white);
  border-left: 0 solid var(--border);
  transition: width 0.25s cubic-bezier(0.3, 0.8, 0.3, 1);
  overflow: hidden;
}
.drawer.open { width: var(--drawer-w); border-left-width: 1px; }
.drawer-inner {
  width: var(--drawer-w);
  height: 100%;
  overflow-y: auto;
}
.drawer-scrim { display: none; }

.drawer-head {
  background: var(--sidebar-bg);
  padding: 24px;
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--border);
}
.drawer-close {
  position: absolute;
  top: 14px; right: 14px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  width: 28px; height: 28px;
  font-size: 14px;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}
.drawer-close:hover { color: var(--headline); border-color: var(--green-light); }
.drawer-dept { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.16em; color: var(--apricot-deep); text-transform: uppercase; margin-bottom: 8px; }
.drawer-name { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--headline); }
.drawer-role { font-size: 13px; color: var(--body); margin-top: 6px; line-height: 1.5; }
.drawer-body { padding: 20px 24px 28px; display: flex; flex-direction: column; gap: 20px; }
.drawer-section .section-title { margin-bottom: 8px; }
.drawer-section ul { margin-left: 18px; font-size: 13px; }
.drawer-section li { margin: 4px 0; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.path-line { font-family: var(--font-mono); font-size: 10px; color: var(--muted); word-break: break-all; background: #F4F6F4; border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }

.drawer-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 12px;
}
@media (max-width: 600px) {
  .drawer-grid-2 { grid-template-columns: minmax(0, 1fr); gap: 20px; }
}

/* ============ Toast ============ */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translate(-50%, 16px);
  background: var(--headline);
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  border: 1px solid var(--headline);
  border-radius: 8px;
  padding: 10px 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { color: var(--apricot); }

/* scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #D4DAD4; border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ===== Scheduler + Skill Hub ===== */

.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #7E978A;
}
/* The drawer panel is light (var(--white)) — form controls must use dark text
   on a light field, otherwise the letters blend into the background. */
.form-field input,
.form-field select,
.form-field textarea {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--headline);
  padding: 8px 10px;
  font-size: 12.5px;
  outline: none;
}
.form-field input::placeholder,
.form-field textarea::placeholder { color: var(--muted); }
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus { border-color: var(--green-light); background: var(--white); }
.form-field textarea { resize: vertical; font-family: var(--font-mono); line-height: 1.55; }
.form-field select option { color: var(--headline); background: var(--white); }
.form-check label {
  flex-direction: row;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body, inherit);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--body);
  cursor: pointer;
}
.form-check input { accent-color: var(--green-light); }

.run-log {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  color: #C9D6CD;
  background: var(--surface-dark);
  border: 1px solid var(--surface-dark);
  border-radius: 8px;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60vh;
  overflow: auto;
}

/* ===== Skill hub filters (light cards) ===== */

.filter-input {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  color: var(--headline);
  padding: 7px 10px;
  font-size: 12.5px;
  outline: none;
}
.filter-input:focus { border-color: var(--green-light); }

.filter-tabs {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}
.filter-tab {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px;
  background: var(--white);
  color: var(--body);
  cursor: pointer;
  border: none;
  border-right: 1px solid var(--border);
}
.filter-tab:last-child { border-right: none; }
.filter-tab.active { background: var(--surface-dark); color: var(--green); }

/* ===== Skill hub rows ===== */

.skill-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--border);
}
.skill-row:last-child { border-bottom: none; }
.skill-toggle {
  position: relative;
  width: 34px; height: 20px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: #ECEFEC;
  flex-shrink: 0;
  margin-top: 2px;
  transition: background 0.15s, border-color 0.15s;
}
.skill-toggle i {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--white);
  border: 1px solid var(--border);
  transition: left 0.15s, border-color 0.15s;
}
.skill-toggle.on { background: var(--green-light); border-color: var(--green-light); }
.skill-toggle.on i { left: 16px; border-color: var(--green-light); }
.skill-main { flex: 1; min-width: 0; }
.skill-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.skill-name { font-family: var(--font-display); font-weight: 600; font-size: 13.5px; color: var(--headline); }
.skill-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.skill-meta {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 5px;
}
.skill-actions { display: flex; gap: 6px; flex-shrink: 0; margin-top: 2px; }

/* ===== Guardrails ===== */

.gr-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.gr-row:last-of-type { border-bottom: none; }
.gr-folder {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--headline);
  flex: 1;
  min-width: 160px;
  word-break: break-all;
}
.gr-tabs .filter-tab { padding: 5px 9px; font-size: 9px; }
.gr-tabs .filter-tab.active.gr-write { background: var(--surface-dark); color: var(--green); }
.gr-tabs .filter-tab.active.gr-ask   { background: #4a3b12; color: #f5c04e; }
.gr-tabs .filter-tab.active.gr-read  { background: #16324a; color: #6fb6e8; }
.gr-tabs .filter-tab.active.gr-deny  { background: #4a1616; color: #f08a8a; }

/* ===== Onboarding modal ===== */

.modal-scrim {
  position: fixed;
  inset: 0;
  background: rgba(11, 34, 24, 0.65);
  display: grid;
  place-items: center;
  z-index: 200;
  padding: 24px;
}
.wizard-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 800px;
  max-height: 85vh;
  display: flex;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
.wizard-sidebar {
  width: 240px;
  background: var(--bg-main);
  border-right: 1px solid var(--border);
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.wizard-step-link {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  transition: all 0.2s;
  cursor: default;
}
.wizard-step-link.active {
  background: var(--white);
  color: var(--headline);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border: 1px solid var(--border);
}
.wizard-step-link.completed {
  color: var(--brand);
}
.wizard-step-num {
  font-family: var(--font-mono);
  font-size: 12px;
  opacity: 0.6;
}
.wizard-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--white);
  padding: 32px 40px;
  overflow-y: auto;
}
.wizard-header {
  margin-bottom: 24px;
}
.wizard-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--headline);
  margin: 0 0 8px;
}
.wizard-desc {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
}
.wizard-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.wizard-footer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.wizard-box {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.wizard-actions {
  display: flex;
  gap: 12px;
}
  align-items: flex-start;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.onb-step-title { display: block; font-weight: 600; color: var(--headline); font-size: 13.5px; }
.onb-cmd {
  display: inline-block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-dark);
  color: var(--green);
  border-radius: 6px;
  padding: 4px 10px;
}
.onb-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* settings section filter */
.settings-filter { padding: 12px 16px; overflow-x: auto; }
.settings-filter .filter-tabs { flex-wrap: nowrap; max-width: 100%; }
.settings-filter .filter-tab { white-space: nowrap; }

/* ===== Drawer date/time picker ===== */

/* The drawer is a light panel — native widgets (datetime-local calendar icon,
   select arrows, checkboxes) render in light scheme so the icons stay dark
   and visible on the light fields. */
.drawer .form-field input,
.drawer .form-field select,
.drawer .form-field textarea,
.drawer .form-check input {
  color-scheme: light;
}
.drawer .form-field input[type="datetime-local"],
.drawer .form-field input[type="time"] {
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.drawer .form-field input[type="datetime-local"]::-webkit-calendar-picker-indicator,
.drawer .form-field input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.75;
}

.gr-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px;
  border: 1px dashed var(--green-light);
  border-radius: 8px;
  margin-bottom: 10px;
  background: var(--green-tint);
}

/* ===== Workflow chain editor (drawer) ===== */

.wfe-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}
.wfe-row select {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--headline);
  padding: 6px 8px;
  font-size: 12px;
  outline: none;
}
.wfe-row select option { background: var(--white); color: var(--headline); }
.wfe-row .chip[disabled] { opacity: 0.35; cursor: default; }

/* ===== Agent drawer plugin toggles ===== */

.agent-plugin-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12.5px;
  color: var(--body);
  cursor: pointer;
}
.agent-plugin-row input { accent-color: var(--green-light); }

/* ===== Scheduler recurrence builder ===== */

.wd-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.wd-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  color: var(--body);
  cursor: pointer;
  user-select: none;
}
.wd-chip input { display: none; }
.wd-chip.on {
  background: var(--surface-dark);
  border-color: var(--surface-dark);
  color: var(--green);
}
.freq-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}
.freq-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.freq-inline label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #7E978A;
}
.cron-preview {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--green-light);
  background: var(--green-tint);
  border-radius: 6px;
  padding: 4px 8px;
  display: inline-block;
}

/* Chat iframe host (persistent between view switches) */
.chat-holder {
  flex: 1;
  min-height: 0;
  position: relative;
}
.chat-offline-note {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--body);
  font-size: 12px;
  padding: 9px 12px;
}
.chat-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
}

.projects-layout.no-sidebar { grid-template-columns: minmax(0, 1fr); }
.pj-board-card { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.pj-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  flex: 1;
  min-height: 0;
}
.pj-col {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #FBFCFB;
  min-width: 280px;
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  max-height: 100%;
}
.pj-col-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
  min-height: 86px;
}
/* Legacy duplicate project-board task styles removed to avoid overriding
   the board-first task card definitions above. */
.pj-col.drag-over { background: var(--green-tint); border-color: var(--green-light); }
.pj-col.drop-disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Subtask UI */
.subtask-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.subtask-toggle {
  cursor: pointer;
  accent-color: var(--green);
}
.subtask-text {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--headline);
  padding: 6px 8px;
  font-size: 12.5px;
  outline: none;
}
.subtask-text:focus {
  border-color: var(--green-light);
  background: var(--white);
}
.subtask-text.completed {
  text-decoration: line-through;
  color: var(--muted);
}

/* ====== PORTED UPSTREAM STYLES ====== */

/* Scheduled job rows: make the schedule immediately readable */
.job-row { align-items: center; gap: 14px; }
.job-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.job-name { font-weight: 600; color: var(--headline); display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-target { font-family: var(--font-mono); font-size: 9.5px; color: var(--muted); letter-spacing: 0.06em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-sched {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 200px;
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #F6F8F6;
}
.job-sched--on { border-color: #BFE8CC; background: var(--green-tint); }
.job-sched-when {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--headline);
  letter-spacing: 0.01em;
}
.job-sched--on .job-sched-when { color: var(--green-light); }
.job-clock { width: 13px; height: 13px; flex: none; }
.job-sched-next { font-family: var(--font-mono); font-size: 9.5px; color: var(--muted); letter-spacing: 0.03em; }
.job-actions { display: flex; gap: 6px; flex: none; }

/* Drop zone: always visible on a leaf (document-holding) folder level */
.kn-dropzone {
  margin: 10px 2px 2px;
  padding: 14px 10px;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  color: var(--muted);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.kn-dropzone-icon { display: block; margin: 0 auto 4px; width: 16px; height: 16px; color: var(--muted); }
.kn-dropzone.drag-over {
  border-color: var(--green-light);
  background: var(--green-tint);
  color: var(--green-light);
}
.kn-dropzone.drag-over .kn-dropzone-icon { color: var(--green-light); }

.chip-accent { color: var(--green-light); border-color: #BFE8CC; background: var(--green-tint); }
.chip-accent:hover { border-color: var(--green-light); background: var(--green-tint); }

.flows-section-label--primary {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--headline);
  border-bottom-color: #BFE8CC;
}
.flows-section-label--primary::before {
  content: '';
  flex: none;
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: var(--green);
}

/* Unified settings design: contrast + green accent motif */
.settings-block .section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--headline);
}
.settings-block .section-title::before {
  content: '';
  flex: none;
  width: 3px;
  height: 13px;
  border-radius: 2px;
  background: var(--green);
}
.settings-block .card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.settings-block .card-head .section-title { flex: 1; margin: 0; min-width: 120px; }
.settings-block .badge { border-radius: 999px; padding: 4px 10px; }
.settings-block .kv-row { padding: 9px 0; justify-content: flex-start; gap: 8px 22px; }
.settings-block .kv-row > span:first-child { flex: 0 1 auto; min-width: 200px; max-width: 460px; color: var(--body); }
.settings-block .kv-row > span:last-child { text-align: left; }
.settings-block .gr-folder { flex: 0 1 auto; }

.rt-signals { display: flex; flex-direction: column; gap: 8px; }
.rt-signal {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--body);
  line-height: 1.55;
}
.rt-signal .badge { flex: none; margin-top: 1px; }
.rt-signal--now { background: var(--green-tint); border-color: #BFE8CC; }
.rt-signal--next { background: var(--apricot-tint); border-color: #EFCDB6; }

.ks-space {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 14px 11px;
  margin-bottom: 12px;
  background: #FBFCFB;
}
.ks-space-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 9px;
  flex-wrap: wrap;
}
.ks-space-head label {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--headline);
  line-height: 1.4;
}
.ks-scope-tag {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.ks-scope-tag::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.ks-space--personal .ks-scope-tag { color: var(--green-light); border-color: #BFE8CC; background: var(--green-tint); }
.ks-space--shared .ks-scope-tag { color: var(--apricot-deep); border-color: #EFCDB6; background: var(--apricot-tint); }

.ks-space-status {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 10px;
}
.ks-status-line { font-size: 12px; color: var(--muted); line-height: 1.6; word-break: break-all; }
.ks-status-label { display: inline-block; min-width: 44px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.ks-status { display: inline-block; font-family: var(--font-mono); font-size: 10px; letter-spacing: .04em; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }
.ks-status--ok { color: var(--green-light); border-color: #BFE8CC; background: var(--green-tint); }
.ks-status--missing { color: var(--apricot-deep); border-color: #EFCDB6; background: var(--apricot-tint); }
.ks-status--none { color: var(--muted); border-color: var(--border); background: #F3F4F3; }
.ks-subfolders { font-size: 11px; color: var(--muted); margin-top: 1px; }
.ks-sub-ok { color: var(--green-light); font-weight: 600; }
.ks-sub-no { color: var(--muted); }
.ks-warning {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid #EFCDB6;
  border-radius: 7px;
  background: var(--apricot-tint);
  color: var(--apricot-deep);
  font-size: 12px;
  line-height: 1.45;
}
.ks-warning > div + div { margin-top: 3px; }

/* Scroll reveal */
.sr { opacity: 0; transform: translateY(18px); }
.sr.sr-in { opacity: 1; transform: none; transition: opacity 0.65s cubic-bezier(0.22, 0.61, 0.21, 1), transform 0.65s cubic-bezier(0.22, 0.61, 0.21, 1); transition-delay: var(--sr-d, 0ms); }
@media (prefers-reduced-motion: reduce) { .sr, .sr.sr-in { opacity: 1; transform: none; transition: none; } }

/* ============================================================
   My Desk Styles
   ============================================================ */
.desk-shell {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.desk-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.desk-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}

.desk-metric-card {
  cursor: pointer;
  outline: none;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.desk-metric-card:focus-visible {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-tint);
}

.desk-metric-card:hover {
  border-color: var(--green-light);
  transform: translateY(-2px);
}

.desk-metric-card.warn {
  border-color: var(--apricot-deep);
  background: var(--apricot-tint);
}

.desk-metric-card.ratio-card {
  background: var(--surface-dark);
  color: var(--white);
  border-color: var(--surface-dark);
}

.desk-metric-card.ratio-card .desk-metric-label {
  color: rgba(255, 255, 255, 0.7);
}

.desk-metric-card.ratio-card .desk-metric-value {
  color: var(--green);
}

.desk-metric-label {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.desk-metric-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--headline);
  line-height: 1;
}

.desk-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.desk-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.desk-filter-chip {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--body);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-body);
}

.desk-filter-chip:hover {
  border-color: var(--green-light);
  color: var(--green-light);
}

.desk-filter-chip.active {
  background: var(--surface-dark);
  border-color: var(--surface-dark);
  color: var(--white);
}

.desk-search-bar {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.desk-search-bar svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.desk-search-bar input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px 8px 36px;
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.desk-search-bar input:focus {
  outline: none;
  border-color: var(--green-light);
}

.desk-quick-capture {
  display: flex;
  gap: 12px;
}

.desk-quick-capture input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-body);
  transition: border-color 0.2s ease;
}

.desk-quick-capture input:focus {
  outline: none;
  border-color: var(--green-light);
}

.desk-group {
  margin-bottom: 32px;
}

.desk-group > summary::-webkit-details-marker {
  display: none;
}

.desk-group[open] .chevron {
  transform: rotate(90deg);
}

.desk-group-header {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--headline);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.desk-group-count {
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
}

.desk-task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.desk-task-row {
  position: relative;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.desk-task-row:hover {
  border-color: var(--green-light);
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.desk-task-row:focus-visible {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-tint);
}

.desk-task-checkbox {
  position: relative;
  width: 20px;
  height: 20px;
  appearance: none;
  border: 2px solid var(--muted);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: grid;
  place-content: center;
  margin: 0;
  flex-shrink: 0;
}

.desk-task-checkbox::before {
  content: "";
  width: 10px;
  height: 10px;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
  background-color: var(--white);
  transform: scale(0);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@media (prefers-reduced-motion: reduce) {
  .desk-task-checkbox, .desk-task-checkbox::before, .desk-task-row, .desk-metric-card {
    transition: none;
  }
}

.desk-task-checkbox:checked {
  background-color: var(--green-light);
  border-color: var(--green-light);
}

.desk-task-checkbox:checked::before {
  transform: scale(1);
}

.desk-task-checkbox:hover {
  border-color: var(--green-light);
}

.desk-task-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.desk-task-title {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--headline);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s ease;
}

.desk-task-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.desk-task-context {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.desk-task-due {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  white-space: nowrap;
}

.desk-task-due.overdue {
  background: var(--apricot-tint);
  color: var(--apricot-deep);
}

.desk-task-due.upcoming {
  background: var(--green-tint);
  color: var(--green-light);
}

.desk-task-status {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.desk-task-row.is-completed {
  opacity: 0.6;
  background: var(--bg);
}

.desk-task-row.is-completed .desk-task-title {
  text-decoration: line-through;
  color: var(--muted);
}

.task-save-ind {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.task-save-ind.is-saving { color: var(--muted); }
.task-save-ind.is-saved { color: var(--green-light); }
.task-save-ind.is-error { color: var(--apricot-deep); }

@media (max-width: 640px) {
  .desk-metrics {
    grid-template-columns: 1fr 1fr;
  }
  
  .desk-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .desk-search-bar {
    width: 100%;
  }
  
  .desk-quick-capture {
    flex-direction: column;
  }
  
  .desk-quick-capture button {
    width: 100%;
  }
  
  .desk-task-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .desk-task-checkbox {
    position: absolute;
    right: 16px;
    top: 16px;
  }
  
  .desk-task-content {
    width: calc(100% - 32px); /* leave room for absolute checkbox */
  }
  
  .desk-task-title {
    white-space: normal;
  }
}

/* ---- Desk Combo Card & Stats Grid ---- */
.desk-stats-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
@container maincol (max-width: 1080px) {
  .desk-stats-grid { grid-template-columns: 1fr 1fr; }
}
@container maincol (max-width: 700px) {
  .desk-stats-grid { grid-template-columns: 1fr; }
}

.desk-combo-card {
  display: flex;
  padding: 0;
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.15s;
}
.desk-combo-card:hover {
  border-color: #C9D2C9;
}

.desk-combo-main {
  flex: 1;
  padding: 18px 20px;
  cursor: pointer;
  background: var(--bg);
  transition: background 0.15s;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.desk-combo-main:hover {
  background: #F4F6F4;
}
.desk-combo-main:focus-visible {
  background: #F4F6F4;
  outline: 2px solid var(--green-light);
  outline-offset: -2px;
}
.desk-combo-main .stat-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  color: var(--headline);
  line-height: 1.1;
  margin: 6px 0 2px;
}

.desk-combo-sub {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
}
.desk-combo-btn {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  min-height: 32px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
  color: var(--headline);
  border-left: none;
  border-right: none;
  border-top: none;
  text-align: left;
}
.desk-combo-btn:last-child {
  border-bottom: none;
}
.desk-combo-btn:hover {
  background: #F4F6F4;
}
.desk-combo-btn:focus-visible {
  background: #F4F6F4;
  outline: 2px solid var(--green-light);
  outline-offset: -2px;
}
.desk-combo-btn .c-label {
  font-weight: 500;
}
.desk-combo-btn .c-val {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ---- Grouped Desk Filters ---- */
.desk-filters-container {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 12px 0;
  margin-left: 12px;
}
.desk-filter-segment {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.desk-filter-label {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-left: 2px;
}
.desk-filter-group {
  display: flex;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.desk-filter-btn {
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: var(--font-body);
}
.desk-filter-btn:last-child {
  border-right: none;
}
.desk-filter-btn:hover,
.desk-filter-btn:focus-visible {
  background: #F4F6F4;
  color: var(--headline);
  outline: none;
}
.desk-filter-btn.active {
  background: var(--surface-dark);
  color: var(--green);
  font-weight: 500;
}
.desk-filter-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 1px;
}
.desk-filter-reset:hover,
.desk-filter-reset:focus-visible {
  background: var(--white);
  border-color: var(--border);
  color: var(--headline);
  outline: none;
}
@container maincol (max-width: 860px) {
  .desk-filters-container {
    margin-left: 0;
    width: 100%;
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: 4px;
  }
}

.wizard-workflow {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.interview-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
