:root {
  /* MIDNIGHT PROFESSIONAL THEME */

  /* background and surfaces - slightly softened for a warmer, human feel */
  --bg-app: #0f1418; /* a touch lighter */
  --bg-panel: #14171b; /* softened panel */
  --bg-hover: rgba(255,255,255,0.02); /* subtle hover glow instead of harsh dark */
  --border: rgba(255,255,255,0.04);

  /* accent moved to a softer indigo with a warm glow */
  --accent: #6c63ff;
  --accent-glow: rgba(108, 99, 255, 0.14);

  --text-primary: #eaf2ff;
  --text-secondary: #98a3b3;

  --risk-high: #ff4757;
  --risk-med: #ffa502;
  --risk-low: #2ed573;

  --font-serif: 'Instrument Serif', serif;
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 12px;
  --card-shadow: 0 8px 24px rgba(2,6,23,0.6);
  --elev-shadow: 0 6px 18px rgba(2,6,23,0.45);
}

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

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-panel);
  border-right: 1px solid transparent;
  box-shadow: inset -1px 0 0 var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  gap: 0.5rem;
}

.brand {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: #fff;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-mark {
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, rgba(108,99,255,0.9), rgba(255,71,87,0.9));
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(108,99,255,0.12);
}

.nav-item {
  padding: 0.7rem 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 999px; /* pill-like */
  margin-bottom: 0.5rem;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-item:hover {
  background: var(--bg-hover);
  transform: translateY(-2px);
  color: #fff;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(108,99,255,0.12), rgba(108,99,255,0.06));
  color: var(--accent);
  box-shadow: var(--elev-shadow);
}

/* Main Content */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top right, rgba(26,31,41,0.6) 0%, transparent 40%);
  overflow-y: auto;
}

.topbar {
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 17, 21, 0.8);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.page-title {
  font-weight: 500;
  font-size: 0.95rem;
}

/* Views */
.view-section {
  padding: 2rem;
  display: none;
}

.view-section.active {
  display: block;
  animation: fadeUp 0.4s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Upload Hero */
.upload-hero {
  max-width: 600px;
  margin: 4rem auto;
  text-align: center;
}

.hero-head {
  font-family: var(--font-serif);
  font-size: 3rem;
  background: linear-gradient(to right, #fff, #a5b4fc);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  margin-bottom: 1rem;
}

.drop-zone {
  background: var(--bg-panel);
  border: 1px dashed rgba(255,255,255,0.04);
  border-radius: var(--radius);
  padding: 2.25rem;
  cursor: pointer;
  transition: transform 220ms ease, box-shadow 220ms ease, background 220ms ease;
  margin: 2rem 0;
  box-shadow: 0 8px 24px rgba(2,6,23,0.55);
}

.drop-zone:hover {
  border-color: rgba(108,99,255,0.9);
  background: linear-gradient(180deg, rgba(255,255,255,0.01), rgba(108,99,255,0.02));
  transform: translateY(-4px);
}

.btn-primary {
  background: linear-gradient(90deg, var(--accent), #9b8bff);
  color: #061126;
  border: none;
  padding: 0.95rem 1.75rem;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 30px var(--accent-glow);
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 120ms ease;
}

.btn-primary:active {
  transform: translateY(1px) scale(0.995);
}

.btn-primary:disabled {
  background: var(--bg-hover);
  color: var(--text-secondary);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 18px 40px rgba(108,99,255,0.12);
}

.btn-primary:focus-visible {
  outline: 3px solid rgba(108,99,255,0.18);
  outline-offset: 2px;
}

/* Dashboard Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid transparent;
  box-shadow: 0 8px 20px rgba(2,6,23,0.45);
}

.kpi-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 0.5rem;
}

.kpi-value {
  font-size: 2rem;
  font-family: var(--font-mono);
  font-weight: 600;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 1.5rem;
  height: 600px;
  margin-bottom: 1.5rem;
}

.panel-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.01), var(--bg-panel));
  border: 1px solid transparent;
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--card-shadow);
}

.panel-header {
  padding: 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.02);
  background: linear-gradient(180deg, rgba(255,255,255,0.01), rgba(255,255,255,0.00));
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  font-weight: 600;
  font-size: 0.9rem;
}

/* Graph */
#graphContainer {
  flex: 1;
  background: radial-gradient(circle at center, #1b2129 0%, #161b22 100%);
  position: relative;
}

.graph-toolbar {
  background: var(--bg-app);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  gap: 4px;
}

.tool-btn {
  background: rgba(255,255,255,0.02);
  border: none;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.tool-btn:hover {
  background: rgba(255,255,255,0.04);
  color: #fff;
  transform: translateY(-3px);
  box-shadow: 0 8px 18px rgba(2,6,23,0.45);
}

.tool-btn.active {
  color: var(--risk-high);
  background: rgba(255, 71, 87, 0.08);
  box-shadow: 0 6px 18px rgba(255,71,87,0.06) inset;
}

/* Tables & Lists */
.list-content {
  flex: 1;
  overflow-y: auto;
}

.list-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  cursor: pointer;
}

.list-item:hover {
  background: var(--bg-hover);
}

.risk-tag {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.high {
  color: var(--risk-high);
  background: rgba(255, 71, 87, 0.1);
}

.med {
  color: var(--risk-med);
  background: rgba(255, 165, 2, 0.1);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  text-align: left;
  padding: 12px 16px;
  color: var(--text-secondary);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

tr:hover {
  background: var(--bg-hover);
}

/* Tooltip */
.tooltip {
  position: absolute;
  position: absolute;
  background: linear-gradient(180deg, rgba(6,8,12,0.9), rgba(6,8,12,0.85));
  backdrop-filter: blur(8px) saturate(1.05);
  border: 1px solid rgba(255,255,255,0.03);
  padding: 12px;
  border-radius: 14px;
  pointer-events: none;
  z-index: 50;
  width: 260px;
  font-size: 0.9rem;
  display: none;
  box-shadow: 0 12px 36px rgba(2,6,23,0.6);
}

.tip-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  color: var(--text-secondary);
}

.tip-val {
  color: #fff;
  font-family: var(--font-mono);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  border-radius: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .sidebar {
    width: 220px;
    padding: 1rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .dashboard-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .panel-card {
    min-height: 220px;
  }

  .hero-head {
    font-size: 2.25rem;
  }

  .drop-zone {
    padding: 2rem;
  }

  #graphContainer {
    min-height: 300px;
  }
}

@media (max-width: 600px) {
  /* Stack the main layout vertically and make sidebar full width */
  body {
    flex-direction: column;
    min-height: 100vh;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 0.75rem 1rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .brand {
    font-size: 1.125rem;
    margin-bottom: 0;
  }

  .nav {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
    align-items: center;
  }

  .nav-item {
    padding: 0.5rem 0.6rem;
    font-size: 0.9rem;
  }

  .main {
    width: 100%;
  }

  .topbar {
    padding: 0.75rem 1rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .hero-head {
    font-size: 1.75rem;
    text-align: left;
  }

  .upload-hero {
    margin: 2rem 1rem;
    max-width: none;
    text-align: left;
  }

  .drop-zone {
    padding: 1.25rem;
  }

  .btn-primary {
    width: 100%;
    padding: 0.75rem;
  }

  table,
  th,
  td {
    font-size: 0.85rem;
  }

  .tooltip {
    width: 90vw;
    left: 5vw;
    right: 5vw;
  }

  .dashboard-layout .panel-card {
    margin-bottom: 1rem;
  }

  .graph-toolbar {
    position: absolute;
    top: 8px;
    right: 8px;
  }

  #graphContainer {
    min-height: 280px;
    height: auto;
  }
}