/* ═══════════════════════════════════════════════════════════════
   BASE
═══════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light;
  --bg: #f5f2ed;
  --ink: #1a1612;
  --ink-2: #3d3530;
  --muted: #7a6f65;
  --card: #fffefb;
  --line: #e0d8cc;
  --line-2: #cfc6b8;
  --accent: #0b6150;
  --accent-hover: #09503f;
  --accent-ink: #ffffff;
  --warn: #b03a20;
  --warn-bg: #fff2ee;
  --warn-line: #f5c4b6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; }

/* ═══════════════════════════════════════════════════════════════
   LANDING PAGE  (index.html — no body class)
═══════════════════════════════════════════════════════════════ */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(20px, 4vw, 52px);
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.brand {
  font-weight: 800;
  letter-spacing: -0.03em;
  text-decoration: none;
  font-size: 1.1rem;
  color: var(--ink);
}

.nav-links,
[data-nav-auth] {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links a,
[data-nav-auth] a {
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-2);
  transition: background 0.15s;
}

.nav-links a:hover,
[data-nav-auth] a:hover { background: var(--line); }

.hero {
  width: min(1140px, calc(100% - 32px));
  margin: 0 auto;
  padding: 72px 0 80px;
}

.eyebrow {
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.76rem;
  margin: 0 0 14px;
}

h1 {
  max-width: 720px;
  font-size: clamp(2.4rem, 7vw, 5.5rem);
  font-family: ui-serif, Georgia, serif;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin: 0 0 20px;
}

.lead {
  max-width: 600px;
  font-size: 1.15rem;
  color: var(--ink-2);
  margin-bottom: 28px;
}

.button,
button {
  appearance: none;
  border: 1.5px solid var(--line-2);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  text-decoration: none;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}

.button.primary,
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.button.primary:hover,
button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 32px 0 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px 24px;
  box-shadow: 0 1px 3px rgb(0 0 0 / 4%), 0 6px 24px rgb(0 0 0 / 4%);
}

.card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 8px;
}

.card p {
  font-size: 0.93rem;
  color: var(--muted);
  margin: 0;
}

.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════
   DASHBOARD APP  (dashboard.html — body.dashboard-page)
═══════════════════════════════════════════════════════════════ */

/* ── Variables ── */
.dashboard-page {
  --d-bg: #0d1117;
  --d-surface: #161b22;
  --d-surface-2: #1c2230;
  --d-border: rgba(255 255 255 / 0.07);
  --d-border-2: rgba(255 255 255 / 0.12);
  --d-text: #e2e8f0;
  --d-text-2: #c9d1d9;
  --d-muted: #7d8590;
  --d-green: #3fb950;
  --d-green-bg: rgba(63 185 80 / 0.12);
  --d-red: #f85149;
  --d-red-bg: rgba(248 81 73 / 0.12);
  --d-accent: #238636;
  --d-accent-hover: #2ea043;
  --sidebar-w: 220px;
}

/* ── Reset for dark context ── */
.dashboard-page {
  height: 100dvh;
  overflow: hidden;
  background: var(--d-bg);
  color: var(--d-text);
  font-size: 14px;
}

/* ── Auth screens ── */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  background: var(--d-bg);
}

.auth-card {
  background: var(--d-surface);
  border: 1px solid var(--d-border-2);
  border-radius: 20px;
  padding: 40px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.auth-card h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--d-text);
  margin: 0 0 10px;
}

.auth-card p {
  color: var(--d-muted);
  margin: 0 0 24px;
  font-size: 0.92rem;
}

/* ── App shell ── */
.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ── Sidebar ── */
.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--d-surface);
  border-right: 1px solid var(--d-border);
  display: flex;
  flex-direction: column;
  padding: 16px 10px 20px;
  gap: 4px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 18px;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  color: var(--d-text);
  text-decoration: none;
  border-bottom: 1px solid var(--d-border);
  margin-bottom: 8px;
}

.sidebar-brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--d-green);
  box-shadow: 0 0 8px var(--d-green);
  animation: pulse 2.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--d-green); }
  50% { opacity: 0.6; box-shadow: 0 0 3px var(--d-green); }
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--d-muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: rgba(255 255 255 / 0.05);
  color: var(--d-text-2);
}

.nav-item.active {
  background: rgba(255 255 255 / 0.08);
  color: var(--d-text);
  font-weight: 600;
}

.nav-icon {
  font-size: 1rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--d-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-chip {
  font-size: 0.75rem;
  color: var(--d-muted);
  padding: 4px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Main area ── */
.app-main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Pipeline layout ── */
.pipeline-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.pipeline-streams {
  width: 44%;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--d-border);
  overflow: hidden;
}

.pipeline-agents {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.section-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--d-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.section-header h2 {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--d-muted);
}

.scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255 255 255 / 0.1) transparent;
}

/* ── Stream blocks ── */
.stream-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-content: flex-start;
}

@keyframes cascade {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.stream-block {
  --hue: 200;
  width: 172px;
  min-height: 168px;
  border-radius: 16px;
  padding: 16px 14px 12px;
  position: relative;
  display: flex;
  flex-direction: column;
  background: linear-gradient(
    120deg,
    hsl(var(--hue), 70%, 82%) 0%,
    hsl(calc(var(--hue) + 35), 65%, 90%) 35%,
    hsl(calc(var(--hue) + 70), 70%, 85%) 65%,
    hsl(calc(var(--hue) + 110), 60%, 80%) 100%
  );
  background-size: 300% 100%;
  animation: cascade 5s ease-in-out infinite;
  color: hsl(var(--hue), 40%, 18%);
  cursor: default;
  transition: transform 0.2s, box-shadow 0.2s;
  overflow: hidden;
}

.stream-block::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 50%, rgba(0,0,0,0.06) 100%);
  border-radius: inherit;
  pointer-events: none;
}

.stream-block:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 40px hsl(var(--hue), 60%, 50%, 0.35);
}

.stream-block.highlighted {
  transform: translateY(-3px);
  box-shadow:
    0 0 0 2.5px hsl(var(--hue), 70%, 48%),
    0 10px 40px hsl(var(--hue), 60%, 50%, 0.4);
}

.stream-name {
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.2;
  margin-bottom: 4px;
}

.stream-type-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(0 0 0 / 0.12);
  border-radius: 999px;
  padding: 2px 7px;
  display: inline-block;
  margin-bottom: 6px;
  align-self: flex-start;
}

.stream-desc {
  font-size: 0.75rem;
  opacity: 0.7;
  line-height: 1.4;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.stream-meta {
  font-size: 0.72rem;
  opacity: 0.65;
  margin-top: auto;
  padding-top: 6px;
}

.stream-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}

.stream-block:hover .stream-actions { opacity: 1; }

.stream-actions button {
  background: rgba(0 0 0 / 0.18);
  border: none;
  border-radius: 6px;
  color: inherit;
  padding: 3px 8px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.stream-actions button:hover { background: rgba(0 0 0 / 0.3); }
.stream-actions button.del { color: #b91c1c; }
.stream-actions button.del:hover { background: rgba(185 28 28 / 0.2); }

.stream-new {
  width: 172px;
  min-height: 168px;
  border-radius: 16px;
  border: 2px dashed rgba(255 255 255 / 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  color: rgba(255 255 255 / 0.28);
  font-size: 0.82rem;
  font-weight: 500;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.stream-new:hover {
  border-color: rgba(255 255 255 / 0.28);
  color: rgba(255 255 255 / 0.55);
  background: rgba(255 255 255 / 0.03);
}

.new-plus {
  font-size: 1.6rem;
  font-weight: 300;
  line-height: 1;
}

/* ── Agent cards ── */
.agent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agent-card {
  background: var(--d-surface);
  border: 1px solid var(--d-border);
  border-left: 3px solid hsl(var(--primary-hue, 210), 55%, 50%);
  border-radius: 12px;
  padding: 14px 16px;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.agent-card:hover {
  box-shadow: 0 4px 20px rgba(0 0 0 / 0.4);
  border-color: var(--d-border-2);
}

.agent-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}

.agent-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--d-text);
  margin: 0;
  letter-spacing: -0.01em;
}

.agent-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.agent-badge.active {
  background: var(--d-green-bg);
  color: var(--d-green);
}

.agent-badge.inactive {
  background: rgba(125 133 144 / 0.15);
  color: var(--d-muted);
}

.agent-instructions {
  font-size: 0.8rem;
  color: var(--d-muted);
  margin: 0 0 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

.stream-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.stream-chip {
  --hue: 200;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: hsl(var(--hue), 55%, 18%);
  color: hsl(var(--hue), 75%, 75%);
  border: 1px solid hsl(var(--hue), 45%, 30%);
}

.agent-meta {
  display: flex;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--d-muted);
  margin-bottom: 10px;
}

.agent-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--d-border);
}

.agent-new {
  background: transparent;
  border: 2px dashed rgba(255 255 255 / 0.1);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  cursor: pointer;
  color: rgba(255 255 255 / 0.28);
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.2s;
}

.agent-new:hover {
  border-color: rgba(255 255 255 / 0.25);
  color: rgba(255 255 255 / 0.55);
  background: rgba(255 255 255 / 0.02);
}

/* ── Dark buttons ── */
.app-btn {
  appearance: none;
  border: 1px solid var(--d-border-2);
  border-radius: 7px;
  background: rgba(255 255 255 / 0.06);
  color: var(--d-text-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.app-btn:hover {
  background: rgba(255 255 255 / 0.1);
  border-color: rgba(255 255 255 / 0.2);
  color: var(--d-text);
}

.app-btn.primary {
  background: var(--d-accent);
  border-color: var(--d-accent-hover);
  color: #fff;
}

.app-btn.primary:hover {
  background: var(--d-accent-hover);
}

.app-btn.danger {
  background: var(--d-red-bg);
  border-color: rgba(248 81 73 / 0.25);
  color: var(--d-red);
}

.app-btn.danger:hover {
  background: rgba(248 81 73 / 0.2);
  border-color: rgba(248 81 73 / 0.45);
}

/* ── Slide panel ── */
.panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0 0 0 / 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
}

.slide-panel {
  width: min(540px, 92vw);
  background: var(--d-surface);
  border-left: 1px solid var(--d-border-2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideIn 0.22s ease;
}

@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--d-border);
  flex-shrink: 0;
}

.panel-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--d-text);
}

.panel-close {
  background: transparent;
  border: none;
  color: var(--d-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.panel-close:hover {
  color: var(--d-text);
  background: rgba(255 255 255 / 0.07);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255 255 255 / 0.08) transparent;
}

.panel-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--d-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input {
  background: var(--d-bg);
  border: 1.5px solid var(--d-border-2);
  border-radius: 9px;
  color: var(--d-text);
  padding: 9px 12px;
  font: 14px/1.4 inherit;
  width: 100%;
  transition: border-color 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: rgba(63 185 80 / 0.5);
}

.form-input::placeholder { color: rgba(255 255 255 / 0.18); }

textarea.form-input {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
}

select.form-input { cursor: pointer; }

select[multiple].form-input {
  padding: 6px 8px;
  font-size: 13px;
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-row .form-field { flex: 1; }

.form-row .form-field.narrow { flex: 0 0 80px; }

.panel-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--d-border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ── Schema editor ── */
.schema-editor {
  border: 1.5px solid var(--d-border-2);
  border-radius: 10px;
  overflow: hidden;
}

.schema-table-head {
  display: grid;
  grid-template-columns: 1fr 100px 1fr 28px;
  padding: 7px 10px;
  background: rgba(255 255 255 / 0.04);
  border-bottom: 1px solid var(--d-border);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--d-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.schema-row {
  display: grid;
  grid-template-columns: 1fr 100px 1fr 28px;
  border-bottom: 1px solid var(--d-border);
  align-items: center;
}

.schema-row:last-child { border-bottom: none; }
.schema-row.locked { background: rgba(255 255 255 / 0.02); }

.schema-cell { padding: 5px 6px; }

.schema-input,
.schema-select {
  background: transparent;
  border: none;
  color: var(--d-text);
  font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  width: 100%;
  padding: 4px 5px;
  border-radius: 5px;
  transition: background 0.12s;
}

.schema-input:focus,
.schema-select:focus {
  outline: 2px solid rgba(63 185 80 / 0.45);
  background: rgba(255 255 255 / 0.04);
}

.schema-input:disabled {
  color: var(--d-muted);
  cursor: not-allowed;
}

.schema-select { cursor: pointer; }

.schema-select option { background: #1c2230; }

.schema-lock-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--d-green);
  font-size: 0.75rem;
  opacity: 0.7;
}

.schema-del-btn {
  background: transparent;
  border: none;
  color: rgba(248 81 73 / 0.5);
  cursor: pointer;
  font-size: 0.95rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  transition: color 0.15s, background 0.15s;
}

.schema-del-btn:hover {
  color: var(--d-red);
  background: var(--d-red-bg);
}

.schema-add-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  background: transparent;
  border: none;
  border-top: 1px solid var(--d-border);
  color: var(--d-green);
  font: 12.5px/1 inherit;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}

.schema-add-btn:hover { background: rgba(63 185 80 / 0.06); }

/* ── List views (flags, insights, executions) ── */
.list-view {
  padding: 26px 30px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255 255 255 / 0.08) transparent;
}

.list-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--d-border);
}

.list-view-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--d-text);
}

.ds-item {
  background: var(--d-surface);
  border: 1px solid var(--d-border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 8px;
}

.ds-item h3 {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--d-text);
  margin: 0 0 4px;
}

.ds-item-meta {
  font-size: 0.75rem;
  color: var(--d-muted);
  margin-bottom: 8px;
}

.ds-item pre {
  background: var(--d-bg);
  color: var(--d-muted);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11.5px;
  overflow: auto;
  margin: 0;
  scrollbar-width: thin;
}

.ds-empty {
  color: rgba(255 255 255 / 0.2);
  font-size: 0.85rem;
  font-style: italic;
  padding: 12px 0;
}

.app-error {
  background: var(--d-red-bg);
  border: 1px solid rgba(248 81 73 / 0.25);
  border-radius: 9px;
  color: var(--d-red);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 10px 14px;
  margin-bottom: 12px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .pipeline-streams { width: 100%; border-right: none; border-bottom: 1px solid var(--d-border); }
  .pipeline-layout { flex-direction: column; }
  .grid { grid-template-columns: 1fr; }
}
