/*
 * Client portal. Matches the firm's invoice letterhead
 * (src/financialDocumentRenderer.js): the firm monogram, Georgia headings,
 * gold rules and the deep green accent.
 */
:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 17px;
  color: #171915;
  --ink: #171915;
  --muted: #545b56;
  --line: #ded8cc;
  --surface: #ffffff;
  --canvas: #fbfaf7;
  --brand: #193f34;
  --brand-dark: #12302a;
  --gold: #b79458;
  --gold-text: #7d5f2c;
  --gold-soft: #fbf7ed;
  --danger: #9d241e;
  --serif: Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }
/* Elements with their own display (buttons, the identity) must still honour hidden. */
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--canvas); display: flex; flex-direction: column; }
button, input { font: inherit; }
a { color: var(--brand); }
h1 { margin: 0; font-family: var(--serif); font-size: clamp(1.6rem, 4vw, 2rem); font-weight: 400; line-height: 1.2; letter-spacing: 0.01em; }
h2 { margin: 0; font-family: var(--serif); font-size: 1.1rem; font-weight: 700; }
p { line-height: 1.5; }

/* ------------------------------------------------------------ letterhead */
.portal-header { background: var(--surface); border-bottom: 2px solid var(--gold); }
.portal-header-inner {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.portal-brand { flex: none; display: inline-flex; align-items: center; gap: 16px; min-width: 0; color: var(--ink); text-decoration: none; }
/* The firm logo already spells out the firm name; the label names the portal. */
.portal-logo { flex: none; display: block; width: auto; height: 58px; }
.portal-brand-label { padding-left: 16px; border-left: 1px solid var(--gold); color: var(--gold-text); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; line-height: 1.6; text-transform: uppercase; white-space: nowrap; }
/* The session side gives way first: a long email is cut short with an ellipsis. */
.portal-session { flex: 1 1 auto; display: flex; justify-content: flex-end; align-items: center; gap: 16px; min-width: 0; }
.portal-session .button { flex: none; }
.portal-identity { min-width: 0; overflow: hidden; color: var(--muted); font-size: 0.82rem; text-overflow: ellipsis; white-space: nowrap; }

.portal-shell { width: min(1040px, calc(100% - 32px)); margin: 40px auto 56px; flex: 1; }
.portal-footer { padding: 20px 16px; border-top: 1px solid var(--line); color: var(--muted); font: italic 0.8rem/1.5 var(--serif); text-align: center; }
.portal-footer p { margin: 0; }

/* ------------------------------------------------------------ forms */
.panel { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: 3px; padding: clamp(20px, 4vw, 36px); }
.panel h1 { margin-bottom: 10px; }
.sign-in-panel { max-width: 560px; margin: 4vh auto 0; }
.eyebrow { margin: 0 0 8px; color: var(--gold-text); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
form { display: grid; gap: 10px; margin-top: 22px; }
label { font-weight: 700; font-size: 0.9rem; }
input { min-height: 48px; border: 1px solid #a8a296; border-radius: 3px; padding: 10px 14px; color: var(--ink); background: var(--surface); }
input:focus { outline: 3px solid rgba(25, 63, 52, 0.2); border-color: var(--brand); }
.button { min-height: 44px; border-radius: 3px; border: 1px solid transparent; padding: 9px 18px; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; }
.button-primary { background: var(--brand); color: #ffffff; }
.button-primary:hover { background: var(--brand-dark); }
.button-secondary { background: var(--surface); color: var(--brand); border-color: var(--brand); }
.button-secondary:hover { background: var(--gold-soft); }
.button:disabled { opacity: 0.6; cursor: wait; }
.message { min-height: 26px; color: var(--muted); }
.message.error { color: var(--danger); }

/* ------------------------------------------------------------ page heading */
.page-heading { margin-bottom: 28px; }
.page-heading h1 { overflow-wrap: anywhere; }
.page-heading::after { content: ''; display: block; width: 96px; height: 3px; margin-top: 14px; background: var(--gold); }
.page-heading p { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.back-link { display: inline-block; margin-bottom: 14px; font-size: 0.85rem; font-weight: 700; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

/* ------------------------------------------------------------ sections */
/* Each section sits on its own white sheet, so balances, matters and each
   document list read as separate blocks on the page. */
.sheet { margin: 0 0 28px; padding: 16px 22px 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.section-title { padding-bottom: 8px; border-bottom: 2px solid var(--gold); font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; }
/* Amounts use the sans face: Georgia draws old-style figures on macOS. */
.balance-summary dd, .matter-card .balance strong { font-family: Arial, Helvetica, sans-serif; font-weight: 700; font-variant-numeric: lining-nums tabular-nums; }

/* ------------------------------------------------------------ balances */
.balance-summary { padding-bottom: 14px; }
.balance-summary dl { display: flex; flex-wrap: wrap; gap: 0 56px; margin: 0; }
.balance-summary div { padding: 14px 0 4px; }
.balance-summary dt { color: var(--gold-text); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap; }
.balance-summary dd { margin: 4px 0 0; font-size: 1.45rem; }
.balance-date { margin: 8px 0 0; color: var(--muted); font: italic 0.82rem/1.4 var(--serif); }
.note { margin: 0 0 28px; padding: 12px 16px; border-left: 3px solid var(--gold); background: var(--gold-soft); }

/* ------------------------------------------------------------ matters */
.matter-list { display: grid; }
.matter-card { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.matter-card:last-child { border-bottom: 0; }
.matter-card:hover { background: var(--gold-soft); }
.matter-card h3 { margin: 0; font-family: var(--serif); font-weight: 700; color: var(--brand); font-size: 1.1rem; }
.matter-card:hover h3 { text-decoration: underline; }
.matter-card .balance { text-align: right; color: var(--muted); font-size: 0.82rem; }
.matter-card .balance span { display: block; }
.matter-card .balance strong { display: block; color: var(--ink); font-size: 1.05rem; line-height: 1.4; }

/* ------------------------------------------------------------ documents */
/* Invoices and receipts sit side by side in two equal columns, each on its
   own sheet; they stack only on a phone. Long filenames wrap inside their
   column. */
.document-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; align-items: start; }
.document-table { width: 100%; border-collapse: collapse; }
.document-table th, .document-table td { padding: 10px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.document-table tr:last-child td { border-bottom: 0; }
/* Column headings stay for screen readers; the section title already labels the list. */
.document-table thead th { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.document-table td:first-child { overflow-wrap: anywhere; }
.document-table small { margin-inline-start: 6px; color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.document-table .actions { width: 1%; padding-inline-start: 24px; white-space: nowrap; text-align: right; }
.document-table .actions a { font-weight: 700; text-decoration: none; }
.document-table .actions a:hover { text-decoration: underline; }
.document-table .actions a + a { margin-inline-start: 16px; }
.empty { margin: 0; padding: 12px 4px; color: var(--muted); font: italic 0.9rem var(--serif); }

/* ------------------------------------------------------------ notifications */
/* A small tracker to the right of the matter: when each notice was sent. */
.matter-layout { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; gap: 0 24px; align-items: start; }
.matter-main { min-width: 0; }
.notice-tracker { padding-bottom: 10px; }
.notice-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.notice-table th { padding: 8px 4px 4px; border-bottom: 1px solid var(--line); color: var(--muted); font: 400 0.75rem var(--serif); text-align: left; }
.notice-table td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.notice-table tr:last-child td { border-bottom: 0; }
.notice-table td:first-child { white-space: nowrap; }

@media (max-width: 900px) {
  .matter-layout { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  /* The logo shrinks to the room left beside Sign out instead of overflowing. */
  .portal-brand { flex: 1 1 auto; flex-direction: column; align-items: flex-start; gap: 4px; }
  .portal-logo { width: 100%; max-width: 185px; height: auto; }
  .portal-session { flex: none; }
  .portal-brand-label { padding-left: 0; border-left: 0; font-size: 0.62rem; }
  .portal-identity { display: none; }
  .portal-shell { margin-top: 28px; }
  .sheet { padding: 14px 16px 4px; }
  .balance-summary dl { gap: 0 32px; }
  .balance-summary dd { font-size: 1.25rem; }
  .matter-card { grid-template-columns: 1fr; gap: 8px; }
  .matter-card .balance { text-align: left; }
  .document-table small { display: block; margin: 2px 0 0; }
  .document-groups { grid-template-columns: 1fr; }
}
