:root {
  --bg: #0b0d12;
  --panel: #11141b;
  --panel-2: #161a22;
  --border: #242b39;
  --text: #f5f7fb;
  --muted: #97a0b2;
  --accent: #6d5efc;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: linear-gradient(180deg, #090b10 0%, #0d1017 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.status-banner {
  position: sticky;
  top: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 13px;
  backdrop-filter: blur(14px);
}
.status-banner.hidden { display: none; }
.offline-banner {
  color: #fff1cf;
  background: rgba(245, 158, 11, 0.14);
  border-bottom-color: rgba(245, 158, 11, 0.3);
}
.install-banner {
  color: var(--text);
  background: rgba(59, 130, 246, 0.14);
  border-bottom-color: rgba(59, 130, 246, 0.3);
}
.status-banner-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.shell { max-width: 1440px; margin: 0 auto; padding: 24px; padding-bottom: 96px; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 20px; position: relative; }
.topbar-menu-button { display: none; }
.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,0.02);
  font-size: 12px;
  font-weight: 700;
}
.connection-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(239,68,68,0.12);
}
.connection-dot.connected { background: var(--green); box-shadow: 0 0 0 4px rgba(34,197,94,0.12); }
.connection-dot.reconnecting { background: var(--yellow); box-shadow: 0 0 0 4px rgba(245,158,11,0.12); }
.connection-dot.disconnected { background: var(--red); box-shadow: 0 0 0 4px rgba(239,68,68,0.12); }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.kpi {
  background: linear-gradient(180deg, rgba(20,24,31,.98), rgba(15,18,24,.98));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}
.kpi-value { font-size: 28px; font-weight: 800; letter-spacing: -0.04em; margin: 6px 0; }
.kpi-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; font-weight: 800; }
.kpi-sub { color: var(--muted); font-size: 13px; }
.eyebrow { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .14em; font-weight: 800; }
h1 { margin: 8px 0 6px; font-size: 32px; letter-spacing: -0.04em; }
.subtitle { margin: 0; color: var(--muted); }
button {
  background: linear-gradient(180deg, #8b7cff, var(--accent));
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 42px;
}
button:disabled {
  cursor: wait;
  opacity: 0.72;
}
.ghost-button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.filter-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.filter-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
  color: var(--muted);
}
.tab-shell {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}
.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-scroll { display: flex; position: relative; gap: 4px; width: max-content; min-width: 100%; }
.tab-chip {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.tab-chip.active {
  background: linear-gradient(180deg, #8b7cff, var(--accent));
  border-color: rgba(109,94,252,0.6);
}
.tab-fade-out { opacity: 0; transform: translateY(4px); transition: opacity 180ms, transform 180ms; }
.tab-fade-in  { animation: tabFadeIn 180ms ease forwards; }
@keyframes tabFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  font-size: 11px; font-weight: 600; line-height: 1;
  border-radius: 9px;
  background: var(--accent); color: var(--bg);
  margin-left: 6px;
}
.tab-chip.active .tab-badge { background: #fff; color: var(--bg); }
.tab-indicator {
  position: absolute; bottom: -2px; height: 2px;
  background: var(--accent); border-radius: 1px;
  transition: left 250ms cubic-bezier(.4,0,.2,1), width 250ms cubic-bezier(.4,0,.2,1);
}
.sub-filter-bar {
  display: flex; gap: 6px; align-items: center;
  padding: 6px 0 2px;
  min-height: 32px;
  flex-wrap: wrap;
}
.sub-filter-bar.hidden { display: none; }
.kpi-card.kpi-dimmed { opacity: 0.4; transition: opacity 300ms; }
.kpi-card { transition: opacity 300ms; }
.tab-hint { min-height: 18px; }
.panel.is-hidden { display: none; }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.panel {
  background: linear-gradient(180deg, rgba(20,24,31,.98), rgba(15,18,24,.98));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.migration-banner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.section-head .filter-bar-wrap {
  min-width: 300px;
}
.task-workflow-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-12 { grid-column: span 12; }
.panel-label { color: #7d8595; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; font-weight: 800; margin-bottom: 10px; }
h2 { margin: 0 0 12px; font-size: 16px; }
.stack, .list { display: grid; gap: 10px; }
.item {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid #252b39;
}
.item.clickable {
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, transform .12s ease, box-shadow .12s ease;
}
.item.clickable:hover,
.item.highlighted {
  border-color: #6d5efc;
  background: rgba(109,94,252,0.08);
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px rgba(109,94,252,0.18);
}
.item strong { display: block; margin-bottom: 6px; }
.muted { color: var(--muted); font-size: 13px; }
.badge {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #2f3647;
  font-size: 12px;
  width: fit-content;
}
.badge.green { color: #d7ffe5; border-color: rgba(34,197,94,.35); background: rgba(34,197,94,.12); }
.badge.yellow { color: #fff1cf; border-color: rgba(245,158,11,.35); background: rgba(245,158,11,.12); }
.badge.red { color: #ffd9d9; border-color: rgba(239,68,68,.35); background: rgba(239,68,68,.12); }
.compact .item { padding: 10px 12px; }
.drawer.hidden, .palette.hidden { display: none; }
.palette, .drawer {
  position: fixed;
  inset: 0;
}
.palette { z-index: 60; }
.drawer { z-index: 40; }
.palette-backdrop, .drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 7, 12, 0.55);
}
.palette-panel {
  position: absolute;
  top: 12vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 24px));
  background: #0f131a;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
  overflow: hidden;
}
.command-palette-panel { max-height: min(76vh, 720px); }
.palette-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 18px 0;
}
.palette-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  padding: 18px 18px 14px;
  font: inherit;
  font-size: 16px;
  border-bottom: 1px solid var(--border);
}
.palette-results {
  display: grid;
  max-height: 52vh;
  overflow: auto;
}
.palette-group {
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.palette-group-label {
  padding: 12px 18px 8px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 800;
}
.palette-item {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
}
.palette-item:last-child { border-bottom: none; }
.palette-item:hover,
.palette-item.active {
  background: rgba(255,255,255,0.04);
}
.palette-title { font-weight: 700; margin-bottom: 4px; }
.palette-subtitle { color: var(--muted); font-size: 13px; }
.palette-hint {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.palette-tag {
  font-size: 11px;
  border-radius: 999px;
  padding: 3px 8px;
  border: 1px solid #334057;
  color: #c5bbff;
}
.toast.hidden { display: none; }
.toast {
  position: sticky;
  top: 8px;
  z-index: 20;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 19, 26, 0.96);
  color: var(--text);
}
.log-output {
  margin: 0;
  padding: 0 18px 18px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d8deea;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  max-height: 60vh;
  overflow: auto;
}
.editor-form {
  display: grid;
  gap: 12px;
  padding: 0 18px 18px;
}
.editor-field { display: grid; gap: 6px; }
.editor-input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(255,255,255,0.03);
  font: inherit;
  font-size: 14px;
}
.editor-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(109,94,252,0.3);
}
select.editor-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2397a0b2' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
select.editor-input option { background: var(--panel); color: var(--text); }
select.editor-input optgroup { background: var(--panel-2); color: var(--accent); font-weight: 600; }
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.action-chip {
  background: transparent;
  border: 1px solid #334057;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  min-height: 34px;
}
.action-chip.active {
  background: rgba(109,94,252,0.14);
  border-color: rgba(109,94,252,0.5);
  color: #d9d3ff;
}
.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(520px, 100vw);
  height: 100%;
  background: #0f131a;
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 60px rgba(0,0,0,.35);
  padding: 18px;
  overflow: auto;
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.drawer-body { display: grid; gap: 14px; }
.drawer-summary {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
}
.drawer-summary-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}
.drawer-summary-sub { color: var(--muted); font-size: 13px; }
.drawer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.drawer-section { display: grid; gap: 8px; }
.drawer-section-title {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 800;
}
.drawer-meta, .meta-list { display: grid; gap: 8px; }
.meta-row, .meta-list-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
}
.meta-key {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 4px;
}
.meta-value-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d8deea;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  max-height: 40vh;
  overflow: auto;
  background: rgba(0,0,0,0.2);
  padding: 10px 12px;
  border-radius: 8px;
}
.meta-inline { display: flex; flex-wrap: wrap; gap: 8px; }
.persona-registry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.persona-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid #242b39;
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
}
.persona-card:hover {
  background: rgba(255,255,255,0.05);
  border-color: #6d5efc;
  transform: translateY(-2px);
}
.persona-card.primary {
  border-color: rgba(109,94,252,0.3);
  background: linear-gradient(135deg, rgba(109,94,252,0.08), rgba(109,94,252,0.02));
}
.persona-name { font-weight: 800; font-size: 14px; margin-bottom: 2px; }
.persona-role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 6px;
}
.persona-domain { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.persona-skills { display: flex; flex-wrap: wrap; gap: 4px; }
.persona-skill {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(109,94,252,0.12);
  color: #c5bbff;
  font-weight: 700;
  letter-spacing: .04em;
}
.execution-flow {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(109,94,252,0.06);
  border: 1px solid rgba(109,94,252,0.15);
}
.flow-stages { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.flow-stage {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.flow-stage.done { color: #d7ffe5; background: rgba(34,197,94,0.12); }
.flow-stage.active {
  color: #fff1cf;
  background: rgba(245,158,11,0.12);
  animation: pulse-glow 2s ease-in-out infinite;
}
.flow-stage.pending { color: #6b7280; background: rgba(107,114,128,0.1); }
.flow-arrow { color: #3a4458; font-size: 10px; }
.flow-detail { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; }
.flow-detail-item {
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid #2a3140;
}
.flow-detail-label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 800;
}
.flow-detail-value { color: var(--text); margin-top: 2px; }
.exec-visual-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 800;
  color: var(--accent);
  border-color: rgba(109,94,252,0.3);
  margin-bottom: 4px;
}
.shortcut-help-panel { width: min(560px, calc(100vw - 24px)); }
.shortcut-list {
  display: grid;
  gap: 10px;
  padding: 0 18px 18px;
}
.shortcut-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
}
.shortcut-row span:first-child {
  font-weight: 800;
  color: #d9d3ff;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); }
  50% { box-shadow: 0 0 0 3px rgba(245,158,11,0.15); }
}
.login-body {
  display: grid;
  place-items: center;
}
.login-shell {
  width: min(100%, 480px);
  padding: 24px;
}
.login-card {
  background: linear-gradient(180deg, rgba(20,24,31,.98), rgba(15,18,24,.98));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}
.login-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}
.login-error {
  border: 1px solid rgba(239,68,68,.35);
  background: rgba(239,68,68,.12);
  color: #ffd9d9;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
}
.login-error.hidden {
  display: none;
}

@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .task-workflow-grid { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .section-head .filter-bar-wrap { min-width: unset; width: 100%; }
  .span-3, .span-4, .span-6, .span-12 { grid-column: span 6; }
  .topbar { flex-direction: column; }
  .filter-bar-wrap { align-items: flex-start; }
}
@media (max-width: 640px) {
  .shell { padding: 16px; padding-bottom: 104px; }
  h1 { font-size: 28px; }
  .topbar { gap: 12px; }
  .topbar-menu-button { display: inline-flex; position: absolute; top: 0; right: 0; }
  .topbar-actions {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(15, 19, 26, 0.98);
  }
  .topbar-actions.open { display: flex; }
  .topbar-actions > * { width: 100%; justify-content: center; }
  .migration-banner { flex-direction: column; align-items: flex-start; }
  .grid { grid-template-columns: 1fr; }
  .span-3, .span-4, .span-6, .span-12 { grid-column: span 1; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .tab-shell {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: rgba(8, 10, 14, 0.94);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(14px);
  }
  .tab-hint, .sub-filter-bar { display: none !important; }
  .tab-bar { overflow-x: auto; }
  .tab-scroll { min-width: max-content; width: max-content; gap: 8px; }
  .tab-chip {
    min-width: 72px;
    min-height: 56px;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 8px 10px;
    border-radius: 18px;
    font-size: 11px;
  }
  .tab-chip::before {
    content: attr(data-tab-icon);
    font-size: 16px;
    line-height: 1;
  }
  .tab-indicator { display: none; }
  .drawer-panel {
    left: 0;
    right: 0;
    width: 100vw;
    border-left: none;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
  .palette-panel {
    top: 8px;
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }
  .palette-results { max-height: calc(100vh - 170px); }
  .shortcut-row { flex-direction: column; gap: 6px; }
  button, .action-chip, .ghost-button { min-height: 44px; }
  .login-shell { padding: 16px; }
  .login-card { padding: 22px; }
  .status-banner {
    flex-direction: column;
    align-items: flex-start;
  }
}
