/* fieldbase — Dashboard Styles */
:root {
  --bg: #080c18;
  --bg-card: #0f1422;
  --bg-card2: #0c1020;
  --bg-sidebar: #0b1020;
  --border: rgba(255,255,255,0.06);
  --border-active: rgba(255,255,255,0.12);
  --text: rgba(255,255,255,0.88);
  --text-muted: rgba(255,255,255,0.45);
  --accent: #7c5cfc;
  --accent-pale: rgba(124,92,252,0.12);
  --lime: #a3ff57;
  --lime-pale: rgba(163,255,87,0.1);
  --gold: #e8a020;
  --gold-pale: rgba(232,160,32,0.12);
  --blue: #3b82f6;
  --blue-pale: rgba(59,130,246,0.12);
  --purple: #a78bfa;
  --purple-pale: rgba(167,139,250,0.12);
  --green: #10b981;
  --green-pale: rgba(16,185,129,0.12);
  --orange: #f59e0b;
  --cyan: #22d3ee;
  --red: #ef4444;
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 220px;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── SIDEBAR ─────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.sidebar-logo .logo-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--accent), var(--lime));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.sidebar-logo .logo-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active { background: var(--accent-pale); color: var(--accent); }
.nav-icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-status {
  padding: 10px 10px 0;
  border-top: 1px solid var(--border);
}

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
}

.status-dot {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 9px 12px;
  color: var(--text-muted);
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.dot.live { background: var(--green); box-shadow: 0 0 6px var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

/* ── APP SHELL ────────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.app-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}

/* ── MAIN CONTENT ─────────────────────────────────────────────────────────── */
.main {
  max-width: 1140px;
  margin: 0 auto;
  padding: 28px 24px;
}

/* ── SECTION LABEL ────────────────────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ── AGENT CARDS ──────────────────────────────────────────────────────────── */
.crew-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s;
  position: relative;
  overflow: hidden;
}
.agent-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  border-radius: var(--radius) var(--radius) 0 0;
}
#card-scout::before { background: var(--blue); }
#card-piper::before { background: var(--accent); }
#card-mira::before  { background: var(--gold); }
.agent-card.running { border-color: var(--border-active); }

.agent-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.agent-avatar {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.agent-avatar.scout { background: var(--blue-pale); }
.agent-avatar.piper { background: var(--accent-pale); }
.agent-avatar.mira  { background: var(--gold-pale); }

.agent-info { flex: 1; min-width: 0; }
.agent-name { font-size: 15px; font-weight: 700; color: var(--text); }
.agent-status {
  font-size: 11px; font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px;
}
.agent-status.running { color: var(--green); }

.agent-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat-box { text-align: center; }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin-top: 3px; }
.stat-value.active { color: var(--green); }
.stat-value.wait   { color: var(--orange); }
.stat-value.done   { color: var(--cyan); }
.stat-value.fail   { color: var(--red); }

/* ── BOTTOM PANELS ────────────────────────────────────────────────────────── */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
}

/* ── ACTIVITY FEED ────────────────────────────────────────────────────────── */
.activity-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-height: 320px; max-height: 480px;
  display: flex; flex-direction: column;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.panel-title { font-size: 14px; font-weight: 600; }
.activity-list {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 0;
}
.activity-list::-webkit-scrollbar { width: 4px; }
.activity-list::-webkit-scrollbar-track { background: transparent; }
.activity-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

.activity-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from{opacity:0;transform:translateY(-4px)} to{opacity:1;transform:translateY(0)} }
.activity-icon { font-size: 13px; margin-top: 1px; flex-shrink: 0; }
.activity-text { font-size: 13px; color: var(--text-muted); flex: 1; line-height: 1.4; }
.activity-text strong { color: var(--text); font-weight: 500; }
.activity-time { font-size: 11px; color: rgba(255,255,255,0.2); flex-shrink: 0; margin-top: 2px; }
.activity-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 40px 0; }

/* ── DEPLOY PANEL ─────────────────────────────────────────────────────────── */
.deploy-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.deploy-panel h3 { font-size: 14px; font-weight: 600; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }

.city-select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: 13px;
  padding: 8px 10px; width: 100%; height: 130px;
  cursor: pointer; outline: none;
}
.city-select:focus { border-color: var(--border-active); }
.city-select option { padding: 4px; }
.city-hint { font-size: 11px; color: var(--text-muted); }

.niche-options { display: flex; flex-direction: column; gap: 8px; }
.niche-option {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: border-color 0.15s; font-size: 13px;
}
.niche-option:hover { border-color: var(--border-active); }
.niche-option input[type=checkbox] { accent-color: var(--accent); width: 14px; height: 14px; }

.tier-options { display: flex; gap: 10px; }
.tier-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  background: var(--surface2, #1a1a2e);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
  font-family: inherit;
}
.tier-btn:hover:not(:disabled) { border-color: var(--border-active); }
.tier-btn.active { border-color: var(--accent); background: rgba(124,92,252,0.1); }
.tier-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.tier-btn-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}
.tier-btn.active .tier-btn-label { color: var(--accent); }
.tier-btn-sub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
  line-height: 1.4;
}

.btn-launch {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 100%);
  color: white; font-size: 14px; font-weight: 700;
  letter-spacing: 0.04em; padding: 13px 20px;
  border-radius: var(--radius-sm); border: none;
  cursor: pointer; transition: opacity 0.2s, transform 0.15s; margin-top: 4px;
}
.btn-launch:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
.btn-launch:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-launch.running { animation: launch-pulse 1.5s infinite; }
@keyframes launch-pulse { 0%,100%{opacity:1} 50%{opacity:0.65} }

.stats-bar {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; padding-top: 12px; border-top: 1px solid var(--border);
}
.stats-bar-item { text-align: center; }
.stats-bar-val { font-size: 20px; font-weight: 700; color: var(--lime); }
.stats-bar-label { font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin-top: 2px; }

/* ── TOAST ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--bg-card); border: 1px solid var(--border-active);
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-size: 13px; max-width: 320px; z-index: 300;
  animation: slideUp 0.3s ease; display: none;
}
.toast.show { display: block; }
@keyframes slideUp { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

/* ── KANBAN ───────────────────────────────────────────────────────────────── */
.view-toggle { display: flex; gap: 4px; margin-bottom: 16px; }
.view-btn {
  padding: 6px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: transparent;
  color: var(--text-muted); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.view-btn:hover { border-color: var(--border-active); color: var(--text); }
.view-btn.active { background: var(--accent); border-color: var(--accent); color: white; }

.kanban-board {
  display: flex; gap: 12px;
  overflow-x: auto; padding-bottom: 16px;
  align-items: flex-start; min-height: 400px;
}
.kanban-board::-webkit-scrollbar { height: 6px; }
.kanban-board::-webkit-scrollbar-track { background: transparent; }
.kanban-board::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

.kanban-col {
  flex: 0 0 230px; min-width: 230px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column;
  max-height: calc(100vh - 220px);
}
.kanban-col-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
}
.kanban-col-title { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.kanban-col-count {
  font-size: 11px; font-weight: 700;
  background: rgba(255,255,255,0.07); color: var(--text-muted);
  border-radius: 10px; padding: 1px 7px;
}
.kanban-col-body {
  flex: 1; overflow-y: auto; padding: 6px;
  display: flex; flex-direction: column; gap: 6px;
  border-radius: 0 0 var(--radius) var(--radius);
  min-height: 60px; transition: background 0.15s; position: relative;
}
.kanban-col-body::-webkit-scrollbar { width: 4px; }
.kanban-col-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 2px; }
.kanban-col-body.drag-over { background: rgba(124,92,252,0.08); border: 1px dashed rgba(124,92,252,0.4); border-radius: 0 0 var(--radius) var(--radius); }

.kanban-card {
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 12px;
  cursor: grab; transition: border-color 0.15s, transform 0.12s, opacity 0.15s;
  user-select: none;
}
.kanban-card:hover { border-color: var(--border-active); transform: translateY(-1px); }
.kanban-card.dragging { opacity: 0.35; cursor: grabbing; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; margin-bottom: 3px; }
.card-name { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.3; }
.card-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.card-rating { font-size: 11px; color: var(--text-muted); margin-bottom: 5px; }
.card-demo { display: inline-flex; align-items: center; gap: 3px; color: var(--cyan); font-size: 11px; text-decoration: none; padding: 2px 6px; border: 1px solid rgba(34,211,238,0.2); border-radius: 4px; margin-top: 2px; }
.card-demo:hover { border-color: var(--cyan); }
.card-note { font-size: 11px; color: var(--text-muted); font-style: italic; border-top: 1px solid var(--border); padding-top: 6px; margin-top: 6px; }

.kanban-drop-hint {
  text-align: center; padding: 20px 12px;
  font-size: 12px; color: rgba(255,255,255,0.15);
  border: 2px dashed rgba(255,255,255,0.08); border-radius: var(--radius-sm);
  display: none;
}
.kanban-col-body.drag-over .kanban-drop-hint { display: block; }

/* ── PIPELINE KPI STRIP ───────────────────────────────────────────────────── */
.pipeline-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}
.pipeline-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.15s;
}
.pipeline-kpi:hover { border-color: var(--border-active); }
.kpi-icon { font-size: 22px; line-height: 1; flex-shrink: 0; }
.kpi-val {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.02em;
}
.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-top: 3px;
}
/* Won = lime, Win rate = lime */
#kpi-won .kpi-val, #kpi-winrate .kpi-val { color: var(--lime); }
/* In Motion = accent purple */
#kpi-in-motion .kpi-val { color: var(--accent); }
/* Demo Sent = cyan */
#kpi-demo-sent .kpi-val { color: var(--cyan); }
/* In Talks = orange */
#kpi-in-talks .kpi-val { color: var(--orange); }
/* Lost = red */
#kpi-lost .kpi-val { color: var(--red); }

@media (max-width: 1100px) {
  .pipeline-strip { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
  .pipeline-strip { grid-template-columns: repeat(2, 1fr); }
}

/* ── CLOSE NOTE MODAL ─────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  z-index: 200; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border-active);
  border-radius: var(--radius); padding: 24px; width: 380px; max-width: 90vw;
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.modal-textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 13px; padding: 10px 12px; outline: none;
  resize: vertical; min-height: 72px; font-family: inherit; display: block;
}
.modal-textarea:focus { border-color: var(--border-active); }
.modal-footer { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }
.modal-btn-cancel {
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: transparent;
  color: var(--text-muted); font-size: 13px; cursor: pointer;
}
.modal-btn-cancel:hover { border-color: var(--border-active); color: var(--text); }
.modal-btn-confirm {
  padding: 8px 20px; border-radius: var(--radius-sm);
  border: none; background: var(--accent); color: white;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.modal-btn-confirm:hover { opacity: 0.85; }

/* ── DRAWER PIPELINE SECTION ──────────────────────────────────────────────── */
.btn-save-stage {
  width: 100%; margin-top: 10px; padding: 8px;
  background: var(--accent); color: white; border: none;
  border-radius: var(--radius-sm); font-size: 13px;
  font-weight: 600; cursor: pointer;
}
.btn-save-stage:hover { opacity: 0.85; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .app-main { margin-left: 0; }
  .crew-grid { grid-template-columns: 1fr; }
  .bottom-grid { grid-template-columns: 1fr; }
}
