/* Fore A Wealth Compass — Private Banking Editorial */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* Backgrounds — warm obsidian */
  --bg-primary: #0C0C0E;
  --bg-secondary: #111113;
  --bg-card: rgba(22, 22, 24, 0.8);
  --bg-card-solid: #161618;
  --bg-card-hover: #1E1E21;

  /* Borders */
  --border: #2A2A2D;
  --border-light: #3A3A3E;

  /* Gold accent */
  --accent-gold: #C9A96E;
  --accent-gold-dim: rgba(201, 169, 110, 0.12);
  --accent-gold-border: rgba(201, 169, 110, 0.25);

  /* Semantic data colors */
  --accent-green: #34D399;
  --accent-green-dim: rgba(52, 211, 153, 0.12);
  --accent-red: #F43F5E;
  --accent-red-dim: rgba(244, 63, 94, 0.12);

  /* Chart palette — muted jewel tones */
  --accent-blue: #5E7CE6;
  --accent-purple: #8B7EC8;
  --accent-cyan: #4ABDC8;
  --accent-yellow: #D4A54A;
  --accent-pink: #D477A0;
  --accent-orange: #D98A4A;
  --accent-indigo: #818CF8;

  /* Text — warm whites & grays */
  --text-primary: #FAFAF9;
  --text-secondary: #A1A1A6;
  --text-muted: #636366;

  /* Typography */
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  /* Spacing & Shape */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --transition: 300ms ease;
  --transition-fast: 150ms ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(201, 169, 110, 0.04) 0%, transparent 60%),
    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.025'/%3E%3C/svg%3E");
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── Custom Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-gold); }

/* ─── Focus States ─── */
*:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

/* ─── Layout ─── */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
  width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 50;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar-logo {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.sidebar-logo span {
  color: var(--accent-gold);
}

.sidebar-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 4px;
  font-weight: 500;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  transition: all var(--transition-fast);
  cursor: pointer;
  border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
  color: var(--text-primary);
  background: rgba(201, 169, 110, 0.04);
}

.sidebar-nav li a.active {
  color: var(--accent-gold);
  background: var(--accent-gold-dim);
  border-left-color: var(--accent-gold);
  font-weight: 500;
}

.sidebar-nav li a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  margin-top: auto;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}

.last-updated {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0;
}

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 32px;
  max-width: 1400px;
}

/* ─── Mobile nav ─── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 60;
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
}

.mobile-menu-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
}

.mobile-menu-btn svg { width: 24px; height: 24px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 40;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    z-index: 55;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-content {
    margin-left: 0;
    padding: 72px 16px 24px;
  }
}

/* ─── Page sections ─── */
.page-view {
  display: none;
}

.page-view.active {
  display: block;
  animation: fadeIn 0.35s ease both;
}

.page-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 400;
  margin-bottom: 28px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.section-title {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin: 36px 0 16px;
}

/* ─── KPI Cards ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent-gold);
  border-radius: var(--radius);
  padding: 24px;
  transition: all var(--transition);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  animation: fadeInUp 0.5s ease both;
}

.kpi-card:nth-child(1) { animation-delay: 0ms; }
.kpi-card:nth-child(2) { animation-delay: 70ms; }
.kpi-card:nth-child(3) { animation-delay: 140ms; }
.kpi-card:nth-child(4) { animation-delay: 210ms; }

.kpi-card:hover {
  border-color: var(--border-light);
  border-top-color: var(--accent-gold);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.kpi-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: 10px;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.kpi-change {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
}

.kpi-change.positive {
  color: var(--accent-green);
  background: var(--accent-green-dim);
}

.kpi-change.negative {
  color: var(--accent-red);
  background: var(--accent-red-dim);
}

/* ─── Charts ─── */
.chart-container {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: border-color var(--transition);
  animation: fadeInUp 0.5s ease both;
  animation-delay: 150ms;
}

.chart-container:hover {
  border-color: var(--border-light);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.chart-title {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.chart-controls {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.chart-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chart-toggle:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
}

.chart-toggle.active {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  color: #0C0C0E;
  font-weight: 600;
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 300px;
}

.chart-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ─── Data Tables ─── */
.data-table-wrap {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 24px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(42, 42, 45, 0.5);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: nowrap;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr.total-row td {
  font-weight: 700;
  color: var(--text-primary);
  border-top: 2px solid var(--border-light);
}

.data-table td.positive { color: var(--accent-green); }
.data-table td.negative { color: var(--accent-red); }

/* ─── Property / Investment Cards ─── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.info-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all var(--transition);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  animation: fadeInUp 0.5s ease both;
}

.info-card:nth-child(1) { animation-delay: 0ms; }
.info-card:nth-child(2) { animation-delay: 80ms; }
.info-card:nth-child(3) { animation-delay: 160ms; }
.info-card:nth-child(4) { animation-delay: 240ms; }
.info-card:nth-child(5) { animation-delay: 320ms; }
.info-card:nth-child(6) { animation-delay: 400ms; }
.info-card:nth-child(7) { animation-delay: 480ms; }

.info-card:hover {
  border-color: var(--accent-gold-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow), 0 0 0 1px var(--accent-gold-border);
}

.info-card.dimmed {
  opacity: 0.5;
}

.info-card.dimmed:hover {
  opacity: 0.75;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.card-name {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-badge {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: 20px;
}

.badge-active {
  color: var(--accent-green);
  background: var(--accent-green-dim);
}

.badge-sold {
  color: var(--accent-red);
  background: var(--accent-red-dim);
}

.badge-written-off {
  color: var(--accent-orange);
  background: rgba(217, 138, 74, 0.12);
}

.badge-paid-off {
  color: var(--accent-blue);
  background: rgba(94, 124, 230, 0.12);
}

.badge-type {
  color: var(--accent-gold);
  background: var(--accent-gold-dim);
}

.card-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(42, 42, 45, 0.3);
}

.card-row:last-child {
  border-bottom: none;
}

.card-row-label {
  color: var(--text-muted);
}

.card-row-value {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-weight: 500;
}

.card-row-value.positive { color: var(--accent-green); }
.card-row-value.negative { color: var(--accent-red); }

/* ─── Policy info card ─── */
.policy-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  animation: fadeInUp 0.5s ease both;
  animation-delay: 100ms;
}

.policy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.policy-item-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 500;
}

.policy-item-value {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
  margin-top: 3px;
}

/* ─── Collapsible sections ─── */
.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 14px 20px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: all var(--transition-fast);
}

.collapsible-header:hover {
  border-color: var(--border-light);
}

.collapsible-header .chevron {
  transition: transform var(--transition);
  color: var(--text-muted);
}

.collapsible-header.open .chevron {
  transform: rotate(180deg);
  color: var(--accent-gold);
}

.collapsible-body {
  display: none;
  margin-bottom: 24px;
}

.collapsible-body.open {
  display: block;
  animation: fadeIn 0.3s ease both;
}

/* ─── Horizontal bar chart (gain/loss) ─── */
.hbar-container {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.hbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.hbar-label {
  width: 140px;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
}

.hbar-bar-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hbar-bar {
  height: 24px;
  border-radius: 4px;
  transition: width 800ms cubic-bezier(0.4, 0, 0.2, 1);
}

.hbar-bar.gain { background: linear-gradient(90deg, var(--accent-green), #2EBD8A); }
.hbar-bar.loss { background: linear-gradient(90deg, var(--accent-red), #E05C6E); }

.hbar-value {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
}

.hbar-value.positive { color: var(--accent-green); }
.hbar-value.negative { color: var(--accent-red); }

/* ─── Password gate ─── */
.auth-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse 60% 40% at 50% 40%, rgba(201, 169, 110, 0.06) 0%, transparent 60%);
}

.auth-box {
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.6s ease both;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.auth-title span { color: var(--accent-gold); }

.auth-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 32px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 500;
}

.auth-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: all var(--transition-fast);
  margin-bottom: 16px;
}

.auth-input:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px var(--accent-gold-dim);
}

.auth-input:focus-visible {
  outline: none;
}

.auth-input::placeholder {
  color: var(--text-muted);
}

.auth-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent-gold);
  border: none;
  border-radius: var(--radius-sm);
  color: #0C0C0E;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  letter-spacing: 0.02em;
}

.auth-btn:hover {
  background: #D4B478;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(201, 169, 110, 0.25);
}

.auth-btn:active {
  transform: translateY(0);
}

.auth-error {
  color: var(--accent-red);
  font-size: 13px;
  margin-top: 12px;
  display: none;
}

/* ─── Animations ─── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Pulse dot */
.pulse-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse 2.5s ease-in-out infinite;
  margin-right: 8px;
  flex-shrink: 0;
}

/* ─── Utility ─── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .two-col { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .card-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 26px; }
  .page-title { font-size: 26px; }
  .hbar-label { width: 100px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
