:root {
  --navy: #1e3a5f;
  --navy-deep: #152a45;
  --gold: #d4a017;
  --gold-soft: #f0d78c;
  --sand: #f7f5f0;
  --white: #ffffff;
  --text: #1a1a1a;
  --muted: #5c6570;
  --border: #e2e8f0;
  --success: #0d9488;
  --danger: #c2410c;
  --shadow: 0 4px 24px rgba(30, 58, 95, 0.08);
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--sand);
  line-height: 1.55;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: linear-gradient(160deg, var(--navy-deep), var(--navy) 50%, #2a5080);
}

.login-card {
  width: min(100%, 380px);
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem 1.5rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo {
  border-radius: 50%;
  margin-bottom: 0.75rem;
}

.login-card h2 {
  margin: 0;
  color: var(--navy);
}

.login-lead {
  margin: 0.35rem 0 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-card label {
  display: block;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.85rem;
}

.login-card input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.login-btn {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.65rem 1rem;
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  background: var(--navy);
  color: var(--white);
  cursor: pointer;
}

.login-btn:hover {
  background: var(--navy-deep);
}

.login-error {
  min-height: 1.25rem;
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--danger);
}

.balance-chart-panel {
  margin-bottom: 1.25rem;
}

.ownership-panel {
  margin-bottom: 1.25rem;
}

.ownership-table-wrap {
  overflow-x: auto;
}

table.ownership-table th:nth-child(3),
table.ownership-table th:nth-child(4),
table.ownership-table th:nth-child(5),
table.ownership-table td:nth-child(3),
table.ownership-table td:nth-child(4),
table.ownership-table td:nth-child(5) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.balance-chart-wrap {
  padding: 1rem 1.25rem 0.5rem;
}

.balance-chart-interactive {
  position: relative;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  background: var(--navy-deep);
  color: var(--white);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  box-shadow: var(--shadow);
  white-space: nowrap;
}

.balance-chart-svg {
  cursor: crosshair;
}

.balance-chart-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-caption {
  padding: 0 1.25rem 1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

a {
  color: var(--navy);
}

img {
  max-width: 100%;
  height: auto;
}

/* Header */
.site-header {
  background: linear-gradient(135deg, var(--navy-deep) 0%, var(--navy) 55%, #2a5080 100%);
  color: var(--white);
  padding: 1.25rem 1.5rem 2rem;
  position: relative;
  overflow: visible;
}

.site-header::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 85% 20%, rgba(212, 160, 23, 0.15), transparent 45%);
  pointer-events: none;
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  position: relative;
  z-index: 1;
}

.logo-wrap {
  flex-shrink: 0;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--white);
  padding: 4px;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 1;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* Desktop: true hover — 100% larger (2×) */
@media (hover: hover) and (pointer: fine) {
  .logo-wrap:hover {
    transform: scale(2);
    z-index: 30;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  }
}

/* Touch (iPhone/iPad): no hover — enlarge while finger is down */
@media (hover: none) {
  .logo-wrap:active {
    transform: scale(2);
    z-index: 30;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  }
}

.logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.header-text h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.header-text p {
  margin: 0.35rem 0 0;
  opacity: 0.9;
  font-size: 0.95rem;
}

/* Nav */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.nav-inner a {
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.nav-inner a:hover,
.nav-inner a.active {
  background: var(--navy);
  color: var(--white);
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

section {
  scroll-margin-top: 4rem;
  margin-bottom: 3.5rem;
}

section h2 {
  font-size: 1.5rem;
  color: var(--navy);
  margin: 0 0 0.35rem;
}

.section-lead {
  color: var(--muted);
  margin: 0 0 1.5rem;
  max-width: 52ch;
}

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.stat-card .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.stat-card .value {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--navy);
  margin-top: 0.35rem;
}

.stat-card .sub {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.panel {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
}

.panel-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--navy);
}

/* Financial controls */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.filters input,
.filters select {
  font: inherit;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
}

.chip {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: #eef2f7;
  color: var(--navy);
}

.chip.insurance { background: #dbeafe; color: #1e40af; }
.chip.utilities { background: #d1fae5; color: #065f46; }
.chip.dues { background: #fef3c7; color: #92400e; }
.chip.maintenance { background: #fce7f3; color: #9d174d; }
.chip.pest_control { background: #e0e7ff; color: #3730a3; }
.chip.alarm { background: #f3e8ff; color: #6b21a8; }
.chip.fees { background: #f1f5f9; color: #475569; }
.chip.other { background: #f1f5f9; color: #64748b; }

/* Monthly timeline */
.month-strip {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  padding: 1rem 1.25rem;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
}

.month-pill {
  flex: 0 0 auto;
  min-width: 140px;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--white);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.month-pill:hover,
.month-pill.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.25);
}

.month-pill .period {
  font-size: 0.75rem;
  color: var(--muted);
}

.month-pill .end-bal {
  font-weight: 700;
  color: var(--navy);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.month-flows {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.flow-in {
  color: var(--success);
}

.flow-out {
  color: var(--danger);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  padding: 0.75rem 1.25rem 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.legend-item::before {
  content: "";
  display: inline-block;
  width: 1.25rem;
  height: 0.2rem;
  margin-right: 0.35rem;
  vertical-align: middle;
  border-radius: 2px;
}

.legend-balance::before {
  background: #1e3a5f;
  height: 0.25rem;
}

.legend-in::before {
  background: #0d9488;
}

.legend-out::before {
  background: #c2410c;
}

.chart-tooltip-multi strong {
  display: block;
  margin-bottom: 0.25rem;
}

.chart-tooltip-multi .tip-in {
  color: #5eead4;
}

.chart-tooltip-multi .tip-out {
  color: #fdba74;
}

/* Transaction table */
.table-wrap {
  max-height: 520px;
  overflow: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table.data-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  text-align: left;
  padding: 0.65rem 1rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  z-index: 2;
}

table.data-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}

table.data-table tr:hover td {
  background: #fafbfc;
}

.amount-w { color: var(--danger); font-variant-numeric: tabular-nums; }
.amount-d { color: var(--success); font-variant-numeric: tabular-nums; }
.amount-b { font-weight: 600; font-variant-numeric: tabular-nums; }

.desc-cell {
  max-width: 320px;
}

.pdf-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--navy);
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  background: #eef2f7;
}

.pdf-link:hover {
  background: var(--gold-soft);
}

.pdf-link-unavailable {
  opacity: 0.55;
  cursor: help;
  background: #e2e8f0;
  color: var(--muted);
}

.pdf-link-unavailable:hover {
  background: #e2e8f0;
}

/* Minutes */
.minutes-accordion-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.minutes-accordion,
.collapse-section {
  overflow: hidden;
}

.minutes-accordion > summary,
.collapse-section > summary.collapse-summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-weight: 600;
  color: var(--navy);
  user-select: none;
}

.minutes-accordion > summary::-webkit-details-marker,
.collapse-section > summary::-webkit-details-marker {
  display: none;
}

.minutes-accordion > summary::after,
.collapse-section > summary.collapse-summary::after {
  content: "+";
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 8px;
  background: #eef2f7;
  color: var(--navy);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  line-height: 1;
}

.minutes-accordion[open] > summary::after,
.collapse-section[open] > summary.collapse-summary::after {
  content: "−";
  background: var(--navy);
  color: var(--white);
}

.minutes-summary-hint,
.collapse-hint {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

.minutes-accordion[open] .minutes-summary-hint,
.collapse-section[open] .collapse-hint {
  display: none;
}

.collapse-body {
  border-top: 1px solid var(--border);
}

.collapse-body .doc-list li:first-child {
  border-top: none;
}

.stmt-archive {
  margin-top: 1rem;
}

/* Checking account activity — desktop: normal panel header; mobile: collapsible summary */
@media (min-width: 641px) {
  .financial-activity-details > summary.financial-activity-summary {
    display: none;
  }

  .financial-activity-details .financial-activity-body {
    border-top: none;
  }
}

.financial-activity-title-desktop {
  display: none;
}

@media (min-width: 641px) {
  .financial-activity-title-desktop {
    display: block;
  }
}

.empty-hint {
  margin: 0;
  padding: 1rem 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.minutes-doc-body {
  padding: 0 1.5rem 1.25rem;
  border-top: 1px solid var(--border);
}

.minutes-pdf-link {
  margin-top: 1rem;
}

.insurance-contact-card {
  margin-bottom: 1rem;
}

.insurance-contact-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.insurance-contact-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--navy);
}

.insurance-contact-body {
  padding: 1.1rem 1.25rem 1.25rem;
  font-size: 0.925rem;
  line-height: 1.5;
}

.insurance-contact-name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--navy);
}

.insurance-contact-title {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.insurance-contact-company {
  margin: 0.75rem 0 0;
  font-weight: 600;
  color: var(--navy-deep);
}

.insurance-contact-line {
  margin: 0.15rem 0 0;
  color: #334155;
}

.insurance-contact-phones {
  margin-top: 0.75rem;
}

.insurance-contact-phones p {
  margin: 0.25rem 0 0;
}

.contact-label {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.insurance-policy-list {
  margin-top: 0;
}

.contractors-panel {
  overflow: hidden;
}

.contractors-table-wrap {
  overflow-x: auto;
}

table.contractors-table td {
  vertical-align: top;
  font-size: 0.875rem;
}

.contractor-name {
  font-weight: 600;
  color: var(--navy);
}

table.contractors-table td:nth-child(3) {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.minutes-section {
  margin-bottom: 1.25rem;
  padding-top: 1rem;
}

.minutes-section:first-child {
  padding-top: 1.25rem;
}

.minutes-section h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--navy-deep);
}

.minutes-section p {
  margin: 0;
  white-space: pre-wrap;
  font-size: 0.9rem;
  color: #334155;
}

/* Insurance & invoices */
.doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.doc-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.doc-list li:last-child {
  border-bottom: none;
}

.doc-meta h4 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
}

.doc-meta p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.footer-note {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 2rem 1rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

.loading {
  text-align: center;
  padding: 4rem;
  color: var(--muted);
}

.policy-detail-mobile {
  display: none;
  margin: 0.5rem 0 0;
}

.policy-detail-desktop {
  margin: 0;
}

@media (max-width: 640px) {
  .header-inner {
    flex-direction: column;
    text-align: center;
  }

  /* —— Checking account activity —— */
  .financial-activity-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }

  .financial-activity-filters {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .financial-activity-filters input,
  .financial-activity-filters select {
    width: 100%;
    min-height: 2.75rem;
    font-size: 16px;
  }

  .financial-activity-filters .chip {
    align-self: flex-start;
  }

  .month-strip {
    padding: 0.75rem 1rem;
  }

  .month-pill {
    min-width: 118px;
  }

  /* One page scroll on touch — no inner scroll boxes */
  .table-wrap {
    max-height: none !important;
    overflow: visible !important;
    -webkit-overflow-scrolling: auto;
  }

  .panel.financial-activity-panel {
    overflow: visible;
  }

  .activity-table-wrap {
    padding: 0 0 0.5rem;
  }

  table.data-table th {
    position: static;
  }

  .mobile-card-table thead {
    display: none;
  }

  .mobile-card-table tbody tr {
    display: block;
    margin: 0.65rem 0.85rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fafbfc;
  }

  .mobile-card-table tbody tr:hover td {
    background: transparent;
  }

  .mobile-card-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border: none;
    font-size: 0.875rem;
  }

  .mobile-card-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    flex: 0 0 5.5rem;
    padding-top: 0.1rem;
  }

  .mobile-card-table tbody td.desc-cell {
    flex-direction: column;
    align-items: stretch;
  }

  .mobile-card-table tbody td.desc-cell::before {
    margin-bottom: 0.15rem;
  }

  .mobile-card-table tbody td.source-cell {
    flex-direction: column;
    align-items: stretch;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--border);
    margin-top: 0.25rem;
  }

  .mobile-card-table tbody td.source-cell::before {
    flex: none;
  }

  .mobile-card-table tbody td.source-cell .pdf-link {
    width: 100%;
    justify-content: center;
    margin-top: 0.25rem;
  }

  /* —— Insurance policies —— */
  .policy-detail-desktop {
    display: none;
  }

  .policy-detail-mobile {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.35rem 0.75rem;
    font-size: 0.875rem;
  }

  .policy-detail-mobile-fallback {
    display: block;
    margin: 0.5rem 0 0;
    font-size: 0.875rem;
    color: var(--muted);
  }

  .policy-detail-mobile dt {
    margin: 0;
    font-weight: 600;
    color: var(--muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .policy-detail-mobile dd {
    margin: 0;
    color: #334155;
    word-break: break-word;
  }

  .insurance-policy-list .insurance-policy-item {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .insurance-policy-list .insurance-policy-item .pdf-link {
    width: 100%;
    justify-content: center;
  }

  .insurance-contact-header {
    flex-direction: column;
    align-items: flex-start;
  }

  /* —— Contractors —— */
  .contractors-table-wrap {
    overflow: visible;
  }

  .contractors-table tbody td.contractor-contact {
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
  }

  .contractors-table tbody td.contractor-contact div {
    width: 100%;
    text-align: right;
    word-break: break-word;
  }

  .contractors-table tbody td.contractor-name {
    font-size: 1rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px dashed var(--border);
    margin-bottom: 0.15rem;
  }

  .contractors-table tbody td.contractor-name::before {
    flex: 0 0 4.5rem;
  }
}
