@font-face {
  font-family: "Agenda";
  src: url("agenda-thin.otf") format("opentype");
  font-weight: 400 600;
  font-display: swap;
}

@font-face {
  font-family: "Agenda";
  src: url("agenda-bold.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}

:root {
  --green: #3d4f4a;
  --sage: #607770;
  --paper: #f8f6f0;
  --white: #fffefa;
  --warm: #e9e2d7;
  --line: rgba(61, 79, 74, 0.2);
  --muted: #65726e;
}

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

[hidden] { display: none !important; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--green);
  font-family: "Agenda", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.5;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.portal-loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1rem;
  background: var(--paper);
  z-index: 100;
}

.portal-loading img { width: 132px; }
.portal-loading p { margin: 0; color: var(--muted); }

.auth-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(430px, 0.85fr) minmax(500px, 1.15fr);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(520px, 100%);
  margin: 0 auto;
  padding: 4rem clamp(2rem, 5vw, 5rem);
}

.portal-logo { align-self: flex-start; margin-bottom: 5rem; }
.portal-logo img {
  display: block;
  width: 155px;
  filter: brightness(0) saturate(100%) invert(29%) sepia(9%) saturate(827%) hue-rotate(112deg) brightness(91%) contrast(89%);
}

.auth-copy h1,
.dashboard h1,
.dashboard h2 { margin: 0; line-height: 1.12; }

.auth-copy h1 { font-size: clamp(2.25rem, 4vw, 3.25rem); }
.auth-copy p { max-width: 440px; margin: 1rem 0 2.4rem; color: var(--muted); font-size: 1.15rem; }

.login-form { display: grid; gap: 0.55rem; }
.login-form label { margin-top: 0.65rem; font-weight: 700; }

.login-form input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--green);
  border-radius: 0;
  background: transparent;
  color: var(--green);
  padding: 0.8rem 0;
  outline: none;
}

.login-form input:focus { border-bottom-width: 2px; }

.primary-button,
.secondary-button,
.preview-button {
  min-height: 48px;
  border: 1px solid var(--green);
  border-radius: 2px;
  padding: 0.75rem 1.3rem;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.primary-button { background: var(--green); color: var(--white); font-weight: 700; }
.secondary-button { background: transparent; color: var(--green); }
.primary-button:hover, .preview-button:hover { background: #2f403b; }
.secondary-button:hover { background: rgba(61, 79, 74, 0.08); }
.primary-button:active, .secondary-button:active, .preview-button:active { transform: translateY(1px); }
.primary-button:disabled {
  border-color: #aeb5b2;
  background: #aeb5b2;
  color: #ffffff;
  cursor: wait;
}
.login-form .primary-button { margin-top: 1rem; }

.text-button,
.quiet-link {
  width: fit-content;
  border: 0;
  border-bottom: 1px solid currentColor;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--sage);
  cursor: pointer;
}

.text-button { margin: 0.55rem auto 0; }
.form-message { display: none; margin: 0.75rem 0 0; }
.form-message:not(:empty) {
  display: block;
  border-left: 3px solid #8a3f36;
  padding: 0.85rem 1rem;
  background: rgba(138, 63, 54, 0.08);
  color: #71362f;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.45;
}
.form-message.loading {
  border-left-color: var(--sage);
  background: rgba(96, 119, 112, 0.09);
  color: var(--green);
}
.form-message.success {
  border-left-color: var(--green);
  background: rgba(61, 79, 74, 0.1);
  color: var(--green);
}
.text-button:disabled { cursor: wait; opacity: 0.72; }

.document-upload {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.25rem 1.5rem;
  margin-top: 1.8rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}
.document-upload div { display: grid; }
.document-upload strong { font-size: 1.18rem; }
.document-upload small { color: var(--muted); font-size: 1.02rem; }
.document-upload .secondary-button { grid-column: 2; grid-row: 1 / span 2; }
.upload-status { grid-column: 1 / -1; min-height: 1.5rem; color: var(--muted); font-size: 1rem; }
.upload-status.error { color: #8a3f36; }
.upload-status.success { color: var(--green); }

.preview-button {
  width: 100%;
  margin-top: 1.25rem;
  background: var(--sage);
  border-color: var(--sage);
  color: white;
}

.auth-help { margin-top: auto; padding-top: 3rem; color: var(--muted); font-size: 0.9rem; }
.auth-help p { margin: 0 0 0.65rem; }
.auth-image {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(61,79,74,0.12), rgba(61,79,74,0)),
    url("accompaniment-hero-coastal.png") center / cover no-repeat;
}

.portal-header {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 104px;
  padding: 1rem clamp(1.5rem, 4vw, 4.5rem);
  border-bottom: 1px solid var(--line);
  background: rgba(248, 246, 240, 0.94);
}

.portal-brand {
  justify-self: start;
}
.portal-header-logo { display: block; }
.portal-header-logo img {
  display: block;
  width: 122px;
  filter: brightness(0) saturate(100%) invert(29%) sepia(9%) saturate(827%) hue-rotate(112deg) brightness(91%) contrast(89%);
}
.portal-name { font-weight: 700; }

.account-toggle {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  border: 0;
  background: none;
  color: var(--green);
  cursor: pointer;
}

.account-toggle > span:first-child {
  display: grid;
  width: 38px;
  aspect-ratio: 1;
  place-content: center;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: 0.82rem;
  font-weight: 700;
}

.account-menu {
  position: absolute;
  top: 78px;
  right: clamp(1.5rem, 4vw, 4.5rem);
  width: 270px;
  padding: 1.1rem;
  border: 1px solid var(--line);
  background: var(--white);
  z-index: 20;
}

.account-menu span { display: block; overflow-wrap: anywhere; color: var(--muted); font-size: 0.9rem; }
.account-menu button { display: block; margin-top: 1rem; border: 0; border-bottom: 1px solid currentColor; padding: 0; background: none; color: var(--green); cursor: pointer; }

.invite-dialog {
  width: min(520px, calc(100% - 2rem));
  border: 0;
  border-radius: 0;
  padding: 0;
  background: var(--paper);
  color: var(--green);
  box-shadow: 0 24px 80px rgba(31, 44, 40, 0.24);
}

.invite-dialog::backdrop { background: rgba(31, 44, 40, 0.52); }
.invite-dialog form { position: relative; display: grid; gap: 0.65rem; padding: clamp(2rem, 6vw, 3.5rem); }
.invite-dialog h2 { margin: 0; font-size: 2.1rem; line-height: 1.1; }
.invite-dialog p { margin: 0 0 1rem; color: var(--muted); }
.invite-dialog label { margin-top: 0.5rem; font-weight: 700; }
.invite-dialog input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--green);
  border-radius: 0;
  padding: 0.8rem 0;
  background: transparent;
  color: var(--green);
  outline: none;
}
.invite-dialog input:focus { border-bottom-width: 2px; }
.invite-dialog .primary-button { margin-top: 0.6rem; }
.invite-dialog .form-message { margin: 0.5rem 0 0; }
.dialog-close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  border: 0;
  padding: 0;
  background: none;
  color: var(--green);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.access-dialog { width: min(680px, calc(100% - 2rem)); max-height: min(760px, calc(100vh - 2rem)); }
.access-dialog-content { position: relative; padding: clamp(2rem, 6vw, 3.5rem); }
.access-dialog-content > h2 { margin: 0; font-size: 2.1rem; line-height: 1.1; }
.access-dialog-content > p { margin: 0.7rem 0 1.8rem; color: var(--muted); }
.access-list { display: grid; gap: 0.55rem; margin-top: 1rem; }
.client-list-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 2rem;
}
.client-list-heading h3 { margin: 0; font-size: 1.2rem; }
.client-list-heading span { color: var(--muted); }
.client-list { display: grid; gap: 0.55rem; margin-top: 0.4rem; }
.client-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0.95rem;
  background: rgba(96, 119, 112, 0.08);
}
.client-entry strong,
.client-entry small { display: block; overflow-wrap: anywhere; }
.client-status { margin-top: 0.2rem; font-size: 0.9rem; }
.client-status.invited { color: var(--muted); }
.client-status.accepted { color: var(--sage); font-weight: 700; }
.client-entry button {
  border: 0;
  border-bottom: 1px solid currentColor;
  padding: 0;
  background: transparent;
  color: var(--sage);
  cursor: pointer;
}
.history-action {
  border: 0;
  border-bottom: 1px solid currentColor;
  padding: 0;
  background: transparent;
  color: var(--sage);
  cursor: pointer;
}

.dashboard { width: min(1180px, calc(100% - 3rem)); margin: 0 auto; padding: 4.5rem 0; }

.welcome-section {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 3rem;
}

.welcome-section h1 { font-size: clamp(2.35rem, 5vw, 4.25rem); }
.welcome-section p { margin: 0.8rem 0 0; color: var(--muted); font-size: 1.2rem; }
.preview-notice { padding: 0.3rem 0.6rem; border: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }

.next-appointment {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: clamp(1.3rem, 3vw, 3rem);
  padding: clamp(1.6rem, 3vw, 2.4rem) 0;
  border-top: 2px solid var(--green);
  border-bottom: 1px solid var(--line);
}

.appointment-date {
  min-width: 90px;
  padding-right: clamp(1rem, 2vw, 2rem);
  border-right: 1px solid var(--line);
  text-align: center;
}
.appointment-date span { display: block; font-size: 3rem; font-weight: 700; line-height: 0.9; }
.appointment-date small { font-size: 1rem; }
.appointment-details h2 { font-size: 1.15rem; }
.appointment-details p { margin: 0.25rem 0 0; color: var(--muted); }
.appointment-details .appointment-time { color: var(--green); font-size: 1.5rem; font-weight: 700; }
.appointment-actions { display: flex; gap: 0.7rem; }

.history-panel { margin-top: 1.2rem; }
.history-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1.1rem;
  background: rgba(96, 119, 112, 0.09);
  color: var(--green);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.history-panel summary::-webkit-details-marker { display: none; }
.history-panel summary::after { content: "+"; margin-left: auto; color: var(--sage); font-size: 1.25rem; }
.history-panel[open] > summary::after { content: "−"; }
.history-panel[open] {
  background: rgba(96, 119, 112, 0.055);
}
.history-panel[open] > summary { background: rgba(96, 119, 112, 0.11); }
.history-panel > .history-list,
.history-panel > .history-groups,
.history-panel > .communications-list {
  padding: 0.85rem 1.1rem 1.1rem 1.35rem;
}
.history-panel > .history-list > .history-row { padding-right: 0; padding-left: 0; background: transparent; }
.upcoming-panel > summary {
  background: rgba(96, 119, 112, 0.15);
}
.upcoming-panel > summary::after { color: var(--green); }
.history-count {
  min-width: 1.7rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 400;
  text-align: right;
}
.history-list { display: grid; gap: 0.65rem; padding: 1rem 0 0; }
.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.25rem;
  padding: 0.8rem 1rem;
  background: rgba(255, 254, 250, 0.65);
}
.history-row strong,
.history-row small { display: block; }
.history-row small { margin-top: 0.15rem; color: var(--muted); font-size: 0.98rem; }
.file-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.file-status {
  grid-column: 1 / -1;
  margin: 0;
  color: #8f332d !important;
}
.history-empty { margin: 0; padding: 0.6rem 1rem; color: var(--muted); }
.section-history { margin-top: 1.8rem; }
.history-groups { display: grid; gap: 1.5rem; padding-top: 1.2rem; }
.history-groups h3 { margin: 0; font-size: 1.1rem; }
.history-groups .history-list { padding-top: 0.55rem; }
.communications-list { display: grid; gap: 0.65rem; padding-top: 1rem; }
.recent-communications { padding-top: 0; }
.recent-communications .history-empty { padding-left: 0; }
.communication-entry { background: rgba(255, 254, 250, 0.65); }
.communication-entry > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.25rem;
  padding: 0.85rem 1rem;
  background: transparent;
  font-weight: 400;
  cursor: pointer;
  list-style: none;
}
.communication-entry > summary::-webkit-details-marker { display: none; }
.history-panel .communication-entry > summary::after { content: none; }
.communication-entry > summary strong { display: block; color: var(--green); }
.communication-entry > summary small { display: block; margin-top: 0.15rem; color: var(--muted); font-size: 0.98rem; }
.communication-entry > summary .communication-toggle { color: var(--sage); font-weight: 700; }
.communication-entry > summary .communication-toggle::before { content: "Read"; }
.communication-entry[open] > summary .communication-toggle::before { content: "Close"; }
.communication-content {
  margin: 0;
  padding: 0.2rem 1rem 1rem;
  color: var(--text);
  line-height: 1.65;
  white-space: pre-wrap;
}

.dashboard-message { min-height: 1.5rem; margin: 0.9rem 0 0; color: var(--sage); text-align: right; }
.dashboard-grid {
  display: block;
  width: min(860px, 100%);
  margin-top: 4rem;
}

.dashboard-column { display: grid; align-content: start; gap: 4rem; }

.portal-section {
  min-width: 0;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.section-heading h2, .service-section h2, .help-section h2 { font-size: 1.8rem; }
.section-heading span { color: var(--muted); font-size: 1.05rem; }

.case-heading-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.case-heading-row h3 { margin: 0; color: var(--green); font-size: 1.35rem; }
.case-status { color: var(--muted); font-size: 0.98rem; }
.case-progress-copy { display: flex; align-items: baseline; gap: 0.6rem; margin-top: 1.4rem; }
.case-progress-copy strong { color: var(--green); font-size: 2.3rem; line-height: 1; }
.case-progress-copy span { color: var(--muted); font-size: 1.05rem; }
.case-progress-track { height: 8px; margin-top: 0.8rem; overflow: hidden; background: rgba(96, 119, 112, 0.14); }
.case-progress-track span { display: block; height: 100%; background: var(--sage); }
.case-meta { display: flex; flex-wrap: wrap; gap: 0.5rem 1.6rem; margin: 1rem 0 0; color: var(--muted); }
.case-meta span { font-size: 0.98rem; }

.row-action { color: var(--sage); font-size: 1.05rem; white-space: nowrap; }
.quiet-link { margin-top: 1.5rem; }

.compact-summary {
  display: grid;
  gap: 1.1rem;
}

.forms-count-label { margin: 0; color: var(--muted); font-size: 1.08rem; }
.forms-count-label strong { color: var(--green); }

.summary-action {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--green);
  text-align: left;
  cursor: pointer;
}

.summary-action strong { display: block; font-size: 1.25rem; }
.summary-action small { display: block; margin-top: 0.25rem; color: var(--muted); font-size: 1.05rem; }
.forms-list { display: grid; gap: 1.25rem; }
.forms-list .summary-action { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }

.invoice-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 0.15rem 1rem;
}

.invoice-label { color: var(--muted); font-size: 1.08rem; }
.invoice-total { grid-column: 1 / -1; font-size: 2.65rem; line-height: 1.1; }
.invoice-summary small { color: var(--muted); font-size: 1.05rem; }

.invoice-action {
  border: 0;
  border-bottom: 1px solid currentColor;
  padding: 0;
  background: transparent;
  color: var(--sage);
  font-size: 1.05rem;
  cursor: pointer;
}

.empty-state {
  display: flex;
  min-height: 94px;
  align-items: center;
  gap: 1.15rem;
}

.empty-state strong,
.empty-state small { display: block; }

.empty-state strong { font-size: 1.25rem; }
.empty-state small { margin-top: 0.25rem; color: var(--muted); font-size: 1.05rem; }

.empty-symbol {
  min-width: 58px;
  color: var(--sage);
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1;
}

.empty-symbol--money { font-size: 2.5rem; letter-spacing: -0.08em; }
.service-section,
.help-section {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: clamp(2.5rem, 6vw, 6rem);
  margin-top: 5rem;
  padding-top: 2rem;
  border-top: 2px solid var(--green);
}

.service-section p, .help-section p { max-width: 460px; margin: 0.7rem 0 0; color: var(--muted); font-size: 1.08rem; }
.service-section dl { margin: 0; }
.service-section dl div { display: flex; justify-content: space-between; gap: 2rem; padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
.service-section dt { color: var(--muted); }
.service-section dd { margin: 0; text-align: right; font-weight: 700; }
.help-section { border-top-width: 1px; }
.help-links { display: flex; flex-direction: column; align-items: flex-start; gap: 0.55rem; }
.help-links a, .help-links span { font-size: 1.08rem; }
.help-links a { text-underline-offset: 0.2em; }

.portal-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem clamp(1.5rem, 4vw, 4.5rem);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .auth-view { grid-template-columns: 1fr; }
  .auth-panel { min-height: 100vh; }
  .auth-image { display: none; }
  .next-appointment { grid-template-columns: auto 1fr; }
  .appointment-actions { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .dashboard-grid, .service-section, .help-section { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  body { font-size: 17px; }
  .portal-header { grid-template-columns: 1fr auto; min-height: 84px; padding: 0.8rem 1rem; }
  .portal-name { display: none; }
  .portal-header-logo img { width: 105px; }
  .account-toggle > span:last-child { display: none; }
  .account-menu { top: 70px; right: 1rem; }
  .dashboard { width: min(100% - 2rem, 1180px); padding: 3rem 0; }
  .welcome-section { align-items: flex-start; flex-direction: column; gap: 1rem; }
  .next-appointment { grid-template-columns: 58px 1fr; gap: 1rem; }
  .appointment-date { min-width: 54px; }
  .appointment-date { padding-right: 0.8rem; }
  .appointment-date span { font-size: 2.4rem; }
  .appointment-details .appointment-time { font-size: 1.25rem; }
  .appointment-actions { display: grid; width: 100%; }
  .dashboard-grid { gap: 3.5rem; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 0.2rem; }
  .compact-summary { gap: 1rem; }
  .forms-list .summary-action { grid-template-columns: 1fr; gap: 0.35rem; }
  .forms-list .row-action { grid-column: 1; }
  .service-section dl div { display: grid; gap: 0.1rem; }
  .service-section dd { text-align: left; }
  .document-upload { grid-template-columns: 1fr; }
  .document-upload .secondary-button { grid-column: 1; grid-row: auto; margin-top: 0.8rem; }
  .access-form-row { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 1fr; gap: 0.55rem; }
  .history-row .history-action { width: fit-content; }
  .client-entry { grid-template-columns: 1fr; }
  .client-entry button { width: fit-content; }
  .communication-entry > summary { grid-template-columns: 1fr auto; gap: 0.7rem; }
  .portal-footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
