/* ============================================================
   Heartbeat Stacker — Admin Dashboard (ops.css)
   Dark theme, neon accents — matches app design
   ============================================================ */

:root {
  --bg: #0A0A0F;
  --surface: #141420;
  --surface-light: #1E1E2E;
  --surface-hover: #252538;
  --text: #E8E8F0;
  --text-secondary: #9898AA;
  --text-muted: #5A5A6E;
  --neon-green: #00FF88;
  --neon-pink: #FF00AA;
  --neon-blue: #00AAFF;
  --gold: #FFD700;
  --red: #FF4466;
  --orange: #FF8844;
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-width: 220px;
  --topbar-height: 56px;
}

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

html { font-size: 14px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
}

a { color: var(--neon-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   Login Screen
   ============================================================ */

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
  letter-spacing: -0.5px;
}

.login-card h1 span { color: var(--neon-green); }

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.35rem;
}

.form-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--neon-green);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.login-error {
  color: var(--red);
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
  min-height: 1.2rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s, box-shadow 0.15s;
  text-decoration: none;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--neon-green);
  color: var(--bg);
  box-shadow: 0 0 16px rgba(0, 255, 136, 0.15);
}
.btn-primary:hover { box-shadow: 0 0 24px rgba(0, 255, 136, 0.25); }

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-secondary {
  background: var(--surface-light);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.4rem 0.65rem;
}
.btn-ghost:hover { color: var(--text); background: var(--surface-light); }

.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.75rem; }

.btn-full { width: 100%; }

.login-step { display: none; }
.login-step.active { display: block; }

/* ============================================================
   Dashboard Layout
   ============================================================ */

.dashboard { display: none; }
.dashboard.active { display: flex; min-height: 100vh; }

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

.sidebar-brand {
  padding: 1rem 1.25rem;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  border-bottom: 1px solid var(--surface-light);
}
.sidebar-brand span { color: var(--neon-green); }

.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.25rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.nav-item:hover {
  background: var(--surface-light);
  color: var(--text);
}

.nav-item.active {
  background: rgba(0, 255, 136, 0.06);
  color: var(--neon-green);
  font-weight: 700;
}

.nav-item .nav-icon { font-size: 1.1rem; width: 1.4rem; text-align: center; }

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--surface-light);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--surface-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.content-area {
  padding: 1.5rem;
  max-width: 1400px;
}

/* Sections */
.section { display: none; }
.section.active { display: block; }

/* ============================================================
   Stat Cards
   ============================================================ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius);
  padding: 1.1rem;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.stat-value.green { color: var(--neon-green); }
.stat-value.blue { color: var(--neon-blue); }
.stat-value.pink { color: var(--neon-pink); }
.stat-value.gold { color: var(--gold); }
.stat-value.red { color: var(--red); }

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* ============================================================
   Data Tables
   ============================================================ */

.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--surface-light);
}

.table-header h3 {
  font-size: 0.9rem;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--surface-light);
}

td {
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(30, 30, 46, 0.5);
  vertical-align: middle;
}

tr:hover td { background: rgba(255, 255, 255, 0.015); }

tr:last-child td { border-bottom: none; }

/* ============================================================
   Status Badges
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-open { background: rgba(0, 255, 136, 0.12); color: var(--neon-green); }
.badge-funding { background: rgba(0, 170, 255, 0.12); color: var(--neon-blue); }
.badge-closed { background: rgba(255, 215, 0, 0.12); color: var(--gold); }
.badge-paid { background: rgba(152, 152, 170, 0.12); color: var(--text-secondary); }

.badge-pending { background: rgba(255, 136, 68, 0.12); color: var(--orange); }
.badge-completed { background: rgba(0, 255, 136, 0.12); color: var(--neon-green); }
.badge-failed { background: rgba(255, 68, 102, 0.12); color: var(--red); }
.badge-requested { background: rgba(0, 170, 255, 0.12); color: var(--neon-blue); }

.badge-low { background: rgba(152, 152, 170, 0.12); color: var(--text-secondary); }
.badge-medium { background: rgba(255, 136, 68, 0.12); color: var(--orange); }
.badge-high { background: rgba(255, 68, 102, 0.12); color: var(--red); }
.badge-critical { background: rgba(255, 0, 170, 0.15); color: var(--neon-pink); }

/* ============================================================
   Funding Progress Bar
   ============================================================ */

.funding-bar {
  width: 100%;
  height: 6px;
  background: var(--surface-light);
  border-radius: 3px;
  overflow: hidden;
}

.funding-bar-fill {
  height: 100%;
  background: var(--neon-green);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.funding-bar-fill.near-complete {
  background: var(--neon-blue);
}

.funding-bar-fill.complete {
  background: var(--gold);
}

.funding-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ============================================================
   Modals
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(10px);
  transition: transform 0.2s;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal h2 {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* ============================================================
   Detail Panel (right-side slide-in)
   ============================================================ */

.detail-panel {
  position: fixed;
  top: 0;
  right: -500px;
  width: 480px;
  max-width: 90vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--surface-light);
  z-index: 60;
  overflow-y: auto;
  transition: right 0.25s ease;
  padding: 1.5rem;
}

.detail-panel.open { right: 0; }

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

.detail-panel-header h2 {
  font-size: 1.1rem;
  font-weight: 800;
}

.detail-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.25rem;
}
.detail-close:hover { color: var(--text); }

.detail-section {
  margin-bottom: 1.25rem;
}

.detail-section h3 {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.85rem;
}

.detail-row .label { color: var(--text-secondary); }
.detail-row .value { font-weight: 600; }

/* ============================================================
   SVG Chart
   ============================================================ */

.chart-container {
  background: var(--surface);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

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

.chart-header h3 {
  font-size: 0.9rem;
  font-weight: 700;
}

.chart-toggle {
  display: flex;
  gap: 0.35rem;
}

.chart-toggle button {
  padding: 0.25rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid var(--surface-light);
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}

.chart-toggle button.active {
  background: var(--neon-green);
  color: var(--bg);
  border-color: var(--neon-green);
}

.chart-svg {
  width: 100%;
  height: 200px;
}

/* ============================================================
   Live Feed
   ============================================================ */

.feed-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgba(30, 30, 46, 0.5);
  animation: fadeIn 0.3s ease;
}

.feed-item:last-child { border-bottom: none; }

.feed-item.new {
  background: rgba(0, 255, 136, 0.04);
}

.feed-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.feed-icon.score { background: rgba(0, 255, 136, 0.1); }
.feed-icon.flag { background: rgba(255, 68, 102, 0.1); }
.feed-icon.revenue { background: rgba(0, 170, 255, 0.1); }

.feed-text {
  flex: 1;
  font-size: 0.8rem;
}

.feed-text strong { font-weight: 700; }

.feed-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Search Bar
   ============================================================ */

.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-bar .form-input {
  flex: 1;
}

/* ============================================================
   Empty State
   ============================================================ */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 2rem; margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.85rem; }

/* ============================================================
   Loading Spinner
   ============================================================ */

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--surface-light);
  border-top-color: var(--neon-green);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ============================================================
   Toast Notifications
   ============================================================ */

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  min-width: 250px;
  max-width: 380px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.25s ease;
}

.toast.success { border-left: 3px solid var(--neon-green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--neon-blue); }

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

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: fixed;
    bottom: 0;
    top: auto;
    left: 0;
    height: auto;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--surface-light);
    z-index: 50;
  }

  .sidebar-brand, .sidebar-footer { display: none; }

  .sidebar-nav {
    display: flex;
    padding: 0;
    overflow-x: auto;
  }

  .nav-item {
    flex-direction: column;
    padding: 0.5rem 0.75rem;
    font-size: 0.65rem;
    gap: 0.2rem;
    white-space: nowrap;
  }

  .nav-badge { display: none; }

  .main-content {
    margin-left: 0;
    margin-bottom: 60px;
  }

  .detail-panel {
    width: 100%;
    max-width: 100vw;
  }

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

/* ============================================================
   Scrollbar
   ============================================================ */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--surface-light);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================================
   Utility
   ============================================================ */

.text-green { color: var(--neon-green); }
.text-blue { color: var(--neon-blue); }
.text-pink { color: var(--neon-pink); }
.text-gold { color: var(--gold); }
.text-red { color: var(--red); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.font-bold { font-weight: 700; }
.font-sm { font-size: 0.8rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.hidden { display: none !important; }

.clickable { cursor: pointer; }
.clickable:hover { opacity: 0.85; }

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
