/* ── Fiducient App Styles ── */
/* Matches landing page design: dark theme, gold accents, Space Grotesk + DM Sans */

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

:root {
  --midnight: #0a0f1c;
  --deep: #111827;
  --slate: #1e293b;
  --slate-light: #283548;
  --gold: #d4a853;
  --gold-light: #e8c97a;
  --gold-dim: rgba(212, 168, 83, 0.15);
  --gold-border: rgba(212, 168, 83, 0.2);
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --white: #f8fafc;
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.15);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.15);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.15);
  --orange: #f59e0b;
  --orange-dim: rgba(245, 158, 11, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --transition: 0.2s ease;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--midnight);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Noise texture */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

body > * { position: relative; z-index: 1; }

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

a {
  color: var(--gold);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--gold-light); }

/* ── Loading ── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 2rem;
}
.loading-screen .logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
}
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--slate);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Nav ── */
.app-nav {
  position: fixed;
  top: 0;
  width: 100%;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
  background: rgba(10, 15, 28, 0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--gold-border);
}
.app-nav .logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--gold);
  cursor: pointer;
}
.app-nav .nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.app-nav .nav-link {
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
}
.app-nav .nav-link:hover,
.app-nav .nav-link.active { color: var(--gold); }
.app-nav .nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.app-nav .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-weight: 600;
  font-size: 0.8rem;
}

/* ── Layout ── */
.app-content {
  padding: 5rem 2rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* ── Cards ── */
.card {
  background: var(--deep);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color var(--transition);
}
.card:hover {
  border-color: var(--gold-border);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.card-title {
  font-size: 1rem;
  color: var(--text-dim);
  font-weight: 500;
}
.card-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--white);
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--deep);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--white);
}
.stat-change {
  font-size: 0.85rem;
  margin-top: 0.25rem;
}
.positive { color: var(--green); }
.negative { color: var(--red); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-primary {
  background: var(--gold);
  color: var(--midnight);
}
.btn-primary:hover {
  background: var(--gold-light);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--slate);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
}
.btn-secondary:hover {
  background: var(--slate-light);
  border-color: var(--gold-border);
}
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover { color: var(--gold); }
.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
}
.btn-danger {
  background: var(--red-dim);
  color: var(--red);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* ── Forms ── */
.form-group {
  margin-bottom: 1.25rem;
}
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}
.form-input,
.form-select {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--slate);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  transition: border-color var(--transition);
  outline: none;
}
.form-input:focus,
.form-select:focus {
  border-color: var(--gold);
}
.form-input::placeholder {
  color: var(--text-muted);
}
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}
.form-help {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ── Auth Pages ── */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}
.auth-card {
  background: var(--deep);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-card .logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  text-align: center;
  margin-bottom: 0.5rem;
}
.auth-card .subtitle {
  color: var(--text-dim);
  text-align: center;
  font-size: 0.9rem;
  margin-bottom: 2rem;
}
.auth-card .btn-primary {
  width: 100%;
  justify-content: center;
  padding: 0.8rem;
  margin-top: 0.5rem;
}
.auth-card .auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.auth-error {
  background: var(--red-dim);
  color: var(--red);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}
.auth-error.show { display: block; }

/* ── Onboarding ── */
.onboarding-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 6rem 2rem 2rem;
}
.onboarding-progress {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
}
.progress-step {
  flex: 1;
  height: 4px;
  background: var(--slate);
  border-radius: 2px;
  transition: background var(--transition);
}
.progress-step.active { background: var(--gold); }
.progress-step.done { background: var(--green); }
.onboarding-card {
  background: var(--deep);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
}
.onboarding-card h2 {
  margin-bottom: 0.5rem;
  font-size: 1.4rem;
}
.onboarding-card .step-desc {
  color: var(--text-dim);
  margin-bottom: 2rem;
  font-size: 0.9rem;
}
.onboarding-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ── Holdings Table ── */
.holdings-table {
  width: 100%;
  border-collapse: collapse;
}
.holdings-table th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-weight: 500;
}
.holdings-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.9rem;
}
.holdings-table tr:hover td {
  background: rgba(255,255,255,0.02);
}
.ticker-badge {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  color: var(--white);
}
.ticker-name {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* ── Allocation Chart ── */
.allocation-chart {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.alloc-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.alloc-label {
  width: 140px;
  font-size: 0.85rem;
  color: var(--text-dim);
  flex-shrink: 0;
}
.alloc-bar-bg {
  flex: 1;
  height: 8px;
  background: var(--slate);
  border-radius: 4px;
  overflow: hidden;
}
.alloc-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.alloc-pct {
  width: 45px;
  text-align: right;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text);
}

/* Sector colors */
.sector-tech { background: #8b5cf6; }
.sector-healthcare { background: #06b6d4; }
.sector-financials { background: #22c55e; }
.sector-consumer { background: #f59e0b; }
.sector-energy { background: #ef4444; }
.sector-communication { background: #ec4899; }
.sector-realestate { background: #14b8a6; }
.sector-fixedincome { background: #6366f1; }
.sector-commodities { background: #d4a853; }
.sector-broad { background: #3b82f6; }
.sector-other { background: #64748b; }

/* ── Alerts ── */
.alert-card {
  background: var(--deep);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  transition: border-color var(--transition);
}
.alert-card:hover { border-color: var(--gold-border); }
.alert-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.2rem;
}
.alert-icon.high { background: var(--red-dim); }
.alert-icon.medium { background: var(--orange-dim); }
.alert-icon.info { background: var(--blue-dim); }
.alert-body { flex: 1; }
.alert-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}
.alert-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
}
.alert-meta {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.alert-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  align-self: center;
}

.severity-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.severity-badge.high { background: var(--red-dim); color: var(--red); }
.severity-badge.medium { background: var(--orange-dim); color: var(--orange); }
.severity-badge.info { background: var(--blue-dim); color: var(--blue); }

/* ── Dashboard Grid ── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.dashboard-grid .full-width {
  grid-column: 1 / -1;
}

/* ── Section Headers ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.section-title {
  font-size: 1.1rem;
  color: var(--white);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-dim);
}
.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}
.empty-state h3 {
  color: var(--text);
  margin-bottom: 0.5rem;
}
.empty-state p {
  max-width: 400px;
  margin: 0 auto 1.5rem;
  font-size: 0.9rem;
}

/* ── Holding Add Form (inline) ── */
.add-holding-row {
  display: grid;
  grid-template-columns: 120px 1fr 100px 140px 80px;
  gap: 0.75rem;
  align-items: end;
  padding: 1rem 0;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.add-holding-row .form-input {
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 1.5rem;
}
.tab {
  padding: 0.75rem 1.25rem;
  font-size: 0.9rem;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
  font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* ── Page Header ── */
.page-header {
  margin-bottom: 2rem;
}
.page-header h1 {
  font-size: 1.8rem;
  margin-bottom: 0.25rem;
}
.page-header .page-subtitle {
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--deep);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.5rem;
  font-size: 0.9rem;
  color: var(--text);
  box-shadow: var(--shadow);
  z-index: 1000;
  opacity: 0;
  transform: translateY(1rem);
  transition: all 0.3s ease;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .app-nav { padding: 0.75rem 1rem; }
  .app-content { padding: 4.5rem 1rem 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .add-holding-row {
    grid-template-columns: 1fr 1fr;
  }
  .holdings-table { font-size: 0.8rem; }
  .holdings-table th, .holdings-table td { padding: 0.5rem; }
}
