/* Respect the HTML hidden attribute even when component rules set display:grid/flex. */
[hidden] { display: none !important; }

:root {
  --ink: #16313b;
  --muted: #60747c;
  --line: #dce6e7;
  --paper: #ffffff;
  --wash: #f3f7f7;
  --ocean: #0b5361;
  --ocean-light: #1b7380;
  --sand: #d49c61;
  --good: #26705c;
  --due: #9a512f;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--wash);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 85% -10%, #d7ebea 0, transparent 34rem), var(--wash); }
button, select { font: inherit; }
a { color: inherit; }
.portal-header { display: flex; align-items: center; justify-content: space-between; min-height: 76px; padding: 12px max(22px, calc((100vw - 1180px) / 2)); color: white; background: #123f4d; box-shadow: 0 3px 18px rgba(9, 43, 53, .16); }
.portal-brand { display: flex; gap: 12px; align-items: center; color: white; text-decoration: none; }
.portal-brand strong, .portal-brand small { display: block; }
.portal-brand strong { font-size: 1rem; }
.portal-brand small { margin-top: 2px; color: #c4dade; font-size: .78rem; }
.portal-logo-wrap { display: grid; width: 68px; height: 50px; place-items: center; padding: 4px; border-radius: 10px; background: white; }
.portal-logo-wrap img { display: block; width: 100%; height: 100%; object-fit: contain; }
.viewer { max-width: 42vw; overflow: hidden; color: #d7e5e7; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
main { width: min(1180px, calc(100% - 36px)); margin: 0 auto; padding: 38px 0 64px; }
.eyebrow { margin: 0 0 6px; color: var(--ocean-light); font-size: .76rem; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
h1, h2, h3, h4, p { margin-top: 0; }
h1, h2 { font-family: Newsreader, serif; }
h1 { margin-bottom: 0; font-size: clamp(2rem, 5vw, 3.3rem); line-height: 1; }
h2 { margin-bottom: 0; font-size: 1.55rem; }
.loading-card, .access-card { display: grid; min-height: 340px; place-items: center; align-content: center; gap: 14px; padding: 40px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.9); text-align: center; box-shadow: 0 18px 55px rgba(20, 62, 73, .08); }
.loading-ring { width: 34px; height: 34px; border: 3px solid #cbdcde; border-top-color: var(--ocean); border-radius: 50%; animation: spin .8s linear infinite; }
.lock-icon { display: grid; width: 56px; height: 56px; place-items: center; border-radius: 50%; color: var(--ocean); background: #e2eeee; font-size: 1.7rem; }
.access-card p:not(.eyebrow) { max-width: 520px; margin-bottom: 0; color: var(--muted); font-size: 1rem; line-height: 1.6; }
.access-actions { display: grid; justify-items: center; gap: 12px; margin-top: 6px; }
.access-button { display: inline-flex; align-items: center; min-height: 46px; padding: 0 20px; border-radius: 11px; color: white; background: var(--ocean); font-weight: 700; text-decoration: none; box-shadow: 0 8px 20px rgba(11, 83, 97, .18); }
.access-link { color: var(--ocean); font-size: .9rem; font-weight: 700; }
.portal-print-brand { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.welcome-row { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.portal-actions { display: flex; align-items: end; gap: 10px; }
.trip-picker { display: grid; gap: 5px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.trip-picker select, .print-button { min-height: 44px; border: 1px solid #cbdadb; border-radius: 10px; background: white; }
.trip-picker select { min-width: 260px; padding: 0 38px 0 12px; color: var(--ink); }
.print-button { padding: 0 16px; color: white; border-color: var(--ocean); background: var(--ocean); font-weight: 700; cursor: pointer; }
.advisor-preview { margin-bottom: 16px; padding: 11px 14px; border: 1px solid #d5b483; border-radius: 10px; color: #704f25; background: #fff8e8; font-size: .86rem; }
.trip-hero { position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(130px, .65fr)); gap: 18px; padding: 28px; border-radius: 22px; color: white; background: linear-gradient(128deg, #0b4655, #0e6977 62%, #21818a); box-shadow: 0 18px 48px rgba(10, 73, 87, .18); }
.trip-hero::after { position: absolute; right: -70px; bottom: -110px; width: 280px; height: 280px; border: 1px solid rgba(255,255,255,.15); border-radius: 50%; content: ""; box-shadow: 0 0 0 46px rgba(255,255,255,.04), 0 0 0 92px rgba(255,255,255,.03); }
.hero-main, .hero-stat { position: relative; z-index: 1; }
.hero-main p { margin-bottom: 7px; color: #cce0e2; }
.hero-main h2 { font-size: clamp(1.8rem, 4vw, 2.7rem); }
.hero-stat { align-self: center; padding-left: 16px; border-left: 1px solid rgba(255,255,255,.2); }
.hero-stat span, .hero-stat strong { display: block; }
.hero-stat span { margin-bottom: 6px; color: #bad5d7; font-size: .76rem; font-weight: 700; text-transform: uppercase; }
.hero-stat strong { font-size: .95rem; line-height: 1.4; }
.portal-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; margin-top: 18px; }
.main-column, .side-column { display: grid; gap: 18px; }
.portal-panel { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 8px 26px rgba(18, 58, 68, .055); }
.panel-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.panel-heading > span { color: var(--muted); font-size: .82rem; }
.timeline { display: grid; }
.portal-day { display: grid; grid-template-columns: 115px minmax(0, 1fr); gap: 18px; padding: 22px; border-bottom: 1px solid #e8eeee; }
.portal-day:last-child { border-bottom: 0; }
.day-date strong, .day-date span { display: block; }
.day-date strong { margin-bottom: 5px; font-size: 1rem; }
.day-date span { color: var(--muted); font-size: .82rem; }
.day-items { display: grid; gap: 10px; }
.timeline-item { padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: #fbfdfd; }
.item-header { display: flex; justify-content: space-between; gap: 14px; }
.item-type { display: inline-flex; padding: 4px 8px; border-radius: 7px; color: #315d66; background: #e5f0f0; font-size: .72rem; font-weight: 700; }
.timeline-item h3 { margin: 7px 0 0; font-size: 1rem; }
.item-time { color: var(--ocean); font-size: .86rem; white-space: nowrap; }
.day-files { display: grid; gap: 8px; padding: 13px; border: 1px solid #cfe0df; border-radius: 12px; background: #f3f9f8; }
.day-files > strong { color: #355c64; font-size: .82rem; }
.day-files a { display: flex; justify-content: space-between; gap: 12px; color: var(--ocean); font-size: .82rem; font-weight: 700; text-decoration: none; }
.day-files a span:first-child { overflow-wrap: anywhere; }
.item-meta, .item-detail, .item-note { margin: 10px 0 0; color: var(--muted); font-size: .9rem; line-height: 1.55; white-space: pre-line; }
.item-note { padding: 10px 12px; border-radius: 9px; color: #3b5f65; background: #edf5f4; }
.item-link { display: inline-block; margin-top: 10px; color: var(--ocean); font-size: .88rem; font-weight: 700; }
.payment-lines { padding: 10px 20px 18px; }
.payment-line { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid #edf1f1; color: var(--muted); font-size: .9rem; }
.payment-line strong { color: var(--ink); }
.payment-line.balance { margin-top: 4px; padding-top: 15px; border-bottom: 0; font-size: 1rem; }
.payment-line.balance strong { color: var(--due); font-size: 1.2rem; }
.payment-line.balance.paid strong { color: var(--good); }
.payment-due { margin: 0 20px 20px; padding: 12px; border-radius: 10px; color: #684c2f; background: #fff6e8; font-size: .86rem; line-height: 1.4; }
.stripe-payment-action { display: grid; gap: 8px; margin: 0 20px 20px; }
.stripe-payment-action a { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: 0 18px; border-radius: 11px; color: #fff; background: var(--ocean); font-weight: 700; text-decoration: none; }
.stripe-payment-action a:hover { background: var(--ocean-dark); }
.stripe-payment-action small { color: var(--muted); font-size: .78rem; line-height: 1.4; }
.client-agreements { display: grid; gap: 10px; padding: 16px; }
.client-agreement-card { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfdfd; }
.client-agreement-card.pending { border-color: #dcc79f; background: #fffaf0; }
.client-agreement-card.signed { border-color: #bfddd1; background: #f4fbf7; }
.client-agreement-heading { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.client-agreement-heading strong { font-size: .9rem; }
.client-agreement-heading span { padding: 4px 7px; border-radius: 999px; color: #6b5a3e; background: #f4ead7; font-size: .68rem; font-weight: 800; white-space: nowrap; }
.client-agreement-card.signed .client-agreement-heading span { color: #23634f; background: #dff0e8; }
.client-agreement-card p { margin: 10px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.client-agreement-card a { display: flex; align-items: center; justify-content: center; min-height: 40px; margin-top: 12px; border-radius: 9px; color: white; background: var(--ocean); font-size: .8rem; font-weight: 700; text-decoration: none; }
.secure-actions { display: grid; gap: 12px; padding: 16px; }
.secure-action-card { padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: #fbfdfd; }
.secure-action-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.secure-kind { display: inline-flex; padding: 4px 7px; border-radius: 7px; color: #315d66; background: #e5f0f0; font-size: .72rem; font-weight: 700; }
.secure-action-card h3 { margin: 7px 0 0; font-size: 1rem; }
.secure-status { display: inline-flex; padding: 5px 8px; border-radius: 999px; color: #6b5a3e; background: #f4ead7; font-size: .72rem; font-weight: 800; white-space: nowrap; }
.secure-status.ready, .secure-status.completed { color: #23634f; background: #dff0e8; }
.secure-status.requested { color: #245d75; background: #dcecf3; }
.secure-status.expired, .secure-status.revoked { color: #7e463a; background: #f6e4df; }
.secure-request-details { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 13px; }
.secure-request-details div { padding: 9px; border-radius: 9px; background: #eef5f4; }
.secure-request-details .secure-wide { grid-column: 1 / -1; }
.secure-request-details span, .secure-request-details strong { display: block; }
.secure-request-details span { color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase; }
.secure-request-details strong { margin-top: 4px; color: var(--ink); font-size: .82rem; line-height: 1.4; }
.secure-action-card > p { margin: 12px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.5; }
.secure-action-card details { margin-top: 12px; padding: 10px 11px; border-radius: 9px; background: #eef5f4; }
.secure-action-card summary { color: var(--ocean); cursor: pointer; font-size: .8rem; font-weight: 700; }
.secure-action-card details p { margin: 9px 0 0; color: var(--muted); font-size: .79rem; line-height: 1.55; white-space: pre-line; }
.secure-action-button { display: flex; align-items: center; justify-content: center; min-height: 42px; margin-top: 13px; padding: 0 14px; border-radius: 10px; color: white; background: var(--ocean); font-size: .86rem; font-weight: 700; text-decoration: none; }
.secure-action-button:hover { background: #073f4b; }
.secure-action-card > small { display: block; margin-top: 10px; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.documents { display: grid; gap: 9px; padding: 16px; }
.document-link { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; text-decoration: none; }
.document-link:hover { border-color: #8fb9bb; background: #f4fafa; }
.document-link strong, .document-link small { display: block; overflow-wrap: anywhere; }
.document-link small { margin-top: 3px; color: var(--muted); font-size: .75rem; }
.empty { padding: 30px 22px; color: var(--muted); text-align: center; font-size: .92rem; line-height: 1.5; }
footer { padding: 24px; color: var(--muted); font-size: .8rem; text-align: center; }
footer a { color: var(--ocean); font-weight: 700; }

@media (max-width: 900px) {
  .trip-hero { grid-template-columns: 1fr 1fr; }
  .hero-main { grid-column: 1 / -1; }
  .portal-grid { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: 1fr 1fr; grid-row: 1; }
}

@media (max-width: 640px) {
  .portal-header { min-height: 66px; padding: 10px 16px; }
  .portal-logo-wrap { width: 58px; height: 43px; }
  .viewer { display: none; }
  main { width: min(100% - 24px, 1180px); padding-top: 25px; }
  .welcome-row, .portal-actions { align-items: stretch; flex-direction: column; }
  .trip-picker select, .print-button { width: 100%; min-width: 0; }
  .trip-hero { grid-template-columns: 1fr; gap: 14px; padding: 22px; }
  .hero-main { grid-column: auto; }
  .hero-stat { padding: 12px 0 0; border-top: 1px solid rgba(255,255,255,.2); border-left: 0; }
  .side-column { grid-template-columns: 1fr; }
  .portal-day { grid-template-columns: 1fr; gap: 12px; padding: 18px; }
  .day-date { display: flex; align-items: baseline; gap: 8px; }
  .panel-heading { padding: 18px; }
  .secure-request-details { grid-template-columns: 1fr; }
  .secure-request-details .secure-wide { grid-column: auto; }
}

@media print {
  @page { size: letter; margin: .55in; }
  body { background: white; }
  .portal-header, .portal-actions, .advisor-preview, footer { display: none !important; }
  .portal-print-brand { display: grid; justify-items: start; gap: 7px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 2px solid #153f52; }
  .portal-print-brand img { width: 185px; height: auto; }
  .portal-print-brand div { display: grid; gap: 3px; font-size: 10px; }
  .portal-print-brand strong { color: #153f52; font-size: 12px; }
  main { width: 100%; padding: 0; }
  .trip-hero { color: #111; background: white; border: 1px solid #aaa; box-shadow: none; }
  .hero-main p, .hero-stat span { color: #444; }
  .hero-stat { border-color: #bbb; }
  .portal-grid { display: block; }
  .portal-panel { margin-top: 14px; break-inside: avoid; box-shadow: none; }
  .side-column { display: block; }
  .side-column .portal-panel { margin-top: 14px; }
  .timeline-item, .portal-day { break-inside: avoid; }
}
