/* GoalVest Design System - Premium Dark Fintech Theme */
:root {
  --bg-primary: #060b14;
  --bg-secondary: #0b1324;
  --bg-tertiary: #111e38;
  --bg-card: rgba(15, 23, 42, 0.85);
  --bg-card-hover: rgba(26, 38, 66, 0.85);
  --bg-glass: rgba(11, 19, 36, 0.75);
  --border-subtle: rgba(148, 163, 184, 0.12);
  --border-medium: rgba(148, 163, 184, 0.22);
  --border-accent: rgba(16, 185, 129, 0.35);

  --accent-green: #10b981;
  --accent-green-light: #34d399;
  --accent-green-dark: #059669;
  --accent-green-bg: rgba(16, 185, 129, 0.12);

  --accent-cyan: #06b6d4;
  --accent-cyan-light: #22d3ee;
  --accent-blue: #3b82f6;
  --accent-blue-light: #60a5fa;
  --accent-purple: #8b5cf6;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-red: #ef4444;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --sidebar-width: 260px;
  --topbar-height: 70px;
  --bottombar-height: 64px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 25px rgba(16, 185, 129, 0.25);
  --shadow-cyan-glow: 0 0 25px rgba(6, 182, 212, 0.25);

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background: radial-gradient(circle at 15% 15%, rgba(16, 185, 129, 0.08) 0%, transparent 40%),
              radial-gradient(circle at 85% 85%, rgba(6, 182, 212, 0.08) 0%, transparent 45%),
              var(--bg-primary);
}

/* Typography Helpers */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.25;
}

p {
  color: var(--text-muted);
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-main);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  outline: none;
  transition: all 0.2s ease;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 2px var(--accent-green-bg);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-green { background: rgba(16, 185, 129, 0.15); color: var(--accent-green-light); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-cyan { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan-light); border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-blue { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue-light); border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: #c084fc; border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-red { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent-green), var(--accent-green-dark));
  color: #041f16;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
  background: linear-gradient(135deg, var(--accent-green-light), var(--accent-green));
}
.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-main);
  border: 1px solid var(--border-medium);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-green);
  color: #fff;
}
.btn-cyan {
  background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
  color: #031e2b;
  font-weight: 700;
}
.btn-cyan:hover {
  background: linear-gradient(135deg, var(--accent-cyan-light), var(--accent-cyan));
  transform: translateY(-1px);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}
.btn-danger:hover {
  background: var(--accent-red);
  color: #fff;
}
.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}
.btn-lg {
  padding: 0.95rem 1.8rem;
  font-size: 1.05rem;
  border-radius: var(--radius-lg);
}
.btn-block {
  width: 100%;
}

/* Glass Card */
.gv-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}
.gv-card:hover {
  border-color: var(--border-medium);
}
.gv-card-glow:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-glow);
}

/* Header & Public Nav */
.public-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(6, 11, 20, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
}
.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #060b14;
  font-weight: 900;
  font-size: 1.2rem;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.35);
}
.brand-name {
  color: #ffffff;
}
.brand-name span {
  color: var(--accent-green-light);
}

.public-menu {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  list-style: none;
}
.public-menu a {
  font-size: 0.92rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: color 0.2s ease;
}
.public-menu a:hover, .public-menu a.active {
  color: var(--accent-green-light);
}
.public-auth-btns {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

/* App Layout: Authenticated */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 90;
  transition: transform 0.3s ease;
}
.sidebar-header {
  height: var(--topbar-height);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.sidebar-nav-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.6rem 0.8rem 0.25rem;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  transition: all 0.2s ease;
}
.sidebar-link svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  flex-shrink: 0;
}
.sidebar-link:hover {
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-main);
}
.sidebar-link.active {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.18), rgba(6, 182, 212, 0.08));
  color: var(--accent-green-light);
  border-left: 3px solid var(--accent-green);
  font-weight: 600;
}
.sidebar-footer {
  padding: 1rem 1.2rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(11, 19, 36, 0.5);
}
.user-avatar-badge {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #059669, #0284c7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 0.95rem;
}

/* Main Content Area */
.main-viewport {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-topbar {
  height: var(--topbar-height);
  background: rgba(6, 11, 20, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.topbar-title {
  font-size: 1.3rem;
  font-weight: 700;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.app-container {
  padding: 2rem;
  flex: 1;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottombar-height);
  background: rgba(11, 19, 36, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  padding: 0 0.5rem;
}
.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
}
.mobile-nav-item svg {
  width: 20px;
  height: 20px;
}
.mobile-nav-item.active {
  color: var(--accent-green-light);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateY(15px);
  transition: transform 0.25s ease;
}
.modal-backdrop.open .modal-card {
  transform: translateY(0);
}
.modal-card-lg {
  max-width: 820px;
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background: rgba(11, 19, 36, 0.4);
}

/* Heatmap Grids */
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
}
.heatmap-cell {
  border-radius: var(--radius-md);
  padding: 1rem 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 95px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.heatmap-cell:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.heatmap-cell.up-heavy { background: linear-gradient(135deg, rgba(5, 150, 105, 0.85), rgba(4, 120, 87, 0.95)); color: #fff; }
.heatmap-cell.up-mod { background: linear-gradient(135deg, rgba(16, 185, 129, 0.4), rgba(5, 150, 105, 0.6)); color: #fff; }
.heatmap-cell.neutral { background: var(--bg-tertiary); color: var(--text-muted); }
.heatmap-cell.down-mod { background: linear-gradient(135deg, rgba(239, 68, 68, 0.4), rgba(220, 38, 38, 0.6)); color: #fff; }
.heatmap-cell.down-heavy { background: linear-gradient(135deg, rgba(220, 38, 38, 0.85), rgba(185, 28, 28, 0.95)); color: #fff; }

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.gv-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}
.gv-table th {
  padding: 0.9rem 1rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
}
.gv-table td {
  padding: 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}
.gv-table tr:hover td {
  background: rgba(148, 163, 184, 0.04);
}

/* Toast System */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.25rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 300px;
  max-width: 420px;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast-success { border-left: 4px solid var(--accent-green); }
.toast-error { border-left: 4px solid var(--accent-red); }
.toast-info { border-left: 4px solid var(--accent-cyan); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 220px;
  }
  .app-container {
    padding: 1.5rem;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .main-viewport {
    margin-left: 0;
    padding-bottom: var(--bottombar-height);
  }
  .mobile-bottom-nav {
    display: flex;
  }
  .public-menu {
    display: none;
  }
  .app-topbar, .public-nav {
    padding: 0 1.25rem;
  }
  .app-container {
    padding: 1.25rem 1rem;
  }
  .heatmap-grid {
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  }
  .toast-container {
    bottom: 5rem;
    right: 1rem;
    left: 1rem;
  }
  .toast {
    min-width: unset;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
