/* Zero Portal — Cybersyn-inspired warm 70s palette */

:root {
  --text: #1c1917;
  --text-2: #44403c;
  --text-3: #a8a29e;
  --orange: #c2410c;
  --orange-mid: #ea580c;
  --orange-bright: #f97316;
  --orange-muted: rgba(194, 65, 12, 0.35);
  --amber: #b45309;
  --teal: #0f766e;
  --teal-mid: #0d9488;
  --surface: #ffffff;
  --bg: #f4f1ec;
  --bg-mid: #eae7e0;
  --border: #ddd6cb;
  --border-light: #e8e2d7;
  --green: #059669;
  --green-bg: #d1fae5;
  --blue: #2563eb;
  --blue-bg: #dbeafe;
  --amber-bg: #fef3c7;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --radius: 14px;
  --shadow: 0 0 0 1px rgba(255,255,255,0.7), 0 1px 2px rgba(28,25,23,0.04), 0 4px 16px rgba(28,25,23,0.07), 0 16px 48px rgba(28,25,23,0.07);
  --shadow-sm: 0 0 0 1px rgba(255,255,255,0.6), 0 1px 2px rgba(28,25,23,0.04), 0 4px 14px rgba(28,25,23,0.06), 0 12px 36px rgba(28,25,23,0.05);
}

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

body {
  font-family: -apple-system, 'SF Pro Display', 'SF Pro Text', system-ui, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
}

/* Warm textured background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse at 15% 20%, rgba(168, 85, 50, 0.02) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 60%, rgba(15, 118, 110, 0.025) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 90%, rgba(140, 100, 60, 0.015) 0%, transparent 40%);
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
}

/* ---- Constellation canvas (inactive — shadows replace it) ---- */
#constellation {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  display: none;
}

/* ---- Shadow layers ---- */
.shadow-layer { /* styled inline by shadows.js */ }

/* ---- Hero ---- */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem;
  position: relative;
  overflow: hidden;
  z-index: 1;
}
.hero-content {
  position: relative;
  z-index: 2;
  max-width: 700px;
}
.hero-mark {
  font-size: clamp(3.5rem, 8vw, 5.5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
}
.hero-context {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--text-3);
  margin-bottom: 1.5rem;
}
.hero-tagline {
  margin-top: 2rem;
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
  font-weight: 500;
  color: var(--text);
  line-height: 1.5;
}
.hero-sub {
  margin-top: 0.65rem;
  font-size: clamp(0.9rem, 2vw, 1.05rem);
  color: var(--text-2);
  line-height: 1.6;
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}
.hero-cta {
  margin-top: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.hero-hint {
  margin-top: 1rem;
  font-size: 0.78rem;
  color: var(--text-3);
}

.scroll-hint {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  color: var(--orange);
  opacity: 0.7;
  animation: bobDown 2.4s ease-in-out infinite;
  transition: opacity 0.3s;
  cursor: pointer;
}
.scroll-hint:hover { opacity: 1; }
.scroll-hint-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.scroll-hint svg {
  width: 24px; height: 24px;
  stroke: currentColor; fill: none;
  stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
}
@keyframes bobDown {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(8px); }
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 9999px;
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-dark {
  background: var(--orange);
  color: #fff;
  padding: 0.8rem 2rem;
}
.btn-dark:hover {
  background: var(--orange-mid);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(194, 65, 12, 0.2);
}
.btn-dark .arrow {
  transition: transform 0.2s;
  font-weight: 400;
}
.btn-dark:hover .arrow { transform: translateX(3px); }
.btn-ghost {
  background: rgba(255,255,255,0.7);
  color: var(--text);
  padding: 0.8rem 2rem;
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.9);
  border-color: var(--text-3);
}
.btn-primary {
  background: var(--orange);
  color: #fff;
  padding: 0.7rem 1.8rem;
  border-radius: 9999px;
}
.btn-primary:hover { background: var(--orange-mid); }
.btn-outline {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border);
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.78rem;
}
.btn-outline:hover { background: var(--surface); border-color: var(--text-3); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }

/* ---- Content sections ---- */
.content { max-width: 600px; margin: 0 auto; padding: 0 1.5rem; position: relative; z-index: 1; }

/* Properties — floating containers */
.properties { padding: 4rem 0 2rem; }
.prop {
  padding: 1.3rem 1.4rem;
  margin-bottom: 0.75rem;
  display: flex;
  gap: 1.5rem;
  align-items: baseline;
  background: linear-gradient(180deg, #ffffff 0%, #fdfcfa 100%);
  border-radius: var(--radius);
  border-top: 1px solid rgba(255,255,255,0.9);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}
.prop-title {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--orange);
  min-width: 130px;
  flex-shrink: 0;
}
.prop-desc {
  font-size: 0.92rem;
  color: var(--text-2);
  line-height: 1.55;
}

/* Steps — floating container */
.steps { padding: 2rem 0 1.5rem; }
.steps-container {
  background: linear-gradient(180deg, #ffffff 0%, #fdfcfa 100%);
  border-radius: var(--radius);
  border-top: 1px solid rgba(255,255,255,0.9);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  padding: 1.4rem;
}
.steps h2 {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 1.25rem;
}
.step {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  padding: 0.65rem 0;
}
.step-num {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--orange);
  min-width: 1.5rem;
}
.step-text {
  font-size: 0.9rem;
  color: var(--text-2);
  line-height: 1.55;
}
.step-text code {
  background: rgba(194, 65, 12, 0.07);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.82rem;
  font-family: 'SF Mono', ui-monospace, monospace;
  color: var(--orange);
  font-weight: 500;
}

/* ---- Dashboard ---- */
.dash-wrap { max-width: 720px; margin: 0 auto; padding: 4.25rem 1.5rem 3rem; position: relative; z-index: 1; }

/* ---- Header bar ---- */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: 44px;
  background: rgba(244, 241, 236, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  max-width: 600px;
  margin: 0 auto;
}
@supports (backdrop-filter: blur(12px)) {
  .header-bar { background: rgba(244, 241, 236, 0.7); }
}

/* Nav — left side */
.header-nav {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 500;
}
.header-nav-home {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: -0.01em;
  transition: color 0.15s;
}
.header-nav-home:hover { color: var(--orange); }
.header-nav-sep { color: var(--text-3); margin: 0 0.3rem; font-weight: 400; }
.header-nav-link {
  color: var(--text-3);
  text-decoration: none;
  transition: color 0.15s;
}
.header-nav-link:hover { color: var(--orange); }
.header-nav-current {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* User — right side */
.header-user { position: relative; }
.header-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--text);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.7rem; color: #fff;
  border: none; cursor: pointer;
  transition: opacity 0.15s;
}
.header-avatar:hover { opacity: 0.8; }

/* Dropdown */
.header-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  padding: 0.35rem 0;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 60;
}
.header-dropdown.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.header-dropdown-email {
  padding: 0.5rem 0.85rem;
  font-size: 0.75rem;
  color: var(--text-3);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-dropdown-sep {
  height: 1px;
  background: var(--border-light);
  margin: 0.2rem 0;
}
.header-dropdown-item {
  display: block;
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  color: var(--text-2);
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
}
.header-dropdown-item:hover {
  background: var(--bg);
  color: var(--text);
}
.header-dropdown-logout { color: var(--text-3); }
.header-dropdown-logout:hover { color: var(--red); }

/* ---- Three-state Panel ---- */
/* ---- Panel grid layout ---- */
.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
}
.panel-grid > div { min-width: 0; }
.panel-grid > div:empty { display: none; }
/* Full-size panels span both columns */
.panel-grid .panel:not(.panel-half):not(.panel-mini) { grid-column: 1 / -1; }
/* Half panels flow naturally into the 2-col grid */
.panel-half { }
/* Mini panels: compact card style */
.panel-mini .panel-body { padding: 0.3rem 0.75rem 0.5rem; }
.panel-mini .panel-header { padding: 0.4rem 0.75rem; }
.panel-mini .panel-summary h3 { font-size: 0.8rem; }
@media (max-width: 540px) {
  .panel-grid { grid-template-columns: 1fr; }
}

.panel {
  background: linear-gradient(180deg, #ffffff 0%, #fdfcfa 100%);
  border-radius: var(--radius);
  border-top: 1px solid rgba(255,255,255,0.9);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  padding: 0;
  margin-bottom: 0.75rem;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  transition: background 0.15s;
}
.panel[data-panel-id] .panel-header { cursor: pointer; user-select: none; -webkit-user-select: none; }
.panel[data-panel-id] .panel-header:hover { background: rgba(0,0,0,0.015); }
.panel-static .panel-header { cursor: default; }
.panel-static .panel-header:hover { background: none; }

.panel-summary { display: flex; align-items: baseline; gap: 0.6rem; min-width: 0; }
.panel-summary h3 { font-size: 0.88rem; font-weight: 600; color: var(--text); white-space: nowrap; }
.panel-hint {
  font-size: 0.75rem; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.panel-actions { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }

/* Chevron */
.panel-chevron { transition: transform 0.25s ease; color: var(--text-3); flex-shrink: 0; }
.panel-expanded .panel-chevron { transform: rotate(180deg); }

/* Full-page button */
.panel-fp-btn {
  background: none; border: none; color: var(--text-3); cursor: pointer;
  padding: 0.2rem; border-radius: 4px; display: flex; align-items: center;
  opacity: 0; pointer-events: none; transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.panel-expanded .panel-fp-btn { opacity: 1; pointer-events: auto; }
.panel-fp-btn:hover { color: var(--orange); background: rgba(194, 65, 12, 0.06); }

/* Panel body — animated */
.panel-body {
  padding: 0 1.25rem;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.25s ease, opacity 0.2s ease;
}
.panel-collapsed .panel-body {
  max-height: 0 !important;
  padding-top: 0; padding-bottom: 0;
  opacity: 0;
}
.panel-expanded .panel-body {
  padding-bottom: 1.25rem;
  opacity: 1;
}
/* Static panels (no id) keep the old padding feel */
.panel-static .panel-body { padding-top: 0; }

.panel-desc { color: var(--text-2); font-size: 0.82rem; margin-bottom: 0.85rem; line-height: 1.5; }

/* ---- Full-page overlay ---- */
.panel-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(28, 25, 23, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; justify-content: center; align-items: flex-start;
  padding: 2rem 1rem;
  overflow-y: auto;
  opacity: 0; transition: opacity 0.2s ease;
}
.panel-overlay-open { opacity: 1; }

.panel-overlay-chrome {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%; max-width: min(960px, calc(100vw - 3rem));
  min-height: 50vh; max-height: calc(100vh - 4rem);
  overflow-y: auto;
  transform: translateY(12px);
  transition: transform 0.25s ease;
}
.panel-overlay-open .panel-overlay-chrome { transform: translateY(0); }

.panel-overlay-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  position: sticky; top: 0;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  z-index: 1;
}
.panel-overlay-header h2 { font-size: 1rem; font-weight: 600; }
.panel-close-btn {
  background: none; border: none; font-size: 1.4rem; color: var(--text-3);
  cursor: pointer; padding: 0.25rem 0.5rem; border-radius: 6px; line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.panel-close-btn:hover { color: var(--text); background: var(--bg); }
.panel-overlay-body { padding: 2rem 2.5rem; }

/* Overlay renders markdown content */
.panel-overlay-body h1 { font-size: 1.1rem; font-weight: 700; margin: 1.5rem 0 0.5rem; }
.panel-overlay-body h2 { font-size: 1rem; font-weight: 600; margin: 1.25rem 0 0.4rem; }
.panel-overlay-body h3 { font-size: 0.92rem; font-weight: 600; margin: 1rem 0 0.3rem; }
.panel-overlay-body p { font-size: 0.88rem; line-height: 1.6; margin-bottom: 0.6rem; color: var(--text-2); }
.panel-overlay-body ul, .panel-overlay-body ol { font-size: 0.88rem; padding-left: 1.25rem; margin-bottom: 0.6rem; color: var(--text-2); }
.panel-overlay-body li { margin-bottom: 0.25rem; line-height: 1.5; }

/* Loading skeleton */
.panel-loading {
  height: 1rem; border-radius: 6px;
  background: linear-gradient(90deg, var(--bg) 25%, var(--bg-mid) 50%, var(--bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite; margin-bottom: 0.5rem;
}
.panel-loading:nth-child(2) { width: 80%; }
.panel-loading:nth-child(3) { width: 60%; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Top progress bar */
.progress-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  height: 2px; background: transparent;
  pointer-events: none;
}
.progress-bar::after {
  content: ''; display: block; height: 100%;
  background: var(--text-3);
  width: 0%; transition: width 0.3s ease;
}
.progress-bar.loading::after {
  width: 70%;
  transition: width 8s cubic-bezier(0.1, 0.5, 0.3, 1);
}
.progress-bar.done::after {
  width: 100%;
  transition: width 0.2s ease;
  opacity: 0;
  transition: width 0.2s ease, opacity 0.4s 0.2s ease;
}

@media (max-width: 520px) {
  .panel-overlay { padding: 0; }
  .panel-overlay-chrome { max-width: 100%; min-height: 100vh; max-height: 100vh; border-radius: 0; }
  .panel-overlay-header { border-radius: 0; }
}

.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--text);
  position: relative;
  cursor: pointer;
  overflow-x: auto;
  white-space: nowrap;
  transition: border-color 0.15s;
}
.code-block:hover { border-color: var(--text-3); }
.code-block .copy {
  position: absolute; top: 0.5rem; right: 0.5rem;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-3); padding: 0.15rem 0.45rem;
  border-radius: 5px; font-size: 0.62rem;
  font-family: inherit; cursor: pointer; font-weight: 500;
}
.code-block .copy:hover { color: var(--text); border-color: var(--text-3); }

/* Connect page */
.connect-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.connect-table td { padding: 0.4rem 0; vertical-align: top; }
.connect-table .connect-label { color: var(--text-3); width: 40%; font-weight: 500; }
.connect-table code { background: var(--bg); padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.78rem; }

.item-list { list-style: none; }
.item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0; border-bottom: 1px solid var(--border-light);
}
.item:last-child { border-bottom: none; }
.item-name { color: var(--text); font-size: 0.85rem; }
.item-meta { display: flex; align-items: center; gap: 0.4rem; }
.badge { font-size: 0.65rem; padding: 0.1rem 0.4rem; border-radius: 4px; font-weight: 500; }
.badge-ok { background: var(--green-bg); color: var(--green); }
.badge-admin { background: var(--blue-bg); color: var(--blue); }
.badge-pending { background: var(--amber-bg); color: var(--amber); }
.badge-muted { background: var(--bg-2); color: var(--text-3); }
.item-date { color: var(--text-3); font-size: 0.68rem; }
.empty { color: var(--text-3); font-size: 0.85rem; font-style: italic; padding: 0.4rem 0; }

/* Entity tree */
.org-group { margin-bottom: 1rem; }
.org-group:last-child { margin-bottom: 0; }
.org-header { display: flex; justify-content: space-between; align-items: center; padding: 0.35rem 0; }
.org-name { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.entity-list { list-style: none; padding-left: 1rem; border-left: 2px solid rgba(194, 65, 12, 0.15); margin: 0.25rem 0 0 0.5rem; }
.entity-item { display: flex; justify-content: space-between; align-items: center; padding: 0.35rem 0; border-bottom: 1px solid var(--border-light); }
.entity-item:last-child { border-bottom: none; }
.entity-name { font-size: 0.82rem; color: var(--text); }
.entity-slug { font-size: 0.68rem; color: var(--text-3); font-family: 'SF Mono', 'Fira Code', monospace; }
.entity-cmd { font-size: 0.65rem; color: var(--orange); cursor: pointer; font-family: 'SF Mono', 'Fira Code', monospace; opacity: 0.7; transition: opacity 0.15s; }
.entity-cmd:hover { opacity: 1; }

/* ---- Request Access ---- */
.req-wrap { max-width: 600px; margin: 0 auto; padding: 2rem 1.5rem 3rem; position: relative; z-index: 1; }
.request-box {
  background: linear-gradient(180deg, #ffffff 0%, #fdfcfa 100%);
  border-radius: var(--radius);
  border-top: 1px solid rgba(255,255,255,0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  padding: 1.75rem;
  text-align: center;
}
.request-box h2 { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 0.5rem; }
.request-box .subtitle { font-size: 0.88rem; color: var(--text-2); margin-bottom: 1.5rem; line-height: 1.55; }
.form-group { text-align: left; margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-2); margin-bottom: 0.3rem; }
.form-input {
  width: 100%; padding: 0.55rem 0.75rem;
  border: 1px solid var(--border); border-radius: 7px;
  font-size: 0.85rem; font-family: inherit; color: var(--text);
  background: var(--bg); transition: border-color 0.15s;
}
.form-input:focus { outline: none; border-color: var(--orange); }
.form-input:read-only { color: var(--text-3); cursor: default; }
textarea.form-input { resize: vertical; min-height: 80px; }
.request-sent { color: var(--green); font-size: 0.85rem; font-weight: 500; }

.error-banner {
  text-align: center; color: var(--red); background: var(--red-bg);
  border: 1px solid #fecaca; border-radius: var(--radius);
  padding: 0.65rem 1rem; font-size: 0.82rem; margin-bottom: 1rem;
}

/* ---- Onboarding steps ---- */
.onboard-steps { display: flex; flex-direction: column; gap: 0.25rem; }
.onboard-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-light);
}
.onboard-step:last-child { border-bottom: none; }
.step-check {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700;
  flex-shrink: 0;
}
.step-check.done { background: var(--green-bg); color: var(--green); font-size: 0.82rem; }
.step-check.pending { background: var(--bg-mid); color: var(--text-3); }
.onboard-step-content { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.onboard-step-label { font-size: 0.85rem; font-weight: 500; color: var(--text); }
.onboard-step.done .onboard-step-label { color: var(--text-2); }
.onboard-step-detail { font-size: 0.75rem; color: var(--text-3); }

/* ---- Invitation banner ---- */
.invite-banner {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.06) 0%, rgba(15, 118, 110, 0.06) 100%);
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}
.invite-banner h3 { font-size: 0.88rem; font-weight: 600; color: var(--blue); margin-bottom: 0.35rem; }
.invite-entity { font-size: 0.85rem; color: var(--text); font-weight: 500; }
.invite-actions { display: flex; gap: 0.5rem; margin-top: 0.65rem; }

/* ---- Entity view ---- */
.entity-doc { font-size: 0.85rem; line-height: 1.6; color: var(--text-2); }
.entity-doc .md-h1 {
  font-size: 0.95rem; font-weight: 700; color: var(--text);
  margin: 1.25rem 0 0.5rem; padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border-light);
}
.entity-doc .md-h1:first-child { margin-top: 0; }
.entity-doc .md-h2 {
  font-size: 0.88rem; font-weight: 600; color: var(--text);
  margin: 1.1rem 0 0.4rem; letter-spacing: 0.01em;
}
.entity-doc .md-h3, .entity-doc .md-h4 {
  font-size: 0.82rem; font-weight: 600; color: var(--text-2);
  margin: 0.85rem 0 0.3rem;
}
.entity-doc .md-p { margin-bottom: 0.45rem; }
.entity-doc .md-ul {
  list-style: none; margin: 0.3rem 0 0.5rem; padding: 0;
}
.entity-doc .md-li {
  margin-left: 1rem; margin-bottom: 0.3rem;
  padding-left: 0.25rem; position: relative;
}
.entity-doc .md-li::before {
  content: ''; position: absolute; left: -0.55rem; top: 0.55em;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--border);
}
.entity-doc .md-li strong:first-child {
  color: var(--text); font-size: 0.84rem;
}
.entity-doc .md-bq {
  border-left: 3px solid var(--border);
  padding: 0.4rem 0.75rem;
  color: var(--text-3); font-size: 0.8rem;
  margin: 0.5rem 0; background: rgba(0,0,0,0.015);
  border-radius: 0 6px 6px 0;
}
.entity-doc .md-code {
  background: rgba(0, 0, 0, 0.04);
  padding: 0.1rem 0.35rem; border-radius: 3px;
  font-size: 0.78rem; font-family: 'SF Mono', ui-monospace, monospace;
  color: var(--text);
}
.entity-doc strong { color: var(--text); }
.entity-doc .md-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.8rem; margin: 0.5rem 0 0.75rem;
}
.entity-doc .md-table th {
  text-align: left; font-weight: 600; color: var(--text);
  padding: 0.4rem 0.6rem; border-bottom: 2px solid var(--border);
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em;
}
.entity-doc .md-table td {
  padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--border-light);
  color: var(--text-2); vertical-align: top;
}
.entity-doc .md-table tr:last-child td { border-bottom: none; }
.entity-doc .md-table tbody tr:hover { background: rgba(0,0,0,0.015); }

.queue-meta { margin-left: 0.4rem; }
.badge-critical { background: var(--red-bg); color: var(--red); }
.badge-high { background: #fef3c7; color: #b45309; }
.badge-medium { background: var(--bg-2); color: var(--text-2); }

/* ---- Plan detail ---- */
.plan-item { cursor: pointer; transition: background 0.15s; }
.plan-item:hover { background: rgba(0,0,0,0.02); }
.plan-item.plan-item-active { background: rgba(0,0,0,0.015); }

.plan-detail { padding: 0.75rem 0 0.5rem; }
.plan-description { font-size: 0.82rem; color: var(--text-2); margin-bottom: 0.75rem; line-height: 1.5; }

/* Stage timeline */
.stage-timeline { list-style: none; position: relative; padding-left: 1.25rem; margin: 0.5rem 0; }
.stage-timeline::before {
  content: ''; position: absolute; left: 0.35rem; top: 0.5rem; bottom: 0.5rem;
  width: 2px; background: var(--border);
}
.stage-item {
  position: relative; padding: 0.4rem 0 0.5rem; font-size: 0.82rem;
  border-bottom: 1px solid var(--border-light);
}
.stage-item:last-child { border-bottom: none; }
.stage-item::before {
  content: ''; position: absolute; left: -1.05rem; top: 0.65rem;
  width: 8px; height: 8px; border-radius: 50%; background: var(--text-3);
}
.stage-item[data-status="active"]::before { background: var(--orange); }
.stage-item[data-status="done"]::before { background: var(--green); }
.stage-item[data-status="blocked"]::before { background: var(--red); }
.stage-item[data-status="pending"]::before { background: var(--text-3); }

.stage-header { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.stage-number { font-size: 0.7rem; color: var(--text-3); font-weight: 600; min-width: 1.2rem; }
.stage-title { font-weight: 500; color: var(--text); }
.stage-owner { font-size: 0.72rem; color: var(--text-3); }
.stage-meta { font-size: 0.75rem; color: var(--text-3); margin-top: 0.2rem; line-height: 1.4; }

.badge-active { background: rgba(194, 65, 12, 0.12); color: var(--orange); }
.badge-done { background: var(--green-bg); color: var(--green); }
.badge-blocked { background: var(--red-bg); color: var(--red); }
.badge-draft { background: var(--bg-mid); color: var(--text-3); }

/* Progress bar */
.plan-progress { margin: 0.5rem 0 0.25rem; }
.plan-progress-label { font-size: 0.72rem; color: var(--text-3); margin-bottom: 0.25rem; }
.plan-progress-bar {
  height: 4px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.plan-progress-fill {
  height: 100%; background: var(--green); border-radius: 2px;
  transition: width 0.3s ease;
}

/* Plan actions */
.plan-actions { margin-top: 0.5rem; }

/* ---- Stub views ---- */
.stub-wrap { max-width: 600px; margin: 0 auto; padding: 2rem 1.5rem 3rem; position: relative; z-index: 1; }
.stub-title { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 0.5rem; }
.stub-hint { font-size: 0.85rem; color: var(--text-3); }

/* Footer */
.footer {
  text-align: center; padding: 3rem 0 2rem;
  color: var(--text-3); font-size: 0.75rem;
  position: relative; z-index: 1;
}
.footer a { color: var(--text-3); text-decoration: none; transition: color 0.15s; }
.footer a:hover { color: var(--orange); }
.footer-links { margin-bottom: 0.5rem; }
.footer-links a { margin: 0 0.5rem; }
.footer-sep { margin: 0 0.15rem; color: var(--border); }

/* ---- Inline entity rename ---- */
.entity-name-editable { cursor: pointer; position: relative; }
.entity-name-editable:hover .entity-rename-icon { opacity: 0.45; }
.entity-rename-icon {
  display: inline-block; opacity: 0; transition: opacity 0.15s;
  margin-left: 0.35rem; font-size: 0.7em; vertical-align: baseline;
  color: var(--text-3);
}
.entity-rename-input {
  font-size: 0.88rem; font-weight: 600; font-family: inherit;
  color: var(--text); background: transparent;
  border: none; border-bottom: 1.5px solid var(--orange);
  outline: none; padding: 0; margin: 0; line-height: inherit;
  width: auto; min-width: 4rem;
}
.entity-rename-saving { opacity: 0.5; pointer-events: none; }
.entity-rename-error {
  position: absolute; top: 100%; left: 0; white-space: nowrap;
  font-size: 0.72rem; font-weight: 400; color: var(--red);
  margin-top: 0.2rem;
}

/* ---- Intelligence panel ---- */

.intel-tabs {
  display: flex; gap: 0.25rem; margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light); padding-bottom: 0.5rem;
  flex-wrap: wrap;
}
.intel-tab {
  background: none; border: none; cursor: pointer;
  font-size: 0.78rem; font-weight: 500; color: var(--text-3);
  padding: 0.3rem 0.6rem; border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  display: inline-flex; align-items: center; gap: 0.3rem;
}
.intel-tab:hover { background: var(--bg-mid); color: var(--text-2); }
.intel-tab-active { background: var(--bg-mid); color: var(--text); font-weight: 600; }
.intel-tab-count {
  font-size: 0.6rem; font-weight: 600; background: var(--border);
  color: var(--text-2); border-radius: 8px; padding: 0 0.3rem;
  min-width: 1.1rem; text-align: center; line-height: 1.4;
}
.intel-tab-active .intel-tab-count { background: var(--orange-muted); color: var(--orange); }

.intel-cards { display: flex; flex-direction: column; gap: 0.5rem; }

.intel-card {
  border: 1px solid var(--border-light); border-radius: 10px;
  padding: 0.65rem 0.8rem; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--surface);
}
.intel-card:hover { border-color: var(--border); box-shadow: var(--shadow-sm); }
.intel-card-expanded { border-color: var(--border); }

.intel-card-header { display: flex; flex-direction: column; gap: 0.25rem; }
.intel-card-title-row { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.intel-card-title { font-size: 0.85rem; color: var(--text); }
.intel-card-meta {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.72rem; color: var(--text-3);
}
.intel-card-source { font-size: 0.72rem; color: var(--text-3); }

.intel-card-preview {
  font-size: 0.8rem; color: var(--text-2); line-height: 1.5;
  margin-top: 0.35rem; word-break: break-word;
}
.intel-card-preview .md-p,
.intel-card-preview .md-ul,
.intel-card-preview .md-h1,
.intel-card-preview .md-h2,
.intel-card-preview .md-h3,
.intel-card-preview .md-h4 { margin: 0.15rem 0; }

.intel-card-content {
  font-size: 0.8rem; color: var(--text-2); line-height: 1.5;
  margin-top: 0.35rem; word-break: break-word;
}

/* JSON preview in intelligence cards */
.json-preview {
  width: 100%; border-collapse: collapse;
  font-size: 0.78rem;
}
.json-preview td {
  padding: 0.2rem 0.5rem 0.2rem 0;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}
.json-key {
  font-weight: 600; color: var(--text); white-space: nowrap;
  width: 1%; /* shrink to fit */
}
.json-val { color: var(--text-2); word-break: break-word; }
.json-raw {
  font-size: 0.75rem; color: var(--text-3);
  white-space: pre-wrap; word-break: break-word;
  margin: 0; padding: 0.5rem;
  background: var(--bg-2); border-radius: 4px;
}

.intel-card-actions {
  display: flex; gap: 0.4rem; margin-top: 0.5rem;
  padding-top: 0.4rem; border-top: 1px solid var(--border-light);
}

/* Intelligence type badges */
.badge-intel-flag { background: rgba(249, 115, 22, 0.12); color: var(--orange); }
.badge-intel-brief { background: var(--blue-bg); color: var(--blue); }
.badge-intel-finding { background: rgba(15, 118, 110, 0.1); color: var(--teal); }
.badge-intel-synthesis { background: rgba(88, 28, 135, 0.08); color: #7c3aed; }

/* ---- Utilities ---- */
.hidden { display: none !important; }
.loading { text-align: center; padding: 5rem 0; color: var(--text-3); font-size: 0.88rem; position: relative; z-index: 1; }

/* ---- Knowledge Explorer ---- */

/* Tree — shared between compact panel and overlay sidebar */
.doc-tree-compact { font-size: 0.82rem; }

.doc-tree-folder-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: color 0.15s;
  font-weight: 600;
  color: var(--text);
  font-size: 0.82rem;
}
.doc-tree-folder-label:hover { color: var(--orange); }

.doc-tree-chevron {
  font-size: 0.55rem;
  color: var(--text-3);
  width: 0.8rem;
  flex-shrink: 0;
  text-align: center;
  transition: color 0.15s;
}
.doc-tree-folder-label:hover .doc-tree-chevron { color: var(--orange); }

.doc-tree-folder-name { letter-spacing: 0.01em; }

.doc-tree-children {
  transition: none;
}

.doc-tree-file {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0;
  padding-left: 1rem;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-2);
  transition: color 0.15s, background 0.15s;
  border-radius: 4px;
}
.doc-tree-file:hover { color: var(--orange); background: rgba(194, 65, 12, 0.04); }
.doc-tree-file.doc-tree-active {
  color: var(--orange);
  background: rgba(194, 65, 12, 0.08);
  font-weight: 500;
}

.doc-tree-file-icon {
  font-size: 0.7rem;
  color: var(--text-3);
  width: 0.8rem;
  flex-shrink: 0;
  text-align: center;
}
.doc-tree-file.doc-tree-active .doc-tree-file-icon { color: var(--orange); }

.doc-tree-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Explorer overlay — split layout */
.doc-explorer-chrome {
  display: flex;
  flex-direction: column;
}

.doc-explorer-split {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.doc-explorer-sidebar {
  width: 250px;
  min-width: 200px;
  max-width: 300px;
  border-right: 1px solid var(--border-light);
  overflow-y: auto;
  padding: 1rem 0.75rem;
  flex-shrink: 0;
}

.doc-explorer-tree { font-size: 0.82rem; }

.doc-explorer-viewer {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  min-width: 0;
}

.doc-explorer-empty,
.doc-explorer-error,
.doc-explorer-loading {
  padding: 2rem 0;
}

.doc-explorer-doc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.doc-explorer-doc-path {
  font-size: 0.72rem;
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  color: var(--text-3);
  letter-spacing: 0.02em;
}

.doc-explorer-actions { flex-shrink: 0; }

/* Markdown extras for explorer */
.doc-explorer-content .md-codeblock {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 0.76rem;
  overflow-x: auto;
  margin: 0.5rem 0 0.75rem;
  line-height: 1.5;
  white-space: pre;
}
.doc-explorer-content .md-codeblock code {
  background: none;
  padding: 0;
  font-size: inherit;
  color: var(--text);
}

.doc-explorer-content .md-hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 1rem 0;
}

.doc-explorer-link {
  color: var(--teal);
  text-decoration: none;
  border-bottom: 1px solid rgba(15, 118, 110, 0.2);
  transition: color 0.15s, border-color 0.15s;
  cursor: pointer;
}
.doc-explorer-link:hover {
  color: var(--teal-mid);
  border-color: var(--teal-mid);
}

/* Override overlay chrome for explorer to use full height with split */
.doc-explorer-overlay .panel-overlay-chrome {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 4rem);
}
.doc-explorer-overlay .panel-overlay-body { display: none; }

@media (max-width: 520px) {
  .doc-explorer-split { flex-direction: column; }
  .doc-explorer-sidebar {
    width: 100%;
    max-width: none;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
    max-height: 40vh;
    overflow-y: auto;
  }
  .doc-explorer-viewer { padding: 1rem; }
  .hero-mark { font-size: 3rem; }
  .hero-cta { flex-direction: column; }
  .prop { flex-direction: column; gap: 0.3rem; }
  .prop-title { min-width: 0; }
}

/* ---- Queue panel ---- */
.queue-filters {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
}
.queue-filter-group {
  display: flex;
  gap: 0.25rem;
}
.queue-filter-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.15s;
}
.queue-filter-btn:hover {
  color: var(--text-2);
  border-color: var(--text-3);
}
.queue-filter-btn.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

/* Queue item expansion */
.queue-item { flex-direction: column; align-items: stretch; }
.queue-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
.queue-item-expanded {
  background: rgba(0, 0, 0, 0.015);
  margin: 0 -0.5rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  border-radius: 8px;
}

/* Queue detail panel */
.queue-item-detail {
  padding: 0.6rem 0 0.25rem;
}
.queue-detail-desc {
  font-size: 0.82rem;
  color: var(--text-2);
  line-height: 1.55;
  margin-bottom: 0.6rem;
  white-space: pre-wrap;
}
.queue-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
}
.queue-detail-field {
  font-size: 0.78rem;
  color: var(--text-2);
}
.queue-detail-field strong {
  color: var(--text-3);
  font-weight: 500;
  margin-right: 0.3rem;
}

/* Queue actions */
.queue-detail-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-light);
}
.queue-action-resolve {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.queue-note-input {
  flex: 1;
  padding: 0.35rem 0.6rem;
  font-size: 0.78rem;
}
.queue-action-approval {
  display: flex;
  gap: 0.4rem;
}

/* ---- Usage & Spend panel ---- */
.usage-summary {
  display: flex;
  gap: 2rem;
  margin-bottom: 1rem;
}
.usage-stat {
  display: flex;
  flex-direction: column;
}
.usage-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}
.usage-stat-label {
  font-size: 0.72rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.usage-chart {
  margin: 0.75rem 0;
}
.usage-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 80px;
}
.usage-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.usage-bar {
  width: 100%;
  max-width: 28px;
  background: var(--orange);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: height 0.3s ease;
}
.usage-bar:hover {
  background: var(--orange-bright);
}
.usage-bar-label {
  font-size: 0.6rem;
  color: var(--text-3);
  margin-top: 2px;
}
.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin-top: 1rem;
}
.usage-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-3);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #e7e5e4;
}
.usage-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid #f5f5f4;
  color: var(--text-2);
}
.usage-td-id {
  font-family: monospace;
  font-size: 0.72rem;
  color: var(--text-3);
}

