/* ---- Reset-ish ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: #1f2937;
  background: #f7f8fa;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

/* Login page uses a centered card on a soft gradient background. */
body.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: linear-gradient(160deg, #eef2ff 0%, #f7f8fa 60%, #f1f5f9 100%);
}
.auth-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  overflow: hidden;                                   /* so the accent stripe clips cleanly */
  width: 100%;
  max-width: 400px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.09);
}
.auth-accent {                                        /* thin brand stripe across the top */
  height: 6px;
  background: linear-gradient(90deg, #1d4ed8, #2563eb 50%, #60a5fa);
}
.auth-card-inner { padding: 2rem 2.25rem 1.75rem; }
.auth-title {
  font-size: 1.6rem;
  margin-bottom: 0.25rem;
  letter-spacing: -0.01em;
}
.auth-subtitle { color: #6b7280; margin: 0 0 1.5rem 0; font-size: 0.9rem; }
.auth-form { display: flex; flex-direction: column; gap: 0.85rem; }
.auth-form label {
  display: flex; flex-direction: column; gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.auth-form input[type="email"],
.auth-form input[type="password"] {
  padding: 0.6rem 0.7rem;
  font-size: 0.95rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #1f2937;
  text-transform: none;                               /* override uppercase inherited from the label */
  letter-spacing: normal;
  font-weight: normal;
}
.auth-form input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.auth-form button.primary {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
}
.auth-error {
  background: #fee2e2;
  color: #991b1b;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin: 0 0 1rem 0;
  border: 1px solid #fecaca;
}
.auth-footer {
  margin: 1.25rem 0 0 0;
  font-size: 0.78rem;
  color: #94a3b8;
  text-align: center;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 0.95rem; }

/* ---- Sidebar ------------------------------------------------------ */
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  background: #111827;
  color: #e5e7eb;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sidebar .brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #1f2937;
}
.sidebar .brand:hover { text-decoration: none; }

.sidebar .nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.sidebar .nav a {
  color: #cbd5e1;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
.sidebar .nav a:hover { background: #1f2937; text-decoration: none; }
.sidebar .nav a.active { background: #2563eb; color: #fff; }
.sidebar .nav .nav-gap { height: 0.85rem; }
.sidebar .nav .nav-section {
  color: #6b7280;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0.9rem 0 0.25rem;
  padding: 0 0.6rem;
}

/* Filters block */
.filters h3 {
  color: #e5e7eb;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.filters label {
  display: block;
  font-size: 0.8rem;
  color: #cbd5e1;
  margin-bottom: 0.75rem;
}
.filters select,
.filters input[type="date"] {
  width: 100%;
  padding: 0.35rem 0.45rem;
  font-size: 0.85rem;
  background: #1f2937;
  color: #f3f4f6;
  border: 1px solid #374151;
  border-radius: 6px;
  margin-top: 0.25rem;
}
.filters select:focus,
.filters input:focus { outline: 2px solid #2563eb; outline-offset: -1px; }

.filters .date-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.filters .search-field { margin-bottom: 0.75rem; }
.filters input[type="search"] {
  width: 100%;
  padding: 0.35rem 0.45rem;
  font-size: 0.85rem;
  background: #1f2937;
  color: #f3f4f6;
  border: 1px solid #374151;
  border-radius: 6px;
  margin-top: 0.25rem;
}
.filters input[type="search"]:focus { outline: 2px solid #2563eb; outline-offset: -1px; }
.filters input[type="search"]::placeholder { color: #64748b; }

/* Multiselect block */
.multiselect { margin-bottom: 0.8rem; }
.multiselect-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  color: #cbd5e1;
  margin-bottom: 0.25rem;
}
.multiselect-header span { font-weight: 600; }
.multiselect select[multiple] {
  min-height: 6rem;
  max-height: 9rem;
}
.select-buttons {
  display: flex;
  gap: 0.3rem;
}
.select-buttons button {
  background: transparent;
  border: 1px solid #374151;
  color: #cbd5e1;
  padding: 1px 6px;
  font-size: 0.7rem;
  border-radius: 4px;
  cursor: pointer;
}
.select-buttons button:hover { background: #1f2937; color: #fff; }

.filters button.secondary,
details.advanced button.secondary {
  width: 100%;
  background: #1f2937;
  border: 1px solid #374151;
  color: #e5e7eb;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  margin-top: 0.25rem;
}
.filters button.secondary:hover,
details.advanced button.secondary:hover { background: #374151; }

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid #1f2937;
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
}
.sidebar-footer .user-email {
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-footer .logout-link {
  color: #cbd5e1;
  text-decoration: none;
}
.sidebar-footer .logout-link:hover { color: #fff; text-decoration: underline; }

details.advanced {
  margin-top: auto;
  border-top: 1px solid #1f2937;
  padding-top: 0.75rem;
}
details.advanced > summary {
  font-size: 0.8rem;
  color: #cbd5e1;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
details.advanced .caption {
  font-size: 0.7rem;
  color: #94a3b8;
  margin: 0.4rem 0 0 0;
}

/* ---- Main area ---------------------------------------------------- */
.main {
  padding: 1.5rem 1.75rem 2rem;
  min-width: 0;          /* needed so grid children can shrink */
}

.page-header {
  margin-bottom: 1rem;
}
.page-header h1 { margin-bottom: 0.25rem; }
.page-header .subtitle,
.page-header .summary {
  color: #6b7280;
  font-size: 0.85rem;
  margin: 0;
}

.grid-row {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}
.grid-row.cols-2 { grid-template-columns: 1fr 1fr; }
.grid-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.85rem 0.95rem 0.75rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  min-width: 0;
}
.card-title {
  color: #475569;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.chart { width: 100%; min-height: 290px; }
.chart.scroll-y { max-height: 290px; overflow-y: auto; overflow-x: hidden; }

.empty-msg {
  color: #94a3b8;
  font-size: 0.85rem;
  padding: 2rem 0;
  text-align: center;
}

/* ---- Home --------------------------------------------------------- */
.home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}
.home-card {
  display: block;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1.25rem;
  color: inherit;
  transition: border-color 120ms ease, transform 120ms ease;
}
.home-card:hover {
  border-color: #2563eb;
  text-decoration: none;
  transform: translateY(-1px);
}
.home-card h2 { margin-bottom: 0.35rem; }
.home-card p { color: #64748b; margin: 0 0 0.75rem 0; }
.home-card .open { color: #2563eb; font-weight: 600; font-size: 0.9rem; }

/* ---- Details table ------------------------------------------------ */
/* Status filter on the Private Equity Portfolio sidebar. */
.status-filter { margin-bottom: 0.8rem; }
.status-filter .status-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 0.25rem;
}
.status-filter .status-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #e5e7eb;
  cursor: pointer;
  margin: 0;
}
.status-filter .status-option:hover { background: #1f2937; }
.status-filter .status-option input[type="checkbox"] {
  margin: 0;
  accent-color: #2563eb;
  width: auto;            /* override .filters select width: 100% */
}
.status-filter .status-label { flex: 1; }
.status-filter .status-count {
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
}

/* KPI tiles on the Accounts and Investments dashboard. */
.tile-row { margin-bottom: 1rem; }
.card.tile {
  text-align: center;
  padding: 1.4rem 1rem 1.6rem;
}
.tile-label {
  color: #475569;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.4rem 0;
}
.tile-value {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.tile-blue  { color: #2563eb; }
.tile-amber { color: #d97706; }
.tile-slate { color: #475569; }

/* Definitions page — generous typography, lots of breathing room. */
.card.defs { line-height: 1.55; max-width: 880px; }
.card.defs h2 {
  margin-top: 1.4rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.3rem;
}
.card.defs h2:first-child { margin-top: 0; }
.card.defs dl { margin: 0; }
.card.defs dt {
  font-weight: 600;
  color: #1f2937;
  margin-top: 0.85rem;
}
.card.defs dd {
  margin: 0.15rem 0 0 0;
  color: #374151;
}
.card.defs code {
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.85em;
  color: #1f2937;
}

.section-heading {
  margin: 1.5rem 0 0.75rem 0;
  font-size: 1.1rem;
  color: #1f2937;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.35rem;
}

.details-table {
  max-height: 380px;
  overflow: auto;
  border-top: 1px solid #e5e7eb;
}
.details-table.wide { max-height: 620px; }

/* Sticky-first-column variant: pin column 1 (and its header) so the
   Investment Name stays visible when the table scrolls horizontally. */
.details-table.sticky-first-col th:first-child,
.details-table.sticky-first-col td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
  /* Subtle separator so the pinned column is visually distinct from the
     scrolling area underneath it. */
  box-shadow: 1px 0 0 #e5e7eb;
}
.details-table.sticky-first-col th:first-child {
  background: #f9fafb;
  z-index: 2;
}

/* Right-justify column headers in the Investment Amount by Year pivot
   so the header sits over its (right-aligned) numeric values. */
.pivot-table.headers-right th { text-align: right; }
.pivot-table.headers-right th:first-child { text-align: left; }

/* Per-column filter row beneath the header in the Investments table. */
.details-table tr.filter-row th {
  padding: 4px 6px;
  background: #f9fafb;
  position: sticky;
  top: 1.85rem;        /* sit just below the label row */
  z-index: 1;
  cursor: default;
  text-transform: none;
  font-weight: normal;
  letter-spacing: normal;
}
.details-table tr.filter-row input[type="search"] {
  width: 100%;
  min-width: 6.5rem;
  padding: 2px 6px;
  font-size: 0.78rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  color: #1f2937;
}
.details-table tr.filter-row input[type="search"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}
/* Pinned first-column filter input keeps the same opaque background so
   the input doesn't look transparent over the scroll body. */
.details-table.sticky-first-col tr.filter-row th:first-child {
  background: #f9fafb;
  z-index: 3;
}
.details-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.details-table th, .details-table td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
}
.details-table th {
  position: sticky;
  top: 0;
  background: #f9fafb;
  color: #475569;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  user-select: none;
}
.details-table th .sort-arrow { opacity: 0.45; margin-left: 0.25rem; }
.details-table th.sorted .sort-arrow { opacity: 1; }
.details-table td.amount { text-align: right; font-variant-numeric: tabular-nums; }

/* Long description cells clip via a wrapping div — max-width on <td> alone
   isn't reliably honored in table-layout:auto. Full text shows on hover. */
.details-table td.truncate { max-width: 50ch; }
.details-table td.truncate .truncate-inner {
  max-width: 50ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Pivot table (payroll) --------------------------------------- */
.pivot-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.pivot-table th, .pivot-table td {
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
}
.pivot-table th {
  background: #f9fafb;
  color: #475569;
  text-align: left;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  user-select: none;
  white-space: normal;
  line-height: 1.2;
}
.pivot-table th.sorted .sort-arrow { opacity: 1; }
.pivot-table th .sort-arrow { opacity: 0.45; margin-left: 0.25rem; }
.pivot-table td.amount { text-align: right; font-variant-numeric: tabular-nums; }
.pivot-table tr.total-row td {
  font-weight: 700;
  background: #f5f5f5;
  border-top: 2px solid #d1d5db;
}

/* ---- Data view ---------------------------------------------------- */
.data-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.etl-status p { margin: 0.4rem 0 0 0; font-size: 0.85rem; }
.etl-status .ok   { color: #166534; }
.etl-status .err  { color: #b91c1c; }
.etl-status .muted { color: #64748b; }

button.primary {
  background: #2563eb;
  color: #fff;
  border: 1px solid #1d4ed8;
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
button.primary:hover:not(:disabled) { background: #1d4ed8; }
button.primary:disabled { opacity: 0.65; cursor: default; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table th, .data-table td {
  padding: 0.5rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.data-table th {
  background: #f9fafb;
  color: #475569;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .path {
  background: #f3f4f6;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: #334155;
}
.muted { color: #64748b; }
.warn  { color: #92400e; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge.ok  { background: #dcfce7; color: #166534; }
.badge.err { background: #fee2e2; color: #991b1b; }

/* ---- Upload slots (Data view) ------------------------------------ */
.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}
.upload-slot {
  border: 1px dashed #d1d5db;
  border-radius: 10px;
  padding: 0.85rem 0.95rem;
  background: #fafbfc;
}
.upload-slot h4 {
  margin: 0 0 0.15rem 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #1f2937;
}
.upload-slot .caption {
  margin: 0 0 0.5rem 0;
  font-size: 0.78rem;
  color: #64748b;
}
.upload-slot input[type="file"] {
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
  width: 100%;
}
.upload-slot button.secondary {
  width: 100%;
  margin-top: 0;
  background: #1f2937;
  color: #f3f4f6;
  border: 1px solid #1f2937;
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.upload-slot button.secondary:hover:not(:disabled) { background: #111827; }
.upload-slot button.secondary:disabled { opacity: 0.6; cursor: default; }
.upload-status {
  margin: 0.55rem 0 0 0;
  font-size: 0.82rem;
  min-height: 1.1em;
}
.upload-status .ok  { color: #166534; }
.upload-status .err { color: #b91c1c; }
.upload-status .muted { color: #64748b; }
