:root {
  --bg: #edf3f6;
  --card: #ffffff;
  --text: #1b3a4b;
  --muted: #5a6e7a;
  --accent: #c17f4e;
  --accent-soft: #f5ebe3;
  --line: #d0dbe2;
  --danger: #a11f1f;
  --success: #146c2e;
  --navy: #1b3a4b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  line-height: 1.4;
}

.container {
  width: min(1000px, 94vw);
  margin: 0 auto;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--navy);
}

.nav-row {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 0;
}

.brand {
  color: #ffffff;
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
}

.brand-logo {
  height: 36px;
  max-width: 100%;
  object-fit: contain;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.nav-links > a,
.nav-links .link-button {
  color: #dce8ee;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  background: none;
  cursor: pointer;
  font: inherit;
}

.nav-links > a:hover,
.nav-links .link-button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.card {
  margin: 1.4rem 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.2rem;
}

.login-card {
  max-width: 400px;
  margin: 4rem auto;
  text-align: center;
}

.login-logo {
  max-width: 320px;
  width: 100%;
  height: auto;
  margin-bottom: 0.5rem;
}

h1 { margin: 0 0 1rem; }
h2 { margin: 1.2rem 0 0.6rem; font-size: 1.1rem; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); }
.success { color: var(--success); }

.button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1.2rem;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
}

.button:hover { opacity: 0.9; }
.button.secondary { background: var(--muted); }
.button.small { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.button.danger { background: var(--danger); }

.inline-form { display: inline-block; margin-right: 0.3rem; margin-bottom: 0.2rem; }

.back-link {
  display: inline-block;
  margin-bottom: 0.5rem;
  color: var(--accent);
  text-decoration: none;
}

.fund-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.4rem;
  margin: 1.4rem 0;
}

.fund-grid .card {
  margin: 0;
}

.fund-card h2 {
  margin-top: 0;
}

.fund-card {
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}

.fund-card:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.fund-amount {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0;
  margin-top: auto;
  padding-top: 0.5rem;
}

.investment-details p { margin: 0.3rem 0; }

.filter-chips {
  display: flex;
  gap: 0.4rem;
  margin: 0.6rem 0 0.8rem;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--accent-soft);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.3rem 0.7rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.chip-count {
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

.documents-table,
.users-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

.documents-table th,
.documents-table td,
.users-table th,
.users-table td {
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--line);
}

.documents-table th,
.users-table th {
  font-size: 0.85rem;
  color: var(--muted);
}

.add-user-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.add-user-form input[type="email"] {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.lp-search-input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  margin-bottom: 0.7rem;
}

/* ── Hamburger toggle (hidden on desktop) ── */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  display: block;
  width: 20px;
  height: 2px;
  background: #dce8ee;
  border-radius: 1px;
  position: relative;
  transition: transform 0.2s;
}

.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: "";
  position: absolute;
  left: 0;
  width: 20px;
}

.nav-toggle-icon::before { top: -6px; }
.nav-toggle-icon::after  { top: 6px; }

/* ── Mobile styles ── */
@media (max-width: 640px) {
  .nav-toggle {
    display: flex;
  }

  .nav-row {
    flex-wrap: wrap;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 0.4rem;
    padding: 0.6rem 0 0.8rem;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links > a,
  .nav-links .link-button {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.6rem 0.7rem;
    min-height: 44px;
    line-height: 1.6;
  }

  /* Responsive tables — horizontal scroll wrapper */
  .documents-table,
  .users-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .documents-table thead,
  .users-table thead {
    display: none;
  }

  .documents-table tbody,
  .documents-table tr,
  .users-table tbody,
  .users-table tr {
    display: block;
  }

  .documents-table tr,
  .users-table tr {
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--line);
  }

  .documents-table td,
  .users-table td {
    display: block;
    border-bottom: none;
    padding: 0.2rem 0.3rem;
  }

  /* Bigger touch targets for buttons */
  .button {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .button.small {
    padding: 0.45rem 0.8rem;
    font-size: 0.9rem;
    min-height: 44px;
  }

  /* Action buttons in user management — stack vertically */
  .users-table td .inline-form {
    display: block;
    margin-bottom: 0.3rem;
  }

  .users-table td .inline-form .button {
    width: 100%;
  }

  /* Add-user form stacks on mobile */
  .add-user-form {
    flex-direction: column;
  }

  .add-user-form input[type="email"] {
    min-height: 44px;
  }

  .add-user-form .button {
    width: 100%;
  }

  /* Card padding tweak */
  .card {
    padding: 1rem;
    border-radius: 10px;
  }

  .filter-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .chip {
    min-height: 36px;
    flex-shrink: 0;
  }

  h1 {
    font-size: 1.3rem;
  }
}

/* Magic-link auth */
.ml-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: left;
  margin-top: 1rem;
}
.ml-form label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
}
.ml-form input[type="email"],
.ml-form input[type="text"] {
  width: 100%;
  padding: 0.65rem 0.8rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}
.ml-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.ml-form input[name="code"] {
  letter-spacing: 0.3rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: center;
  text-transform: uppercase;
}
.ml-form .button {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
}
.login-card a:not(.button) {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.login-card a:not(.button):hover { opacity: 0.85; }
.login-card .small { font-size: 0.85rem; }
.login-card .or-divider {
  margin: 0.9rem 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.login-card .or-divider::before,
.login-card .or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.magic-link-code {
  font-size: 1.8rem;
  letter-spacing: 0.4rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600;
  padding: 0.7rem 1.1rem;
  background: var(--accent-soft);
  color: var(--text);
  border-radius: 8px;
  display: inline-block;
  margin: 0.6rem 0;
}
.button.secondary {
  background: var(--card);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.button.secondary:hover { background: var(--accent-soft); }

.login-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1rem;
}
.login-actions .button {
  flex: 1;
  min-width: 0;
}
@media (max-width: 480px) {
  .login-actions {
    flex-direction: column;
  }
}
