/* Family finance dashboard.
   Priorities, in order: legibility, obvious controls, calm surfaces. */

:root {
  font-size: 20px;

  --paper: #f6f4ef;
  --surface: #ffffff;
  --ink: #16212c;
  --ink-soft: #47535f;
  --border: #cfc8bb;
  --border-strong: #a9a093;

  --accent: #14584a;
  --accent-dark: #0d3f34;
  --accent-tint: #e7f0ed;

  --notice: #fbf1d5;
  --notice-border: #b4881a;
  --danger: #8d2311;
  --danger-tint: #fbeeeb;
  --focus: #14508f;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(22, 33, 44, 0.06);
}

html[data-text-size="large"] { font-size: 24px; }
html[data-text-size="largest"] { font-size: 28px; }

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  width: 100%;
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 1rem;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 0.75rem 1rem;
  z-index: 10;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* ---------- header and footer ---------- */

.site-header {
  background: var(--ink);
  color: #fff;
  border-bottom: 4px solid var(--accent);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}

.site-title {
  color: #fff;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  padding: 0.35rem 0;
}
.site-title:hover { text-decoration: underline; }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.1rem;
}

.site-nav a,
.site-nav .link-button {
  color: #f3f1ec;
  font-size: 0.95rem;
  text-decoration: none;
  padding: 0.5rem 0.15rem;
  display: inline-block;
  border-bottom: 3px solid transparent;
}
.site-nav a:hover,
.site-nav .link-button:hover { border-bottom-color: #fff; }
.site-nav a[aria-current="page"] {
  border-bottom-color: #fff;
  font-weight: 700;
}

.link-button {
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
}
.signout { margin: 0; display: inline; }

.site-footer {
  margin-top: 3rem;
  border-top: 2px solid var(--border);
  background: var(--surface);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-top: 1rem;
  padding-bottom: 1.5rem;
}
.footer-note {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin: 0;
}

.text-size { display: flex; align-items: center; gap: 0.4rem; }
.text-size-label {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-right: 0.25rem;
}
.size-button {
  min-width: 2.6rem;
  min-height: 2.6rem;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.size-button.size-large { font-size: 1.05rem; }
.size-button.size-largest { font-size: 1.3rem; }
.size-button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

/* ---------- typography ---------- */

main { padding-top: 1.75rem; }

h1 {
  font-size: 1.9rem;
  line-height: 1.2;
  margin: 0 0 1rem;
}
h2 { font-size: 1.3rem; margin: 0 0 0.75rem; }
h3 { font-size: 1.1rem; margin: 0 0 0.5rem; }

p { margin: 0 0 1rem; }

.lead { font-size: 1.05rem; color: var(--ink-soft); }
.muted { color: var(--ink-soft); font-weight: 400; }
.breadcrumb { margin-bottom: 0.75rem; }
.subhead { color: var(--ink-soft); margin-bottom: 1.5rem; }

a { color: #0f4a7a; }
a:hover { color: #0a3557; }

:where(a, button, input, select, textarea):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--border);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head-amount {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.card-head-note {
  display: block;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--ink-soft);
}
.card-link { margin-top: 0.9rem; margin-bottom: 0; font-size: 0.9rem; }

.total-card {
  background: var(--accent-tint);
  border-color: var(--accent);
  text-align: center;
}
.total-label {
  margin: 0;
  font-size: 0.95rem;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.total-amount {
  margin: 0.35rem 0 0.35rem;
  font-size: 3rem;
  line-height: 1.1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-dark);
}
.total-card-small .total-amount { font-size: 2.3rem; }
.total-note { margin: 0; color: var(--ink-soft); font-size: 0.9rem; }
.total-card .actions {
  margin-top: 1rem;
  margin-bottom: 0;
  justify-content: center;
}

.notice {
  background: var(--notice);
  border-color: var(--notice-border);
}
.notice-quiet { background: var(--surface); border-color: var(--border-strong); }
.notice-title { margin: 0 0 0.5rem; font-size: 1.1rem; }
.notice-list { margin: 0; padding-left: 1.4rem; }
.notice-list li { margin-bottom: 0.35rem; }
.notice-inline {
  background: var(--notice);
  border-left: 6px solid var(--notice-border);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
}
.warn-inline { color: var(--danger); font-weight: 600; }

.card-danger { border-color: var(--danger); background: var(--danger-tint); }

.empty-state { text-align: center; }
.empty-state .actions { margin-bottom: 0; }

.summary-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
}

.group-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 3px solid var(--ink);
  font-size: 1.45rem;
}
.group-total { font-variant-numeric: tabular-nums; }

/* ---------- messages ---------- */

.messages { margin-bottom: 1.5rem; }
.message {
  margin: 0 0 0.6rem;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  font-size: 0.95rem;
}
.message-success { border-color: var(--accent); background: var(--accent-tint); }
.message-error { border-color: var(--danger); background: var(--danger-tint); }
.message-info { border-color: var(--notice-border); background: var(--notice); }

/* ---------- tables ---------- */

table {
  width: 100%;
  border-collapse: collapse;
}

.summary th, .summary td {
  padding: 0.55rem 0.25rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
}
.summary tbody:last-child tr:last-child th,
.summary tbody:last-child tr:last-child td { border-bottom: 0; }
.summary .subtotal th, .summary .subtotal td {
  font-weight: 700;
  border-top: 2px solid var(--border-strong);
}
.summary .group-row th {
  padding-top: 1.1rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  border-bottom: 2px solid var(--border-strong);
}
.summary tbody:first-of-type .group-row th { padding-top: 0; }
.summary .indent { padding-left: 0.8rem; }
.summary .kind-row th {
  padding-left: 1.6rem;
  font-weight: 400;
  color: var(--ink-soft);
}
.kind-summary {
  margin-top: 0.9rem;
  padding-top: 0.6rem;
  border-top: 2px solid var(--border);
}

/* Fixed widths so the columns line up from one card to the next. */
.accounts { table-layout: fixed; }
.accounts thead th:nth-child(1) { width: 36%; }
.accounts thead th:nth-child(2) { width: 17%; }
.accounts thead th:nth-child(3) { width: 18%; }
.accounts thead th:nth-child(4) { width: 16%; }
.accounts thead th:nth-child(5) { width: 13%; }

.accounts th, .accounts td {
  padding: 0.7rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.accounts thead th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  border-bottom: 2px solid var(--border-strong);
  padding-bottom: 0.4rem;
}
.accounts tbody tr:last-child th,
.accounts tbody tr:last-child td { border-bottom: 0; }
.accounts th:first-child, .accounts td:first-child { padding-left: 0; }
.accounts th:last-child, .accounts td:last-child { padding-right: 0; }

.account-name { font-weight: 600; }
.account-name a { text-decoration-thickness: 2px; }
.row-note {
  display: block;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--ink-soft);
}
.address-note { white-space: pre-wrap; }
.num { text-align: right; }
.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}
.date-cell { white-space: nowrap; color: var(--ink-soft); font-size: 0.9rem; }
.holding-row th,
.holding-row td {
  font-weight: 400;
  color: var(--ink-soft);
  border-bottom-style: dotted;
}
.holding-name {
  padding-left: 1.25rem;
  font-weight: 400;
}
.kind-group th,
.kind-group td {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  background: var(--paper);
  border-bottom: 2px solid var(--border);
}
.accounts.holdings thead th:nth-child(1) { width: 34%; }
.accounts.holdings thead th:nth-child(2) { width: 16%; }
.accounts.holdings thead th:nth-child(3) { width: 18%; }
.accounts.holdings thead th:nth-child(4) { width: 16%; }
.accounts.holdings thead th:nth-child(5) { width: 16%; }

.row-action { text-align: right; vertical-align: middle; }
.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

/* Two side-by-side buttons need a wider last column than a single Update. */
.accounts-with-pair thead th:nth-child(1) { width: 30%; }
.accounts-with-pair thead th:nth-child(2) { width: 16%; }
.accounts-with-pair thead th:nth-child(3) { width: 12%; }
.accounts-with-pair thead th:nth-child(4) { width: 16%; }
.accounts-with-pair thead th:nth-child(5) { width: 26%; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 2px solid var(--border-strong);
  background: var(--paper);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-gic { border-color: var(--notice-border); background: var(--notice); }
.badge-tfsa, .badge-rrif, .badge-non_registered {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent-dark);
}

.details { margin: 0; }
.details > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.details > div:last-child { border-bottom: 0; }
.details dt { font-weight: 600; min-width: 11rem; }
.details dd { margin: 0; font-variant-numeric: tabular-nums; }
.details-stacked > div { display: block; }
.details-stacked dd { color: var(--ink-soft); }

.notes-text { white-space: pre-wrap; margin: 0; }

/* ---------- forms ---------- */

.field { margin-bottom: 1.25rem; }
.field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
}
.field-hint {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.field-error-text {
  margin: 0.4rem 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--danger);
}

.input {
  width: 100%;
  max-width: 26rem;
  min-height: 3rem;
  padding: 0.6rem 0.7rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: 8px;
}
textarea.input { max-width: 34rem; line-height: 1.5; }
select.input { max-width: 26rem; }
.field-invalid .input { border-color: var(--danger); }

.field-check { margin-bottom: 1.25rem; }
.check-label {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  font-weight: 600;
  cursor: pointer;
}
.checkbox {
  width: 1.5rem;
  height: 1.5rem;
  margin: 0.15rem 0 0;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.fieldset {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1rem 0.25rem;
  margin: 0 0 1.5rem;
}
.fieldset legend {
  padding: 0 0.5rem;
  font-weight: 700;
}

.current-value {
  padding-bottom: 0.9rem;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--border);
}
.current-value strong { font-variant-numeric: tabular-nums; }

/* ---------- buttons ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}
.page-actions { margin-top: 2rem; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.5rem 1.2rem;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: #ece8e0; color: var(--ink); }

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.button-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

.button-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.button-danger:hover { background: #6d1b0d; border-color: #6d1b0d; color: #fff; }

.button-quiet {
  border-color: var(--border-strong);
  color: var(--ink-soft);
  font-weight: 400;
}
.button-quiet:hover { color: var(--ink); }

.button-big { font-size: 1.05rem; min-height: 3.4rem; padding: 0.6rem 1.6rem; }
.button-small { min-height: 2.6rem; padding: 0.35rem 0.9rem; font-size: 0.9rem; }

/* ---------- pages ---------- */

.signin-page { max-width: 30rem; margin: 2rem auto 0; }
.signin-page h1 { text-align: center; }
.signin-page .lead { text-align: center; }

.prose h2 { margin-top: 1.75rem; }
.prose h2:first-child { margin-top: 0; }
.prose ol, .prose ul { padding-left: 1.5rem; }
.prose li { margin-bottom: 0.5rem; }

/* ---------- narrow screens ---------- */

@media (max-width: 48rem) {
  :root { font-size: 19px; }
  h1 { font-size: 1.6rem; }
  .total-amount { font-size: 2.4rem; }
  .total-card-small .total-amount { font-size: 2rem; }

  .accounts thead { display: none; }
  .accounts tbody tr {
    display: block;
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 0.85rem;
    margin-bottom: 0.85rem;
  }
  .accounts tbody th,
  .accounts tbody td {
    display: block;
    border: 0;
    padding: 0.15rem 0;
    text-align: left;
  }
  .accounts tbody td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--ink-soft);
    font-size: 0.85rem;
    font-weight: 400;
  }
  .accounts tbody td.amount {
    font-size: 1.25rem;
    padding-top: 0.35rem;
  }
  .accounts tbody td.row-action {
    text-align: left;
    padding-top: 0.7rem;
  }
  .holding-name { padding-left: 0; }
  .kind-group td:empty,
  .holding-row td:empty { display: none; }
  .row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .details dt { min-width: 0; }
  .details > div { display: block; }
  .button { width: 100%; }
  .button-small { width: auto; }
  .actions { gap: 0.6rem; }
}

/* ---------- printing ---------- */

@media print {
  .site-header, .site-footer, .actions, .row-action, .breadcrumb, .messages {
    display: none !important;
  }
  body { background: #fff; font-size: 12pt; }
  .card { break-inside: avoid; box-shadow: none; }
}
