:root {
  --bg: #09090b;
  --bg-card: rgba(24, 24, 27, 0.7);
  --border: rgba(63, 63, 70, 0.4);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --green: #22c55e;
  --red: #ef4444;
  --radius: 12px;
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(139, 92, 246, 0.08), transparent 25%),
    radial-gradient(circle at 85% 30%, rgba(56, 189, 248, 0.08), transparent 25%);
}

/* Typography */
h1, h2, h3 { font-family: 'Outfit', sans-serif; }

/* Buttons */
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 0 15px rgba(139, 92, 246, 0.4); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.1); }

/* Login Screen */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 400px;
  box-shadow: var(--glass-shadow);
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 30px; }
.login-logo h1 { font-size: 24px; font-weight: 700; background: linear-gradient(to right, #a78bfa, #38bdf8); -webkit-background-clip: text; color: transparent; }
.login-logo span { font-size: 12px; color: var(--muted); }
.login-card label { display: block; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.login-card input {
  width: 100%;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: white;
  margin-bottom: 20px;
  font-family: 'JetBrains Mono', monospace;
  transition: all 0.2s;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button { width: 100%; }

/* App Header */
#app { display: none; flex-direction: column; min-height: 100vh; }
header {
  height: 60px;
  background: rgba(9, 9, 11, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-logo { display: flex; align-items: center; gap: 8px; font-weight: 700; cursor: pointer; }
.header-logo span { background: linear-gradient(to right, #a78bfa, #38bdf8); -webkit-background-clip: text; color: transparent; font-family: 'Outfit'; font-size: 18px; }
.breadcrumb { display: flex; gap: 8px; color: var(--muted); font-size: 14px; }
.btn-logout { background: transparent; border: none; color: var(--muted); cursor: pointer; }
.btn-logout:hover { color: var(--red); }
.badge-admin { background: rgba(139, 92, 246, 0.2); border: 1px solid rgba(139, 92, 246, 0.4); color: #a78bfa; padding: 2px 8px; border-radius: 12px; font-size: 12px; }

/* Main Content */
.main-content { padding: 40px; max-width: 1200px; margin: 0 auto; width: 100%; flex: 1; display: flex; flex-direction: column; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.section-title { font-size: 28px; }
.section-meta { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* Projects Grid */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.project-card:hover {
  transform: translateY(-4px);
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 10px 40px -10px rgba(139, 92, 246, 0.3);
}
.project-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, #a78bfa, #38bdf8); opacity: 0; transition: opacity 0.3s;
}
.project-card:hover::before { opacity: 1; }
.card-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; font-family: 'Outfit'; }
.card-hash { font-family: 'JetBrains Mono'; font-size: 12px; color: var(--muted); background: rgba(255,255,255,0.05); padding: 4px 8px; border-radius: 6px; display: inline-block; }
.card-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--green); margin-top: 16px; }
.dot { width: 8px; height: 8px; background: var(--green); border-radius: 50%; box-shadow: 0 0 10px var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Project Details View */
.project-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.project-title { font-size: 32px; background: linear-gradient(to right, #fff, #a1a1aa); -webkit-background-clip: text; color: transparent; }

/* Tabs */
.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab { padding: 10px 4px; color: var(--muted); cursor: pointer; font-weight: 500; border-bottom: 2px solid transparent; transition: all 0.2s; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { flex: 1; display: flex; flex-direction: column; }
.tab-pane { display: none; flex: 1; }
.tab-pane.active { display: block; }

/* Components Tab */
.components-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.component-card { background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.comp-type { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); margin-bottom: 8px; font-weight: 700; }
.comp-name { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.comp-port { font-family: 'JetBrains Mono'; font-size: 12px; color: var(--muted); }

/* Topology (Canvas) Tab */
.canvas-container {
  position: relative;
  height: 600px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background-image: radial-gradient(rgba(255,255,255,0.1) 1px, transparent 1px);
  background-size: 20px 20px;
  cursor: grab;
}
.canvas-container:active { cursor: grabbing; }
.canvas-controls { position: absolute; bottom: 20px; left: 20px; display: flex; gap: 8px; z-index: 10; }
.canvas-controls button { background: var(--bg-card); border: 1px solid var(--border); color: white; width: 32px; height: 32px; border-radius: 6px; cursor: pointer; font-weight: bold; }

/* Visual Nodes */
#nodes-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; transform-origin: 0 0; }
.v-node {
  position: absolute;
  width: 140px;
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  user-select: none;
  box-shadow: var(--glass-shadow);
  transition: box-shadow 0.2s, border-color 0.2s;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
}
.v-node:hover { border-color: var(--accent); box-shadow: 0 0 20px rgba(139, 92, 246, 0.4); }
.v-node-icon { font-size: 24px; width: 40px; height: 40px; background: rgba(255,255,255,0.05); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.v-node-name { font-size: 13px; font-weight: 600; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-node-status { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); position: absolute; top: -4px; right: -4px; }
.v-node-status.active { background: var(--green); box-shadow: 0 0 8px var(--green); }

/* Node Inspector */
.node-inspector {
  position: absolute; top: 0; right: -350px; width: 300px; height: 100%;
  background: var(--bg-card); border-left: 1px solid var(--border);
  backdrop-filter: blur(12px); padding: 20px; transition: right 0.3s ease; z-index: 20;
}
.node-inspector.open { right: 0; }
.inspector-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 20px; }
.inspector-header button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; }

/* Logs Terminal */
.terminal {
  background: #000; border: 1px solid var(--border); border-radius: var(--radius);
  height: 500px; padding: 16px; font-family: 'JetBrains Mono', monospace; font-size: 13px;
  overflow-y: auto; color: #a1a1aa;
}
.term-line { margin-bottom: 4px; }

/* File Browser */
.files-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 20px; }
.file-breadcrumbs { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.file-breadcrumbs .crumb-link { cursor: pointer; transition: color 0.2s; }
.file-breadcrumbs .crumb-link:hover { color: var(--accent); text-shadow: 0 0 8px rgba(139, 92, 246, 0.4); }
.file-breadcrumbs .crumb-active { color: white; font-weight: 600; }

.storage-widget { display: flex; flex-direction: column; width: 280px; }
.storage-info { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.storage-bar { height: 6px; background: rgba(0, 0, 0, 0.3); border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
.storage-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #38bdf8); box-shadow: 0 0 10px rgba(139, 92, 246, 0.6); border-radius: 4px; transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1); }

.file-table { background: rgba(255,255,255,0.02); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.file-table-header { display: grid; grid-template-columns: 1fr 120px 100px; padding: 14px 20px; border-bottom: 1px solid var(--border); font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; background: rgba(255,255,255,0.01); }
.file-row { display: grid; grid-template-columns: 1fr 120px 100px; padding: 14px 20px; border-bottom: 1px solid rgba(255,255,255,0.03); align-items: center; cursor: pointer; transition: all 0.2s; }
.file-row:hover { background: rgba(139, 92, 246, 0.05); border-left: 2px solid var(--accent); padding-left: 18px; }
.file-row:last-child { border-bottom: none; }
.file-name-cell { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.file-name-cell .file-icon { font-size: 16px; }
.file-row-parent { font-style: italic; color: var(--accent); }

/* File Viewer */
.file-viewer-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; backdrop-filter: blur(12px); box-shadow: var(--glass-shadow); }
.file-viewer-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,0.01); }
.file-viewer-title { display: flex; align-items: center; gap: 8px; }
.file-viewer-body { padding: 0; background: #070709; min-height: 300px; max-height: 600px; overflow: auto; border-top: 1px solid rgba(0, 0, 0, 0.5); }
.file-viewer-body::-webkit-scrollbar { width: 8px; height: 8px; }
.file-viewer-body::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
.file-viewer-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
.file-viewer-body::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

#viewer-code-block { margin: 0; padding: 20px; font-family: 'JetBrains Mono', monospace; font-size: 13px; line-height: 1.6; color: #d4d4d8; background: #070709; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
