:root {
  --bg-1: #070b17;
  --bg-2: #0b1020;
  --bg-3: #111827;
  --panel: rgba(17, 24, 39, 0.82);
  --panel-soft: rgba(30, 41, 59, 0.82);
  --panel-strong: rgba(15, 23, 42, 0.92);
  --line: rgba(255, 255, 255, 0.10);
  --text: #e5e7eb;
  --text-soft: #cbd5e1;
  --muted: #94a3b8;
  --primary: #4f46e5;
  --accent: #7c3aed;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  font-family: Arial, sans-serif;
  color: var(--text);
  margin: 0;
  padding: 16px 16px 140px;
  background:
    radial-gradient(circle at top right, rgba(79,70,229,0.18), transparent 28%),
    radial-gradient(circle at left bottom, rgba(124,58,237,0.16), transparent 32%),
    linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 45%, var(--bg-3) 100%);
}

h1, h2, h3 { margin-top: 0; color: #f8fafc; }
p { color: var(--muted); line-height: 1.55; }
a { color: #a5b4fc; }

input, select, textarea {
  width: 100%;
  max-width: 420px;
  padding: 12px 14px;
  margin: 6px 8px 6px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(129,140,248,0.7);
  box-shadow: 0 0 0 4px rgba(79,70,229,0.15);
  background: rgba(255,255,255,0.06);
}

input::placeholder { color: #7c8aa3; }
select option { color: #111827; }

button, .navbtn {
  display: inline-block;
  padding: 11px 16px;
  margin: 6px 8px 6px 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s ease, background .2s ease, border-color .2s ease;
  white-space: nowrap;
}

button:hover, .navbtn:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.10);
}

button.primary, .primary, .tab-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 10px 24px rgba(79,70,229,0.25);
}

/* ── Active nav button highlight ── */
.navbtn.nav-active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 4px 20px rgba(79,70,229,0.5);
  border-color: rgba(129,140,248,0.6);
  color: #fff !important;
  font-weight: 600;
}

.tab-row { margin-bottom: 12px; }

/* ── Login screen ── */
.login-screen {
  min-height: calc(100vh - 32px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-shell {
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 28px;
  align-items: stretch;
}

.brand-mark, .login-panel, .card, .toolbar, .hero {
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.28);
}

/* Header must not clip dropdown */
.header { overflow: visible !important; }

.brand-mark {
  padding: 34px;
  display: flex;
  gap: 18px;
  align-items: center;
}

.login-panel, .card { padding: 22px; }

/* ── Header / nav ── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  border-radius: 20px;
  padding: 12px 18px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.28);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 14px 18px;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

/* ── Hamburger for mobile ── */
.nav-toggle {
  display: none;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #fff;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  filter: drop-shadow(0 6px 18px rgba(79,70,229,0.25));
  flex-shrink: 0;
}

.logo.lg { width: 88px; height: 88px; }

.eyebrow {
  color: #8b90ff;
  letter-spacing: 0.16em;
  font-size: 12px;
  font-weight: 700;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 22px 24px;
  margin-bottom: 18px;
}

.hero-chip {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(99,102,241,0.18);
  border: 1px solid rgba(129,140,248,0.25);
  color: #c7d2fe;
  white-space: nowrap;
}

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }

.summary-box, .description-box {
  margin-top: 14px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  color: var(--text-soft);
}

.fv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 18px;
}

.fv-tile {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.primary-tile { background: linear-gradient(135deg, rgba(79,70,229,0.28), rgba(124,58,237,0.22)); }
.secondary-tile { background: linear-gradient(135deg, rgba(30,41,59,0.92), rgba(17,24,39,0.92)); }

.fv-label { color: #c7d2fe; font-size: 13px; text-transform: uppercase; }
.fv-value { font-size: 30px; font-weight: 700; margin: 10px 0 6px; }
.fv-note, .muted, .muted-light, .shortfall-note, .chart-note { color: var(--text-soft); font-size: 13px; }

.shortfall-card {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  margin-top: 16px;
}
.shortfall-card.shortfall { background: rgba(239,68,68,0.16); }
.shortfall-card.surplus { background: rgba(16,185,129,0.16); }
.shortfall-card.neutral { background: rgba(255,255,255,0.04); }
.shortfall-label { color: #c7d2fe; font-size: 13px; text-transform: uppercase; }

/* ── Table — horizontal scroll on mobile ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  background: rgba(255,255,255,0.02);
  border-radius: 16px;
  overflow: hidden;
  min-width: 540px;
}

th, td {
  border: 1px solid var(--line);
  padding: 12px;
  text-align: left;
}

th { background: rgba(255,255,255,0.04); color: #cbd5e1; }
td input { width: 100%; margin: 0; }

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
}
.red { background: rgba(239,68,68,0.16); color: #fecaca; }
.green { background: rgba(16,185,129,0.16); color: #bbf7d0; }
.yellow { background: rgba(245,158,11,0.16); color: #fde68a; }

.minirow { padding: 10px 0; border-bottom: 1px solid var(--line); }

.heatwrap {
  display: flex;
  min-height: 140px;
  gap: 8px;
  flex-wrap: wrap;
}

.heatbox {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 70px;
  padding: 12px;
  border-radius: 14px;
  font-weight: bold;
  border: 1px solid rgba(255,255,255,0.08);
}

/* ── Footer ── */
.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(7,11,23,0.96);
  color: #dbe4f0;
  border-top: 1px solid var(--line);
  padding: 10px 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  z-index: 40;
  font-size: 12px;
  flex-wrap: wrap;
}

.site-footer a { color: #a5b4fc; text-decoration: none; }
.footer-legal {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.5;
  text-align: right;
  max-width: 480px;
}

.contact-btn { margin: 0; }

/* ── Contact modal ── */
.contact-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 60;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.contact-modal.open { display: flex; }

.contact-modal-card {
  width: min(640px, 100%);
  background: #111827;
  color: #e5e7eb;
  border-radius: 16px;
  padding: 24px;
  position: relative;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 18px 50px rgba(0,0,0,0.35);
}

.contact-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  font-size: 24px;
  line-height: 1;
}

.page-shell { width: 100%; }

/* ── Responsive breakpoints ── */
@media (max-width: 1100px) {
  .grid.three { grid-template-columns: 1fr 1fr; }
  .brand-shell { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  body { padding: 10px 10px 160px; }

  .grid.three, .grid.two, .fv-grid { grid-template-columns: 1fr; }

  .brand-shell { grid-template-columns: 1fr; gap: 16px; }

  .brand-mark { padding: 20px; flex-direction: column; text-align: center; align-items: center; }
  .logo.lg { width: 64px; height: 64px; }

  .header { padding: 10px 14px; gap: 8px; }
  .header h1 { font-size: 15px; }
  .eyebrow { font-size: 10px; }

  /* Hamburger menu */
  .nav-toggle { display: block; }

  nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding-top: 8px;
  }

  nav.open { display: flex; }

  nav .navbtn {
    width: 100%;
    text-align: center;
    padding: 12px;
    margin: 0;
  }

  .hero { flex-direction: column; align-items: flex-start; padding: 16px; }
  .hero-chip { align-self: flex-start; }

  .toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .toolbar input { max-width: 100%; }
  .toolbar button { width: 100%; margin: 0; }

  .card { padding: 16px; }

  input, select, textarea { max-width: 100%; }

  .fv-value { font-size: 22px; }

  .site-footer {
    flex-direction: column;
    align-items: flex-start;
    padding: 10px 14px;
    font-size: 11px;
  }
  .footer-legal { text-align: left; max-width: 100%; }

  table { min-width: 480px; }
}

@media (max-width: 400px) {
  .header h1 { font-size: 13px; }
  .logo { width: 36px; height: 36px; }
}

/* ── Toast / notification modal ── */
.trudy-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.trudy-modal-overlay.open { display: flex; }
.trudy-modal-box {
  width: min(520px, 100%);
  background: #111827;
  border-radius: 20px;
  padding: 28px 28px 22px;
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
  text-align: center;
}
.trudy-modal-icon { font-size: 42px; margin-bottom: 12px; }
.trudy-modal-title { font-size: 20px; font-weight: 700; color: #f8fafc; margin-bottom: 8px; }
.trudy-modal-body  { font-size: 14px; color: #94a3b8; line-height: 1.65; margin-bottom: 20px; }
.trudy-modal-box .primary { width: 100%; margin: 0; }

/* Success variant */
.trudy-modal-box.success { border-color: rgba(16,185,129,0.35); }
.trudy-modal-box.success .trudy-modal-title { color: #6ee7b7; }

/* Warning / shortfall variant */
.trudy-modal-box.warning { border-color: rgba(245,158,11,0.35); }
.trudy-modal-box.warning .trudy-modal-title { color: #fde68a; }

/* Info variant (email verification) */
.trudy-modal-box.info { border-color: rgba(99,102,241,0.45); }
.trudy-modal-box.info .trudy-modal-title { color: #c7d2fe; }

/* Input highlight for shortfall fields */
.input-highlight {
  border-color: rgba(245,158,11,0.8) !important;
  box-shadow: 0 0 0 4px rgba(245,158,11,0.18) !important;
  background: rgba(245,158,11,0.06) !important;
}

/* ── My Account dropdown ── */
.myaccount-wrap { position: relative; display: inline-block; }
.myaccount-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; border: none; cursor: pointer;
  font-size: 13px; font-weight: 500; white-space: nowrap;
}
.myaccount-btn .avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.myaccount-menu {
  display: none; position: fixed; top: 0; left: 0;
  background: #0b1020; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px; min-width: 220px; z-index: 99999;
  box-shadow: 0 16px 40px rgba(0,0,0,0.6); overflow: hidden;
  pointer-events: auto;
}
.myaccount-menu.open { display: block; }
.myaccount-menu a,
.myaccount-menu button {
  display: block; width: 100%; text-align: left;
  padding: 11px 16px; font-size: 13px; color: #cbd5e1;
  background: transparent; border: none; border-bottom: 1px solid rgba(255,255,255,0.06);
  cursor: pointer; text-decoration: none; transition: background .15s;
  margin: 0; border-radius: 0;
}
.myaccount-menu a:hover,
.myaccount-menu button:hover { background: rgba(255,255,255,0.07); color: #fff; }
.myaccount-menu .menu-danger { color: #f87171; }
.myaccount-menu .menu-danger:hover { background: rgba(239,68,68,0.12); }
.myaccount-menu .menu-header {
  padding: 12px 16px 8px; font-size: 11px; color: #6366f1;
  letter-spacing: 0.1em; font-weight: 700; text-transform: uppercase;
  border-bottom: 1px solid rgba(255,255,255,0.08); cursor: default;
}
.myaccount-menu .menu-header:hover { background: transparent; color: #6366f1; }

/* ── Remove number spinners ── */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* ── Chart legend white text ── */
.chart-legend-white .chartjs-legend li span { color: #fff !important; }

/* ── Rebalance table ── */
.rebalance-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12px; }
.rebalance-table th {
  background: rgba(255,255,255,0.06); color: #cbd5e1;
  padding: 8px 10px; text-align: left; font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.rebalance-table td { padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,0.04); color: var(--text); }
.rebalance-table tr:last-child td { border-bottom: none; }
.rebalance-table .action-reduce { color: #fca5a5; font-weight: 600; }
.rebalance-table .action-increase { color: #bbf7d0; font-weight: 600; }
.rebalance-table .action-maintain { color: #fde68a; font-weight: 600; }
.rebalance-table .gap-neg { color: #bbf7d0; }
.rebalance-table .gap-pos { color: #fca5a5; }

/* ── Generate PDF Report — always highlighted ── */
.btn-pdf {
  background: linear-gradient(135deg, #854d0e, #b45309) !important;
  border-color: rgba(251,191,36,0.4) !important;
  color: #fef3c7 !important;
  font-weight: 600 !important;
  box-shadow: 0 4px 18px rgba(180,83,9,0.4) !important;
  letter-spacing: 0.02em;
}
.btn-pdf:hover {
  background: linear-gradient(135deg, #92400e, #d97706) !important;
  box-shadow: 0 6px 24px rgba(180,83,9,0.55) !important;
  transform: translateY(-1px);
}

/* ── Floating PDF button bottom-right ── */
.pdf-fab {
  position: fixed;
  bottom: 140px;
  right: 24px;
  z-index: 9998;
  background: linear-gradient(135deg, #854d0e, #b45309);
  color: #fef3c7;
  border: none;
  border-radius: 50px;
  padding: 14px 22px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(180,83,9,0.6);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.02em;
  transition: transform .15s, box-shadow .15s;
}
.pdf-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(180,83,9,0.65);
}

/* ── Upgrade to Pro nav button ── */
.navbtn-upgrade {
  background: linear-gradient(135deg, #7c3aed, #4f46e5) !important;
  color: #fff !important;
  border-color: transparent !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 14px rgba(124,58,237,0.4);
  animation: pulse-pro 2.5s ease-in-out infinite;
}
.navbtn-upgrade:hover {
  box-shadow: 0 6px 20px rgba(124,58,237,0.6);
  transform: translateY(-1px);
}
@keyframes pulse-pro {
  0%, 100% { box-shadow: 0 4px 14px rgba(124,58,237,0.4); }
  50%       { box-shadow: 0 4px 22px rgba(124,58,237,0.7); }
}
