:root {
  --bg-base: #0a0c10;
  --bg-body: #0f1219;
  --bg-glass: rgba(15, 18, 25, 0.65);
  --bg-glass-hover: rgba(25, 30, 40, 0.8);
  
  --primary: #00e5ff;
  --primary-glow: rgba(0, 229, 255, 0.4);
  --secondary: #7000ff;
  --secondary-glow: rgba(112, 0, 255, 0.4);
  --accent: #ff0055;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.15);
  --border-primary: rgba(0, 229, 255, 0.3);
  
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --shadow-glow: 0 0 20px rgba(0, 229, 255, 0.25);
  
  --history-panel-height: clamp(300px, 45vh, 360px);
  --font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-family);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Base view toggling */
.view-hidden { display: none !important; }
.view-active { display: block; animation: fadeIn 0.5s ease-out forwards; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUpFade {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   Utility Classes
   ========================================= */
.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-glass);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-lift:hover {
  transform: translateY(-5px);
  border-color: var(--border-light);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), var(--shadow-glow);
}

.hover-glow:hover {
  box-shadow: var(--shadow-glow);
  border-color: var(--border-primary);
}

.text-gradient {
  background: linear-gradient(135deg, var(--primary), #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* =========================================
   Buttons
   ========================================= */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.95rem;
}

.button--primary {
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.button--ghost {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-main);
}

.button--outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}

.button--outline:hover, .button--ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-light);
}

.button--glow:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.button--large {
  padding: 14px 28px;
  font-size: 1.1rem;
}

.button--full {
  width: 100%;
}

/* =========================================
   LANDING PAGE
   ========================================= */
.navbar {
  position: fixed;
  top: 0; left: 0; width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 48px;
  z-index: 100;
  transition: all 0.3s ease;
}

.navbar.scrolled {
  background: rgba(10, 12, 16, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 12px 48px;
}

.nav-brand img { height: 36px; }
.nav-links {
  display: flex; gap: 32px; list-style: none; margin: 0; padding: 0;
}
.nav-links a { color: var(--text-main); font-weight: 500; font-size: 0.95rem; }
.nav-links a:hover { color: var(--primary); }

.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 120px 20px 80px;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: 
    radial-gradient(circle at 20% 30%, rgba(112, 0, 255, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(0, 229, 255, 0.1) 0%, transparent 40%);
  z-index: -1;
}

.hero-content {
  max-width: 900px;
  animation: slideUpFade 0.8s ease-out forwards;
}

.badge {
  display: inline-block;
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid rgba(0, 229, 255, 0.2);
  color: var(--primary);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 24px;
  letter-spacing: 1px;
}

.hero-title {
  font-size: clamp(2.5rem, 5vw, 4.5rem);
  line-height: 1.1;
  margin-bottom: 24px;
  letter-spacing: -1px;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 700px;
  margin: 0 auto 40px;
}

.hero-buttons {
  display: flex; justify-content: center; gap: 16px;
}

.section {
  padding: 100px 5%;
  max-width: 1400px; margin: 0 auto;
}

.dark-section {
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  max-width: none;
}

.section-header { text-align: center; margin-bottom: 60px; }
.section-header h2 { font-size: 2.5rem; margin-bottom: 16px; }

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 24px;
}

.three-cols { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.feature-card { padding: 32px 24px; text-align: center; }
.feature-icon {
  font-size: 2.5rem; margin-bottom: 20px; display: inline-block;
}
.icon-glow-blue { text-shadow: 0 0 20px rgba(0,102,255,0.6); }
.icon-glow-purple { text-shadow: 0 0 20px rgba(112,0,255,0.6); }
.icon-glow-pink { text-shadow: 0 0 20px rgba(255,0,85,0.6); }
.icon-glow-cyan { text-shadow: 0 0 20px rgba(0,229,255,0.6); }

.split-section {
  display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: center; max-width: 1400px; margin: 0 auto;
}
.split-content h3 { font-size: 2rem; margin-bottom: 20px; }
.styled-list { list-style: none; padding: 0; margin-top: 24px; }
.styled-list li {
  position: relative; padding-left: 28px; margin-bottom: 12px; color: var(--text-main);
}
.styled-list li::before {
  content: '✓'; position: absolute; left: 0; top: 0; color: var(--primary); font-weight: bold;
}
.split-image { overflow: hidden; position: relative; aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center; }
.split-image img { width: 100%; height: 100%; object-fit: cover; }
.image-fallback { position: absolute; color: var(--border-light); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; text-align: center; }
.stat-item { padding: 40px 20px; }
.stat-number { font-size: 3.5rem; font-weight: 700; margin-bottom: 8px; line-height: 1; }

.contact-grid { display: grid; grid-template-columns: 1fr 1.5fr; gap: 40px; }
.contact-info { display: flex; flex-direction: column; gap: 24px; }
.contact-info-item { padding: 32px; }
.contact-detail { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--text-main); }
.contact-form-container { padding: 40px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }

.footer { border-top: 1px solid var(--border); padding: 40px 20px; text-align: center; margin-top: 60px; }
.footer-icp { font-size: 0.85rem; margin-top: 8px; }

/* =========================================
   APP CONTAINER
   ========================================= */
#app-container { height: 100vh; overflow: hidden; background: var(--bg-body); }

.layout {
  height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}
.layout.is-locked { display: none; }

/* Auth Overlay */
.auth {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 12, 16, 0.8); backdrop-filter: blur(20px);
}
.auth.is-hidden { display: none; }
.auth__card { width: 100%; max-width: 420px; padding: 40px; text-align: center; }
.logo-wrapper { width: 64px; height: 64px; margin: 0 auto 16px; background: rgba(0, 229, 255, 0.1); border-radius: 16px; padding: 12px; border: 1px solid var(--border-primary); }
.logo-wrapper-small { width: 40px; height: 40px; background: rgba(0, 229, 255, 0.1); border-radius: 10px; padding: 6px; border: 1px solid var(--border-primary); }
.logo-wrapper img, .logo-wrapper-small img { width: 100%; height: 100%; object-fit: contain; }
.auth__brand h1 { font-size: 2rem; margin-bottom: 4px; }
.auth__form { margin-top: 32px; text-align: left; }
.auth__error { color: var(--accent); font-size: 0.85rem; margin-top: 12px; text-align: center; height: 20px; }

/* Sidebar */
.sidebar {
  padding: 32px 24px;
  display: flex; flex-direction: column; gap: 32px;
  border-right: 1px solid var(--border);
  border-radius: 0;
  background: rgba(15, 18, 25, 0.5);
}
.brand { display: flex; align-items: center; gap: 16px; text-decoration: none; }
.brand__name { font-size: 1.4rem; font-weight: 700; line-height: 1.1; display: block; }
.brand__tagline { font-size: 0.75rem; color: var(--text-muted); }

.nav { display: flex; flex-direction: column; gap: 8px; }
.nav__item {
  display: flex; align-items: center; gap: 12px;
  background: transparent; border: none;
  padding: 12px 16px; border-radius: 12px;
  color: var(--text-muted); font-size: 1rem; font-weight: 500;
  cursor: pointer; transition: all 0.3s;
}
.nav__item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text-main); }
.nav__item.is-active {
  background: rgba(0, 229, 255, 0.1); color: var(--primary);
  border: 1px solid rgba(0, 229, 255, 0.2); box-shadow: inset 0 0 10px rgba(0, 229, 255, 0.05);
}

.sidebar__footer { margin-top: auto; }
.sidebar__status { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 16px; padding: 8px 12px; background: rgba(0,0,0,0.2); border-radius: 8px; }
.status-dot { width: 8px; height: 8px; background: #10b981; border-radius: 50%; box-shadow: 0 0 8px #10b981; }
.sidebar__actions { display: grid; gap: 12px; }
.sidebar__action { width: 100%; padding: 10px; border-radius: 8px; text-align: center; border: 1px solid var(--border); background: rgba(255,255,255,0.05); cursor: pointer; color: var(--text-main); transition: 0.3s; }
.sidebar__action:hover { background: rgba(255,255,255,0.1); }
.sidebar__action--accent { border-color: rgba(255,0,85,0.3); color: var(--accent); }
.sidebar__action--accent:hover { background: rgba(255,0,85,0.1); box-shadow: 0 0 15px rgba(255,0,85,0.2); }

/* Main Area */
.main { padding: 40px; overflow-y: auto; height: 100vh; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.main::-webkit-scrollbar { width: 6px; }
.main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.panel { display: none; flex-direction: column; gap: 24px; animation: slideUpFade 0.4s ease-out forwards; }
.panel.is-visible { display: flex; }
.panel__header h1 { font-size: 2.2rem; margin-bottom: 8px; letter-spacing: -0.5px; }

/* Form Elements */
.input-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.input-group label { font-size: 0.9rem; color: var(--text-muted); font-weight: 500; }
input[type="text"], input[type="password"], input[type="email"], input[type="number"], textarea, select {
  width: 100%; padding: 12px 16px; border-radius: 8px;
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--border);
  color: var(--text-main); font-family: inherit; transition: all 0.3s; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.1); }
.select-wrapper { position: relative; }
.select-wrapper::after { content: '▼'; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 0.8rem; color: var(--text-muted); pointer-events: none; }
select { appearance: none; -webkit-appearance: none; padding-right: 40px; }

/* Filters Grid */
.filters__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; align-items: end; margin-top: 16px; }
.range { display: flex; align-items: center; gap: 8px; }
.range input { padding: 8px 12px; }
.range-sep { color: var(--text-muted); }

/* Database View */
.database { display: grid; gap: 24px; grid-template-columns: 1fr; align-items: start; }
.database--with-detail { grid-template-columns: 1.2fr 0.8fr; }
.database__list { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.list-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; }

.glass-tabs { display: flex; background: rgba(0,0,0,0.3); border-radius: 8px; padding: 4px; border: 1px solid var(--border); }
.glass-tabs .tab { background: transparent; border: none; color: var(--text-muted); padding: 8px 16px; border-radius: 6px; cursor: pointer; transition: 0.3s; font-weight: 500; }
.glass-tabs .tab:hover { color: var(--text-main); }
.glass-tabs .tab.is-active { background: rgba(0, 229, 255, 0.15); color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,0.2); }

.list-view { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: rgba(0,0,0,0.1); }
.list-view__header { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1.5fr; padding: 16px; background: rgba(0,0,0,0.3); font-size: 0.85rem; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.list-view__row { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1.5fr; padding: 16px; border: none; background: transparent; border-bottom: 1px solid var(--border); cursor: pointer; text-align: left; color: var(--text-main); transition: 0.2s; width: 100%; align-items: center; }
.list-view__row:last-child { border-bottom: none; }
.list-view__row:hover { background: rgba(255,255,255,0.03); }
.list-view__row.is-active { background: rgba(0, 229, 255, 0.08); border-left: 3px solid var(--primary); }
.list-view__title { font-weight: 600; color: var(--primary); display: block; }
.list-view__meta, .list-view__cell--feature { font-size: 0.85rem; color: var(--text-muted); }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 8px; }
.page-btn { display: flex; align-items: center; justify-content: center; background: transparent; border: none; color: var(--text-muted); width: 28px; height: 28px; border-radius: 4px; cursor: pointer; transition: 0.2s; }
.page-btn:hover:not(:disabled) { background: rgba(255,255,255,0.1); color: var(--text-main); }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination__status { font-size: 0.85rem; padding: 0 8px; }

/* Detail Card */
.detail-card { padding: 24px; position: sticky; top: 0; }
.detail__header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.detail__title { font-size: 1.5rem; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.tag { background: rgba(0, 229, 255, 0.1); border: 1px solid rgba(0, 229, 255, 0.2); color: var(--primary); padding: 4px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.detail__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; margin-bottom: 24px; }
.metric { background: rgba(0,0,0,0.3); border: 1px solid var(--border); padding: 16px 12px; border-radius: 12px; text-align: center; }
.metric__label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.metric__value { font-size: 1.1rem; font-weight: 700; color: var(--text-main); }
.chart-wrapper { background: rgba(0,0,0,0.3); border: 1px solid var(--border); border-radius: 12px; padding: 16px; height: 250px; margin-bottom: 16px; }
.detail__footer { font-size: 0.9rem; color: var(--text-muted); background: rgba(0, 229, 255, 0.05); padding: 16px; border-radius: 12px; border: 1px solid rgba(0,229,255,0.1); }

/* History & Forms */
.form { padding: 24px; }
.form-title { margin-bottom: 20px; font-size: 1.2rem; }
.history-card { padding: 24px; display: flex; flex-direction: column; height: var(--history-panel-height); }
.history-card h3 { margin-bottom: 16px; font-size: 1.1rem; }
.history-list-container { flex: 1; overflow-y: auto; padding-right: 8px; }
.history-list-container::-webkit-scrollbar { width: 4px; }
.history-list-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }
.history-entry { background: rgba(0,0,0,0.3); border: 1px solid var(--border); padding: 12px 16px; border-radius: 8px; cursor: pointer; transition: 0.2s; margin-bottom: 12px; }
.history-entry:hover { border-color: var(--border-light); background: rgba(255,255,255,0.05); }
.history-entry.is-active { border-color: var(--primary); background: rgba(0,229,255,0.05); }
.history-entry__title { font-weight: 600; color: var(--primary); font-size: 0.95rem; margin-bottom: 4px; }

/* Recommendations */
.recommendations__list { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-top: 20px; }
.recommendation { background: rgba(0,0,0,0.3); border: 1px solid var(--border); padding: 20px; border-radius: 12px; cursor: pointer; text-align: left; transition: 0.3s; }
.recommendation:hover { background: rgba(255,255,255,0.05); border-color: var(--primary-glow); transform: translateY(-3px); }
.recommendation.is-active { border-color: var(--primary); box-shadow: 0 0 15px rgba(0,229,255,0.15); background: rgba(0,229,255,0.05); }
.mt-3 { margin-top: 24px; }

/* Responsive Adjustments */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 240px 1fr; }
  .split-section { grid-template-columns: 1fr; text-align: center; }
  .split-content .styled-list { text-align: left; display: inline-block; }
  .stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .database--with-detail { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .hero-title { font-size: 2.5rem; }
  .contact-grid { grid-template-columns: 1fr; }
}