:root {
  --bg:       #0f0f10;
  --surface:  #18181b;
  --surface2: #1f1f24;
  --surface3: #26262c;
  --border:   rgba(255,255,255,0.07);
  --border2:  rgba(255,255,255,0.12);
  --text:     #f0eff2;
  --muted:    #7a7880;

  --font: 'DM Sans', sans-serif;
  --mono: 'DM Mono', monospace;

  --c-green:  #22c97a;
  --c-blue:   #4fa3e8;
  --c-purple: #b97cf3;
  --c-amber:  #e8a84f;
  --c-red:    #e86060;
  --c-teal:   #4fe8c9;

  --c0: #22c97a;
  --accent-green:  #22c97a;
  --accent-blue:   #4fa3e8;
  --accent-purple: #b97cf3;
  --accent-amber:  #e8a84f;
  --accent-red:    #e86060;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* Navbar */
.navbar {
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  height: 48px;
}

.navbar-brand {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-right: 2rem;
  white-space: nowrap;
}

.navbar-brand span { color: var(--c-green); }

.nav-link {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--muted);
  padding: 0 14px;
  height: 48px;
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  text-decoration: none;
  transition: color 0.12s;
  white-space: nowrap;
}

.nav-link:hover { color: var(--text); }

.nav-link.active {
  color: var(--text);
  border-bottom-color: var(--c-green);
}

/* Page header */
header {
  padding: 1rem 2rem;
  border-bottom: 0.5px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

header h1 {
  font-size: 20px;
  font-weight: 300;
  letter-spacing: -0.02em;
}

.header-sub {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}

.header-btns {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Buttons */
.btn {
  font-size: 11px;
  font-family: var(--mono);
  padding: 5px 12px;
  border-radius: 6px;
  border: 0.5px solid var(--border2);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:hover {
  color: var(--text);
  border-color: rgba(255,255,255,0.2);
}

.btn.primary {
  background: rgba(34,201,122,0.1);
  color: var(--c-green);
  border-color: rgba(34,201,122,0.25);
}

.btn.primary:hover { background: rgba(34,201,122,0.18); }

.btn.danger {
  background: rgba(232,96,96,0.1);
  color: var(--c-red);
  border-color: rgba(232,96,96,0.25);
}

.btn.danger:hover { background: rgba(232,96,96,0.18); }

.btn.icon-btn { padding: 4px 8px; font-size: 13px; }

/* Two-column layout */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: calc(100vh - 110px);
}

.sidebar {
  border-right: 0.5px solid var(--border);
  padding: 1.25rem;
  overflow-y: auto;
}

.main {
  padding: 1.25rem;
  overflow: hidden;
}

/* Panels */
.panel {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
}

.panel-title {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin-bottom: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Metrics row */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.metric {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}

.metric-label {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 2px;
  font-family: var(--mono);
}

.metric-val {
  font-size: 20px;
  font-weight: 300;
  letter-spacing: -0.02em;
}

/* Chart cards */
.chart-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
}

.chart-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Legend */
.legend { display: flex; gap: 14px; flex-wrap: wrap; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--muted);
  cursor: pointer;
  transition: opacity 0.15s;
}

.legend-item.hidden { opacity: 0.35; }

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Forms */
.form-row { margin-bottom: 10px; }

.form-row label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.form-input {
  width: 100%;
  background: var(--surface2);
  border: 0.5px solid var(--border2);
  border-radius: 6px;
  color: var(--text);
  padding: 7px 10px;
  font-size: 12px;
  font-family: var(--mono);
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus { border-color: rgba(255,255,255,0.25); }

.form-row-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 0.5px solid var(--border2);
  border-radius: 14px;
  width: min(440px, 95vw);
  padding: 1.5rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.modal-header h2 { font-size: 16px; font-weight: 300; }

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}

.modal-close:hover { color: var(--text); background: var(--surface2); }

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 0.5px solid var(--border);
}

/* Tab bar */
.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border-radius: 7px;
  padding: 3px;
}

.tab {
  font-size: 10px;
  font-family: var(--mono);
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--muted);
  border: none;
  background: none;
  transition: background 0.12s, color 0.12s;
}

.tab.active { background: var(--surface); color: var(--text); }

/* Toast notification */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 0.5px solid var(--border2);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 200;
}

.toast.show { opacity: 1; }

/* Empty states */
.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  font-size: 13px;
}

.empty .big { font-size: 32px; margin-bottom: 0.5rem; }

.chart-empty-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  gap: 4px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* Accessibility: respect OS-level reduce-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* Responsive */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 0.5px solid var(--border); }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .navbar { padding: 0 1rem; }
  /*
   * On mobile the layout collapses to a single column and .main no longer
   * needs to contain a side-by-side chart area. Switching overflow to
   * visible (x) / auto (y) lets the .table-wrap horizontal scroll work
   * correctly without being clipped by the parent.
   */
  .main { overflow-x: visible; overflow-y: auto; }
}
