/* Reunite shared styles: calm, high contrast, large text, phone first. */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #14181f;
  --muted: #47505e;
  --border: #b8c0cc;
  --primary: #0b4f8a;
  --primary-hover: #083c69;
  --primary-text: #ffffff;
  --focus: #ffb000;
  --ok: #17663a;
  --ok-bg: #e5f4ea;
  --bad: #a3231a;
  --bad-bg: #fbe9e7;
  --warn-bg: #fff4d6;
  --warn-border: #b07800;
  --bar-track: #dde2e9;
  --radius: 10px;
  --max: 60rem;
}

* { box-sizing: border-box; }

html { font-size: 112.5%; } /* 18px base */

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.55;
}

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--primary);
  color: var(--primary-text);
  padding: .6rem 1rem;
  border-radius: var(--radius);
  z-index: 10;
}
.skip-link:focus { top: 1rem; }

/* Header and navigation */
.site-header {
  background: var(--header-bg, var(--primary));
  color: var(--primary-text);
}
.site-header .inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: .9rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  align-items: center;
  justify-content: space-between;
}
.brand { font-weight: 700; font-size: 1.15rem; }
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .5rem;
}
.site-nav a {
  color: var(--primary-text);
  text-decoration: none;
  padding: .35rem .6rem;
  border-radius: 6px;
  display: inline-block;
}
.site-nav a:hover { background: var(--primary-hover); }
.site-nav a[aria-current="page"] {
  background: var(--primary-text);
  color: var(--primary);
  font-weight: 700;
}

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}

h1 { font-size: 1.75rem; line-height: 1.25; margin: .5rem 0 .75rem; }
h2 { font-size: 1.35rem; line-height: 1.3; margin: 0 0 .75rem; }
h3 { font-size: 1.1rem; margin: 0 0 .5rem; }
.lead { font-size: 1.1rem; color: var(--muted); margin-top: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 0 0 1.25rem;
}

/* Forms */
.field { margin-bottom: 1rem; }
.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0 1rem;
}
label, legend { display: block; font-weight: 600; margin-bottom: .3rem; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: .9rem; }
.optional { font-weight: 400; color: var(--muted); }

input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: .6rem .7rem;
  min-height: 2.9rem;
}
textarea { min-height: 8rem; resize: vertical; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--bad);
}
.field-error { color: var(--bad); font-weight: 600; font-size: .95rem; margin-top: .25rem; }
.field-error:empty { display: none; }

button, .button {
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  padding: .65rem 1.2rem;
  min-height: 2.9rem;
  cursor: pointer;
  border: 2px solid var(--primary);
  background: var(--primary);
  color: var(--primary-text);
}
button:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button:disabled { opacity: .6; cursor: wait; }
button.secondary { background: var(--surface); color: var(--primary); }
button.secondary:hover { background: #e8eef6; }
button.confirm { background: var(--ok); border-color: var(--ok); }
button.reject { background: var(--surface); color: var(--bad); border-color: var(--bad); }
button.reject:hover { background: var(--bad-bg); }
button.link {
  background: none; border: none; color: var(--primary);
  text-decoration: underline; padding: .2rem .1rem; min-height: 0;
}
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: .5rem; }

/* Messages */
.message {
  border-radius: var(--radius);
  padding: .9rem 1rem;
  margin: 1rem 0 0;
  border-left: 6px solid var(--border);
  background: var(--surface);
}
.message:empty { display: none; }
.message.error { border-color: var(--bad); background: var(--bad-bg); }
.message.success { border-color: var(--ok); background: var(--ok-bg); }
.message ul { margin: .4rem 0 0; padding-left: 1.25rem; }

.report-id {
  display: block;
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: .06em;
  margin: .3rem 0;
}

.status-pill {
  display: inline-block;
  padding: .3rem .8rem;
  border-radius: 999px;
  font-weight: 700;
  border: 2px solid currentColor;
}
.status-searching { color: #3d4a5c; background: #eef1f5; }
.status-under_review, .status-possible_match { color: #7a4f00; background: var(--warn-bg); }
.status-reunited { color: var(--ok); background: var(--ok-bg); }
.status-big { font-size: 1.3rem; padding: .5rem 1.1rem; }

.banner {
  background: var(--warn-bg);
  border: 2px solid var(--warn-border);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}
.banner.sticky { position: sticky; top: 0; z-index: 5; }

.mock-note {
  font-size: .9rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: .4rem .7rem;
  display: inline-block;
}

/* Authority table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .95rem; color: var(--muted); }
tr.selected { background: #e8eef6; }

/* Candidate cards */
.candidate { border-width: 2px; }
.candidate-head {
  display: flex; flex-wrap: wrap; gap: .5rem 1rem;
  align-items: baseline; justify-content: space-between;
}
.score-label { font-size: 1.1rem; font-weight: 700; }
.score-bar {
  height: 1.1rem;
  background: var(--bar-track);
  border-radius: 999px;
  overflow: hidden;
  margin: .4rem 0 1rem;
}
.score-fill { height: 100%; background: var(--primary); border-radius: 999px; }

.reasons { list-style: none; padding: 0; margin: 0 0 1rem; }
.reasons li { display: flex; gap: .6rem; align-items: flex-start; padding: .25rem 0; }
.mark {
  flex: 0 0 1.6rem; height: 1.6rem;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800;
}
.mark.yes { background: var(--ok-bg); color: var(--ok); border: 2px solid var(--ok); }
/* Not matched: neutral grey, not red. A difference is information, not an error. */
.mark.no { background: #eef0f3; color: #5b6573; border: 2px solid #8a94a3; }

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.compare section { background: var(--bg); border-radius: 8px; padding: .8rem; border: 1px solid var(--border); }
.compare dl { margin: 0; }
.compare dt { font-size: .85rem; color: var(--muted); font-weight: 600; margin-top: .45rem; }
.compare dd { margin: 0; overflow-wrap: anywhere; }

/* Platform page */
.bench-row { margin: 1rem 0 1.25rem; }
.bench-label { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .25rem 1rem; font-weight: 600; }
.bench-track { height: 2.2rem; background: var(--bar-track); border-radius: 8px; overflow: hidden; margin-top: .35rem; }
.bench-fill { height: 100%; border-radius: 8px; transition: width .6s ease; }
.bench-fill.on { background: var(--primary); }
.bench-fill.off { background: #6b7686; }
.flow { padding-left: 1.25rem; }
.flow li { margin-bottom: .5rem; }

.hidden { display: none !important; }

.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;
}

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

@media (max-width: 40rem) {
  html { font-size: 106.25%; }
  .compare { grid-template-columns: 1fr; }
  .card { padding: 1rem; }
  .report-id { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .bench-fill { transition: none; }
}

/* Accounts and family */
.auth-card { max-width: 34rem; }
.tabs { display: flex; gap: .5rem; border-bottom: 2px solid var(--border); margin: -.25rem 0 1.25rem; }
.tabs [role="tab"] {
  background: none; color: var(--muted); border: none; border-bottom: 4px solid transparent;
  border-radius: 0; padding: .5rem .8rem; margin-bottom: -2px;
}
.tabs [role="tab"]:hover { background: #e8eef6; }
.tabs [role="tab"][aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }

.member-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
.member-list .card { margin: 0; background: var(--bg); }
.member-list dl { display: grid; grid-template-columns: auto 1fr; gap: .15rem .75rem; margin: .25rem 0 .75rem; }
.member-list dt { color: var(--muted); font-weight: 600; font-size: .9rem; }
.member-list dd { margin: 0; overflow-wrap: anywhere; }
.sub-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }

.plain-fieldset { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
.when-where { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: .75rem; }
.sub-label { font-weight: 400; color: var(--muted); font-size: .9rem; }
@media (max-width: 40rem) {
  .when-where { grid-template-columns: 1fr 1fr; }
  .when-where > :first-child { grid-column: 1 / -1; }
}

/* ---------- Portals ---------- */
/* Authority portal gets its own darker, "internal tool" identity. */
body.portal-authority {
  --header-bg: #18212c;
  --primary: #0f5f56;
  --primary-hover: #0a4740;
  --bg: #eef1f4;
}

.brand { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .6rem; }
.portal-tag {
  font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: .15rem .55rem; border-radius: 999px; border: 1.5px solid currentColor; opacity: .9;
}
.user-menu { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.user-menu .who { font-size: .95rem; }
.site-header button.secondary { min-height: 2.4rem; padding: .35rem .9rem; }

a.button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
a.button:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.button.secondary { background: var(--surface); color: var(--primary); }
a.button.secondary:hover { background: #e8eef6; }

/* ---------- Welcome page ---------- */
.hero { text-align: center; padding: 1.5rem 0 1rem; }
.hero h1 { font-size: 2.2rem; margin-bottom: .5rem; }
.hero .lead { max-width: 38rem; margin: 0 auto; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1.25rem; margin: 1.5rem 0; }
.role-card { display: flex; flex-direction: column; border-width: 2px; margin: 0; }
.role-card .role-icon {
  width: 3rem; height: 3rem; border-radius: 12px; display: grid; place-items: center;
  font-size: 1.5rem; margin-bottom: .75rem;
}
.role-card.family .role-icon { background: #e3eefa; }
.role-card.authority { border-color: #18212c; }
.role-card.authority .role-icon { background: #18212c; color: #fff; }
.role-card ul { padding-left: 1.2rem; margin: .25rem 0 1.25rem; flex: 1; }
.role-card .actions { margin-top: auto; }
.role-card.authority .button { background: #0f5f56; border-color: #0f5f56; }
.role-card.authority .button.secondary { background: var(--surface); color: #0f5f56; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; padding: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.steps li::before {
  content: counter(step); display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem;
  border-radius: 50%; background: var(--primary); color: var(--primary-text); font-weight: 700; margin: 0 .5rem .4rem 0;
}

/* ---------- Login and sign-up pages ---------- */
.auth-shell {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; margin: 1rem auto 0; max-width: 56rem;
  box-shadow: 0 6px 24px rgba(20, 24, 31, .08);
}
.auth-aside { background: var(--header-bg, var(--primary)); color: #fff; padding: 2rem; }
.auth-aside h2 { font-size: 1.5rem; }
.auth-aside p, .auth-aside li { color: #e6ecf3; }
.auth-aside ul { padding-left: 1.2rem; }
.auth-main { padding: 2rem; }
.auth-main h1 { margin-top: 0; }
.auth-switch { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.auth-other { font-size: .95rem; color: var(--muted); }
.restricted {
  display: flex; gap: .6rem; align-items: flex-start; background: #fff4d6; border: 1.5px solid #b07800;
  border-radius: 8px; padding: .6rem .8rem; font-size: .95rem; margin-bottom: 1.25rem; color: #3b2a00;
}

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 4.75rem; }
.pw-toggle {
  position: absolute; right: .35rem; top: 50%; transform: translateY(-50%);
  min-height: 0; padding: .3rem .65rem; background: none; border: none; color: var(--primary); font-size: .95rem;
}
.pw-toggle:hover { background: #e8eef6; }

.check { display: flex; gap: .65rem; align-items: flex-start; font-weight: 400; }
.check input { width: 1.4rem; height: 1.4rem; min-height: 0; margin: .15rem 0 0; flex: 0 0 auto; accent-color: var(--primary); }

.request-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .75rem; }
.request-list li { border: 1px solid var(--border); border-radius: 8px; padding: .8rem 1rem; background: var(--bg); }
.request-list dl { display: grid; grid-template-columns: auto 1fr; gap: .1rem .75rem; margin: .4rem 0 .6rem; }
.request-list dt { color: var(--muted); font-weight: 600; font-size: .9rem; }
.request-list dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 44rem) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { padding: 1.25rem; }
  .auth-aside ul { display: none; }
  .auth-main { padding: 1.25rem; }
  .hero h1 { font-size: 1.7rem; }
}

/* ---------- Brief v2 additions ---------- */
tr.flagged { background: #fff8e6; }
tr.flagged td:first-child { box-shadow: inset 5px 0 0 #b07800; }
.flag-badge {
  display: inline-block; margin-right: .5rem; padding: .05rem .5rem; border-radius: 999px;
  background: #b07800; color: #fff; font-size: .8rem; font-weight: 700; white-space: nowrap;
}

.decision-tag { font-weight: 700; padding: .45rem .8rem; border-radius: 8px; align-self: center; }
.decision-tag.confirmed { background: var(--ok-bg); color: var(--ok); border: 2px solid var(--ok); }
.decision-tag.rejected { background: #eef0f3; color: #47505e; border: 2px solid #8a94a3; }
.candidate.decided-confirmed { border-color: var(--ok); }
.candidate.decided-rejected { opacity: .7; }
.claimed-note, .public-note {
  border-radius: 8px; padding: .5rem .75rem; font-weight: 600; font-size: .95rem; margin: 0 0 .75rem;
}
.claimed-note { background: var(--bad-bg); color: var(--bad); }
.public-note { background: var(--warn-bg); color: #5c4100; }

.demo-panel { border: 2px dashed #7a4fbf; background: #f6f1ff; }

.found-cta {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between;
  border-width: 2px; border-color: #b07800; background: #fffaf0;
}
.found-cta h2 { margin-bottom: .25rem; }
.found-cta p { margin: 0; }
.status-link { text-align: center; font-size: 1.05rem; }

.loading { color: var(--muted); font-style: italic; }
.loading::before {
  content: ""; display: inline-block; width: .9rem; height: .9rem; margin-right: .5rem; vertical-align: -.1rem;
  border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading::before { animation: none; } }

.big-number strong { font-size: 2rem; color: var(--primary); }
.chip-note { background: var(--bg); border-left: 5px solid var(--primary); padding: .6rem .8rem; border-radius: 6px; }
.raw-json {
  background: #14181f; color: #e6ecf3; padding: 1rem; border-radius: 8px; overflow-x: auto;
  font-size: .85rem; line-height: 1.45; white-space: pre;
}
details summary { cursor: pointer; font-weight: 600; color: var(--primary); }

.status-key { display: grid; grid-template-columns: auto 1fr; gap: .75rem 1rem; align-items: center; margin: 0; }
.status-key dd { margin: 0; }
@media (max-width: 40rem) {
  .status-key { grid-template-columns: 1fr; gap: .25rem; }
  .status-key dd { margin-bottom: .75rem; }
}
